contract AtomicAntz is ERC721Enumerable, PaymentSplitter, AccessControl {
    uint256 public tokenPrice = 80000000000000000;   // .08 ETH
    uint256 private _reserve = 715;
    string private _metadataURI = "https://atomicantz.com/api/metadata.php?TokenID=";
    address[] private _team = [
        0xc03D1E2D94dc8fBCD7b015FD8bA1267245cFf2af, // Alina ~ 10%
        0x7e7837E605BbEAdd43068d61De924CCBf5411B2b, // Colonel Tux ~ 45%
        0x12403CdDaBaFdA1c850f58c48156B477614d5453  // SargentZ ~ 45%
    ];
    uint256[] private _team_shares = [10, 45, 45];
    bool public saleActive = false;
    bytes32 public constant DEV_ROLE = keccak256("DEV");
    string public provenance = "7B8A877D8752BCE9EF234A207394E4E4BA92263CB29A8BDE202854AC896D46BB";
    /**
    * @dev Emitted when `saleActive` switches.
    */
    event SalesFlipped( bool saleActive );

    constructor( ) ERC721( "AtomicAntz", "AAZ" ) PaymentSplitter( _team, _team_shares ) {
        _setupRole( DEV_ROLE, _team[0] );
        _setupRole( DEV_ROLE, _team[1] );
        _setupRole( DEV_ROLE, _team[2] );
        _setupRole( DEFAULT_ADMIN_ROLE, _team[1] );
        _setupRole( DEFAULT_ADMIN_ROLE, _team[2] );
    }
    modifier onlyDev( ) {
        require( hasRole( DEV_ROLE, _msgSender( ) ), "Roles: caller does not have the DEV role" );
        _;
    }
    modifier onlyAdmin( ) {
        require( hasRole( DEFAULT_ADMIN_ROLE, _msgSender( ) ), "Roles: caller does not have the ADMIN role" );
        _;
    }
    function mintAnt( uint quantity ) public payable {
        require( saleActive, "Sale must be active to mint an ant" );
        require( quantity < 21, "Can only mint 20 tokens at a time" );
        uint totalSupply = totalSupply();
        require( totalSupply + quantity < 10001, "Purchase would exceed max supply of ants");
        require( msg.value == tokenPrice * quantity, "Ether value sent is not correct" );
        for( uint i = 0; i < quantity; i++ ) {
            uint mintIndex = totalSupply + i;
            _safeMint( _msgSender( ), mintIndex );
        }
    }
    function airdropAnt( address recipient, uint quantity ) public onlyAdmin( ) {
        require( quantity < _reserve + 1, "Not enough ants left in reserve" );
        uint totalSupply = totalSupply( );
        require( totalSupply + quantity < 11001, "Purchase would exceed max supply of ants" );
        for( uint i = 0; i < quantity; i++ ) {
            uint mintIndex = totalSupply + i;
            _safeMint( recipient, mintIndex );
        }
        _reserve -= quantity;
    }
    function withdraw( ) public onlyAdmin( ) {
        for ( uint256 i = 0; i < _team.length; i++ ) {
            address payable wallet = payable( _team[i] );
            release( wallet );
        }
    }
    function flipSales( ) public onlyDev( ) {
        saleActive = !saleActive;
        emit SalesFlipped(saleActive);
    }
    function setBaseURI( string memory baseURI ) public onlyDev( ) {
        _metadataURI = baseURI;
    }
    function setProvenance( string memory new_povenance ) public onlyDev( ) {
        provenance = new_povenance;
    }
    function _baseURI( ) internal override view returns ( string memory ) {
        return _metadataURI;
    }
    /**
    * @dev See {IERC165-supportsInterface}.
    * Needs to be overridden here as two or more parent classes define it.
    */
    function supportsInterface( bytes4 interfaceId ) public pure override( AccessControl, ERC721Enumerable ) returns ( bool ) {
        bool isIAccessControl = interfaceId == type( IAccessControl ).interfaceId;
        bool isIERC721Enumerable = interfaceId == type( IERC721Enumerable ).interfaceId;
        bool isIERC721 = interfaceId == type( IERC721 ).interfaceId;
        bool isIERC721Metadata = interfaceId == type( IERC721Metadata ).interfaceId;
        bool isIERC165 = interfaceId == type( IERC165 ).interfaceId;
        return isIERC165 || isIERC721 || isIERC721Metadata || isIERC721Enumerable || isIAccessControl;
    }
}
/************************************************************************************
 *                                  ATOMIC    ANTZ                                   *
 ************************************************************************************/
function supportsInterface( bytes4 interfaceId ) public pure override( AccessControl, ERC721Enumerable ) returns ( bool ) {
    bool isIAccessControl = interfaceId == type( IAccessControl ).interfaceId;
    bool isIERC721Enumerable = interfaceId == type( IERC721Enumerable ).interfaceId;
    bool isIERC721 = interfaceId == type( IERC721 ).interfaceId;
    bool isIERC721Metadata = interfaceId == type( IERC721Metadata ).interfaceId;
    bool isIERC165 = interfaceId == type( IERC165 ).interfaceId;
    return isIERC165 || isIERC721 || isIERC721Metadata || isIERC721Enumerable || isIAccessControl;
}

/**
 * @dev See {IERC165-supportsInterface}.
 * Needs to be overridden here as two or more parent classes define it.
 */