// File: contracts/ElixirBottles.sol



// SPDX-License-Identifier: Unlicense
// Creator: 0xVeryBased

// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛//============\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛//============\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\============//⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\============//⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\  ( ( (   //⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\  ( ( (   //⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|||  ) ) ) |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|||  ) ) ) |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ( ( (  |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ( ( (  |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|||  ) ) ) |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|||  ) ) ) |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ( ( (  |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ( ( (  |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|||  ) ) ) |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|||  ) ) ) |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ≈≈≈≈≈≈ |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ≈≈≈≈≈≈ |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ≈≈≈≈≈≈ |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ≈≈≈≈≈≈ |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛/// ≈≈≈≈≈≈≈≈ \\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||========== ≈≈≈≈≈≈≈≈ ==========||⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛/// ≈≈≈≈≈≈≈≈≈≈ \\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|| ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ||⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛/// ≈≈≈≈≈≈≈≈≈≈≈≈ \\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|| ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ||⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛/// ≈≈≈≈≈≈≈≈≈≈≈≈≈≈ \\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|| ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ||⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛/// ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ \\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|| ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ||⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛/// ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ \\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|| ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ||⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛/// ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ \\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|| ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ||⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛/// ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ \\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|| ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ||⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛/// ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ \\\⊛⊛⊛⊛⊛⊛⊛⊛⊛|| ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ||⊛⊛⊛⊛
// ⊛⊛⊛⊛/// ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ \\\⊛⊛⊛⊛⊛⊛⊛⊛|| ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ||⊛⊛⊛⊛
// ⊛⊛⊛⊛///============================\\\⊛⊛⊛⊛⊛⊛⊛⊛||==============================||⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛//============\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛//============\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\============//⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\============//⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\  ( ( (   //⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\  ( ( (   //⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|||  ) ) ) |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|||  ) ) ) |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ( ( (  |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ( ( (  |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|||  ) ) ) |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|||  ) ) ) |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ( ( (  |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ( ( (  |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|||  ) ) ) |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|||  ) ) ) |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ≈≈≈≈≈≈ |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ≈≈≈≈≈≈ |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ≈≈≈≈≈≈ |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||| ≈≈≈≈≈≈ |||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛==== ≈≈≈≈≈≈≈≈ ====⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛||========== ≈≈≈≈≈≈≈≈ ==========||⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛/// ≈≈≈≈≈≈≈≈≈≈≈≈≈≈ \\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|| ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ||⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛/// ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ \\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|| ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ||⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛/// ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ \\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛|| ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ||⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛/// ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ \\\⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\\ ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ///⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛|| ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\\ ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ///⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛|| ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ||⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\\ ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ///⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛\\\ ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ///⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\\ ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ///⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛\\\ ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ///⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\\ ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ///⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛\\\≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ///⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\\ ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ///⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\\================///⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛\\\================///⊛⊛⊛⊛⊛⊛⊛⊛⊛
// ⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛⊛

pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "./ERC721.sol";
import "./ERC721TopLevel.sol";

contract ElixirBottles is ERC721TopLevel {
    using Strings for uint256;

    // Liyat yew gnilaaw gnilaww ay oo
    
    bool public izItDer = true;

    // decaf gib

    enum HowHard2See {
        BlindAF,
        Hard2See,
        ItGone
    }

    // HTCPCP

    HowHard2See public canUSeesIt = HowHard2See.BlindAF;

    mapping(address => bool) public nightVision;

    //ᚢᚢᚢᛉᚺᚠᛚᚺᚨᚾᛁᚺᚠᚺᚢᚲᛉᛊᚺᚠᛈᛊᛊᛞᚺᚠᚢᛏᛚᛃᚺᚠᚢᚨᚺᚠᛚᛚᚨᛟᚺᚠᚢᚢᚢᛉᚺᚠᚢᚢᛚᛉᚠᚺᚠᚢᛒ
    //ᛊᛉᚺᚠᛈᛊᛊᛞᚺᚠᛚᛁᚺᚠᛚᚨᛉᚺᚠᛚᛚᛗᛁᚺᚠᛚᚺᚱᛁᛁᚺᚠᛚᚨᛟᚺᚠᚢᚲᛚᛃᚺᚠᛈᚢᚲᛗᚺᚠᛚᚨᛟᚺᚠᛚᛚᚨ
    //ᛁᚺᚠᚢᛊᛊᚢᛞᛗᚺᚠᛚᚨᛟᚺᚠᚺᚲᛚᛊᛊᛚᛁᚨᛁᚺᚠᚢᚨᚺᚠᛒᚢᛊᚢᛃᚱᚠᚺᚠᛚᚨᛚᛁᚢᛈᚨᚠᚠᚺᚠᛈᚢᚾᛁᛚᚲ
    //ᛈᛚᚢᚨᛉᚠᚺᚠᛈᛊᛊᛞᚺᚠᛚᛁᚺᚠᚢᛒᚢᚲᛗᚺᚠᚺᛁᛗᚺᚠᚺᚢᚲᚠᚺᚠᛈᚲᛚᛞᚺᚠᛚᚨᛟᚺᚠᚢᛞᛚᛁᛉᚹᚺᚠᛚᚠ
    //ᚨᛟᚺᚠᛚᛉᚨᚢᛞᛁᚺᚠᛈᛊᛊᛞᚺᚠᛚᛁᚺᚠᛈᚢᛉᛈᚲᛚᚠᚺᚠᛚᚾᚾᛉᚠᚺᚠᛈᛊᛊᛞᚺᚠᚺᚨᛃᛟᛟᚺᚠᚢᚢᛚᚠᚺᚠ
    //ᚺᚠᚲᚺᚠᛚᛁᛈᛚᛉᛏᚠᛉᚨᚺᚠᛚᚲᛚᚺᛊᛚᚲᛁᚺᚠᚢᛞᛟᚺᚠᚺᚢᚠᚦᚠᛈᛊᛊᛞᚺᚠᚢᛒᚠᚺᚠᛒᛉᚨᛚᛁᚦ
    //ᚠᚢᛞᛟᚺᚠᚺᚢᚠᚦᚠᛈᛊᛊᛞᚺᚠᚢᛒᚠᚺᚠᛈᛚᛊᚲᚠᚺᚠᛒᛈᛊᚲᛁᚺᚠᚢᛒᛁᚠᚺᚠᚺᛃᚨᛈᚢᚢᛉᛗᚺᚠᛒᛈᛊᚲᛁᚺᚠᚢᛒ
    //ᛁᚠᚺᚠᛚᚺᛏᛉᚨᚺᚠᛚᛗᛚᚢᚲᚲᚺᚠᚢᛒᛁᛉᛚᛊᚲᛚᛉᚠᚺᚠᚺᚾᚺᛈᚢᛉᚨᚠᚺᚠᛈᚢᚾᛉᚨᛟᚺᚠᛒᚢᛉᛚᛚᚢᚠᚺ
    //ᚠᛈᚢᚲᛗᚺᚠᚢᛒᛁᚠᚺᚠᚺᛃᛚᛉᚹᛊᚺᚠᛈᚢᚠᚺᚠᛚᚨᛟᚺᚠᚺᛃᛚᛉᛉᚹᚺᚠᚺᚱᛚᚦᚠᚢᛒᛁᚠᚺᚠᚢᛈᛃᛚᛉᛃᛟ
    //ᚺᚠᚺᚢᚲᚠᚺᚠᚢᛞᚱᚢᚺᚠᚢᛒᛁᚠᚺᚠᚢᛈᛃᛚᛉᚲᚺᚠᚠᚹᛚᛁᛉᚨᛁᛒᛃᚨᛒᛁᛚᛉᛟᚺᚠᚢᛊᚲᚨᚺᚠᚢᚢᚢᛉᚺᚠ
    //ᚢᚨᚺᚠᚢᛏᛚᛃᚺᚠᚢᛁᚨᛟᛗᚺᚠᛒᛈᛊᚲᛁᚺᚠᛚᚨᛟᚺᚠᚺᚨᛗᚢᛁᛏᚹᛊᚺᚠᚺᚢᚲᚠᚺᚠᚢᚢᛉᚨᛁᚺᚠᛚᚨᛟᚺᚠ
    //ᛈᚾᚢᚺᛊᛉᚺᚠᛚᚨᛟᚺᚠᛒᚲᛚᛁᚢᛁᚢᛚᛃᛁᚺᚠᚺᚠᛞᚺᚠᛈᛊᛊᛞᚺᚠᛚᛃᚢᛏᛚᛁᚺᚠᚢᛒᛁᚠᚺᚠᛈᚾᛈᛊᛉᚺᚠ

    /*************************************************************************/
    /*** PAYMENT VARIABLES (Start) *******************************************/
    address[] public based;
    mapping(address => uint256) private howBased;
    uint256 totalReceived = 0;
    mapping(address => uint256) amountsWithdrawn;

    // Liyat yew gnilaaw gnilaww ay oo

    modifier onlyBased() {
        _isBased();
        _;
    }
    function _isBased() internal view virtual {
        require(howBased[msg.sender] > 0, "not a royalty payee");
    }
    // decaf gib
    /*** PAYMENT VARIABLES (End) *******************************************/
    /***********************************************************************/
    
    
    mapping(uint256 => uint256) public hazUFoundIt;
    CrudeBorneEggs public eggzzz;


    /***********************************************************************************/
    /*** CONTRACT METADATA VARIABLES (Start) *******************************************/
    string collectionDescription;
    string collecImg;
    /*** CONTRACT METADATA VARIABLES (Start) *******************************************/
    /***********************************************************************************/

    /******************************************************************************************/
    /*** METADATA AND CONSUMPTION VARIABLES (Start) *******************************************/
    ElixirMetadataProto public metadataStorage;

    IERC721Receiver public redistributionReceiver;

    mapping(address => bool) public authorizedConsumers;

    mapping(address => mapping(address => bool)) perUserAuths;
    /*** METADATA AND CONSUMPTION VARIABLES (End) *******************************************/
    /****************************************************************************************/


    /*******************************************************************/
    /*** CONSTRUCTOR (Start) *******************************************/
    constructor(
        address _cbeAddy,
        string memory _collectionDescription,
        string memory _collectionImage,
        address[] memory _based,
        uint128[] memory _basisPoints
    ) {
        // FACED
        collectionDescription = _collectionDescription;
        collecImg = _collectionImage;

        for (uint256 i = 0; i < _based.length; i++) {
            howBased[_based[i]] = _basisPoints[i];
        }

        based = _based;

        eggzzz = CrudeBorneEggs(_cbeAddy);
    }
    /*** CONSTRUCTOR (End) *******************************************/
    /*****************************************************************/

    //222221268612811425868211126198616191948622201210862218612121158622222
    //126862221122668622219268616191948612986121268612121325861281892586121
    //158622111210861621111386121158612121258622191922413861211586831219191
    //225125862218622119221018686121122521161668616211425121116122112668616
    //191948612986222211113868251386821116861611124861211586224122526238612
    //611586122612249861619194861298616212616111268612141426686161919486811
    //015158622211268686118612251612262062618612312819121125862241586821620
    //861619194862226862261122520862241586821620861619194862226861612191168
    //621619119862222568681011622212613862161911986222256861282026186121312
    //211111862222526121931226686814816212616861621142611586221261212216861
    //621111386222256868101226231986162168612115868101226262386818122086222
    //256862216101226101586821116862241821862222568622161012263866231225261
    //252101225122615862219111862222212686221862220121086222511513862161911
    //986121158681132225202319868211168622222619861211586161421819268612115
    //862111292225211210258686486161919486121022201298622225686161416192686

    function izItDerOrIzItGone() external onlyOwner {
        izItDer = !izItDer;
    }

    // faced gib

    function enableNightVision(address whomst) public onlyOwner {
        nightVision[whomst] = true;
    }

    function howHardIzIt2See(HowHard2See _howHard) public onlyOwner {
        require(_howHard != HowHard2See.BlindAF);
        canUSeesIt = _howHard;
    }

    // 418

    /*******************************************************************************/
    /*** CONTRACT METADATA LOGIC (Start) *******************************************/
    function contractURI() public view returns (string memory) {
        return _contractURI(collectionDescription, collecImg, uint256(uint160(address(this))).toHexString());
    }
    /*** CONTRACT METADATA LOGIC (End) *******************************************/
    /*****************************************************************************/

    /****************************************************************************/
    /*** TOKEN METADATA LOGIC (Start) *******************************************/
    function getCharges(uint256 elixirId) public view returns (uint256) {
        return metadataStorage.getCharges(elixirId);
    }

    function getElement(uint256 elixirId) public view returns (uint256) {
        return metadataStorage.getElement(elixirId);
    }

    function getAttributes(uint256 elixirId) public view returns (uint256[] memory) {
        return metadataStorage.getAttributes(elixirId);
    }

    // decaf gib

    function getElementAndAttributes(
        uint256 elixirId
    ) public view returns (uint256, uint256[] memory) {
        return metadataStorage.getElementAndAttributes(elixirId);
    }

    // 0x526163697374204D6F6E6B6579

    function getChargesElementAndAttributes(
        uint256 elixirId
    ) public view returns (uint256, uint256, uint256[] memory) {
        return metadataStorage.getChargesElementAndAttributes(elixirId);
    }

    // 418

    function tokenURI(uint256 tokenId) public view returns (string memory) {
        require(exists(tokenId), "z");
        return metadataStorage.getElixirMetadata(tokenId);
    }
    /*** TOKEN METADATA LOGIC (End) *******************************************/
    /**************************************************************************/


    function eliksirHazBeenGot(uint256 disEgg) public view returns (bool) {
        uint256 eggBlocc = disEgg/250;
        uint256 eggSlot = disEgg - eggBlocc*250;
        return ((hazUFoundIt[eggBlocc] >> eggSlot)%2 == 1);
    }

    // faced gib

    function piktItUpp(uint256[] memory eggz) public {
        require(izItDer, 'is');
        require(canUSeesIt == HowHard2See.Hard2See || (nightVision[msg.sender] && (canUSeesIt == HowHard2See.BlindAF)), 'so');

        uint256 curBlocc = 0;
        uint256 bloccUpdates = 0;
        uint256 eggBlocc;

        bool bottleRequire = true;
        bool ownerRequire = true;

        for (uint256 i = 0; i < eggz.length; i++) {
            eggBlocc = eggz[i]/250;
            if (eggBlocc != curBlocc) {
                hazUFoundIt[curBlocc] = hazUFoundIt[curBlocc] | bloccUpdates;
                curBlocc = eggBlocc;
                bloccUpdates = 0;
            }

            uint256 eggSlot = eggz[i] - curBlocc*250;
            bottleRequire = bottleRequire && (hazUFoundIt[curBlocc] >> eggSlot)%2 == 0;
            ownerRequire = ownerRequire && eggzzz.ownerOf(eggz[i]) == msg.sender;

            bloccUpdates += (1 << eggSlot);
        }
        require(bottleRequire && ownerRequire, 'b;o');

        hazUFoundIt[curBlocc] = hazUFoundIt[curBlocc] | bloccUpdates;

        safeMint(msg.sender, eggz.length);
    }

    //╮╮╮╵ᚽᛙ⸌ᚽ⸝⸜ᛁᚽᛙᚽ╮ᛍ╵╵ᚽᛙި╵╵⸍ᚽᛙ╮⸍⸌ᛁᚽᛙ╮⸝ᚽᛙ⸌⸌⸝ˎᚽᛙ╮╮╮╵ᚽᛙ╮╮⸌╵ᛙᚽᛙ╮ި╵╵ᚽᛙި╵╵⸍ᚽᛙ⸌ᛁᚽᛙ⸌⸝╵ᚽᛙ⸌⸌⠃ᛁ
    //ᚽᛙ⸌ᚽ◟ᛁᛁᚽᛙ⸌⸝ˎᚽᛙ╮ᛍ⸌ᛁᚽᛙި╮ᛍ⠃ᚽᛙ⸌⸝ˎᚽᛙ⸌⸌⸝ᛁᚽᛙ╮╵╵╮⸍⠃ᚽᛙ⸌⸝ˎᚽᛙᚽᛍ⸌╵╵⸌ᛁ⸝ᛁᚽᛙ╮⸝ᚽᛙި╮╵╮ᛁ◟ᛙᚽᛙ⸌⸝⸌ᛁ╮ި⸝ᛙᛙᚽᛙ
    //ި╮⸜ᛁ⸌ᛍި⸌╮⸝╵ᛙᚽᛙި╵╵⸍ᚽᛙ⸌ᛁᚽᛙ╮ި╮ᛍ⠃ᚽᛙᚽᛁ⠃ᚽᛙᚽ╮ᛍᛙᚽᛙިᛍ⸌⸍ᚽᛙ⸌⸝ˎᚽᛙ╮⸍⸌ᛁ╵╮ᚽᛙ⸌ᛙ⸝ˎᚽᛙ⸌╵⸝╮⸍ᛁᚽᛙި╵╵⸍ᚽᛙ⸌ᛁᚽᛙި╮╵
    //ިᛍ⸌ᛙᚽᛙ⸌⸜⸜╵ᛙᚽᛙި╵╵⸍ᚽᛙᚽ⸝ᛁˎˎᚽᛙ╮╮⸌ᛙᚽᛙᚽᛙᛍᚽᛙ⸌ᛁި⸌╵⸍ᛙ╵⸝ᚽᛙ⸌ᛍ⸌ᚽ╵⸌ᛍᛁᚽᛙ╮⸍ˎᚽᛙᚽ╮ᛙוᛙި╵╵⸍ᚽᛙ╮ިᛙᚽᛙި╵⸝⸌ᛁוᛙ╮
    //⸍ˎᚽᛙᚽ╮ᛙוᛙި╵╵⸍ᚽᛙ╮ިᛙᚽᛙި⸌╵ᛍᛙᚽᛙިި╵ᛍᛁᚽᛙ╮ިᛁᛙᚽᛙᚽᛁ⸝ި╮╮╵⠃ᚽᛙިި╵ᛍᛁᚽᛙ╮ިᛁᛙᚽᛙ⸌ᚽ⸍╵⸝ᚽᛙ⸌⠃⸌╮ᛍᛍᚽᛙ╮ިᛁ╵⸌╵ᛍ⸌╵ᛙ
    //ᚽᛙᚽ⸜ᚽި╮╵⸝ᛙᚽᛙި╮⸜╵⸝ˎᚽᛙި╮╵⸌⸌╮ᛙᚽᛙި╮ᛍ⠃ᚽᛙ╮ިᛁᛙᚽᛙᚽᛁ⸌╵╮╵ᚽᛙި╮ᛙᚽᛙ⸌⸝ˎᚽᛙᚽᛁ⸌╵╵╮ᚽᛙᚽ◟⸌וᛙ╮ިᛁᛙᚽᛙ╮ިᛁ⸌╵ᛁˎ
    //ᚽᛙᚽ╮ᛍᛙᚽᛙ╮⸍◟╮ᚽᛙ╮ިᛁᛙᚽᛙ╮ިᛁ⸌╵ᛍᚽᛙᛙ╮⸌ᛁ╵⸝ᛁިᛁ⸝ިᛁ⸌╵ˎᚽᛙ╮╵ᛍ⸝ᚽᛙ╮╮╮╵ᚽᛙ╮⸝ᚽᛙ╮⸍⸌ᛁᚽᛙ╮ᛁ⸝ˎ⠃ᚽᛙިި╵ᛍᛁᚽᛙ⸌⸝ˎᚽ
    //ᛙᚽ⸝⠃╮ᛁ⸍╮╵ᚽᛙᚽ╮ᛍᛙᚽᛙ╮╮╵⸝ᛁᚽᛙ⸌⸝/ˎᚽᛙި⸜╮ᚽ╵╵ᚽᛙ⸌⸝ˎᚽᛙިᛍ⸌ᛁ╮ᛁ╮⸌ᛁᛁᚽᛙᚽᛙ⸍ᚽᛙި╵╵⸍ᚽᛙ⸌ᛁ╮⸍⸌ᛁᚽᛙ╮ިᛁᛙᚽᛙި⸜ި╵╵ᚽᛙ

    /**************************************************************************************/
    /*** METADATA AND CONSUMPTION SETUP (Start) *******************************************/
    function registerMetadataStorage(address _msAddy) public onlyOwner {
        metadataStorage = ElixirMetadataProto(_msAddy);
    }
    // 0x552B353136442074696D656C696E6573

    function registerRedistributionReceiver(address _rrAddy) public onlyOwner {
        redistributionReceiver = IERC721Receiver(_rrAddy); // 0x552B3846324120552B35454642
    }

    // Liyat yew gnilaaw gnilaww ay oo

    function setConsumerAuthorization(address _cAddy, bool _authorized) public onlyOwner {
        authorizedConsumers[_cAddy] = _authorized;
    }
    /*** METADATA AND CONSUMPTION SETUP (End) *******************************************/
    /************************************************************************************/


    /**************************************************************************************/
    /*** METADATA AND CONSUMPTION LOGIC (Start) *******************************************/
    // 0x3736353433323139
    function brewIt(uint256 wotEliksir, uint256[] memory stuffs, uint256[] memory wichStuffz) public {
        require(stuffs.length == wichStuffz.length, "l");
        require(ownerOf(wotEliksir) == msg.sender, "o");

        for (uint256 i = 0; i < wichStuffz.length; i++) {
            ERC721Basic ingredientContract = ERC721Basic(metadataStorage.getIngredientContract(stuffs[i]));
            ingredientContract.safeTransferFrom(ingredientContract.ownerOf(wichStuffz[i]), address(redistributionReceiver), wichStuffz[i]);
        }

        metadataStorage.charge(wotEliksir, stuffs, wichStuffz);
    }

    function authorizeToDrink(address operator, bool _authorized) public {
        perUserAuths[msg.sender][operator] = _authorized;
    }

    function isAuthorizedToDrink(address owner, address operator) public view returns (bool) {
        return perUserAuths[owner][operator];
    }

    // 418

    function slurpIt(
        uint256 datEliksir,
        uint256 targetId,
        address msgSender
    ) public {
        // DECAF
        require(
            msgSender == ownerOf(datEliksir) &&
            authorizedConsumers[msg.sender] &&
            isAuthorizedToDrink(msgSender, msg.sender), "o;a");

        (uint256 element, uint256[] memory attributes) = metadataStorage.getElementAndAttributes(datEliksir);

        metadataStorage.drink(datEliksir);

        ElixirConsumerProto(msg.sender).applyElixir(targetId, element, attributes);
    }
    // 0x7768617420646F6573207468652064657620736C7572703F */

    function ohNoes(uint256 waaaMyEliksir) public {
        require(ownerOf(waaaMyEliksir) == msg.sender, "o");

        metadataStorage.spill(waaaMyEliksir);
    }

    // Liyat yew gnilaaw gnilaww ay oo


    /*********************************************************************/
    /*** PAYMENT LOGIC (Start) *******************************************/
    receive() external payable {
        totalReceived += msg.value;
    }

    function withdraw() public onlyBased {
        uint256 totalForPayee = (totalReceived/10000)*howBased[msg.sender];
        uint256 toWithdraw = totalForPayee - amountsWithdrawn[msg.sender];
        amountsWithdrawn[msg.sender] = totalForPayee;
        (bool success, ) = payable(msg.sender).call{value: toWithdraw}("");
        require(success, "Payment failed!");
    }

    function withdrawTokens(address tokenAddress) external onlyOwner() {
        for (uint256 i = 0; i < based.length; i++) {
            IERC20(tokenAddress).transfer(
                based[i],
                (IERC20(tokenAddress).balanceOf(address(this))/10000)*howBased[based[i]]
            );
        }
    }

    // decaf gib

    function emergencyWithdrawTokens(address tokenAddress) external onlyOwner() {
        IERC20(tokenAddress).transfer(msg.sender, IERC20(tokenAddress).balanceOf(address(this)));
    }
    /*** PAYMENT LOGIC (End) *******************************************/
    /*******************************************************************/


    function restrictOperator(address operator) public onlyOwner {
        _restrictOperator(operator);
    }

    function releaseOperator(address operator) public onlyOwner {
        _releaseOperator(operator);
    }

    // 418

    function preventNewRestrictions() public onlyOwner {
        _preventNewRestrictions();
    }
}

////////////////////

abstract contract CrudeBorneEggs {
    function balanceOf(address owner) public view virtual returns (uint256);
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
    function ownerOf(uint256 tokenId) public view virtual returns (address);
}

// faced gib

abstract contract ElixirMetadataProto {
    function getIngredientContract(uint256 ingredientType) public view virtual returns (address);

    // 0x43616E20796F75207368616B6520697420627265616B206974204A656C6C7920626162793F2043616E20796F7520736F6C7665206974206B6E6F7720697420647269766520796F75206372617A793F

    function getCharges(uint256 elixirId) public view virtual returns (uint256);
    function getElement(uint256 elixirId) public view virtual returns (uint256);
    function getAttributes(uint256 elixirId) public view virtual returns (uint256[] memory);

    function getElementAndAttributes(
        uint256 elixirId
    ) public view virtual returns (uint256, uint256[] memory);

    function getChargesElementAndAttributes(
        uint256 elixirId
    ) public view virtual returns (uint256, uint256, uint256[] memory);

    // Liyat yew gnilaaw gnilaww ay oo

    function getElixirMetadata(uint256 elixirId) public view virtual returns (string memory);

    function getIngredientsList() public view virtual returns (string[] memory);

    function charge(
        uint256 elixirId,
        uint256[] memory ingredientTypes,
        uint256[] memory ingredientIDs
    ) public virtual;

    function drink(uint256 elixirId) public virtual;

    function spill(uint256 elixirId) public virtual;
}

// zzzzzzzzzzZZZZZZZZZZ //

abstract contract ElixirConsumerProto {
    function ownerOf(uint256 tokenId) public view virtual returns (address);
    function applyElixir(
        uint256 targetId,
        uint256 elixirElement,
        uint256[] memory elixirAttributes
    ) public virtual;
}

abstract contract ERC721Basic {
    function ownerOf(uint256 tokenId) public view virtual returns (address);
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual;
}

////////////////////////////////////////



/**
                       (
                        )       (         )
                 ____...(.-------)--.....(___
             .-""        )      (        )   ""-.
       .-'``'|-._             )         (    _.-|
      /  .--.|   `""-----............-----""`   |
     /  /    |                                  |
     |  |    |                                  |
      \  \   |                                  |
       `\ `\ |                                  |
         `\ `|                                  |
         _/ /\                                  /
        (__/  \                                /
     _..---""` \                              /`""---.._
  .-'           \                            /          '-.
 :               `-.__                  __.-'              :
 :                  ) ""-----.....-----"" (                 :
  '._               `"--....._____.....--"`              _.'
    \""--..__                                    __..--""/
     '._     """----.....__________.......----"""     _.'
        `""--..,,_____                 ______,,..--""`
                      `"""""------"""""`
**/



////////////////////////////////////////
















// File: @openzeppelin/contracts/token/ERC20/IERC20.sol



// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

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



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

pragma solidity ^0.8.0;

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

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

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

// File: contracts/ERC721.sol



// SPDX-License-Identifier: Unlicense
// Creator: CrudeBorne
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";

//contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
contract ERC721 is Context, ERC165 {//, IERC721, IERC721Metadata, IERC721Enumerable {
    using Address for address;
    using Strings for uint256;

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

    uint256 private currentIndex = 0;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

//    // Base URI
//    string private _baseURI;
//    string private _preRevealURI;

    mapping(uint256 => address) private _ownerships;
    mapping(address => uint256) private _balances;

    address public immutable burnAddress = 0x000000000000000000000000000000000000dEaD;
    uint256 private numTokensBurned;

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

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

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

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
    **/
//    function totalSupply() public view override returns (uint256) {
    function totalSupply() public view returns (uint256) {
        return (currentIndex - numTokensBurned);
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
//    function tokenByIndex(uint256 index) public view override returns (uint256) {
    function tokenByIndex(uint256 index) public view returns (uint256) {
        require(index < totalSupply(), "g");
        require(ownerOf(index) != burnAddress, "b");
        return index;
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
     * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
     */
//    function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
    function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) {
        require(index < balanceOf(owner), "b");
        uint256 numMintedSoFar = totalSupply();
        uint256 tokenIdsIdx = 0;
        address currOwnershipAddr = address(0);
        for (uint256 i = 0; i < numMintedSoFar; i++) {
            address ownership = _ownerships[i];
            if (ownership != address(0)) {
                currOwnershipAddr = ownership;
            }
            if (currOwnershipAddr == owner) {
                if (tokenIdsIdx == index) {
                    return i;
                }
                tokenIdsIdx++;
            }
        }
        revert("u");
    }

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

    /**
     * @dev See {IERC721-balanceOf}.
     */
//    function balanceOf(address owner) public view override returns (uint256) {
    function balanceOf(address owner) public view returns (uint256) {
        require(owner != address(0), "0");
        return uint256(_balances[owner]);
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
//    function ownerOf(uint256 tokenId) public view override returns (address) {
    function ownerOf(uint256 tokenId) public view returns (address) {
        //        return ownershipOf(tokenId);

        require(tokenId < currentIndex, "t");

        for (uint256 curr = tokenId; curr >= 0; curr--) {
            address ownership = _ownerships[curr];
            if (ownership != address(0)) {
                return ownership;
            }
        }

        revert("o");
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
//    function name() public view virtual override returns (string memory) {
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
//    function symbol() public view virtual override returns (string memory) {
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
    * @dev See {IERC721-approve}.
     */
//    function approve(address to, uint256 tokenId) public override {
    function approve(address to, uint256 tokenId) public {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "o");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "a"
        );

        _approve(to, tokenId, owner);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
//    function getApproved(uint256 tokenId) public view override returns (address) {
    function getApproved(uint256 tokenId) public view returns (address) {
        require(_exists(tokenId), "a");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
//    function setApprovalForAll(address operator, bool approved) public override {
    function setApprovalForAll(address operator, bool approved) public {
//        require(operator != _msgSender() && !(operatorRestrict[operator]), "a;r");
        require(operator != _msgSender(), "a");

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
//    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
    function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
//    ) public override {
    ) public {
        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
//    ) public override {
    ) public {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
//    ) public override {
    ) public {
        _transfer(from, to, tokenId);
        require(
            _checkOnERC721Received(from, to, tokenId, _data),
            "z"
        );
    }

    function burnToken(uint256 tokenId) public {
        _transfer(ownerOf(tokenId), burnAddress, tokenId);
        numTokensBurned++;
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     */
    function _exists(uint256 tokenId) internal view returns (bool) {
        return (tokenId < currentIndex && ownerOf(tokenId) != burnAddress);
    }

    function _safeMint(address to, uint256 quantity) internal {
        _safeMint(to, quantity, "");
    }

    function _safeMint(
        address to,
        uint256 quantity,
        bytes memory _data
    ) internal {
        _mint(to, quantity);
        require(_checkOnERC721Received(address(0), to, currentIndex - 1, _data), "z");
    }

    function _mint(address to, uint256 quantity) internal {
        uint256 startTokenId = currentIndex;
        require(to != address(0), "0");
        // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
        require(!_exists(startTokenId), "a");

        _balances[to] = _balances[to] + quantity;
        _ownerships[startTokenId] = to;

        uint256 updatedIndex = startTokenId;

        for (uint256 i = 0; i < quantity; i++) {
            emit Transfer(address(0), to, updatedIndex);
            updatedIndex++;
        }

        currentIndex = updatedIndex;
    }

    /******************/

    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) private {
        address prevOwnership = ownerOf(tokenId);

        bool isApprovedOrOwner = (_msgSender() == prevOwnership ||
        getApproved(tokenId) == _msgSender() ||
        isApprovedForAll(prevOwnership, _msgSender()));

        require(isApprovedOrOwner && prevOwnership == from, "a");
        require(prevOwnership == from, "o");
        require(to != address(0), "0");

        // Clear approvals from the previous owner
        _approve(address(0), tokenId, prevOwnership);

        _balances[from] -= 1;
        _balances[to] += 1;
        _ownerships[tokenId] = to;

        // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
        // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
        uint256 nextTokenId = tokenId + 1;
        if (_ownerships[nextTokenId] == address(0)) {
            if (_exists(nextTokenId)) {
                _ownerships[nextTokenId] = prevOwnership;
            }
        }

        emit Transfer(from, to, tokenId);
    }

    function _approve(
        address to,
        uint256 tokenId,
        address owner
    ) private {
        _tokenApprovals[tokenId] = to;
        emit Approval(owner, to, tokenId);
    }

    /******************/

    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721Receiver(to).onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("z");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }
}

////////////////////////////////////////




















// File: contracts/ERC721TopLevel.sol



// SPDX-License-Identifier: Unlicense
// Creator: 0xVeryBased

pragma solidity ^0.8.9;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "./ERC721Storage.sol";

contract ERC721TopLevel is ERC165, Ownable {
    using Address for address;
    using Strings for uint256;

    /**
     * @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 Storage layer contract that separates out internal minting logic from top level functions
     *   - Designed to reduce top level contract size and enable implementation of additional functionality
    **/
    ERC721Storage public storageLayer;
    bool public storageLayerSet = false;
    modifier onlyStorage() {
        _isStorage();
        _;
    }
    function _isStorage() internal view virtual {
        require(msg.sender == address(storageLayer), "not storage");
    }
    /******************/

    /**
     * @dev Mapping from addresses to whether or not an address is restricted as an operator for all
    **/
    mapping(address => bool) public operatorRestrictions;
    bool public canRestrict = true; // Determines whether or not the contract owner can still restrict any new addresses

    /**
     * @dev Sets the storage layer for this top-level contract and prevents it from being reset
    **/
    function setStorageLayer(address storageLayerAddress_) public onlyOwner {
        require(!storageLayerSet, "sls");
        storageLayer = ERC721Storage(storageLayerAddress_);
        storageLayerSet = true;
    }

    /**
     * @dev get the address of the storage layer contract
    **/
    function _storageLayerAddress() public view returns (address) {
        return address(storageLayer);
    }

    /**
     * @dev Restrict an address from being an operator for all
    **/
    function _restrictOperator(address operator) internal {
        require(canRestrict, "nnr");

        operatorRestrictions[operator] = true;
    }

    /**
     * @dev Release an address from restriction, permitting it to be an operator for all
    **/
    function _releaseOperator(address operator) internal {
        operatorRestrictions[operator] = false;
    }

    /**
     * @dev Prevent the contract owner from restricting any additional operators
    **/
    function _preventNewRestrictions() internal {
        canRestrict = false;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
    **/
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165) returns (bool) {
        return (interfaceId == type(IERC721).interfaceId ||
        interfaceId == type(IERC721Metadata).interfaceId ||
        interfaceId == type(IERC721Enumerable).interfaceId ||
        super.supportsInterface(interfaceId));
    }

    function totalSupply() public view returns (uint256) {
        return storageLayer.storage_totalSupply();
    }

    function tokenByIndex(uint256 index) public view returns (uint256) {
        return storageLayer.storage_tokenByIndex(index);
    }

    function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) {
        return storageLayer.storage_tokenOfOwnerByIndex(owner, index);
    }

    function tokenOfOwnerByIndexStepped(
        address owner,
        uint256 index,
        uint256 lastToken,
        uint256 lastIndex
    ) public view returns (uint256) {
        return storageLayer.storage_tokenOfOwnerByIndexStepped(
            owner, index, lastToken, lastIndex
        );
    }

    function balanceOf(address owner) public view returns (uint256) {
        return storageLayer.storage_balanceOf(owner);
    }

    function ownerOf(uint256 tokenId) public view returns (address) {
        return storageLayer.storage_ownerOf(tokenId);
    }

    function name() public view virtual returns (string memory) {
        return storageLayer.storage_name();
    }

    function symbol() public view virtual returns (string memory) {
        return storageLayer.storage_symbol();
    }

    function approve(address to, uint256 tokenId) public {
        storageLayer.storage_approve(to, tokenId, msg.sender);
    }

    function getApproved(uint256 tokenId) public view returns (address) {
        return storageLayer.storage_getApproved(tokenId);
    }

    function setApprovalForAll(address operator, bool approved) public {
        require(!(operatorRestrictions[operator]), "r");

        storageLayer.storage_setApprovalForAll(operator, approved, msg.sender);
    }

    function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
        return storageLayer.storage_isApprovedForAll(owner, operator);
    }

    function transferFrom(address from, address to, uint256 tokenId) public {
        storageLayer.storage_transferFrom(from, to, tokenId, msg.sender);
    }

    function safeTransferFrom(address from, address to, uint256 tokenId) public {
        storageLayer.storage_safeTransferFrom(from, to, tokenId, msg.sender);
    }

    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public {
        storageLayer.storage_safeTransferFrom(from, to, tokenId, _data, msg.sender);
    }

    function burnToken(uint256 tokenId) public {
        storageLayer.storage_burnToken(tokenId, msg.sender);
    }

    function exists(uint256 tokenId) public view returns (bool) {
        return storageLayer.storage_exists(tokenId);
    }

    function safeMint(address to, uint256 quantity) internal {
        storageLayer.storage_safeMint(to, quantity, msg.sender);
    }

    function safeMint(address to, uint256 quantity, bytes memory _data) internal {
        storageLayer.storage_safeMint(to, quantity, _data, msg.sender);
    }

    function mint(address to, uint256 quantity) internal {
        storageLayer.storage_mint(to, quantity);
    }

    function _contractURI(
        string memory _description,
        string memory _img,
        string memory _self
    ) internal view returns (string memory) {
        return storageLayer.storage_contractURI(_description, _img, _self);
    }

    //////////

    function emitTransfer(address from, address to, uint256 tokenId) public onlyStorage {
        emit Transfer(from, to, tokenId);
    }

    function emitApproval(address owner, address approved, uint256 tokenId) public onlyStorage {
        emit Approval(owner, approved, tokenId);
    }

    function emitApprovalForAll(address owner, address operator, bool approved) public onlyStorage {
        emit ApprovalForAll(owner, operator, approved);
    }
}

////////////////////////////////////////




















// File: @openzeppelin/contracts/token/ERC721/IERC721.sol



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

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 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 ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @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 caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

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

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

// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol



// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 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);
}

// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol



// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../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);
}

// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol



// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

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



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

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

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



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

pragma solidity ^0.8.0;

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

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

// File: @openzeppelin/contracts/utils/introspection/ERC165.sol



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

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 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);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

// File: @openzeppelin/contracts/utils/introspection/IERC165.sol



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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * 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[EIP 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: @openzeppelin/contracts/access/Ownable.sol



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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

// File: contracts/ERC721Storage.sol



// SPDX-License-Identifier: Unlicense
// Creator: 0xVeryBased

pragma solidity ^0.8.9;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";

contract ERC721Storage is Ownable {
    using Address for address;
    using Strings for uint256;

    // Tracker for calculating number minted/total supply and assigning token indices
    uint256 private currentIndex = 0;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Token owners and token balances
    mapping(uint256 => address) private _ownerships;
    mapping(address => uint256) private _balances;

    // Burn address and counter
    address public immutable burnAddress = 0x000000000000000000000000000000000000dEaD;
    uint256 private numTokensBurned;

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

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

    // Mapping from operators to whether or not they are restricted
    mapping(address => bool) private _operatorRestrictions;
    // Bool indicating whether one can still restrict an operator or not
    bool private _canRestrict;

    ERC721TopLevelProto public topLevelContract;

    constructor(
        string memory name_,
        string memory symbol_
    ) {
        _name = name_;
        _symbol = symbol_;
//        topLevelContract = ERC721TopLevelProto(msg.sender);
    }

    function setTopLevelContract(address _topLevelContract) public onlyOwner {
        topLevelContract = ERC721TopLevelProto(_topLevelContract);
        transferOwnership(_topLevelContract);
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
    **/
    function storage_totalSupply() public view returns (uint256) {
        return (currentIndex - numTokensBurned);
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
    **/
    function storage_tokenByIndex(uint256 index) public view returns (uint256) {
        require(index < storage_totalSupply(), "g");
        require(storage_ownerOf(index) != burnAddress, "b");
        return index;
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
     * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
    **/
    function storage_tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) {
        require(index < storage_balanceOf(owner), "b");
        uint256 numMintedSoFar = storage_totalSupply();
        uint256 tokenIdsIdx = 0;
        address currOwnershipAddr = address(0);
        for (uint256 i = 0; i < numMintedSoFar; i++) {
            address ownership = _ownerships[i];
            if (ownership != address(0)) {
                currOwnershipAddr = ownership;
            }
            if (currOwnershipAddr == owner) {
                if (tokenIdsIdx == index) {
                    return i;
                }
                tokenIdsIdx++;
            }
        }
        revert("u");
    }

    function storage_tokenOfOwnerByIndexStepped(address owner, uint256 index, uint256 lastToken, uint256 lastIndex) public view returns (uint256) {
        require(index < storage_balanceOf(owner), "b");
        uint256 numTokenIds = currentIndex;
        uint256 tokenIdsIdx = ((lastIndex == 0) ? 0 : (lastIndex + 1));
        address currOwnershipAddr = address(0);
        for (uint256 i = ((lastToken == 0) ? 0 : (lastToken + 1)); i < numTokenIds; i++) {
            address ownership = _ownerships[i];
            if (ownership != address(0)) {
                currOwnershipAddr = ownership;
            }
            if (currOwnershipAddr == owner) {
                if (tokenIdsIdx == index) {
                    return i;
                }
                tokenIdsIdx++;
            }
        }
        revert("u");
    }

//    /**
//     * @dev See {IERC165-supportsInterface}.
//    **/
//    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
//        return (interfaceId == type(IERC721).interfaceId ||
//        interfaceId == type(IERC721Metadata).interfaceId ||
//        interfaceId == type(IERC721Enumerable).interfaceId ||
//        super.supportsInterface(interfaceId));
//    }

    /**
     * @dev See {IERC721-balanceOf}.
    **/
    function storage_balanceOf(address owner) public view returns (uint256) {
        require(owner != address(0), "0");
        return uint256(_balances[owner]);
    }

    /**
     * @dev See {IERC721-ownerOf}.
    **/
    function storage_ownerOf(uint256 tokenId) public view returns (address) {
        require(tokenId < currentIndex, "t");

        for (uint256 curr = tokenId; curr >= 0; curr--) {
            address ownership = _ownerships[curr];
            if (ownership != address(0)) {
                return ownership;
            }
        }

        revert("o");
    }

    /**
     * @dev See {IERC721Metadata-name}.
    **/
    function storage_name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
    **/
    function storage_symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721-approve}.
    **/
    function storage_approve(address to, uint256 tokenId, address msgSender) public onlyOwner {
        address owner = ERC721Storage.storage_ownerOf(tokenId);
        require(to != owner, "o");

        require(
            msgSender == owner || storage_isApprovedForAll(owner, msgSender),
            "a"
        );

        _approve(to, tokenId, owner);
    }

    /**
     * @dev See {IERC721-getApproved}.
    **/
    function storage_getApproved(uint256 tokenId) public view returns (address) {
        require(_exists(tokenId), "a");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
    **/
    function storage_setApprovalForAll(address operator, bool approved, address msgSender) public {
        //        require(operator != msgSender && !(operatorRestrict[operator]), "a;r");
        require(operator != msgSender, "a");

        _operatorApprovals[msgSender][operator] = approved;
        topLevelContract.emitApprovalForAll(msgSender, operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
    **/
    function storage_isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
    **/
    function storage_transferFrom(
        address from,
        address to,
        uint256 tokenId,
        address msgSender
    ) public onlyOwner {
        _transfer(from, to, tokenId, msgSender);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
    **/
    function storage_safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        address msgSender
    ) public onlyOwner {
        storage_safeTransferFrom(from, to, tokenId, "", msgSender);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
    **/
    function storage_safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data,
        address msgSender
    ) public onlyOwner {
        _transfer(from, to, tokenId, msgSender);
        require(
            _checkOnERC721Received(from, to, tokenId, _data, msgSender),
            "z"
        );
    }

    /**
     * @dev Burns a token to the designated burn address
    **/
    function storage_burnToken(uint256 tokenId, address msgSender) public onlyOwner {
        _transfer(storage_ownerOf(tokenId), burnAddress, tokenId, msgSender);
        numTokensBurned++;
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
    **/
    function _exists(uint256 tokenId) internal view returns (bool) {
        return (tokenId < currentIndex && storage_ownerOf(tokenId) != burnAddress);
    }

    function storage_exists(uint256 tokenId) public view returns (bool) {
        return _exists(tokenId);
    }

    function storage_safeMint(address to, uint256 quantity, address msgSender) public onlyOwner {
        storage_safeMint(to, quantity, "", msgSender);
    }

    function storage_safeMint(
        address to,
        uint256 quantity,
        bytes memory _data,
        address msgSender
    ) public onlyOwner {
        storage_mint(to, quantity);
        require(_checkOnERC721Received(address(0), to, currentIndex - 1, _data, msgSender), "z");
    }

    function storage_mint(address to, uint256 quantity) public onlyOwner {
        uint256 startTokenId = currentIndex;
        require(to != address(0), "0");
        // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
        require(!_exists(startTokenId), "a");

        _balances[to] = _balances[to] + quantity;
        _ownerships[startTokenId] = to;

        uint256 updatedIndex = startTokenId;

        for (uint256 i = 0; i < quantity; i++) {
            topLevelContract.emitTransfer(address(0), to, updatedIndex);
            updatedIndex++;
        }

        currentIndex = updatedIndex;
    }

    function storage_contractURI(string memory _description, string memory _img, string memory _self) public view returns (string memory) {
        return string(
            abi.encodePacked(
                "data:application/json;utf8,{\"name\":\"", storage_name(),"\",",
                "\"description\":\"", _description, "\",",
                "\"image\":\"", _img, "\",",
                "\"external_link\":\"https://crudeborne.wtf\",",
                "\"seller_fee_basis_points\":420,\"fee_recipient\":\"",
                _self, "\"}"
            )
        );
    }

    function _transfer(
        address from,
        address to,
        uint256 tokenId,
        address msgSender
    ) private {
        address prevOwnership = storage_ownerOf(tokenId);

        bool isApprovedOrOwner = (msgSender == prevOwnership ||
        storage_getApproved(tokenId) == msgSender ||
        storage_isApprovedForAll(prevOwnership, msgSender));

        require(isApprovedOrOwner && prevOwnership == from, "a");
        require(prevOwnership == from, "o");
        require(to != address(0), "0");

        // Clear approvals from the previous owner
        _approve(address(0), tokenId, prevOwnership);

        _balances[from] -= 1;
        _balances[to] += 1;
        _ownerships[tokenId] = to;

        // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
        // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
        uint256 nextTokenId = tokenId + 1;
        if (_ownerships[nextTokenId] == address(0)) {
            if (_exists(nextTokenId)) {
                _ownerships[nextTokenId] = prevOwnership;
            }
        }

        topLevelContract.emitTransfer(from, to, tokenId);
    }

    function _approve(
        address to,
        uint256 tokenId,
        address owner
    ) private {
        _tokenApprovals[tokenId] = to;
        topLevelContract.emitApproval(owner, to, tokenId);
    }

    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data,
        address msgSender
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(msgSender, from, tokenId, _data) returns (bytes4 retVal) {
                return retVal == IERC721Receiver(to).onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("z");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }
}

////////////////////

abstract contract ERC721TopLevelProto {
    function emitTransfer(address from, address to, uint256 tokenId) public virtual;
    function emitApproval(address owner, address approved, uint256 tokenId) public virtual;
    function emitApprovalForAll(address owner, address operator, bool approved) public virtual;
}

////////////////////////////////////////