text: define(["exports", "../../../lit/index.js", "../../hax-body-behaviors/lib/HAXFields.js", "../../simple-icon/lib/simple-icon-lite.js", "../../hax-iconset/lib/simple-hax-iconset.js", "../../simple-icon/lib/simple-icon-button.js", "../../simple-fields/simple-fields.js", "./hax-store.js", "../../../mobx/dist/mobx.esm.js", "../../i18n-manager/lib/I18NMixin.js"], function (_exports, _index, _HAXFields, _simpleIconLite, _simpleHaxIconset, _simpleIconButton, _simpleFields, _haxStore, _mobxEsm, _I18NMixin2) {
    "use strict";
  
    Object.defineProperty(_exports, "__esModule", {
      value: true
    });
    _exports.HaxPreferencesDialog = void 0;
  
    var _templateObject_ecaf8fd0941711ec8d52c707f928eca0, _templateObject2_ecaf8fd0941711ec8d52c707f928eca0, _templateObject3_ecaf8fd0941711ec8d52c707f928eca0;
  
    function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  
    function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { babelHelpers.defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  
    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 { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  
    /**
     * `hax-preferences-dialog`
     * @element hax-preferences-dialog
     * `Export dialog with all export options and settings provided.`
     */
    var HaxPreferencesDialog = /*#__PURE__*/function (_I18NMixin) {
      babelHelpers.inherits(HaxPreferencesDialog, _I18NMixin);
  
      var _super = _createSuper(HaxPreferencesDialog);
  
      function HaxPreferencesDialog() {
        var _this;
  
        babelHelpers.classCallCheck(this, HaxPreferencesDialog);
        _this = _super.call(this);
        _this.hideLink = false;
        _this.t = {
          learnAboutHAXTheWeb: "Learn about HAXTheWeb",
          voiceCommands: "Voice commands",
          haxUITheme: "HAX UI Theme",
          language: "Language",
          english: "English",
          spanish: "Spanish"
        };
  
        _this.udpateSchema();
  
        _this.registerLocalization({
          context: babelHelpers.assertThisInitialized(_this),
          namespace: "hax",
          updateCallback: "udpateSchema"
        });
  
        (0, _mobxEsm.autorun)(function () {
          _this.globalPreferences = (0, _mobxEsm.toJS)(_haxStore.HAXStore.globalPreferences);
  
          if (_this.globalPreferences.haxLang && _I18NMixin2.I18NManagerStore.lang != _this.globalPreferences.haxLang) {
            _I18NMixin2.I18NManagerStore.lang = _this.globalPreferences.haxLang || "en";
  
            _this.udpateSchema();
          }
        });
        return _this;
      }
  
      babelHelpers.createClass(HaxPreferencesDialog, [{
        key: "udpateSchema",
        value: function udpateSchema() {
          // JSON schema object needs delayed to ensure page repaints the form
          var lang = _I18NMixin2.I18NManagerStore.lang;
  
          if (lang.indexOf("-")) {
            lang = lang.split("-")[0];
          }
  
          this.schema = [{
            property: "haxVoiceCommands",
            title: this.t.voiceCommands,
            description: "Experimental: Voice based control system",
            inputMethod: "boolean",
            value: false
          }, {
            property: "haxUiTheme",
            title: this.t.haxUITheme,
            description: "Change the theme of the HAX interface (not the site's content).",
            inputMethod: "radio",
            options: {
              hax: "Default (light)",
              haxdark: "Dark",
              system: "System Default"
            },
            value: "hax"
          }, {
            property: "haxLang",
            title: this.t.language,
            description: "Toggle between supported languages for internationalization",
            inputMethod: "radio",
            options: {
              en: this.t.english,
              es: this.t.spanish
            },
            value: lang
          }];
          this.schemaValues = {
            haxVoiceCommands: false,
            haxUiTheme: "hax",
            haxLang: lang
          };
  
          if (this.shadowRoot && this.shadowRoot.querySelector("#settingsform")) {
            this.reloadPreferencesForm();
          }
        }
      }, {
        key: "closeBtn",
        value: function closeBtn(e) {
          this.dispatchEvent(new CustomEvent("hax-tray-button-click", {
            bubbles: true,
            cancelable: true,
            composed: true,
            detail: {
              eventName: "open-preferences",
              index: 0,
              value: true
            }
          }));
        }
      }, {
        key: "render",
        value: function render() {
          return (0, _index.html)(_templateObject_ecaf8fd0941711ec8d52c707f928eca0 || (_templateObject_ecaf8fd0941711ec8d52c707f928eca0 = babelHelpers.taggedTemplateLiteral(["\n      <div style=\"height: 100%; overflow: auto;\" class=\"pref-container\">\n        <simple-fields\n          id=\"settingsform\"\n          .schematizer=\"", "\"\n          .elementizer=\"", "\"\n        >\n        </simple-fields>\n      </div>\n      <hr />\n      <br />\n      ", "\n    "])), _HAXFields.HaxSchematizer, _HAXFields.HaxElementizer, !this.hideLink ? (0, _index.html)(_templateObject2_ecaf8fd0941711ec8d52c707f928eca0 || (_templateObject2_ecaf8fd0941711ec8d52c707f928eca0 = babelHelpers.taggedTemplateLiteral(["<a\n            href=\"https://haxtheweb.org/\"\n            rel=\"noopener\"\n            id=\"link\"\n            target=\"_blank\"\n            part=\"haxlink\"\n            ><simple-icon-lite icon=\"hax:hax2022\"></simple-icon-lite> ", "</a\n          >"])), this.t.learnAboutHAXTheWeb) : "");
        }
      }, {
        key: "firstUpdated",
        value: function firstUpdated(changedProperties) {
          this.reloadPreferencesForm();
          this.shadowRoot.querySelector("#settingsform").addEventListener("value-changed", this.__valueChangedEvent.bind(this));
        }
      }, {
        key: "__valueChangedEvent",
        value: function __valueChangedEvent(e) {
          if (e.detail.value) {
            _haxStore.HAXStore.globalPreferences = _objectSpread({}, e.detail.value);
            this.schemaValues = _objectSpread({}, e.detail.value);
          }
        }
        /**
         * force an update of settings
         */
  
      }, {
        key: "reloadPreferencesForm",
        value: function reloadPreferencesForm() {
          this.shadowRoot.querySelector("#settingsform").fields = babelHelpers.toConsumableArray(this.schema);
          this.shadowRoot.querySelector("#settingsform").value = _objectSpread({}, this.schemaValues);
        }
      }], [{
        key: "styles",
        get:
        /**
         * LitElement constructable styles enhancement
         */
        function get() {
          return [(0, _index.css)(_templateObject3_ecaf8fd0941711ec8d52c707f928eca0 || (_templateObject3_ecaf8fd0941711ec8d52c707f928eca0 = babelHelpers.taggedTemplateLiteral(["\n        :host {\n          display: block;\n        }\n        .pref-container {\n          text-align: left;\n        }\n        simple-icon-lite {\n          --simple-icon-height: 36px;\n          --simple-icon-width: 36px;\n        }\n      "])))];
        }
      }, {
        key: "tag",
        get: function get() {
          return "hax-preferences-dialog";
        }
      }, {
        key: "properties",
        get: function get() {
          return {
            /**
             * Developer prop to hide the link
             */
            hideLink: {
              type: Boolean
            },
  
            /**
             * Schema that has all of inputs / manages state
             */
            schema: {
              type: Object
            },
  
            /**
             * Preferences managed for everything global about HAX.
             */
            globalPreferences: {
              type: Object
            }
          };
        }
      }]);
      return HaxPreferencesDialog;
    }((0, _I18NMixin2.I18NMixin)(_index.LitElement));
  
    _exports.HaxPreferencesDialog = HaxPreferencesDialog;
    window.customElements.define(HaxPreferencesDialog.tag, HaxPreferencesDialog);
  });