contract SharkCove is ERC721Enumerable, Ownable, PaymentSplitter {

    using Strings for uint256;

    uint256 private _price = 0.05 ether;

    string public _baseTokenURI = '';

    string public SHARK_PROVENANCE = '';

    uint256 public MAX_TOKENS_PER_TRANSACTION = 20;

    uint256 public MAX_SUPPLY = 10000;

    uint256 public RESERVED_SUPPLY = 200;

    bool public _paused = true;

    string public LICENSE_TEXT = ""; // IT IS WHAT IT SAYS

    bool licenseLocked = false; // TEAM CAN'T EDIT THE LICENSE AFTER THIS GETS TRUE

    mapping(uint => string) private _owners;

    event licenseisLocked(string _licenseText);

    // Withdrawal addresses
    address t1 = 0x5a6F0489f0bfcD21889D26189C218a455612148F;
    address t2 = 0xda73C4DFa2F04B189A7f8EafB586501b4D0B73dC;

    address[] addressList = [t1, t2];
    uint256[] shareList = [60, 40];

    constructor()
    ERC721("The Shark Cove", "SHARK")
    PaymentSplitter(addressList, shareList)  {}

    function mint(uint256 count) public payable {
        uint256 supply = totalSupply();
        require( !_paused,                                      "Sale paused" );
        require( block.timestamp >= 1629151200,                 "Sale has not started yet" );
        require( count <= MAX_TOKENS_PER_TRANSACTION,           "You can mint a maximum of 20 SHARKs per transaction" );
        require( supply + count <= MAX_SUPPLY - RESERVED_SUPPLY,"Exceeds maximum SHARK supply" );
        require( msg.value >= _price * count,                   "Ether sent is not correct" );

        for(uint256 i; i < count; i++){
            _safeMint( msg.sender, supply + i );
        }
    }

    function airdrop(address wallet, uint256 count) public onlyOwner {
        require(count <= RESERVED_SUPPLY, "Exceeds maximum reserved SHARK supply");
        
        uint256 supply = totalSupply();
        
        for(uint256 i; i < count; i++){
            _safeMint(wallet, supply + i );
        }
        
        RESERVED_SUPPLY -= count;
    }

    // Just in case Eth does some crazy stuff
    function setPrice(uint256 _newPrice) public onlyOwner {
        _price = _newPrice;
    }

    function _baseURI() internal view virtual override returns (string memory) {
        return _baseTokenURI;
    }

    function setBaseURI(string memory baseURI) public onlyOwner {
        _baseTokenURI = baseURI;
    }

    function getPrice() public view returns (uint256){
        return _price;
    }

    function flipSaleState() public onlyOwner {
        _paused = !_paused;
    }

    function setProvenanceHash(string memory provenanceHash) public onlyOwner {
        SHARK_PROVENANCE = provenanceHash;
    }
    
    // Returns the license for tokens
    function tokenLicense(uint _id) public view returns(string memory) {
        require(_id < totalSupply(), "Invalid ID");
        return LICENSE_TEXT;
    }
    
    // Locks the license to prevent further changes 
    function lockLicense() public onlyOwner {
        licenseLocked =  true;
        emit licenseisLocked(LICENSE_TEXT);
    }
    
    // Change the license
    function changeLicense(string memory _license) public onlyOwner {
        require(licenseLocked == false, "License already locked");
        LICENSE_TEXT = _license;
    }

    function walletOfOwner(address _owner) public view returns(uint256[] memory) {
        uint256 tokenCount = balanceOf(_owner);

        uint256[] memory tokensId = new uint256[](tokenCount);
        for(uint256 i; i < tokenCount; i++){
            tokensId[i] = tokenOfOwnerByIndex(_owner, i);
        }
        return tokensId;
    }
}
function changeLicense(string memory _license) public onlyOwner {
    require(licenseLocked == false, "License already locked");
    LICENSE_TEXT = _license;
}

// Change the license