// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/*
  _____ __  __ ____   _____ 
 |_   _|  \/  |  _ \ / ____|
   | | | \  / | |_) | |     
   | | | |\/| |  _ <| |     
  _| |_| |  | | |_) | |____ 
 |_____|_|  |_|____/ \_____|

https://imbobnft.com

*/


abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }
    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
abstract contract Ownable is Context {
    address private _owner;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    constructor() {
        _transferOwnership(_msgSender());
    }
    function owner() public view virtual returns (address) {
        return _owner;
    }
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
abstract contract ReentrancyGuard {
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;
    uint256 private _status;
    constructor() {
        _status = _NOT_ENTERED;
    }
    modifier nonReentrant() {
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
        _status = _ENTERED;
        _;
        _status = _NOT_ENTERED;
    }
}
interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}
interface IERC165 {
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
interface IERC721 is IERC165 {
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
    function balanceOf(address owner) external view returns (uint256 balance);
    function ownerOf(uint256 tokenId) external view returns (address owner);
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;
    function approve(address to, uint256 tokenId) external;
    function getApproved(uint256 tokenId) external view returns (address operator);
    function setApprovalForAll(address operator, bool _approved) external;
    function isApprovedForAll(address owner, address operator) external view returns (bool);
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;
}
interface IERC721Receiver {
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}
interface IERC721Metadata is IERC721 {
    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function tokenURI(uint256 tokenId) external view returns (string memory);
}
interface IERC721Enumerable is IERC721 {
    function totalSupply() external view returns (uint256);
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
    function tokenByIndex(uint256 index) external view returns (uint256);
}
library Address {
    function isContract(address account) internal view returns (bool) {
        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");
        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            if (returndata.length > 0) {
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
    function toString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}
abstract contract ERC165 is IERC165 {
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
contract ERC721A is
  Context,
  ERC165,
  IERC721,
  IERC721Metadata,
  IERC721Enumerable
{
  using Address for address;
  using Strings for uint256;
  struct TokenOwnership {
    address addr;
    uint64 startTimestamp;
  }
  struct AddressData {
    uint128 balance;
    uint128 numberMinted;
  }
  uint256 private currentIndex = 0;
  uint256 internal immutable collectionSize;
  uint256 internal immutable maxBatchSize;
  string private _name;
  string private _symbol;
  mapping(uint256 => TokenOwnership) private _ownerships;
  mapping(address => AddressData) private _addressData;
  mapping(uint256 => address) private _tokenApprovals;
  mapping(address => mapping(address => bool)) private _operatorApprovals;
  constructor(
    string memory name_,
    string memory symbol_,
    uint256 maxBatchSize_,
    uint256 collectionSize_
  ) {
    require(
      collectionSize_ > 0,
      "ERC721A: collection must have a nonzero supply"
    );
    require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero");
    _name = name_;
    _symbol = symbol_;
    maxBatchSize = maxBatchSize_;
    collectionSize = collectionSize_;
  }
  function totalSupply() public view override returns (uint256) {
    return currentIndex;
  }
  function tokenByIndex(uint256 index) public view override returns (uint256) {
    require(index < totalSupply(), "ERC721A: global index out of bounds");
    return index;
  }
  function tokenOfOwnerByIndex(address owner, uint256 index)
    public
    view
    override
    returns (uint256)
  {
    require(index < balanceOf(owner), "ERC721A: owner index out of bounds");
    uint256 numMintedSoFar = totalSupply();
    uint256 tokenIdsIdx = 0;
    address currOwnershipAddr = address(0);
    for (uint256 i = 0; i < numMintedSoFar; i++) {
      TokenOwnership memory ownership = _ownerships[i];
      if (ownership.addr != address(0)) {
        currOwnershipAddr = ownership.addr;
      }
      if (currOwnershipAddr == owner) {
        if (tokenIdsIdx == index) {
          return i;
        }
        tokenIdsIdx++;
      }
    }
    revert("ERC721A: unable to get token of owner by index");
  }
  function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(ERC165, IERC165)
    returns (bool)
  {
    return
      interfaceId == type(IERC721).interfaceId ||
      interfaceId == type(IERC721Metadata).interfaceId ||
      interfaceId == type(IERC721Enumerable).interfaceId ||
      super.supportsInterface(interfaceId);
  }
  function balanceOf(address owner) public view override returns (uint256) {
    require(owner != address(0), "ERC721A: balance query for the zero address");
    return uint256(_addressData[owner].balance);
  }
  function _numberMinted(address owner) internal view returns (uint256) {
    require(
      owner != address(0),
      "ERC721A: number minted query for the zero address"
    );
    return uint256(_addressData[owner].numberMinted);
  }
  function ownershipOf(uint256 tokenId)
    internal
    view
    returns (TokenOwnership memory)
  {
    require(_exists(tokenId), "ERC721A: owner query for nonexistent token");
    uint256 lowestTokenToCheck;
    if (tokenId >= maxBatchSize) {
      lowestTokenToCheck = tokenId - maxBatchSize + 1;
    }
    for (uint256 curr = tokenId; curr >= lowestTokenToCheck; curr--) {
      TokenOwnership memory ownership = _ownerships[curr];
      if (ownership.addr != address(0)) {
        return ownership;
      }
    }
    revert("ERC721A: unable to determine the owner of token");
  }
  function ownerOf(uint256 tokenId) public view override returns (address) {
    return ownershipOf(tokenId).addr;
  }
  function name() public view virtual override returns (string memory) {
    return _name;
  }
  function symbol() public view virtual override returns (string memory) {
    return _symbol;
  }
  function tokenURI(uint256 tokenId)
    public
    view
    virtual
    override
    returns (string memory)
  {
    require(
      _exists(tokenId),
      "ERC721Metadata: URI query for nonexistent token"
    );
    string memory baseURI = _baseURI();
    return
      bytes(baseURI).length > 0
        ? string(abi.encodePacked(baseURI, tokenId.toString()))
        : "";
  }
  function _baseURI() internal view virtual returns (string memory) {
    return "";
  }
  function approve(address to, uint256 tokenId) public override {
    address owner = ERC721A.ownerOf(tokenId);
    require(to != owner, "ERC721A: approval to current owner");
    require(
      _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
      "ERC721A: approve caller is not owner nor approved for all"
    );
    _approve(to, tokenId, owner);
  }
  function getApproved(uint256 tokenId) public view override returns (address) {
    require(_exists(tokenId), "ERC721A: approved query for nonexistent token");
    return _tokenApprovals[tokenId];
  }
  function setApprovalForAll(address operator, bool approved) public override {
    require(operator != _msgSender(), "ERC721A: approve to caller");
    _operatorApprovals[_msgSender()][operator] = approved;
    emit ApprovalForAll(_msgSender(), operator, approved);
  }
  function isApprovedForAll(address owner, address operator)
    public
    view
    virtual
    override
    returns (bool)
  {
    return _operatorApprovals[owner][operator];
  }
  function transferFrom(
    address from,
    address to,
    uint256 tokenId
  ) public override {
    _transfer(from, to, tokenId);
  }
  function safeTransferFrom(
    address from,
    address to,
    uint256 tokenId
  ) public override {
    safeTransferFrom(from, to, tokenId, "");
  }
  function safeTransferFrom(
    address from,
    address to,
    uint256 tokenId,
    bytes memory _data
  ) public override {
    _transfer(from, to, tokenId);
    require(
      _checkOnERC721Received(from, to, tokenId, _data),
      "ERC721A: transfer to non ERC721Receiver implementer"
    );
  }
  function _exists(uint256 tokenId) internal view returns (bool) {
    return tokenId < currentIndex;
  }
  function _safeMint(address to, uint256 quantity) internal {
    _safeMint(to, quantity, "");
  }
  function _safeMint(
    address to,
    uint256 quantity,
    bytes memory _data
  ) internal {
    uint256 startTokenId = currentIndex;
    require(to != address(0), "ERC721A: mint to the zero address");
    require(!_exists(startTokenId), "ERC721A: token already minted");
    require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high");
    _beforeTokenTransfers(address(0), to, startTokenId, quantity);
    AddressData memory addressData = _addressData[to];
    _addressData[to] = AddressData(
      addressData.balance + uint128(quantity),
      addressData.numberMinted + uint128(quantity)
    );
    _ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp));
    uint256 updatedIndex = startTokenId;
    for (uint256 i = 0; i < quantity; i++) {
      emit Transfer(address(0), to, updatedIndex);
      require(
        _checkOnERC721Received(address(0), to, updatedIndex, _data),
        "ERC721A: transfer to non ERC721Receiver implementer"
      );
      updatedIndex++;
    }
    currentIndex = updatedIndex;
    _afterTokenTransfers(address(0), to, startTokenId, quantity);
  }
  function reStake(
    address from,
    address to,
    uint256 _id
  ) internal {
    _beforeTokenTransfers(from, to, _id, 1);
    AddressData memory addressData = _addressData[to];
    _addressData[to] = AddressData(
      addressData.balance + uint128(1),
      addressData.numberMinted + uint128(1)
    );
    _ownerships[_id] = TokenOwnership(to, uint64(block.timestamp));
    emit Transfer(from, to, _id);
    _afterTokenTransfers(from, to, _id, 1);
  }
  function _transfer(
    address from,
    address to,
    uint256 tokenId
  ) private {
    TokenOwnership memory prevOwnership = ownershipOf(tokenId);
    bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
      getApproved(tokenId) == _msgSender() ||
      isApprovedForAll(prevOwnership.addr, _msgSender()));
    require(
      isApprovedOrOwner,
      "ERC721A: transfer caller is not owner nor approved"
    );
    require(
      prevOwnership.addr == from,
      "ERC721A: transfer from incorrect owner"
    );
    require(to != address(0), "ERC721A: transfer to the zero address");
    _beforeTokenTransfers(from, to, tokenId, 1);
    _approve(address(0), tokenId, prevOwnership.addr);
    _addressData[from].balance -= 1;
    _addressData[to].balance += 1;
    _ownerships[tokenId] = TokenOwnership(to, uint64(block.timestamp));
    uint256 nextTokenId = tokenId + 1;
    if (_ownerships[nextTokenId].addr == address(0)) {
      if (_exists(nextTokenId)) {
        _ownerships[nextTokenId] = TokenOwnership(
          prevOwnership.addr,
          prevOwnership.startTimestamp
        );
      }
    }
    emit Transfer(from, to, tokenId);
    _afterTokenTransfers(from, to, tokenId, 1);
  }
  function _approve(
    address to,
    uint256 tokenId,
    address owner
  ) private {
    _tokenApprovals[tokenId] = to;
    emit Approval(owner, to, tokenId);
  }
  uint256 public nextOwnerToExplicitlySet = 0;
  function _setOwnersExplicit(uint256 quantity) internal {
    uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet;
    require(quantity > 0, "quantity must be nonzero");
    uint256 endIndex = oldNextOwnerToSet + quantity - 1;
    if (endIndex > collectionSize - 1) {
      endIndex = collectionSize - 1;
    }
    require(_exists(endIndex), "not enough minted yet for this cleanup");
    for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) {
      if (_ownerships[i].addr == address(0)) {
        TokenOwnership memory ownership = ownershipOf(i);
        _ownerships[i] = TokenOwnership(
          ownership.addr,
          ownership.startTimestamp
        );
      }
    }
    nextOwnerToExplicitlySet = endIndex + 1;
  }
  function _checkOnERC721Received(
    address from,
    address to,
    uint256 tokenId,
    bytes memory _data
  ) private returns (bool) {
    if (to.isContract()) {
      try
        IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data)
      returns (bytes4 retval) {
        return retval == IERC721Receiver(to).onERC721Received.selector;
      } catch (bytes memory reason) {
        if (reason.length == 0) {
          revert("ERC721A: transfer to non ERC721Receiver implementer");
        } else {
          assembly {
            revert(add(32, reason), mload(reason))
          }
        }
      }
    } else {
      return true;
    }
  }
  function _beforeTokenTransfers(
    address from,
    address to,
    uint256 startTokenId,
    uint256 quantity
  ) internal virtual {}
  function _afterTokenTransfers(
    address from,
    address to,
    uint256 startTokenId,
    uint256 quantity
  ) internal virtual {}
}
contract BOB is ERC721A, Ownable, ReentrancyGuard {
    bytes32 whroot;
    bytes32 raroot;
    string public baseTokenURI;
    uint256 public allowlistprice = 0.19 ether;
    uint256 public allowlistmaxmint = 3;
    uint256 public waitlistprice = 0.19 ether;
    uint256 public waitlistmaxmint = 3;
    uint256 public publicprice = 0.25 ether;
    uint256 public publicmaxmint = 10;
    uint256 public collectionsize = 5335;
    uint256 public reservedsize = 335;
    uint256 public stakedmax = 20;
    uint256 public mintpause=1;
    uint256 public allowlistmintopen;
    uint256 public waitlistmintopen;
    uint256 public publicmintopen;
    uint256 public stakingpoolopen;
    mapping(address => uint256) public mintedq;
    mapping(address => uint256[]) public userStakedTokens;
    uint256 public stakedToken;
    struct stakeInfo {
	uint32 epoch;
	uint32 status;
	uint32 tokenId;
	address owner;
    }
    stakeInfo[] public stakeLog;
    struct holderInfo {
	uint32 tokenId;
	address owner;
    }
constructor() ERC721A("IMBC", "BOB",100,5335){}
    function _onlyMinter() private view 
    { 
	require(msg.sender == tx.origin);
    }
    modifier onlyMinter 
    {
	_onlyMinter();
	_;
    }
    function ownerMintOne(address recipient) public onlyOwner returns (uint256) 
    {
	_safeMint(recipient, 1);
	return 1;
    }
    function ownerMintMulti(address recipient,uint256 value) public onlyOwner returns (uint256) 
    {
	_safeMint(recipient, value);
	return 1;
    }
    function calculateq(uint256 ev, uint256 aprice) internal view returns (uint256) 
    {
        uint256 r=ev%aprice;
        require(r==0,"Bad ammount of ETH");
        uint256 a=ev/aprice;
        require(a>0,"Input amount=0");
        require(totalSupply() + a <= collectionsize - reservedsize, "Sold out!" );
        return a;
    }
    function isOwner(uint256 _id, address _address) public view virtual returns (bool) 
    {
	return ownerOf(_id) == _address;
    }
    function createStake(uint256 _id) external payable onlyMinter nonReentrant
    {
	require(stakingpoolopen!=0, "Staking Pool is not open yet!");
        require(ownerOf(_id) == msg.sender,
            "You are not a owner of the NFT"
        );
        require(userStakedTokens[msg.sender].length<stakedmax,"This would exceed the maximum staked NFTs/address!");
	transferFrom(msg.sender, address(this), _id);
	userStakedTokens[msg.sender].push(_id);
	stakedToken++;
	stakeLog.push(stakeInfo({
	    epoch: uint32(block.timestamp),
	    status: uint32(1),
	    tokenId: uint32(_id),
	    owner: address(msg.sender)
	}));
    }
    function unStake(uint256 _id) external payable onlyMinter nonReentrant
    {
	uint256 st=99999;
	uint256 value = userStakedTokens[msg.sender].length;
	if ( value > 0 )
	{
    	    for (uint256 i = 0; i < value; i++) 
	    {
		if ( userStakedTokens[msg.sender][i] == _id )
		{
		    st=i;
		    break;
		}
	    }
	}
        require( st != 99999, "You are not a owner of the staked NFT" );
	reStake(address(this), address(msg.sender), _id );
        userStakedTokens[msg.sender][st] = userStakedTokens[msg.sender][value-1];
	userStakedTokens[msg.sender].pop();
	stakedToken--;
	stakeLog.push(stakeInfo({
	    epoch: uint32(block.timestamp),
	    status: uint32(2),
	    tokenId: uint32(_id),
	    owner: address(msg.sender)
	}));
    }
    function stakedValue(address _address) public view virtual returns (uint32) 
    {
	return uint32(userStakedTokens[_address].length);
    }
    function getStakelog(uint256 from, uint256 value) public view virtual returns (stakeInfo[] memory)  
    {
        stakeInfo[] memory stakeLogRe = new stakeInfo[](value);
        for (uint256 i = 0; i < value; i++) 
	{
	    stakeLogRe[i]=stakeLog[i+from];
	}
	return stakeLogRe;
    }
    function numStakelog() public view virtual returns (uint32)  
    {
	return uint32(stakeLog.length);
    }
    function getStakedTokens(address tokenowner) public view virtual returns(uint256[] memory) 
    {
	require(totalSupply() > 0);
	require(userStakedTokens[tokenowner].length > 0);
	return userStakedTokens[tokenowner];
    }
    function isStaker(uint256 _id, address _address) public view virtual returns (bool) 
    {
	uint256 value = userStakedTokens[_address].length;
	if ( value > 0 )
	{
    	    for (uint256 i = 0; i < value; i++) 
	    {
		if ( userStakedTokens[_address][i] == _id )
		{
		    return true;
		}
	    }
	}
	return false;
    }
    function allowlistMint(bytes32[] memory proof) external payable onlyMinter nonReentrant
    {
	uint256 st;
	bytes32 cHa;
	require(mintpause==0, "Minting is not live yet!");
	require(allowlistmintopen!=0, "Allowlist minting is not open!");
	cHa = keccak256(abi.encodePacked(msg.sender));
    	for (uint256 i = 0; i < proof.length; i++) 
	{
	    bytes32 pEl = proof[i];
    	    if (cHa <= pEl) 
	    {
        	cHa = keccak256(abi.encodePacked(cHa, pEl));
    	    } else {
                cHa = keccak256(abi.encodePacked(pEl, cHa));
    	    }
    	}
	require( cHa==whroot, "You are not eligible for Allowlist mint!" );
        st=calculateq(msg.value,allowlistprice);
        require(mintedq[msg.sender]+st<=allowlistmaxmint,"This would exceed the maximum NFTs/address!");
        mintedq[msg.sender]+=st;
	_safeMint(msg.sender,st);
    }
    function waitlistMint() external payable onlyMinter nonReentrant
    {
	uint256 st;
	require(mintpause==0, "Minting is not live yet!");
	require(waitlistmintopen!=0, "Waitlist minting is not open!");
        st=calculateq(msg.value,waitlistprice);
        require(mintedq[msg.sender]+st<=waitlistmaxmint,"This would exceed the maximum NFTs/address!");
        mintedq[msg.sender]+=st;
	_safeMint(msg.sender,st);
    }
    function publicMint() external payable onlyMinter nonReentrant
    {
	uint256 st;
	require(mintpause==0, "Minting is not live yet!");
	require(publicmintopen!=0, "Public minting is not open!");
        st=calculateq(msg.value,publicprice);
        require(mintedq[msg.sender]+st<=publicmaxmint,"This would exceed the maximum NFTs/address!");
        mintedq[msg.sender]+=st;
	_safeMint(msg.sender,st);
    }
    function _baseURI() internal view virtual override returns (string memory) 
    {
	return baseTokenURI;
    }
    function setBaseTokenURI(string memory _b) public onlyOwner 
    {
	baseTokenURI = _b;
    }
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory)
    {
	string memory currentBaseURI = _baseURI();
	return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, Strings.toString(tokenId), "")) : "";
    }
    function _sendmoney(address _address, uint256 _amount) private 
    {
        (bool success, ) = _address.call{value: _amount}("");
	require(success, "Transfer failed.");
    }
    function withdraw() public onlyOwner 
    {
	_sendmoney(owner(),address(this).balance);
    }
    function withdrawto(address payable to, uint256 amount) public onlyOwner 
    {
	require( address(this).balance >= amount, "Insufficient balance to withdraw");
	_sendmoney(to,amount);
    }
    function setallowlistprice(uint256 _p) external onlyOwner 
    {
	allowlistprice=_p;
    }
    function setallowlistmaxmint(uint256 _p) external onlyOwner 
    {
	allowlistmaxmint=_p;
    }
    function setwaitlistprice(uint256 _p) external onlyOwner 
    {
	waitlistprice=_p;
    }
    function setwaitlistmaxmint(uint256 _p) external onlyOwner 
    {
	waitlistmaxmint=_p;
    }
    function setpublicprice(uint256 _p) external onlyOwner 
    {
	waitlistprice=_p;
    }
    function setpublicmaxmint(uint256 _p) external onlyOwner 
    {
	publicmaxmint=_p;
    }
    function setreserveditem(uint256 _p) external onlyOwner 
    {
	reservedsize=_p;
    }
    function setcollectionsize(uint256 _p) external onlyOwner 
    {
	collectionsize=_p;
    }
    function setstakedmax(uint256 _p) external onlyOwner 
    {
	stakedmax=_p;
    }
    function setmintpause(uint256 _st) external onlyOwner
    {
        mintpause = _st;
    }
    function setallowlistmintopen(uint256 _st) external onlyOwner
    {
        allowlistmintopen = _st;
    }
    function setwaitlistmintopen(uint256 _st) external onlyOwner
    {
        waitlistmintopen = _st;
    }
    function setpublicmintopen(uint256 _st) external onlyOwner
    {
        publicmintopen = _st;
    }
    function setstakingpoolopen(uint256 _st) external onlyOwner
    {
        stakingpoolopen = _st;
    }
    function getmintstatus(address minter) public view virtual returns (string memory) 
    {
	string memory o1 = string(abi.encodePacked(
	"mintpause:",Strings.toString(mintpause),
	";allowlist:",Strings.toString(allowlistmintopen), 
	";waitlist:",Strings.toString(waitlistmintopen), 
	";public:",Strings.toString(publicmintopen), 
	";staking:",Strings.toString(stakingpoolopen), 
	";allowlistprice:",Strings.toString(allowlistprice), 
	";allowlistmaxmint:",Strings.toString(allowlistmaxmint),
	";stakedtoken:",Strings.toString(stakedToken)
	));
	string memory o2 = string(abi.encodePacked(
	";waitlistprice:",Strings.toString(waitlistprice), 
	";waitlistmaxmint:",Strings.toString(waitlistmaxmint),
	";publicprice:",Strings.toString(publicprice), 
	";publicmaxmint:",Strings.toString(publicmaxmint),
	";totalsupply:", Strings.toString(totalSupply()), 
	";reservedsize:", Strings.toString(reservedsize), 
	";collectionsize:", Strings.toString(collectionsize),
	";minted:", Strings.toString(mintedq[minter]) 
	));
	string memory outstring = string(abi.encodePacked(o1,o2));
	return outstring;
    }
    function getholdertokens(address _owner,uint256 from, uint256 value) public view returns (uint[] memory) 
    {
        uint[] memory _tokensOfOwner = new uint[](value);
        uint i;
        for (i=0;i<value;i++)
	{
            _tokensOfOwner[i] = ERC721A.tokenOfOwnerByIndex(_owner, i+from);
        }
        return (_tokensOfOwner);
    }
    function getallholder(uint256 from, uint256 value) public view virtual returns (holderInfo[] memory)  
    {
	uint256 index;
        holderInfo[] memory holderRe = new holderInfo[](value);
        for (uint256 i = 0; i < value; i++) 
	{
	    index = i+from;
	    holderRe[i].owner=ownerOf(index);
	    holderRe[i].tokenId=uint32(index);
	}
	return holderRe;
    }
    function setallowlistroot(bytes32 _mr) external onlyOwner
    {
	whroot = _mr;
    }
}