// File: NFTSociety/Daonnaki.sol



//SPDX-License-Identifier: UNLICENSED

/*
 *  Daonnaki NFT Collection
 *  Created by NFTSociety.io
 */

pragma solidity ^0.8.17;

import "erc721a/contracts/ERC721A.sol";
import "operator-filter-registry/src/DefaultOperatorFilterer.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./NSClaimer.sol";

contract Daonnaki is ERC721A, Ownable, DefaultOperatorFilterer, NSClaimer {
    using Strings for uint256;
    using ECDSA for bytes32;

    uint256 public maxSupply = 10000;
    uint256 public currentSupply = 0;

    uint256 public salePrice = 0.0198 ether;
    uint256 public presalePrice = 0.0185 ether;

    //Placeholders
    address private presaleAddress = address(0xA57C2D44EB8f127CA6C43Cf0Aa1bE8800aEc7c93);
    address private wallet = address(0x8A72c401649A23DE311b8108ec7962979689d083);

    string private baseURI;
    string private notRevealedUri = "ipfs://QmcmU4Q47CQxBksyLy6jRLJ6uVcfoZNKeDwKWo5N72B3Lq";

    bool public revealed = false;
    bool public baseLocked = false;

    bool public claimOpened = false;
    bool public presaleOpened = false;
    bool public saleOpened = false;

    mapping(address => uint256) public mintLog;

    constructor()
        ERC721A("Daonnaki", "DAO")
    {
        transferOwnership(msg.sender);
        //Reserved NFTs to be claimed at any time
        currentSupply = 6209;
    }

    //Opensea Operator Filterer method overwrite
    function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {
        super.setApprovalForAll(operator, approved);
    }

    function approve(address operator, uint256 tokenId) public payable override onlyAllowedOperatorApproval(operator) {
        super.approve(operator, tokenId);
    }

    function transferFrom(address from, address to, uint256 tokenId) public payable override onlyAllowedOperator(from) {
        super.transferFrom(from, to, tokenId);
    }

    function safeTransferFrom(address from, address to, uint256 tokenId) public payable override onlyAllowedOperator(from) {
        super.safeTransferFrom(from, to, tokenId);
    }

    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data)
        public payable override
        onlyAllowedOperator(from)
    {
        super.safeTransferFrom(from, to, tokenId, data);
    }
    // - - - -
    
    function withdraw() public onlyOwner {
        uint256 _balance = address( this ).balance;
        payable( wallet ).transfer( _balance );
    }

    function setWallet(address _newWallet) public onlyOwner {
        wallet = _newWallet;
    }

    function totalSupply() public view override returns (uint256) {
        return currentSupply;
    }

    function validateSignature( address _addr, bytes memory _s ) internal view returns (bool){
        bytes32 messageHash = keccak256(
            abi.encodePacked( address(this), msg.sender)
        );

        address signer = messageHash.toEthSignedMessageHash().recover(_s);

        if( _addr == signer ) {
            return true;
        } else {
            return false;
        }
    }

    /**
        Claim reserved NFTs
     */
    function claimReserved() external {
        require( 
            claimOpened, 
            "This phase has not yet started." 
        );

        require( 
            !claimLog[ msg.sender ], 
            "You have already claimed your reserved NFTs." 
        );

        require( 
            reserveLog[ msg.sender ] > 0, 
            "You don't have reserved NFTs for claim." 
        );

        uint256 _am = reserveLog[ msg.sender ];

        mintLog[ msg.sender ] += _am;
        claimLog[ msg.sender ] = true;
        claimed += _am;

        _mint( msg.sender, _am );
    }

    /**
        Presale ( Allowlist ) mint
     */
    function presaleMint(uint256 _amount, bytes calldata signature) external payable {
        //Presale opened check
        require( 
            presaleOpened, 
            "Daonnaki: Allowlist mint is not opened yet." 
        );

        //Min 1 NFT check
        require(_amount > 0, "Daonnaki: You must mint at least one NFT");

        //Check presale signature
        require(
            validateSignature(
                presaleAddress,
                signature
            ),
            "SIGNATURE_VALIDATION_FAILED"
        );

        //Price check
        require(
            msg.value >= presalePrice * _amount,
            "Daonnaki: Insufficient ETH amount sent."
        );

        uint256 supply = currentSupply;

        require(
            supply + _amount <= maxSupply,
            "Daonnaki: Mint too large, exceeding the collection supply"
        );

        mintLog[ msg.sender ] += _amount;
        currentSupply += _amount;

        _mint( msg.sender, _amount);
    }

    /**
        Phase 3 of the mint
     */
    function publicMint(uint256 _amount) external payable {
        //Public mint check
        require( 
            saleOpened, 
            "Daonnaki: Public mint is not opened yet." 
        );

        //Price check
        require(
            msg.value >= salePrice * _amount,
            "Daonnaki: Insufficient ETH amount sent."
        );

        uint256 supply = currentSupply;

        require(
            supply + _amount <= maxSupply,
            "Daonnaki: Mint too large, exceeding the collection supply"
        );

        mintLog[ msg.sender ] += _amount;
        currentSupply += _amount;

        _mint( msg.sender, _amount );
    }

    function forceMint(uint256 number, address receiver) external onlyOwner {
        uint256 supply = currentSupply;

        require(
            supply + number <= maxSupply,
            "Daonnaki: You can't mint more than max supply"
        );

        currentSupply += number;

        _mint( receiver, number );
    }

    /**
        Force-Claim reserved NFTs
     */
    function forceClaim( address _addr ) external onlyOwner {
        require( 
            !claimLog[ _addr ], 
            "Already claimed." 
        );

        require( 
            reserveLog[ _addr ] > 0, 
            "No NFTs for claim on this address." 
        );

        uint256 _am = reserveLog[ _addr ];

        mintLog[ _addr ] += _am;
        claimLog[ _addr ] = true;
        claimed += _am;

        _mint( _addr, _am );
    }

    function ownerMint(uint256 number) external onlyOwner {
        uint256 supply = currentSupply;

        require(
            supply + number <= maxSupply,
            "Daonnaki: You can't mint more than max supply"
        );

        currentSupply += number;

        _mint( msg.sender, number );
    }

    function addToReserve( address _addr, uint256 _am ) public onlyOwner { 
        uint256 supply = currentSupply;

        require(
            supply + _am <= maxSupply,
            "Daonnaki: You can't add more than max supply"
        );

        require( 
            !claimLog[ _addr ], 
            "Already claimed." 
        );

        currentSupply += _am;
        reserveLog[ _addr ] += _am;
    }

    function setSalePrice(uint256 _newPrice) public onlyOwner {
        salePrice = _newPrice;
    }
    
    function setPresalePrice(uint256 _newPrice) public onlyOwner {
        presalePrice = _newPrice;
    }

    function claimOpen() public onlyOwner { 
        claimOpened = true;
    }

    function claimStop() public onlyOwner { 
        claimOpened = false;
    }

    function saleOpen() public onlyOwner { 
        saleOpened = true;
    }
    
    function saleStop() public onlyOwner {
        saleOpened = false;
    }

    function presaleOpen() public onlyOwner {
        presaleOpened = true;
    }
    
    function presaleStop() public onlyOwner {
        presaleOpened = false;
    }

    function reveal() public onlyOwner {
        revealed = true;
    }

    function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
        notRevealedUri = _notRevealedURI;
    }

    function setBaseURI(string memory _newBaseURI) public onlyOwner {
        require( baseLocked == false, "Base URI change has been disabled permanently");

        baseURI = _newBaseURI;
    }

    //Lock base security - your nfts can never be changed.
    function lockBase() public onlyOwner {
        baseLocked = true;
    }

    // FACTORY
    function tokenURI(uint256 tokenId)
        public
        view
        override(ERC721A)
        returns (string memory)
    {
        if (revealed == false) {
            return notRevealedUri;
        }

        string memory currentBaseURI = baseURI;
        return
            bytes(currentBaseURI).length > 0
                ? string(abi.encodePacked(currentBaseURI, tokenId.toString(),'.json'))
                : "";
    }
 
}
// File: NFTSociety/NSClaimer.sol



//SPDX-License-Identifier: UNLICENSED

/*
 *  Claim reserved NFTs 
 *  Created by NFTSociety.io
 */

pragma solidity ^0.8.17;

abstract contract NSClaimer {
    
    mapping( address => uint256 ) public reserveLog;
    mapping( address => bool ) public claimLog;
    uint256 public claimed;
    
    constructor() {
        //Init Access
        setAccess();
    }

    //AccessLog Init
    function setAccess() internal {
		reserveLog[ address(0xC7086014ABeB5C730CC75D92F7439544039ad424) ] = 30;
		reserveLog[ address(0x40E5529fc270566dD00272af0Bfa684C230cb210) ] = 50;
		reserveLog[ address(0xC405d61AaF8106F1A5242D1ccb4397acA1E689ac) ] = 6;
		reserveLog[ address(0x00D4da27deDce60F859471D8f595fDB4aE861557) ] = 25;
		reserveLog[ address(0x92fb6b5BC7f49b02E1d44c78FC5e671893F0E531) ] = 25;
		reserveLog[ address(0x9e2Ac6A3F2e8346a979cAa24fC00f8F9de8f8115) ] = 30;
		reserveLog[ address(0xf71eA5dB26888f1f38E7DE3375030f32861c0803) ] = 30;
		reserveLog[ address(0xE5d08078CA78C9B14101f16fcACbEE8818D06Bfa) ] = 51;
		reserveLog[ address(0x3C27D06a9A390b1290a124f06593fe95E0d64A93) ] = 10;
		reserveLog[ address(0x70069C30CbED62eD40Eb8813566A7a7D26A42D4C) ] = 30;
		reserveLog[ address(0x4a9b4cea73531Ebbe64922639683574104e72E4E) ] = 25;
		reserveLog[ address(0x62eF1F4b8D468863C88C8BE2c88D388f3D72D474) ] = 5;
		reserveLog[ address(0x74D7f706b26a6Fe2caE4999DFA6940f60CF8b916) ] = 15;
		reserveLog[ address(0x2Ef3f778D3032158f1bCf9c78772869339016631) ] = 15;
		reserveLog[ address(0x92b398370dda6392cf5b239561aB1bD3ba393CB6) ] = 5;
		reserveLog[ address(0x0Ad4214E4DEa19A8247b487af43Ea1410CF4c3DB) ] = 10;
		reserveLog[ address(0x00Ef8c07aEB53A3D538e6B97a662Be2b6700F9EE) ] = 25;
		reserveLog[ address(0xacCB1e0eAa4d6bB3AB8268cFa8fB08d77F082655) ] = 35;
		reserveLog[ address(0xCb61C44Dd8fC8E8d40DD17975ed43A5CA4161deE) ] = 5;
		reserveLog[ address(0xE0F6Bb10e17Ae2fEcD114d43603482fcEa5A9654) ] = 50;
		reserveLog[ address(0x474C235426E40aD6626A3E508Dc0011E023BFE43) ] = 50;
		reserveLog[ address(0x5CaA27A1Cd3351D5b9F86558A56a566DEC2f7658) ] = 40;
		reserveLog[ address(0xa54F87a652254baA2D1B39984a7E25022681fF41) ] = 5;
		reserveLog[ address(0x9a6F64645a71f0a40bEf45f21aB58F5dccaa18Ad) ] = 8;
		reserveLog[ address(0x356d581acCE55090eEaE6348c36c7a9501CD7cB9) ] = 25;
		reserveLog[ address(0x86348d8f5E3B0BF8e49e2707933d5d87CFe2119A) ] = 53;
		reserveLog[ address(0xBB6a0FBE1F1D4D7D3Df73efa4Dc2888F6dce1736) ] = 5;
		reserveLog[ address(0x777D30Db5EFC9b99bF5CA48Ce667a0EfC0c11913) ] = 20;
		reserveLog[ address(0xAb784a5081C478f518a4B804323f2ee7931df533) ] = 10;
		reserveLog[ address(0x10a348dDb0ae269eA73d9E01451eecd0a6164A28) ] = 5;
		reserveLog[ address(0xf01F2ef4A58874F00A125A6722958Cf22A76C08F) ] = 2;
		reserveLog[ address(0x321f9Bb604E21024Ff57259f09fcc5A5Fc19550B) ] = 21;
		reserveLog[ address(0x0d2958E4d38b67f2A95892F362c238A35A8cFc51) ] = 10;
		reserveLog[ address(0xb41e212b047f7A8e3961d52001ADE9413f7D0C70) ] = 35;
		reserveLog[ address(0x8B0850E5F3eb8659cBE140d8423Ccc0027DD535f) ] = 5;
		reserveLog[ address(0xC59E591a5a159a6FB9fCb4285052F4C5c2657810) ] = 33;
		reserveLog[ address(0x2125668BC6Ea43094fe06Ac2Af328E69516753fd) ] = 5;
		reserveLog[ address(0xf865C4da53B7599C1f52b3339d936420af31469d) ] = 11;
		reserveLog[ address(0x069805bEFFb3deC781aff8b71dB9357Be7ae418c) ] = 16;
		reserveLog[ address(0x80ea006315A1c8278419BED1951c4fC047581641) ] = 10;
		reserveLog[ address(0xeC303E97f025DF3947e9E901bcc06a70F9f377B4) ] = 1;
		reserveLog[ address(0x5c8aD9343c76CCE594cB3B663410DD2fa1aC0e78) ] = 110;
		reserveLog[ address(0x12ab48D6eA7Fa8aabdBB845DD71DCC7868053761) ] = 1;
		reserveLog[ address(0xAB674D86bF1943C060cF0C3D8103A09F5299599C) ] = 6;
		reserveLog[ address(0x0Dd11C2a71ca194F7bcfcac806988b580Eb3ba8A) ] = 58;
		reserveLog[ address(0x60314c86B99a2a108E5097fc2688AA1E3c30Be30) ] = 10;
		reserveLog[ address(0x7b5D04A9aab29D06F8e21eb6c957a38a760F50B4) ] = 11;
		reserveLog[ address(0x4494d7FB34930cC147131d405bB21027Aded12f4) ] = 10;
		reserveLog[ address(0xb4F3745E46f67204c072B2B33aaA2d6176463ACD) ] = 16;
		reserveLog[ address(0x081bcA4a664Cc3B440F3F6De5fEa209986056856) ] = 1;
		reserveLog[ address(0x6EDf6b0229C9A205d0D0E4f81e6a956e064ECFAa) ] = 26;
		reserveLog[ address(0x3b067DB9d9339169ad1C4A49504888441B0D9390) ] = 12;
		reserveLog[ address(0x40EfBE92D9AD4cfA8Deb52111fBCaCCD4DBd5495) ] = 1;
		reserveLog[ address(0xDd8463c7e803d6A5E8711010cFfAfd977B54f744) ] = 53;
		reserveLog[ address(0x6c2e34F61c4A9031c3c7E8059A09c381Ad340007) ] = 26;
		reserveLog[ address(0x562389B4B2b4c2123589800393D9c1c0051949C1) ] = 35;
		reserveLog[ address(0x5F4dF796b08AcAb25dc35b14e4D3Fd0b1588290e) ] = 5;
		reserveLog[ address(0xB84404f79EbeF00233E1AEdB273c67c917B8840f) ] = 5;
		reserveLog[ address(0x621C6De117f61c3D0c8eC1D6dFD3E36414202480) ] = 4;
		reserveLog[ address(0x19139f9C2420cF587E95375863121931581DBE9B) ] = 6;
		reserveLog[ address(0x083CC11901b1bB3Ab79958C386Ed3DE674ADf564) ] = 5;
		reserveLog[ address(0x0FEbC5A457F29C753B7D9BbC12e8e9f7D26b024b) ] = 1;
		reserveLog[ address(0xBF412BE283Fe1105C709f1F64d40e9f70057a305) ] = 18;
		reserveLog[ address(0x9Fef5892be1c331426aeb4E6E32AAc3718f96e87) ] = 50;
		reserveLog[ address(0xD58D449Af4832d76eD247e0b2DD80327CfE377c0) ] = 46;
		reserveLog[ address(0x9CC1126F327128Ee73175c6fD68F88a0b1F72Ac7) ] = 1;
		reserveLog[ address(0x7FDF505f1fDcCb3D1e55E06f2890871DdFfA3FBe) ] = 5;
		reserveLog[ address(0x4cBD07e1b723eC2334c5c33dFC92DA94cbF8994C) ] = 33;
		reserveLog[ address(0x728E1D2a727d14051a3787203Db3646701026315) ] = 15;
		reserveLog[ address(0x07f183E920c135A6A01f86aa64E583EF0E91164C) ] = 25;
		reserveLog[ address(0x5431c0Dce14A9FFdFfc82097538f330e6d2Cbc81) ] = 5;
		reserveLog[ address(0xe84db627dB0722d076F0f81ccf0AA0C72eB41d5d) ] = 3;
		reserveLog[ address(0x065735841E157d74Cd2D69A95d3E4C4003A76E28) ] = 15;
		reserveLog[ address(0x99EE59f6130F88113d87Cabd8A19e97D269946cf) ] = 30;
		reserveLog[ address(0x345Aa080b2ca5ed336D7FEA600153CB1C57Aa387) ] = 2;
		reserveLog[ address(0x090738F0600660206636E2E175553E4802bfC2fd) ] = 3;
		reserveLog[ address(0x2b518e05767B49dDF3C5E1B353F923A25611c0F7) ] = 6;
		reserveLog[ address(0x8575adfB4a62c2371AB87EcCa87ADE99A968F504) ] = 5;
		reserveLog[ address(0xBaA3f0f0983267D1B9847B6328eDa968Aa5cB0e5) ] = 5;
		reserveLog[ address(0xd8CE40b6f51f3df2F774f35Eaf9c9F20ad76AA5F) ] = 5;
		reserveLog[ address(0x986eAa8d5a0EC0a0f0433BBB249D15E5430CF550) ] = 10;
		reserveLog[ address(0x709A37e109D7c5b7AF637cEd53ccD2a16Cf804E6) ] = 5;
		reserveLog[ address(0xdDd1918AC0D873eb02feD2ac24251da75d983Fed) ] = 1;
		reserveLog[ address(0x08734fe979Db217d19A9963E358F7F2009e940d6) ] = 5;
		reserveLog[ address(0x651741aD4945bE1B8fEC753168DA613FC2060c01) ] = 3;
		reserveLog[ address(0x8b835e35838448a8A29Be15E926D99E9FB040822) ] = 25;
		reserveLog[ address(0xe07E2A56849F1D31233dF11710C00E5a526c59aa) ] = 5;
		reserveLog[ address(0xae4a6373198c7FF52992705178CC3d81BFB5c1bf) ] = 5;
		reserveLog[ address(0x770Ea337b0B3b5E99AdFc3474779690856afac06) ] = 30;
		reserveLog[ address(0x5fB4E2617Bdfd6c8FAe563d4cf9070b45580C305) ] = 1;
		reserveLog[ address(0x3Bcb6e863939828DD391ff5c2820E1Ee93398C17) ] = 26;
		reserveLog[ address(0x03d86EC6Ad13eef60Fa516E7ed291a2171AFBf6A) ] = 10;
		reserveLog[ address(0x3C03Fb9387524111D5528eC19B606eF22D107AC0) ] = 10;
		reserveLog[ address(0x7E7c1A3541d2ff134f755ca58512B703906f2785) ] = 6;
		reserveLog[ address(0x381C43E044f019BD1bca7CCbA3db83d756e9643C) ] = 4;
		reserveLog[ address(0xCBc6C9CeF4f3C7cbBb8Eb82A2aD60c00e631A8C1) ] = 3;
		reserveLog[ address(0x5114908f1c7B8cB43a11bdC7f1731Db0fF8e85F8) ] = 15;
		reserveLog[ address(0x25840805c7B742488f2E5566398C99d0c39A373B) ] = 4;
		reserveLog[ address(0x67C1EC6455C4e62acdaC256BE78604b9cEA50A31) ] = 1;
		reserveLog[ address(0xeCedfe638f467D4b7429f2d945b2b68bc8bdEEd7) ] = 57;
		reserveLog[ address(0xDaef2F9cDAFB8a63c309C5969a4D4E0A507143c6) ] = 1;
		reserveLog[ address(0x24a44d75938c4477900DEa8f418bC1dAfB101657) ] = 2;
		reserveLog[ address(0x1444FedEA6cD0Fd7c78fB2d0CAf803F486B86cBE) ] = 5;
		reserveLog[ address(0x1AF045428EB6c93486d359ac84ac6D1e3A0fb0E4) ] = 25;
		reserveLog[ address(0x420CBC1223e6173c084536166877d59E072dA089) ] = 6;
		reserveLog[ address(0x20687eEe454A4A8b48CBA410d67B5aa6c46fBd21) ] = 6;
		reserveLog[ address(0xF78768D71fEa7e6EdA6219609046c291FA058D7B) ] = 14;
		reserveLog[ address(0x0B9960B28759222d45e2fA059066BE3d94DA12c9) ] = 5;
		reserveLog[ address(0xB55Be226B485f1E3DB7259159780E97119a614F3) ] = 12;
		reserveLog[ address(0x659DA5D440313e21f80E55c7fBf18C704B425010) ] = 10;
		reserveLog[ address(0x056bF45a910A1713260448Fb35B87109b9B9d80B) ] = 3;
		reserveLog[ address(0xb20963d8655316bfCb649055397159B97088AaFA) ] = 1;
		reserveLog[ address(0x87E11C338fdC4053f2AC27311E032EdA29aFa974) ] = 10;
		reserveLog[ address(0x097a2D60513C377cF08041fB51847DB6A97a5d7F) ] = 6;
		reserveLog[ address(0x5DC3f17c714E3076F55849A00ed8397e9661f423) ] = 1;
		reserveLog[ address(0x1E18677d4c9391eCBbBf63A0Dc56f1B10F099f7f) ] = 5;
		reserveLog[ address(0x775ED38A7A77D35c2D8b1cd785E39902Ed2F8F3d) ] = 1;
		reserveLog[ address(0x3fE79050f920C69bC3aC67424e4005dBD0C2429b) ] = 11;
		reserveLog[ address(0x0B993B2b87828f1bCf74f74e1F97cB813A966B2b) ] = 5;
		reserveLog[ address(0x6B71F02e474a0005Ef2B4E69475Db0dB2091033d) ] = 6;
		reserveLog[ address(0x5d0A692c1b83caE90a74bcD362d626A09b44FA98) ] = 1;
		reserveLog[ address(0x0A1717bA21CEAf7c03448f6BdCE4E43a5E2D1cCD) ] = 3;
		reserveLog[ address(0x72f2658CF458C1ECF60545CC38b6766a2f723185) ] = 5;
		reserveLog[ address(0xBdFF8F94d23e4de61B12323605067FC14E3CbCd7) ] = 5;
		reserveLog[ address(0xd140d902B24E4b94c9Ed1473a7e20db8E42b5B1F) ] = 6;
		reserveLog[ address(0xBc48d0cb0f85434186b83263dcBbA6bfE79CAa10) ] = 1;
		reserveLog[ address(0x32bB91144a38f372f120225661DA947B90fda3c1) ] = 5;
		reserveLog[ address(0x397712e87cc37A8472dE68953F37d7D9C2A97099) ] = 5;
		reserveLog[ address(0xf9794B535D607DDeedFB43a31EAd3f4B2DC1612C) ] = 2;
		reserveLog[ address(0x9B52f408a3FdBCaCa3a61bB1354d287123B03Ce9) ] = 5;
		reserveLog[ address(0x41993B75bDE61E347f889cE73b0Eb7b5763c6bd7) ] = 5;
		reserveLog[ address(0xD5F3CCCF2243f6F67Ee93415Febf1a22e5fCb7EA) ] = 6;
		reserveLog[ address(0x602Ff8316a7c4387f897E92838d91C74124A5E4d) ] = 6;
		reserveLog[ address(0xf1FC52D4485BD6894B42Ad80FA1a06C427d6B410) ] = 10;
		reserveLog[ address(0xaCef6dffec76437682A63F7A8FDcF037F06B5B30) ] = 5;
		reserveLog[ address(0xeA5F6704694ffECF5A309a93fc122105B507faAF) ] = 11;
		reserveLog[ address(0xE84B803FFb156d9Fe84569cFf2eb44E94116195F) ] = 10;
		reserveLog[ address(0x623C04dd784cd3a937AB8511BbB165C872223A32) ] = 5;
		reserveLog[ address(0x61aC5784E9BD011EE2D708a2000c707eF18B4356) ] = 5;
		reserveLog[ address(0x910e909175BE35C21A97180653C8942F0669eBAe) ] = 9;
		reserveLog[ address(0x9aee6EeD675278C23CDbC6cae68A84Ec8eaDf108) ] = 1;
		reserveLog[ address(0xb0610e10a5278e5c8D6eC4FAE9C6F39eA37f1489) ] = 5;
		reserveLog[ address(0x07dbD92bf686c5b60c1Db96bB66A90bd6af556F0) ] = 1;
		reserveLog[ address(0x58538dC6fe148E1252296A2Cfe1cc61bCB34104B) ] = 26;
		reserveLog[ address(0xE210Fa629e53721f46c9B28fE13dA66bf8a1fEFf) ] = 1;
		reserveLog[ address(0x45896c9885066Fe00D1C9c95B962CD5e6579bAC5) ] = 50;
		reserveLog[ address(0x1850DFF98F726c3196351e9BaBA70e92BAdc9000) ] = 40;
		reserveLog[ address(0x2A2794F7da0c5e27F0D0621AE47237E872bf62c2) ] = 40;
		reserveLog[ address(0xF807C4a5f07452FD962e5068D4F98b9d0931C72e) ] = 40;
		reserveLog[ address(0xa2aF3d9bdA52dB53aC5fA03F996607C2A51B4FAE) ] = 30;
		reserveLog[ address(0x18aB58A1F4Ea0d873Be2F2970CB83E00103dcE43) ] = 35;
		reserveLog[ address(0x8E19CB0afe1534B66cD23c38D602ccF12bdC686A) ] = 35;
		reserveLog[ address(0x6C7C962089eE9BF42710302FC799CEbdb191327e) ] = 30;
		reserveLog[ address(0xf9cc106ebEED623eE22ED56339a894D88469f267) ] = 30;
		reserveLog[ address(0x1475acBbf626AAb0fD09c7B9D2aB87F85c3d7E14) ] = 30;
		reserveLog[ address(0x670C15E92f712583225e2430C1425622633112c6) ] = 40;
		reserveLog[ address(0x184e65b0B9d596ADce02A4B9fcbFd95d9660aC95) ] = 40;
		reserveLog[ address(0xF73cF15076259422A5dC9DBb020237b5c2045A19) ] = 30;
		reserveLog[ address(0x5f58CE5DDDfc0e170C248867d6c378d64513aa49) ] = 30;
		reserveLog[ address(0xf761b2CC7C68d0583371e3189fdD633fE70105dA) ] = 40;
		reserveLog[ address(0x03044F4367D8bEbeB261D98dA8dCaeD088FD6760) ] = 30;
		reserveLog[ address(0xd91A31a9e7f695A9a43701FA604F7C06941825f2) ] = 35;
		reserveLog[ address(0x78FE789767BaE3372cBBc2a7A47dD0A7F8b32353) ] = 30;
		reserveLog[ address(0xc19496A7Dce4fd9fc6623702303322a571a90187) ] = 40;
		reserveLog[ address(0xC6077Cd3DF4Ad9de8B1356136Fd1C14B55eA2F6d) ] = 35;
		reserveLog[ address(0x454b3697ad71299Bd539F2E057E6D21AD849d3d8) ] = 35;
		reserveLog[ address(0xF363b8D00F609E8082459E6b6f8724D6080E6fa0) ] = 40;
		reserveLog[ address(0x6E1d2C69Dde53cf94e120E426a1c3531FBF79766) ] = 40;
		reserveLog[ address(0xa4266f94758F2bb84285f8e2C6393C3d7707C60e) ] = 35;
		reserveLog[ address(0x5D7dFCBB5643717f0b36A987a3ba91cFb37E350d) ] = 30;
		reserveLog[ address(0x76568C4FB1Ed4876825bB13af439303Ba56574ba) ] = 30;
		reserveLog[ address(0x27D9064310FB02E52D5ADb4aB269aEd1dF27cb4b) ] = 30;
		reserveLog[ address(0x4449CAdadB625DDA3E3A3A422ecAe46450a0aB54) ] = 30;
		reserveLog[ address(0xD788D7F8b9A86d203F5cF86d7E54F2f058624100) ] = 35;
		reserveLog[ address(0x562Ea2E758BCCc41e0c1D2c485235fbF08237608) ] = 35;
		reserveLog[ address(0x71D01033f8ffb379935C0d0e8474f45E6f92A972) ] = 2;
		reserveLog[ address(0xA8C3cFC34f2B0ceAF622026B3017db77170A1FF5) ] = 7;
		reserveLog[ address(0x700F1523bBB4a4430860138b26606b574E417cE5) ] = 1;
		reserveLog[ address(0xC6Ac567b250b986acAE49A842Dad7865dA4be3a0) ] = 20;
		reserveLog[ address(0xBCe965Bcd3D16dc05bCB3F796a2314bC1ddFb8A3) ] = 30;
		reserveLog[ address(0x3aBaf15114858d4C7477E30Deab1F779013C9e17) ] = 50;
		reserveLog[ address(0xD67fAf0157E6576B81A083c0888b7F275cA7308c) ] = 20;
		reserveLog[ address(0x94E69Ebf630cD79C89247981FBd6ac7fbC68A300) ] = 27;
		reserveLog[ address(0xa34c2bd0D3Df7cbd371F94Ab68c5c826DFABB245) ] = 23;
		reserveLog[ address(0x60271ffBbbD4Bb382Ad4A32129D51C2DfF46e4D4) ] = 24;
		reserveLog[ address(0xA746e529E8B66C77FFC6fF7EAaA8cf0F2fB4d925) ] = 36;
		reserveLog[ address(0x9F225e7E711776f86Fc4e47FE28085d8666a2ef8) ] = 19;
		reserveLog[ address(0xAe00F3f0FE3672a4BF24646392024F8542DC1ac3) ] = 17;
		reserveLog[ address(0x7B3c88772277E5ba86E722A08E8A8e070Ed622a7) ] = 23;
		reserveLog[ address(0x887CbD3b6abEA847AE16d7e5C109366F9468A403) ] = 12;
		reserveLog[ address(0x548c79cEb69f6d02a3997FD7335C38A21dA32d69) ] = 21;
		reserveLog[ address(0x12BA6E5d7A0f7FF173007304e0Da014D9dBEE3aA) ] = 25;
		reserveLog[ address(0xc2029cb9760A5baE2A7c9de25afd85E174D55728) ] = 22;
		reserveLog[ address(0x6BDF0fe934f1e94DaA519a139ED1089BC69EE598) ] = 35;
		reserveLog[ address(0xB7515518c86620910AD1490AF64c101fD16Dc8F9) ] = 38;
		reserveLog[ address(0x4423fE89F2783fb0A8a7bA3Cc169324404A8DbF1) ] = 32;
		reserveLog[ address(0xce64b5060A48aC01e78e7d953050cE1E4b5ac351) ] = 15;
		reserveLog[ address(0x2428228000071cD44968f2b0542736BD1af47CDE) ] = 21;
		reserveLog[ address(0x138b4C10B7A091023aA87451BD9d760A8b98A8ae) ] = 18;
		reserveLog[ address(0x807428F34b2A1b8FD7363081cFFeDC53fB133743) ] = 26;
		reserveLog[ address(0xBFdf468C854EC88Ea7761C3f1AD917317eD20a75) ] = 16;
		reserveLog[ address(0xA465bcB79F887a10460537a0D2B1e2C689f743c3) ] = 33;
		reserveLog[ address(0xb0Abd5E82D81AD7A69D0cfEAD5A8e0D133717fB5) ] = 2;
		reserveLog[ address(0xa1a3331CC412fc9B4bE1f6e8E0fe2DB20775Fe42) ] = 5;
		reserveLog[ address(0xF0f1ed472A049762967788D887d0A3ccf280c460) ] = 5;
		reserveLog[ address(0x0783FD17d11589b59Ef7837803Bfb046c025C5Af) ] = 1;
		reserveLog[ address(0x0945BE11418b180Ec8DfE0447a9bE1c15FB1BeaD) ] = 16;
		reserveLog[ address(0x7a837fcA21341e78086f7022ac1e07f3c6b03240) ] = 1;
		reserveLog[ address(0xEa0bC5d9E7e7209Db6d154589EcB5A9eC834789B) ] = 5;
		reserveLog[ address(0x6E84a7EB0c34A757652A2474f4D2c73e288347c3) ] = 8;
		reserveLog[ address(0xfF0F74D6c8602c95De89F67A2799BA0B17CAd4B8) ] = 11;
		reserveLog[ address(0x5593cb346Fd6BBf2b6B7Ae06983785DdD31Cce75) ] = 7;
		reserveLog[ address(0x372344a8808Bb85560bace3b5d4aAd03A74290f7) ] = 7;
		reserveLog[ address(0x92806839C70e789a9aFDc21b53737746B1048f82) ] = 6;
		reserveLog[ address(0x412802B7fF77718A3fAe786C670e4F7E19434C88) ] = 7;
		reserveLog[ address(0x8D7E8E86b53283D3544Aeee3226Cab0a1BFAcf1c) ] = 11;
		reserveLog[ address(0x388E66fB6D609a9D434C9e44495381A0Cfc60b65) ] = 8;
		reserveLog[ address(0x94518CAE5546b20525C829f33D5e2e409672e365) ] = 14;
		reserveLog[ address(0x89cb461617A7B9a7b2BE4d528a19A9dfab8f64D2) ] = 9;
		reserveLog[ address(0x39a6454759fE3cD81edf71B2cf6C7f0CCa5b814d) ] = 7;
		reserveLog[ address(0xF02D1F90f9F05371b724467f9dB3F867A832D69f) ] = 13;
		reserveLog[ address(0xB1335c5F8947327CD1A0926A1A6891D3eb654b93) ] = 22;
		reserveLog[ address(0x238f59Ee635e1D5079Cb0407Ad6157980c69C96C) ] = 8;
		reserveLog[ address(0x86E453d8c94bc0ADC4f4B05b2b4E451e17Be8abe) ] = 9;
		reserveLog[ address(0xb0e41D26Cc795Da7220e3FBaaa0c92E6Baf65db2) ] = 6;
		reserveLog[ address(0xfB72c1a0500E18D757f722d1F71191503e937f1F) ] = 11;
		reserveLog[ address(0x41C3BD08f55a1279C3c596449eB42e00A2E86823) ] = 5;
		reserveLog[ address(0x95631A17dd0F4D19eb90Cc6A0a7e330C987a5139) ] = 6;
		reserveLog[ address(0x4Ce304754Bbd6Bfe8643ebba72Cf494ccb089d8e) ] = 8;
		reserveLog[ address(0x210DC570f8e7F0Ce80dfF902ecEc7AF2eb4b32C6) ] = 7;
		reserveLog[ address(0xe3b29c5794Ac8C9c7c9fdE346209d1927A1E7B33) ] = 9;
		reserveLog[ address(0xA9Eaa007aAE4924D650c50381b278841Ee4d4e01) ] = 12;
		reserveLog[ address(0x278868be49d73284e6415d68b8583211eE96ce1F) ] = 6;
		reserveLog[ address(0xf500006B104b34660B81d6F2Eb6eBBc1CBE2BaE3) ] = 9;
		reserveLog[ address(0x0Cb7Dbc3837Ce16661BeC77e1Db239AAA6d4F0b4) ] = 13;
		reserveLog[ address(0x817f2D50F51E448c1E9DCc82cd83259F3A5a6088) ] = 9;
		reserveLog[ address(0x70102E977B12A3269D2a7539539d7DDFe5D63b2D) ] = 9;
		reserveLog[ address(0x61D1C8059a1988725474709067D8140894545912) ] = 5;
		reserveLog[ address(0x5176BB80780a68ae0194af21Ff2D168574734638) ] = 17;
		reserveLog[ address(0x8CEe034078EADd552D0c8E6E80e45A9B3A7A5BE9) ] = 14;
		reserveLog[ address(0xdFA7ae04064eE82378b01FDe8Fcd1aE72cE957a8) ] = 7;
		reserveLog[ address(0xAe6556336374029D12C4f88813Db19D6d60AdDe7) ] = 11;
		reserveLog[ address(0xC976E311b3B4Bb244C9b4f461D4EdDc3e4B229B0) ] = 6;
		reserveLog[ address(0xFF64798F3dbEf51256f4De0a642d492B218F06c4) ] = 16;
		reserveLog[ address(0x95bC2c07928A4AfC814c7A1b6036a3C684d5F7aF) ] = 11;
		reserveLog[ address(0x4bB7EFc52778d0f5F9A3698cdaD98410da9a077c) ] = 9;
		reserveLog[ address(0xC15A3291144981E0Ae8b5444a299c201A0B08e87) ] = 12;
		reserveLog[ address(0x3C99046aA00B6e42a0Ec5858Bb2c9825cFf40A72) ] = 14;
		reserveLog[ address(0xE718419c7DFF14Fc34AAbed3fcF4533BcF816960) ] = 8;
		reserveLog[ address(0x761e3455C87ad14CBf45b1846296043e06412F1C) ] = 15;
		reserveLog[ address(0x57fED59B69e1aB098033bCAFf9E73E1861ed8a10) ] = 20;
		reserveLog[ address(0x251625D0FE5dAd9728ce575de96a92DEDc4DF987) ] = 17;
		reserveLog[ address(0xbd05A759F39330B7001618738De8acB2E556466A) ] = 14;
		reserveLog[ address(0xb36336BEB87613ffE60B28a6f94D8ab18973C10E) ] = 9;
		reserveLog[ address(0x0C319880d4296207b82F463B979b4923E5F9AD07) ] = 8;
		reserveLog[ address(0xdBA68BD903a0D989599905016450f396D82314e2) ] = 6;
		reserveLog[ address(0x49c72c829B2aa1Ae2526fAEE29461E6cb7Efe0E6) ] = 11;
		reserveLog[ address(0xbF1aE3F91EC24B5Da2d85F2bD95a9E2a0F632d47) ] = 16;
		reserveLog[ address(0xF13cD4FFFB7E8C837dC3F3Bff04D34Cac4D414f5) ] = 100;
		reserveLog[ address(0x8f643591EF13FbE21ecA5fbBf20Cb0662cae34A0) ] = 75;
		reserveLog[ address(0x3561b596790663c72E75908060d2a882D65cc48a) ] = 85;
		reserveLog[ address(0x795C9C9Dfef4cfCCbFdED3BAb98d6bC841A46534) ] = 70;
		reserveLog[ address(0xe5129a9bAafAda04C82744938DEa163fFc361Cc7) ] = 90;
		reserveLog[ address(0x3DDeD3Efa15d23A38eab0e8f155972Da1bB0AeBE) ] = 80;
		reserveLog[ address(0x56E48cad4419A8a27DE6444f5839d85bCdBAfA27) ] = 50;
		reserveLog[ address(0xA664487EAB27879d59F6162777BFb86A47bAdA68) ] = 30;
		reserveLog[ address(0x800A88d1615a7B557641F5C3C4f8d6CfC9692239) ] = 20;
		reserveLog[ address(0xc7A493935700EC98295E963bb3E27176761C4B91) ] = 5;
		reserveLog[ address(0x4AA42aEB8a3cd22A256140b41902C5e1eA9c5cd7) ] = 6;
		reserveLog[ address(0xF51F3e88923dfEFDf33A2E7cc471E27a97531783) ] = 5;
		reserveLog[ address(0xb32336B2ec1C7bE286A961b8DEE466A2B6472e91) ] = 5;
		reserveLog[ address(0x6A5B70026c432E5D12c13b5dC39f3E9F4e229C31) ] = 6;
		reserveLog[ address(0x7f3865E3F61054b357553A09D647D77959d5287b) ] = 12;
		reserveLog[ address(0xBb066a9029105b6ccC5A4d678F7C560432014D55) ] = 6;
		reserveLog[ address(0x9816DE38B33C46Ef44e7D4d0f555c171404d841E) ] = 12;
		reserveLog[ address(0x300D83Fa181010ab3bc10a0dFfE2fa7C392A84d1) ] = 6;
		reserveLog[ address(0xa5046C737847fa4eA1372c27209EffB112748cc6) ] = 7;
		reserveLog[ address(0x0a4C396BeA0170BEF5836Be1b5E2e9F0Ffab14f2) ] = 12;
		reserveLog[ address(0xCAb5aa3Cda2802cec23c0006734fF4Fe3262c4a2) ] = 13;
		reserveLog[ address(0xA7132B6E1a4DF7724B78fD956a3FD7c76b1BB86b) ] = 10;
		reserveLog[ address(0xD4D42b578E90E1b7De6c148D26394EcC092dC97A) ] = 5;
		reserveLog[ address(0xf5192AA5437646e240b5F30Ef6fcff93dC52a813) ] = 40;
		reserveLog[ address(0xA1ffDB5B6845F7bC578C9E7CdfADED4C6De76c82) ] = 50;
		reserveLog[ address(0x57DAB937AD5a3675200baA12DBED928dCD2C5acC) ] = 30;
		reserveLog[ address(0x923DE51F9BDaFc5c66fb8DeC8a27B8ae0d5688De) ] = 25;
		reserveLog[ address(0x5F79E401485c1Be93380dec4bA2c81b1D088b0eC) ] = 55;
		reserveLog[ address(0xE118436bD944108aCFEB6E4E48B0c7F67F4e5150) ] = 45;
		reserveLog[ address(0xEE679B08470218C9922dF223f2e7B0F4eb00F12e) ] = 200;
		reserveLog[ address(0xb3caedA9DED7930a5485F6a36326B789C33c6c1e) ] = 45;
		reserveLog[ address(0x2bE7cD3ad21fbDE0f3E963D13b958CFcF9fc252d) ] = 60;
		reserveLog[ address(0xA59b4038b6DB489e9f257A1ABC92D8c6F402Be23) ] = 40;
		reserveLog[ address(0xEA0f8E0b8Bb13386673827De68f64b6fFc1144B6) ] = 55;
		reserveLog[ address(0xA0224C61f8960D989dF5455F7055D9D3aCB33Be1) ] = 30;
		reserveLog[ address(0xD540254d008833463b39a9E86db5e6f0da96236f) ] = 15;
		reserveLog[ address(0x054a8371805b573BB551fd214947cC7e4DCFad12) ] = 20;
		reserveLog[ address(0x2Ad0f0D3CeE43291EfAFcC270Bd805005BDEe503) ] = 25;
		reserveLog[ address(0x330567B06781027dBab477A9e7F73f36661B0997) ] = 30;
		reserveLog[ address(0x216213236d99dFE4a76E431C93eCA1f606a051Fb) ] = 35;
		reserveLog[ address(0x2E0BB93D258922e6da25F9adA10b47fB229A5f00) ] = 10;
		reserveLog[ address(0x293aF2Dd1Cf2E75568392eE8A590881387dE5B05) ] = 10;
		reserveLog[ address(0x105a426D0A18A69addc3CE1aE6D0500E448991ef) ] = 10;
		reserveLog[ address(0x5ad9d740Abaa11aCE2a495da8A51338fab81b460) ] = 10;
		reserveLog[ address(0xBF7FD93Fe70Fd6126c6f06DfBCe4EcA9Ac09e050) ] = 15;
		reserveLog[ address(0xF88AaFAd4780Eb3b0eEFaB3aa886759acF9d82dC) ] = 15;
		reserveLog[ address(0x41eC5138ffA418A3c61eeB2BA6a03e8C17210e3D) ] = 20;
		reserveLog[ address(0x8742C30158d4889a6711A7C28C3F9eAd1A5214cA) ] = 15;
		reserveLog[ address(0x74AE243121bc550b40983315E6Db541C1dB7AB96) ] = 15;
		reserveLog[ address(0x2eAB1fC74bE243C5f5204F30A9bdEF6d6d236B95) ] = 20;
		reserveLog[ address(0xdd4b49fb97113646DEB8aaf34f462953472D6bD6) ] = 10;
		reserveLog[ address(0x351E0db8bDE58C73CB2F168Fed7fA5B65Bde7f2f) ] = 20;
		reserveLog[ address(0x116d2f18B6A410AE52631a10D4bE4CC84d8be8C6) ] = 15;
		reserveLog[ address(0xa110F3BF5B77E48BbF2Bc15717740E7BF1bD7c7c) ] = 15;
		reserveLog[ address(0x63B2bD90Ef96dbD4EA50dd933B4463d40F8E14E5) ] = 15;
		reserveLog[ address(0xf6fb5914115523ee81098047876F223E00Fc4Cdc) ] = 15;
		reserveLog[ address(0xc8c671c29aEE3E57631f3647BfC763afbaECcEef) ] = 10;
		reserveLog[ address(0x8a642f921aD4fA6f4F6CC7C51222832e74819c5e) ] = 10;
		reserveLog[ address(0xE53ab456a22d67330CA09f91EAA13d14B65D4A7A) ] = 15;
		reserveLog[ address(0x5556336191F9297d7cFA54051480d3f36b397A72) ] = 15;
		reserveLog[ address(0x5c019d29e67BeD0135845a5b747ae3E705275504) ] = 10;
		reserveLog[ address(0xF8E4d023d222De287e848F7A80e59E8746f9b28B) ] = 10;
		reserveLog[ address(0xfADA1A694fA3A39D550dd9DD5A3Efd3C42D5A29B) ] = 10;
		reserveLog[ address(0xf54DF4D46d36193170FcFDC479015DF7C6B66Fa8) ] = 10;
		reserveLog[ address(0xbF0885C44D2cAB7453ABb12aA32Cf243Ef1f687a) ] = 5;
		reserveLog[ address(0xAB39eB31402d0aC1d0d680c0BC123F6c798da42B) ] = 10;
		reserveLog[ address(0x21B9F33A7EF798594270bed7F5a497eef76C2eA8) ] = 10;
		reserveLog[ address(0x2af53963353BA3fCFaC15dF8Cde1f387f8cCC1c8) ] = 10;
		reserveLog[ address(0xf85DDb44E9790E6a03F8714f2b78E60f98372e2f) ] = 3;
		reserveLog[ address(0x0f25C5aC5cBEd4Ff15AAb4ca3639F87a453B9ab8) ] = 3;
		reserveLog[ address(0x381022d39583b052d5F0De3E137cF1998C39fb18) ] = 10;
		reserveLog[ address(0x6242DAaBadd3c08163337Cec11Db00B9a68bD149) ] = 1;
		reserveLog[ address(0x853d2a8D7c855f21b86c071F2A27055345352Ae6) ] = 100;

    }
    
}
// File: @openzeppelin/contracts/access/Ownable.sol



// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// File: @openzeppelin/contracts/utils/Counters.sol



// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library Counters {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

// File: @openzeppelin/contracts/utils/cryptography/ECDSA.sol



// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

// File: operator-filter-registry/src/DefaultOperatorFilterer.sol



// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import {OperatorFilterer} from "./OperatorFilterer.sol";
import {CANONICAL_CORI_SUBSCRIPTION} from "./lib/Constants.sol";
/**
 * @title  DefaultOperatorFilterer
 * @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.
 * @dev    Please note that if your token contract does not provide an owner with EIP-173, it must provide
 *         administration methods on the contract itself to interact with the registry otherwise the subscription
 *         will be locked to the options set during construction.
 */

abstract contract DefaultOperatorFilterer is OperatorFilterer {
    /// @dev The constructor that is called when the contract is being deployed.
    constructor() OperatorFilterer(CANONICAL_CORI_SUBSCRIPTION, true) {}
}

// File: erc721a/contracts/ERC721A.sol



// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import './IERC721A.sol';

/**
 * @dev Interface of ERC721 token receiver.
 */
interface ERC721A__IERC721Receiver {
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

/**
 * @title ERC721A
 *
 * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)
 * Non-Fungible Token Standard, including the Metadata extension.
 * Optimized for lower gas during batch mints.
 *
 * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)
 * starting from `_startTokenId()`.
 *
 * Assumptions:
 *
 * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
 * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).
 */
contract ERC721A is IERC721A {
    // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).
    struct TokenApprovalRef {
        address value;
    }

    // =============================================================
    //                           CONSTANTS
    // =============================================================

    // Mask of an entry in packed address data.
    uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;

    // The bit position of `numberMinted` in packed address data.
    uint256 private constant _BITPOS_NUMBER_MINTED = 64;

    // The bit position of `numberBurned` in packed address data.
    uint256 private constant _BITPOS_NUMBER_BURNED = 128;

    // The bit position of `aux` in packed address data.
    uint256 private constant _BITPOS_AUX = 192;

    // Mask of all 256 bits in packed address data except the 64 bits for `aux`.
    uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;

    // The bit position of `startTimestamp` in packed ownership.
    uint256 private constant _BITPOS_START_TIMESTAMP = 160;

    // The bit mask of the `burned` bit in packed ownership.
    uint256 private constant _BITMASK_BURNED = 1 << 224;

    // The bit position of the `nextInitialized` bit in packed ownership.
    uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;

    // The bit mask of the `nextInitialized` bit in packed ownership.
    uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;

    // The bit position of `extraData` in packed ownership.
    uint256 private constant _BITPOS_EXTRA_DATA = 232;

    // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.
    uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;

    // The mask of the lower 160 bits for addresses.
    uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;

    // The maximum `quantity` that can be minted with {_mintERC2309}.
    // This limit is to prevent overflows on the address data entries.
    // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}
    // is required to cause an overflow, which is unrealistic.
    uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;

    // The `Transfer` event signature is given by:
    // `keccak256(bytes("Transfer(address,address,uint256)"))`.
    bytes32 private constant _TRANSFER_EVENT_SIGNATURE =
        0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;

    // =============================================================
    //                            STORAGE
    // =============================================================

    // The next token ID to be minted.
    uint256 private _currentIndex;

    // The number of tokens burned.
    uint256 private _burnCounter;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to ownership details
    // An empty struct value does not necessarily mean the token is unowned.
    // See {_packedOwnershipOf} implementation for details.
    //
    // Bits Layout:
    // - [0..159]   `addr`
    // - [160..223] `startTimestamp`
    // - [224]      `burned`
    // - [225]      `nextInitialized`
    // - [232..255] `extraData`
    mapping(uint256 => uint256) private _packedOwnerships;

    // Mapping owner address to address data.
    //
    // Bits Layout:
    // - [0..63]    `balance`
    // - [64..127]  `numberMinted`
    // - [128..191] `numberBurned`
    // - [192..255] `aux`
    mapping(address => uint256) private _packedAddressData;

    // Mapping from token ID to approved address.
    mapping(uint256 => TokenApprovalRef) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    // =============================================================
    //                          CONSTRUCTOR
    // =============================================================

    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
        _currentIndex = _startTokenId();
    }

    // =============================================================
    //                   TOKEN COUNTING OPERATIONS
    // =============================================================

    /**
     * @dev Returns the starting token ID.
     * To change the starting token ID, please override this function.
     */
    function _startTokenId() internal view virtual returns (uint256) {
        return 0;
    }

    /**
     * @dev Returns the next token ID to be minted.
     */
    function _nextTokenId() internal view virtual returns (uint256) {
        return _currentIndex;
    }

    /**
     * @dev Returns the total number of tokens in existence.
     * Burned tokens will reduce the count.
     * To get the total number of tokens minted, please see {_totalMinted}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        // Counter underflow is impossible as _burnCounter cannot be incremented
        // more than `_currentIndex - _startTokenId()` times.
        unchecked {
            return _currentIndex - _burnCounter - _startTokenId();
        }
    }

    /**
     * @dev Returns the total amount of tokens minted in the contract.
     */
    function _totalMinted() internal view virtual returns (uint256) {
        // Counter underflow is impossible as `_currentIndex` does not decrement,
        // and it is initialized to `_startTokenId()`.
        unchecked {
            return _currentIndex - _startTokenId();
        }
    }

    /**
     * @dev Returns the total number of tokens burned.
     */
    function _totalBurned() internal view virtual returns (uint256) {
        return _burnCounter;
    }

    // =============================================================
    //                    ADDRESS DATA OPERATIONS
    // =============================================================

    /**
     * @dev Returns the number of tokens in `owner`'s account.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        if (owner == address(0)) revert BalanceQueryForZeroAddress();
        return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the number of tokens minted by `owner`.
     */
    function _numberMinted(address owner) internal view returns (uint256) {
        return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the number of tokens burned by or on behalf of `owner`.
     */
    function _numberBurned(address owner) internal view returns (uint256) {
        return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
     */
    function _getAux(address owner) internal view returns (uint64) {
        return uint64(_packedAddressData[owner] >> _BITPOS_AUX);
    }

    /**
     * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
     * If there are multiple variables, please pack them into a uint64.
     */
    function _setAux(address owner, uint64 aux) internal virtual {
        uint256 packed = _packedAddressData[owner];
        uint256 auxCasted;
        // Cast `aux` with assembly to avoid redundant masking.
        assembly {
            auxCasted := aux
        }
        packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX);
        _packedAddressData[owner] = packed;
    }

    // =============================================================
    //                            IERC165
    // =============================================================

    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30000 gas.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        // The interface IDs are constants representing the first 4 bytes
        // of the XOR of all function selectors in the interface.
        // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)
        // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)
        return
            interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.
            interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.
            interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.
    }

    // =============================================================
    //                        IERC721Metadata
    // =============================================================

    /**
     * @dev Returns the token collection name.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        if (!_exists(tokenId)) revert URIQueryForNonexistentToken();

        string memory baseURI = _baseURI();
        return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : '';
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, it can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return '';
    }

    // =============================================================
    //                     OWNERSHIPS OPERATIONS
    // =============================================================

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        return address(uint160(_packedOwnershipOf(tokenId)));
    }

    /**
     * @dev Gas spent here starts off proportional to the maximum mint batch size.
     * It gradually moves to O(1) as tokens get transferred around over time.
     */
    function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {
        return _unpackedOwnership(_packedOwnershipOf(tokenId));
    }

    /**
     * @dev Returns the unpacked `TokenOwnership` struct at `index`.
     */
    function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {
        return _unpackedOwnership(_packedOwnerships[index]);
    }

    /**
     * @dev Initializes the ownership slot minted at `index` for efficiency purposes.
     */
    function _initializeOwnershipAt(uint256 index) internal virtual {
        if (_packedOwnerships[index] == 0) {
            _packedOwnerships[index] = _packedOwnershipOf(index);
        }
    }

    /**
     * Returns the packed ownership data of `tokenId`.
     */
    function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) {
        uint256 curr = tokenId;

        unchecked {
            if (_startTokenId() <= curr)
                if (curr < _currentIndex) {
                    uint256 packed = _packedOwnerships[curr];
                    // If not burned.
                    if (packed & _BITMASK_BURNED == 0) {
                        // Invariant:
                        // There will always be an initialized ownership slot
                        // (i.e. `ownership.addr != address(0) && ownership.burned == false`)
                        // before an unintialized ownership slot
                        // (i.e. `ownership.addr == address(0) && ownership.burned == false`)
                        // Hence, `curr` will not underflow.
                        //
                        // We can directly compare the packed value.
                        // If the address is zero, packed will be zero.
                        while (packed == 0) {
                            packed = _packedOwnerships[--curr];
                        }
                        return packed;
                    }
                }
        }
        revert OwnerQueryForNonexistentToken();
    }

    /**
     * @dev Returns the unpacked `TokenOwnership` struct from `packed`.
     */
    function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {
        ownership.addr = address(uint160(packed));
        ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);
        ownership.burned = packed & _BITMASK_BURNED != 0;
        ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);
    }

    /**
     * @dev Packs ownership data into a single uint256.
     */
    function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {
        assembly {
            // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
            owner := and(owner, _BITMASK_ADDRESS)
            // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.
            result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags))
        }
    }

    /**
     * @dev Returns the `nextInitialized` flag set if `quantity` equals 1.
     */
    function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {
        // For branchless setting of the `nextInitialized` flag.
        assembly {
            // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.
            result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
        }
    }

    // =============================================================
    //                      APPROVAL OPERATIONS
    // =============================================================

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the
     * zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) public payable virtual override {
        address owner = ownerOf(tokenId);

        if (_msgSenderERC721A() != owner)
            if (!isApprovedForAll(owner, _msgSenderERC721A())) {
                revert ApprovalCallerNotOwnerNorApproved();
            }

        _tokenApprovals[tokenId].value = to;
        emit Approval(owner, to, tokenId);
    }

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();

        return _tokenApprovals[tokenId].value;
    }

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom}
     * for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _operatorApprovals[_msgSenderERC721A()][operator] = approved;
        emit ApprovalForAll(_msgSenderERC721A(), operator, approved);
    }

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted. See {_mint}.
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return
            _startTokenId() <= tokenId &&
            tokenId < _currentIndex && // If within bounds,
            _packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.
    }

    /**
     * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.
     */
    function _isSenderApprovedOrOwner(
        address approvedAddress,
        address owner,
        address msgSender
    ) private pure returns (bool result) {
        assembly {
            // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
            owner := and(owner, _BITMASK_ADDRESS)
            // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.
            msgSender := and(msgSender, _BITMASK_ADDRESS)
            // `msgSender == owner || msgSender == approvedAddress`.
            result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))
        }
    }

    /**
     * @dev Returns the storage slot and value for the approved address of `tokenId`.
     */
    function _getApprovedSlotAndAddress(uint256 tokenId)
        private
        view
        returns (uint256 approvedAddressSlot, address approvedAddress)
    {
        TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];
        // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.
        assembly {
            approvedAddressSlot := tokenApproval.slot
            approvedAddress := sload(approvedAddressSlot)
        }
    }

    // =============================================================
    //                      TRANSFER OPERATIONS
    // =============================================================

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token
     * by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public payable virtual override {
        uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);

        if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();

        (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);

        // The nested ifs save around 20+ gas over a compound boolean condition.
        if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
            if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();

        if (to == address(0)) revert TransferToZeroAddress();

        _beforeTokenTransfers(from, to, tokenId, 1);

        // Clear approvals from the previous owner.
        assembly {
            if approvedAddress {
                // This is equivalent to `delete _tokenApprovals[tokenId]`.
                sstore(approvedAddressSlot, 0)
            }
        }

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
        unchecked {
            // We can directly increment and decrement the balances.
            --_packedAddressData[from]; // Updates: `balance -= 1`.
            ++_packedAddressData[to]; // Updates: `balance += 1`.

            // Updates:
            // - `address` to the next owner.
            // - `startTimestamp` to the timestamp of transfering.
            // - `burned` to `false`.
            // - `nextInitialized` to `true`.
            _packedOwnerships[tokenId] = _packOwnershipData(
                to,
                _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)
            );

            // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
            if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
                uint256 nextTokenId = tokenId + 1;
                // If the next slot's address is zero and not burned (i.e. packed value is zero).
                if (_packedOwnerships[nextTokenId] == 0) {
                    // If the next slot is within bounds.
                    if (nextTokenId != _currentIndex) {
                        // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
                        _packedOwnerships[nextTokenId] = prevOwnershipPacked;
                    }
                }
            }
        }

        emit Transfer(from, to, tokenId);
        _afterTokenTransfers(from, to, tokenId, 1);
    }

    /**
     * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public payable virtual override {
        safeTransferFrom(from, to, tokenId, '');
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token
     * by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement
     * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public payable virtual override {
        transferFrom(from, to, tokenId);
        if (to.code.length != 0)
            if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
                revert TransferToNonERC721ReceiverImplementer();
            }
    }

    /**
     * @dev Hook that is called before a set of serially-ordered token IDs
     * are about to be transferred. This includes minting.
     * And also called before burning one token.
     *
     * `startTokenId` - the first token ID to be transferred.
     * `quantity` - the amount to be transferred.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, `tokenId` will be burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _beforeTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}

    /**
     * @dev Hook that is called after a set of serially-ordered token IDs
     * have been transferred. This includes minting.
     * And also called after one token has been burned.
     *
     * `startTokenId` - the first token ID to be transferred.
     * `quantity` - the amount to be transferred.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
     * transferred to `to`.
     * - When `from` is zero, `tokenId` has been minted for `to`.
     * - When `to` is zero, `tokenId` has been burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _afterTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}

    /**
     * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.
     *
     * `from` - Previous owner of the given token ID.
     * `to` - Target address that will receive the token.
     * `tokenId` - Token ID to be transferred.
     * `_data` - Optional data to send along with the call.
     *
     * Returns whether the call correctly returned the expected magic value.
     */
    function _checkContractOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (
            bytes4 retval
        ) {
            return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;
        } catch (bytes memory reason) {
            if (reason.length == 0) {
                revert TransferToNonERC721ReceiverImplementer();
            } else {
                assembly {
                    revert(add(32, reason), mload(reason))
                }
            }
        }
    }

    // =============================================================
    //                        MINT OPERATIONS
    // =============================================================

    /**
     * @dev Mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `quantity` must be greater than 0.
     *
     * Emits a {Transfer} event for each mint.
     */
    function _mint(address to, uint256 quantity) internal virtual {
        uint256 startTokenId = _currentIndex;
        if (quantity == 0) revert MintZeroQuantity();

        _beforeTokenTransfers(address(0), to, startTokenId, quantity);

        // Overflows are incredibly unrealistic.
        // `balance` and `numberMinted` have a maximum limit of 2**64.
        // `tokenId` has a maximum limit of 2**256.
        unchecked {
            // Updates:
            // - `balance += quantity`.
            // - `numberMinted += quantity`.
            //
            // We can directly add to the `balance` and `numberMinted`.
            _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);

            // Updates:
            // - `address` to the owner.
            // - `startTimestamp` to the timestamp of minting.
            // - `burned` to `false`.
            // - `nextInitialized` to `quantity == 1`.
            _packedOwnerships[startTokenId] = _packOwnershipData(
                to,
                _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
            );

            uint256 toMasked;
            uint256 end = startTokenId + quantity;

            // Use assembly to loop and emit the `Transfer` event for gas savings.
            // The duplicated `log4` removes an extra check and reduces stack juggling.
            // The assembly, together with the surrounding Solidity code, have been
            // delicately arranged to nudge the compiler into producing optimized opcodes.
            assembly {
                // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
                toMasked := and(to, _BITMASK_ADDRESS)
                // Emit the `Transfer` event.
                log4(
                    0, // Start of data (0, since no data).
                    0, // End of data (0, since no data).
                    _TRANSFER_EVENT_SIGNATURE, // Signature.
                    0, // `address(0)`.
                    toMasked, // `to`.
                    startTokenId // `tokenId`.
                )

                // The `iszero(eq(,))` check ensures that large values of `quantity`
                // that overflows uint256 will make the loop run out of gas.
                // The compiler will optimize the `iszero` away for performance.
                for {
                    let tokenId := add(startTokenId, 1)
                } iszero(eq(tokenId, end)) {
                    tokenId := add(tokenId, 1)
                } {
                    // Emit the `Transfer` event. Similar to above.
                    log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)
                }
            }
            if (toMasked == 0) revert MintToZeroAddress();

            _currentIndex = end;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Mints `quantity` tokens and transfers them to `to`.
     *
     * This function is intended for efficient minting only during contract creation.
     *
     * It emits only one {ConsecutiveTransfer} as defined in
     * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),
     * instead of a sequence of {Transfer} event(s).
     *
     * Calling this function outside of contract creation WILL make your contract
     * non-compliant with the ERC721 standard.
     * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309
     * {ConsecutiveTransfer} event is only permissible during contract creation.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `quantity` must be greater than 0.
     *
     * Emits a {ConsecutiveTransfer} event.
     */
    function _mintERC2309(address to, uint256 quantity) internal virtual {
        uint256 startTokenId = _currentIndex;
        if (to == address(0)) revert MintToZeroAddress();
        if (quantity == 0) revert MintZeroQuantity();
        if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit();

        _beforeTokenTransfers(address(0), to, startTokenId, quantity);

        // Overflows are unrealistic due to the above check for `quantity` to be below the limit.
        unchecked {
            // Updates:
            // - `balance += quantity`.
            // - `numberMinted += quantity`.
            //
            // We can directly add to the `balance` and `numberMinted`.
            _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);

            // Updates:
            // - `address` to the owner.
            // - `startTimestamp` to the timestamp of minting.
            // - `burned` to `false`.
            // - `nextInitialized` to `quantity == 1`.
            _packedOwnerships[startTokenId] = _packOwnershipData(
                to,
                _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
            );

            emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);

            _currentIndex = startTokenId + quantity;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Safely mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement
     * {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
     * - `quantity` must be greater than 0.
     *
     * See {_mint}.
     *
     * Emits a {Transfer} event for each mint.
     */
    function _safeMint(
        address to,
        uint256 quantity,
        bytes memory _data
    ) internal virtual {
        _mint(to, quantity);

        unchecked {
            if (to.code.length != 0) {
                uint256 end = _currentIndex;
                uint256 index = end - quantity;
                do {
                    if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {
                        revert TransferToNonERC721ReceiverImplementer();
                    }
                } while (index < end);
                // Reentrancy protection.
                if (_currentIndex != end) revert();
            }
        }
    }

    /**
     * @dev Equivalent to `_safeMint(to, quantity, '')`.
     */
    function _safeMint(address to, uint256 quantity) internal virtual {
        _safeMint(to, quantity, '');
    }

    // =============================================================
    //                        BURN OPERATIONS
    // =============================================================

    /**
     * @dev Equivalent to `_burn(tokenId, false)`.
     */
    function _burn(uint256 tokenId) internal virtual {
        _burn(tokenId, false);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId, bool approvalCheck) internal virtual {
        uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);

        address from = address(uint160(prevOwnershipPacked));

        (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);

        if (approvalCheck) {
            // The nested ifs save around 20+ gas over a compound boolean condition.
            if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
                if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
        }

        _beforeTokenTransfers(from, address(0), tokenId, 1);

        // Clear approvals from the previous owner.
        assembly {
            if approvedAddress {
                // This is equivalent to `delete _tokenApprovals[tokenId]`.
                sstore(approvedAddressSlot, 0)
            }
        }

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
        unchecked {
            // Updates:
            // - `balance -= 1`.
            // - `numberBurned += 1`.
            //
            // We can directly decrement the balance, and increment the number burned.
            // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.
            _packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;

            // Updates:
            // - `address` to the last owner.
            // - `startTimestamp` to the timestamp of burning.
            // - `burned` to `true`.
            // - `nextInitialized` to `true`.
            _packedOwnerships[tokenId] = _packOwnershipData(
                from,
                (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked)
            );

            // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
            if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
                uint256 nextTokenId = tokenId + 1;
                // If the next slot's address is zero and not burned (i.e. packed value is zero).
                if (_packedOwnerships[nextTokenId] == 0) {
                    // If the next slot is within bounds.
                    if (nextTokenId != _currentIndex) {
                        // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
                        _packedOwnerships[nextTokenId] = prevOwnershipPacked;
                    }
                }
            }
        }

        emit Transfer(from, address(0), tokenId);
        _afterTokenTransfers(from, address(0), tokenId, 1);

        // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
        unchecked {
            _burnCounter++;
        }
    }

    // =============================================================
    //                     EXTRA DATA OPERATIONS
    // =============================================================

    /**
     * @dev Directly sets the extra data for the ownership data `index`.
     */
    function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {
        uint256 packed = _packedOwnerships[index];
        if (packed == 0) revert OwnershipNotInitializedForExtraData();
        uint256 extraDataCasted;
        // Cast `extraData` with assembly to avoid redundant masking.
        assembly {
            extraDataCasted := extraData
        }
        packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA);
        _packedOwnerships[index] = packed;
    }

    /**
     * @dev Called during each token transfer to set the 24bit `extraData` field.
     * Intended to be overridden by the cosumer contract.
     *
     * `previousExtraData` - the value of `extraData` before transfer.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, `tokenId` will be burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _extraData(
        address from,
        address to,
        uint24 previousExtraData
    ) internal view virtual returns (uint24) {}

    /**
     * @dev Returns the next extra data for the packed ownership data.
     * The returned result is shifted into position.
     */
    function _nextExtraData(
        address from,
        address to,
        uint256 prevOwnershipPacked
    ) private view returns (uint256) {
        uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);
        return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;
    }

    // =============================================================
    //                       OTHER OPERATIONS
    // =============================================================

    /**
     * @dev Returns the message sender (defaults to `msg.sender`).
     *
     * If you are writing GSN compatible contracts, you need to override this function.
     */
    function _msgSenderERC721A() internal view virtual returns (address) {
        return msg.sender;
    }

    /**
     * @dev Converts a uint256 to its ASCII string decimal representation.
     */
    function _toString(uint256 value) internal pure virtual returns (string memory str) {
        assembly {
            // The maximum value of a uint256 contains 78 digits (1 byte per digit), but
            // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.
            // We will need 1 word for the trailing zeros padding, 1 word for the length,
            // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.
            let m := add(mload(0x40), 0xa0)
            // Update the free memory pointer to allocate.
            mstore(0x40, m)
            // Assign the `str` to the end.
            str := sub(m, 0x20)
            // Zeroize the slot after the string.
            mstore(str, 0)

            // Cache the end of the memory to calculate the length later.
            let end := str

            // We write the string from rightmost digit to leftmost digit.
            // The following is essentially a do-while loop that also handles the zero case.
            // prettier-ignore
            for { let temp := value } 1 {} {
                str := sub(str, 1)
                // Write the character to the pointer.
                // The ASCII index of the '0' character is 48.
                mstore8(str, add(48, mod(temp, 10)))
                // Keep dividing `temp` until zero.
                temp := div(temp, 10)
                // prettier-ignore
                if iszero(temp) { break }
            }

            let length := sub(end, str)
            // Move the pointer 32 bytes leftwards to make room for the length.
            str := sub(str, 0x20)
            // Store the length.
            mstore(str, length)
        }
    }
}

// File: operator-filter-registry/src/lib/Constants.sol



// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

address constant CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS = 0x000000000000AAeB6D7670E522A718067333cd4E;
address constant CANONICAL_CORI_SUBSCRIPTION = 0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6;

// File: operator-filter-registry/src/OperatorFilterer.sol



// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import {IOperatorFilterRegistry} from "./IOperatorFilterRegistry.sol";
import {CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS} from "./lib/Constants.sol";
/**
 * @title  OperatorFilterer
 * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another
 *         registrant's entries in the OperatorFilterRegistry.
 * @dev    This smart contract is meant to be inherited by token contracts so they can use the following:
 *         - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.
 *         - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.
 *         Please note that if your token contract does not provide an owner with EIP-173, it must provide
 *         administration methods on the contract itself to interact with the registry otherwise the subscription
 *         will be locked to the options set during construction.
 */

abstract contract OperatorFilterer {
    /// @dev Emitted when an operator is not allowed.
    error OperatorNotAllowed(address operator);

    IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =
        IOperatorFilterRegistry(CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS);

    /// @dev The constructor that is called when the contract is being deployed.
    constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {
        // If an inheriting token contract is deployed to a network without the registry deployed, the modifier
        // will not revert, but the contract will need to be registered with the registry once it is deployed in
        // order for the modifier to filter addresses.
        if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {
            if (subscribe) {
                OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);
            } else {
                if (subscriptionOrRegistrantToCopy != address(0)) {
                    OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);
                } else {
                    OPERATOR_FILTER_REGISTRY.register(address(this));
                }
            }
        }
    }

    /**
     * @dev A helper function to check if an operator is allowed.
     */
    modifier onlyAllowedOperator(address from) virtual {
        // Allow spending tokens from addresses with balance
        // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred
        // from an EOA.
        if (from != msg.sender) {
            _checkFilterOperator(msg.sender);
        }
        _;
    }

    /**
     * @dev A helper function to check if an operator approval is allowed.
     */
    modifier onlyAllowedOperatorApproval(address operator) virtual {
        _checkFilterOperator(operator);
        _;
    }

    /**
     * @dev A helper function to check if an operator is allowed.
     */
    function _checkFilterOperator(address operator) internal view virtual {
        // Check registry code length to facilitate testing in environments without a deployed registry.
        if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {
            // under normal circumstances, this function will revert rather than return false, but inheriting contracts
            // may specify their own OperatorFilterRegistry implementations, which may behave differently
            if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {
                revert OperatorNotAllowed(operator);
            }
        }
    }
}

// File: erc721a/contracts/IERC721A.sol



// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

/**
 * @dev Interface of ERC721A.
 */
interface IERC721A {
    /**
     * The caller must own the token or be an approved operator.
     */
    error ApprovalCallerNotOwnerNorApproved();

    /**
     * The token does not exist.
     */
    error ApprovalQueryForNonexistentToken();

    /**
     * Cannot query the balance for the zero address.
     */
    error BalanceQueryForZeroAddress();

    /**
     * Cannot mint to the zero address.
     */
    error MintToZeroAddress();

    /**
     * The quantity of tokens minted must be more than zero.
     */
    error MintZeroQuantity();

    /**
     * The token does not exist.
     */
    error OwnerQueryForNonexistentToken();

    /**
     * The caller must own the token or be an approved operator.
     */
    error TransferCallerNotOwnerNorApproved();

    /**
     * The token must be owned by `from`.
     */
    error TransferFromIncorrectOwner();

    /**
     * Cannot safely transfer to a contract that does not implement the
     * ERC721Receiver interface.
     */
    error TransferToNonERC721ReceiverImplementer();

    /**
     * Cannot transfer to the zero address.
     */
    error TransferToZeroAddress();

    /**
     * The token does not exist.
     */
    error URIQueryForNonexistentToken();

    /**
     * The `quantity` minted with ERC2309 exceeds the safety limit.
     */
    error MintERC2309QuantityExceedsLimit();

    /**
     * The `extraData` cannot be set on an unintialized ownership slot.
     */
    error OwnershipNotInitializedForExtraData();

    // =============================================================
    //                            STRUCTS
    // =============================================================

    struct TokenOwnership {
        // The address of the owner.
        address addr;
        // Stores the start time of ownership with minimal overhead for tokenomics.
        uint64 startTimestamp;
        // Whether the token has been burned.
        bool burned;
        // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.
        uint24 extraData;
    }

    // =============================================================
    //                         TOKEN COUNTERS
    // =============================================================

    /**
     * @dev Returns the total number of tokens in existence.
     * Burned tokens will reduce the count.
     * To get the total number of tokens minted, please see {_totalMinted}.
     */
    function totalSupply() external view returns (uint256);

    // =============================================================
    //                            IERC165
    // =============================================================

    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);

    // =============================================================
    //                            IERC721
    // =============================================================

    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables
     * (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in `owner`'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`,
     * checking first that contract recipients are aware of the ERC721 protocol
     * to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move
     * this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement
     * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external payable;

    /**
     * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external payable;

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom}
     * whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token
     * by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external payable;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the
     * zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external payable;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom}
     * for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    // =============================================================
    //                        IERC721Metadata
    // =============================================================

    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);

    // =============================================================
    //                           IERC2309
    // =============================================================

    /**
     * @dev Emitted when tokens in `fromTokenId` to `toTokenId`
     * (inclusive) is transferred from `from` to `to`, as defined in the
     * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.
     *
     * See {_mintERC2309} for more details.
     */
    event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);
}

// File: @openzeppelin/contracts/utils/Strings.sol



// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed 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] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

// File: @openzeppelin/contracts/utils/Context.sol



// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

// File: operator-filter-registry/src/IOperatorFilterRegistry.sol



// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

interface IOperatorFilterRegistry {
    /**
     * @notice Returns true if operator is not filtered for a given token, either by address or codeHash. Also returns
     *         true if supplied registrant address is not registered.
     */
    function isOperatorAllowed(address registrant, address operator) external view returns (bool);

    /**
     * @notice Registers an address with the registry. May be called by address itself or by EIP-173 owner.
     */
    function register(address registrant) external;

    /**
     * @notice Registers an address with the registry and "subscribes" to another address's filtered operators and codeHashes.
     */
    function registerAndSubscribe(address registrant, address subscription) external;

    /**
     * @notice Registers an address with the registry and copies the filtered operators and codeHashes from another
     *         address without subscribing.
     */
    function registerAndCopyEntries(address registrant, address registrantToCopy) external;

    /**
     * @notice Unregisters an address with the registry and removes its subscription. May be called by address itself or by EIP-173 owner.
     *         Note that this does not remove any filtered addresses or codeHashes.
     *         Also note that any subscriptions to this registrant will still be active and follow the existing filtered addresses and codehashes.
     */
    function unregister(address addr) external;

    /**
     * @notice Update an operator address for a registered address - when filtered is true, the operator is filtered.
     */
    function updateOperator(address registrant, address operator, bool filtered) external;

    /**
     * @notice Update multiple operators for a registered address - when filtered is true, the operators will be filtered. Reverts on duplicates.
     */
    function updateOperators(address registrant, address[] calldata operators, bool filtered) external;

    /**
     * @notice Update a codeHash for a registered address - when filtered is true, the codeHash is filtered.
     */
    function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;

    /**
     * @notice Update multiple codeHashes for a registered address - when filtered is true, the codeHashes will be filtered. Reverts on duplicates.
     */
    function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;

    /**
     * @notice Subscribe an address to another registrant's filtered operators and codeHashes. Will remove previous
     *         subscription if present.
     *         Note that accounts with subscriptions may go on to subscribe to other accounts - in this case,
     *         subscriptions will not be forwarded. Instead the former subscription's existing entries will still be
     *         used.
     */
    function subscribe(address registrant, address registrantToSubscribe) external;

    /**
     * @notice Unsubscribe an address from its current subscribed registrant, and optionally copy its filtered operators and codeHashes.
     */
    function unsubscribe(address registrant, bool copyExistingEntries) external;

    /**
     * @notice Get the subscription address of a given registrant, if any.
     */
    function subscriptionOf(address addr) external returns (address registrant);

    /**
     * @notice Get the set of addresses subscribed to a given registrant.
     *         Note that order is not guaranteed as updates are made.
     */
    function subscribers(address registrant) external returns (address[] memory);

    /**
     * @notice Get the subscriber at a given index in the set of addresses subscribed to a given registrant.
     *         Note that order is not guaranteed as updates are made.
     */
    function subscriberAt(address registrant, uint256 index) external returns (address);

    /**
     * @notice Copy filtered operators and codeHashes from a different registrantToCopy to addr.
     */
    function copyEntriesOf(address registrant, address registrantToCopy) external;

    /**
     * @notice Returns true if operator is filtered by a given address or its subscription.
     */
    function isOperatorFiltered(address registrant, address operator) external returns (bool);

    /**
     * @notice Returns true if the hash of an address's code is filtered by a given address or its subscription.
     */
    function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);

    /**
     * @notice Returns true if a codeHash is filtered by a given address or its subscription.
     */
    function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);

    /**
     * @notice Returns a list of filtered operators for a given address or its subscription.
     */
    function filteredOperators(address addr) external returns (address[] memory);

    /**
     * @notice Returns the set of filtered codeHashes for a given address or its subscription.
     *         Note that order is not guaranteed as updates are made.
     */
    function filteredCodeHashes(address addr) external returns (bytes32[] memory);

    /**
     * @notice Returns the filtered operator at the given index of the set of filtered operators for a given address or
     *         its subscription.
     *         Note that order is not guaranteed as updates are made.
     */
    function filteredOperatorAt(address registrant, uint256 index) external returns (address);

    /**
     * @notice Returns the filtered codeHash at the given index of the list of filtered codeHashes for a given address or
     *         its subscription.
     *         Note that order is not guaranteed as updates are made.
     */
    function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);

    /**
     * @notice Returns true if an address has registered
     */
    function isRegistered(address addr) external returns (bool);

    /**
     * @dev Convenience method to compute the code hash of an arbitrary contract
     */
    function codeHashOf(address addr) external returns (bytes32);
}

// File: @openzeppelin/contracts/utils/math/Math.sol



// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}