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

{
  "namespace": "trade2",

  //---------------------------------------------------------------------------
  // #region Common Images
  //---------------------------------------------------------------------------

  "toolbar_background": {
    "type": "image",
    "texture": "textures/ui/toolbar_background"
  },

  "arrow_left_image": {
    "type": "image",
    "size": [ 16, 13 ],
    "texture": "textures/ui/arrow_dark_left_stretch"
  },

  "arrow_right_image": {
    "type": "image",
    "size": [ 16, 13 ],
    "texture": "textures/ui/arrow_dark_right_stretch"
  },

  "trade_cell_image": {
    "type": "image",
    "layer": 1,
    "bindings": [
      {
        "binding_name": "#trade_cell_background_texture",
        "binding_name_override": "#texture",
        "binding_type": "collection",
        "binding_collection_name": "$collection_name",
        "binding_condition": "always_when_visible"
      }
    ]
  },

  "cross_out_image": {
    "type": "image",
    "texture": "textures/ui/crossout",
    "layer": 1,
    "size": [ 15, 15 ]
  },

  "lock_image": {
    "type": "image",
    "size": [ 8, 8 ],
    "texture": "textures/ui/lock",
    "color": "$trade_lock_color"
  },

  "scroll_background_image": {
    "type": "image",
    "texture": "textures/ui/background_with_border",
    "layer": 3
  },

  "red_slash": {
    "type": "image",
    "texture": "textures/ui/red_slash"
  },

  "blue_progress_bar": {
    "type": "image",
    "texture": "textures/ui/experience_bar_full_blue",
    "clip_direction": "left",
    "clip_pixelperfect": false
  },

  "white_progress_bar": {
    "type": "image",
    "texture": "textures/ui/experience_bar_full_white",
    "clip_direction": "left",
    "clip_pixelperfect": false
  },

  "empty_progress_bar": {
    "type": "image",
    "texture": "textures/ui/experience_bar_empty_blue"
  },

  "progress_bar_nub": {
    "type": "image",
    "texture": "textures/ui/experience_bar_nub_blue",
    "tiled": true
  },

  // #endregion

  //---------------------------------------------------------------------------
  // #region Trade List Items
  //---------------------------------------------------------------------------

  "hover_button": {
    "type": "button",
    "layer": 1,
    "default_focus_precedence": 1,
    "hover_control": "hover_text",
    "consume_event": false,
    "button_mappings": [
      {
        "to_button_id": "button.container_slot_hovered",
        "mapping_type": "pressed",
        "consume_event": false
      }
    ],
    "controls": [
      {
        "hover_text@common.hover_text": {
          "bindings": [
            {
              "binding_type": "collection_details"
            },
            {
              "binding_name": "#hover_text",
              "binding_condition": "visible"
            }
          ]
        }
      }
    ],
    "bindings": [
      {
        "binding_type": "collection_details"
      },
      {
        "binding_name": "(not #using_touch)",
        "binding_name_override": "#visible"
      }
    ]
  },

  "stack_count_label": {
    "type": "label",
    "color": "$item_stack_count_color",
    "shadow": true
  },

  "changed_item_count_label": {
    "type": "stack_panel",
    "orientation": "horizontal",
    "size": [ "100%c", "100%cm" ],
    "controls": [
      {
        "stack_count_label@trade2.stack_count_label": {
          "layer": 2,
          "text": "#trade_item_count",
          "bindings": [
            {
              "binding_type": "collection_details"
            },
            {
              "binding_name": "#trade_item_count"
            }
          ],
          "controls": [
            {
              "red_slash@trade2.red_slash": {
                "size": [ 6, 2 ],
                "offset": [ 0, -4 ],
                "anchor_to": "bottom_right",
                "anchor_from": "bottom_right",
                "layer": 3,
                "bindings": [
                  {
                    "binding_type": "collection_details"
                  },
                  {
                    "binding_name": "#single_slash_visible",
                    "binding_name_override": "#visible"
                  }
                ]
              }
            },
            {
              "red_slash_double@trade2.red_slash": {
                "size": [ 12, 2 ],
                "offset": [ 0, -4 ],
                "anchor_to": "bottom_right",
                "anchor_from": "bottom_right",
                "layer": 3,
                "bindings": [
                  {
                    "binding_type": "collection_details"
                  },
                  {
                    "binding_name": "#double_slash_visible",
                    "binding_name_override": "#visible"
                  }
                ]
              }
            }
          ]
        }
      },
      {
        "padding": {
          "type": "panel",
          "size": [ 2, 0 ]
        }
      },
      {
        "second_stack_count_label@trade2.stack_count_label": {
          "layer": 2,
          "text": "#second_trade_item_count",
          "bindings": [
            {
              "binding_type": "collection_details"
            },
            {
              "binding_name": "#second_trade_item_count"
            }
          ]
        }
      }
    ]
  },

  "single_item_grid": {
    "type": "grid",
    "size": [ "100%c", "100%c" ],
    "grid_dimensions": [ 1, 1 ],
    "controls": [
      {
        "item_with_count": {
          "type": "panel",
          "size": [ "100%cm", "100%cm" ],
          "$stack_count_required": true,
          "controls": [
            {
              "item_renderer@common.item_renderer": {
                "size": "$item_renderer_size",
                "$item_renderer_size|default": [ 16, 16 ],

                "layer": 1,
                "bindings": [
                  {
                    "binding_type": "collection_details"
                  },
                  {
                    "binding_name": "#item_id_aux"
                  },
                  {
                    "binding_name": "#item_custom_color"
                  },
                  {
                    "binding_name": "#item_pickup_time"
                  },
                  {
                    "binding_name": "#banner_patterns"
                  },
                  {
                    "binding_name": "#banner_colors"
                  },
                  {
                    "binding_name": "#banner_type"
                  }
                ],
                "controls": [
                  {
                    "stack_count_label@trade2.stack_count_label": {
                      "layer": 2,
                      "text": "#trade_item_count",
                      "anchor_from": "bottom_right",
                      "anchor_to": "bottom_right",
                      "offset": [ 1, 1 ],
                      "bindings": [
                        {
                          "binding_type": "collection_details"
                        },
                        {
                          "binding_name": "#trade_item_count"
                        },
                        {
                          "binding_name": "(not #trade_price_different)",
                          "binding_name_override": "#visible"
                        }
                      ]
                    }
                  },
                  {
                    "changed_item_count_label@trade2.changed_item_count_label": {
                      "anchor_from": "bottom_middle",
                      "anchor_to": "bottom_middle",
                      "offset": [ 4, 1 ],
                      "bindings": [
                        {
                          "binding_type": "collection_details"
                        },
                        {
                          "binding_name": "#trade_item_count"
                        },
                        {
                          "binding_name": "#trade_price_different",
                          "binding_name_override": "#visible"
                        }
                      ]
                    }
                  },
                  { "hover_button@trade2.hover_button": {} }
                ]
              }
            }
          ]
        }
      }
    ]
  },

  "trade_item_1@trade2.single_item_grid": {
    "collection_name": "trade_item_1"
  },

  "trade_item_2@trade2.single_item_grid": {
    "collection_name": "trade_item_2"
  },

  "sell_item@trade2.single_item_grid": {
    "collection_name": "sell_item"
  },

  // #endregion

  //---------------------------------------------------------------------------
  // #region Trade Toggle List
  //---------------------------------------------------------------------------

  "arrow_holder": {
    "type": "panel",
    "size": [ 16, 0 ],
    "controls": [
      {
        "arrow_image@trade2.arrow_right_image": {
          "bindings": [
            {
              "binding_type": "collection_details"
            },
            {
              "binding_name": "#trade_toggle_enabled",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "cross_out_image@trade2.cross_out_image": {
          "layer": 2,
          "anchor_from": "right_middle",
          "anchor_to": "right_middle",
          "bindings": [
            {
              "binding_type": "collection_details"
            },
            {
              "binding_name": "#trade_cross_out_visible",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "lock_image@trade2.lock_image": {
          "bindings": [
            {
              "binding_type": "collection_details"
            },
            {
              "binding_name": "(not #trade_toggle_enabled)",
              "binding_name_override": "#visible"
            }
          ]
        }
      }
    ]
  },

  "toggle_content": {
    "type": "stack_panel",
    "size": [ "100%", "100%cm" ],
    "orientation": "horizontal",

    "controls": [
      {
        "padding_1": {
          "type": "panel",
          "size": [ "fill", 0 ]
        }
      },
      {
        "trade_item_1@trade2.trade_item_1": {
          "layer": 2
        }
      },
      {
        "padding_2": {
          "type": "panel",
          "size": [ 2, 0 ]
        }
      },
      {
        "padding_2_extra": {
          "type": "panel",
          "size": [ 10, 0 ],
          "bindings": [
            {
              "binding_type": "collection_details"
            },
            {
              "binding_name": "(not #padding_around_sell_item)",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "trade_item_2@trade2.trade_item_2": {
          "layer": 2
        }
      },
      {
        "padding_3": {
          "type": "panel",
          "size": [ 2, 0 ]
        }
      },
      {
        "padding_3_extra": {
          "type": "panel",
          "size": [ 6, 0 ],
          "bindings": [
            {
              "binding_type": "collection_details"
            },
            {
              "binding_name": "(not #padding_around_sell_item)",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "arrow_holder@trade2.arrow_holder": {
          "inherit_max_sibling_height": true
        }
      },
      {
        "padding_4": {
          "type": "panel",
          "size": [ 2, 0 ]
        }
      },
      {
        "sell_item_holder": {
          "type": "panel",
          "size": [ "200%c", "100%c" ],
          "layer": 2,
          "controls": [
            { "sell_item@trade2.sell_item": {} }
          ],
          "bindings": [
            {
              "binding_type": "collection_details"
            },
            {
              "binding_name": "#padding_around_sell_item",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "sell_item_holder_with_less_padding": {
          "type": "panel",
          "size": [ "150%c", "100%c" ],
          "layer": 2,
          "controls": [
            { "sell_item@trade2.sell_item": {} }
          ],
          "bindings": [
            {
              "binding_type": "collection_details"
            },
            {
              "binding_name": "(not #padding_around_sell_item)",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "padding_5": {
          "type": "panel",
          "size": [ "fill", 0 ]
        }
      }
    ]
  },

  "toggle_content_holder": {
    "type": "panel",
    "size": [ "100%", "100%" ],
    "$toggle_content_control|default": "trade2.toggle_content",
    "controls": [
      { "toggle_content@$toggle_content_control": {} }
    ]
  },

  "trade_toggle_unchecked": {
    "type": "panel",
    "controls": [
      {
        "toggle_checked_normal@common_toggles.toggle_unchecked": {
          "bindings": [
            {
              "binding_type": "collection_details"
            },
            {
              "binding_name": "#trade_possible",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "toggle_checked_red@common_toggles.toggle_unchecked": {
          "$new_ui_button_texture": "textures/ui/button_trade_red",
          "bindings": [
            {
              "binding_type": "collection_details"
            },
            {
              "binding_name": "(not #trade_possible)",
              "binding_name_override": "#visible"
            }
          ]
        }
      }
    ]
  },

  "trade_toggle_checked": {
    "type": "panel",
    "controls": [
      {
        "toggle_checked_normal@common_toggles.toggle_checked": {
          "bindings": [
            {
              "binding_type": "collection_details"
            },
            {
              "binding_name": "#trade_possible",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "toggle_checked_red@common_toggles.toggle_checked": {
          "$new_ui_button_texture": "textures/ui/button_trade_red_pressed",
          "bindings": [
            {
              "binding_type": "collection_details"
            },
            {
              "binding_name": "(not #trade_possible)",
              "binding_name_override": "#visible"
            }
          ]
        }
      }
    ]
  },

  "trade_toggle_locked@common_toggles.toggle_locked": {
    "$border_visible": false
  },

  "trade_actual_toggle@common.toggle": {
    "button_mappings": [
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "button.trade_select",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_secondary_select",
        "to_button_id": "button.trade_secondary_select",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.trade_select",
        "mapping_type": "focused"
      },
      {
        "to_button_id": "button.trade_toggle_hovered",
        "mapping_type": "pressed"
      }
    ]
  },

  "trade_toggle@common_toggles.light_image_toggle_collection": {
    "layer": 2,
    "size": "$toggle_size",

    "$toggle_size|default": [ "100%", 24 ],

    "$toggle_name": "trade_toggle",
    "$template_toggle": "trade2.trade_actual_toggle",

    "$toggle_binding_type": "global",
    "$toggle_state_binding_name": "#trade_toggle_state",

    "$toggle_enabled_binding_type": "global",
    "$toggle_enabled_binding_name": "#trade_toggle_enabled",
    "$toggle_enabled_binding_condition": "always_when_visible",

    "$button_content": "trade2.toggle_content_holder",

    "$unchecked_control": "trade2.trade_toggle_unchecked",
    "$checked_control": "trade2.trade_toggle_checked",
    "$unchecked_locked_control": "trade2.trade_toggle_locked",
    "$unchecked_locked_hover_control": "trade2.trade_toggle_locked",
    "$checked_locked_control": "trade2.trade_toggle_locked",
    "$checked_locked_hover_control": "trade2.trade_toggle_locked"
  },

  "trade_toggle_holder": {
    "type": "panel",
    "size": [ "100%", "100%c - 1px" ],
    "controls": [
      {
        "trade_toggle@trade2.trade_toggle": {
          "anchor_from": "top_middle",
          "anchor_to": "top_middle"
        }
      }
    ]
  },

  "trade_toggle_stack_panel": {
    "type": "stack_panel",
    "orientation": "vertical",
    "size": [ "100%", "default" ],

    "factory": {
      "name": "selected_pack_factory",
      "control_name": "trade2.trade_toggle_holder"
    },

    "$trade_collection_name": "trades",
    "collection_name": "$trade_collection_name",
    "bindings": [
      {
        "binding_name": "#trade_tier_total",
        "binding_name_override": "#collection_length",
        "binding_type": "collection",
        "binding_collection_name": "$collection_name"
      }
    ]
  },

  "tier_label": {
    "type": "label",
    "color": "$trade_tier_name_color",
    "text": "#tier_name",
    "bindings": [
      {
        "binding_name": "#tier_name",
        "binding_type": "collection",
        "binding_collection_name": "$collection_name"
      },
      {
        "binding_name": "#is_tier_unlocked",
        "binding_name_override": "#visible",
        "binding_type": "collection",
        "binding_collection_name": "$collection_name",
        "binding_condition": "always"
      }
    ]
  },

  "tier_label_locked": {
    "type": "label",
    "color": "$trade_tier_name_locked_color",
    "text": "#tier_name",
    "bindings": [
      {
        "binding_name": "#tier_name",
        "binding_type": "collection",
        "binding_collection_name": "$collection_name"
      },
      {
        "binding_name": "(not #is_tier_unlocked)",
        "binding_name_override": "#visible",
        "binding_type": "collection",
        "binding_collection_name": "$collection_name",
        "binding_condition": "always"
      }
    ]
  },

  "tier_stack_panel": {
    "type": "stack_panel",
    "size": [ "100%", "100%c + 1px" ],
    "orientation": "vertical",
    "controls": [
      {
        "padding": {
          "type": "panel",
          "size": [ 0, 2 ]
        }
      },
      {
        "tier_label_holder": {
          "type": "panel",
          "size": [ "100%", "100%cm" ],
          "controls": [
            {
              "tier_label@trade2.tier_label": {
                "size": [ "100%", "default" ],
                "offset": [ 2, 0 ],
                "layer": 2
              }
            },
            {
              "tier_label_locked@trade2.tier_label_locked": {
                "size": [ "100%", "default" ],
                "offset": [ 2, 0 ],
                "layer": 2
              }
            }
          ],
          "bindings": [
            {
              "binding_name": "#show_level",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      { "trade_toggle_stack_panel@trade2.trade_toggle_stack_panel": {} }
    ],
    "bindings": [
      {
        "binding_name": "#tier_visible",
        "binding_name_override": "#visible",
        "binding_type": "collection",
        "binding_collection_name": "$collection_name",
        "binding_condition": "always"
      }
    ]
  },

  "trade_selector_stack_panel": {
    "type": "stack_panel",
    "orientation": "vertical",
    "size": [ "100% - 4px", "default" ],

    "factory": {
      "name": "selected_pack_factory",
      "control_name": "trade2.tier_stack_panel"
    },

    "collection_name": "$collection_name",
    "bindings": [
      {
        "binding_name": "#trade_selector_total",
        "binding_name_override": "#collection_length"
      }
    ]
  },

  "scroll_inner_input_panel@common.root_panel": {
    "type": "input_panel",
    "size": [ "100%", "100%c + 2px" ],
    "controls": [
      { "trade_selector_stack_panel@trade2.trade_selector_stack_panel": {} }
    ]
  },

  "trade_scroll_panel@common.container_scroll_panel": {
    "size": [ "100% - 12px", "100% - 12px" ],

    "$scrolling_content": "trade2.scroll_inner_input_panel",
    "$collection_name": "trade_tiers",

    "$scroll_background_image_control": "trade2.scroll_background_image"
  },

  "left_panel@common.root_panel": {
    "size": [ 136, 166 ],
    "controls": [
      {
        "bg@common.common_panel": {
          "$show_close_button": false
        }
      },
      { "trade_scroll_panel@trade2.trade_scroll_panel": {} }
    ]
  },

  // #endregion

  //---------------------------------------------------------------------------
  // #region XP Bar
  //---------------------------------------------------------------------------

  "exp_progress_bar": {
    "type": "panel",
    "size": [ 153, 5 ],
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "offset": [ 0, 17 ],
    "bindings": [
      {
        "binding_name": "#exp_bar_visible",
        "binding_name_override": "#visible"
      }
    ],
    "controls": [
      {
        "empty_progress_bar@trade2.empty_progress_bar": {
          "layer": 1,
          "controls": [
            {
              "progress_bar_nub@trade2.progress_bar_nub": {
                "layer": 3,
                "size": [ "100% - 10px", "100%" ]
              }
            },
            {
              "blue_progress_bar@trade2.blue_progress_bar": {
                "layer": 2,
                "bindings": [
                  {
                    "binding_name": "#exp_progress",
                    "binding_name_override": "#clip_ratio",
                    "binding_type": "global",
                    "binding_condition": "always_when_visible"
                  }
                ]
              }
            },
            {
              "white_progress_bar@trade2.white_progress_bar": {
                "layer": 1,
                "bindings": [
                  {
                    "binding_name": "#exp_possible_progress",
                    "binding_name_override": "#clip_ratio",
                    "binding_type": "global",
                    "binding_condition": "always_when_visible"
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  },

  // #endregion

  //---------------------------------------------------------------------------
  // #region Touch Details Buttons
  //---------------------------------------------------------------------------

  "anim_trade_details_alpha": {
    "anim_type": "alpha",
    "easing": "in_quint",
    "destroy_at_end": "trade_details",
    "duration": 2,
    "from": 1.0,
    "to": 0
  },

  "trade_details": {
    "type": "panel",
    "size": [ "100%c", "100%c" ],
    "offset": [ 0, 0 ],
    "anchor_to": "bottom_middle",
    "anchor_from": "bottom_middle",
    "layer": 30,

    "$alpha_anim|default": "@trade2.anim_trade_details_alpha",

    "controls": [
      {
        "item_panel_image": {
          "type": "image",
          "size": [ "100%c + 8px", "100%c + 8px" ],
          "layer": 30,

          "alpha": "$alpha_anim",
          "texture": "textures/ui/purpleBorder",

          "controls": [
            {
              "item_text_label": {
                "type": "label",
                "max_size": [ 80, 60 ],
                "layer": 1,

                "alpha": "$alpha_anim",
                "text": "#selected_hover_text",
                "color": "$item_hover_text_color"
              }
            }
          ]
        }
      }
    ]
  },

  "trade_details_factory": {
    "type": "factory",
    "control_name": "@trade2.trade_details",
    "size": [ 0, 0 ]
  },

  "trade_details_factory_holder": {
    "type": "panel",
    "size": [ 0, 0 ],
    "layer": "$factory_layer",
    "$factory_name|default": "trade_details_factory",
    "$factory_layer|default": 1,
    "controls": [
      { "$factory_name@trade2.trade_details_factory": {} }
    ]
  },

  "trade_details_button@common_buttons.light_text_button": {
    "size": [ 28, 18 ],
    "$button_image_size": [ "100%", "100%" ],
    "$button_content_size": [ "100% - 4px", "100% - 4px" ],
    "$pressed_button_name": "button.trade_details",
    "$button_text": "trade.excalamation",
    "$border_visible": false
  },

  "trade_details_1_button@trade2.trade_details_button": {
    "$pressed_button_name": "button.trade_details_1",
    "bindings": [
      {
        "binding_name": "#trade_details_button_1_visible",
        "binding_name_override": "#visible"
      }
    ]
  },

  "trade_details_2_button@trade2.trade_details_button": {
    "$pressed_button_name": "button.trade_details_2",
    "bindings": [
      {
        "binding_name": "#trade_details_button_2_visible",
        "binding_name_override": "#visible"
      }
    ]
  },

  "enchantment_details_button@trade2.trade_details_button": {
    "$pressed_button_name": "button.enchantment_details",
    "$button_text": "trade.mysteriousText",
    "$font_type": "rune",

    "$default_button_texture": "textures/ui/button_purple",
    "$default_text_color": "$enchantment_button_default_text_color",

    "bindings": [
      {
        "binding_name": "#enchantment_details_button_visible",
        "binding_name_override": "#visible"
      }
    ]
  },

  // #endregion

  //---------------------------------------------------------------------------
  // #region Ingredient and Result Slots
  //---------------------------------------------------------------------------

  "trade_result_item_slot_button@common.container_slot_button_prototype": {
    "button_mappings": [
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "button.trade_take_all_place_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.trade_take_all_place_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_secondary_select",
        "to_button_id": "button.trade_take_all_place_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_select",
        "to_button_id": "button.trade_take_all_place_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_auto_place",
        "to_button_id": "button.container_auto_place",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_secondary_select",
        "to_button_id": "button.container_auto_place",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_inventory_drop",
        "to_button_id": "button.drop_one",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_inventory_drop_all",
        "to_button_id": "button.drop_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "button.trade_coalesce_stack",
        "mapping_type": "double_pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.trade_coalesce_stack",
        "mapping_type": "double_pressed"
      },
      {
        "to_button_id": "button.container_slot_hovered",
        "mapping_type": "pressed"
      }
    ]
  },

  "red_cell_image": {
    "type": "image",
    "texture": "textures/ui/cell_image_red"
  },

  "container_cell_image": {
    "type": "panel",
    "$cell_image_binding_condition|default": "none",
    "controls": [
      {
        "cell_image@common.cell_image": {
          "bindings": [
            {
              "binding_name": "#item_valid",
              "binding_name_override": "#visible",
              "binding_type": "collection",
              "binding_collection_name": "$item_collection_name",
              "binding_condition": "$cell_image_binding_condition"
            }
          ]
        }
      },
      {
        "red_cell_image@trade2.red_cell_image": {
          "bindings": [
            {
              "binding_name": "(not #item_valid)",
              "binding_name_override": "#visible",
              "binding_type": "collection",
              "binding_collection_name": "$item_collection_name",
              "binding_condition": "$cell_image_binding_condition"
            }
          ]
        }
      }
    ]
  },

  "item_slot@common.container_item": {
    "anchor_from": "center",
    "anchor_to": "center",
    "size": [ 28, 28 ],
    "$cell_image_size": [ 28, 28 ],
    "$item_renderer_panel_size": [ 24, 24 ],
    "$item_renderer_size": [ 24, 24 ],
    "$background_images": "trade2.container_cell_image",

    "$item_renderer_binding_condition": "always_when_visible",
    "$stack_count_binding_condition": "always_when_visible",
    "$cell_image_binding_condition": "always"
  },

  "ingredient_1_item_slot@trade2.item_slot": {
    "$item_collection_name": "trade2_ingredient1_item"
  },

  "ingredient_2_item_slot@trade2.item_slot": {
    "$item_collection_name": "trade2_ingredient2_item"
  },

  "result_item_slot@trade2.item_slot": {
    "$item_collection_name": "trade2_result_item",
    "$button_ref": "trade2.trade_result_item_slot_button"
  },

  "item_slot_holder": {
    "type": "panel",
    "size": [ "100%cm", "100%cm" ],

    "$item_slot_control|default": "",
    "$item_details_control|default": "",
    "$factory_name|default": "",

    "controls": [
      { "ingredient_1_item_slot@$item_slot_control": {} },
      {
        "trade_details_1_button@$item_details_control": {
          "size": [ 0, 12 ],
          "inherit_max_sibling_width": true,
          "anchor_from": "bottom_middle",
          "anchor_to": "top_middle"
        }
      },
      {
        "trade_details_1_factory_holder@trade2.trade_details_factory_holder": {
          "anchor_from": "top_middle",
          "anchor_to": "bottom_middle"
        }
      }
    ]
  },

  "item_slots_stack_panel": {
    "type": "stack_panel",
    "orientation": "horizontal",
    "size": [ 96, "100%cm" ],
    "controls": [
      {
        "ingredient_item_1_holder@trade2.item_slot_holder": {
          "$item_slot_control": "trade2.ingredient_1_item_slot",
          "$item_details_control": "trade2.trade_details_1_button",
          "$factory_name": "trade_details_1_factory"
        }
      },
      {
        "ingredient_item_2_holder@trade2.item_slot_holder": {
          "ignored": "$second_item_slot_ignored",
          "$item_slot_control": "trade2.ingredient_2_item_slot",
          "$item_details_control": "trade2.trade_details_2_button",
          "$factory_name": "trade_details_2_factory",
          "$factory_layer": 4
        }
      },
      {
        "pointing_right_arrow_holder": {
          "type": "panel",
          "size": [ "fill", 0 ],
          "inherit_max_sibling_height": true,
          "controls": [
            {
              "arrow_right_image@trade2.arrow_right_image": {
                "size": [ "100% + 3px", 13 ],
                "anchor_from": "top_left",
                "anchor_to": "top_left",
                "offset": [ 0, 2 ]
              }
            }
          ]
        }
      },
      {
        "pointing_left_arrow_holder": {
          "type": "panel",
          "size": [ "fill", 0 ],
          "inherit_max_sibling_height": true,
          "controls": [
            {
              "arrow_left_image@trade2.arrow_left_image": {
                "size": [ "100% + 3px", 13 ],
                "anchor_from": "bottom_right",
                "anchor_to": "bottom_right",
                "offset": [ 0, -2 ]
              }
            }
          ]
        }
      },
      {
        "result_item_slot_holder@trade2.item_slot_holder": {
          "$item_slot_control": "trade2.result_item_slot",
          "$item_details_control": "trade2.enchantment_details_button",
          "$factory_name": "trade_enchantment_details_factory",
          "$factory_layer": 7
        }
      }
    ]
  },

  // #endregion

  //---------------------------------------------------------------------------
  // #region Trade Button and How To Play Button
  //---------------------------------------------------------------------------

  "trade_button@common_buttons.light_text_button": {
    "size": [ 48, 18 ],
    "$pressed_button_name": "button.trade",
    "$button_text": "trade.trade",
    "bindings": [
      {
        "binding_name": "#trade_button_enabled",
        "binding_name_override": "#enabled"
      }
    ]
  },

  "how_to_play_button@common_buttons.light_text_button": {
    "size": [ 18, 18 ],
    "$pressed_button_name": "button.help",
    "$button_text": "trade.question"
  },

  // #endregion

  //---------------------------------------------------------------------------
  // #region Right Panel, Inventory and Trading
  //---------------------------------------------------------------------------

  "top_half_stack_panel": {
    "type": "stack_panel",
    "orientation": "horizontal",
    "size": [ "100%c", "100%cm" ],
    "controls": [
      {
        "item_slots_holder": {
          "type": "panel",
          "size": [ "100%c", "100%c" ],
          "inherit_max_sibling_height": true,
          "controls": [
            { "item_slots_stack_panel@trade2.item_slots_stack_panel": {} }
          ]
        }
      },
      {
        "padding_1": {
          "type": "panel",
          "size": [ 1, 0 ]
        }
      },
      {
        "trade_button_holder": {
          "type": "panel",
          "size": [ "100%c", 0 ],
          "inherit_max_sibling_height": true,
          "controls": [
            { "trade_button@trade2.trade_button": {} }
          ]
        }
      },
      {
        "how_to_play_button_holder": {
          "type": "panel",
          "size": [ "100%c - 1px", 0 ],
          "inherit_max_sibling_height": true,
          "controls": [
            {
              "how_to_play_button@trade2.how_to_play_button": {
                "anchor_from": "right_middle",
                "anchor_to": "right_middle"
              }
            }
          ]
        }
      }
    ]
  },

  "top_half_panel": {
    "type": "panel",
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "size": [ "100% - 14px", "50% - 22px" ],
    "offset": [ 0, 15 ],
    "controls": [
      { "top_half_stack_panel@trade2.top_half_stack_panel": {} }
    ]
  },

  "villager_name_label": {
    "type": "label",
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "offset": [ 0, 5 ],
    "color": "$title_text_color",
    "layer": 1,
    "text": "#name_label",
    "bindings": [
      {
        "binding_name": "#name_label",
        "binding_condition": "always_when_visible"
      }
    ]
  },

  "right_panel@common.root_panel": {
    "layer": 1,
    "controls": [
      {
        "common_panel@common.common_panel": {
          "$show_close_button": false
        }
      },
      {
        "trade_screen_inventory": {
          "type": "panel",
          "layer": 2,
          "controls": [
            { "villager_name_label@trade2.villager_name_label": {} },
            { "exp_progress_bar@trade2.exp_progress_bar": {} },
            { "top_half_panel@trade2.top_half_panel": {} },
            { "inventory_panel_bottom_half_with_label@common.inventory_panel_bottom_half_with_label": {} },
            { "hotbar_grid@common.hotbar_grid_template": {} }
          ]
        }
      }
    ]
  },

  // #endregion

  //---------------------------------------------------------------------------
  // #region toolbar
  //---------------------------------------------------------------------------

  "toolbar_panel@common.root_panel": {
    "size": [ "100%c", 20 ],
    "controls": [
      {
        "toolbar_background@trade2.toolbar_background": {
          "size": [ "100%cm", "100% + 8px" ],
          "offset": [ 0, -3 ],
          "anchor_from": "top_right",
          "anchor_to": "top_right",

          "controls": [
            {
              "toolbar_stack_panel": {
                "type": "stack_panel",
                "orientation": "horizontal",

                "size": [ "default", "100% - 8px" ],
                "offset": [ 0, 3 ],
                "anchor_from": "top_middle",
                "anchor_to": "top_middle",

                "controls": [
                  {
                    "padding_1": {
                      "type": "panel",
                      "size": [ 6, 0 ]
                    }
                  },
                  {
                    "close_button_panel": {
                      "type": "panel",
                      "size": [ "100%c", "100%" ],
                      "bindings": [
                        {
                          "binding_name": "#close_button_visible",
                          "binding_name_override": "#visible"
                        }
                      ],
                      "controls": [
                        {
                          "close_button@common.light_close_button": {
                            "size": [ "100%cm", "100%cm" ],
                            "offset": [ 0, 0 ],
                            "anchor_from": "center",
                            "anchor_to": "center"
                          }
                        }
                      ]
                    }
                  },
                  {
                    "padding_2": {
                      "type": "panel",
                      "size": [ 6, 0 ]
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  },

  "toolbar_anchor": {
    "type": "panel",
    "size": [ 0, 0 ],
    "inherit_max_sibling_height": true,
    "controls": [
      {
        "toolbar_panel@trade2.toolbar_panel": {
          "anchor_from": "top_right",
          "anchor_to": "bottom_right",
          "bindings": [
            {
              "binding_name": "#close_button_visible",
              "binding_name_override": "#visible"
            }
          ]
        }
      }
    ]
  },

  // #endregion

  //---------------------------------------------------------------------------
  // #region screen
  //---------------------------------------------------------------------------

  "center_fold@common.root_panel": {
    "size": [ 4, 166 ],
    "controls": [
      {
        "center_bg": {
          "type": "image",
          "texture": "textures/ui/recipe_back_panel",
          "size": [ "100% + 8px", "100% - 6px" ]
        }
      }
    ]
  },

  "screen_stack_panel": {
    "type": "stack_panel",
    "orientation": "horizontal",
    "size": [ "100%c", "100%cm" ],
    "controls": [
      { "left_panel@trade2.left_panel": {} },
      { "center_fold@trade2.center_fold": {} },
      { "right_panel@trade2.right_panel": {} },
      { "toolbar_anchor@trade2.toolbar_anchor": {} }
    ]
  },

  "gamepad_helper_x@common.gamepad_helper_x": {
    "$gamepad_helper_visible_binding_name": "#gamepad_helper_x_visible",
    "$gamepad_helper_binding_condition": "always"
  },

  "gamepad_helper_y@common.gamepad_helper_y": {
    "$gamepad_helper_visible_binding_name": "#gamepad_helper_y_visible",
    "$gamepad_helper_binding_condition": "always"
  },

  "screen_panel": {
    "type": "panel",
    "controls": [
      { "screen_stack_panel@trade2.screen_stack_panel": {} },

      {
        "container_gamepad_helpers@common.container_gamepad_helpers": {
          "$helper_x_control": "trade2.gamepad_helper_x",
          "$helper_y_control": "trade2.gamepad_helper_y"
        }
      },
      { "selected_item_details_factory@common.selected_item_details_factory": {} },
      { "inventory_selected_icon_button@common.inventory_selected_icon_button": {} },
      { "inventory_take_progress_icon_button@common.inventory_take_progress_icon_button": {} },
      {
        "flying_item_renderer@common.flying_item_renderer": {
          "layer": 20
        }
      }
    ]
  },

  "trade_screen@common.inventory_screen_common": {
    "close_on_player_hurt": true,
    "$screen_bg_content": "common.screen_background",

    "button_mappings": "$button_mappings",

    "variables": [
      {
        "requires": "$desktop_screen",
        "$screen_content": "trade2.screen_panel"
      },
      {
        "requires": "$pocket_screen",
        "$screen_content": "trade2_pocket.screen_panel",
        "$button_mappings": [
          {
            "from_button_id": "button.menu_cancel",
            "to_button_id": "button.menu_exit",
            "mapping_type": "global"
          },
          {
            "from_button_id": "button.menu_inventory_cancel",
            "to_button_id": "button.menu_exit",
            "mapping_type": "global"
          },
          {
            "from_button_id": "button.menu_up",
            "to_button_id": "button.menu_up",
            "mapping_type": "global",
            "scope": "view"
          },
          {
            "from_button_id": "button.menu_down",
            "to_button_id": "button.menu_down",
            "mapping_type": "global",
            "scope": "view"
          },
          {
            "from_button_id": "button.menu_left",
            "to_button_id": "button.menu_left",
            "mapping_type": "global",
            "scope": "view"
          },
          {
            "from_button_id": "button.menu_right",
            "to_button_id": "button.menu_right",
            "mapping_type": "global",
            "scope": "view"
          },
          {
            "from_button_id": "button.menu_select",
            "to_button_id": "button.cursor_drop_all",
            "mapping_type": "pressed"
          },
          {
            "from_button_id": "button.menu_secondary_select",
            "to_button_id": "button.cursor_drop_one",
            "mapping_type": "pressed"
          },
          {
            "from_button_id": "button.menu_ok",
            "to_button_id": "button.cursor_drop_all",
            "mapping_type": "pressed"
          },
          {
            "from_button_id": "button.controller_select",
            "to_button_id": "button.cursor_drop_one",
            "mapping_type": "pressed"
          },
          {
            "from_button_id": "button.controller_secondary_select",
            "to_button_id": "button.cursor_drop_all",
            "mapping_type": "pressed"
          },
          {
            "from_button_id": "button.menu_tab_left",
            "to_button_id": "button.left_panel_tab_decrement",
            "mapping_type": "global"
          },
          {
            "from_button_id": "button.menu_tab_right",
            "to_button_id": "button.menu_tab_right",
            "mapping_type": "global"
          },
          {
            "from_button_id": "button.menu_alternate_tab_left",
            "to_button_id": "button.left_panel_tab_increment",
            "mapping_type": "global"
          },
          {
            "from_button_id": "button.menu_alternate_tab_right",
            "to_button_id": "button.menu_alternate_tab_right",
            "mapping_type": "global"
          },
          {
            "from_button_id": "button.controller_secondary_select_left",
            "to_button_id": "button.focus_left",
            "mapping_type": "global"
          },
          {
            "from_button_id": "button.menu_clear",
            "to_button_id": "button.menu_clear",
            "mapping_type": "focused"
          }
        ]
      }
    ],

    "$button_mappings|default": [
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "button.menu_exit",
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.menu_inventory_cancel",
        "to_button_id": "button.menu_exit",
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.menu_up",
        "to_button_id": "button.menu_up",
        "mapping_type": "global",
        "scope": "view"
      },
      {
        "from_button_id": "button.menu_down",
        "to_button_id": "button.menu_down",
        "mapping_type": "global",
        "scope": "view"
      },
      {
        "from_button_id": "button.menu_left",
        "to_button_id": "button.menu_left",
        "mapping_type": "global",
        "scope": "view"
      },
      {
        "from_button_id": "button.menu_right",
        "to_button_id": "button.menu_right",
        "mapping_type": "global",
        "scope": "view"
      },
      {
        "from_button_id": "button.menu_select",
        "to_button_id": "button.cursor_drop_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_secondary_select",
        "to_button_id": "button.cursor_drop_one",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.menu_ok",
        "to_button_id": "button.cursor_drop_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_select",
        "to_button_id": "button.cursor_drop_one",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_secondary_select",
        "to_button_id": "button.cursor_drop_all",
        "mapping_type": "pressed"
      },
      {
        "from_button_id": "button.controller_secondary_select_left",
        "to_button_id": "button.focus_left",
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.controller_secondary_select_right",
        "to_button_id": "button.focus_right",
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.chat",
        "to_button_id": "button.chat",
        "mapping_type": "global"
      }
    ]
  }
}

// #endregion