abstract contract Pausable is Context, Ownable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;
    bool private _allowMinting;
    bool private _allowExtending;

    /**
     * @dev Initializes the contract in paused state.
     */
    constructor() {
        _paused = true;
        _allowMinting = false;
        _allowExtending = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    modifier whenMintingOpen() {
        require(!paused() && _allowMinting, "Minting is not open");
        _;
    }

    modifier whenExtendingOpen() {
        require(!paused() && _allowExtending, "Extending is not open");
        _;
    }

    function pause() external onlyOwner {
        _pause();
    }

    function unpause() external onlyOwner {
        _unpause();
    }

    function openExtending() external onlyOwner {
        _openExtending();
    }

    function closeExtending() external onlyOwner {
        _closeExtending();
    }

    function openMinting() external onlyOwner {
        _openMinting();
    }

    function closeMinting() external onlyOwner {
        _closeMinting();
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }

    function _openMinting() internal virtual whenNotPaused {
        _allowMinting = true;
    }

    function _closeMinting() internal virtual {
        _allowMinting = false;
    }

    function _openExtending() internal virtual whenNotPaused {
        _allowExtending = true;
    }

    function _closeExtending() internal virtual {
        _allowExtending = false;
    }
}
/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
/**
 * @dev Returns to normal state.
 *
 * Requirements:
 *
 * - The contract must be paused.
 */