contract FKUP is ERC721, ERC721Enumerable, Ownable {
  using Strings for uint256;
  bool public _isWhiteListSaleActive = false;
  bool public _isSaleActive = false;

  // Constants
  uint256 constant public MAX_SUPPLY = 10000;
  uint256 public mintPrice = 0.04 ether;
  
  


  string private _baseURIExtended;


  

  event TokenMinted(uint256 supply);

  constructor() ERC721('Fuckyoupolitician', 'FKUP') {}

//ok
  function filpSaleActive() public onlyOwner {
    _isSaleActive = !_isSaleActive;
  }

//ok
  function setMintPrice(uint256 _mintPrice) public onlyOwner {
    mintPrice = _mintPrice;
  }


//ok
  function withdraw(address to) public onlyOwner {
    uint256 balance = address(this).balance;
    payable(to).transfer(balance);
  }
//ok
  function preserveMint(uint numFKUPs, address to) public onlyOwner {
    require(totalSupply() + numFKUPs <= MAX_SUPPLY, 'Preserve mint would exceed max supply');
    _mintFKUP(numFKUPs, to);
    emit TokenMinted(totalSupply());
  }
//ok
  function getTotalSupply() public view returns (uint256) {
    return totalSupply();
  }
//ok
  function getFKUPByOwner(address _owner) public view returns (uint256[] memory) {
    uint256 tokenCount = balanceOf(_owner);
    uint256[] memory tokenIds = new uint256[](tokenCount);
    for (uint256 i; i < tokenCount; i++) {
      tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
    }
    return tokenIds;
  }

//ok
  function mintFKUPs(uint numFKUPs) public payable {
    require(_isSaleActive, 'Sale must be active to mint FKUPs');
    require(totalSupply() + numFKUPs <= MAX_SUPPLY, 'Sale would exceed max supply');
    require(numFKUPs * mintPrice <= msg.value, 'Not enough ether sent');
    _mintFKUP(numFKUPs, msg.sender);
    emit TokenMinted(totalSupply());
  }
 

//ok
  function _mintFKUP(uint256 numFKUPs, address recipient) internal {
    uint256 supply = totalSupply();
    for (uint256 i = 0; i < numFKUPs; i++) {
      _safeMint(recipient, supply + i);
    }
  }
//ok
  function setBaseURI(string memory baseURI_) external onlyOwner {
    _baseURIExtended = baseURI_;
  }
//ok
  function _baseURI() internal view virtual override returns (string memory) {
    return _baseURIExtended;
  }
//ok
  function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
    require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
    require(tokenId < MAX_SUPPLY,'Something wrong');
        return string(abi.encodePacked(_baseURI(), tokenId.toString(), ".json"));
    }

  function _beforeTokenTransfer (
    address from,
    address to,
    uint256 tokenId
  ) internal override(ERC721, ERC721Enumerable) {
    super._beforeTokenTransfer(from, to, tokenId);
  }
//ok
  function supportsInterface(bytes4 interfaceId)
    public
    view
    override(ERC721, ERC721Enumerable)
    returns (bool)
  {
    return super.supportsInterface(interfaceId);
  }
}
//import '@openzeppelin/contracts/access/Ownable.sol';
//import '@openzeppelin/contracts/token/ERC721/ERC721.sol';
//import '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol';
function _mintFKUP(uint256 numFKUPs, address recipient) internal {
  uint256 supply = totalSupply();
  for (uint256 i = 0; i < numFKUPs; i++) {
    _safeMint(recipient, supply + i);
  }
}

//ok