ETH Price: $1,981.97 (-4.49%)

Contract

0x0134E4C83b5A5B5B45F2238FaabDFfC6C30fe575
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Reveal Note241361072026-01-01 0:10:5965 days ago1767226259IN
0x0134E4C8...6C30fe575
0 ETH0.000149120.15547956
Set Seven Words241347362025-12-31 19:35:5965 days ago1767209759IN
0x0134E4C8...6C30fe575
0 ETH0.000017250.14572481
Safe Transfer Fr...240907882025-12-25 16:19:2371 days ago1766679563IN
0x0134E4C8...6C30fe575
0 ETH0.000001970.03332461
Set Seven Words240762152025-12-23 15:29:4773 days ago1766503787IN
0x0134E4C8...6C30fe575
0 ETH0.000018680.19461203
Set Seven Words240762092025-12-23 15:28:3573 days ago1766503715IN
0x0134E4C8...6C30fe575
0 ETH0.000070620.59681953
Set Seven Words240343192025-12-17 19:07:5979 days ago1765998479IN
0x0134E4C8...6C30fe575
0 ETH0.000023080.19500505
Finalize Permuta...240331782025-12-17 15:18:4779 days ago1765984727IN
0x0134E4C8...6C30fe575
0 ETH0.000037120.70292484
Ingest Permutati...240331752025-12-17 15:18:1179 days ago1765984691IN
0x0134E4C8...6C30fe575
0 ETH0.000130160.77256736
Ingest Permutati...240331732025-12-17 15:17:4779 days ago1765984667IN
0x0134E4C8...6C30fe575
0 ETH0.000475250.80366226
Ingest Permutati...240331712025-12-17 15:17:2379 days ago1765984643IN
0x0134E4C8...6C30fe575
0 ETH0.000474420.80038757
Ingest Permutati...240331692025-12-17 15:16:5979 days ago1765984619IN
0x0134E4C8...6C30fe575
0 ETH0.000461140.7751803
Ingest Permutati...240331662025-12-17 15:16:2379 days ago1765984583IN
0x0134E4C8...6C30fe575
0 ETH0.00053970.83876865
Withdraw240330812025-12-17 14:58:5979 days ago1765983539IN
0x0134E4C8...6C30fe575
0 ETH0.000028150.72262576
Request Permutat...240329402025-12-17 14:30:2379 days ago1765981823IN
0x0134E4C8...6C30fe575
0 ETH0.000004060.03241189
Set Mint Enabled240279182025-12-16 21:41:2380 days ago1765921283IN
0x0134E4C8...6C30fe575
0 ETH0.000001030.03889157
Mint240275442025-12-16 20:26:1180 days ago1765916771IN
0x0134E4C8...6C30fe575
0.01 ETH0.000013910.03570336
Mint240274172025-12-16 20:00:3580 days ago1765915235IN
0x0134E4C8...6C30fe575
0.002 ETH0.00022252.03304579
Mint240261492025-12-16 15:45:2380 days ago1765899923IN
0x0134E4C8...6C30fe575
0.01 ETH0.000025410.06245441
Mint240259692025-12-16 15:09:2380 days ago1765897763IN
0x0134E4C8...6C30fe575
0.004 ETH0.000016030.08153208
Mint240195952025-12-15 17:48:3581 days ago1765820915IN
0x0134E4C8...6C30fe575
0.002 ETH0.000017070.13494431
Mint240169592025-12-15 8:58:2381 days ago1765789103IN
0x0134E4C8...6C30fe575
0.002 ETH0.000223082.03830283
Mint240169512025-12-15 8:56:4781 days ago1765789007IN
0x0134E4C8...6C30fe575
0.002 ETH0.000223252.03988085
Mint240169492025-12-15 8:56:2381 days ago1765788983IN
0x0134E4C8...6C30fe575
0.002 ETH0.000222742.03526995
Mint240169462025-12-15 8:55:4781 days ago1765788947IN
0x0134E4C8...6C30fe575
0.002 ETH0.000223132.03883978
Mint240169442025-12-15 8:55:2381 days ago1765788923IN
0x0134E4C8...6C30fe575
0.002 ETH0.000222762.03542906
View all transactions

Latest 2 internal transactions

Advanced mode:
Parent Transaction Hash Method Block
From
To
Transfer240330812025-12-17 14:58:5979 days ago1765983539
0x0134E4C8...6C30fe575
0.844 ETH
Transfer239768672025-12-09 18:01:1187 days ago1765303271
0x0134E4C8...6C30fe575
0.002 ETH
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
EveryTwoMillionBlocks

Compiler Version
v0.8.30+commit.73712a01

Optimization Enabled:
Yes with 1 runs

Other Settings:
prague EvmVersion
File 1 of 29 : EveryTwoMillionBlocks.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
                                             

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Base64.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

// Interfaces for external contracts
import "../interfaces/ISongAlgorithm.sol";
import "../interfaces/IMusicRenderer.sol";
import "../interfaces/IAudioRenderer.sol";
import "../interfaces/IPointsManager.sol";
import "../interfaces/IPointsAggregator.sol";
import "../interfaces/IVRFCoordinatorV2_5.sol";
import "@chainlink/contracts/src/v0.8/vrf/dev/libraries/VRFV2PlusClient.sol";
import { BokkyPooBahsDateTimeLibrary as DateTime } from "../../lib/bokkypon/BokkyPooBahsDateTimeLibrary.sol";

// Countdown renderer (external contract)
import "../render/IRenderTypes.sol";
import "../render/pre/IPreRevealRegistry.sol";
import "./RevealEngine.sol";

interface ICountdownRenderer {
    function render(RenderTypes.RenderCtx memory ctx) external view returns (string memory);
}

interface ICountdownHtmlRenderer {
    function render(RenderTypes.RenderCtx memory ctx) external view returns (string memory);
}

/**
 * @title EveryTwoMillionBlocks
 * @dev ERC-721 orchestrator that wires external renderers/points modules to stay under the size cap.
 */
contract EveryTwoMillionBlocks is ERC721, Ownable, ReentrancyGuard {
    using RevealEngine for RevealEngine.PendingStorage;
    using Strings for uint256;
    
    uint256 public constant START_YEAR = 2026;

    error TokenDoesNotExist();
    error TokenAlreadyRevealed();
    error RevealAlreadyPending();
    error RevealNotPending();
    error SnapshotMissing();
    error SevenWordsChanged();
    error NotRevealTime();

    uint256 public totalMinted;
    bool public mintEnabled;
    uint256 public mintPrice;
    address payable public payoutAddress;
    mapping(uint256 => uint32) public tokenSeed;
    
    // New Reveal Logic State
    uint256 public totalRevealedCount;
    mapping(uint256 => uint256) public finalYear;

    // --- EXTERNAL CONTRACT ADDRESSES ---
    ISongAlgorithm public songAlgorithm;
    IMusicRenderer public musicRenderer;
    IAudioRenderer public audioRenderer;
    IPointsManager public pointsManager;
    IPointsAggregator public pointsAggregator;
    IPreRevealRegistry public preRevealRegistry;

    IVRFCoordinatorV2_5 public vrfCoordinator;
    bytes32 public vrfKeyHash;
    uint256 public vrfSubscriptionId;
    uint16 public vrfMinConfirmations;
    uint32 public vrfCallbackGasLimit;
    uint32 public vrfNumWords = 1;
    uint256 public vrfRequestId;
    bool public vrfRequestInFlight;
    bytes32 public permutationSeed;
    bool public permutationSeedFulfilled;
    
    bool public renderersFinalized;
    
    // --- DYNAMIC RANKING ---
    mapping(uint256 => uint256) public basePermutation;
    bool public permutationFinalized;
    uint256 public permutationEntryCount;
    uint256 public permutationChunkCount;
    
    // --- REVEAL SYSTEM ---
    mapping(uint256 => bool) public revealed;
    mapping(uint256 => ISongAlgorithm.Event) public revealedLeadNote;
    mapping(uint256 => ISongAlgorithm.Event) public revealedBassNote;
    mapping(uint256 => uint256) public revealBlockTimestamp;
    mapping(uint256 => uint256) public finalRank;
    
    // --- SEED COMPONENTS ---
    mapping(uint256 => bytes32) public sevenWords;
    mapping(uint256 => string) public sevenWordsText;
    bytes32 public previousNotesHash;
    bytes32 public globalState;
    
    // --- TWO-STEP REVEAL STATE ---
    RevealEngine.PendingStorage private pendingSnapshots;
    mapping(uint256 => bool) public revealPending;

    struct PreRevealSelection {
        uint256 rendererId;
        uint256 defaultRendererId;
        address svgRenderer;
        address htmlRenderer;
        address defaultSvgRenderer;
        address defaultHtmlRenderer;
    }
    
    event NoteRevealed(
        uint256 indexed tokenId, 
        uint256 beat, 
        int16 leadPitch, 
        int16 bassPitch,
        uint256 timestamp
    );
    
    event RenderersUpdated(address music, address audio, address countdown);
    event RenderersFinalized();
    event PointsManagerUpdated(address pointsManager);
    event PointsAggregatorUpdated(address pointsAggregator);
    event RevealPrepared(uint256 indexed tokenId, uint32 beat, bytes32 words);
    event RevealCancelled(uint256 indexed tokenId);
    event PermutationChunkIngested(uint256 indexed chunkId, uint256 count);
    event PermutationFinalized(uint256 totalEntries);
    event VRFConfigUpdated(
        address indexed coordinator,
        bytes32 keyHash,
        uint256 subscriptionId,
        uint16 minConfirmations,
        uint32 callbackGasLimit,
        uint32 numWords
    );
    event PermutationSeedRequested(uint256 indexed requestId);
    event PermutationSeedFulfilled(uint256 indexed requestId, bytes32 seed);
    event PermutationSeedManuallySet(bytes32 seed);
    event TokenPreRevealRendererSelected(uint256 indexed tokenId, uint256 indexed rendererId, address indexed caller);
    event TokenPreRevealRendererCleared(uint256 indexed tokenId, address indexed caller);
    event PreRevealRegistryUpdated(address indexed registry);

    constructor() ERC721("Every Two Million Blocks", "E2MB") Ownable(msg.sender) {}
    
    // --- RENDERER MANAGEMENT ---
    modifier renderersNotFinalized() {
        require(!renderersFinalized, "Renderers finalized");
        _;
    }

    /// @notice Set external contract addresses (only before finalization)
    function setRenderers(
        address _songAlgorithm,
        address _music,
        address _audio
    ) external onlyOwner renderersNotFinalized {
        songAlgorithm = ISongAlgorithm(_songAlgorithm);
        musicRenderer = IMusicRenderer(_music);
        audioRenderer = IAudioRenderer(_audio);
        emit RenderersUpdated(_music, _audio, _songAlgorithm);
    }
    
    /// @notice Set points manager address (only before finalization)
    function setPointsManager(address _pointsManager) external onlyOwner renderersNotFinalized {
        pointsManager = IPointsManager(_pointsManager);
        emit PointsManagerUpdated(_pointsManager);
    }

    /// @notice Set points aggregator address (only before finalization)
    function setPointsAggregator(address _pointsAggregator) external onlyOwner renderersNotFinalized {
        pointsAggregator = IPointsAggregator(_pointsAggregator);
        emit PointsAggregatorUpdated(_pointsAggregator);
    }

    /// @notice Configure the external pre-reveal registry contract
    function setPreRevealRegistry(address registry) external onlyOwner renderersNotFinalized {
        require(registry != address(0), "Invalid registry");
        preRevealRegistry = IPreRevealRegistry(registry);
        require(preRevealRegistry.controller() == address(this), "Registry controller mismatch");
        emit PreRevealRegistryUpdated(registry);
    }

    /// @notice Configure Chainlink VRF settings (only before finalization)
    function configureVRF(
        address _coordinator,
        bytes32 _keyHash,
        uint256 _subscriptionId,
        uint16 _minConfirmations,
        uint32 _callbackGasLimit,
        uint32 _numWords
    ) external onlyOwner renderersNotFinalized {
        require(_coordinator != address(0), "Invalid coordinator");
        require(_keyHash != bytes32(0), "Invalid key hash");
        require(_subscriptionId != 0, "Invalid subscription");
        require(_minConfirmations > 0, "Confirmations=0");
        require(_callbackGasLimit > 0, "Callback gas=0");
        require(_numWords > 0, "Num words=0");

        vrfCoordinator = IVRFCoordinatorV2_5(_coordinator);
        vrfKeyHash = _keyHash;
        vrfSubscriptionId = _subscriptionId;
        vrfMinConfirmations = _minConfirmations;
        vrfCallbackGasLimit = _callbackGasLimit;
        vrfNumWords = _numWords;

        emit VRFConfigUpdated(_coordinator, _keyHash, _subscriptionId, _minConfirmations, _callbackGasLimit, _numWords);
    }

    /// @notice Manually set the permutation seed (testing fallback)
    function setPermutationSeedManual(bytes32 seed) external onlyOwner renderersNotFinalized {
        permutationSeed = seed;
        permutationSeedFulfilled = true;
        vrfRequestInFlight = false;
        vrfRequestId = 0;
        emit PermutationSeedManuallySet(seed);
    }

    /// @notice Request randomness from Chainlink VRF to seed the permutation shuffle
    function requestPermutationSeed() external onlyOwner renderersNotFinalized {
        require(address(vrfCoordinator) != address(0), "VRF not configured");
        require(!vrfRequestInFlight, "Request in flight");

        uint256 requestId = vrfCoordinator.requestRandomWords(
            IVRFCoordinatorV2_5.RandomWordsRequest({
                keyHash: vrfKeyHash,
                subId: vrfSubscriptionId,
                requestConfirmations: vrfMinConfirmations,
                callbackGasLimit: vrfCallbackGasLimit,
                numWords: vrfNumWords,
                extraArgs: VRFV2PlusClient._argsToBytes(
                    VRFV2PlusClient.ExtraArgsV1({nativePayment: true})
                )
            })
        );

        vrfRequestId = requestId;
        vrfRequestInFlight = true;
        permutationSeedFulfilled = false;

        emit PermutationSeedRequested(requestId);
    }
    
    /// @notice Assign a renderer slot to a token (token owner or approved)
    function setTokenPreRevealRenderer(uint256 tokenId, uint256 rendererId) external {
        address tokenOwner = _requireMinted(tokenId);
        require(_isAuthorized(tokenOwner, msg.sender, tokenId), "Not authorized");
        if (revealed[tokenId]) revert TokenAlreadyRevealed();
        require(address(preRevealRegistry) != address(0), "Registry not set");
        bool hasWords = bytes(sevenWordsText[tokenId]).length > 0;
        if (!hasWords) {
            IPreRevealRegistry.Renderer memory rendererInfo = preRevealRegistry.getRenderer(rendererId);
            if (rendererInfo.requiresSevenWords) {
                revert("Seven words not set");
            }
        }
        preRevealRegistry.setTokenRenderer(tokenId, rendererId, hasWords);
        emit TokenPreRevealRendererSelected(tokenId, rendererId, msg.sender);
    }

    /// @notice Clear a token's manual renderer choice so it falls back to the default slot
    function clearTokenPreRevealRenderer(uint256 tokenId) external {
        address tokenOwner = _requireMinted(tokenId);
        require(_isAuthorized(tokenOwner, msg.sender, tokenId), "Not authorized");
        require(address(preRevealRegistry) != address(0), "Registry not set");
        preRevealRegistry.clearTokenRenderer(tokenId);
        emit TokenPreRevealRendererCleared(tokenId, msg.sender);
    }

    /// @notice Finalize renderer addresses (one-way, cannot be changed after)
    function finalizeRenderers() external onlyOwner {
        renderersFinalized = true;
        emit RenderersFinalized();
    }

    // --- MINTING ---
    event MintStatusUpdated(bool enabled);
    event MintPriceUpdated(uint256 price);
    event PayoutAddressUpdated(address payout);

    function setMintEnabled(bool enabled) external onlyOwner {
        mintEnabled = enabled;
        emit MintStatusUpdated(enabled);
    }

    function setMintPrice(uint256 price) external onlyOwner {
        mintPrice = price;
        emit MintPriceUpdated(price);
    }

    function setPayoutAddress(address payable payout) external onlyOwner {
        require(payout != address(0), "Invalid payout");
        payoutAddress = payout;
        emit PayoutAddressUpdated(payout);
    }

    function mint(uint256 count) external payable nonReentrant returns (uint256[] memory tokenIds) {
        tokenIds = _mintBatch(msg.sender, count);
    }

    function mint(uint32[] calldata seeds) external payable nonReentrant returns (uint256[] memory tokenIds) {
        tokenIds = _mintBatch(msg.sender, seeds.length);
    }

    function _mintBatch(address minter, uint256 count) internal returns (uint256[] memory tokenIds) {
        require(mintEnabled, "Mint disabled");
        require(count > 0, "Empty batch");
        uint256 totalCost = mintPrice * count;
        require(msg.value == totalCost, "Incorrect payment");

        tokenIds = new uint256[](count);
        for (uint256 i = 0; i < count; i++) {
            tokenIds[i] = _mintToken(minter, 0);
        }
    }

    function _mintToken(address to, uint32 seed) internal returns (uint256 tokenId) {
        tokenId = ++totalMinted;
        _safeMint(to, tokenId);
        tokenSeed[tokenId] = (seed == 0)
            ? uint32(uint256(keccak256(abi.encodePacked(block.timestamp, block.prevrandao, to, msg.sender, tokenId))))
            : seed;

        basePermutation[tokenId] = tokenId - 1;
    }

    function withdraw() external onlyOwner nonReentrant {
        address payable recipient = payoutAddress;
        require(recipient != address(0), "Payout not set");
        uint256 balance = address(this).balance;
        require(balance > 0, "No balance");
        (bool success, ) = recipient.call{value: balance}("");
        require(success, "Withdraw failed");
    }
    /// @notice Ingest a batch of permutation entries before finalization
    function ingestPermutationChunk(
        uint256[] calldata tokenIds,
        uint256[] calldata permutationIndices
    ) external onlyOwner renderersNotFinalized {
        require(!permutationFinalized, "Permutation finalized");
        require(tokenIds.length == permutationIndices.length, "Length mismatch");
        uint256 length = tokenIds.length;
        require(length > 0, "Empty chunk");

        for (uint256 i = 0; i < length; i++) {
            basePermutation[tokenIds[i]] = permutationIndices[i];
        }

        unchecked {
            permutationEntryCount += length;
            permutationChunkCount += 1;
        }

        emit PermutationChunkIngested(permutationChunkCount, length);
    }

    /// @notice Finalize permutation data; irreversible
    function finalizePermutation() external onlyOwner renderersNotFinalized {
        require(!permutationFinalized, "Already finalized");
        require(permutationSeedFulfilled, "Permutation seed not ready");
        permutationFinalized = true;
        emit PermutationFinalized(permutationEntryCount);
    }
    
    /// @notice Set the seven words for a token (owner can do this before reveal)
    function setSevenWords(uint256 tokenId, string calldata wordsText) external {
        require(_ownerOf(tokenId) == msg.sender, "Not token owner");
        if (revealed[tokenId]) revert TokenAlreadyRevealed();
        require(bytes(wordsText).length > 0, "Words required");
        require(bytes(sevenWordsText[tokenId]).length == 0, "Seven words locked");
        sevenWords[tokenId] = keccak256(bytes(wordsText));
        sevenWordsText[tokenId] = wordsText;
    }

    function hasSevenWords(uint256 tokenId) public view returns (bool) {
        _requireMinted(tokenId);
        return bytes(sevenWordsText[tokenId]).length > 0;
    }

    function pendingBeat(uint256 tokenId) external view returns (uint32) {
        return pendingSnapshots.data[tokenId].beat;
    }

    function pendingWords(uint256 tokenId) external view returns (bytes32) {
        return pendingSnapshots.data[tokenId].wordsHash;
    }
    
    /// @notice Initialize or update global state (owner only, for testing)
    function setGlobalState(bytes32 newState) external onlyOwner {
        globalState = newState;
    }

    // --- REVEAL FUNCTIONS ---
    function revealNote(uint256 tokenId) external {
        _requireMinted(tokenId);
        if (revealed[tokenId]) revert TokenAlreadyRevealed();
        
        uint256 rank = getCurrentRank(tokenId);
        uint256 revealYear = _scheduledRevealYear(rank);
        _enforceRevealTime(revealYear);
        
        _performReveal(
            tokenId,
            rank,
            revealYear,
            sevenWords[tokenId],
            previousNotesHash,
            globalState
        );
    }
    
    /// @notice Test helper that bypasses the time gate
    function forceReveal(uint256 tokenId) external onlyOwner {
        _requireMinted(tokenId);
        if (revealed[tokenId]) revert TokenAlreadyRevealed();
        
        uint256 rank = getCurrentRank(tokenId);
        uint256 revealYear = _scheduledRevealYear(rank);
        _performReveal(
            tokenId,
            rank,
            revealYear,
            sevenWords[tokenId],
            previousNotesHash,
            globalState
        );
    }
    
    // --- TWO-STEP REVEAL (Gas-Optimized) ---
    
    /// @notice Step 1: Prepare reveal by computing rank and locking inputs
    /// @dev Separates expensive rank computation from music generation
    function prepareReveal(uint256 tokenId) external {
        _requireMinted(tokenId);
        if (revealed[tokenId]) revert TokenAlreadyRevealed();
        if (revealPending[tokenId]) revert RevealAlreadyPending();
        
        // Snapshot current rank (PointsManager handles ordering)
        uint256 rank = getCurrentRank(tokenId);
        uint256 revealYear = _scheduledRevealYear(rank);
        _enforceRevealTime(revealYear);
        
        // Cache data so finalizeReveal cannot be manipulated mid-flow
        pendingSnapshots.stage(
            tokenId,
            uint32(rank),
            revealYear,
            sevenWords[tokenId],
            previousNotesHash,
            globalState
        );
        revealPending[tokenId] = true;
        
        emit RevealPrepared(tokenId, uint32(rank), sevenWords[tokenId]);
    }
    
    /// @notice Step 2: Finalize reveal by generating and storing music
    /// @dev Uses snapshotted inputs from prepareReveal
    function finalizeReveal(uint256 tokenId) external {
        _requireMinted(tokenId);
        if (!revealPending[tokenId]) revert RevealNotPending();
        if (revealed[tokenId]) revert TokenAlreadyRevealed();
        
        RevealEngine.PendingSnapshot storage snapshot = pendingSnapshots.snapshot(tokenId);
        if (!snapshot.initialized) revert SnapshotMissing();
        if (sevenWords[tokenId] != snapshot.wordsHash) revert SevenWordsChanged();
        _enforceRevealTime(snapshot.revealYear);
        uint32 beat = snapshot.beat;
        finalRank[tokenId] = beat;

        // Calculate and store final reveal year
        finalYear[tokenId] = snapshot.revealYear;
        totalRevealedCount++;

        // Flip storage flags
        revealed[tokenId] = true;
        revealBlockTimestamp[tokenId] = block.timestamp;
        
        // Seed rests on cached words and rolling hash
        uint32 seed = _computeRevealSeed(
            tokenId,
            snapshot.wordsHash,
            snapshot.previousNotesHash,
            snapshot.globalState
        );
        
        // Produce deterministic events
        (ISongAlgorithm.Event memory lead, ISongAlgorithm.Event memory bass) = 
            songAlgorithm.generateBeat(beat, seed);
        
        // Persist generated events
        revealedLeadNote[tokenId] = lead;
        revealedBassNote[tokenId] = bass;
        
        // Extend rolling hash
        previousNotesHash = keccak256(abi.encodePacked(
            previousNotesHash,
            lead.pitch,
            lead.duration,
            bass.pitch,
            bass.duration
        ));
        
        // Clear staging slots
        revealPending[tokenId] = false;
        pendingSnapshots.clear(tokenId);

        _notifyReveal(tokenId);
        
        emit NoteRevealed(tokenId, beat, lead.pitch, bass.pitch, block.timestamp);
    }
    
    /// @notice Cancel a pending reveal
    /// @dev Allows owner or token owner to reset pending state
    function cancelReveal(uint256 tokenId) external {
        require(msg.sender == owner() || msg.sender == _ownerOf(tokenId), "Not authorized");
        if (!revealPending[tokenId]) revert RevealNotPending();
        
        revealPending[tokenId] = false;
        pendingSnapshots.clear(tokenId);
        
        emit RevealCancelled(tokenId);
    }
    
    function _performReveal(
        uint256 tokenId,
        uint256 rank,
        uint256 revealYear,
        bytes32 wordsHash,
        bytes32 notesHashSnapshot,
        bytes32 globalStateSnapshot
    ) private {
        revealed[tokenId] = true;
        revealBlockTimestamp[tokenId] = block.timestamp;
        
        uint32 beat = uint32(rank);
        finalRank[tokenId] = rank;
        finalYear[tokenId] = revealYear;
        totalRevealedCount++;
        uint32 seed = _computeRevealSeed(tokenId, wordsHash, notesHashSnapshot, globalStateSnapshot);
        
        (ISongAlgorithm.Event memory lead, ISongAlgorithm.Event memory bass) = 
            songAlgorithm.generateBeat(beat, seed);
        
        revealedLeadNote[tokenId] = lead;
        revealedBassNote[tokenId] = bass;
        
        previousNotesHash = keccak256(abi.encodePacked(
            previousNotesHash,
            lead.pitch,
            lead.duration,
            bass.pitch,
            bass.duration
        ));
        
        _notifyReveal(tokenId);
        emit NoteRevealed(tokenId, beat, lead.pitch, bass.pitch, block.timestamp);
    }
    
    function _enforceRevealTime(uint256 revealYear) private view {
        uint256 revealTime = _jan1Timestamp(revealYear);
        if (block.timestamp < revealTime) revert NotRevealTime();
    }
    
    function _scheduledRevealYear(uint256 rank) private view returns (uint256) {
        if (rank < 73) {
            return START_YEAR + totalRevealedCount + rank;
        }
        return START_YEAR + rank;
    }

    function _computeRevealSeed(
        uint256 tokenId,
        bytes32 wordsHash,
        bytes32 notesHashSnapshot,
        bytes32 globalStateSnapshot
    ) private view returns (uint32) {
        return uint32(uint256(keccak256(abi.encodePacked(
            tokenSeed[tokenId],
            wordsHash,
            notesHashSnapshot,
            globalStateSnapshot,
            tokenId
        ))));
    }

    function _notifyReveal(uint256 tokenId) private {
        if (address(pointsAggregator) != address(0)) {
            try pointsAggregator.onTokenRevealed(tokenId) {
                // no-op
            } catch {
                // Ignore failures so reveals cannot be blocked
            }
        }
    }

    function _requireMinted(uint256 tokenId) private view returns (address owner) {
        owner = _ownerOf(tokenId);
        if (owner == address(0)) revert TokenDoesNotExist();
    }

    function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external {
        require(msg.sender == address(vrfCoordinator), "Only VRF coordinator");
        _fulfillPermutationSeed(requestId, randomWords);
    }

    function _fulfillPermutationSeed(uint256 requestId, uint256[] memory randomWords) internal {
        require(vrfRequestInFlight, "No request");
        require(requestId == vrfRequestId, "Request mismatch");
        require(randomWords.length > 0, "Empty random words");

        bytes32 seed = keccak256(abi.encodePacked(randomWords));
        permutationSeed = seed;
        permutationSeedFulfilled = true;
        vrfRequestInFlight = false;
        vrfRequestId = requestId;

        emit PermutationSeedFulfilled(requestId, seed);
    }

    // --- RANKING SYSTEM ---
    
    /// @notice Get current rank for a token (0-indexed)
    /// @dev Delegates to PointsManager if set, otherwise falls back to tokenId order
    function getCurrentRank(uint256 tokenId) public view virtual returns (uint256) {
        _requireMinted(tokenId);
        
        if (address(pointsManager) != address(0)) {
            return pointsManager.currentRankOf(tokenId);
        } else {
            // Fallback: simple tokenId-based ranking
            return tokenId - 1;
        }
    }
    
    /// @notice Get points for a token
    /// @dev Delegates to PointsManager if set, otherwise returns 0
    function getPoints(uint256 tokenId) public view returns (uint256) {
        if (address(pointsManager) != address(0)) {
            return pointsManager.pointsOf(tokenId);
        } else {
            return 0;
        }
    }
    
    /// @notice Get total number of tokens minted
    function totalSupply() external view returns (uint256) {
        return totalMinted;
    }

    /// @notice Returns true if the permutation seed has been set (via VRF or manual override)
    function hasPermutationSeed() external view returns (bool) {
        return permutationSeedFulfilled;
    }
    
    /// @notice Get song algorithm address
    function getSongAlgorithm() external view returns (address) {
        return address(songAlgorithm);
    }
    
    /// @notice Get music renderer address
    function getMusicRenderer() external view returns (address) {
        return address(musicRenderer);
    }
    
    /// @notice Get audio renderer address
    function getAudioRenderer() external view returns (address) {
        return address(audioRenderer);
    }

    // --- TOKEN URI ---
    function tokenURI(uint256 tokenId) public view override returns (string memory) {
        _requireMinted(tokenId);
        
        bool isRevealed = revealed[tokenId];
        uint256 rank = isRevealed ? finalRank[tokenId] : getCurrentRank(tokenId);
        
        uint256 revealYear;
        if (isRevealed) {
            revealYear = finalYear[tokenId];
        } else {
            if (rank < 73) {
                revealYear = START_YEAR + totalRevealedCount + rank;
            } else {
                revealYear = START_YEAR + rank;
            }
        }
        
        string memory image;
        string memory animationUrl = "";
        string memory description;
        string memory wordsText = sevenWordsText[tokenId];
        bool hasWords = bytes(wordsText).length > 0;
        string memory escapedWords = "";
        if (hasWords) {
            escapedWords = _escapeJsonString(wordsText);
        }
        
        if (!isRevealed) {
            // Pre-reveal path delegates to the registry
            uint256 revealTime = _jan1Timestamp(revealYear);
            uint256 blocksRemaining = (revealTime > block.timestamp) 
                ? (revealTime - block.timestamp) / 12
                : 0;
            
            uint256 closenessBps = 10000;
            uint256 startTime = _jan1Timestamp(START_YEAR);
            if (revealTime > block.timestamp && block.timestamp >= startTime) {
                uint256 totalTime = revealTime - startTime;
                uint256 elapsed = block.timestamp - startTime;
                if (totalTime > 0) {
                    closenessBps = (elapsed * 10000) / totalTime;
                }
            } else if (block.timestamp < startTime) {
                // Clamp to zero before the program begins
                closenessBps = 0;
            }
            
            RenderTypes.RenderCtx memory ctx = RenderTypes.RenderCtx({
                tokenId: tokenId,
                // rank removed
                revealYear: revealYear,
                closenessBps: closenessBps > 10000 ? 10000 : closenessBps,
                blocksDisplay: blocksRemaining,
                seed: tokenSeed[tokenId],
                nowTs: block.timestamp
            });

            PreRevealSelection memory selection = _resolvePreRevealSelection(tokenId, hasWords);
            string memory svgContent = _renderPreRevealSVG(selection, ctx);
            // Encode as data URI
            image = string(abi.encodePacked(
                "data:image/svg+xml;base64,",
                Base64.encode(bytes(svgContent))
            ));
            
            // Attach HTML renderer output if available
            string memory html = _renderPreRevealHtml(selection, ctx);
            if (bytes(html).length > 0) {
                animationUrl = html;
            }
            
            description = hasWords
                ? escapedWords 
                : string(abi.encodePacked(
                    "Every Two Million Blocks token #", tokenId.toString(),
                    " will reveal on Jan 1, ", revealYear.toString(), " UTC"
                  ));
        } else {
            // Post-reveal path uses the final renderer stack
            ISongAlgorithm.Event memory lead = revealedLeadNote[tokenId];
            ISongAlgorithm.Event memory bass = revealedBassNote[tokenId];
            
            string memory svgContent;
            if (address(musicRenderer) != address(0)) {
                try musicRenderer.render(IMusicRenderer.BeatData({
                    tokenId: tokenId,
                    beat: rank,
                    year: revealYear,
                    leadPitch: lead.pitch,
                    leadDuration: lead.duration,
                    bassPitch: bass.pitch,
                    bassDuration: bass.duration
                })) returns (string memory svg) {
                    svgContent = svg;
                    // Encode renderer output as a data URI
                    image = string(abi.encodePacked(
                        "data:image/svg+xml;base64,",
                        Base64.encode(bytes(svg))
                    ));
                } catch {
                    svgContent = _buildFallbackSVG(tokenId, "Music renderer error");
                    image = svgContent;
                }
            } else {
                svgContent = _buildFallbackSVG(tokenId, "Music renderer not set");
                image = svgContent;
            }
            
            if (address(audioRenderer) != address(0)) {
                try audioRenderer.generateAudioHTML(
                    lead.pitch,
                    bass.pitch,
                    revealBlockTimestamp[tokenId],
                    svgContent
                ) returns (string memory html) {
                    animationUrl = html;
                } catch {
                    // Audio is best-effort
                }
            }
            
            description = hasWords
                ? escapedWords 
                : string(abi.encodePacked(
                    "Every Two Million Blocks token #", tokenId.toString(),
                    " - Year ", revealYear.toString(),
                    ". Continuous organ tones ring since reveal."
                  ));
        }
        
        // Build metadata JSON (revealed tokens expose their notes)
        string memory name;
        if (isRevealed) {
            // Example format: "G4 (G4) + Eb2 (Eb2) [67+39]"
            ISongAlgorithm.Event memory lead = revealedLeadNote[tokenId];
            ISongAlgorithm.Event memory bass = revealedBassNote[tokenId];
            string memory leadUnicodeName = _midiToUnicodeNoteName(lead.pitch);
            string memory bassUnicodeName = _midiToUnicodeNoteName(bass.pitch);
            string memory leadAsciiName = _midiToAsciiNoteName(lead.pitch);
            string memory bassAsciiName = _midiToAsciiNoteName(bass.pitch);
            name = string(abi.encodePacked(
                leadUnicodeName,
                " (",
                leadAsciiName,
                ") + ",
                bassUnicodeName,
                " (",
                bassAsciiName,
                ") [",
                _int16ToString(lead.pitch),
                "+",
                _int16ToString(bass.pitch),
                "]"
            ));
        } else {
            name = hasWords
                ? escapedWords
                : string(abi.encodePacked(
                    "Every Two Million Blocks #", tokenId.toString(),
                    " - Year ", revealYear.toString()
                ));
        }
        
        string memory json = string(abi.encodePacked(
            '{"name":"', name,
            '","description":"', description,
            '","image":"', image, '"'
        ));
        
        if (bytes(animationUrl).length > 0) {
            json = string(abi.encodePacked(json, ',"animation_url":"', animationUrl, '"'));
        }
        
        // Attach attributes
        uint256 tokenPoints = getPoints(tokenId);
        json = string(abi.encodePacked(
            json,
            ',"attributes":[',
            '{"trait_type":"Year","value":', revealYear.toString(), '},',
            '{"trait_type":"Queue Rank","value":', rank.toString(), '},',
            '{"trait_type":"Points","value":', tokenPoints.toString(), '}'
        ));
        
        if (isRevealed) {
            string memory leadUnicodeNameAttr = _midiToUnicodeNoteName(revealedLeadNote[tokenId].pitch);
            string memory bassUnicodeNameAttr = _midiToUnicodeNoteName(revealedBassNote[tokenId].pitch);
            string memory leadAsciiNameAttr = _midiToAsciiNoteName(revealedLeadNote[tokenId].pitch);
            string memory bassAsciiNameAttr = _midiToAsciiNoteName(revealedBassNote[tokenId].pitch);
            json = string(abi.encodePacked(
                json,
                ',{"trait_type":"Lead Pitch (MIDI)","value":', _int16ToString(revealedLeadNote[tokenId].pitch), '}',
                ',{"trait_type":"Lead Duration","value":', uint256(revealedLeadNote[tokenId].duration).toString(), '}',
                ',{"trait_type":"Bass Pitch (MIDI)","value":', _int16ToString(revealedBassNote[tokenId].pitch), '}',
                ',{"trait_type":"Bass Duration","value":', uint256(revealedBassNote[tokenId].duration).toString(), '}',
                ',{"trait_type":"Lead Note (Unicode)","value":"', leadUnicodeNameAttr, '"}',
                ',{"trait_type":"Lead Note (ASCII)","value":"', leadAsciiNameAttr, '"}',
                ',{"trait_type":"Bass Note (Unicode)","value":"', bassUnicodeNameAttr, '"}',
                ',{"trait_type":"Bass Note (ASCII)","value":"', bassAsciiNameAttr, '"}'
            ));
        }
        
        json = string(abi.encodePacked(json, ']}'));
        
        return string(abi.encodePacked(
            "data:application/json;base64,",
            Base64.encode(bytes(json))
        ));
    }
    
    function _resolvePreRevealSelection(uint256 tokenId, bool wordsSet)
        private
        view
        returns (PreRevealSelection memory selection)
    {
        require(address(preRevealRegistry) != address(0), "Registry not set");
        (uint256 rendererId, address svgRendererAddr, address htmlRendererAddr,) =
            preRevealRegistry.resolveRenderer(tokenId, wordsSet);
        selection.rendererId = rendererId;
        selection.svgRenderer = svgRendererAddr;
        selection.htmlRenderer = htmlRendererAddr;

        uint256 defaultRendererId = preRevealRegistry.defaultRendererId();
        selection.defaultRendererId = defaultRendererId;
        IPreRevealRegistry.Renderer memory defaultRenderer = preRevealRegistry.getRenderer(defaultRendererId);
        selection.defaultSvgRenderer = defaultRenderer.svgRenderer;
        selection.defaultHtmlRenderer = defaultRenderer.htmlRenderer;

        return selection;
    }

    function _renderPreRevealSVG(PreRevealSelection memory selection, RenderTypes.RenderCtx memory ctx)
        private
        view
        returns (string memory)
    {
        (bool success, string memory svg) = _tryRenderSvg(selection.svgRenderer, ctx);
        if (success) {
            return svg;
        }
        if (selection.rendererId != selection.defaultRendererId) {
            (bool fallbackSuccess, string memory fallbackSvg) = _tryRenderSvg(selection.defaultSvgRenderer, ctx);
            if (fallbackSuccess) {
                return fallbackSvg;
            }
            revert("Default pre-reveal renderer error");
        }
        revert("Pre-reveal renderer error");
    }

    function _renderPreRevealHtml(PreRevealSelection memory selection, RenderTypes.RenderCtx memory ctx)
        private
        view
        returns (string memory)
    {
        (bool success, string memory html) = _tryRenderPreRevealHtml(selection.htmlRenderer, ctx);
        if (success) {
            return html;
        }
        if (selection.rendererId != selection.defaultRendererId) {
            (bool fallbackSuccess, string memory fallbackHtml) =
                _tryRenderPreRevealHtml(selection.defaultHtmlRenderer, ctx);
            if (fallbackSuccess) {
                return fallbackHtml;
            }
        }
        return "";
    }

    function _tryRenderSvg(address rendererAddr, RenderTypes.RenderCtx memory ctx)
        private
        view
        returns (bool, string memory)
    {
        if (rendererAddr == address(0)) {
            return (false, "");
        }
        try ICountdownRenderer(rendererAddr).render(ctx) returns (string memory svg) {
            return (true, svg);
        } catch {
            return (false, "");
        }
    }

    function _tryRenderPreRevealHtml(address rendererAddr, RenderTypes.RenderCtx memory ctx)
        private
        view
        returns (bool, string memory)
    {
        if (rendererAddr == address(0)) {
            return (false, "");
        }
        try ICountdownHtmlRenderer(rendererAddr).render(ctx) returns (string memory html) {
            return (true, html);
        } catch {
            return (false, "");
        }
    }

    function _buildFallbackSVG(uint256 tokenId, string memory message) private pure returns (string memory) {
        string memory svg = string(abi.encodePacked(
            '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">',
            '<rect width="100%" height="100%" fill="#000"/>',
            '<text x="300" y="300" text-anchor="middle" fill="#fff" font-size="20">',
            'Token #', tokenId.toString(),
            '</text>',
            '<text x="300" y="330" text-anchor="middle" fill="#fff" font-size="14">',
            message,
            '</text>',
            '</svg>'
        ));
        
        return string(abi.encodePacked(
            "data:image/svg+xml;base64,",
            Base64.encode(bytes(svg))
        ));
    }

    function _escapeJsonString(string memory value) internal pure returns (string memory) {
        bytes memory data = bytes(value);
        uint256 len = data.length;
        if (len == 0) {
            return "";
        }

        bytes memory buffer = new bytes(len * 6);
        uint256 pos = 0;

        for (uint256 i = 0; i < len; i++) {
            bytes1 char = data[i];
            if (char == 0x22 || char == 0x5c) {
                buffer[pos++] = 0x5c;
                buffer[pos++] = char;
            } else if (char == 0x08) {
                buffer[pos++] = 0x5c;
                buffer[pos++] = 0x62;
            } else if (char == 0x0c) {
                buffer[pos++] = 0x5c;
                buffer[pos++] = 0x66;
            } else if (char == 0x0a) {
                buffer[pos++] = 0x5c;
                buffer[pos++] = 0x6e;
            } else if (char == 0x0d) {
                buffer[pos++] = 0x5c;
                buffer[pos++] = 0x72;
            } else if (char == 0x09) {
                buffer[pos++] = 0x5c;
                buffer[pos++] = 0x74;
            } else if (uint8(char) < 0x20 || char == 0x3c || char == 0x3e || char == 0x26) {
                buffer[pos++] = 0x5c;
                buffer[pos++] = 0x75;
                buffer[pos++] = 0x30;
                buffer[pos++] = 0x30;
                buffer[pos++] = _hexChar(uint8(char) >> 4);
                buffer[pos++] = _hexChar(uint8(char) & 0x0f);
            } else {
                buffer[pos++] = char;
            }
        }

        bytes memory escaped = new bytes(pos);
        for (uint256 j = 0; j < pos; j++) {
            escaped[j] = buffer[j];
        }
        return string(escaped);
    }

    function _hexChar(uint8 nibble) private pure returns (bytes1) {
        uint8 charCode = nibble < 10 ? nibble + uint8(bytes1("0")) : nibble - 10 + uint8(bytes1("a"));
        return bytes1(charCode);
    }
    
    function _int16ToString(int16 value) private pure returns (string memory) {
        if (value >= 0) {
            return uint256(uint16(value)).toString();
        } else {
            return string(abi.encodePacked("-", uint256(uint16(-value)).toString()));
        }
    }
    
    /// @notice Convert MIDI pitch to note name (e.g., 60 -> "C4", 67 -> "G4")
    function _midiToUnicodeNoteName(int16 midi) private pure returns (string memory) {
        if (midi == -1) return unicode"𝄽"; // Unicode quarter rest

        string[12] memory unicodeNotes = [
            unicode"C",
            unicode"D♭",
            unicode"D",
            unicode"E♭",
            unicode"E",
            unicode"F",
            unicode"G♭",
            unicode"G",
            unicode"A♭",
            unicode"A",
            unicode"B♭",
            unicode"B"
        ];

        uint256 midiUint = uint256(int256(midi));
        uint256 pitchClass = midiUint % 12;
        int16 octave = int16(int256(midiUint / 12) - 1);

        return string(abi.encodePacked(unicodeNotes[pitchClass], _int16ToString(octave)));
    }

    function _midiToAsciiNoteName(int16 midi) private pure returns (string memory) {
        if (midi == -1) return "REST";

        string[12] memory asciiNotes = ["C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B"];
        uint256 midiUint = uint256(int256(midi));
        uint256 pitchClass = midiUint % 12;
        int16 octave = int16(int256(midiUint / 12) - 1);

        return string(abi.encodePacked(asciiNotes[pitchClass], _int16ToString(octave)));
    }
    
    // --- UTC DATE CALCULATION ---
    function _jan1Timestamp(uint256 year) internal view virtual returns (uint256) {
        require(year >= 1970, "Year before Unix epoch");
        return DateTime.timestampFromDate(year, 1, 1);
    }
    
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.20;

import {IERC721} from "./IERC721.sol";
import {IERC721Metadata} from "./extensions/IERC721Metadata.sol";
import {ERC721Utils} from "./utils/ERC721Utils.sol";
import {Context} from "../../utils/Context.sol";
import {Strings} from "../../utils/Strings.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {IERC721Errors} from "../../interfaces/draft-IERC6093.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC-721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Errors {
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    mapping(uint256 tokenId => address) private _owners;

    mapping(address owner => uint256) private _balances;

    mapping(uint256 tokenId => address) private _tokenApprovals;

    mapping(address owner => mapping(address operator => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /// @inheritdoc IERC165
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC721).interfaceId ||
            interfaceId == type(IERC721Metadata).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /// @inheritdoc IERC721
    function balanceOf(address owner) public view virtual returns (uint256) {
        if (owner == address(0)) {
            revert ERC721InvalidOwner(address(0));
        }
        return _balances[owner];
    }

    /// @inheritdoc IERC721
    function ownerOf(uint256 tokenId) public view virtual returns (address) {
        return _requireOwned(tokenId);
    }

    /// @inheritdoc IERC721Metadata
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /// @inheritdoc IERC721Metadata
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /// @inheritdoc IERC721Metadata
    function tokenURI(uint256 tokenId) public view virtual returns (string memory) {
        _requireOwned(tokenId);

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : "";
    }

    /**
     * @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, can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /// @inheritdoc IERC721
    function approve(address to, uint256 tokenId) public virtual {
        _approve(to, tokenId, _msgSender());
    }

    /// @inheritdoc IERC721
    function getApproved(uint256 tokenId) public view virtual returns (address) {
        _requireOwned(tokenId);

        return _getApproved(tokenId);
    }

    /// @inheritdoc IERC721
    function setApprovalForAll(address operator, bool approved) public virtual {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /// @inheritdoc IERC721
    function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /// @inheritdoc IERC721
    function transferFrom(address from, address to, uint256 tokenId) public virtual {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        // Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists
        // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.
        address previousOwner = _update(to, tokenId, _msgSender());
        if (previousOwner != from) {
            revert ERC721IncorrectOwner(from, tokenId, previousOwner);
        }
    }

    /// @inheritdoc IERC721
    function safeTransferFrom(address from, address to, uint256 tokenId) public {
        safeTransferFrom(from, to, tokenId, "");
    }

    /// @inheritdoc IERC721
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual {
        transferFrom(from, to, tokenId);
        ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data);
    }

    /**
     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
     *
     * IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
     * core ERC-721 logic MUST be matched with the use of {_increaseBalance} to keep balances
     * consistent with ownership. The invariant to preserve is that for any address `a` the value returned by
     * `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`.
     */
    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
        return _owners[tokenId];
    }

    /**
     * @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted.
     */
    function _getApproved(uint256 tokenId) internal view virtual returns (address) {
        return _tokenApprovals[tokenId];
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in
     * particular (ignoring whether it is owned by `owner`).
     *
     * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
     * assumption.
     */
    function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {
        return
            spender != address(0) &&
            (owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);
    }

    /**
     * @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner.
     * Reverts if:
     * - `spender` does not have approval from `owner` for `tokenId`.
     * - `spender` does not have approval to manage all of `owner`'s assets.
     *
     * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
     * assumption.
     */
    function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual {
        if (!_isAuthorized(owner, spender, tokenId)) {
            if (owner == address(0)) {
                revert ERC721NonexistentToken(tokenId);
            } else {
                revert ERC721InsufficientApproval(spender, tokenId);
            }
        }
    }

    /**
     * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
     *
     * NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that
     * a uint256 would ever overflow from increments when these increments are bounded to uint128 values.
     *
     * WARNING: Increasing an account's balance using this function tends to be paired with an override of the
     * {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership
     * remain consistent with one another.
     */
    function _increaseBalance(address account, uint128 value) internal virtual {
        unchecked {
            _balances[account] += value;
        }
    }

    /**
     * @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner
     * (or `to`) is the zero address. Returns the owner of the `tokenId` before the update.
     *
     * The `auth` argument is optional. If the value passed is non 0, then this function will check that
     * `auth` is either the owner of the token, or approved to operate on the token (by the owner).
     *
     * Emits a {Transfer} event.
     *
     * NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
     */
    function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) {
        address from = _ownerOf(tokenId);

        // Perform (optional) operator check
        if (auth != address(0)) {
            _checkAuthorized(from, auth, tokenId);
        }

        // Execute the update
        if (from != address(0)) {
            // Clear approval. No need to re-authorize or emit the Approval event
            _approve(address(0), tokenId, address(0), false);

            unchecked {
                _balances[from] -= 1;
            }
        }

        if (to != address(0)) {
            unchecked {
                _balances[to] += 1;
            }
        }

        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        return from;
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        address previousOwner = _update(to, tokenId, address(0));
        if (previousOwner != address(0)) {
            revert ERC721InvalidSender(address(0));
        }
    }

    /**
     * @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
        _mint(to, tokenId);
        ERC721Utils.checkOnERC721Received(_msgSender(), address(0), to, tokenId, data);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     * This is an internal function that does not check if the sender is authorized to operate on the token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal {
        address previousOwner = _update(address(0), tokenId, address(0));
        if (previousOwner == address(0)) {
            revert ERC721NonexistentToken(tokenId);
        }
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(address from, address to, uint256 tokenId) internal {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        address previousOwner = _update(to, tokenId, address(0));
        if (previousOwner == address(0)) {
            revert ERC721NonexistentToken(tokenId);
        } else if (previousOwner != from) {
            revert ERC721IncorrectOwner(from, tokenId, previousOwner);
        }
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients
     * are aware of the ERC-721 standard to prevent tokens from being forever locked.
     *
     * `data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is like {safeTransferFrom} in the sense that it invokes
     * {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `tokenId` token must exist and be owned by `from`.
     * - `to` cannot be the zero address.
     * - `from` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(address from, address to, uint256 tokenId) internal {
        _safeTransfer(from, to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
        _transfer(from, to, tokenId);
        ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is
     * either the owner of the token, or approved to operate on all tokens held by this owner.
     *
     * Emits an {Approval} event.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address to, uint256 tokenId, address auth) internal {
        _approve(to, tokenId, auth, true);
    }

    /**
     * @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not
     * emitted in the context of transfers.
     */
    function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual {
        // Avoid reading the owner unless necessary
        if (emitEvent || auth != address(0)) {
            address owner = _requireOwned(tokenId);

            // We do not use _isAuthorized because single-token approvals should not be able to call approve
            if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) {
                revert ERC721InvalidApprover(auth);
            }

            if (emitEvent) {
                emit Approval(owner, to, tokenId);
            }
        }

        _tokenApprovals[tokenId] = to;
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Requirements:
     * - operator can't be the address zero.
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
        if (operator == address(0)) {
            revert ERC721InvalidOperator(operator);
        }
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned).
     * Returns the owner.
     *
     * Overrides to ownership logic should be done to {_ownerOf}.
     */
    function _requireOwned(uint256 tokenId) internal view returns (address) {
        address owner = _ownerOf(tokenId);
        if (owner == address(0)) {
            revert ERC721NonexistentToken(tokenId);
        }
        return owner;
    }
}

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

pragma solidity ^0.8.20;

import {Context} from "../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.
 *
 * The initial owner is set to the address provided by the deployer. 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;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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 {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling 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 {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _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);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/Base64.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides a set of functions to operate with Base64 strings.
 */
library Base64 {
    /**
     * @dev Base64 Encoding/Decoding Table
     * See sections 4 and 5 of https://datatracker.ietf.org/doc/html/rfc4648
     */
    string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    string internal constant _TABLE_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";

    /**
     * @dev Converts a `bytes` to its Bytes64 `string` representation.
     */
    function encode(bytes memory data) internal pure returns (string memory) {
        return _encode(data, _TABLE, true);
    }

    /**
     * @dev Converts a `bytes` to its Bytes64Url `string` representation.
     * Output is not padded with `=` as specified in https://www.rfc-editor.org/rfc/rfc4648[rfc4648].
     */
    function encodeURL(bytes memory data) internal pure returns (string memory) {
        return _encode(data, _TABLE_URL, false);
    }

    /**
     * @dev Internal table-agnostic conversion
     */
    function _encode(bytes memory data, string memory table, bool withPadding) private pure returns (string memory) {
        /**
         * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence
         * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol
         */
        if (data.length == 0) return "";

        // If padding is enabled, the final length should be `bytes` data length divided by 3 rounded up and then
        // multiplied by 4 so that it leaves room for padding the last chunk
        // - `data.length + 2`  -> Prepare for division rounding up
        // - `/ 3`              -> Number of 3-bytes chunks (rounded up)
        // - `4 *`              -> 4 characters for each chunk
        // This is equivalent to: 4 * Math.ceil(data.length / 3)
        //
        // If padding is disabled, the final length should be `bytes` data length multiplied by 4/3 rounded up as
        // opposed to when padding is required to fill the last chunk.
        // - `4 * data.length`  -> 4 characters for each chunk
        // - ` + 2`             -> Prepare for division rounding up
        // - `/ 3`              -> Number of 3-bytes chunks (rounded up)
        // This is equivalent to: Math.ceil((4 * data.length) / 3)
        uint256 resultLength = withPadding ? 4 * ((data.length + 2) / 3) : (4 * data.length + 2) / 3;

        string memory result = new string(resultLength);

        assembly ("memory-safe") {
            // Prepare the lookup table (skip the first "length" byte)
            let tablePtr := add(table, 1)

            // Prepare result pointer, jump over length
            let resultPtr := add(result, 0x20)
            let dataPtr := data
            let endPtr := add(data, mload(data))

            // In some cases, the last iteration will read bytes after the end of the data. We cache the value, and
            // set it to zero to make sure no dirty bytes are read in that section.
            let afterPtr := add(endPtr, 0x20)
            let afterCache := mload(afterPtr)
            mstore(afterPtr, 0x00)

            // Run over the input, 3 bytes at a time
            for {} lt(dataPtr, endPtr) {} {
                // Advance 3 bytes
                dataPtr := add(dataPtr, 3)
                let input := mload(dataPtr)

                // To write each character, shift the 3 byte (24 bits) chunk
                // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)
                // and apply logical AND with 0x3F to bitmask the least significant 6 bits.
                // Use this as an index into the lookup table, mload an entire word
                // so the desired character is in the least significant byte, and
                // mstore8 this least significant byte into the result and continue.

                mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance
            }

            // Reset the value that was cached
            mstore(afterPtr, afterCache)

            if withPadding {
                // When data `bytes` is not exactly 3 bytes long
                // it is padded with `=` characters at the end
                switch mod(mload(data), 3)
                case 1 {
                    mstore8(sub(resultPtr, 1), 0x3d)
                    mstore8(sub(resultPtr, 2), 0x3d)
                }
                case 2 {
                    mstore8(sub(resultPtr, 1), 0x3d)
                }
            }
        }

        return result;
    }
}

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

pragma solidity ^0.8.20;

import {Math} from "./math/Math.sol";
import {SafeCast} from "./math/SafeCast.sol";
import {SignedMath} from "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    using SafeCast for *;

    bytes16 private constant HEX_DIGITS = "0123456789abcdef";
    uint8 private constant ADDRESS_LENGTH = 20;
    uint256 private constant SPECIAL_CHARS_LOOKUP =
        (1 << 0x08) | // backspace
            (1 << 0x09) | // tab
            (1 << 0x0a) | // newline
            (1 << 0x0c) | // form feed
            (1 << 0x0d) | // carriage return
            (1 << 0x22) | // double quote
            (1 << 0x5c); // backslash

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

    /**
     * @dev The string being parsed contains characters that are not in scope of the given base.
     */
    error StringsInvalidChar();

    /**
     * @dev The string being parsed is not a properly formatted address.
     */
    error StringsInvalidAddressFormat();

    /**
     * @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;
            assembly ("memory-safe") {
                ptr := add(add(buffer, 0x20), length)
            }
            while (true) {
                ptr--;
                assembly ("memory-safe") {
                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toStringSigned(int256 value) internal pure returns (string memory) {
        return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
    }

    /**
     * @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) {
        uint256 localValue = value;
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = HEX_DIGITS[localValue & 0xf];
            localValue >>= 4;
        }
        if (localValue != 0) {
            revert StringsInsufficientHexLength(value, length);
        }
        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);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal
     * representation, according to EIP-55.
     */
    function toChecksumHexString(address addr) internal pure returns (string memory) {
        bytes memory buffer = bytes(toHexString(addr));

        // hash the hex part of buffer (skip length + 2 bytes, length 40)
        uint256 hashValue;
        assembly ("memory-safe") {
            hashValue := shr(96, keccak256(add(buffer, 0x22), 40))
        }

        for (uint256 i = 41; i > 1; --i) {
            // possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)
            if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {
                // case shift by xoring with 0x20
                buffer[i] ^= 0x20;
            }
            hashValue >>= 4;
        }
        return string(buffer);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
    }

    /**
     * @dev Parse a decimal string and returns the value as a `uint256`.
     *
     * Requirements:
     * - The string must be formatted as `[0-9]*`
     * - The result must fit into an `uint256` type
     */
    function parseUint(string memory input) internal pure returns (uint256) {
        return parseUint(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseUint-string} that parses a substring of `input` located between position `begin` (included) and
     * `end` (excluded).
     *
     * Requirements:
     * - The substring must be formatted as `[0-9]*`
     * - The result must fit into an `uint256` type
     */
    function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
        (bool success, uint256 value) = tryParseUint(input, begin, end);
        if (!success) revert StringsInvalidChar();
        return value;
    }

    /**
     * @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character.
     *
     * NOTE: This function will revert if the result does not fit in a `uint256`.
     */
    function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) {
        return _tryParseUintUncheckedBounds(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid
     * character.
     *
     * NOTE: This function will revert if the result does not fit in a `uint256`.
     */
    function tryParseUint(
        string memory input,
        uint256 begin,
        uint256 end
    ) internal pure returns (bool success, uint256 value) {
        if (end > bytes(input).length || begin > end) return (false, 0);
        return _tryParseUintUncheckedBounds(input, begin, end);
    }

    /**
     * @dev Implementation of {tryParseUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.
     */
    function _tryParseUintUncheckedBounds(
        string memory input,
        uint256 begin,
        uint256 end
    ) private pure returns (bool success, uint256 value) {
        bytes memory buffer = bytes(input);

        uint256 result = 0;
        for (uint256 i = begin; i < end; ++i) {
            uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
            if (chr > 9) return (false, 0);
            result *= 10;
            result += chr;
        }
        return (true, result);
    }

    /**
     * @dev Parse a decimal string and returns the value as a `int256`.
     *
     * Requirements:
     * - The string must be formatted as `[-+]?[0-9]*`
     * - The result must fit in an `int256` type.
     */
    function parseInt(string memory input) internal pure returns (int256) {
        return parseInt(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and
     * `end` (excluded).
     *
     * Requirements:
     * - The substring must be formatted as `[-+]?[0-9]*`
     * - The result must fit in an `int256` type.
     */
    function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) {
        (bool success, int256 value) = tryParseInt(input, begin, end);
        if (!success) revert StringsInvalidChar();
        return value;
    }

    /**
     * @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if
     * the result does not fit in a `int256`.
     *
     * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
     */
    function tryParseInt(string memory input) internal pure returns (bool success, int256 value) {
        return _tryParseIntUncheckedBounds(input, 0, bytes(input).length);
    }

    uint256 private constant ABS_MIN_INT256 = 2 ** 255;

    /**
     * @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid
     * character or if the result does not fit in a `int256`.
     *
     * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
     */
    function tryParseInt(
        string memory input,
        uint256 begin,
        uint256 end
    ) internal pure returns (bool success, int256 value) {
        if (end > bytes(input).length || begin > end) return (false, 0);
        return _tryParseIntUncheckedBounds(input, begin, end);
    }

    /**
     * @dev Implementation of {tryParseInt-string-uint256-uint256} that does not check bounds. Caller should make sure that
     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.
     */
    function _tryParseIntUncheckedBounds(
        string memory input,
        uint256 begin,
        uint256 end
    ) private pure returns (bool success, int256 value) {
        bytes memory buffer = bytes(input);

        // Check presence of a negative sign.
        bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
        bool positiveSign = sign == bytes1("+");
        bool negativeSign = sign == bytes1("-");
        uint256 offset = (positiveSign || negativeSign).toUint();

        (bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end);

        if (absSuccess && absValue < ABS_MIN_INT256) {
            return (true, negativeSign ? -int256(absValue) : int256(absValue));
        } else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) {
            return (true, type(int256).min);
        } else return (false, 0);
    }

    /**
     * @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as a `uint256`.
     *
     * Requirements:
     * - The string must be formatted as `(0x)?[0-9a-fA-F]*`
     * - The result must fit in an `uint256` type.
     */
    function parseHexUint(string memory input) internal pure returns (uint256) {
        return parseHexUint(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseHexUint-string} that parses a substring of `input` located between position `begin` (included) and
     * `end` (excluded).
     *
     * Requirements:
     * - The substring must be formatted as `(0x)?[0-9a-fA-F]*`
     * - The result must fit in an `uint256` type.
     */
    function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
        (bool success, uint256 value) = tryParseHexUint(input, begin, end);
        if (!success) revert StringsInvalidChar();
        return value;
    }

    /**
     * @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character.
     *
     * NOTE: This function will revert if the result does not fit in a `uint256`.
     */
    function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) {
        return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an
     * invalid character.
     *
     * NOTE: This function will revert if the result does not fit in a `uint256`.
     */
    function tryParseHexUint(
        string memory input,
        uint256 begin,
        uint256 end
    ) internal pure returns (bool success, uint256 value) {
        if (end > bytes(input).length || begin > end) return (false, 0);
        return _tryParseHexUintUncheckedBounds(input, begin, end);
    }

    /**
     * @dev Implementation of {tryParseHexUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.
     */
    function _tryParseHexUintUncheckedBounds(
        string memory input,
        uint256 begin,
        uint256 end
    ) private pure returns (bool success, uint256 value) {
        bytes memory buffer = bytes(input);

        // skip 0x prefix if present
        bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
        uint256 offset = hasPrefix.toUint() * 2;

        uint256 result = 0;
        for (uint256 i = begin + offset; i < end; ++i) {
            uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
            if (chr > 15) return (false, 0);
            result *= 16;
            unchecked {
                // Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check).
                // This guarantees that adding a value < 16 will not cause an overflow, hence the unchecked.
                result += chr;
            }
        }
        return (true, result);
    }

    /**
     * @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as an `address`.
     *
     * Requirements:
     * - The string must be formatted as `(0x)?[0-9a-fA-F]{40}`
     */
    function parseAddress(string memory input) internal pure returns (address) {
        return parseAddress(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseAddress-string} that parses a substring of `input` located between position `begin` (included) and
     * `end` (excluded).
     *
     * Requirements:
     * - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}`
     */
    function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) {
        (bool success, address value) = tryParseAddress(input, begin, end);
        if (!success) revert StringsInvalidAddressFormat();
        return value;
    }

    /**
     * @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly
     * formatted address. See {parseAddress-string} requirements.
     */
    function tryParseAddress(string memory input) internal pure returns (bool success, address value) {
        return tryParseAddress(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly
     * formatted address. See {parseAddress-string-uint256-uint256} requirements.
     */
    function tryParseAddress(
        string memory input,
        uint256 begin,
        uint256 end
    ) internal pure returns (bool success, address value) {
        if (end > bytes(input).length || begin > end) return (false, address(0));

        bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
        uint256 expectedLength = 40 + hasPrefix.toUint() * 2;

        // check that input is the correct length
        if (end - begin == expectedLength) {
            // length guarantees that this does not overflow, and value is at most type(uint160).max
            (bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end);
            return (s, address(uint160(v)));
        } else {
            return (false, address(0));
        }
    }

    function _tryParseChr(bytes1 chr) private pure returns (uint8) {
        uint8 value = uint8(chr);

        // Try to parse `chr`:
        // - Case 1: [0-9]
        // - Case 2: [a-f]
        // - Case 3: [A-F]
        // - otherwise not supported
        unchecked {
            if (value > 47 && value < 58) value -= 48;
            else if (value > 96 && value < 103) value -= 87;
            else if (value > 64 && value < 71) value -= 55;
            else return type(uint8).max;
        }

        return value;
    }

    /**
     * @dev Escape special characters in JSON strings. This can be useful to prevent JSON injection in NFT metadata.
     *
     * WARNING: This function should only be used in double quoted JSON strings. Single quotes are not escaped.
     *
     * NOTE: This function escapes all unicode characters, and not just the ones in ranges defined in section 2.5 of
     * RFC-4627 (U+0000 to U+001F, U+0022 and U+005C). ECMAScript's `JSON.parse` does recover escaped unicode
     * characters that are not in this range, but other tooling may provide different results.
     */
    function escapeJSON(string memory input) internal pure returns (string memory) {
        bytes memory buffer = bytes(input);
        bytes memory output = new bytes(2 * buffer.length); // worst case scenario
        uint256 outputLength = 0;

        for (uint256 i; i < buffer.length; ++i) {
            bytes1 char = bytes1(_unsafeReadBytesOffset(buffer, i));
            if (((SPECIAL_CHARS_LOOKUP & (1 << uint8(char))) != 0)) {
                output[outputLength++] = "\\";
                if (char == 0x08) output[outputLength++] = "b";
                else if (char == 0x09) output[outputLength++] = "t";
                else if (char == 0x0a) output[outputLength++] = "n";
                else if (char == 0x0c) output[outputLength++] = "f";
                else if (char == 0x0d) output[outputLength++] = "r";
                else if (char == 0x5c) output[outputLength++] = "\\";
                else if (char == 0x22) {
                    // solhint-disable-next-line quotes
                    output[outputLength++] = '"';
                }
            } else {
                output[outputLength++] = char;
            }
        }
        // write the actual length and deallocate unused memory
        assembly ("memory-safe") {
            mstore(output, outputLength)
            mstore(0x40, add(output, shl(5, shr(5, add(outputLength, 63)))))
        }

        return string(output);
    }

    /**
     * @dev Reads a bytes32 from a bytes array without bounds checking.
     *
     * NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the
     * assembly block as such would prevent some optimizations.
     */
    function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {
        // This is not memory safe in the general case, but all calls to this private function are within bounds.
        assembly ("memory-safe") {
            value := mload(add(add(buffer, 0x20), offset))
        }
    }
}

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

/// @title ISongAlgorithm
/// @notice Interface for music generation algorithm
interface ISongAlgorithm {
    struct Event {
        int16 pitch;      // MIDI pitch, -1 for rest
        uint16 duration;  // Duration in ticks (480 PPQN)
    }
    
    /// @notice Generate lead and bass events for a given beat
    /// @param beat Beat number (0-indexed)
    /// @param tokenSeed Random seed for generation
    /// @return lead Lead voice event
    /// @return bass Bass voice event
    function generateBeat(uint32 beat, uint32 tokenSeed) external pure returns (Event memory lead, Event memory bass);
    
    /// @notice Generate ABC notation for a beat
    /// @param beat Beat number
    /// @param tokenSeed Random seed
    /// @return abc ABC notation string
    function generateAbcBeat(uint32 beat, uint32 tokenSeed) external pure returns (string memory abc);
}

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

/// @title IMusicRenderer
/// @notice Interface for complete music SVG rendering
interface IMusicRenderer {
    struct BeatData {
        uint256 tokenId;
        uint256 beat;
        uint256 year;
        int16 leadPitch;      // MIDI pitch, -1 for rest
        uint16 leadDuration;  // Duration in ticks
        int16 bassPitch;      // MIDI pitch, -1 for rest
        uint16 bassDuration;  // Duration in ticks
    }
    
    /// @notice Render complete SVG for a beat
    /// @param data Beat data to render
    /// @return Complete SVG string (600x600, white bg, black notation)
    function render(BeatData memory data) external view returns (string memory);
}

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

/// @title IAudioRenderer
/// @notice Interface for generating HTML audio player with embedded SVG
interface IAudioRenderer {
    /// @notice Generate HTML audio player with WebAudio synthesis and embedded SVG
    /// @param leadPitch Lead MIDI pitch (-1 for rest)
    /// @param bassPitch Bass MIDI pitch (-1 for rest)
    /// @param revealTimestamp Unix timestamp of reveal
    /// @param svgContent SVG markup to display (not data URI, just raw SVG)
    /// @return data:text/html;base64 URI
    function generateAudioHTML(
        int16 leadPitch,
        int16 bassPitch,
        uint256 revealTimestamp,
        string memory svgContent
    ) external pure returns (string memory);
}

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

/**
 * @title IPointsManager
 * @notice Interface for PointsManager contract
 */
interface IPointsManager {
    function pointsOf(uint256 tokenId) external view returns (uint256);
    function currentRankOf(uint256 tokenId) external view returns (uint256);
    function addPoints(uint256 tokenId, uint256 amount, string calldata source) external;
    function handleReveal(uint256 tokenId) external;
}

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

interface IPointsAggregator {
    function onTokenRevealed(uint256 tokenId) external;
}

File 12 of 29 : IVRFCoordinatorV2_5.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IVRFCoordinatorV2_5 {
    struct RandomWordsRequest {
        bytes32 keyHash;
        uint256 subId;
        uint16 requestConfirmations;
        uint32 callbackGasLimit;
        uint32 numWords;
        bytes extraArgs;
    }

    function requestRandomWords(
        RandomWordsRequest calldata request
    ) external returns (uint256 requestId);
}

File 13 of 29 : VRFV2PlusClient.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

// End consumer library.
library VRFV2PlusClient {
  // extraArgs will evolve to support new features
  bytes4 public constant EXTRA_ARGS_V1_TAG = bytes4(keccak256("VRF ExtraArgsV1"));

  struct ExtraArgsV1 {
    bool nativePayment;
  }

  struct RandomWordsRequest {
    bytes32 keyHash;
    uint256 subId;
    uint16 requestConfirmations;
    uint32 callbackGasLimit;
    uint32 numWords;
    bytes extraArgs;
  }

  function _argsToBytes(
    ExtraArgsV1 memory extraArgs
  ) internal pure returns (bytes memory bts) {
    return abi.encodeWithSelector(EXTRA_ARGS_V1_TAG, extraArgs);
  }
}

File 14 of 29 : BokkyPooBahsDateTimeLibrary.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.9.0;

// ----------------------------------------------------------------------------
// BokkyPooBah's DateTime Library v1.01
//
// A gas-efficient Solidity date and time library
//
// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary
//
// Tested date range 1970/01/01 to 2345/12/31
//
// Conventions:
// Unit      | Range         | Notes
// :-------- |:-------------:|:-----
// timestamp | >= 0          | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC
// year      | 1970 ... 2345 |
// month     | 1 ... 12      |
// day       | 1 ... 31      |
// hour      | 0 ... 23      |
// minute    | 0 ... 59      |
// second    | 0 ... 59      |
// dayOfWeek | 1 ... 7       | 1 = Monday, ..., 7 = Sunday
//
//
// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.
// ----------------------------------------------------------------------------

library BokkyPooBahsDateTimeLibrary {

    uint constant SECONDS_PER_DAY = 24 * 60 * 60;
    uint constant SECONDS_PER_HOUR = 60 * 60;
    uint constant SECONDS_PER_MINUTE = 60;
    int constant OFFSET19700101 = 2440588;

    uint constant DOW_MON = 1;
    uint constant DOW_TUE = 2;
    uint constant DOW_WED = 3;
    uint constant DOW_THU = 4;
    uint constant DOW_FRI = 5;
    uint constant DOW_SAT = 6;
    uint constant DOW_SUN = 7;

    // ------------------------------------------------------------------------
    // Calculate the number of days from 1970/01/01 to year/month/day using
    // the date conversion algorithm from
    //   https://aa.usno.navy.mil/faq/JD_formula.html
    // and subtracting the offset 2440588 so that 1970/01/01 is day 0
    //
    // days = day
    //      - 32075
    //      + 1461 * (year + 4800 + (month - 14) / 12) / 4
    //      + 367 * (month - 2 - (month - 14) / 12 * 12) / 12
    //      - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4
    //      - offset
    // ------------------------------------------------------------------------
    function _daysFromDate(uint year, uint month, uint day) internal pure returns (uint _days) {
        require(year >= 1970);
        int _year = int(year);
        int _month = int(month);
        int _day = int(day);

        int __days = _day
          - 32075
          + 1461 * (_year + 4800 + (_month - 14) / 12) / 4
          + 367 * (_month - 2 - (_month - 14) / 12 * 12) / 12
          - 3 * ((_year + 4900 + (_month - 14) / 12) / 100) / 4
          - OFFSET19700101;

        _days = uint(__days);
    }

    // ------------------------------------------------------------------------
    // Calculate year/month/day from the number of days since 1970/01/01 using
    // the date conversion algorithm from
    //   http://aa.usno.navy.mil/faq/docs/JD_Formula.php
    // and adding the offset 2440588 so that 1970/01/01 is day 0
    //
    // int L = days + 68569 + offset
    // int N = 4 * L / 146097
    // L = L - (146097 * N + 3) / 4
    // year = 4000 * (L + 1) / 1461001
    // L = L - 1461 * year / 4 + 31
    // month = 80 * L / 2447
    // dd = L - 2447 * month / 80
    // L = month / 11
    // month = month + 2 - 12 * L
    // year = 100 * (N - 49) + year + L
    // ------------------------------------------------------------------------
    function _daysToDate(uint _days) internal pure returns (uint year, uint month, uint day) {
        int __days = int(_days);

        int L = __days + 68569 + OFFSET19700101;
        int N = 4 * L / 146097;
        L = L - (146097 * N + 3) / 4;
        int _year = 4000 * (L + 1) / 1461001;
        L = L - 1461 * _year / 4 + 31;
        int _month = 80 * L / 2447;
        int _day = L - 2447 * _month / 80;
        L = _month / 11;
        _month = _month + 2 - 12 * L;
        _year = 100 * (N - 49) + _year + L;

        year = uint(_year);
        month = uint(_month);
        day = uint(_day);
    }

    function timestampFromDate(uint year, uint month, uint day) internal pure returns (uint timestamp) {
        timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY;
    }
    function timestampFromDateTime(uint year, uint month, uint day, uint hour, uint minute, uint second) internal pure returns (uint timestamp) {
        timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + hour * SECONDS_PER_HOUR + minute * SECONDS_PER_MINUTE + second;
    }
    function timestampToDate(uint timestamp) internal pure returns (uint year, uint month, uint day) {
        (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
    }
    function timestampToDateTime(uint timestamp) internal pure returns (uint year, uint month, uint day, uint hour, uint minute, uint second) {
        (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
        uint secs = timestamp % SECONDS_PER_DAY;
        hour = secs / SECONDS_PER_HOUR;
        secs = secs % SECONDS_PER_HOUR;
        minute = secs / SECONDS_PER_MINUTE;
        second = secs % SECONDS_PER_MINUTE;
    }

    function isValidDate(uint year, uint month, uint day) internal pure returns (bool valid) {
        if (year >= 1970 && month > 0 && month <= 12) {
            uint daysInMonth = _getDaysInMonth(year, month);
            if (day > 0 && day <= daysInMonth) {
                valid = true;
            }
        }
    }
    function isValidDateTime(uint year, uint month, uint day, uint hour, uint minute, uint second) internal pure returns (bool valid) {
        if (isValidDate(year, month, day)) {
            if (hour < 24 && minute < 60 && second < 60) {
                valid = true;
            }
        }
    }
    function isLeapYear(uint timestamp) internal pure returns (bool leapYear) {
        (uint year,,) = _daysToDate(timestamp / SECONDS_PER_DAY);
        leapYear = _isLeapYear(year);
    }
    function _isLeapYear(uint year) internal pure returns (bool leapYear) {
        leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
    }
    function isWeekDay(uint timestamp) internal pure returns (bool weekDay) {
        weekDay = getDayOfWeek(timestamp) <= DOW_FRI;
    }
    function isWeekEnd(uint timestamp) internal pure returns (bool weekEnd) {
        weekEnd = getDayOfWeek(timestamp) >= DOW_SAT;
    }
    function getDaysInMonth(uint timestamp) internal pure returns (uint daysInMonth) {
        (uint year, uint month,) = _daysToDate(timestamp / SECONDS_PER_DAY);
        daysInMonth = _getDaysInMonth(year, month);
    }
    function _getDaysInMonth(uint year, uint month) internal pure returns (uint daysInMonth) {
        if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
            daysInMonth = 31;
        } else if (month != 2) {
            daysInMonth = 30;
        } else {
            daysInMonth = _isLeapYear(year) ? 29 : 28;
        }
    }
    // 1 = Monday, 7 = Sunday
    function getDayOfWeek(uint timestamp) internal pure returns (uint dayOfWeek) {
        uint _days = timestamp / SECONDS_PER_DAY;
        dayOfWeek = (_days + 3) % 7 + 1;
    }

    function getYear(uint timestamp) internal pure returns (uint year) {
        (year,,) = _daysToDate(timestamp / SECONDS_PER_DAY);
    }
    function getMonth(uint timestamp) internal pure returns (uint month) {
        (,month,) = _daysToDate(timestamp / SECONDS_PER_DAY);
    }
    function getDay(uint timestamp) internal pure returns (uint day) {
        (,,day) = _daysToDate(timestamp / SECONDS_PER_DAY);
    }
    function getHour(uint timestamp) internal pure returns (uint hour) {
        uint secs = timestamp % SECONDS_PER_DAY;
        hour = secs / SECONDS_PER_HOUR;
    }
    function getMinute(uint timestamp) internal pure returns (uint minute) {
        uint secs = timestamp % SECONDS_PER_HOUR;
        minute = secs / SECONDS_PER_MINUTE;
    }
    function getSecond(uint timestamp) internal pure returns (uint second) {
        second = timestamp % SECONDS_PER_MINUTE;
    }

    function addYears(uint timestamp, uint _years) internal pure returns (uint newTimestamp) {
        (uint year, uint month, uint day) = _daysToDate(timestamp / SECONDS_PER_DAY);
        year += _years;
        uint daysInMonth = _getDaysInMonth(year, month);
        if (day > daysInMonth) {
            day = daysInMonth;
        }
        newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY;
        require(newTimestamp >= timestamp);
    }
    function addMonths(uint timestamp, uint _months) internal pure returns (uint newTimestamp) {
        (uint year, uint month, uint day) = _daysToDate(timestamp / SECONDS_PER_DAY);
        month += _months;
        year += (month - 1) / 12;
        month = (month - 1) % 12 + 1;
        uint daysInMonth = _getDaysInMonth(year, month);
        if (day > daysInMonth) {
            day = daysInMonth;
        }
        newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY;
        require(newTimestamp >= timestamp);
    }
    function addDays(uint timestamp, uint _days) internal pure returns (uint newTimestamp) {
        newTimestamp = timestamp + _days * SECONDS_PER_DAY;
        require(newTimestamp >= timestamp);
    }
    function addHours(uint timestamp, uint _hours) internal pure returns (uint newTimestamp) {
        newTimestamp = timestamp + _hours * SECONDS_PER_HOUR;
        require(newTimestamp >= timestamp);
    }
    function addMinutes(uint timestamp, uint _minutes) internal pure returns (uint newTimestamp) {
        newTimestamp = timestamp + _minutes * SECONDS_PER_MINUTE;
        require(newTimestamp >= timestamp);
    }
    function addSeconds(uint timestamp, uint _seconds) internal pure returns (uint newTimestamp) {
        newTimestamp = timestamp + _seconds;
        require(newTimestamp >= timestamp);
    }

    function subYears(uint timestamp, uint _years) internal pure returns (uint newTimestamp) {
        (uint year, uint month, uint day) = _daysToDate(timestamp / SECONDS_PER_DAY);
        year -= _years;
        uint daysInMonth = _getDaysInMonth(year, month);
        if (day > daysInMonth) {
            day = daysInMonth;
        }
        newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY;
        require(newTimestamp <= timestamp);
    }
    function subMonths(uint timestamp, uint _months) internal pure returns (uint newTimestamp) {
        (uint year, uint month, uint day) = _daysToDate(timestamp / SECONDS_PER_DAY);
        uint yearMonth = year * 12 + (month - 1) - _months;
        year = yearMonth / 12;
        month = yearMonth % 12 + 1;
        uint daysInMonth = _getDaysInMonth(year, month);
        if (day > daysInMonth) {
            day = daysInMonth;
        }
        newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY;
        require(newTimestamp <= timestamp);
    }
    function subDays(uint timestamp, uint _days) internal pure returns (uint newTimestamp) {
        newTimestamp = timestamp - _days * SECONDS_PER_DAY;
        require(newTimestamp <= timestamp);
    }
    function subHours(uint timestamp, uint _hours) internal pure returns (uint newTimestamp) {
        newTimestamp = timestamp - _hours * SECONDS_PER_HOUR;
        require(newTimestamp <= timestamp);
    }
    function subMinutes(uint timestamp, uint _minutes) internal pure returns (uint newTimestamp) {
        newTimestamp = timestamp - _minutes * SECONDS_PER_MINUTE;
        require(newTimestamp <= timestamp);
    }
    function subSeconds(uint timestamp, uint _seconds) internal pure returns (uint newTimestamp) {
        newTimestamp = timestamp - _seconds;
        require(newTimestamp <= timestamp);
    }

    function diffYears(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _years) {
        require(fromTimestamp <= toTimestamp);
        (uint fromYear,,) = _daysToDate(fromTimestamp / SECONDS_PER_DAY);
        (uint toYear,,) = _daysToDate(toTimestamp / SECONDS_PER_DAY);
        _years = toYear - fromYear;
    }
    function diffMonths(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _months) {
        require(fromTimestamp <= toTimestamp);
        (uint fromYear, uint fromMonth,) = _daysToDate(fromTimestamp / SECONDS_PER_DAY);
        (uint toYear, uint toMonth,) = _daysToDate(toTimestamp / SECONDS_PER_DAY);
        _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;
    }
    function diffDays(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _days) {
        require(fromTimestamp <= toTimestamp);
        _days = (toTimestamp - fromTimestamp) / SECONDS_PER_DAY;
    }
    function diffHours(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _hours) {
        require(fromTimestamp <= toTimestamp);
        _hours = (toTimestamp - fromTimestamp) / SECONDS_PER_HOUR;
    }
    function diffMinutes(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _minutes) {
        require(fromTimestamp <= toTimestamp);
        _minutes = (toTimestamp - fromTimestamp) / SECONDS_PER_MINUTE;
    }
    function diffSeconds(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _seconds) {
        require(fromTimestamp <= toTimestamp);
        _seconds = toTimestamp - fromTimestamp;
    }
}

File 15 of 29 : IRenderTypes.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library RenderTypes {
    struct RenderCtx {
        uint256 tokenId;
        // rank removed
        uint256 revealYear;
        uint256 closenessBps; // 0..10000
        uint256 blocksDisplay; // countdown display units (blocks)
        uint32 seed;
        uint256 nowTs;
    }
}

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

interface IPreRevealRegistry {
    struct Renderer {
        address svgRenderer;
        address htmlRenderer;
        bool active;
        bool requiresSevenWords;
    }

    function addRenderer(address svgRenderer, address htmlRenderer, bool active) external returns (uint256);

    function updateRenderer(uint256 rendererId, address svgRenderer, address htmlRenderer, bool active) external;

    function setRendererRequiresSevenWords(uint256 rendererId, bool required) external;

    function setDefaultRenderer(uint256 rendererId) external;

    function freeze() external;

    function rendererCount() external view returns (uint256);

    function defaultRendererId() external view returns (uint256);

    function registryFrozen() external view returns (bool);

    function getRenderer(uint256 rendererId) external view returns (Renderer memory);

    function getTokenRenderer(uint256 tokenId) external view returns (uint256 rendererId, bool isCustom);

    function setTokenRenderer(uint256 tokenId, uint256 rendererId, bool hasSevenWords) external;

    function clearTokenRenderer(uint256 tokenId) external;

    function resolveRenderer(uint256 tokenId, bool hasSevenWords)
        external
        view
        returns (uint256 rendererId, address svgRenderer, address htmlRenderer, bool isCustom);

    function setController(address controller) external;

    function controller() external view returns (address);

    function controllerLocked() external view returns (bool);
}

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

library RevealEngine {
    struct PendingSnapshot {
        uint32 beat;
        uint256 revealYear;
        bytes32 wordsHash;
        bytes32 previousNotesHash;
        bytes32 globalState;
        bool initialized;
    }

    struct PendingStorage {
        mapping(uint256 => PendingSnapshot) data;
    }

    function stage(
        PendingStorage storage store,
        uint256 tokenId,
        uint32 beat,
        uint256 revealYear,
        bytes32 wordsHash,
        bytes32 previousNotesHash,
        bytes32 globalState
    ) internal {
        PendingSnapshot storage snapshot = store.data[tokenId];
        snapshot.beat = beat;
        snapshot.revealYear = revealYear;
        snapshot.wordsHash = wordsHash;
        snapshot.previousNotesHash = previousNotesHash;
        snapshot.globalState = globalState;
        snapshot.initialized = true;
    }

    function clear(PendingStorage storage store, uint256 tokenId) internal {
        delete store.data[tokenId];
    }

    function snapshot(PendingStorage storage store, uint256 tokenId)
        internal
        view
        returns (PendingSnapshot storage)
    {
        return store.data[tokenId];
    }

    function isPending(PendingStorage storage store, uint256 tokenId) internal view returns (bool) {
        return store.data[tokenId].initialized;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC721/IERC721.sol)

pragma solidity >=0.6.2;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC-721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @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`.
     *
     * 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 calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC-721 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 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) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * 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;

    /**
     * @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;

    /**
     * @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 address zero.
     *
     * 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);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity >=0.6.2;

import {IERC721} from "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @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);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC721/utils/ERC721Utils.sol)

pragma solidity ^0.8.20;

import {IERC721Receiver} from "../IERC721Receiver.sol";
import {IERC721Errors} from "../../../interfaces/draft-IERC6093.sol";

/**
 * @dev Library that provide common ERC-721 utility functions.
 *
 * See https://eips.ethereum.org/EIPS/eip-721[ERC-721].
 *
 * _Available since v5.1._
 */
library ERC721Utils {
    /**
     * @dev Performs an acceptance check for the provided `operator` by calling {IERC721Receiver-onERC721Received}
     * on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
     *
     * The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
     * Otherwise, the recipient must implement {IERC721Receiver-onERC721Received} and return the acceptance magic value to accept
     * the transfer.
     */
    function checkOnERC721Received(
        address operator,
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal {
        if (to.code.length > 0) {
            try IERC721Receiver(to).onERC721Received(operator, from, tokenId, data) returns (bytes4 retval) {
                if (retval != IERC721Receiver.onERC721Received.selector) {
                    // Token rejected
                    revert IERC721Errors.ERC721InvalidReceiver(to);
                }
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    // non-IERC721Receiver implementer
                    revert IERC721Errors.ERC721InvalidReceiver(to);
                } else {
                    assembly ("memory-safe") {
                        revert(add(reason, 0x20), mload(reason))
                    }
                }
            }
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /// @inheritdoc IERC165
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/draft-IERC6093.sol)
pragma solidity >=0.8.4;

/**
 * @dev Standard ERC-20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC-721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC-1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}

File 24 of 29 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Return the 512-bit addition of two uint256.
     *
     * The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
     */
    function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
        assembly ("memory-safe") {
            low := add(a, b)
            high := lt(low, a)
        }
    }

    /**
     * @dev Return the 512-bit multiplication of two uint256.
     *
     * The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
     */
    function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
        // 512-bit multiply [high low] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
        // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
        // variables such that product = high * 2²⁵⁶ + low.
        assembly ("memory-safe") {
            let mm := mulmod(a, b, not(0))
            low := mul(a, b)
            high := sub(sub(mm, low), lt(mm, low))
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a + b;
            success = c >= a;
            result = c * SafeCast.toUint(success);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a - b;
            success = c <= a;
            result = c * SafeCast.toUint(success);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a * b;
            assembly ("memory-safe") {
                // Only true when the multiplication doesn't overflow
                // (c / a == b) || (a == 0)
                success := or(eq(div(c, a), b), iszero(a))
            }
            // equivalent to: success ? c : 0
            result = c * SafeCast.toUint(success);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            success = b > 0;
            assembly ("memory-safe") {
                // The `DIV` opcode returns zero when the denominator is 0.
                result := div(a, b)
            }
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            success = b > 0;
            assembly ("memory-safe") {
                // The `MOD` opcode returns zero when the denominator is 0.
                result := mod(a, b)
            }
        }
    }

    /**
     * @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
     */
    function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
        (bool success, uint256 result) = tryAdd(a, b);
        return ternary(success, result, type(uint256).max);
    }

    /**
     * @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
     */
    function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
        (, uint256 result) = trySub(a, b);
        return result;
    }

    /**
     * @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
     */
    function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
        (bool success, uint256 result) = tryMul(a, b);
        return ternary(success, result, type(uint256).max);
    }

    /**
     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
     *
     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
     * one branch when needed, making this function more expensive.
     */
    function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
        unchecked {
            // branchless ternary works because:
            // b ^ (a ^ b) == a
            // b ^ 0 == b
            return b ^ ((a ^ b) * SafeCast.toUint(condition));
        }
    }

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

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return ternary(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 towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }

        // The following calculation ensures accurate ceiling division without overflow.
        // Since a is non-zero, (a - 1) / b will not overflow.
        // The largest possible result occurs when (a - 1) / b is type(uint256).max,
        // but the largest value we can obtain is type(uint256).max - 1, which happens
        // when a = type(uint256).max and b = 1.
        unchecked {
            return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
        }
    }

    /**
     * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     *
     * 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 {
            (uint256 high, uint256 low) = mul512(x, y);

            // Handle non-overflow cases, 256 by 256 division.
            if (high == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return low / denominator;
            }

            // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
            if (denominator <= high) {
                Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
            }

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

            // Make division exact by subtracting the remainder from [high low].
            uint256 remainder;
            assembly ("memory-safe") {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                high := sub(high, gt(remainder, low))
                low := sub(low, 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.

            uint256 twos = denominator & (0 - denominator);
            assembly ("memory-safe") {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [high low] by twos.
                low := div(low, twos)

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

            // Shift in bits from high into low.
            low |= high * twos;

            // Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
            // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv ≡ 1 mod 2⁴.
            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⁸
            inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
            inverse *= 2 - denominator * inverse; // inverse mod 2³²
            inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
            inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
            inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶

            // 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²⁵⁶. Since the preconditions guarantee that the outcome is
            // less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and high
            // is no longer required.
            result = low * inverse;
            return result;
        }
    }

    /**
     * @dev 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) {
        return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
    }

    /**
     * @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
     */
    function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
        unchecked {
            (uint256 high, uint256 low) = mul512(x, y);
            if (high >= 1 << n) {
                Panic.panic(Panic.UNDER_OVERFLOW);
            }
            return (high << (256 - n)) | (low >> n);
        }
    }

    /**
     * @dev Calculates x * y >> n with full precision, following the selected rounding direction.
     */
    function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
        return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);
    }

    /**
     * @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
     *
     * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
     * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
     *
     * If the input value is not inversible, 0 is returned.
     *
     * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
     * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
     */
    function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
        unchecked {
            if (n == 0) return 0;

            // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
            // Used to compute integers x and y such that: ax + ny = gcd(a, n).
            // When the gcd is 1, then the inverse of a modulo n exists and it's x.
            // ax + ny = 1
            // ax = 1 + (-y)n
            // ax ≡ 1 (mod n) # x is the inverse of a modulo n

            // If the remainder is 0 the gcd is n right away.
            uint256 remainder = a % n;
            uint256 gcd = n;

            // Therefore the initial coefficients are:
            // ax + ny = gcd(a, n) = n
            // 0a + 1n = n
            int256 x = 0;
            int256 y = 1;

            while (remainder != 0) {
                uint256 quotient = gcd / remainder;

                (gcd, remainder) = (
                    // The old remainder is the next gcd to try.
                    remainder,
                    // Compute the next remainder.
                    // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
                    // where gcd is at most n (capped to type(uint256).max)
                    gcd - remainder * quotient
                );

                (x, y) = (
                    // Increment the coefficient of a.
                    y,
                    // Decrement the coefficient of n.
                    // Can overflow, but the result is casted to uint256 so that the
                    // next value of y is "wrapped around" to a value between 0 and n - 1.
                    x - y * int256(quotient)
                );
            }

            if (gcd != 1) return 0; // No inverse exists.
            return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
        }
    }

    /**
     * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
     *
     * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
     * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
     * `a**(p-2)` is the modular multiplicative inverse of a in Fp.
     *
     * NOTE: this function does NOT check that `p` is a prime greater than `2`.
     */
    function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
        unchecked {
            return Math.modExp(a, p - 2, p);
        }
    }

    /**
     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
     *
     * Requirements:
     * - modulus can't be zero
     * - underlying staticcall to precompile must succeed
     *
     * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
     * sure the chain you're using it on supports the precompiled contract for modular exponentiation
     * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
     * the underlying function will succeed given the lack of a revert, but the result may be incorrectly
     * interpreted as 0.
     */
    function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
        (bool success, uint256 result) = tryModExp(b, e, m);
        if (!success) {
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }
        return result;
    }

    /**
     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
     * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
     * to operate modulo 0 or if the underlying precompile reverted.
     *
     * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
     * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
     * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
     * of a revert, but the result may be incorrectly interpreted as 0.
     */
    function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
        if (m == 0) return (false, 0);
        assembly ("memory-safe") {
            let ptr := mload(0x40)
            // | Offset    | Content    | Content (Hex)                                                      |
            // |-----------|------------|--------------------------------------------------------------------|
            // | 0x00:0x1f | size of b  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x20:0x3f | size of e  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x40:0x5f | size of m  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x60:0x7f | value of b | 0x<.............................................................b> |
            // | 0x80:0x9f | value of e | 0x<.............................................................e> |
            // | 0xa0:0xbf | value of m | 0x<.............................................................m> |
            mstore(ptr, 0x20)
            mstore(add(ptr, 0x20), 0x20)
            mstore(add(ptr, 0x40), 0x20)
            mstore(add(ptr, 0x60), b)
            mstore(add(ptr, 0x80), e)
            mstore(add(ptr, 0xa0), m)

            // Given the result < m, it's guaranteed to fit in 32 bytes,
            // so we can use the memory scratch space located at offset 0.
            success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
            result := mload(0x00)
        }
    }

    /**
     * @dev Variant of {modExp} that supports inputs of arbitrary length.
     */
    function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
        (bool success, bytes memory result) = tryModExp(b, e, m);
        if (!success) {
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }
        return result;
    }

    /**
     * @dev Variant of {tryModExp} that supports inputs of arbitrary length.
     */
    function tryModExp(
        bytes memory b,
        bytes memory e,
        bytes memory m
    ) internal view returns (bool success, bytes memory result) {
        if (_zeroBytes(m)) return (false, new bytes(0));

        uint256 mLen = m.length;

        // Encode call args in result and move the free memory pointer
        result = abi.encodePacked(b.length, e.length, mLen, b, e, m);

        assembly ("memory-safe") {
            let dataPtr := add(result, 0x20)
            // Write result on top of args to avoid allocating extra memory.
            success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
            // Overwrite the length.
            // result.length > returndatasize() is guaranteed because returndatasize() == m.length
            mstore(result, mLen)
            // Set the memory pointer after the returned data.
            mstore(0x40, add(dataPtr, mLen))
        }
    }

    /**
     * @dev Returns whether the provided byte array is zero.
     */
    function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
        for (uint256 i = 0; i < byteArray.length; ++i) {
            if (byteArray[i] != 0) {
                return false;
            }
        }
        return true;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * This method is based on Newton's method for computing square roots; the algorithm is restricted to only
     * using integer operations.
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        unchecked {
            // Take care of easy edge cases when a == 0 or a == 1
            if (a <= 1) {
                return a;
            }

            // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
            // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
            // the current value as `ε_n = | x_n - sqrt(a) |`.
            //
            // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
            // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
            // bigger than any uint256.
            //
            // By noticing that
            // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
            // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
            // to the msb function.
            uint256 aa = a;
            uint256 xn = 1;

            if (aa >= (1 << 128)) {
                aa >>= 128;
                xn <<= 64;
            }
            if (aa >= (1 << 64)) {
                aa >>= 64;
                xn <<= 32;
            }
            if (aa >= (1 << 32)) {
                aa >>= 32;
                xn <<= 16;
            }
            if (aa >= (1 << 16)) {
                aa >>= 16;
                xn <<= 8;
            }
            if (aa >= (1 << 8)) {
                aa >>= 8;
                xn <<= 4;
            }
            if (aa >= (1 << 4)) {
                aa >>= 4;
                xn <<= 2;
            }
            if (aa >= (1 << 2)) {
                xn <<= 1;
            }

            // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
            //
            // We can refine our estimation by noticing that the middle of that interval minimizes the error.
            // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
            // This is going to be our x_0 (and ε_0)
            xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)

            // From here, Newton's method give us:
            // x_{n+1} = (x_n + a / x_n) / 2
            //
            // One should note that:
            // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
            //              = ((x_n² + a) / (2 * x_n))² - a
            //              = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
            //              = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
            //              = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
            //              = (x_n² - a)² / (2 * x_n)²
            //              = ((x_n² - a) / (2 * x_n))²
            //              ≥ 0
            // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
            //
            // This gives us the proof of quadratic convergence of the sequence:
            // ε_{n+1} = | x_{n+1} - sqrt(a) |
            //         = | (x_n + a / x_n) / 2 - sqrt(a) |
            //         = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
            //         = | (x_n - sqrt(a))² / (2 * x_n) |
            //         = | ε_n² / (2 * x_n) |
            //         = ε_n² / | (2 * x_n) |
            //
            // For the first iteration, we have a special case where x_0 is known:
            // ε_1 = ε_0² / | (2 * x_0) |
            //     ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
            //     ≤ 2**(2*e-4) / (3 * 2**(e-1))
            //     ≤ 2**(e-3) / 3
            //     ≤ 2**(e-3-log2(3))
            //     ≤ 2**(e-4.5)
            //
            // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
            // ε_{n+1} = ε_n² / | (2 * x_n) |
            //         ≤ (2**(e-k))² / (2 * 2**(e-1))
            //         ≤ 2**(2*e-2*k) / 2**e
            //         ≤ 2**(e-2*k)
            xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5)  -- special case, see above
            xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9)    -- general case with k = 4.5
            xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18)   -- general case with k = 9
            xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36)   -- general case with k = 18
            xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72)   -- general case with k = 36
            xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144)  -- general case with k = 72

            // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
            // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
            // sqrt(a) or sqrt(a) + 1.
            return xn - SafeCast.toUint(xn > a / xn);
        }
    }

    /**
     * @dev 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log2(uint256 x) internal pure returns (uint256 r) {
        // If value has upper 128 bits set, log2 result is at least 128
        r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
        // If upper 64 bits of 128-bit half set, add 64 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
        // If upper 32 bits of 64-bit half set, add 32 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
        // If upper 16 bits of 32-bit half set, add 16 to result
        r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
        // If upper 8 bits of 16-bit half set, add 8 to result
        r |= SafeCast.toUint((x >> r) > 0xff) << 3;
        // If upper 4 bits of 8-bit half set, add 4 to result
        r |= SafeCast.toUint((x >> r) > 0xf) << 2;

        // Shifts value right by the current result and use it as an index into this lookup table:
        //
        // | x (4 bits) |  index  | table[index] = MSB position |
        // |------------|---------|-----------------------------|
        // |    0000    |    0    |        table[0] = 0         |
        // |    0001    |    1    |        table[1] = 0         |
        // |    0010    |    2    |        table[2] = 1         |
        // |    0011    |    3    |        table[3] = 1         |
        // |    0100    |    4    |        table[4] = 2         |
        // |    0101    |    5    |        table[5] = 2         |
        // |    0110    |    6    |        table[6] = 2         |
        // |    0111    |    7    |        table[7] = 2         |
        // |    1000    |    8    |        table[8] = 3         |
        // |    1001    |    9    |        table[9] = 3         |
        // |    1010    |   10    |        table[10] = 3        |
        // |    1011    |   11    |        table[11] = 3        |
        // |    1100    |   12    |        table[12] = 3        |
        // |    1101    |   13    |        table[13] = 3        |
        // |    1110    |   14    |        table[14] = 3        |
        // |    1111    |   15    |        table[15] = 3        |
        //
        // The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
        assembly ("memory-safe") {
            r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
        }
    }

    /**
     * @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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
        }
    }

    /**
     * @dev Return the log in base 10 of a positive value rounded towards zero.
     * 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
        }
    }

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * 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 x) internal pure returns (uint256 r) {
        // If value has upper 128 bits set, log2 result is at least 128
        r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
        // If upper 64 bits of 128-bit half set, add 64 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
        // If upper 32 bits of 64-bit half set, add 32 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
        // If upper 16 bits of 32-bit half set, add 16 to result
        r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
        // Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
        return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
    }

    /**
     * @dev Return the log in base 256, 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
        }
    }

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

File 25 of 29 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.20;

/**
 * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeCast {
    /**
     * @dev Value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);

    /**
     * @dev An int value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedIntToUint(int256 value);

    /**
     * @dev Value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);

    /**
     * @dev An uint value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedUintToInt(uint256 value);

    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        if (value > type(uint248).max) {
            revert SafeCastOverflowedUintDowncast(248, value);
        }
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        if (value > type(uint240).max) {
            revert SafeCastOverflowedUintDowncast(240, value);
        }
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        if (value > type(uint232).max) {
            revert SafeCastOverflowedUintDowncast(232, value);
        }
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        if (value > type(uint224).max) {
            revert SafeCastOverflowedUintDowncast(224, value);
        }
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        if (value > type(uint216).max) {
            revert SafeCastOverflowedUintDowncast(216, value);
        }
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        if (value > type(uint208).max) {
            revert SafeCastOverflowedUintDowncast(208, value);
        }
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        if (value > type(uint200).max) {
            revert SafeCastOverflowedUintDowncast(200, value);
        }
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        if (value > type(uint192).max) {
            revert SafeCastOverflowedUintDowncast(192, value);
        }
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        if (value > type(uint184).max) {
            revert SafeCastOverflowedUintDowncast(184, value);
        }
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        if (value > type(uint176).max) {
            revert SafeCastOverflowedUintDowncast(176, value);
        }
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        if (value > type(uint168).max) {
            revert SafeCastOverflowedUintDowncast(168, value);
        }
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        if (value > type(uint160).max) {
            revert SafeCastOverflowedUintDowncast(160, value);
        }
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        if (value > type(uint152).max) {
            revert SafeCastOverflowedUintDowncast(152, value);
        }
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        if (value > type(uint144).max) {
            revert SafeCastOverflowedUintDowncast(144, value);
        }
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        if (value > type(uint136).max) {
            revert SafeCastOverflowedUintDowncast(136, value);
        }
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        if (value > type(uint128).max) {
            revert SafeCastOverflowedUintDowncast(128, value);
        }
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        if (value > type(uint120).max) {
            revert SafeCastOverflowedUintDowncast(120, value);
        }
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        if (value > type(uint112).max) {
            revert SafeCastOverflowedUintDowncast(112, value);
        }
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        if (value > type(uint104).max) {
            revert SafeCastOverflowedUintDowncast(104, value);
        }
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        if (value > type(uint96).max) {
            revert SafeCastOverflowedUintDowncast(96, value);
        }
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        if (value > type(uint88).max) {
            revert SafeCastOverflowedUintDowncast(88, value);
        }
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        if (value > type(uint80).max) {
            revert SafeCastOverflowedUintDowncast(80, value);
        }
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        if (value > type(uint72).max) {
            revert SafeCastOverflowedUintDowncast(72, value);
        }
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        if (value > type(uint64).max) {
            revert SafeCastOverflowedUintDowncast(64, value);
        }
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        if (value > type(uint56).max) {
            revert SafeCastOverflowedUintDowncast(56, value);
        }
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        if (value > type(uint48).max) {
            revert SafeCastOverflowedUintDowncast(48, value);
        }
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        if (value > type(uint40).max) {
            revert SafeCastOverflowedUintDowncast(40, value);
        }
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        if (value > type(uint32).max) {
            revert SafeCastOverflowedUintDowncast(32, value);
        }
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        if (value > type(uint24).max) {
            revert SafeCastOverflowedUintDowncast(24, value);
        }
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        if (value > type(uint16).max) {
            revert SafeCastOverflowedUintDowncast(16, value);
        }
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        if (value > type(uint8).max) {
            revert SafeCastOverflowedUintDowncast(8, value);
        }
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        if (value < 0) {
            revert SafeCastOverflowedIntToUint(value);
        }
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(248, value);
        }
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(240, value);
        }
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(232, value);
        }
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(224, value);
        }
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(216, value);
        }
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(208, value);
        }
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(200, value);
        }
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(192, value);
        }
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(184, value);
        }
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(176, value);
        }
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(168, value);
        }
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(160, value);
        }
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(152, value);
        }
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(144, value);
        }
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(136, value);
        }
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(128, value);
        }
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(120, value);
        }
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(112, value);
        }
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(104, value);
        }
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(96, value);
        }
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(88, value);
        }
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(80, value);
        }
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(72, value);
        }
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(64, value);
        }
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(56, value);
        }
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(48, value);
        }
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(40, value);
        }
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(32, value);
        }
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(24, value);
        }
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(16, value);
        }
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(8, value);
        }
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        if (value > uint256(type(int256).max)) {
            revert SafeCastOverflowedUintToInt(value);
        }
        return int256(value);
    }

    /**
     * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
     */
    function toUint(bool b) internal pure returns (uint256 u) {
        assembly ("memory-safe") {
            u := iszero(iszero(b))
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.20;

import {SafeCast} from "./SafeCast.sol";

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
     *
     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
     * one branch when needed, making this function more expensive.
     */
    function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {
        unchecked {
            // branchless ternary works because:
            // b ^ (a ^ b) == a
            // b ^ 0 == b
            return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));
        }
    }

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

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson.
            // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,
            // taking advantage of the most significant (or "sign" bit) in two's complement representation.
            // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,
            // the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).
            int256 mask = n >> 255;

            // A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.
            return uint256((n + mask) ^ mask);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 28 of 29 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity >=0.5.0;

/**
 * @title ERC-721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC-721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be
     * reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)

pragma solidity ^0.8.20;

/**
 * @dev Helper library for emitting standardized panic codes.
 *
 * ```solidity
 * contract Example {
 *      using Panic for uint256;
 *
 *      // Use any of the declared internal constants
 *      function foo() { Panic.GENERIC.panic(); }
 *
 *      // Alternatively
 *      function foo() { Panic.panic(Panic.GENERIC); }
 * }
 * ```
 *
 * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
 *
 * _Available since v5.1._
 */
// slither-disable-next-line unused-state
library Panic {
    /// @dev generic / unspecified error
    uint256 internal constant GENERIC = 0x00;
    /// @dev used by the assert() builtin
    uint256 internal constant ASSERT = 0x01;
    /// @dev arithmetic underflow or overflow
    uint256 internal constant UNDER_OVERFLOW = 0x11;
    /// @dev division or modulo by zero
    uint256 internal constant DIVISION_BY_ZERO = 0x12;
    /// @dev enum conversion error
    uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
    /// @dev invalid encoding in storage
    uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
    /// @dev empty array pop
    uint256 internal constant EMPTY_ARRAY_POP = 0x31;
    /// @dev array out of bounds access
    uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
    /// @dev resource error (too large allocation or too large array)
    uint256 internal constant RESOURCE_ERROR = 0x41;
    /// @dev calling invalid internal function
    uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;

    /// @dev Reverts with a panic code. Recommended to use with
    /// the internal constants with predefined codes.
    function panic(uint256 code) internal pure {
        assembly ("memory-safe") {
            mstore(0x00, 0x4e487b71)
            mstore(0x20, code)
            revert(0x1c, 0x24)
        }
    }
}

Settings
{
  "remappings": [
    "openzeppelin-contracts/=node_modules/@openzeppelin/contracts/",
    "forge-std/=lib/forge-std/src/",
    "@layerzerolabs/lz-evm-protocol-v2/=node_modules/@layerzerolabs/lz-evm-protocol-v2/",
    "@chainlink/=node_modules/@chainlink/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "bokkypon/=lib/bokkypon/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "vrf/=lib/vrf/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 1
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "prague",
  "viaIR": true
}

Contract Security Audit

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721IncorrectOwner","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721InsufficientApproval","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC721InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC721InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721InvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC721InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC721InvalidSender","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721NonexistentToken","type":"error"},{"inputs":[],"name":"NotRevealTime","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"RevealAlreadyPending","type":"error"},{"inputs":[],"name":"RevealNotPending","type":"error"},{"inputs":[],"name":"SevenWordsChanged","type":"error"},{"inputs":[],"name":"SnapshotMissing","type":"error"},{"inputs":[],"name":"TokenAlreadyRevealed","type":"error"},{"inputs":[],"name":"TokenDoesNotExist","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"MintPriceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"MintStatusUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"beat","type":"uint256"},{"indexed":false,"internalType":"int16","name":"leadPitch","type":"int16"},{"indexed":false,"internalType":"int16","name":"bassPitch","type":"int16"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"NoteRevealed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"payout","type":"address"}],"name":"PayoutAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"chunkId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"count","type":"uint256"}],"name":"PermutationChunkIngested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalEntries","type":"uint256"}],"name":"PermutationFinalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"seed","type":"bytes32"}],"name":"PermutationSeedFulfilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"seed","type":"bytes32"}],"name":"PermutationSeedManuallySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"PermutationSeedRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pointsAggregator","type":"address"}],"name":"PointsAggregatorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pointsManager","type":"address"}],"name":"PointsManagerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"registry","type":"address"}],"name":"PreRevealRegistryUpdated","type":"event"},{"anonymous":false,"inputs":[],"name":"RenderersFinalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"music","type":"address"},{"indexed":false,"internalType":"address","name":"audio","type":"address"},{"indexed":false,"internalType":"address","name":"countdown","type":"address"}],"name":"RenderersUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"RevealCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint32","name":"beat","type":"uint32"},{"indexed":false,"internalType":"bytes32","name":"words","type":"bytes32"}],"name":"RevealPrepared","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"TokenPreRevealRendererCleared","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"rendererId","type":"uint256"},{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"TokenPreRevealRendererSelected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"coordinator","type":"address"},{"indexed":false,"internalType":"bytes32","name":"keyHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"subscriptionId","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"minConfirmations","type":"uint16"},{"indexed":false,"internalType":"uint32","name":"callbackGasLimit","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"numWords","type":"uint32"}],"name":"VRFConfigUpdated","type":"event"},{"inputs":[],"name":"START_YEAR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"audioRenderer","outputs":[{"internalType":"contract IAudioRenderer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"basePermutation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"cancelReveal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"clearTokenPreRevealRenderer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_coordinator","type":"address"},{"internalType":"bytes32","name":"_keyHash","type":"bytes32"},{"internalType":"uint256","name":"_subscriptionId","type":"uint256"},{"internalType":"uint16","name":"_minConfirmations","type":"uint16"},{"internalType":"uint32","name":"_callbackGasLimit","type":"uint32"},{"internalType":"uint32","name":"_numWords","type":"uint32"}],"name":"configureVRF","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"finalRank","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"finalYear","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"finalizePermutation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"finalizeRenderers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"finalizeReveal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"forceReveal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAudioRenderer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getCurrentRank","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMusicRenderer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSongAlgorithm","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalState","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasPermutationSeed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"hasSevenWords","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"permutationIndices","type":"uint256[]"}],"name":"ingestPermutationChunk","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"seeds","type":"uint32[]"}],"name":"mint","outputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"count","type":"uint256"}],"name":"mint","outputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mintEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"musicRenderer","outputs":[{"internalType":"contract IMusicRenderer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"payoutAddress","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"pendingBeat","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"pendingWords","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permutationChunkCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permutationEntryCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permutationFinalized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permutationSeed","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permutationSeedFulfilled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pointsAggregator","outputs":[{"internalType":"contract IPointsAggregator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pointsManager","outputs":[{"internalType":"contract IPointsManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"preRevealRegistry","outputs":[{"internalType":"contract IPreRevealRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"prepareReveal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"previousNotesHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"rawFulfillRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renderersFinalized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"requestPermutationSeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"revealBlockTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"revealNote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"revealPending","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"revealed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"revealedBassNote","outputs":[{"internalType":"int16","name":"pitch","type":"int16"},{"internalType":"uint16","name":"duration","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"revealedLeadNote","outputs":[{"internalType":"int16","name":"pitch","type":"int16"},{"internalType":"uint16","name":"duration","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"newState","type":"bytes32"}],"name":"setGlobalState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setMintEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setMintPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"payout","type":"address"}],"name":"setPayoutAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"seed","type":"bytes32"}],"name":"setPermutationSeedManual","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pointsAggregator","type":"address"}],"name":"setPointsAggregator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pointsManager","type":"address"}],"name":"setPointsManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"registry","type":"address"}],"name":"setPreRevealRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_songAlgorithm","type":"address"},{"internalType":"address","name":"_music","type":"address"},{"internalType":"address","name":"_audio","type":"address"}],"name":"setRenderers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"wordsText","type":"string"}],"name":"setSevenWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"rendererId","type":"uint256"}],"name":"setTokenPreRevealRenderer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"sevenWords","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"sevenWordsText","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"songAlgorithm","outputs":[{"internalType":"contract ISongAlgorithm","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenSeed","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalRevealedCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vrfCallbackGasLimit","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vrfCoordinator","outputs":[{"internalType":"contract IVRFCoordinatorV2_5","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vrfKeyHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vrfMinConfirmations","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vrfNumWords","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vrfRequestId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vrfRequestInFlight","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vrfSubscriptionId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

6080604052346103a057604080519081016001600160401b038111828210176102b6576040908152601882527f45766572792054776f204d696c6c696f6e20426c6f636b730000000000000000602083015280519081016001600160401b038111828210176102b6576040526004815263229926a160e11b602082015281516001600160401b0381116102b6575f54600181811c91168015610396575b602082101461029857601f8111610334575b50602092601f82116001146102d557928192935f926102ca575b50508160011b915f199060031b1c1916175f555b80516001600160401b0381116102b657600154600181811c911680156102ac575b602082101461029857601f8111610235575b50602091601f82116001146101d5579181925f926101ca575b50508160011b915f199060031b1c1916176001555b33156101b75760068054336001600160a01b03198216811790925560405191906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a36001600755660100000000000069ffffffff000000000000196018541617601855615f8790816103a58239f35b631e4fbdf760e01b5f525f60045260245ffd5b015190505f80610128565b601f1982169260015f52805f20915f5b85811061021d57508360019510610205575b505050811b0160015561013d565b01515f1960f88460031b161c191690555f80806101f7565b919260206001819286850151815501940192016101e5565b60015f527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6601f830160051c8101916020841061028e575b601f0160051c01905b818110610283575061010f565b5f8155600101610276565b909150819061026d565b634e487b7160e01b5f52602260045260245ffd5b90607f16906100fd565b634e487b7160e01b5f52604160045260245ffd5b015190505f806100c8565b601f198216935f8052805f20915f5b86811061031c5750836001959610610304575b505050811b015f556100dc565b01515f1960f88460031b161c191690555f80806102f7565b919260206001819286850151815501940192016102e4565b5f80527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563601f830160051c8101916020841061038c575b601f0160051c01905b81811061038157506100ae565b5f8155600101610374565b909150819061036b565b90607f169061009c565b5f80fdfe6101206040526004361015610012575f80fd5b5f5f3560e01c806301069fc014613cc057806301ffc9a714613c525780630415f1d214613c35578063041d443e14613c18578063046a9043146139b957806305a6bd2014613bfb5780630689392b146128c757806306fdde0314613b595780630748d70314613b2f578063081812fc14613af3578063094940f914613acb578063095ea7b3146139e15780630ba5c3b5146139b957806313cec91d14613745578063151f2aab146135df57806318160ddd146125e657806318a7ea5f146135c25780631fb1edc9146135815780631fe543e31461335d57806323b872dd14613346578063265316df14613316578063265ab676146132c657806326869216146132a95780632c094e381461328c5780632e51d88c1461320e5780632f6aea9f146131e157806333ea51a814613137578063345402971461310d5780633b7ed734146130e75780633b999e0b14612f485780633ccfd60b14612e525780634024a59f14612b955780634083892514612b6b57806342842e0e14612b3c5780635151804a14612b165780635b8d02d714612aee5780635debcf2e14612acc5780635f51683614612a9c57806361a2bc0114612a6d5780636352211e14612a3d5780636817c76c14612a205780636a10b0e9146129b257806370a0823114612961578063715018a61461291957806377191e14146128ef578063775a603b146128c7578063813fe238146128a6578063894bdb0f1461286b5780638acf2a4a146128495780638da5cb5b14612821578063904b5f03146127f957806395d89b411461271b57806399c5819f146126fa578063a007ad11146126d2578063a0712d681461269e578063a22cb46514612603578063a2309ff8146125e6578063a2c1a905146124b9578063a3e56fa814612491578063a8135221146123da578063a967eee4146123bc578063afda869114612345578063afefa02e1461228f578063b3b4cde114612272578063b88d4fde146121fe578063bca567cc146121db578063bd456bfc1461218c578063bde0d296146120bb578063c4a723ef14611f14578063c87b56dd14610bc2578063ca9aab9514610b99578063cae42a0814610b19578063caeb94e914610af6578063ce50a16014610acf578063d123973014610aac578063d432bdc214610a83578063d6099dfc14610a59578063d72ce3e914610a19578063e0218b84146109fc578063e4b0074e146109d2578063e54fff43146109ac578063e5e95e5514610729578063e76c01e41461070b578063e985e9c5146106b3578063ed647d2114610695578063f2953ec414610657578063f2bdbc6214610628578063f2fde38b146105b2578063f46a04eb1461054a578063f4a0a528146104fc5763fe9185dd14610404575f80fd5b346104f957806003193601126104f95761041c614691565b601c5461042f60ff8260081c16156141c8565b601e549060ff82166104c05760ff161561047e5760019060ff191617601e557f43b1783899a7761df084116cdbe40fc4dc90a7d6d0bcebc592c361e2344042b36020601f54604051908152a180f35b60405162461bcd60e51b815260206004820152601a6024820152795065726d75746174696f6e2073656564206e6f7420726561647960301b6044820152606490fd5b60405162461bcd60e51b8152602060048201526011602482015270105b1c9958591e48199a5b985b1a5e9959607a1b6044820152606490fd5b80fd5b50346104f95760203660031901126104f9577f525b762709cc2a983aec5ccdfd807a061f993c91090b5bcd7da92ca254976aaa602060043561053c614691565b80600a55604051908152a180f35b50346104f95760203660031901126104f9576004358015158091036105ae5760207fba05b2d00ab98bd1b179e3718215e855be66c8e2662226717f54d603374b3efd91610595614691565b60ff196009541660ff821617600955604051908152a180f35b5080fd5b50346104f95760203660031901126104f9576105cc613f2b565b6105d4614691565b6001600160a01b0316801561061457600680546001600160a01b0319811683179091556001600160a01b03165f516020615ef25f395f51905f528380a380f35b631e4fbdf760e01b82526004829052602482fd5b50346104f95760203660031901126104f95760ff60406020926004358152602b84522054166040519015158152f35b50346104f95760203660031901126104f95761068b604060209260043561067d81614a8c565b508152602784522054614086565b1515604051908152f35b50346104f957806003193601126104f9576020601754604051908152f35b50346104f95760403660031901126104f95760406106cf613f2b565b916106d8613f41565b9260018060a01b031681526005602052209060018060a01b03165f52602052602060ff60405f2054166040519015158152f35b50346104f957806003193601126104f9576020602954604051908152f35b50346104f95760403660031901126104f957602435906004356001600160401b0383116105ae57366023840112156105ae576004830135906001600160401b0382116109a85736602483860101116109a857808352600260205260408320546001600160a01b0316330361097157808352602160205260ff60408420541661096257811561092c5780835260276020526107c66040842054614086565b6108f2576107d8368360248701614192565b60208151910120818452602660205260408420558252602760205260408220906108028254614086565b601f81116108ad575b5082601f821160011461084757839482939492610839575b50508160011b915f199060031b1c191617905580f35b602492500101355f80610823565b601f198216948385526020852091855b878110610892575083600195969710610876575b505050811b01905580f35b01602401355f19600384901b60f8161c191690555f808061086b565b90926020600181926024878701013581550194019101610857565b82845260208420601f830160051c810191602084106108e8575b601f0160051c01905b8181106108dd575061080b565b8481556001016108d0565b90915081906108c7565b60405162461bcd60e51b815260206004820152601260248201527114d95d995b881ddbdc991cc81b1bd8dad95960721b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d15dbdc991cc81c995c5d5a5c995960921b6044820152606490fd5b6305a049a960e41b8352600483fd5b60405162461bcd60e51b815260206004820152600f60248201526e2737ba103a37b5b2b71037bbb732b960891b6044820152606490fd5b8280fd5b50346104f957806003193601126104f957602060ff601c5460081c166040519015158152f35b50346104f95760203660031901126104f95760406020916004358152602483522054604051908152f35b50346104f957806003193601126104f95760208054604051908152f35b50346104f95760203660031901126104f9576040610a5591600435815260226020522054604051918161ffff849360101c169060010b8361415e565b0390f35b50346104f95760203660031901126104f95760406020916004358152600e83522054604051908152f35b50346104f957806003193601126104f957600f546040516001600160a01b039091168152602090f35b50346104f957806003193601126104f957602060ff600954166040519015158152f35b50346104f95760203660031901126104f9576020610aee600435614637565b604051908152f35b50346104f957806003193601126104f957602060ff601a54166040519015158152f35b50346104f95760203660031901126104f9577f7619eb3b0b2346250e2839a10da35fc58eea3632c6f045e8abffa1864bce25516020610b56613f2b565b610b5e614691565b610b7060ff601c5460081c16156141c8565b601280546001600160a01b0319166001600160a01b03929092169182179055604051908152a180f35b50346104f957806003193601126104f9576014546040516001600160a01b039091168152602090f35b50346104f95760203660031901126104f957610bdf600435614a8c565b5060043581526021602052604081205460ff16908115611f0357600435815260256020526040812054915b8015611ea4576004358252600e60205260408220545b602061010081905260405190610c369082614012565b83815290600435845260276101005152610c52604085206140be565b805115158091604051610c686101005182614012565b87815291611e94575b5084611a8d57610c808361557c565b42811192908315611a8657600c610c97428361462a565b04935b61271091610d27610d22617d491960048d610d196064610d13610cbe6107ea615ded565b610d00610ce4600c199888610cdd610cd85f198097615e29565b615e44565b0590615e29565b600c610cdd610cfb610cf586615e57565b86615876565b615e6d565b96610d0c6107ea615e0b565b9050615e29565b05615e80565b90500590615876565b615851565b9162015180830292808404620151801490151715611a725790829180611a68575b15611a5857610d6191610d5a9161462a565b914261462a565b81158015611a0a575b5050505b612710811115611a045750612710925b6004358852600c610100515263ffffffff6040892054169060405194610da386613fc0565b600435865286610100518701526040860152606085015260808401524260a084015260405192610dd284613fc0565b87845287610100518501528760408501528760608501528760808501528760a085015260018060a01b0360145416610e0b811515614505565b6040516351e77d4b60e11b81526004356004820152836024820152608081604481855afa908115611994578a8b918c9361199f575b5087526001600160a01b039081166040808901919091529116606087015251635e0cc79d60e01b81526101005181600481855afa8015611994578a9061195b575b608091508061010051880152602460405180948193635be7128f60e11b835260048301525afa9081156119505794886025958b610a559d96610f4b6112ce9c9760019c9760219c8591611921575b508d8060a01b0381511660808901528d8060a01b03906101005101511660a0880152610f03610efe828961563d565b6153cd565b610f45603a60405180935f516020615eb25f395f51905f52610100518301528051809161010051018484015e810188838201520301601f198101835282614012565b9661571a565b8051611918575b50602993601161117e9484600b948f9650805f1461188757825b945b156117e9575090506004358152602261010051526110ec858060408085209461ffff825196610f9c88613fdb565b5480850b885260101c16610100518701526004358152602361010051522061ffff60405191610fca83613fdb565b5480840b835260101c16610100518201526003610fe98651840b61589f565b916002610ff88251860b61589f565b9160046110078a51880b615a3b565b998361102d61102461101b86518c0b615a3b565b93518b0b615b75565b94518a0b615b75565b956040519c898e9a5180916101005101610100518d015e8a019061040560f31b61010051830152805180916101005101602284015e61010051910101630149015960e51b83820152815180926101005101600683015e010161040560f31b83820152815180926101005101600683015e01016229205b60e81b83820152815180926101005101600583015e0101602b60f81b83820152815180926101005101600483015e0101605d60f81b838201520301601e19810184520182614012565b965b60405196879361010051850199683d913730b6b2911d1160b91b8b528051809161010051018488015e8501701116113232b9b1b934b83a34b7b7111d1160791b83820152815180926101005101603a83015e01016a11161134b6b0b3b2911d1160a91b83820152815180926101005101601c83015e0101601160f91b838201520301601e19810184520182614012565b80938051611777575b505050602c91926111ae6111a86111a86111a260043561448f565b94615434565b92615434565b9360405160e0528051809161010051016101005160e051015e60e05101906e2c2261747472696275746573223a5b60881b610100518301527f7b2274726169745f74797065223a2259656172222c2276616c7565223a000000602f830152805180916101005101604c84015e61010051910101611f4b60f21b838201527f7b2274726169745f74797065223a2251756575652052616e6b222c2276616c75602e8201526232911d60e91b604e820152815180926101005101605183015e0101611f4b60f21b838201527f7b2274726169745f74797065223a22506f696e7473222c2276616c7565223a006027820152815180926101005101604683015e0101607d60f81b8282015260e051900301601e19810160e051520160e051614012565b60e05190611387575b603d61131e61136f92610efe6002604051928051809161010051016101005186015e8301615d7d60f01b610100518201528361010051910301601d19810184520182614012565b6040519384917f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000610100518401528051809161010051018585015e820190838201520301601f198101835282614012565b60405191829161010051835261010051830190613f07565b5060043581526022610100515261176f6002602e603081602f6113b0604088205460010b61589f565b6004358852602361010051526113cc604089205460010b61589f565b60805260043588526022610100515260286113ed60408a205460010b615a3b565b916004358a526023610100515261140a60408b205460010b615a3b565b60c0526004358a5260226101005152602c61142b60408c205460010b615b75565b6004358c5260226101005152838c602b61144f61ffff604084205460101c16615434565b60043583526023610100515261148a61ffff60406114728187205460010b615b75565b95600435815260236101005152205460101c16615434565b9460405160a05260e05151806101005160e051016101005160a051015e60a05101907f2c7b2274726169745f74797065223a224c65616420506974636820284d494449610100518301526a149116113b30b63ab2911d60a91b6040830152805180916101005101604b84015e61010051910101607d60f81b838201527f2c7b2274726169745f74797065223a224c656164204475726174696f6e222c2287820152663b30b63ab2911d60c91b604c820152815180926101005101605383015e0101607d60f81b838201527f2c7b2274726169745f74797065223a224261737320506974636820284d49444960298201526a149116113b30b63ab2911d60a91b6049820152815180926101005101605483015e0101607d60f81b838201527f2c7b2274726169745f74797065223a2242617373204475726174696f6e222c22602d820152663b30b63ab2911d60c91b604d820152815180926101005101605483015e0101607d60f81b838201527f2c7b2274726169745f74797065223a224c656164204e6f74652028556e69636f60298201526d3232949116113b30b63ab2911d1160911b6049820152815180926101005101605783015e010161227d60f01b838201527f2c7b2274726169745f74797065223a224c656164204e6f74652028415343494960318201526b149116113b30b63ab2911d1160a11b6051820152815180926101005101605d83015e010161227d60f01b828201527f2c7b2274726169745f74797065223a2242617373204e6f74652028556e69636f838201526d3232949116113b30b63ab2911d1160911b60508201526080515190816101005160805101605e83015e010161227d60f01b828201527f2c7b2274726169745f74797065223a2242617373204e6f74652028415343494960328201526b149116113b30b63ab2911d1160a11b605282015260c0515190816101005160c05101605e83015e010161227d60f01b8282015260a051900301601d19810160a051520160a051614012565b60a0516112d7565b602c945060126117e1928a926040519586925180916101005185015e82019071161130b734b6b0ba34b7b72fbab936111d1160711b61010051830152805180916101005101603284015e61010051910101601160f91b838201520301601e19810184520182614012565b915f80611187565b156117f657505b966110ee565b90506118826008611808600435615434565b6118118c615434565b93603a6040519586937945766572792054776f204d696c6c696f6e20426c6f636b73202360301b610100518601528051809161010051018487015e84016701016902cb2b0b9160c51b83820152815180926101005101604283015e010190838201520301601f198101835282614012565b6117f0565b8a6119136004601761189c6111a28335615434565b93604080519586925f516020615e925f395f51905f52610100518501528051809161010051018486015e8301760103bb4b636103932bb32b0b61037b7102530b71018961604d1b83820152815180926101005101605783015e0101632055544360e01b838201520301601b19810184520182614012565b610f6c565b96506029610f52565b611943915060803d608011611949575b61193b8183614012565b810190614551565b5f610ecf565b503d611931565b6040513d8b823e3d90fd5b50610100513d811161198d575b6119728183614012565b816101005191810103126119895760809051610e81565b5f80fd5b503d611968565b6040513d8c823e3d90fd5b925050506080813d6080116119fc575b816119bc60809383614012565b810103126119f8578051906119d561010051820161420a565b916119ee60606119e76040850161420a565b9301614544565b509190915f610e40565b8980fd5b3d91506119af565b92610d7e565b909192506127108202918083046127101490151715611a4457611a3057045f8080610d6a565b634e487b7160e01b89526012600452602489fd5b634e487b7160e01b8a52601160045260248afd5b5050421015610d6e575086610d6e565b5081421015610d48565b634e487b7160e01b8b52601160045260248bfd5b8793610c9a565b600496939635865260226101005152604086209160405192611aae84613fdb565b548060010b845261ffff6101005185019160101c168152600435885260236101005152604088209060405191611ae383613fdb565b54600181900b835261010051601091821c61ffff1690840190815290546001600160a01b0316908115611e365761ffff875160010b9351169061ffff855160010b91511691604051948560e081011060018060401b0360e088011117611e225796610a559e968b8f8f969e6112ce9f60019f9a60219f9a60259f99849f9361ffff9182889c60e49760e088016040526004358852610100518801998a52604088019b8c52606088019081526080880191825260a0880193845260c088019485526040519b8c9a8b99632587bc9560e01b8b525160048b01525160248a01525160448901525160010b6064880152511660848601525160010b60a4850152511660c48301525afa849181611e06575b50611db45750611c33604051611c08604082614012565b601481527326bab9b4b1903932b73232b932b91032b93937b960611b610100518201526004356151ed565b9081965b8d8060a01b03601154169081611d19575b50505050602993601161117e9484600b948f9650805f14611c6b57825b94610f6e565b8a611d14602b6008611c816111a2600435615434565b93604080519586925f516020615e925f395f51905f52610100518501528051809161010051018486015e83016701016902cb2b0b9160c51b83820152815180926101005101604883015e01017f2e20436f6e74696e756f7573206f7267616e20746f6e65732072696e67207369838201526a3731b2903932bb32b0b61760a91b6028820152030189810184520182614012565b611c65565b90859291518f0b91518f0b600435845260246101005152604084205492611d6d6040519687958694859463d5a6696960e01b8652600486015260248501526044840152608060648401526084830190613f07565b03915afa839181611d90575b50611d87575b808080611c48565b96506029611d7f565b611dad9192503d8086833e611da58183614012565b8101906145c8565b905f611d79565b90611dbe826153cd565b611e00603a60405180935f516020615eb25f395f51905f52610100518301528051809161010051018484015e810188838201520301601f198101835282614012565b96611c37565b611e1b9192503d8087833e611da58183614012565b905f611bf1565b634e487b7160e01b8e52604160045260248efd5b50505097600194602194886025958b6112ce9a96610a559e611e8c604051611e5f604082614012565b6016815275135d5cda58c81c995b99195c995c881b9bdd081cd95d60521b610100518201526004356151ed565b908196611c37565b611e9e9150614f03565b5f610c71565b6049831015611ee057600d546107ea01806107ea11611ecc5783611ec7916145bb565b610c20565b634e487b7160e01b83526011600452602483fd5b826107ea01806107ea1115610c2057634e487b7160e01b83526011600452602483fd5b611f0e600435614637565b91610c0a565b50346104f95760403660031901126104f957600435602435611f48611f4383611f3c81614a8c565b3390614d38565b614452565b818352602160205260ff6040842054166109625760145483906001600160a01b0316611f75811515614505565b8382526027602052611f8a6040832054614086565b158061201a575b813b156109a8578291606483926040519485938492634d91558b60e01b84528a60048501528960248501521560448401525af1801561200f57611ffa575b505033917f7705d1eb8a47e96b299b19e3664e8795960fbc3ba30af792e78506bd034088c88480a480f35b8161200491614012565b6109a857825f611fcf565b6040513d84823e3d90fd5b9150604051635be7128f60e11b8152836004820152608081602481855afa80156120b0576060918791612091575b500151612056578491611f91565b60405162461bcd60e51b815260206004820152601360248201527214d95d995b881ddbdc991cc81b9bdd081cd95d606a1b6044820152606490fd5b6120aa915060803d6080116119495761193b8183614012565b5f612048565b6040513d88823e3d90fd5b50346104f95760603660031901126104f9576120d5613f2b565b6120dd613f41565b906044356001600160a01b03811690819003612188577f66cd6f63bfce81eb84ce68fba06e890adfc9788d2cd317cd34d6385bcc8543fd92606092612120614691565b61213260ff601c5460081c16156141c8565b600f80546001600160a01b039283166001600160a01b031991821681179092556010805494909316938116841790925560118054909216841790915560408051928352602083019390935291810191909152a180f35b8380fd5b50346104f957806003193601126104f9576121a5614691565b61010061ff0019601c541617601c557fb1b55a633f0c097c32f64c5845d57f2face9917e90303fe9aba6e47f5e9f66218180a180f35b50346104f957806003193601126104f957602060ff601c54166040519015158152f35b50346104f95760803660031901126104f957612218613f2b565b612220613f41565b6064359190604435906001600160401b03841161226e573660238501121561226e5761225961226b943690602481600401359101614192565b9261226583838361421e565b33614dc3565b80f35b8480fd5b50346104f957806003193601126104f95760206040516107ea8152f35b5034611989576020366003190112611989576004356122b4611f4382611f3c81614a8c565b6014546001600160a01b03166122cb811515614505565b803b15611989575f8091602460405180948193635e0da3fd60e01b83528760048401525af1801561233a57612325575b5033907f21a8f5cbbad4131d0240eb5c13a30d5f8dbdac2b30e65a1f7b3f91f9c91850c38380a380f35b6123329192505f90614012565b5f905f6122fb565b6040513d5f823e3d90fd5b34611989576020366003190112611989577fa9364d56b05f85a353957cc52cf124496bc454434c180a42db8487c194cd4bd16020600435612384614691565b6001601c5461239960ff8260081c16156141c8565b82601b5560ff191617601c5560ff19601a5416601a555f601955604051908152a1005b34611989576020366003190112611989576020610aee60043561448f565b346119895760203660031901126119895760043560018060a01b036006541633148015612472575b61240b90614452565b805f52602b60205260ff60405f2054161561246357805f52602b60205260405f2060ff19815416905561243d81614cbe565b7f7fc176478ac48da2a5dc9e43507efeeadfb837980de07a34c4362d556fc5adaa5f80a2005b639bacd75b60e01b5f5260045ffd5b505f818152600260205260409020546001600160a01b03163314612402565b34611989575f366003190112611989576015546040516001600160a01b039091168152602090f35b34611989576020366003190112611989576004356124d681614a8c565b50805f52602160205260ff60405f2054166125d757805f52602b60205260ff60405f2054166125c8577f0187d3ba648623e82084dd3f3f86edeaab5d7cbcd2aa24c70c5646226e192286604061252b83614637565b600563ffffffff61253b83614abb565b9261254584614c4c565b1691855f526026602052835f205460285460295491885f52602a602052865f209363ffffffff871663ffffffff19865416178555600185015560028401556003830155600482015501600160ff19825416179055835f52602b602052815f20600160ff19825416179055835f526026602052815f205482519182526020820152a2005b63b59c293760e01b5f5260045ffd5b6305a049a960e41b5f5260045ffd5b34611989575f366003190112611989576020600854604051908152f35b346119895760403660031901126119895761261c613f2b565b60243590811515809203611989576001600160a01b031690811561268b57335f52600560205260405f20825f5260205260405f2060ff1981541660ff83161790556040519081527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a3005b50630b61174360e31b5f5260045260245ffd5b6020366003190112611989576126b26146ec565b610a556126c16004353361470c565b600160075560405191829182613f87565b34611989575f36600319011261198957600f546040516001600160a01b039091168152602090f35b3461198957602036600319011261198957612713614691565b600435602955005b34611989575f366003190112611989576040515f60015461273b81614086565b80845290600181169081156127d55750600114612777575b610a558361276381850382614012565b604051918291602083526020830190613f07565b60015f9081527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6939250905b8082106127bb57509091508101602001612763612753565b9192600181602092548385880101520191019092916127a3565b60ff191660208086019190915291151560051b840190910191506127639050612753565b34611989575f366003190112611989576012546040516001600160a01b039091168152602090f35b34611989575f366003190112611989576006546040516001600160a01b039091168152602090f35b34611989575f36600319011261198957602060ff601c54166040519015158152f35b34611989576020366003190112611989576004355f526023602052610a5560405f2054604051918161ffff849360101c169060010b8361415e565b34611989575f36600319011261198957602061ffff60185416604051908152f35b34611989575f366003190112611989576011546040516001600160a01b039091168152602090f35b34611989576020366003190112611989576004355f526025602052602060405f2054604051908152f35b34611989575f36600319011261198957612931614691565b600680546001600160a01b031981169091555f906001600160a01b03165f516020615ef25f395f51905f528280a3005b34611989576020366003190112611989576001600160a01b03612982613f2b565b16801561299f575f526003602052602060405f2054604051908152f35b6322718ad960e21b5f525f60045260245ffd5b34611989576020366003190112611989576004356129cf81614a8c565b50805f52602160205260ff60405f2054166125d757806129f1612a1e92614637565b6129fa81614abb565b612a0381614c4c565b825f52602660205260405f2054906028549260295494614aed565b005b34611989575f366003190112611989576020600a54604051908152f35b34611989576020366003190112611989576020612a5b6004356146b8565b6040516001600160a01b039091168152f35b34611989576020366003190112611989576004355f526021602052602060ff60405f2054166040519015158152f35b34611989576020366003190112611989576004355f52600c602052602063ffffffff60405f205416604051908152f35b34611989575f36600319011261198957602060ff601e54166040519015158152f35b34611989575f36600319011261198957600b546040516001600160a01b039091168152602090f35b34611989575f36600319011261198957602063ffffffff60185460301c16604051908152f35b3461198957612a1e612b4d3661404c565b9060405192612b5d602085614012565b5f845261226583838361421e565b34611989576020366003190112611989576004355f52601d602052602060405f2054604051908152f35b3461198957602036600319011261198957600435612bb281614a8c565b50805f52602b60205260ff60405f2054161561246357805f52602160205260ff60405f2054166125d757805f52602a60205260405f2060ff60058201541615612e4357815f52602660205260405f20546002820190815403612e34576080612c91836001612ccf950193612c268554614c4c565b63ffffffff82541694875f5260256020528560405f205554875f52600e60205260405f2055612c56600d54614391565b600d55865f52602160205260405f20600160ff19825416179055865f5260246020524260405f20555490600460038201549101549187614c6c565b600f5460405163232f358b60e11b815263ffffffff80861660048301529092166024830152909384916001600160a01b031690829081906044820190565b03915afa801561233a575f516020615f325f395f51905f52925f905f92612e00575b50612dfb90855f52602260205260405f20815190805491602084019261ffff63ffff0000855160101b1692169063ffffffff191617179055865f52602360205260405f2090612d9c85519183549360208801519463ffff00008660101b169061ffff86169063ffffffff191617179055612d8e6028549361ffff875160010b9351169460405195869461ffff6020870199169360010b9289614419565b03601f198101835282614012565b519020602855855f52602b60205260405f2060ff198154169055612dbf86614cbe565b612dc886614ceb565b5191516040805163ffffffff9095168552600193840b6020860152920b9183019190915242606083015281906080820190565b0390a2005b612dfb9250612e27915060803d608011612e2d575b612e1f8183614012565b8101906143f3565b91612cf1565b503d612e15565b6388e134c760e01b5f5260045ffd5b633ce8ae7f60e21b5f5260045ffd5b34611989575f36600319011261198957612e6a614691565b612e726146ec565b600b546001600160a01b03168015612f125747908115612ee0575f80809381935af1612e9c614362565b5015612ea9576001600755005b60405162461bcd60e51b815260206004820152600f60248201526e15da5d1a191c985dc819985a5b1959608a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152600a6024820152694e6f2062616c616e636560b01b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d14185e5bdd5d081b9bdd081cd95d60921b6044820152606490fd5b34611989576040366003190112611989576004356001600160401b03811161198957612f78903690600401613f57565b906024356001600160401b03811161198957612f98903690600401613f57565b612fa3929192614691565b612fb560ff601c5460081c16156141c8565b60ff601e54166130aa57808403613073578315613040575f5b848110613013578480601f5401601f557ff568ff94e3b74d950644b19253025001012802b6c60f7157a2e573c19a2f8a946020600181540192838255604051908152a2005b80613021600192848761433e565b3561302d82888761433e565b355f52601d60205260405f205501612fce565b60405162461bcd60e51b815260206004820152600b60248201526a456d707479206368756e6b60a81b6044820152606490fd5b60405162461bcd60e51b815260206004820152600f60248201526e098cadccee8d040dad2e6dac2e8c6d608b1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601560248201527414195c9b5d5d185d1a5bdb88199a5b985b1a5e9959605a1b6044820152606490fd5b34611989575f36600319011261198957602063ffffffff60185460101c16604051908152f35b34611989576020366003190112611989576004355f526027602052610a5561276360405f206140be565b34611989576020366003190112611989576004356001600160a01b0381169081900361198957613165614691565b80156131ab57600b80546001600160a01b031916821790556040519081527ffcbb1571f6f637b3645e200ff18fbcb7fc2f8db33547e2f582146a51246e104390602090a1005b60405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a59081c185e5bdd5d60921b6044820152606490fd5b34611989576020366003190112611989576004355f52602a6020526020600260405f200154604051908152f35b34611989576020366003190112611989577fce5202ecc8b8799ee1618adf9acec1ce2a28f52077ffc9bcdcf6c794f9e0c37a602061324a613f2b565b613252614691565b61326460ff601c5460081c16156141c8565b601380546001600160a01b0319166001600160a01b03929092169182179055604051908152a1005b34611989575f366003190112611989576020602854604051908152f35b34611989575f366003190112611989576020600d54604051908152f35b34611989576020366003190112611989576004356132e2614691565b6132eb81614a8c565b50805f52602160205260ff60405f2054166125d7578061330d612a1e92614637565b612a0381614abb565b34611989576020366003190112611989576004355f52602a602052602063ffffffff60405f205416604051908152f35b3461198957612a1e6133573661404c565b9161421e565b34611989576040366003190112611989576004356024356001600160401b03811161198957366023820112156119895780600401359061339c82614035565b906133aa6040519283614012565b828252602082016024819460051b8301019136831161198957602401905b8282106135715750506015546001600160a01b03163303905061353557601a549160ff8316156135035760195484036134cb5781511561349157604051915160208301929183915f5b81811061347b57877fe6a62e3b78d7c6d033cc5a5342e02a252e89d611a1a06139ec4fff6cf9b7a95d6020898989613452818b03601f198101835282614012565b5190209081601b55600160ff19601c541617601c5560ff1916601a5583601955604051908152a2005b8251845260209384019390920191600101613411565b60405162461bcd60e51b8152602060048201526012602482015271456d7074792072616e646f6d20776f72647360701b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f0a4cae2eacae6e840dad2e6dac2e8c6d60831b6044820152606490fd5b60405162461bcd60e51b815260206004820152600a602482015269139bc81c995c5d595cdd60b21b6044820152606490fd5b60405162461bcd60e51b815260206004820152601460248201527327b7363c902b29231031b7b7b93234b730ba37b960611b6044820152606490fd5b81358152602091820191016133c8565b6020366003190112611989576004356001600160401b038111611989576126c16135b2610a55923690600401613f57565b90506135bc6146ec565b3361470c565b34611989575f366003190112611989576020601954604051908152f35b34611989576020366003190112611989576135f8613f2b565b613600614691565b61361260ff601c5460081c16156141c8565b6001600160a01b0316801561370d57601480546001600160a01b0319168217905560405163f77c479160e01b8152602081600481855afa90811561233a575f916136d3575b50306001600160a01b039091160361368f577f8bcb883236eb12e417bbcf3954fbfb75e412cafc6b9e2d3a28c5855e9a821d675f80a2005b60405162461bcd60e51b815260206004820152601c60248201527b0a4caced2e6e8e4f240c6dedce8e4ded8d8cae440dad2e6dac2e8c6d60231b6044820152606490fd5b90506020813d602011613705575b816136ee60209383614012565b81010312611989576136ff9061420a565b82613657565b3d91506136e1565b60405162461bcd60e51b815260206004820152601060248201526f496e76616c696420726567697374727960801b6044820152606490fd5b346119895760c03660031901126119895761375e613f2b565b602435604435916064359161ffff8316809303611989576084359163ffffffff83168084036119895760a4359463ffffffff861692838703611989576137a2614691565b6137b460ff601c5460081c16156141c8565b6001600160a01b031696871561397e57841561394657801561390a5781156138d357821561389d57831561386a577fdb916dcd2cdb2972bd841f7aca5eb0597e3ebafd6ff8338eaebe31a6da321e8f9660a096896001808a1b03196015541617601555866016558260175565ffffffff0000846018549363ffffffff60301b9060301b169360018060501b031916179160101b1617176018556040519485526020850152604084015260608301526080820152a2005b60405162461bcd60e51b815260206004820152600b60248201526a04e756d20776f7264733d360ac1b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d043616c6c6261636b206761733d360941b6044820152606490fd5b60405162461bcd60e51b815260206004820152600f60248201526e0436f6e6669726d6174696f6e733d3608c1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601460248201527324b73b30b634b21039bab139b1b934b83a34b7b760611b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f092dcecc2d8d2c840d6caf240d0c2e6d60831b6044820152606490fd5b60405162461bcd60e51b815260206004820152601360248201527224b73b30b634b21031b7b7b93234b730ba37b960691b6044820152606490fd5b34611989575f366003190112611989576010546040516001600160a01b039091168152602090f35b34611989576040366003190112611989576139fa613f2b565b602435613a06816146b8565b33151580613ab8575b80613a8b575b613a785781906001600160a01b0384811691167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9255f80a45f90815260046020526040902080546001600160a01b0319166001600160a01b03909216919091179055005b63a9fbf51f60e01b5f523360045260245ffd5b506001600160a01b0381165f90815260056020908152604080832033845290915290205460ff1615613a15565b506001600160a01b038116331415613a0f565b34611989575f366003190112611989576013546040516001600160a01b039091168152602090f35b3461198957602036600319011261198957600435613b10816146b8565b505f526004602052602060018060a01b0360405f205416604051908152f35b34611989576020366003190112611989576004355f526026602052602060405f2054604051908152f35b34611989575f366003190112611989576040515f5f54613b7881614086565b80845290600181169081156127d55750600114613b9f57610a558361276381850382614012565b5f8080527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563939250905b808210613be157509091508101602001612763612753565b919260018160209254838588010152019101909291613bc9565b34611989575f366003190112611989576020601b54604051908152f35b34611989575f366003190112611989576020601654604051908152f35b34611989575f366003190112611989576020601f54604051908152f35b346119895760203660031901126119895760043563ffffffff60e01b8116809103611989576020906380ac58cd60e01b8114908115613caf575b8115613c9e575b506040519015158152f35b6301ffc9a760e01b14905082613c93565b635b5e139f60e01b81149150613c8c565b34611989575f36600319011261198957613cd8614691565b613cea60ff601c5460081c16156141c8565b6015546001600160a01b03168015613ecd5760ff601a5416613e945760165460175460185460405192936020840193919290916001600160401b03851181861017613e805761ffff95613dfa5f92602097604052600181526040519063125fa26760e31b89830152511515602482015260248152613d69604482614012565b60405192613d7684613fc0565b835287830194855263ffffffff60408401978a811689528160608601818360101c16815281608088019360301c16835260a087019485526040519c8d9b8c9a8b99634d8e1c2f60e11b8b528f60048c01525160248b01525160448a01525116606488015251166084860152511660a48401525160c060c484015260e4830190613f07565b03925af190811561233a575f91613e4e575b5080601955600160ff19601a541617601a5560ff19601c5416601c557fa4e9307236598ef4dc1664a1ca86010aef9cc4c4e4fb9d54efda8c5d437932e05f80a2005b90506020813d602011613e78575b81613e6960209383614012565b81010312611989575181613e0c565b3d9150613e5c565b634e487b7160e01b5f52604160045260245ffd5b60405162461bcd60e51b815260206004820152601160248201527014995c5d595cdd081a5b88199b1a59da1d607a1b6044820152606490fd5b60405162461bcd60e51b8152602060048201526012602482015271159491881b9bdd0818dbdb999a59dd5c995960721b6044820152606490fd5b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b600435906001600160a01b038216820361198957565b602435906001600160a01b038216820361198957565b9181601f84011215611989578235916001600160401b038311611989576020808501948460051b01011161198957565b60206040818301928281528451809452019201905f5b818110613faa5750505090565b8251845260209384019390920191600101613f9d565b60c081019081106001600160401b03821117613e8057604052565b604081019081106001600160401b03821117613e8057604052565b61018081019081106001600160401b03821117613e8057604052565b601f909101601f19168101906001600160401b03821190821017613e8057604052565b6001600160401b038111613e805760051b60200190565b6060906003190112611989576004356001600160a01b038116810361198957906024356001600160a01b0381168103611989579060443590565b90600182811c921680156140b4575b60208310146140a057565b634e487b7160e01b5f52602260045260245ffd5b91607f1691614095565b9060405191825f8254926140d184614086565b808452936001811690811561413c57506001146140f8575b506140f692500383614012565b565b90505f9291925260205f20905f915b8183106141205750509060206140f6928201015f6140e9565b6020919350806001915483858901015201910190918492614107565b9050602092506140f694915060ff191682840152151560051b8201015f6140e9565b90929161ffff602091604084019560010b845216910152565b6001600160401b038111613e8057601f01601f191660200190565b92919261419e82614177565b916141ac6040519384614012565b829481845281830111611989578281602093845f960137010152565b156141cf57565b60405162461bcd60e51b815260206004820152601360248201527214995b99195c995c9cc8199a5b985b1a5e9959606a1b6044820152606490fd5b51906001600160a01b038216820361198957565b6001600160a01b039091169190821561432b575f828152600260205260409020546001600160a01b0316928290336142e5575b846142c4575b805f52600360205260405f2060018154019055815f52600260205260405f208160018060a01b0319825416179055845f516020615f125f395f51905f525f80a46001600160a01b03168083036142ac57505050565b6364283d7b60e01b5f5260045260245260445260645ffd5b6142cd82615be0565b845f52600360205260405f205f198154019055614257565b906142f1903386614d38565b156142fd578290614251565b828461431557637e27328960e01b5f5260045260245ffd5b63177e802f60e01b5f523360045260245260445ffd5b633250574960e11b5f525f60045260245ffd5b919081101561434e5760051b0190565b634e487b7160e01b5f52603260045260245ffd5b3d1561438c573d9061437382614177565b916143816040519384614012565b82523d5f602084013e565b606090565b5f19811461439f5760010190565b634e487b7160e01b5f52601160045260245ffd5b9190826040910312611989576040516143cb81613fdb565b80928051908160010b820361198957602091835201519061ffff821682036119895760200152565b91906080838203126119895780604061440f61441693866143b3565b94016143b3565b90565b90815260f091821b602082015291811b6001600160f01b0319908116602284015292811b60248301529290921b16602682015260280190565b1561445957565b60405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b6044820152606490fd5b6012546001600160a01b03169081156144ff57602090602460405180948193631048226b60e31b835260048301525afa90811561233a575f916144d0575090565b90506020813d6020116144f7575b816144eb60209383614012565b81010312611989575190565b3d91506144de565b50505f90565b1561450c57565b60405162461bcd60e51b815260206004820152601060248201526f149959da5cdd1c9e481b9bdd081cd95d60821b6044820152606490fd5b5190811515820361198957565b908160809103126119895760405190608082016001600160401b03811183821017613e80576145b3916060916040526145898161420a565b84526145976020820161420a565b60208501526145a860408201614544565b604085015201614544565b606082015290565b9190820180921161439f57565b602081830312611989578051906001600160401b038211611989570181601f82011215611989578051906145fb82614177565b926146096040519485614012565b8284526020838301011161198957815f9260208093018386015e8301015290565b9190820391821161439f57565b61464081614a8c565b506012546001600160a01b03169081156146825760209060246040518094819363b176aa4560e01b835260048301525afa90811561233a575f916144d0575090565b5f1981019150811161439f5790565b6006546001600160a01b031633036146a557565b63118cdaa760e01b5f523360045260245ffd5b5f818152600260205260409020546001600160a01b03169081156146da575090565b637e27328960e01b5f5260045260245ffd5b6002600754146146fd576002600755565b633ee5aeb560e01b5f5260045ffd5b919060ff6009541615614a57578015614a2457600a548181029080820483149015171561439f5734036149eb579161474383614035565b6147506040519182614012565b838152601f1961475f85614035565b0136602083013780935f9260203360601b945b83811061478157505050505050565b61478c600854614391565b908160085560405161479e8482614012565b5f81526001600160a01b03851690811561432b575f8481526002865260409020546001600160a01b031680151590816149cb575b5f8481526003885260408082208054600101905587825260028952812080546001600160a01b031916861790558690859083905f516020615f125f395f51905f529080a4506149b857853b6148ba575b505063ffffffff6040518481019042825244604082015260018060601b03198760601b1660608201528960748201528460888201526088815261486660a882614012565b51902016825f52600c845263ffffffff60405f20911663ffffffff198254161790555f19820182811161439f57825f52601d845260405f2055855181101561434e57600191838260051b8801015201614772565b84614902835f9360409e9c9a989d9b999796959e51948580948193630a85bd0160e11b83523360048401528360248401528a6044840152608060648401526084830190613f07565b03925af15f9181614978575b5061493c578a8a61491d614362565b80519190826149395783633250574960e11b5f5260045260245ffd5b01fd5b630a85bd0160e19b92939496989a9597999b1b9063ffffffff60e01b160361496657505f80614822565b633250574960e11b5f5260045260245ffd5b9091508a81813d83116149b1575b6149908183614012565b8101031261198957516001600160e01b03198116810361198957905f61490e565b503d614986565b6339e3563760e11b5f525f60045260245ffd5b6149d486615be0565b805f526003875260405f205f1981540190556147d2565b60405162461bcd60e51b8152602060048201526011602482015270125b98dbdc9c9958dd081c185e5b595b9d607a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152600b60248201526a08adae0e8f240c4c2e8c6d60ab1b6044820152606490fd5b60405162461bcd60e51b815260206004820152600d60248201526c135a5b9d08191a5cd8589b1959609a1b6044820152606490fd5b5f908152600260205260409020546001600160a01b0316908115614aac57565b63677510db60e11b5f5260045ffd5b60498110614ad3576107ea01806107ea1161439f5790565b600d546107ea0190816107ea1161439f57614416916145bb565b94614b5594612c919294608094885f52602160205260405f20600160ff19825416179055885f5260246020524260405f205563ffffffff871696895f52602560205260405f2055885f52600e60205260405f2055614b4c600d54614391565b600d5587614c6c565b03915afa801561233a575f516020615f325f395f51905f52925f905f92614c28575b50614c2390855f52602260205260405f20815190805491602084019261ffff63ffff0000855160101b1692169063ffffffff191617179055865f52602360205260405f2090614c1485519183549360208801519463ffff00008660101b169061ffff86169063ffffffff191617179055612d8e6028549361ffff875160010b9351169460405195869461ffff6020870199169360010b9289614419565b519020602855612dc886614ceb565b0390a2565b614c239250614c46915060803d608011612e2d57612e1f8183614012565b91614b77565b614c559061557c565b4210614c5d57565b635905cd4d60e01b5f5260045ffd5b63ffffffff93815f52600c60205260405f2054936040519360208501958760e01b9060e01b168652602485015260448401526064830152608482015260848152614cb760a482614012565b5190201690565b5f52602a6020525f6005604082208281558260018201558260028201558260038201558260048201550155565b6013546001600160a01b03169081614d01575050565b813b15611989575f9160248392604051948593849263181d4bb960e11b845260048401525af1614d2e5750565b5f6140f691614012565b6001600160a01b03909116801515929183614d54575b50505090565b6001600160a01b031680821493509091908315614da0575b508215614d7e575b50505f8080614d4e565b5f908152600460205260408120546001600160a01b0316909114915080614d74565b9092505f52600560205260405f20815f5260205260ff60405f205416915f614d6c565b823b614dd1575b5050505050565b604051630a85bd0160e11b81526001600160a01b039182166004820152918116602483015260448201939093526080606482015291169160209082908190614e1d906084830190613f07565b03815f865af15f9181614e7b575b50614e595750614e39614362565b80519081614e545782633250574960e11b5f5260045260245ffd5b602001fd5b6001600160e01b03191663757a42ff60e11b0161496657505f80808080614dca565b9091506020813d602011614eb8575b81614e9760209383614012565b8101031261198957516001600160e01b03198116810361198957905f614e2b565b3d9150614e8a565b90614eca82614177565b614ed76040519182614012565b8281528092614ee8601f1991614177565b0190602036910137565b90815181101561434e570160200190565b9081519182156151d6576006830283810460060361439f57614f2490614ec0565b925f915f5b828110614f7857505050614f3c81614ec0565b905f5b818110614f4d575090925050565b6001906001600160f81b0319614f638288614ef2565b51165f1a614f718286614ef2565b5301614f3f565b614f828183614ef2565b516001600160f81b0319811694908790601160f91b871480156151c9575b15614fdf5750509081605c614fc0614fb9600195614391565b928a614ef2565b53614fd7614fcd82614391565b965f1a9189614ef2565b535b01614f29565b91959091600160fb1b820361501e57505050600190605c61500961500287614391565b9689614ef2565b53606261501861500287614391565b53614fd9565b600360fa1b820361504c57505050600190605c61503d61500287614391565b53606661501861500287614391565b600560f91b820361507a57505050600190605c61506b61500287614391565b53606e61501861500287614391565b600d60f81b82036150a857505050600190605c61509961500287614391565b53607261501861500287614391565b600960f81b82036150d657505050600190605c6150c761500287614391565b53607461501861500287614391565b9091958160f81c926020841080156151bc575b80156151af575b80156151a2575b1561518d5750600193926151626151809360306151598b8261514988605c61512a615123600f9c614391565b9286614ef2565b53607561513961512383614391565b5361514381614391565b93614ef2565b5361515381614391565b9c614ef2565b5360fc1c615bfd565b9761517961516f82614391565b995f1a918c614ef2565b5316615bfd565b94615018614fcd82614391565b965090506001929150615018614fcd82614391565b50601360f91b81146150f7565b50601f60f91b81146150f0565b50600f60fa1b81146150e9565b50601760fa1b8714614fa0565b5090506040516151e7602082614012565b5f815290565b603a6153956020610efe600d604d839760d98561520c6144169a615434565b926040519788947f3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f3230828701527f30302f737667222076696577426f783d223020302036303020363030223e000060408701527f3c726563742077696474683d223130302522206865696768743d223130302522605e8701526d103334b6361e911198181811179f60911b607e8701527f3c7465787420783d223330302220793d223330302220746578742d616e63686f608c8701525f516020615ed25f395f51905f5260ac870152651e911918111f60d11b60cc87015266546f6b656e202360c81b60d28701528051918291018587015e840190661e17ba32bc3a1f60c91b848301527f3c7465787420783d223330302220793d223333302220746578742d616e63686f60e08301525f516020615ed25f395f51905f52610100830152651e91189a111f60d11b61012083015280519283910161012683015e0101661e17ba32bc3a1f60c91b83820152651e17b9bb339f60d11b60548201520301601219810184520182614012565b6040519384915f516020615eb25f395f51905f52828401528051918291018484015e81015f838201520301601f198101835282614012565b604051614416916153df606083614012565b604082527f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208301527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f6040830152615c55565b5f908072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b811015615559575b600a906904ee2d6d415b85acef8160201b81101561553d575b662386f26fc10000811015615529575b6305f5e100811015615518575b612710811015615509575b60648110156154fb575b10156154f0575b600a60216154b860018501614ec0565b938401015b5f1901916f181899199a1a9b1b9c1cb0b131b232b360811b8282061a83530480156154eb57600a90916154bd565b505090565b6001909101906154a8565b6064600291049301926154a1565b61271060049104930192615497565b6305f5e1006008910493019261548c565b662386f26fc100006010910493019261547f565b602093909301926904ee2d6d415b85acef8160201b900461546f565b506040915072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8104615456565b6107b281106155ff57610d226155e59160046155de6064610d13617d49196155a386615ded565b90610d0c6155d86155c1600c199389610cdd610cd85f198099615e29565b600c610cdd610cfb6155d288615e57565b88615876565b97615e0b565b0590615876565b6201518081029080820462015180149015171561439f5790565b60405162461bcd60e51b81526020600482015260166024820152750b2cac2e440c4caccdee4ca40aadcd2f040cae0dec6d60531b6044820152606490fd5b906156548160018060a01b03604085015116615d36565b90615714575081516020830151036156a75760405162461bcd60e51b815260206004820152601960248201527828393296b932bb32b0b6103932b73232b932b91032b93937b960391b6044820152606490fd5b6080909101516156c091906001600160a01b0316615d36565b906144165760405162461bcd60e51b815260206004820152602160248201527f44656661756c74207072652d72657665616c2072656e6465726572206572726f6044820152603960f91b6064820152608490fd5b91505090565b906157318160018060a01b03606085015116615d36565b9061571457508151602083015103615754575b50506040516151e7602082614012565b60a09091015161576d91906001600160a01b0316615d36565b906144165780615744565b60405190615787604083614012565b60018252604360f81b6020830152565b604051906157a6604083614012565b60018252601160fa1b6020830152565b604051906157c5604083614012565b60018252604560f81b6020830152565b604051906157e4604083614012565b60018252602360f91b6020830152565b60405190615803604083614012565b60018252604760f81b6020830152565b60405190615822604083614012565b60018252604160f81b6020830152565b60405190615841604083614012565b60018252602160f91b6020830152565b9062253d8b19820191821360011661439f57565b905f19820191821360011661439f57565b81810392915f13801582851316918412161761439f57565b90600c81101561434e5760051b0190565b60010b5f198114615a185761441660209182806040516158be81613ff6565b6158c6615778565b81526159e56159de60409283516158dd8582614012565b600481526344e299ad60e01b86820152818601526158f9615797565b8482015283516159098582614012565b600481526345e299ad60e01b8682015260608201526159266157b6565b60808201526159336157d5565b60a082015283516159448582614012565b600481526347e299ad60e01b8682015260c08201526159616157f4565b60e082015283516159728582614012565b600481526341e299ad60e01b86820152610100820152615990615813565b61012082015283516159a28582614012565b600481526342e299ad60e01b868201526101408201526159c0615832565b610160820152600c6159d3818904615865565b60010b97069061588e565b5194615b75565b90519584879551918291018487015e8401908282015f8152815193849201905e01015f815203601f198101835282614012565b50604051615a27604082614012565b6004815263f09d84bd60e01b602082015290565b60010b5f198114615b52576144166020918280604051615a5a81613ff6565b615a62615778565b81526159e56159de6040928351615a798582614012565b6002815261223160f11b8682015285820152615a93615797565b848201528351615aa38582614012565b600281526122b160f11b868201526060820152615abe6157b6565b6080820152615acb6157d5565b60a08201528351615adc8582614012565b600281526123b160f11b8682015260c0820152615af76157f4565b60e08201528351615b088582614012565b600281526120b160f11b86820152610100820152615b24615813565b6101208201528351615b368582614012565b6002815261213160f11b868201526101408201526159c0615832565b50604051615b61604082614012565b6004815263149154d560e21b602082015290565b600181900b5f8112615b8f575061ffff6144169116615434565b9050617fff19811461439f576144166021615bb161ffff6020945f0316615434565b604051938491602d60f81b828401528051918291018484015e81015f838201520301601f198101835282614012565b5f90815260046020526040902080546001600160a01b0319169055565b60ff16600a811015615c255760300160ff811161439f575b60f81b6001600160f81b03191690565b6009190160ff811161439f5760ff606191160160ff811115615c1557634e487b7160e01b5f52601160045260245ffd5b9190918051156151d65780516002810180911161439f5760039004600281901b906001600160fe1b0381160361439f57615c8e90614ec0565b90602082019080815182019560208701908151925f83525b888110615ce85750506003939495965052510680600114615cd657600214615ccc575090565b603d905f19015390565b50603d90815f19820153600119015390565b600360049199969901986001603f8b5182828260121c16870101518453828282600c1c16870101518385015382828260061c1687010151600285015316840101516003820153019497615ca6565b6001600160a01b0316908115615ddb5760a060c45f92604051948593849263018e174b60e11b84528051600485015260208101516024850152604081015160448501526060810151606485015263ffffffff6080820151166084850152015160a48301525afa5f9181615dbf575b50615dba57505f906040516151e7602082614012565b600191565b615dd49192503d805f833e611da58183614012565b905f615da4565b50505f906040516151e7602082614012565b906112c08201915f6112c08412911290801582169115161761439f57565b906113248201915f6113248412911290801582169115161761439f57565b9190915f838201938412911290801582169115161761439f57565b90816105b502916105b583050361439f57565b90600c820291808305600c149015171561439f57565b908161016f029161016f83050361439f57565b908160030291600383050361439f5756fe45766572792054776f204d696c6c696f6e20426c6f636b7320746f6b656e2023646174613a696d6167652f7376672b786d6c3b6261736536342c000000000000723d226d6964646c65222066696c6c3d22236666662220666f6e742d73697a658be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef29dee32be1e7550cd032521981e098ddf419ea5c2454868f36012088b755171ba26469706673582212201b8d622cdb589bee9dedee8e72b52b68303d045fdde1ee0a8af01b7059d272af64736f6c634300081e0033

Deployed Bytecode

0x6101206040526004361015610012575f80fd5b5f5f3560e01c806301069fc014613cc057806301ffc9a714613c525780630415f1d214613c35578063041d443e14613c18578063046a9043146139b957806305a6bd2014613bfb5780630689392b146128c757806306fdde0314613b595780630748d70314613b2f578063081812fc14613af3578063094940f914613acb578063095ea7b3146139e15780630ba5c3b5146139b957806313cec91d14613745578063151f2aab146135df57806318160ddd146125e657806318a7ea5f146135c25780631fb1edc9146135815780631fe543e31461335d57806323b872dd14613346578063265316df14613316578063265ab676146132c657806326869216146132a95780632c094e381461328c5780632e51d88c1461320e5780632f6aea9f146131e157806333ea51a814613137578063345402971461310d5780633b7ed734146130e75780633b999e0b14612f485780633ccfd60b14612e525780634024a59f14612b955780634083892514612b6b57806342842e0e14612b3c5780635151804a14612b165780635b8d02d714612aee5780635debcf2e14612acc5780635f51683614612a9c57806361a2bc0114612a6d5780636352211e14612a3d5780636817c76c14612a205780636a10b0e9146129b257806370a0823114612961578063715018a61461291957806377191e14146128ef578063775a603b146128c7578063813fe238146128a6578063894bdb0f1461286b5780638acf2a4a146128495780638da5cb5b14612821578063904b5f03146127f957806395d89b411461271b57806399c5819f146126fa578063a007ad11146126d2578063a0712d681461269e578063a22cb46514612603578063a2309ff8146125e6578063a2c1a905146124b9578063a3e56fa814612491578063a8135221146123da578063a967eee4146123bc578063afda869114612345578063afefa02e1461228f578063b3b4cde114612272578063b88d4fde146121fe578063bca567cc146121db578063bd456bfc1461218c578063bde0d296146120bb578063c4a723ef14611f14578063c87b56dd14610bc2578063ca9aab9514610b99578063cae42a0814610b19578063caeb94e914610af6578063ce50a16014610acf578063d123973014610aac578063d432bdc214610a83578063d6099dfc14610a59578063d72ce3e914610a19578063e0218b84146109fc578063e4b0074e146109d2578063e54fff43146109ac578063e5e95e5514610729578063e76c01e41461070b578063e985e9c5146106b3578063ed647d2114610695578063f2953ec414610657578063f2bdbc6214610628578063f2fde38b146105b2578063f46a04eb1461054a578063f4a0a528146104fc5763fe9185dd14610404575f80fd5b346104f957806003193601126104f95761041c614691565b601c5461042f60ff8260081c16156141c8565b601e549060ff82166104c05760ff161561047e5760019060ff191617601e557f43b1783899a7761df084116cdbe40fc4dc90a7d6d0bcebc592c361e2344042b36020601f54604051908152a180f35b60405162461bcd60e51b815260206004820152601a6024820152795065726d75746174696f6e2073656564206e6f7420726561647960301b6044820152606490fd5b60405162461bcd60e51b8152602060048201526011602482015270105b1c9958591e48199a5b985b1a5e9959607a1b6044820152606490fd5b80fd5b50346104f95760203660031901126104f9577f525b762709cc2a983aec5ccdfd807a061f993c91090b5bcd7da92ca254976aaa602060043561053c614691565b80600a55604051908152a180f35b50346104f95760203660031901126104f9576004358015158091036105ae5760207fba05b2d00ab98bd1b179e3718215e855be66c8e2662226717f54d603374b3efd91610595614691565b60ff196009541660ff821617600955604051908152a180f35b5080fd5b50346104f95760203660031901126104f9576105cc613f2b565b6105d4614691565b6001600160a01b0316801561061457600680546001600160a01b0319811683179091556001600160a01b03165f516020615ef25f395f51905f528380a380f35b631e4fbdf760e01b82526004829052602482fd5b50346104f95760203660031901126104f95760ff60406020926004358152602b84522054166040519015158152f35b50346104f95760203660031901126104f95761068b604060209260043561067d81614a8c565b508152602784522054614086565b1515604051908152f35b50346104f957806003193601126104f9576020601754604051908152f35b50346104f95760403660031901126104f95760406106cf613f2b565b916106d8613f41565b9260018060a01b031681526005602052209060018060a01b03165f52602052602060ff60405f2054166040519015158152f35b50346104f957806003193601126104f9576020602954604051908152f35b50346104f95760403660031901126104f957602435906004356001600160401b0383116105ae57366023840112156105ae576004830135906001600160401b0382116109a85736602483860101116109a857808352600260205260408320546001600160a01b0316330361097157808352602160205260ff60408420541661096257811561092c5780835260276020526107c66040842054614086565b6108f2576107d8368360248701614192565b60208151910120818452602660205260408420558252602760205260408220906108028254614086565b601f81116108ad575b5082601f821160011461084757839482939492610839575b50508160011b915f199060031b1c191617905580f35b602492500101355f80610823565b601f198216948385526020852091855b878110610892575083600195969710610876575b505050811b01905580f35b01602401355f19600384901b60f8161c191690555f808061086b565b90926020600181926024878701013581550194019101610857565b82845260208420601f830160051c810191602084106108e8575b601f0160051c01905b8181106108dd575061080b565b8481556001016108d0565b90915081906108c7565b60405162461bcd60e51b815260206004820152601260248201527114d95d995b881ddbdc991cc81b1bd8dad95960721b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d15dbdc991cc81c995c5d5a5c995960921b6044820152606490fd5b6305a049a960e41b8352600483fd5b60405162461bcd60e51b815260206004820152600f60248201526e2737ba103a37b5b2b71037bbb732b960891b6044820152606490fd5b8280fd5b50346104f957806003193601126104f957602060ff601c5460081c166040519015158152f35b50346104f95760203660031901126104f95760406020916004358152602483522054604051908152f35b50346104f957806003193601126104f95760208054604051908152f35b50346104f95760203660031901126104f9576040610a5591600435815260226020522054604051918161ffff849360101c169060010b8361415e565b0390f35b50346104f95760203660031901126104f95760406020916004358152600e83522054604051908152f35b50346104f957806003193601126104f957600f546040516001600160a01b039091168152602090f35b50346104f957806003193601126104f957602060ff600954166040519015158152f35b50346104f95760203660031901126104f9576020610aee600435614637565b604051908152f35b50346104f957806003193601126104f957602060ff601a54166040519015158152f35b50346104f95760203660031901126104f9577f7619eb3b0b2346250e2839a10da35fc58eea3632c6f045e8abffa1864bce25516020610b56613f2b565b610b5e614691565b610b7060ff601c5460081c16156141c8565b601280546001600160a01b0319166001600160a01b03929092169182179055604051908152a180f35b50346104f957806003193601126104f9576014546040516001600160a01b039091168152602090f35b50346104f95760203660031901126104f957610bdf600435614a8c565b5060043581526021602052604081205460ff16908115611f0357600435815260256020526040812054915b8015611ea4576004358252600e60205260408220545b602061010081905260405190610c369082614012565b83815290600435845260276101005152610c52604085206140be565b805115158091604051610c686101005182614012565b87815291611e94575b5084611a8d57610c808361557c565b42811192908315611a8657600c610c97428361462a565b04935b61271091610d27610d22617d491960048d610d196064610d13610cbe6107ea615ded565b610d00610ce4600c199888610cdd610cd85f198097615e29565b615e44565b0590615e29565b600c610cdd610cfb610cf586615e57565b86615876565b615e6d565b96610d0c6107ea615e0b565b9050615e29565b05615e80565b90500590615876565b615851565b9162015180830292808404620151801490151715611a725790829180611a68575b15611a5857610d6191610d5a9161462a565b914261462a565b81158015611a0a575b5050505b612710811115611a045750612710925b6004358852600c610100515263ffffffff6040892054169060405194610da386613fc0565b600435865286610100518701526040860152606085015260808401524260a084015260405192610dd284613fc0565b87845287610100518501528760408501528760608501528760808501528760a085015260018060a01b0360145416610e0b811515614505565b6040516351e77d4b60e11b81526004356004820152836024820152608081604481855afa908115611994578a8b918c9361199f575b5087526001600160a01b039081166040808901919091529116606087015251635e0cc79d60e01b81526101005181600481855afa8015611994578a9061195b575b608091508061010051880152602460405180948193635be7128f60e11b835260048301525afa9081156119505794886025958b610a559d96610f4b6112ce9c9760019c9760219c8591611921575b508d8060a01b0381511660808901528d8060a01b03906101005101511660a0880152610f03610efe828961563d565b6153cd565b610f45603a60405180935f516020615eb25f395f51905f52610100518301528051809161010051018484015e810188838201520301601f198101835282614012565b9661571a565b8051611918575b50602993601161117e9484600b948f9650805f1461188757825b945b156117e9575090506004358152602261010051526110ec858060408085209461ffff825196610f9c88613fdb565b5480850b885260101c16610100518701526004358152602361010051522061ffff60405191610fca83613fdb565b5480840b835260101c16610100518201526003610fe98651840b61589f565b916002610ff88251860b61589f565b9160046110078a51880b615a3b565b998361102d61102461101b86518c0b615a3b565b93518b0b615b75565b94518a0b615b75565b956040519c898e9a5180916101005101610100518d015e8a019061040560f31b61010051830152805180916101005101602284015e61010051910101630149015960e51b83820152815180926101005101600683015e010161040560f31b83820152815180926101005101600683015e01016229205b60e81b83820152815180926101005101600583015e0101602b60f81b83820152815180926101005101600483015e0101605d60f81b838201520301601e19810184520182614012565b965b60405196879361010051850199683d913730b6b2911d1160b91b8b528051809161010051018488015e8501701116113232b9b1b934b83a34b7b7111d1160791b83820152815180926101005101603a83015e01016a11161134b6b0b3b2911d1160a91b83820152815180926101005101601c83015e0101601160f91b838201520301601e19810184520182614012565b80938051611777575b505050602c91926111ae6111a86111a86111a260043561448f565b94615434565b92615434565b9360405160e0528051809161010051016101005160e051015e60e05101906e2c2261747472696275746573223a5b60881b610100518301527f7b2274726169745f74797065223a2259656172222c2276616c7565223a000000602f830152805180916101005101604c84015e61010051910101611f4b60f21b838201527f7b2274726169745f74797065223a2251756575652052616e6b222c2276616c75602e8201526232911d60e91b604e820152815180926101005101605183015e0101611f4b60f21b838201527f7b2274726169745f74797065223a22506f696e7473222c2276616c7565223a006027820152815180926101005101604683015e0101607d60f81b8282015260e051900301601e19810160e051520160e051614012565b60e05190611387575b603d61131e61136f92610efe6002604051928051809161010051016101005186015e8301615d7d60f01b610100518201528361010051910301601d19810184520182614012565b6040519384917f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000610100518401528051809161010051018585015e820190838201520301601f198101835282614012565b60405191829161010051835261010051830190613f07565b5060043581526022610100515261176f6002602e603081602f6113b0604088205460010b61589f565b6004358852602361010051526113cc604089205460010b61589f565b60805260043588526022610100515260286113ed60408a205460010b615a3b565b916004358a526023610100515261140a60408b205460010b615a3b565b60c0526004358a5260226101005152602c61142b60408c205460010b615b75565b6004358c5260226101005152838c602b61144f61ffff604084205460101c16615434565b60043583526023610100515261148a61ffff60406114728187205460010b615b75565b95600435815260236101005152205460101c16615434565b9460405160a05260e05151806101005160e051016101005160a051015e60a05101907f2c7b2274726169745f74797065223a224c65616420506974636820284d494449610100518301526a149116113b30b63ab2911d60a91b6040830152805180916101005101604b84015e61010051910101607d60f81b838201527f2c7b2274726169745f74797065223a224c656164204475726174696f6e222c2287820152663b30b63ab2911d60c91b604c820152815180926101005101605383015e0101607d60f81b838201527f2c7b2274726169745f74797065223a224261737320506974636820284d49444960298201526a149116113b30b63ab2911d60a91b6049820152815180926101005101605483015e0101607d60f81b838201527f2c7b2274726169745f74797065223a2242617373204475726174696f6e222c22602d820152663b30b63ab2911d60c91b604d820152815180926101005101605483015e0101607d60f81b838201527f2c7b2274726169745f74797065223a224c656164204e6f74652028556e69636f60298201526d3232949116113b30b63ab2911d1160911b6049820152815180926101005101605783015e010161227d60f01b838201527f2c7b2274726169745f74797065223a224c656164204e6f74652028415343494960318201526b149116113b30b63ab2911d1160a11b6051820152815180926101005101605d83015e010161227d60f01b828201527f2c7b2274726169745f74797065223a2242617373204e6f74652028556e69636f838201526d3232949116113b30b63ab2911d1160911b60508201526080515190816101005160805101605e83015e010161227d60f01b828201527f2c7b2274726169745f74797065223a2242617373204e6f74652028415343494960328201526b149116113b30b63ab2911d1160a11b605282015260c0515190816101005160c05101605e83015e010161227d60f01b8282015260a051900301601d19810160a051520160a051614012565b60a0516112d7565b602c945060126117e1928a926040519586925180916101005185015e82019071161130b734b6b0ba34b7b72fbab936111d1160711b61010051830152805180916101005101603284015e61010051910101601160f91b838201520301601e19810184520182614012565b915f80611187565b156117f657505b966110ee565b90506118826008611808600435615434565b6118118c615434565b93603a6040519586937945766572792054776f204d696c6c696f6e20426c6f636b73202360301b610100518601528051809161010051018487015e84016701016902cb2b0b9160c51b83820152815180926101005101604283015e010190838201520301601f198101835282614012565b6117f0565b8a6119136004601761189c6111a28335615434565b93604080519586925f516020615e925f395f51905f52610100518501528051809161010051018486015e8301760103bb4b636103932bb32b0b61037b7102530b71018961604d1b83820152815180926101005101605783015e0101632055544360e01b838201520301601b19810184520182614012565b610f6c565b96506029610f52565b611943915060803d608011611949575b61193b8183614012565b810190614551565b5f610ecf565b503d611931565b6040513d8b823e3d90fd5b50610100513d811161198d575b6119728183614012565b816101005191810103126119895760809051610e81565b5f80fd5b503d611968565b6040513d8c823e3d90fd5b925050506080813d6080116119fc575b816119bc60809383614012565b810103126119f8578051906119d561010051820161420a565b916119ee60606119e76040850161420a565b9301614544565b509190915f610e40565b8980fd5b3d91506119af565b92610d7e565b909192506127108202918083046127101490151715611a4457611a3057045f8080610d6a565b634e487b7160e01b89526012600452602489fd5b634e487b7160e01b8a52601160045260248afd5b5050421015610d6e575086610d6e565b5081421015610d48565b634e487b7160e01b8b52601160045260248bfd5b8793610c9a565b600496939635865260226101005152604086209160405192611aae84613fdb565b548060010b845261ffff6101005185019160101c168152600435885260236101005152604088209060405191611ae383613fdb565b54600181900b835261010051601091821c61ffff1690840190815290546001600160a01b0316908115611e365761ffff875160010b9351169061ffff855160010b91511691604051948560e081011060018060401b0360e088011117611e225796610a559e968b8f8f969e6112ce9f60019f9a60219f9a60259f99849f9361ffff9182889c60e49760e088016040526004358852610100518801998a52604088019b8c52606088019081526080880191825260a0880193845260c088019485526040519b8c9a8b99632587bc9560e01b8b525160048b01525160248a01525160448901525160010b6064880152511660848601525160010b60a4850152511660c48301525afa849181611e06575b50611db45750611c33604051611c08604082614012565b601481527326bab9b4b1903932b73232b932b91032b93937b960611b610100518201526004356151ed565b9081965b8d8060a01b03601154169081611d19575b50505050602993601161117e9484600b948f9650805f14611c6b57825b94610f6e565b8a611d14602b6008611c816111a2600435615434565b93604080519586925f516020615e925f395f51905f52610100518501528051809161010051018486015e83016701016902cb2b0b9160c51b83820152815180926101005101604883015e01017f2e20436f6e74696e756f7573206f7267616e20746f6e65732072696e67207369838201526a3731b2903932bb32b0b61760a91b6028820152030189810184520182614012565b611c65565b90859291518f0b91518f0b600435845260246101005152604084205492611d6d6040519687958694859463d5a6696960e01b8652600486015260248501526044840152608060648401526084830190613f07565b03915afa839181611d90575b50611d87575b808080611c48565b96506029611d7f565b611dad9192503d8086833e611da58183614012565b8101906145c8565b905f611d79565b90611dbe826153cd565b611e00603a60405180935f516020615eb25f395f51905f52610100518301528051809161010051018484015e810188838201520301601f198101835282614012565b96611c37565b611e1b9192503d8087833e611da58183614012565b905f611bf1565b634e487b7160e01b8e52604160045260248efd5b50505097600194602194886025958b6112ce9a96610a559e611e8c604051611e5f604082614012565b6016815275135d5cda58c81c995b99195c995c881b9bdd081cd95d60521b610100518201526004356151ed565b908196611c37565b611e9e9150614f03565b5f610c71565b6049831015611ee057600d546107ea01806107ea11611ecc5783611ec7916145bb565b610c20565b634e487b7160e01b83526011600452602483fd5b826107ea01806107ea1115610c2057634e487b7160e01b83526011600452602483fd5b611f0e600435614637565b91610c0a565b50346104f95760403660031901126104f957600435602435611f48611f4383611f3c81614a8c565b3390614d38565b614452565b818352602160205260ff6040842054166109625760145483906001600160a01b0316611f75811515614505565b8382526027602052611f8a6040832054614086565b158061201a575b813b156109a8578291606483926040519485938492634d91558b60e01b84528a60048501528960248501521560448401525af1801561200f57611ffa575b505033917f7705d1eb8a47e96b299b19e3664e8795960fbc3ba30af792e78506bd034088c88480a480f35b8161200491614012565b6109a857825f611fcf565b6040513d84823e3d90fd5b9150604051635be7128f60e11b8152836004820152608081602481855afa80156120b0576060918791612091575b500151612056578491611f91565b60405162461bcd60e51b815260206004820152601360248201527214d95d995b881ddbdc991cc81b9bdd081cd95d606a1b6044820152606490fd5b6120aa915060803d6080116119495761193b8183614012565b5f612048565b6040513d88823e3d90fd5b50346104f95760603660031901126104f9576120d5613f2b565b6120dd613f41565b906044356001600160a01b03811690819003612188577f66cd6f63bfce81eb84ce68fba06e890adfc9788d2cd317cd34d6385bcc8543fd92606092612120614691565b61213260ff601c5460081c16156141c8565b600f80546001600160a01b039283166001600160a01b031991821681179092556010805494909316938116841790925560118054909216841790915560408051928352602083019390935291810191909152a180f35b8380fd5b50346104f957806003193601126104f9576121a5614691565b61010061ff0019601c541617601c557fb1b55a633f0c097c32f64c5845d57f2face9917e90303fe9aba6e47f5e9f66218180a180f35b50346104f957806003193601126104f957602060ff601c54166040519015158152f35b50346104f95760803660031901126104f957612218613f2b565b612220613f41565b6064359190604435906001600160401b03841161226e573660238501121561226e5761225961226b943690602481600401359101614192565b9261226583838361421e565b33614dc3565b80f35b8480fd5b50346104f957806003193601126104f95760206040516107ea8152f35b5034611989576020366003190112611989576004356122b4611f4382611f3c81614a8c565b6014546001600160a01b03166122cb811515614505565b803b15611989575f8091602460405180948193635e0da3fd60e01b83528760048401525af1801561233a57612325575b5033907f21a8f5cbbad4131d0240eb5c13a30d5f8dbdac2b30e65a1f7b3f91f9c91850c38380a380f35b6123329192505f90614012565b5f905f6122fb565b6040513d5f823e3d90fd5b34611989576020366003190112611989577fa9364d56b05f85a353957cc52cf124496bc454434c180a42db8487c194cd4bd16020600435612384614691565b6001601c5461239960ff8260081c16156141c8565b82601b5560ff191617601c5560ff19601a5416601a555f601955604051908152a1005b34611989576020366003190112611989576020610aee60043561448f565b346119895760203660031901126119895760043560018060a01b036006541633148015612472575b61240b90614452565b805f52602b60205260ff60405f2054161561246357805f52602b60205260405f2060ff19815416905561243d81614cbe565b7f7fc176478ac48da2a5dc9e43507efeeadfb837980de07a34c4362d556fc5adaa5f80a2005b639bacd75b60e01b5f5260045ffd5b505f818152600260205260409020546001600160a01b03163314612402565b34611989575f366003190112611989576015546040516001600160a01b039091168152602090f35b34611989576020366003190112611989576004356124d681614a8c565b50805f52602160205260ff60405f2054166125d757805f52602b60205260ff60405f2054166125c8577f0187d3ba648623e82084dd3f3f86edeaab5d7cbcd2aa24c70c5646226e192286604061252b83614637565b600563ffffffff61253b83614abb565b9261254584614c4c565b1691855f526026602052835f205460285460295491885f52602a602052865f209363ffffffff871663ffffffff19865416178555600185015560028401556003830155600482015501600160ff19825416179055835f52602b602052815f20600160ff19825416179055835f526026602052815f205482519182526020820152a2005b63b59c293760e01b5f5260045ffd5b6305a049a960e41b5f5260045ffd5b34611989575f366003190112611989576020600854604051908152f35b346119895760403660031901126119895761261c613f2b565b60243590811515809203611989576001600160a01b031690811561268b57335f52600560205260405f20825f5260205260405f2060ff1981541660ff83161790556040519081527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a3005b50630b61174360e31b5f5260045260245ffd5b6020366003190112611989576126b26146ec565b610a556126c16004353361470c565b600160075560405191829182613f87565b34611989575f36600319011261198957600f546040516001600160a01b039091168152602090f35b3461198957602036600319011261198957612713614691565b600435602955005b34611989575f366003190112611989576040515f60015461273b81614086565b80845290600181169081156127d55750600114612777575b610a558361276381850382614012565b604051918291602083526020830190613f07565b60015f9081527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6939250905b8082106127bb57509091508101602001612763612753565b9192600181602092548385880101520191019092916127a3565b60ff191660208086019190915291151560051b840190910191506127639050612753565b34611989575f366003190112611989576012546040516001600160a01b039091168152602090f35b34611989575f366003190112611989576006546040516001600160a01b039091168152602090f35b34611989575f36600319011261198957602060ff601c54166040519015158152f35b34611989576020366003190112611989576004355f526023602052610a5560405f2054604051918161ffff849360101c169060010b8361415e565b34611989575f36600319011261198957602061ffff60185416604051908152f35b34611989575f366003190112611989576011546040516001600160a01b039091168152602090f35b34611989576020366003190112611989576004355f526025602052602060405f2054604051908152f35b34611989575f36600319011261198957612931614691565b600680546001600160a01b031981169091555f906001600160a01b03165f516020615ef25f395f51905f528280a3005b34611989576020366003190112611989576001600160a01b03612982613f2b565b16801561299f575f526003602052602060405f2054604051908152f35b6322718ad960e21b5f525f60045260245ffd5b34611989576020366003190112611989576004356129cf81614a8c565b50805f52602160205260ff60405f2054166125d757806129f1612a1e92614637565b6129fa81614abb565b612a0381614c4c565b825f52602660205260405f2054906028549260295494614aed565b005b34611989575f366003190112611989576020600a54604051908152f35b34611989576020366003190112611989576020612a5b6004356146b8565b6040516001600160a01b039091168152f35b34611989576020366003190112611989576004355f526021602052602060ff60405f2054166040519015158152f35b34611989576020366003190112611989576004355f52600c602052602063ffffffff60405f205416604051908152f35b34611989575f36600319011261198957602060ff601e54166040519015158152f35b34611989575f36600319011261198957600b546040516001600160a01b039091168152602090f35b34611989575f36600319011261198957602063ffffffff60185460301c16604051908152f35b3461198957612a1e612b4d3661404c565b9060405192612b5d602085614012565b5f845261226583838361421e565b34611989576020366003190112611989576004355f52601d602052602060405f2054604051908152f35b3461198957602036600319011261198957600435612bb281614a8c565b50805f52602b60205260ff60405f2054161561246357805f52602160205260ff60405f2054166125d757805f52602a60205260405f2060ff60058201541615612e4357815f52602660205260405f20546002820190815403612e34576080612c91836001612ccf950193612c268554614c4c565b63ffffffff82541694875f5260256020528560405f205554875f52600e60205260405f2055612c56600d54614391565b600d55865f52602160205260405f20600160ff19825416179055865f5260246020524260405f20555490600460038201549101549187614c6c565b600f5460405163232f358b60e11b815263ffffffff80861660048301529092166024830152909384916001600160a01b031690829081906044820190565b03915afa801561233a575f516020615f325f395f51905f52925f905f92612e00575b50612dfb90855f52602260205260405f20815190805491602084019261ffff63ffff0000855160101b1692169063ffffffff191617179055865f52602360205260405f2090612d9c85519183549360208801519463ffff00008660101b169061ffff86169063ffffffff191617179055612d8e6028549361ffff875160010b9351169460405195869461ffff6020870199169360010b9289614419565b03601f198101835282614012565b519020602855855f52602b60205260405f2060ff198154169055612dbf86614cbe565b612dc886614ceb565b5191516040805163ffffffff9095168552600193840b6020860152920b9183019190915242606083015281906080820190565b0390a2005b612dfb9250612e27915060803d608011612e2d575b612e1f8183614012565b8101906143f3565b91612cf1565b503d612e15565b6388e134c760e01b5f5260045ffd5b633ce8ae7f60e21b5f5260045ffd5b34611989575f36600319011261198957612e6a614691565b612e726146ec565b600b546001600160a01b03168015612f125747908115612ee0575f80809381935af1612e9c614362565b5015612ea9576001600755005b60405162461bcd60e51b815260206004820152600f60248201526e15da5d1a191c985dc819985a5b1959608a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152600a6024820152694e6f2062616c616e636560b01b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d14185e5bdd5d081b9bdd081cd95d60921b6044820152606490fd5b34611989576040366003190112611989576004356001600160401b03811161198957612f78903690600401613f57565b906024356001600160401b03811161198957612f98903690600401613f57565b612fa3929192614691565b612fb560ff601c5460081c16156141c8565b60ff601e54166130aa57808403613073578315613040575f5b848110613013578480601f5401601f557ff568ff94e3b74d950644b19253025001012802b6c60f7157a2e573c19a2f8a946020600181540192838255604051908152a2005b80613021600192848761433e565b3561302d82888761433e565b355f52601d60205260405f205501612fce565b60405162461bcd60e51b815260206004820152600b60248201526a456d707479206368756e6b60a81b6044820152606490fd5b60405162461bcd60e51b815260206004820152600f60248201526e098cadccee8d040dad2e6dac2e8c6d608b1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601560248201527414195c9b5d5d185d1a5bdb88199a5b985b1a5e9959605a1b6044820152606490fd5b34611989575f36600319011261198957602063ffffffff60185460101c16604051908152f35b34611989576020366003190112611989576004355f526027602052610a5561276360405f206140be565b34611989576020366003190112611989576004356001600160a01b0381169081900361198957613165614691565b80156131ab57600b80546001600160a01b031916821790556040519081527ffcbb1571f6f637b3645e200ff18fbcb7fc2f8db33547e2f582146a51246e104390602090a1005b60405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a59081c185e5bdd5d60921b6044820152606490fd5b34611989576020366003190112611989576004355f52602a6020526020600260405f200154604051908152f35b34611989576020366003190112611989577fce5202ecc8b8799ee1618adf9acec1ce2a28f52077ffc9bcdcf6c794f9e0c37a602061324a613f2b565b613252614691565b61326460ff601c5460081c16156141c8565b601380546001600160a01b0319166001600160a01b03929092169182179055604051908152a1005b34611989575f366003190112611989576020602854604051908152f35b34611989575f366003190112611989576020600d54604051908152f35b34611989576020366003190112611989576004356132e2614691565b6132eb81614a8c565b50805f52602160205260ff60405f2054166125d7578061330d612a1e92614637565b612a0381614abb565b34611989576020366003190112611989576004355f52602a602052602063ffffffff60405f205416604051908152f35b3461198957612a1e6133573661404c565b9161421e565b34611989576040366003190112611989576004356024356001600160401b03811161198957366023820112156119895780600401359061339c82614035565b906133aa6040519283614012565b828252602082016024819460051b8301019136831161198957602401905b8282106135715750506015546001600160a01b03163303905061353557601a549160ff8316156135035760195484036134cb5781511561349157604051915160208301929183915f5b81811061347b57877fe6a62e3b78d7c6d033cc5a5342e02a252e89d611a1a06139ec4fff6cf9b7a95d6020898989613452818b03601f198101835282614012565b5190209081601b55600160ff19601c541617601c5560ff1916601a5583601955604051908152a2005b8251845260209384019390920191600101613411565b60405162461bcd60e51b8152602060048201526012602482015271456d7074792072616e646f6d20776f72647360701b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f0a4cae2eacae6e840dad2e6dac2e8c6d60831b6044820152606490fd5b60405162461bcd60e51b815260206004820152600a602482015269139bc81c995c5d595cdd60b21b6044820152606490fd5b60405162461bcd60e51b815260206004820152601460248201527327b7363c902b29231031b7b7b93234b730ba37b960611b6044820152606490fd5b81358152602091820191016133c8565b6020366003190112611989576004356001600160401b038111611989576126c16135b2610a55923690600401613f57565b90506135bc6146ec565b3361470c565b34611989575f366003190112611989576020601954604051908152f35b34611989576020366003190112611989576135f8613f2b565b613600614691565b61361260ff601c5460081c16156141c8565b6001600160a01b0316801561370d57601480546001600160a01b0319168217905560405163f77c479160e01b8152602081600481855afa90811561233a575f916136d3575b50306001600160a01b039091160361368f577f8bcb883236eb12e417bbcf3954fbfb75e412cafc6b9e2d3a28c5855e9a821d675f80a2005b60405162461bcd60e51b815260206004820152601c60248201527b0a4caced2e6e8e4f240c6dedce8e4ded8d8cae440dad2e6dac2e8c6d60231b6044820152606490fd5b90506020813d602011613705575b816136ee60209383614012565b81010312611989576136ff9061420a565b82613657565b3d91506136e1565b60405162461bcd60e51b815260206004820152601060248201526f496e76616c696420726567697374727960801b6044820152606490fd5b346119895760c03660031901126119895761375e613f2b565b602435604435916064359161ffff8316809303611989576084359163ffffffff83168084036119895760a4359463ffffffff861692838703611989576137a2614691565b6137b460ff601c5460081c16156141c8565b6001600160a01b031696871561397e57841561394657801561390a5781156138d357821561389d57831561386a577fdb916dcd2cdb2972bd841f7aca5eb0597e3ebafd6ff8338eaebe31a6da321e8f9660a096896001808a1b03196015541617601555866016558260175565ffffffff0000846018549363ffffffff60301b9060301b169360018060501b031916179160101b1617176018556040519485526020850152604084015260608301526080820152a2005b60405162461bcd60e51b815260206004820152600b60248201526a04e756d20776f7264733d360ac1b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d043616c6c6261636b206761733d360941b6044820152606490fd5b60405162461bcd60e51b815260206004820152600f60248201526e0436f6e6669726d6174696f6e733d3608c1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601460248201527324b73b30b634b21039bab139b1b934b83a34b7b760611b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f092dcecc2d8d2c840d6caf240d0c2e6d60831b6044820152606490fd5b60405162461bcd60e51b815260206004820152601360248201527224b73b30b634b21031b7b7b93234b730ba37b960691b6044820152606490fd5b34611989575f366003190112611989576010546040516001600160a01b039091168152602090f35b34611989576040366003190112611989576139fa613f2b565b602435613a06816146b8565b33151580613ab8575b80613a8b575b613a785781906001600160a01b0384811691167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9255f80a45f90815260046020526040902080546001600160a01b0319166001600160a01b03909216919091179055005b63a9fbf51f60e01b5f523360045260245ffd5b506001600160a01b0381165f90815260056020908152604080832033845290915290205460ff1615613a15565b506001600160a01b038116331415613a0f565b34611989575f366003190112611989576013546040516001600160a01b039091168152602090f35b3461198957602036600319011261198957600435613b10816146b8565b505f526004602052602060018060a01b0360405f205416604051908152f35b34611989576020366003190112611989576004355f526026602052602060405f2054604051908152f35b34611989575f366003190112611989576040515f5f54613b7881614086565b80845290600181169081156127d55750600114613b9f57610a558361276381850382614012565b5f8080527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563939250905b808210613be157509091508101602001612763612753565b919260018160209254838588010152019101909291613bc9565b34611989575f366003190112611989576020601b54604051908152f35b34611989575f366003190112611989576020601654604051908152f35b34611989575f366003190112611989576020601f54604051908152f35b346119895760203660031901126119895760043563ffffffff60e01b8116809103611989576020906380ac58cd60e01b8114908115613caf575b8115613c9e575b506040519015158152f35b6301ffc9a760e01b14905082613c93565b635b5e139f60e01b81149150613c8c565b34611989575f36600319011261198957613cd8614691565b613cea60ff601c5460081c16156141c8565b6015546001600160a01b03168015613ecd5760ff601a5416613e945760165460175460185460405192936020840193919290916001600160401b03851181861017613e805761ffff95613dfa5f92602097604052600181526040519063125fa26760e31b89830152511515602482015260248152613d69604482614012565b60405192613d7684613fc0565b835287830194855263ffffffff60408401978a811689528160608601818360101c16815281608088019360301c16835260a087019485526040519c8d9b8c9a8b99634d8e1c2f60e11b8b528f60048c01525160248b01525160448a01525116606488015251166084860152511660a48401525160c060c484015260e4830190613f07565b03925af190811561233a575f91613e4e575b5080601955600160ff19601a541617601a5560ff19601c5416601c557fa4e9307236598ef4dc1664a1ca86010aef9cc4c4e4fb9d54efda8c5d437932e05f80a2005b90506020813d602011613e78575b81613e6960209383614012565b81010312611989575181613e0c565b3d9150613e5c565b634e487b7160e01b5f52604160045260245ffd5b60405162461bcd60e51b815260206004820152601160248201527014995c5d595cdd081a5b88199b1a59da1d607a1b6044820152606490fd5b60405162461bcd60e51b8152602060048201526012602482015271159491881b9bdd0818dbdb999a59dd5c995960721b6044820152606490fd5b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b600435906001600160a01b038216820361198957565b602435906001600160a01b038216820361198957565b9181601f84011215611989578235916001600160401b038311611989576020808501948460051b01011161198957565b60206040818301928281528451809452019201905f5b818110613faa5750505090565b8251845260209384019390920191600101613f9d565b60c081019081106001600160401b03821117613e8057604052565b604081019081106001600160401b03821117613e8057604052565b61018081019081106001600160401b03821117613e8057604052565b601f909101601f19168101906001600160401b03821190821017613e8057604052565b6001600160401b038111613e805760051b60200190565b6060906003190112611989576004356001600160a01b038116810361198957906024356001600160a01b0381168103611989579060443590565b90600182811c921680156140b4575b60208310146140a057565b634e487b7160e01b5f52602260045260245ffd5b91607f1691614095565b9060405191825f8254926140d184614086565b808452936001811690811561413c57506001146140f8575b506140f692500383614012565b565b90505f9291925260205f20905f915b8183106141205750509060206140f6928201015f6140e9565b6020919350806001915483858901015201910190918492614107565b9050602092506140f694915060ff191682840152151560051b8201015f6140e9565b90929161ffff602091604084019560010b845216910152565b6001600160401b038111613e8057601f01601f191660200190565b92919261419e82614177565b916141ac6040519384614012565b829481845281830111611989578281602093845f960137010152565b156141cf57565b60405162461bcd60e51b815260206004820152601360248201527214995b99195c995c9cc8199a5b985b1a5e9959606a1b6044820152606490fd5b51906001600160a01b038216820361198957565b6001600160a01b039091169190821561432b575f828152600260205260409020546001600160a01b0316928290336142e5575b846142c4575b805f52600360205260405f2060018154019055815f52600260205260405f208160018060a01b0319825416179055845f516020615f125f395f51905f525f80a46001600160a01b03168083036142ac57505050565b6364283d7b60e01b5f5260045260245260445260645ffd5b6142cd82615be0565b845f52600360205260405f205f198154019055614257565b906142f1903386614d38565b156142fd578290614251565b828461431557637e27328960e01b5f5260045260245ffd5b63177e802f60e01b5f523360045260245260445ffd5b633250574960e11b5f525f60045260245ffd5b919081101561434e5760051b0190565b634e487b7160e01b5f52603260045260245ffd5b3d1561438c573d9061437382614177565b916143816040519384614012565b82523d5f602084013e565b606090565b5f19811461439f5760010190565b634e487b7160e01b5f52601160045260245ffd5b9190826040910312611989576040516143cb81613fdb565b80928051908160010b820361198957602091835201519061ffff821682036119895760200152565b91906080838203126119895780604061440f61441693866143b3565b94016143b3565b90565b90815260f091821b602082015291811b6001600160f01b0319908116602284015292811b60248301529290921b16602682015260280190565b1561445957565b60405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b6044820152606490fd5b6012546001600160a01b03169081156144ff57602090602460405180948193631048226b60e31b835260048301525afa90811561233a575f916144d0575090565b90506020813d6020116144f7575b816144eb60209383614012565b81010312611989575190565b3d91506144de565b50505f90565b1561450c57565b60405162461bcd60e51b815260206004820152601060248201526f149959da5cdd1c9e481b9bdd081cd95d60821b6044820152606490fd5b5190811515820361198957565b908160809103126119895760405190608082016001600160401b03811183821017613e80576145b3916060916040526145898161420a565b84526145976020820161420a565b60208501526145a860408201614544565b604085015201614544565b606082015290565b9190820180921161439f57565b602081830312611989578051906001600160401b038211611989570181601f82011215611989578051906145fb82614177565b926146096040519485614012565b8284526020838301011161198957815f9260208093018386015e8301015290565b9190820391821161439f57565b61464081614a8c565b506012546001600160a01b03169081156146825760209060246040518094819363b176aa4560e01b835260048301525afa90811561233a575f916144d0575090565b5f1981019150811161439f5790565b6006546001600160a01b031633036146a557565b63118cdaa760e01b5f523360045260245ffd5b5f818152600260205260409020546001600160a01b03169081156146da575090565b637e27328960e01b5f5260045260245ffd5b6002600754146146fd576002600755565b633ee5aeb560e01b5f5260045ffd5b919060ff6009541615614a57578015614a2457600a548181029080820483149015171561439f5734036149eb579161474383614035565b6147506040519182614012565b838152601f1961475f85614035565b0136602083013780935f9260203360601b945b83811061478157505050505050565b61478c600854614391565b908160085560405161479e8482614012565b5f81526001600160a01b03851690811561432b575f8481526002865260409020546001600160a01b031680151590816149cb575b5f8481526003885260408082208054600101905587825260028952812080546001600160a01b031916861790558690859083905f516020615f125f395f51905f529080a4506149b857853b6148ba575b505063ffffffff6040518481019042825244604082015260018060601b03198760601b1660608201528960748201528460888201526088815261486660a882614012565b51902016825f52600c845263ffffffff60405f20911663ffffffff198254161790555f19820182811161439f57825f52601d845260405f2055855181101561434e57600191838260051b8801015201614772565b84614902835f9360409e9c9a989d9b999796959e51948580948193630a85bd0160e11b83523360048401528360248401528a6044840152608060648401526084830190613f07565b03925af15f9181614978575b5061493c578a8a61491d614362565b80519190826149395783633250574960e11b5f5260045260245ffd5b01fd5b630a85bd0160e19b92939496989a9597999b1b9063ffffffff60e01b160361496657505f80614822565b633250574960e11b5f5260045260245ffd5b9091508a81813d83116149b1575b6149908183614012565b8101031261198957516001600160e01b03198116810361198957905f61490e565b503d614986565b6339e3563760e11b5f525f60045260245ffd5b6149d486615be0565b805f526003875260405f205f1981540190556147d2565b60405162461bcd60e51b8152602060048201526011602482015270125b98dbdc9c9958dd081c185e5b595b9d607a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152600b60248201526a08adae0e8f240c4c2e8c6d60ab1b6044820152606490fd5b60405162461bcd60e51b815260206004820152600d60248201526c135a5b9d08191a5cd8589b1959609a1b6044820152606490fd5b5f908152600260205260409020546001600160a01b0316908115614aac57565b63677510db60e11b5f5260045ffd5b60498110614ad3576107ea01806107ea1161439f5790565b600d546107ea0190816107ea1161439f57614416916145bb565b94614b5594612c919294608094885f52602160205260405f20600160ff19825416179055885f5260246020524260405f205563ffffffff871696895f52602560205260405f2055885f52600e60205260405f2055614b4c600d54614391565b600d5587614c6c565b03915afa801561233a575f516020615f325f395f51905f52925f905f92614c28575b50614c2390855f52602260205260405f20815190805491602084019261ffff63ffff0000855160101b1692169063ffffffff191617179055865f52602360205260405f2090614c1485519183549360208801519463ffff00008660101b169061ffff86169063ffffffff191617179055612d8e6028549361ffff875160010b9351169460405195869461ffff6020870199169360010b9289614419565b519020602855612dc886614ceb565b0390a2565b614c239250614c46915060803d608011612e2d57612e1f8183614012565b91614b77565b614c559061557c565b4210614c5d57565b635905cd4d60e01b5f5260045ffd5b63ffffffff93815f52600c60205260405f2054936040519360208501958760e01b9060e01b168652602485015260448401526064830152608482015260848152614cb760a482614012565b5190201690565b5f52602a6020525f6005604082208281558260018201558260028201558260038201558260048201550155565b6013546001600160a01b03169081614d01575050565b813b15611989575f9160248392604051948593849263181d4bb960e11b845260048401525af1614d2e5750565b5f6140f691614012565b6001600160a01b03909116801515929183614d54575b50505090565b6001600160a01b031680821493509091908315614da0575b508215614d7e575b50505f8080614d4e565b5f908152600460205260408120546001600160a01b0316909114915080614d74565b9092505f52600560205260405f20815f5260205260ff60405f205416915f614d6c565b823b614dd1575b5050505050565b604051630a85bd0160e11b81526001600160a01b039182166004820152918116602483015260448201939093526080606482015291169160209082908190614e1d906084830190613f07565b03815f865af15f9181614e7b575b50614e595750614e39614362565b80519081614e545782633250574960e11b5f5260045260245ffd5b602001fd5b6001600160e01b03191663757a42ff60e11b0161496657505f80808080614dca565b9091506020813d602011614eb8575b81614e9760209383614012565b8101031261198957516001600160e01b03198116810361198957905f614e2b565b3d9150614e8a565b90614eca82614177565b614ed76040519182614012565b8281528092614ee8601f1991614177565b0190602036910137565b90815181101561434e570160200190565b9081519182156151d6576006830283810460060361439f57614f2490614ec0565b925f915f5b828110614f7857505050614f3c81614ec0565b905f5b818110614f4d575090925050565b6001906001600160f81b0319614f638288614ef2565b51165f1a614f718286614ef2565b5301614f3f565b614f828183614ef2565b516001600160f81b0319811694908790601160f91b871480156151c9575b15614fdf5750509081605c614fc0614fb9600195614391565b928a614ef2565b53614fd7614fcd82614391565b965f1a9189614ef2565b535b01614f29565b91959091600160fb1b820361501e57505050600190605c61500961500287614391565b9689614ef2565b53606261501861500287614391565b53614fd9565b600360fa1b820361504c57505050600190605c61503d61500287614391565b53606661501861500287614391565b600560f91b820361507a57505050600190605c61506b61500287614391565b53606e61501861500287614391565b600d60f81b82036150a857505050600190605c61509961500287614391565b53607261501861500287614391565b600960f81b82036150d657505050600190605c6150c761500287614391565b53607461501861500287614391565b9091958160f81c926020841080156151bc575b80156151af575b80156151a2575b1561518d5750600193926151626151809360306151598b8261514988605c61512a615123600f9c614391565b9286614ef2565b53607561513961512383614391565b5361514381614391565b93614ef2565b5361515381614391565b9c614ef2565b5360fc1c615bfd565b9761517961516f82614391565b995f1a918c614ef2565b5316615bfd565b94615018614fcd82614391565b965090506001929150615018614fcd82614391565b50601360f91b81146150f7565b50601f60f91b81146150f0565b50600f60fa1b81146150e9565b50601760fa1b8714614fa0565b5090506040516151e7602082614012565b5f815290565b603a6153956020610efe600d604d839760d98561520c6144169a615434565b926040519788947f3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f3230828701527f30302f737667222076696577426f783d223020302036303020363030223e000060408701527f3c726563742077696474683d223130302522206865696768743d223130302522605e8701526d103334b6361e911198181811179f60911b607e8701527f3c7465787420783d223330302220793d223330302220746578742d616e63686f608c8701525f516020615ed25f395f51905f5260ac870152651e911918111f60d11b60cc87015266546f6b656e202360c81b60d28701528051918291018587015e840190661e17ba32bc3a1f60c91b848301527f3c7465787420783d223330302220793d223333302220746578742d616e63686f60e08301525f516020615ed25f395f51905f52610100830152651e91189a111f60d11b61012083015280519283910161012683015e0101661e17ba32bc3a1f60c91b83820152651e17b9bb339f60d11b60548201520301601219810184520182614012565b6040519384915f516020615eb25f395f51905f52828401528051918291018484015e81015f838201520301601f198101835282614012565b604051614416916153df606083614012565b604082527f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208301527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f6040830152615c55565b5f908072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b811015615559575b600a906904ee2d6d415b85acef8160201b81101561553d575b662386f26fc10000811015615529575b6305f5e100811015615518575b612710811015615509575b60648110156154fb575b10156154f0575b600a60216154b860018501614ec0565b938401015b5f1901916f181899199a1a9b1b9c1cb0b131b232b360811b8282061a83530480156154eb57600a90916154bd565b505090565b6001909101906154a8565b6064600291049301926154a1565b61271060049104930192615497565b6305f5e1006008910493019261548c565b662386f26fc100006010910493019261547f565b602093909301926904ee2d6d415b85acef8160201b900461546f565b506040915072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8104615456565b6107b281106155ff57610d226155e59160046155de6064610d13617d49196155a386615ded565b90610d0c6155d86155c1600c199389610cdd610cd85f198099615e29565b600c610cdd610cfb6155d288615e57565b88615876565b97615e0b565b0590615876565b6201518081029080820462015180149015171561439f5790565b60405162461bcd60e51b81526020600482015260166024820152750b2cac2e440c4caccdee4ca40aadcd2f040cae0dec6d60531b6044820152606490fd5b906156548160018060a01b03604085015116615d36565b90615714575081516020830151036156a75760405162461bcd60e51b815260206004820152601960248201527828393296b932bb32b0b6103932b73232b932b91032b93937b960391b6044820152606490fd5b6080909101516156c091906001600160a01b0316615d36565b906144165760405162461bcd60e51b815260206004820152602160248201527f44656661756c74207072652d72657665616c2072656e6465726572206572726f6044820152603960f91b6064820152608490fd5b91505090565b906157318160018060a01b03606085015116615d36565b9061571457508151602083015103615754575b50506040516151e7602082614012565b60a09091015161576d91906001600160a01b0316615d36565b906144165780615744565b60405190615787604083614012565b60018252604360f81b6020830152565b604051906157a6604083614012565b60018252601160fa1b6020830152565b604051906157c5604083614012565b60018252604560f81b6020830152565b604051906157e4604083614012565b60018252602360f91b6020830152565b60405190615803604083614012565b60018252604760f81b6020830152565b60405190615822604083614012565b60018252604160f81b6020830152565b60405190615841604083614012565b60018252602160f91b6020830152565b9062253d8b19820191821360011661439f57565b905f19820191821360011661439f57565b81810392915f13801582851316918412161761439f57565b90600c81101561434e5760051b0190565b60010b5f198114615a185761441660209182806040516158be81613ff6565b6158c6615778565b81526159e56159de60409283516158dd8582614012565b600481526344e299ad60e01b86820152818601526158f9615797565b8482015283516159098582614012565b600481526345e299ad60e01b8682015260608201526159266157b6565b60808201526159336157d5565b60a082015283516159448582614012565b600481526347e299ad60e01b8682015260c08201526159616157f4565b60e082015283516159728582614012565b600481526341e299ad60e01b86820152610100820152615990615813565b61012082015283516159a28582614012565b600481526342e299ad60e01b868201526101408201526159c0615832565b610160820152600c6159d3818904615865565b60010b97069061588e565b5194615b75565b90519584879551918291018487015e8401908282015f8152815193849201905e01015f815203601f198101835282614012565b50604051615a27604082614012565b6004815263f09d84bd60e01b602082015290565b60010b5f198114615b52576144166020918280604051615a5a81613ff6565b615a62615778565b81526159e56159de6040928351615a798582614012565b6002815261223160f11b8682015285820152615a93615797565b848201528351615aa38582614012565b600281526122b160f11b868201526060820152615abe6157b6565b6080820152615acb6157d5565b60a08201528351615adc8582614012565b600281526123b160f11b8682015260c0820152615af76157f4565b60e08201528351615b088582614012565b600281526120b160f11b86820152610100820152615b24615813565b6101208201528351615b368582614012565b6002815261213160f11b868201526101408201526159c0615832565b50604051615b61604082614012565b6004815263149154d560e21b602082015290565b600181900b5f8112615b8f575061ffff6144169116615434565b9050617fff19811461439f576144166021615bb161ffff6020945f0316615434565b604051938491602d60f81b828401528051918291018484015e81015f838201520301601f198101835282614012565b5f90815260046020526040902080546001600160a01b0319169055565b60ff16600a811015615c255760300160ff811161439f575b60f81b6001600160f81b03191690565b6009190160ff811161439f5760ff606191160160ff811115615c1557634e487b7160e01b5f52601160045260245ffd5b9190918051156151d65780516002810180911161439f5760039004600281901b906001600160fe1b0381160361439f57615c8e90614ec0565b90602082019080815182019560208701908151925f83525b888110615ce85750506003939495965052510680600114615cd657600214615ccc575090565b603d905f19015390565b50603d90815f19820153600119015390565b600360049199969901986001603f8b5182828260121c16870101518453828282600c1c16870101518385015382828260061c1687010151600285015316840101516003820153019497615ca6565b6001600160a01b0316908115615ddb5760a060c45f92604051948593849263018e174b60e11b84528051600485015260208101516024850152604081015160448501526060810151606485015263ffffffff6080820151166084850152015160a48301525afa5f9181615dbf575b50615dba57505f906040516151e7602082614012565b600191565b615dd49192503d805f833e611da58183614012565b905f615da4565b50505f906040516151e7602082614012565b906112c08201915f6112c08412911290801582169115161761439f57565b906113248201915f6113248412911290801582169115161761439f57565b9190915f838201938412911290801582169115161761439f57565b90816105b502916105b583050361439f57565b90600c820291808305600c149015171561439f57565b908161016f029161016f83050361439f57565b908160030291600383050361439f5756fe45766572792054776f204d696c6c696f6e20426c6f636b7320746f6b656e2023646174613a696d6167652f7376672b786d6c3b6261736536342c000000000000723d226d6964646c65222066696c6c3d22236666662220666f6e742d73697a658be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef29dee32be1e7550cd032521981e098ddf419ea5c2454868f36012088b755171ba26469706673582212201b8d622cdb589bee9dedee8e72b52b68303d045fdde1ee0a8af01b7059d272af64736f6c634300081e0033

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.