{
  "namespace": "enchanting_pocket",

  "generic_label": {
    "type": "label",
    "color": "$body_text_color",
    "anchor_from": "center",
    "anchor_to": "center",
    "shadow": true
  },

  // Backgrounds //

  "background_image": {
    "type": "image",
    "size": [ "100%", "100%" ],
    "texture": "textures/ui/background_panel"
  },

  // Inventory Grids //

  "inventory_grid": {
    "type": "grid",
    "grid_rescaling_type": "horizontal",
    "anchor_to": "top_left",
    "anchor_from": "top_left",
    "size": [ "100%", "default" ],
    "maximum_grid_items": 36,
    "collection_name": "combined_hotbar_and_inventory_items",
    "grid_item_template": "common.pocket_ui_container_item",
    "$item_collection_name": "combined_hotbar_and_inventory_items"
  },

  "inventory_content": {
    "type": "panel",
    "size": [ "80%", "95%" ],
    "anchor_to": "center",
    "anchor_from": "center",
    "controls": [
      {
        "scrolling_panel@common.scrolling_panel": {
          "layer": 1,
          "$scrolling_pane_size": [ "100%", "100%-2px" ],
          "$scrolling_content": "enchanting_pocket.inventory_grid",
          "$scroll_box_mouse_image_control": "common-classic.button_state_default",
          "$scroll_size": [ "8px", "100%" ]
        }
      }
    ]
  },

  // Enchanting Slots Panel //

  "lapis_image@enchanting.enchanting_image": {
    "anchor_to": "center",
    "anchor_from": "center",
    "size": [ 16, 16 ],
    "texture": "textures/ui/lapis"
  },

  "enchanting_slots_panel": {
    "type": "panel",
    "size": [ 32, 68 ],
    "anchor_to": "top_left",
    "anchor_from": "top_left",
    "controls": [
      {
        "input_slot@common.pocket_ui_large_container_item": {
          "$item_collection_name": "enchanting_input_items",
          "anchor_from": "top_middle",
          "anchor_to": "top_middle",
          "property_bag": {
            "#start_selected": true
          }
        }
      },
      {
        "lapis_slot@common.pocket_ui_large_container_item": {
          "$item_collection_name": "enchanting_lapis_items",
          "$cell_overlay_ref": "enchanting_pocket.lapis_image",
          "anchor_from": "bottom_middle",
          "anchor_to": "bottom_middle"
        }
      }
    ]
  },

  // Enchant Buttton //

  "enchant_text_runes@enchanting.enchant_runes": {
    "size": [ "100% - 29px", "100% - 6px" ],
    "color": "$enchanting_runes_fail_color"
  },

  "show_highlighted_slot_control@common.pocket_ui_highlight_selected_slot": {
    "visible": false,
    "bindings": [
      {
        "binding_type": "collection",
        "binding_name": "#show_selected_button_highlight",
        "binding_name_override": "#visible",
        "binding_collection_name": "#enchant_buttons"
      }
    ]
  },

  "show_highlighted_hover_slot_control@common.pocket_ui_highlight_selected_slot": {
    "visible": false,
    "bindings": [
      {
        "binding_type": "collection",
        "binding_name": "#show_selected_button_highlight",
        "binding_name_override": "#visible",
        "binding_collection_name": "#enchant_buttons"
      }
    ]
  },

  "inactive_background": {
    "type": "image",
    "texture": "textures/ui/pocket_button_pressed"
  },

  "unselectable_button@enchanting.unselectable_button": {
    "button_mappings": [
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "button.menu_select",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.menu_ok",
        "mapping_type": "pressed"
      },
      {
        "to_button_id": "button.button_hovered",
        "mapping_type": "pressed"
      }
    ],
    "controls": [
      { "default@enchanting.dark_background": {} },
      { "hover@enchanting.dark_background_with_hover_text": {} },
      { "pressed@enchanting.dark_background": {} },
      {
        "enchant_cost@enchanting.fail_cost": {
          "anchor_from": "bottom_right",
          "anchor_to": "bottom_right",
          "offset": [ -3, -2 ]
        }
      }
    ]
  },

  "selectable_button@enchanting.selectable_button": {
    "button_mappings": [
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "button.menu_select",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.menu_ok",
        "mapping_type": "pressed"
      },
      {
        "to_button_id": "button.button_hovered",
        "mapping_type": "pressed"
      }
    ],
    "controls": [
      { "default@enchanting.active_background": {} },
      { "hover@enchanting.active_background_with_hover_text": {} },
      { "pressed@enchanting.dark_background": {} },
      {
        "enchant_cost@enchanting.success_cost": {
          "anchor_from": "bottom_right",
          "anchor_to": "bottom_right",
          "offset": [ -3, -2 ]
        }
      }
    ]
  },

  "enchant_button_panel": {
    "type": "panel",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "size": [ "100%", "33.3333333%-1px" ],
    "controls": [
      {
        "inactive_background@enchanting_pocket.inactive_background": {
          "size": [ "100%", "100%" ]
        }
      },
      {
        "unselectable_button@enchanting_pocket.unselectable_button": {
          "size": [ "100%", "100%" ],
          "layer": 1
        }
      },
      {
        "selectable_button@enchanting_pocket.selectable_button": {
          "size": [ "100%", "100%" ],
          "layer": 1
        }
      },
      {
        "dust@enchanting.dust_template": {
          "anchor_from": "left_middle",
          "anchor_to": "left_middle",
          "size": [ 13, 11 ],
          "offset": [ 1, 0 ],
          "layer": 2
        }
      },
      {
        "rune_text@enchanting_pocket.enchant_text_runes": {
          "layer": 2,
          "offset": [ 20, 2 ]
        }
      },
      { "highlight@enchanting_pocket.show_highlighted_slot_control": { "layer": 3 } }
    ]
  },

  // Enchant Selection Panel //

  "enchant_selection_panel": {
    "type": "panel",
    "size": [ "100%-34px", 60 ],
    "offset": [ 34, 0 ],
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "controls": [
      {
        "grid": {
          "type": "grid",
          "collection_name": "#enchant_buttons",
          "size": [ "100%", "100%" ],
          "layer": 4,
          "anchor_from": "center",
          "anchor_to": "center",
          "grid_dimensions": [ 1, 3 ],
          "controls": [
            {
              "button1@enchanting_pocket.enchant_button_panel": {
                "grid_position": [ 0, 0 ],
                "$texture_selectable": "textures/ui/dust_selectable_1",
                "$texture_unselectable": "textures/ui/dust_unselectable_1"
              }
            },
            {
              "button2@enchanting_pocket.enchant_button_panel": {
                "grid_position": [ 0, 1 ],
                "$texture_selectable": "textures/ui/dust_selectable_2",
                "$texture_unselectable": "textures/ui/dust_unselectable_2"
              }
            },
            {
              "button3@enchanting_pocket.enchant_button_panel": {
                "grid_position": [ 0, 2 ],
                "$texture_selectable": "textures/ui/dust_selectable_3",
                "$texture_unselectable": "textures/ui/dust_unselectable_3"
              }
            }
          ]
        }
      }
    ]
  },

  // Enchanting Confirm Panel //

  "item_renderer": {
    "type": "custom",
    "renderer": "inventory_item_renderer",
    "anchor_from": "center",
    "anchor_to": "center",
    "size": [ 16, 16 ]
  },

  "confirm_default_control": {
    "type": "image",
    "texture": "textures/ui/pocket_button_default"
  },

  "enchanting_confirm_button@common.button": {
    "size": [ 120, 30 ],
    "focus_enabled": false,
    "$pressed_button_name": "button.enchant",

    "controls": [
      { "default@enchanting_pocket.confirm_default_control": {} },
      { "hover@enchanting_pocket.confirm_default_control": {} },
      {
        "pressed": {
          "type": "image",
          "texture": "textures/ui/pocket_button_pressed"
        }
      },
      {
        "arrow_active": {
          "type": "image",
          "texture": "textures/ui/arrow_active",
          "size": [ 22, 15 ],
          "layer": 1,
          "bindings": [
            {
              "binding_name": "#active_enchant",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "arrow_inactive": {
          "type": "image",
          "texture": "textures/ui/arrow_inactive",
          "size": [ 22, 15 ],
          "layer": 1,
          "bindings": [
            {
              "binding_name": "#inactive_enchant",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "input_item_renderer@enchanting_pocket.item_renderer": {
          "anchor_from": "left_middle",
          "anchor_to": "left_middle",
          "layer": 1,
          "offset": [ 5, 0 ],
          "property_bag": {
            "#filtered_light_multiplier": 0.5
          },
          "bindings": [
            {
              "binding_name": "#input_item_id",
              "binding_name_override": "#item_id_aux"
            },
            {
              "binding_name": "#inactive_enchant",
              "binding_name_override": "#disabled_filter_visible"
            }
          ]
        }
      },
      {
        "output_item_renderer@enchanting_pocket.item_renderer": {
          "anchor_from": "right_middle",
          "anchor_to": "right_middle",
          "offset": [ -5, 0 ],
          "layer": 1,
          "bindings": [
            {
              "binding_name": "#output_item_id",
              "binding_name_override": "#item_id_aux"
            }
          ]
        }
      }
    ]
  },

  "enchanting_confirm_panel": {
    "type": "panel",
    "size": [ "100%-34px", 44 ],
    "offset": [ 17, 0 ],
    "anchor_from": "bottom_middle",
    "anchor_to": "bottom_middle",
    "controls": [
      {
        "confirm@enchanting_pocket.enchanting_confirm_button": {
          "anchor_from": "top_middle",
          "anchor_to": "top_middle"
        }
      },
      {
        "enchantment_hint_text@enchanting_pocket.generic_label": {
          "anchor_from": "bottom_middle",
          "anchor_to": "bottom_middle",
          "text": "#text",
          "bindings": [
            {
              "binding_name": "#enchant_hint",
              "binding_name_override": "#text"
            }
          ]
        }
      }
    ]
  },

  // Enchanting Book Panel //

  "enchanting_book_panel": {
    "type": "panel",
    "size": [ 40, 40 ],
    "anchor_from": "bottom_left",
    "anchor_to": "bottom_left",
    "controls": [
      {
        "enchanting_book": {
          "type": "custom",
          "renderer": "enchanting_book_renderer",
          "animation_reset_name": "screen_animation_reset",
          "layer": -1,
          "offset": [ 0, 0 ],
          "anims": [
            "@common.screen_exit_size_animation_push",
            "@common.screen_exit_size_animation_pop",
            "@common.screen_entrance_size_animation_push",
            "@common.screen_entrance_size_animation_pop"
          ],
          "bindings": [
            {
              "binding_name": "#open",
              "binding_type": "global"
            }
          ]
        }
      },
      {
        "player_level_label@enchanting_pocket.generic_label": {
          "offset": [ 0, -9 ],
          "font_type": "rune",
          // This doesn't need loc because it is being converted to the rune font.
          "text": "Level",
          "anchor_from": "bottom_middle",
          "anchor_to": "bottom_middle",
          "bindings": [
            {
              "binding_name": "#player_level_color",
              "binding_name_override": "#color"
            }
          ]
        }
      },
      {
        "level_label@enchanting_pocket.generic_label": {
          "text": "#text",
          "anchor_from": "bottom_middle",
          "anchor_to": "bottom_middle",
          "bindings": [
            {
              "binding_name": "#player_level_info",
              "binding_name_override": "#text"
            },
            {
              "binding_name": "#player_level_color",
              "binding_name_override": "#color"
            }
          ]
        }
      }
    ]
  },


  // Enchanting Panel //

  "enchanting_contents_panel": {
    "type": "panel",
    "size": [ "100%", 108 ],
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "controls": [
      { "enchanting_slots_panel@enchanting_pocket.enchanting_slots_panel": {} },
      { "enchant_selection_panel@enchanting_pocket.enchant_selection_panel": {} },
      { "enchanting_confirm_panel@enchanting_pocket.enchanting_confirm_panel": {} },
      { "enchanting_book_panel@enchanting_pocket.enchanting_book_panel": {} }
    ]
  },

  // Half Screens //

  "half_screen": {
    "type": "input_panel"
  },

  "inventory_half_screen@enchanting_pocket.half_screen": {
    "offset": [ 8, 31 ],
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "size": [ "45%-4px", "100%-35px" ],
    "controls": [
      { "inventory_content@enchanting_pocket.inventory_content": {} }
    ]
  },

  "enchanting_half_screen@enchanting_pocket.half_screen": {
    "offset": [ -4, 31 ],
    "size": [ "55%-8px", "100%-35px" ],
    "anchor_from": "top_right",
    "anchor_to": "top_right",
    "controls": [
      { "enchanting_contents_panel@enchanting_pocket.enchanting_contents_panel": { "layer": 1 } }
    ]
  },

  // Header //

  "header": {
    "type": "panel",
    "size": [ "100%", 28 ],
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "controls": [
      {
        "header_background": {
          "type": "image",
          "texture": "textures/ui/header_bar"
        }
      },
      { "legacy_pocket_close_button@common.legacy_pocket_close_button": {} },
      {
        "panel": {
          "type": "panel",
          "anchor_from": "center",
          "anchor_to": "center",
          "controls": [
            {
              "title_label@enchanting_pocket.generic_label": {
                "text": "$container_title",
                "layer": 1
              }
            }
          ]
        }
      }
    ]
  },

  // Output error label //

  "anim_error_text_alpha": {
    "anim_type": "alpha",
    "easing": "in_expo",
    "destroy_at_end": "item_text_label",
    "duration": 2,
    "from": 1.0,
    "to": 0
  },
  "error_text_panel": {
    "type": "panel",
    "anchor_from": "bottom_middle",
    "offset": [ 0, "-20%+10px" ],
    "layer": 30,
    "controls": [
      {
        "item_text_label@enchanting_pocket.generic_label": {
          "text": "#enchant_error",
          "alpha": "@enchanting_pocket.anim_error_text_alpha"
        }
      }
    ]
  },

  // Enchanting Screen //

  "enchanting_panel": {
    "type": "panel",
    "controls": [
      { "header@enchanting_pocket.header": { "layer": 2 } },
      { "bg@enchanting_pocket.background_image": {} },
      { "root_panel@common.root_panel": {} },
      {
        "enchant_error_factory": {
          "type": "factory",
          "control_name": "@enchanting_pocket.error_text_panel",
          "layer": 3
        }
      },
      {
        "inventory_half_screen@enchanting_pocket.inventory_half_screen": {
          "layer": 1,
          "$pane_collection": "combined_hotbar_and_inventory_items", // Only put in to not break Norse Mythology Resource Pack, check later if uneeded
          "$container_size": 36 // Only put in to not break Norse Mythology Resource Pack, check later if uneeded
        }
      },
      { "enchanting_half_screen@enchanting_pocket.enchanting_half_screen": { "layer": 2 } },

      { "container_gamepad_helpers@common.container_gamepad_helpers": { "layer": 2 } },
      { "inventory_selected_icon_button@common.inventory_selected_icon_button": {} },
      { "hold_icon@common.inventory_take_progress_icon_button": {} },
      { "flying_item_renderer@common.flying_item_renderer": {} },
      { "selected_item_details_factory@common.selected_item_details_factory": {} },
      {
        "item_lock_notification_factory@common.item_lock_notification_factory": {
          "$offset": [ 0, "85%" ]
        }
      }
    ]
  }
}