{
  "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": [ "85%", "85%" ],
    "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": [ "100%-5px", "100%-5px" ],
    "offset": [ "5px", "2px" ],
    "anchor_to": "top_left",
    "anchor_from": "top_left",
    "controls": [
      {
        "scrolling_panel@common.scrolling_panel": {
          "$allow_scrolling_even_when_content_fits": false,
          "$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, 67 ],
    "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% - 5px" ],
    "controls": [
      {
        "inactive_background@enchanting_pocket.inactive_background": {
          "size": [ "100%", "100%" ]
        }
      },
      {
        "unselectable_button@enchanting_pocket.unselectable_button": {
          "size": [ "100%", "100%" ],
          "layer": 22
        }
      },
      {
        "selectable_button@enchanting_pocket.selectable_button": {
          "size": [ "100%", "100%" ],
          "layer": 22
        }
      },
      {
        "dust@enchanting.dust_template": {
          "anchor_from": "left_middle",
          "anchor_to": "left_middle",
          "size": [ 13, 11 ],
          "offset": [ 1, 0 ],
          "layer": 1
        }
      },
      {
        "rune_text@enchanting_pocket.enchant_text_runes": {
          "layer": 23,
          "offset": [ 20, 2 ]
        }
      },
      { "highlight@enchanting_pocket.show_highlighted_slot_control": { "layer": 3 } }
    ]
  },

  // Enchant Selection Panel //

  "enchant_selection_panel": {
    "type": "panel",
    "size": [ "100%-34px", 72 ],
    "offset": [ 0, 0 ],
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "controls": [
      {
        "grid": {
          "type": "grid",
          "collection_name": "#enchant_buttons",
          "size": [ "100%", "100%" ],
          "layer": 6,
          "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": [ "100%", 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%", 30 ],
    "offset": [ 0, 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_contents_panel": {
    "type": "panel",
    "size": [ 40, 40 ],
    "anchor_from": "center",
    "anchor_to": "center",
    "controls": [
      {
        "enchanting_book": {
          "type": "custom",
          "renderer": "enchanting_book_renderer",
          "animation_reset_name": "screen_animation_reset",
          "layer": 0,
          "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_book_panel": {
    "type": "panel",
    "size": [ "100%", 40 ],
    "controls": [
      { "enchanting_slots_panel@enchanting_pocket.enchanting_book_contents_panel": {} }
    ]
  },



  "enchanting_slots_and_selection": {
    "type": "stack_panel",
    "orientation": "horizontal",
    "size": [ "100%", 67 ],
    "controls": [
      { "enchanting_slots_panel@enchanting_pocket.enchanting_slots_panel": {} },
      {
        "pad1": {
          "type": "panel",
          "size": [ 2, 0 ]
        }
      },
      { "enchant_selection_panel@enchanting_pocket.enchant_selection_panel": {} }
    ]
  },


  // Enchanting Panel //

  "enchanting_contents_panel": {
    "type": "stack_panel",
    "size": [ "85%", "95%" ],
    "offset": [ 0, 0 ],
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "controls": [
      {
        "fill1": {
          "type": "panel",
          "size": [ 0, "fill" ]
        }
      },
      { "enchanting_book_panel@enchanting_pocket.enchanting_book_panel": {} },
      {
        "pad1": {
          "type": "panel",
          "size": [ 0, 4 ]
        }
      },
      { "enchanting_slots_and_selection@enchanting_pocket.enchanting_slots_and_selection": {} },
      {
        "pad2": {
          "type": "panel",
          "size": [ 0, 4 ]
        }
      },
      { "enchanting_confirm_panel@enchanting_pocket.enchanting_confirm_panel": {} },
      {
        "fill2": {
          "type": "panel",
          "size": [ 0, "fill" ]
        }
      }
    ]
  },



  // 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_2"
        }
      },
      { "legacy_pocket_close_button@common.legacy_pocket_close_button": { "offset": [ -3, 3 ] } },
      {
        "panel": {
          "type": "panel",
          "anchor_from": "center",
          "anchor_to": "center",
          "controls": [
            {
              "title_label@enchanting_pocket.generic_label": {
                "layer": 1,
                "shadow": false,
                "text": "$container_title",
                "enable_profanity_filter": true,
                "color": "$title_text_color",
                "localize": "$localize_title"
              }
            }
          ]
        }
      }
    ]
  },

  // Layout Content Panels //

  "inventory_and_enchanting_panel": {
    "type": "panel",
    "controls": [
      {
        "inventory_half_screen": {
          "type": "panel",
          "size": [ "50%", "100%" ],
          "anchor_from": "left_middle",
          "anchor_to": "left_middle",

          "controls": [
            { "inventory_content@enchanting_pocket.inventory_content": {} }
          ]
        }
      },
      {
        "enchanting_half_screen": {
          "type": "panel",
          "size": [ "50%", "100%" ],
          "anchor_from": "right_middle",
          "anchor_to": "right_middle",

          "controls": [
            { "enchanting_content@enchanting_pocket.enchanting_contents_panel": {} }
          ]
        }
      }
    ]
  },

  "header_and_content_stack_panel": {
    "type": "stack_panel",
    "orientation": "vertical",
    "size": [ "85%", "85%" ],
    "controls": [
      { "header@enchanting_pocket.header": { "layer": 2 } },
      {
        "inventory_and_enchanting_panel@enchanting_pocket.inventory_and_enchanting_panel": {
          "size": [ "100%", "fill" ]
        }
      }
    ]
  },

  // 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": [
      { "bg@enchanting_pocket.background_image": {} },
      { "root_panel@common.root_panel": { "size": [ "85%", "85%" ], "layer": 1 } },
      { "header_and_content_stack_panel@enchanting_pocket.header_and_content_stack_panel": {} },

      { "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": {} },
      { "selected_item_details_factory@common.selected_item_details_factory": {} },
      {
        "item_lock_notification_factory@common.item_lock_notification_factory": {
          "$offset": [ 0, "85%" ]
        }
      },
      { "flying_item_renderer@common.flying_item_renderer": { "layer": 12 } }
    ]
  }
}
