/********************************************************
+*   (c) Mojang. All rights reserved                       *
+*   (c) Microsoft. All rights reserved.                   *
+*********************************************************/

{
  "namespace": "enchanting",

  "enchanting_image": {
    "type": "image"
  },

  "lapis_image@enchanting.enchanting_image": {
    "anchor_to": "top_left",
    "anchor_from": "top_left",
    "layer": 1,
    "offset": [ 1, 1 ],
    "size": [ 16, 16 ],
    "texture": "textures/ui/lapis_image"
  },

  "dust_image@enchanting.enchanting_image": {
    "anchor_to": "left_middle",
    "anchor_from": "left_middle",
    "offset": [ 3, 0 ],
    "size": [ 13, 11 ],
    "bindings": [
      {
        "binding_name": "$visibility_binding_name",
        "binding_name_override": "#visible",
        "binding_collection_name": "#enchant_buttons",
        "binding_type": "collection"
      }
    ]
  },

  "dust_image_selectable@enchanting.dust_image": {
    "texture": "$texture_selectable",
    "layer": 2,
    "$visibility_binding_name": "#selectable_dust_is_visible"
  },

  "dust_image_unselectable@enchanting.dust_image": {
    "texture": "$texture_unselectable",
    "layer": 1,
    "$visibility_binding_name": "#unselectable_dust_is_visible"
  },

  "dust_template": {
    "type": "panel",
    "controls": [
      { "dust_image_selectable@enchanting.dust_image_selectable": {} },
      { "dust_image_unselectable@enchanting.dust_image_unselectable": {} }
    ]
  },

  "dust_panel": {
    "type": "grid",
    "grid_dimensions": [ 1, 3 ],
    "layer": 5,
    "collection_name": "#enchant_buttons",
    "controls": [
      {
        "a@enchanting.dust_template": {
          "grid_position": [ 0, 0 ],
          "$texture_selectable": "textures/ui/dust_selectable_1",
          "$texture_unselectable": "textures/ui/dust_unselectable_1"
        }
      },
      {
        "b@enchanting.dust_template": {
          "grid_position": [ 0, 1 ],
          "$texture_selectable": "textures/ui/dust_selectable_2",
          "$texture_unselectable": "textures/ui/dust_unselectable_2"
        }
      },
      {
        "c@enchanting.dust_template": {
          "grid_position": [ 0, 2 ],
          "$texture_selectable": "textures/ui/dust_selectable_3",
          "$texture_unselectable": "textures/ui/dust_unselectable_3"
        }
      }
    ]
  },

  "background_with_hover_text@enchanting.enchanting_image": {
    "controls": [
      {
        "hover_text@common.hover_text": {
          "bindings": [
            {
              "binding_name": "#hover_text",
              "binding_collection_name": "#enchant_buttons",
              "binding_type": "collection"
            }
          ]
        }
      }
    ]
  },

  "dark_background@enchanting.enchanting_image": {
    "texture": "textures/ui/enchanting_dark_background"
  },

  "dark_background_with_hover_text@enchanting.background_with_hover_text": {
    "texture": "textures/ui/enchanting_dark_background"
  },

  "active_background@enchanting.enchanting_image": {
    "texture": "textures/ui/enchanting_active_background"
  },

  "active_background_with_hover_text@enchanting.background_with_hover_text": {
    "texture": "textures/ui/enchanting_active_background_with_hover_text"
  },

  "enchant_runes": {
    "type": "label",
    "color": "$enchanting_runes_color",
    "shadow": false,
    "layer": 1,
    "anchor_to": "left_middle",
    "anchor_from": "left_middle",
    "text": "#runes",
    "offset": [ 18, 4 ],
    "size": [ 84, 16 ],
    "font_type": "rune",
    "bindings": [
      {
        "binding_collection_name": "#enchant_buttons",
        "binding_name": "#runes",
        "binding_type": "collection"
      }
    ]
  },

  "enchant_cost": {
    "type": "label",
    "color": "$enchanting_cost_success_color",
    "shadow": true,
    "offset": [ -2, -2 ],
    "layer": 1,
    "anchor_from": "bottom_right",
    "anchor_to": "bottom_right",
    "text": "#cost",
    "bindings": [
      {
        "binding_name": "#cost",
        "binding_collection_name": "#enchant_buttons",
        "binding_type": "collection"
      }
    ]
  },

  "success_runes@enchanting.enchant_runes": {
    "color": "$enchanting_runes_color"
  },

  "fail_runes@enchanting.enchant_runes": {
    "color": "$enchanting_runes_fail_color"
  },

  "success_cost@enchanting.enchant_cost": {
    "color": "$enchanting_cost_success_color"
  },

  "fail_cost@enchanting.enchant_cost": {
    "color": "$enchanting_cost_fail_color"
  },

  "enchanting_label": {
    "type": "label",
    "offset": [ 12, -4 ],
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "text": "$container_title",
    "color": "$title_text_color",
    "layer": 2
  },

  "base_button@common.button": {
    "size": [ "100%", "100%" ],
    "bindings": [
      {
        "binding_name": "$visibility_binding_name",
        "binding_name_override": "#visible",
        "binding_collection_name": "#enchant_buttons",
        "binding_type": "collection"
      },
      {
        "binding_type": "collection_details",
        "binding_collection_name": "#enchant_buttons"
      }
    ]
  },

  "unselectable_button@enchanting.base_button": {
    "$visibility_binding_name": "#unselectable_button_visibility",
    "sound_volume": 0.0,
    "layer": 1,
    "button_mappings": [],
    "controls": [
      { "default@enchanting.dark_background": {} },
      { "hover@enchanting.dark_background_with_hover_text": {} },
      { "pressed@enchanting.dark_background": {} },
      { "rune_text@enchanting.fail_runes": {} },
      { "enchant_cost@enchanting.fail_cost": {} }
    ]
  },

  "selectable_button@enchanting.base_button": {
    "$visibility_binding_name": "#selectable_button_visibility",
    "$focus_override_left": "enchanting_lapis",
    "$focus_override_right": "FOCUS_OVERRIDE_STOP",

    "button_mappings": [
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "button.menu_ok",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.menu_ok",
        "mapping_type": "focused"
      }
    ],
    "controls": [
      { "default@enchanting.active_background": {} },
      { "hover@enchanting.active_background_with_hover_text": {} },
      { "pressed@enchanting.dark_background": {} },
      { "rune_text@enchanting.fail_runes": {} },
      { "enchant_cost@enchanting.success_cost": {} }
    ]
  },

  "enchant_button_panel": {
    "type": "panel",
    "size": [ "100%", "33.333333%" ],
    "layer": 7,
    "controls": [
      { "dark_background@enchanting.dark_background": {} },
      { "unselectable_button@enchanting.unselectable_button": {} },
      { "selectable_button@enchanting.selectable_button": {} }
    ]
  },

  "enchanting_panel_top_half": {
    "type": "panel",
    "size": [ "100%", "50% - 12px" ],
    "offset": [ 0, 7 ],
    "anchor_to": "top_left",
    "anchor_from": "top_left",
    "controls": [
      { "enchanting_label@enchanting.enchanting_label": {} },
      {
        "enchanting_book_panel": {
          "type": "panel",
          "offset": [ 13, -12 ],
          "size": [ 40, 40 ],
          "anchor_from": "left_middle",
          "anchor_to": "left_middle",
          "controls": [
            {
              "enchanting_book": {
                "type": "custom",
                "renderer": "enchanting_book_renderer",
                "layer": 13,
                "animation_reset_name": "screen_animation_reset",
                "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"
                  }
                ]
              }
            }
          ]
        }
      },
      {
        "item_grid": {
          "type": "grid",
          "grid_dimensions": [ 1, 1 ],
          "anchor_from": "left_middle",
          "anchor_to": "left_middle",
          "offset": [ 13, 14 ],
          "size": [ 18, 18 ],
          "collection_name": "enchanting_input_items",
          "controls": [
            {
              "item_slot@common.container_item": {
                "grid_position": [ 0, 0 ],
                "$item_collection_name": "enchanting_input_items"
              }
            }
          ]
        }
      },
      {
        "lapis_grid": {
          "type": "grid",
          "grid_dimensions": [ 1, 1 ],
          "anchor_from": "left_middle",
          "anchor_to": "left_middle",
          "offset": [ 33, 14 ],
          "size": [ 18, 18 ],
          "collection_name": "enchanting_lapis_items",
          "controls": [
            {
              "lapis@common.container_item": {
                "grid_position": [ 0, 0 ],
                "$cell_overlay_ref": "enchanting.lapis_image",
                "$item_collection_name": "enchanting_lapis_items",

                "$focus_id_binding_type": "none",
                "$focus_id": "enchanting_lapis"
              }
            }
          ]
        }
      },
      {
        "grid_panel": {
          "type": "panel",
          "anchor_from": "right_middle",
          "anchor_to": "right_middle",
          "offset": [ -8, 2 ],
          "size": [ "65%-8px", "80%+4px" ],
          "controls": [
            {
              "indent@common.cell_image": {
                "size": [ "100%+2px", "100%+2px" ]
              }
            },
            {
              "dust_panel@enchanting.dust_panel": {
                "anchor_from": "top_left",
                "anchor_to": "top_left",
                "layer": 10
              }
            },
            {
              "enchantments_grid": {
                "type": "grid",
                "collection_name": "#enchant_buttons",
                "size": [ "100%", "100%" ],
                "layer": 2,
                "anchor_from": "center",
                "anchor_to": "center",
                "grid_dimensions": [ 1, 3 ],
                "grid_item_template": "enchanting.enchant_button_panel"
              }
            }
          ]
        }
      }
    ]
  },

  "enchanting_panel": {
    "type": "panel",
    "$use_compact_close_button": true,
    "controls": [
      { "container_gamepad_helpers@common.container_gamepad_helpers": {} },
      {
        "flying_item_renderer@common.flying_item_renderer": {
          "layer": 11
        }
      },
      { "selected_item_details_factory@common.selected_item_details_factory": {} },
      {
        "root_panel@common.root_panel": {
          "layer": 1,
          "controls": [
            { "common_panel@common.common_panel": {} },
            {
              "enchanting_screen_inventory": {
                "type": "panel",
                "layer": 5,
                "controls": [
                  { "enchanting_panel_top_half@enchanting.enchanting_panel_top_half": {} },
                  { "inventory_panel_bottom_half_with_label@common.inventory_panel_bottom_half_with_label": {} },
                  { "hotbar_grid@common.hotbar_grid_template": {} },
                  { "inventory_take_progress_icon_button@common.inventory_take_progress_icon_button": {} }
                ]
              }
            },
            { "inventory_selected_icon_button@common.inventory_selected_icon_button": {} },
            { "gamepad_cursor@common.gamepad_cursor_button": {} }
          ]
        }
      }
    ]
  },
  "enchanting_screen@common.inventory_screen_common": {
    "$close_on_player_hurt|default": true,
    "close_on_player_hurt": "$close_on_player_hurt",
    "variables": [
      {
        "requires": "$desktop_screen",
        "$screen_content": "enchanting.enchanting_panel",
        "$screen_bg_content": "common.screen_background"
      },
      {
        "requires": "$pocket_screen",
        "$screen_content": "enchanting_pocket.enchanting_panel"
      }
    ]
  }
}