text: define(["exports", "../../../lit-element/lit-element.js", "../../simple-toolbar/lib/simple-button-grid.js", "./hax-ui-styles.js", "./hax-store.js"], function (_exports, _litElement, _simpleButtonGrid, _haxUiStyles, _haxStore) {
    "use strict";
  
    Object.defineProperty(_exports, "__esModule", {
      value: true
    });
    _exports.HaxPicker = void 0;
  
    function _templateObject3_3db666f099b011eb851ed31c596cbbd8() {
      var data = babelHelpers.taggedTemplateLiteral(["\n            <hax-tray-button\n              show-text-label\n              id=\"picker-item-", "\"\n              @click=\"", "\"\n              data-selected=\"", "\"\n              ?disabled=\"", "\"\n              label=\"", "\"\n              icon=\"", "\"\n              icon-position=\"top\"\n            ></hax-tray-button>\n          "]);
  
      _templateObject3_3db666f099b011eb851ed31c596cbbd8 = function _templateObject3_3db666f099b011eb851ed31c596cbbd8() {
        return data;
      };
  
      return data;
    }
  
    function _templateObject2_3db666f099b011eb851ed31c596cbbd8() {
      var data = babelHelpers.taggedTemplateLiteral(["\n      <simple-button-grid cols=\"100px\">\n        ", "\n      </simple-button-grid>\n    "]);
  
      _templateObject2_3db666f099b011eb851ed31c596cbbd8 = function _templateObject2_3db666f099b011eb851ed31c596cbbd8() {
        return data;
      };
  
      return data;
    }
  
    function _templateObject_3db666f099b011eb851ed31c596cbbd8() {
      var data = babelHelpers.taggedTemplateLiteral(["\n        simple-button-grid {\n          overflow-y: auto;\n          margin: var(--hax-ui-spacing-sm);\n          --simple-button-grid-cols: 100px;\n        }\n      "]);
  
      _templateObject_3db666f099b011eb851ed31c596cbbd8 = function _templateObject_3db666f099b011eb851ed31c596cbbd8() {
        return data;
      };
  
      return data;
    }
  
    function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; }
  
    function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  
    /**
     `hax-picker`
     A picker for selecting an item from a list of apps / hax gizmos which require
     a decision to be made. This is used when multiple things match either on upload
     in the add operation of the app or in the gizmo selection to render through,
     such as having multiple ways of presenting an image.
    
    * @demo demo/index.html
    
    @microcopy - the mental model for this element
     - data - this is the app data model for an element which expresses itself to hax
    */
    var HaxPicker = /*#__PURE__*/function (_LitElement) {
      babelHelpers.inherits(HaxPicker, _LitElement);
  
      var _super = _createSuper(HaxPicker);
  
      babelHelpers.createClass(HaxPicker, null, [{
        key: "styles",
        get: function get() {
          return [].concat(babelHelpers.toConsumableArray(_haxUiStyles.HaxComponentStyles), [(0, _litElement.css)(_templateObject_3db666f099b011eb851ed31c596cbbd8())]);
        }
      }]);
  
      function HaxPicker() {
        var _this;
  
        babelHelpers.classCallCheck(this, HaxPicker);
        _this = _super.call(this);
        _this._elements = [];
        _this.selectionList = [];
        _this.pickerType = "gizmo";
        return _this;
      }
  
      babelHelpers.createClass(HaxPicker, [{
        key: "render",
        value: function render() {
          var _this2 = this;
  
          return (0, _litElement.html)(_templateObject2_3db666f099b011eb851ed31c596cbbd8(), this.selectionList.map(function (element, index) {
            return (0, _litElement.html)(_templateObject3_3db666f099b011eb851ed31c596cbbd8(), index, _this2._selected, index, _haxStore.HAXStore.activeGizmo && _haxStore.HAXStore.activeGizmo.tag == element.tag, element.title, element.icon);
          }));
        }
      }, {
        key: "buildOptions",
  
        /**
         * Present options to the user with a modal and selection method that
         * shifts itself to be above everything (stack order)
         * @param  [array] elements  a list of elements for presenting to the user
         * to select between.
         */
        value: function buildOptions(elements) {
          var _this3 = this;
  
          var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "element";
          var title = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "Select an option";
          var pickerType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "gizmo";
          // wipe existing
          this.pickerType = pickerType;
          var tmp = [];
  
          switch (pickerType) {
            // hax gizmo selector
            case "gizmo":
              for (var i in elements) {
                elements[i].__type = type;
                tmp.push({
                  icon: elements[i].gizmo.icon,
                  title: elements[i].gizmo.title,
                  color: elements[i].gizmo.color,
                  tag: elements[i].gizmo.tag
                });
              }
  
              break;
            // app selector
  
            case "app":
              for (var i in elements) {
                tmp.push({
                  icon: elements[i].details.icon,
                  title: elements[i].details.title,
                  color: elements[i].details.color,
                  tag: elements[i].gizmo.tag
                });
              }
  
              break;
            // we don't know what to do with this
  
            default:
              tmp = elements;
              break;
          }
  
          this._elements = elements;
          this.selectionList = babelHelpers.toConsumableArray(tmp); // try to focus on option 0
  
          setTimeout(function () {
            _this3.shadowRoot.querySelector("#picker-item-0").focus();
          }, 50);
        }
        /**
         * Handle the user selecting an app.
         */
  
      }, {
        key: "_selected",
        value: function _selected(e) {
          var key = e.target.getAttribute("data-selected");
          e.preventDefault();
          e.stopPropagation();
  
          if (babelHelpers.typeof(this._elements[key]) !== (typeof undefined === "undefined" ? "undefined" : babelHelpers.typeof(undefined))) {
            // haxElement is a unique case
            if (this.pickerType == "gizmo") {
              this._elements[key].replace = true;
              this.dispatchEvent(new CustomEvent("hax-insert-content", {
                bubbles: true,
                cancelable: true,
                composed: true,
                detail: this._elements[key]
              }));
            } else {
              // bubble this up
              this.dispatchEvent(new CustomEvent("hax-app-picker-selection", {
                bubbles: true,
                cancelable: true,
                composed: true,
                detail: this._elements[key]
              }));
            }
          }
  
          this.close();
        }
      }, {
        key: "close",
        value: function close() {
          window.dispatchEvent(new CustomEvent("simple-modal-hide", {
            bubbles: true,
            cancelable: true,
            detail: {}
          }));
        }
      }], [{
        key: "tag",
        get: function get() {
          return "hax-picker";
        }
      }, {
        key: "properties",
        get: function get() {
          return {
            /**
             * raw element set
             */
            _elements: {
              type: Array
            },
  
            /**
             * Refactored list for selection purposes
             */
            selectionList: {
              type: Array
            },
  
            /**
             * Allow multiple uses
             */
            pickerType: {
              type: String,
              attribute: "picker-type"
            }
          };
        }
      }]);
      return HaxPicker;
    }(_litElement.LitElement);
  
    _exports.HaxPicker = HaxPicker;
    window.customElements.define(HaxPicker.tag, HaxPicker);
  });