{"version":3,"sources":["PreferencesPanel.min__d67acfe80778de2e04cc.js","./src/utils/AccessibleModal.ts","./src/ui/PreferencesPanel/PreferencesPanel.ts","./src/ui/FocusTrap/FocusTrap.ts"],"names":["webpackJsonpCoveo__temporary","179","module","exports","__webpack_require__","__assign","this","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","defineProperty","value","className","ownerElement","modalboxModule","options","ModalBox","sizeMod","get","focusTrap","enumerable","configurable","activeModal","modalBox","content","wrapper","element","querySelector","openResult","parameters","isOpen","openModalAndTrap","validation","origin","title","DomUtils","getQuickviewHeader","result","bindings","el","makeAccessible","open","initiallyFocusedElement","document","activeElement","onModalClose","body","overlayClose","FocusTrap","close","setAttribute","headerElement","makeCloseButtonAccessible","updateFocus","closeButton","l","tabIndex","$$","on","KeyboardUtils","keypressAction","KEYBOARD","ENTER","click","focusOnOpen","focus","disable","contains","AccessibleModal","265","__extends","extendStatics","setPrototypeOf","__proto__","Array","d","b","__","constructor","create","PreferencesPanel","ID","ComponentOptions","initComponentOptions","bind","onRootElement","SettingsEvents","settingsPopulateMenu","args","menuData","push","text","onOpen","onClose","svgIcon","SVGIcons","icons","dropdownPreferences","svgIconClassName","InitializationEvents","afterComponentsInitialization","children","modalbox","searchInterface","modalContainer","_this","root","_","each","oneChild","append","cleanupOnExit","save","trigger","PreferencesPanelEvents","savePreferences","queryController","executeQuery","exitPreferencesWithoutSave","doExport","exportGlobally","Component","Initialization","registerAutoCreateComponent","470","container","focusableSelector","hiddenElements","enable","chain","Dom","nodeListToArray","querySelectorAll","filter","isVisible","sortBy","removeEventListener","focusInEvent","focusOutEvent","showHiddenElements","enabled","addEventListener","e","onFocusIn","onFocusOut","hideAllExcept","pop","removeAttribute","hideElement","getAttribute","hideSiblings","allowedElement","parent","parentElement","without","forEach","elementToHide","getFocusableSibling","previous","elements","focusableElements","currentIndex","indexOf","focusSibling","sibling","focusFirstElement","elementIsBefore","oldElement","newElement","compareDocumentPosition","Node","DOCUMENT_POSITION_PRECEDING","onLosingFocus","Defer","defer","focusIsAllowed","elementIsInPage","relatedTarget","target","638"],"mappings":"AAAAA,8BAA8B,KAExBC,IACA,SAAUC,EAAQC,EAASC,GAEjC,YAEA,IAAIC,GAAYC,MAAQA,KAAKD,UAAaE,OAAOC,QAAU,SAASC,GAChE,IAAK,GAAIC,GAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAAK,CACjDD,EAAIG,UAAUF,EACd,KAAK,GAAII,KAAKL,GAAOH,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KACzDN,EAAEM,GAAKL,EAAEK,IAEjB,MAAON,GAEXF,QAAOY,eAAehB,EAAS,cAAgBiB,OAAO,GCftD,aACA,SACA,OACA,OACA,QAIA,QAwBA,aA0BE,WACUC,EACAC,EACAC,EACRC,OADQ,KAAAD,MAA0C,EAAAE,cAClD,KAAAD,UAHQ,KAAAH,YACA,KAAAC,eACA,KAAAC,iBAGRjB,KAAKkB,QAAU,GAEXE,QAAS,OAERF,GAqFT,MAnHE,uBAAW,sBDJLG,ICIN,WACE,QAASrB,KAAKsB,WDFVC,YAAY,EACZC,cAAc,ICIpB,sBAAW,uBDDLH,ICCN,WACE,MAAOrB,MAAKyB,aAAezB,KAAKyB,YAAYC,UDCxCH,YAAY,EACZC,cAAc,ICCpB,sBAAW,uBDELH,ICFN,WACE,MAAOrB,MAAKyB,aAAezB,KAAKyB,YAAYE,SDIxCJ,YAAY,EACZC,cAAc,ICFpB,sBAAW,uBDKLH,ICLN,WACE,MAAOrB,MAAKyB,aAAezB,KAAKyB,YAAYG,SDOxCL,YAAY,EACZC,cAAc,ICLpB,sBAAY,6BDQNH,ICRN,WACE,MAAOrB,MAAK6B,SAAW7B,KAAK6B,QAAQC,cAA2B,2BDU3DP,YAAY,EACZC,cAAc,ICMb,YAAAO,WAAP,SAAkBC,GACZhC,KAAKiC,SAGTjC,KAAKkC,kBACHP,QAASK,EAAWL,QACpBQ,WAAYH,EAAWG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H,aH2aPmI,IACA,SAAU1L,EAAQC","file":"PreferencesPanel.min__d67acfe80778de2e04cc.js","sourcesContent":["webpackJsonpCoveo__temporary([37],{\n\n/***/ 179:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n    for (var s, i = 1, n = arguments.length; i < n; i++) {\n        s = arguments[i];\n        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n            t[p] = s[p];\n    }\n    return t;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar ExternalModulesShim_1 = __webpack_require__(26);\nvar FocusTrap_1 = __webpack_require__(470);\nvar Strings_1 = __webpack_require__(6);\nvar Dom_1 = __webpack_require__(1);\nvar KeyboardUtils_1 = __webpack_require__(25);\nvar Core_1 = __webpack_require__(20);\nvar AccessibleModal = /** @class */ (function () {\n    function AccessibleModal(className, ownerElement, modalboxModule, options) {\n        if (modalboxModule === void 0) { modalboxModule = ExternalModulesShim_1.ModalBox; }\n        if (options === void 0) { options = {}; }\n        this.className = className;\n        this.ownerElement = ownerElement;\n        this.modalboxModule = modalboxModule;\n        this.options = __assign({\n            sizeMod: 'big'\n        }, options);\n    }\n    Object.defineProperty(AccessibleModal.prototype, \"isOpen\", {\n        get: function () {\n            return !!this.focusTrap;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(AccessibleModal.prototype, \"element\", {\n        get: function () {\n            return this.activeModal && this.activeModal.modalBox;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(AccessibleModal.prototype, \"content\", {\n        get: function () {\n            return this.activeModal && this.activeModal.content;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(AccessibleModal.prototype, \"wrapper\", {\n        get: function () {\n            return this.activeModal && this.activeModal.wrapper;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(AccessibleModal.prototype, \"headerElement\", {\n        get: function () {\n            return this.element && this.element.querySelector('.coveo-modal-header h1');\n        },\n        enumerable: true,\n        configurable: true\n    });\n    AccessibleModal.prototype.openResult = function (parameters) {\n        if (this.isOpen) {\n            return;\n        }\n        this.openModalAndTrap({\n            content: parameters.content,\n            validation: parameters.validation,\n            origin: parameters.origin,\n            title: Core_1.DomUtils.getQuickviewHeader(parameters.result, parameters.options, parameters.bindings).el\n        });\n        this.makeAccessible(parameters.options.title || parameters.result.title);\n    };\n    AccessibleModal.prototype.open = function (parameters) {\n        if (this.isOpen) {\n            return;\n        }\n        this.openModalAndTrap(parameters);\n        this.makeAccessible();\n    };\n    AccessibleModal.prototype.openModalAndTrap = function (parameters) {\n        var _this = this;\n        this.initiallyFocusedElement = parameters.origin || document.activeElement;\n        this.activeModal = this.modalboxModule.open(parameters.content, {\n            title: parameters.title,\n            className: this.className,\n            validation: function () {\n                _this.onModalClose();\n                return parameters.validation();\n            },\n            body: this.ownerElement,\n            sizeMod: this.options.sizeMod,\n            overlayClose: this.options.overlayClose\n        });\n        this.focusTrap = new FocusTrap_1.FocusTrap(this.element);\n    };\n    AccessibleModal.prototype.close = function () {\n        if (!this.isOpen) {\n            return;\n        }\n        this.activeModal.close();\n        this.activeModal = null;\n    };\n    AccessibleModal.prototype.makeAccessible = function (title) {\n        this.element.setAttribute('aria-modal', 'true');\n        if (title) {\n            this.headerElement.setAttribute('aria-label', title);\n        }\n        this.makeCloseButtonAccessible();\n        this.updateFocus();\n    };\n    Object.defineProperty(AccessibleModal.prototype, \"closeButton\", {\n        get: function () {\n            return this.element.querySelector('.coveo-small-close');\n        },\n        enumerable: true,\n        configurable: true\n    });\n    AccessibleModal.prototype.makeCloseButtonAccessible = function () {\n        var closeButton = this.closeButton;\n        closeButton.setAttribute('aria-label', Strings_1.l('Close'));\n        closeButton.setAttribute('role', 'button');\n        closeButton.tabIndex = 0;\n        Dom_1.$$(closeButton).on('keyup', KeyboardUtils_1.KeyboardUtils.keypressAction(KeyboardUtils_1.KEYBOARD.ENTER, function () { return closeButton.click(); }));\n    };\n    AccessibleModal.prototype.updateFocus = function () {\n        var focusOnElement = (this.options.focusOnOpen && this.options.focusOnOpen()) || this.closeButton;\n        focusOnElement.focus();\n    };\n    AccessibleModal.prototype.onModalClose = function () {\n        this.focusTrap.disable();\n        this.focusTrap = null;\n        if (this.initiallyFocusedElement && document.body.contains(this.initiallyFocusedElement)) {\n            this.initiallyFocusedElement.focus();\n        }\n    };\n    return AccessibleModal;\n}());\nexports.AccessibleModal = AccessibleModal;\n\n\n/***/ }),\n\n/***/ 265:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __extends = (this && this.__extends) || (function () {\n    var extendStatics = Object.setPrototypeOf ||\n        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Component_1 = __webpack_require__(7);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar SettingsEvents_1 = __webpack_require__(55);\nvar PreferencesPanelEvents_1 = __webpack_require__(100);\nvar Initialization_1 = __webpack_require__(2);\nvar Strings_1 = __webpack_require__(6);\nvar Dom_1 = __webpack_require__(1);\nvar GlobalExports_1 = __webpack_require__(3);\nvar ExternalModulesShim_1 = __webpack_require__(26);\nvar _ = __webpack_require__(0);\nvar AccessibleModal_1 = __webpack_require__(179);\n__webpack_require__(638);\nvar InitializationEvents_1 = __webpack_require__(17);\nvar SVGIcons_1 = __webpack_require__(12);\n/**\n * The PreferencesPanel component renders a **Preferences** item inside the {@link Settings} component which the end\n * user can click to access a panel from which it is possible to specify certain customization options for the search\n * interface. These customization options are then saved in the browser local storage.\n *\n * This component should be used inside the {@link Settings} component.\n *\n * See also the {@link ResultsFiltersPreferences} and {@link ResultsPreferences} components.\n */\nvar PreferencesPanel = /** @class */ (function (_super) {\n    __extends(PreferencesPanel, _super);\n    /**\n     * Creates a new PreferencesPanel.\n     * @param element The HTMLElement on which to instantiate the component.\n     * @param options The options for the PreferencesPanel component.\n     * @param bindings The bindings that the component requires to function normally. If not set, these will be\n     * automatically resolved (with a slower execution time).\n     */\n    function PreferencesPanel(element, options, bindings, ModalBox) {\n        if (ModalBox === void 0) { ModalBox = ExternalModulesShim_1.ModalBox; }\n        var _this = _super.call(this, element, PreferencesPanel.ID, bindings) || this;\n        _this.element = element;\n        _this.options = options;\n        _this.ModalBox = ModalBox;\n        _this.content = [];\n        _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, PreferencesPanel, options);\n        _this.bind.onRootElement(SettingsEvents_1.SettingsEvents.settingsPopulateMenu, function (args) {\n            args.menuData.push({\n                className: 'coveo-preferences-panel',\n                text: Strings_1.l('Preferences'),\n                onOpen: function () { return _this.open(); },\n                onClose: function () { return _this.close(); },\n                svgIcon: SVGIcons_1.SVGIcons.icons.dropdownPreferences,\n                svgIconClassName: 'coveo-preferences-panel-svg'\n            });\n        });\n        _this.bind.onRootElement(InitializationEvents_1.InitializationEvents.afterComponentsInitialization, function () {\n            _this.content = Dom_1.$$(_this.element).children();\n        });\n        _this.modalbox = new AccessibleModal_1.AccessibleModal('coveo-preferences-panel', _this.searchInterface.options.modalContainer, _this.ModalBox, {\n            overlayClose: true\n        });\n        return _this;\n    }\n    /**\n     * Opens the PreferencesPanel.\n     */\n    PreferencesPanel.prototype.open = function () {\n        var _this = this;\n        var root = Dom_1.$$('div');\n        _.each(this.content, function (oneChild) {\n            root.append(oneChild);\n        });\n        this.modalbox.open({\n            title: Strings_1.l('Preferences'),\n            content: root.el,\n            origin: this.element,\n            validation: function () {\n                _this.cleanupOnExit();\n                return true;\n            }\n        });\n    };\n    /**\n     * Closes the PreferencesPanel without saving changes.\n     *\n     * Also triggers the `exitPreferencesWithoutSave` event.\n     */\n    PreferencesPanel.prototype.close = function () {\n        this.cleanupOnExit();\n        this.modalbox.close();\n    };\n    /**\n     * Saves the changes and executes a new query.\n     *\n     * Also triggers the `savePreferences` event.\n     */\n    PreferencesPanel.prototype.save = function () {\n        Dom_1.$$(this.element).trigger(PreferencesPanelEvents_1.PreferencesPanelEvents.savePreferences);\n        this.queryController.executeQuery();\n    };\n    PreferencesPanel.prototype.cleanupOnExit = function () {\n        Dom_1.$$(this.element).trigger(PreferencesPanelEvents_1.PreferencesPanelEvents.exitPreferencesWithoutSave);\n    };\n    PreferencesPanel.ID = 'PreferencesPanel';\n    PreferencesPanel.doExport = function () {\n        GlobalExports_1.exportGlobally({\n            PreferencesPanel: PreferencesPanel\n        });\n    };\n    PreferencesPanel.options = {};\n    return PreferencesPanel;\n}(Component_1.Component));\nexports.PreferencesPanel = PreferencesPanel;\nInitialization_1.Initialization.registerAutoCreateComponent(PreferencesPanel);\n\n\n/***/ }),\n\n/***/ 470:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Defer_1 = __webpack_require__(31);\nvar underscore_1 = __webpack_require__(0);\nvar Dom_1 = __webpack_require__(1);\nvar FocusTrap = /** @class */ (function () {\n    function FocusTrap(container, options) {\n        if (options === void 0) { options = {\n            focusableSelector: '[tabindex], button'\n        }; }\n        this.container = container;\n        this.options = options;\n        this.hiddenElements = [];\n        this.enable();\n    }\n    Object.defineProperty(FocusTrap.prototype, \"focusableElements\", {\n        get: function () {\n            return underscore_1.chain(Dom_1.Dom.nodeListToArray(this.container.querySelectorAll(this.options.focusableSelector)))\n                .filter(function (element) { return Dom_1.$$(element).isVisible(); })\n                .sortBy(function (element) { return element.tabIndex; })\n                .value();\n        },\n        enumerable: true,\n        configurable: true\n    });\n    FocusTrap.prototype.disable = function () {\n        document.removeEventListener('focusin', this.focusInEvent);\n        document.removeEventListener('focusout', this.focusOutEvent);\n        this.showHiddenElements();\n        this.enabled = false;\n    };\n    FocusTrap.prototype.enable = function () {\n        var _this = this;\n        document.addEventListener('focusin', (this.focusInEvent = function (e) { return _this.onFocusIn(e); }));\n        document.addEventListener('focusout', (this.focusOutEvent = function (e) { return _this.onFocusOut(e); }));\n        this.hideAllExcept(this.container);\n        this.enabled = true;\n    };\n    FocusTrap.prototype.showHiddenElements = function () {\n        while (this.hiddenElements.length) {\n            this.hiddenElements.pop().removeAttribute('aria-hidden');\n        }\n    };\n    FocusTrap.prototype.hideElement = function (element) {\n        if (element.getAttribute('aria-hidden')) {\n            return;\n        }\n        this.hiddenElements.push(element);\n        element.setAttribute('aria-hidden', \"\" + true);\n    };\n    FocusTrap.prototype.hideSiblings = function (allowedElement) {\n        var _this = this;\n        var parent = allowedElement.parentElement;\n        if (parent) {\n            underscore_1.without(Dom_1.$$(parent).children(), allowedElement).forEach(function (elementToHide) {\n                _this.hideElement(elementToHide);\n            });\n        }\n    };\n    FocusTrap.prototype.hideAllExcept = function (allowedElement) {\n        this.hideSiblings(allowedElement);\n        var parent = allowedElement.parentElement;\n        if (parent && parent !== document.body) {\n            this.hideAllExcept(parent);\n        }\n    };\n    FocusTrap.prototype.getFocusableSibling = function (element, previous) {\n        if (previous === void 0) { previous = false; }\n        var elements = this.focusableElements;\n        var currentIndex = elements.indexOf(element);\n        if (currentIndex === -1) {\n            return null;\n        }\n        return elements[(currentIndex + (previous ? -1 : 1) + elements.length) % elements.length];\n    };\n    FocusTrap.prototype.focusSibling = function (element, previous) {\n        if (previous === void 0) { previous = false; }\n        var sibling = this.getFocusableSibling(element, previous);\n        if (sibling) {\n            sibling.focus();\n        }\n    };\n    FocusTrap.prototype.focusFirstElement = function () {\n        var elements = this.focusableElements;\n        if (elements.length) {\n            elements[0].focus();\n        }\n    };\n    FocusTrap.prototype.elementIsBefore = function (oldElement, newElement) {\n        if (!newElement) {\n            return false;\n        }\n        return oldElement.compareDocumentPosition(newElement) === Node.DOCUMENT_POSITION_PRECEDING;\n    };\n    FocusTrap.prototype.onLosingFocus = function (oldElement, newElement) {\n        var _this = this;\n        Defer_1.Defer.defer(function () {\n            if (!_this.enabled) {\n                return;\n            }\n            _this.enabled = false;\n            if (oldElement && _this.focusIsAllowed(oldElement)) {\n                _this.focusSibling(oldElement, _this.elementIsBefore(oldElement, newElement));\n            }\n            else {\n                _this.focusFirstElement();\n            }\n            _this.enabled = true;\n        });\n    };\n    FocusTrap.prototype.focusIsAllowed = function (element) {\n        return this.container.contains(element);\n    };\n    FocusTrap.prototype.elementIsInPage = function (element) {\n        return element && element !== document.body.parentElement;\n    };\n    FocusTrap.prototype.onFocusIn = function (e) {\n        if (!this.enabled) {\n            return;\n        }\n        var oldElement = e.relatedTarget;\n        var handledByFocusOut = this.elementIsInPage(oldElement);\n        if (handledByFocusOut) {\n            return;\n        }\n        var newElement = e.target;\n        if (!this.elementIsInPage(newElement)) {\n            return;\n        }\n        if (!this.focusIsAllowed(newElement)) {\n            this.onLosingFocus(null, newElement);\n        }\n    };\n    FocusTrap.prototype.onFocusOut = function (e) {\n        if (!this.enabled) {\n            return;\n        }\n        var newElement = e.relatedTarget;\n        if (!this.elementIsInPage(newElement)) {\n            return;\n        }\n        if (!newElement || !this.focusIsAllowed(newElement)) {\n            this.onLosingFocus(e.target, newElement);\n        }\n    };\n    return FocusTrap;\n}());\nexports.FocusTrap = FocusTrap;\n\n\n/***/ }),\n\n/***/ 638:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// PreferencesPanel.min__d67acfe80778de2e04cc.js","import { ModalBox as ModalBoxModule } from '../ExternalModulesShim';\nimport { FocusTrap } from '../ui/FocusTrap/FocusTrap';\nimport { l } from '../strings/Strings';\nimport { $$ } from './Dom';\nimport { KeyboardUtils, KEYBOARD } from './KeyboardUtils';\nimport { IQuickViewHeaderOptions } from './DomUtils';\nimport { IQueryResult } from '../rest/QueryResult';\nimport { IComponentBindings } from '../ui/Base/ComponentBindings';\nimport { DomUtils } from '../Core';\n\nexport interface IAccessibleModalOptions {\n  overlayClose?: boolean;\n  sizeMod: 'small' | 'normal' | 'big';\n  focusOnOpen?(): HTMLElement;\n}\n\nexport interface IAccessibleModalOpenParameters {\n  content: HTMLElement;\n  validation: () => boolean;\n  origin: HTMLElement;\n}\n\nexport interface IAccessibleModalOpenResultParameters extends IAccessibleModalOpenParameters {\n  result: IQueryResult;\n  options: IQuickViewHeaderOptions;\n  bindings: IComponentBindings;\n}\n\nexport interface IAccessibleModalOpenNormalParameters extends IAccessibleModalOpenParameters {\n  title: HTMLElement;\n}\n\nexport class AccessibleModal {\n  private focusTrap: FocusTrap;\n  private activeModal: Coveo.ModalBox.ModalBox;\n  private options: IAccessibleModalOptions;\n  private initiallyFocusedElement: HTMLElement;\n\n  public get isOpen() {\n    return !!this.focusTrap;\n  }\n\n  public get element() {\n    return this.activeModal && this.activeModal.modalBox;\n  }\n\n  public get content() {\n    return this.activeModal && this.activeModal.content;\n  }\n\n  public get wrapper() {\n    return this.activeModal && this.activeModal.wrapper;\n  }\n\n  private get headerElement() {\n    return this.element && this.element.querySelector<HTMLElement>('.coveo-modal-header h1');\n  }\n\n  constructor(\n    private className: string,\n    private ownerElement: HTMLElement,\n    private modalboxModule: Coveo.ModalBox.ModalBox = ModalBoxModule,\n    options: Partial<IAccessibleModalOptions> = {}\n  ) {\n    this.options = {\n      ...{\n        sizeMod: 'big'\n      },\n      ...options\n    };\n  }\n\n  public openResult(parameters: IAccessibleModalOpenResultParameters) {\n    if (this.isOpen) {\n      return;\n    }\n    this.openModalAndTrap({\n      content: parameters.content,\n      validation: parameters.validation,\n      origin: parameters.origin,\n      title: DomUtils.getQuickviewHeader(parameters.result, parameters.options, parameters.bindings).el\n    });\n    this.makeAccessible(parameters.options.title || parameters.result.title);\n  }\n\n  public open(parameters: IAccessibleModalOpenNormalParameters) {\n    if (this.isOpen) {\n      return;\n    }\n    this.openModalAndTrap(parameters);\n    this.makeAccessible();\n  }\n\n  private openModalAndTrap(parameters: IAccessibleModalOpenNormalParameters) {\n    this.initiallyFocusedElement = parameters.origin || (document.activeElement as HTMLElement);\n    this.activeModal = this.modalboxModule.open(parameters.content, {\n      title: parameters.title,\n      className: this.className,\n      validation: () => {\n        this.onModalClose();\n        return parameters.validation();\n      },\n      body: this.ownerElement,\n      sizeMod: this.options.sizeMod,\n      overlayClose: this.options.overlayClose\n    });\n    this.focusTrap = new FocusTrap(this.element);\n  }\n\n  public close() {\n    if (!this.isOpen) {\n      return;\n    }\n    this.activeModal.close();\n    this.activeModal = null;\n  }\n\n  private makeAccessible(title?: string) {\n    this.element.setAttribute('aria-modal', 'true');\n    if (title) {\n      this.headerElement.setAttribute('aria-label', title);\n    }\n    this.makeCloseButtonAccessible();\n    this.updateFocus();\n  }\n\n  private get closeButton(): HTMLElement {\n    return this.element.querySelector('.coveo-small-close');\n  }\n\n  private makeCloseButtonAccessible() {\n    const closeButton = this.closeButton;\n    closeButton.setAttribute('aria-label', l('Close'));\n    closeButton.setAttribute('role', 'button');\n    closeButton.tabIndex = 0;\n    $$(closeButton).on(\n      'keyup',\n      KeyboardUtils.keypressAction(KEYBOARD.ENTER, () => closeButton.click())\n    );\n  }\n\n  private updateFocus() {\n    const focusOnElement: HTMLElement = (this.options.focusOnOpen && this.options.focusOnOpen()) || this.closeButton;\n    focusOnElement.focus();\n  }\n\n  private onModalClose() {\n    this.focusTrap.disable();\n    this.focusTrap = null;\n    if (this.initiallyFocusedElement && document.body.contains(this.initiallyFocusedElement)) {\n      this.initiallyFocusedElement.focus();\n    }\n  }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils/AccessibleModal.ts","import { Component } from '../Base/Component';\nimport { IComponentBindings } from '../Base/ComponentBindings';\nimport { ComponentOptions } from '../Base/ComponentOptions';\nimport { SettingsEvents } from '../../events/SettingsEvents';\nimport { ISettingsPopulateMenuArgs } from '../Settings/Settings';\nimport { PreferencesPanelEvents } from '../../events/PreferencesPanelEvents';\nimport { Initialization } from '../Base/Initialization';\nimport { l } from '../../strings/Strings';\nimport { $$ } from '../../utils/Dom';\nimport { exportGlobally } from '../../GlobalExports';\nimport { ModalBox as ModalBoxModule } from '../../ExternalModulesShim';\nimport * as _ from 'underscore';\nimport { AccessibleModal } from '../../utils/AccessibleModal';\n\nimport 'styling/_PreferencesPanel';\nimport { InitializationEvents } from '../../events/InitializationEvents';\nimport { SVGIcons } from '../../utils/SVGIcons';\n\nexport interface IPreferencesPanelOptions {}\n\n/**\n * The PreferencesPanel component renders a **Preferences** item inside the {@link Settings} component which the end\n * user can click to access a panel from which it is possible to specify certain customization options for the search\n * interface. These customization options are then saved in the browser local storage.\n *\n * This component should be used inside the {@link Settings} component.\n *\n * See also the {@link ResultsFiltersPreferences} and {@link ResultsPreferences} components.\n */\nexport class PreferencesPanel extends Component {\n  static ID = 'PreferencesPanel';\n\n  static doExport = () => {\n    exportGlobally({\n      PreferencesPanel: PreferencesPanel\n    });\n  };\n\n  static options: IPreferencesPanelOptions = {};\n  private modalbox: AccessibleModal;\n  private content: HTMLElement[] = [];\n\n  /**\n   * Creates a new PreferencesPanel.\n   * @param element The HTMLElement on which to instantiate the component.\n   * @param options The options for the PreferencesPanel component.\n   * @param bindings The bindings that the component requires to function normally. If not set, these will be\n   * automatically resolved (with a slower execution time).\n   */\n  constructor(\n    public element: HTMLElement,\n    public options: IPreferencesPanelOptions,\n    bindings?: IComponentBindings,\n    private ModalBox = ModalBoxModule\n  ) {\n    super(element, PreferencesPanel.ID, bindings);\n    this.options = ComponentOptions.initComponentOptions(element, PreferencesPanel, options);\n    this.bind.onRootElement(SettingsEvents.settingsPopulateMenu, (args: ISettingsPopulateMenuArgs) => {\n      args.menuData.push({\n        className: 'coveo-preferences-panel',\n        text: l('Preferences'),\n        onOpen: () => this.open(),\n        onClose: () => this.close(),\n        svgIcon: SVGIcons.icons.dropdownPreferences,\n        svgIconClassName: 'coveo-preferences-panel-svg'\n      });\n    });\n    this.bind.onRootElement(InitializationEvents.afterComponentsInitialization, () => {\n      this.content = $$(this.element).children();\n    });\n    this.modalbox = new AccessibleModal('coveo-preferences-panel', this.searchInterface.options.modalContainer, this.ModalBox, {\n      overlayClose: true\n    });\n  }\n\n  /**\n   * Opens the PreferencesPanel.\n   */\n  public open(): void {\n    let root = $$('div');\n    _.each(this.content, oneChild => {\n      root.append(oneChild);\n    });\n    this.modalbox.open({\n      title: l('Preferences'),\n      content: root.el,\n      origin: this.element,\n      validation: () => {\n        this.cleanupOnExit();\n        return true;\n      }\n    });\n  }\n\n  /**\n   * Closes the PreferencesPanel without saving changes.\n   *\n   * Also triggers the `exitPreferencesWithoutSave` event.\n   */\n  public close(): void {\n    this.cleanupOnExit();\n    this.modalbox.close();\n  }\n\n  /**\n   * Saves the changes and executes a new query.\n   *\n   * Also triggers the `savePreferences` event.\n   */\n  public save(): void {\n    $$(this.element).trigger(PreferencesPanelEvents.savePreferences);\n    this.queryController.executeQuery();\n  }\n\n  private cleanupOnExit() {\n    $$(this.element).trigger(PreferencesPanelEvents.exitPreferencesWithoutSave);\n  }\n}\n\nInitialization.registerAutoCreateComponent(PreferencesPanel);\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/PreferencesPanel/PreferencesPanel.ts","import { Defer } from '../../misc/Defer';\nimport { without, chain } from 'underscore';\nimport { $$, Dom } from '../../utils/Dom';\n\nexport interface FocusTrapOptions {\n  focusableSelector: string;\n}\n\nexport class FocusTrap {\n  private focusInEvent: (e: FocusEvent) => void;\n  private focusOutEvent: (e: FocusEvent) => void;\n  private hiddenElements: HTMLElement[];\n  private enabled: boolean;\n\n  private get focusableElements(): HTMLElement[] {\n    return chain(Dom.nodeListToArray(this.container.querySelectorAll(this.options.focusableSelector)))\n      .filter(element => $$(element).isVisible())\n      .sortBy(element => element.tabIndex)\n      .value();\n  }\n\n  constructor(\n    private container: HTMLElement,\n    private options: FocusTrapOptions = {\n      focusableSelector: '[tabindex], button'\n    }\n  ) {\n    this.hiddenElements = [];\n    this.enable();\n  }\n\n  public disable() {\n    document.removeEventListener('focusin', this.focusInEvent);\n    document.removeEventListener('focusout', this.focusOutEvent);\n    this.showHiddenElements();\n    this.enabled = false;\n  }\n\n  private enable() {\n    document.addEventListener('focusin', (this.focusInEvent = e => this.onFocusIn(e)));\n    document.addEventListener('focusout', (this.focusOutEvent = e => this.onFocusOut(e)));\n    this.hideAllExcept(this.container);\n    this.enabled = true;\n  }\n\n  private showHiddenElements() {\n    while (this.hiddenElements.length) {\n      this.hiddenElements.pop().removeAttribute('aria-hidden');\n    }\n  }\n\n  private hideElement(element: HTMLElement) {\n    if (element.getAttribute('aria-hidden')) {\n      return;\n    }\n    this.hiddenElements.push(element);\n    element.setAttribute('aria-hidden', `${true}`);\n  }\n\n  private hideSiblings(allowedElement: HTMLElement) {\n    const parent = allowedElement.parentElement;\n    if (parent) {\n      without($$(parent).children(), allowedElement).forEach(elementToHide => {\n        this.hideElement(elementToHide);\n      });\n    }\n  }\n\n  private hideAllExcept(allowedElement: HTMLElement) {\n    this.hideSiblings(allowedElement);\n    const parent = allowedElement.parentElement;\n    if (parent && parent !== document.body) {\n      this.hideAllExcept(parent);\n    }\n  }\n\n  private getFocusableSibling(element: HTMLElement, previous = false) {\n    const elements = this.focusableElements;\n    const currentIndex = elements.indexOf(element);\n    if (currentIndex === -1) {\n      return null;\n    }\n    return elements[(currentIndex + (previous ? -1 : 1) + elements.length) % elements.length];\n  }\n\n  private focusSibling(element: HTMLElement, previous = false) {\n    const sibling = this.getFocusableSibling(element, previous);\n    if (sibling) {\n      sibling.focus();\n    }\n  }\n\n  private focusFirstElement() {\n    const elements = this.focusableElements;\n    if (elements.length) {\n      elements[0].focus();\n    }\n  }\n\n  private elementIsBefore(oldElement: HTMLElement, newElement: HTMLElement) {\n    if (!newElement) {\n      return false;\n    }\n    return oldElement.compareDocumentPosition(newElement) === Node.DOCUMENT_POSITION_PRECEDING;\n  }\n\n  private onLosingFocus(oldElement: HTMLElement, newElement: HTMLElement) {\n    Defer.defer(() => {\n      if (!this.enabled) {\n        return;\n      }\n      this.enabled = false;\n      if (oldElement && this.focusIsAllowed(oldElement)) {\n        this.focusSibling(oldElement, this.elementIsBefore(oldElement, newElement));\n      } else {\n        this.focusFirstElement();\n      }\n      this.enabled = true;\n    });\n  }\n\n  private focusIsAllowed(element: HTMLElement) {\n    return this.container.contains(element);\n  }\n\n  private elementIsInPage(element: HTMLElement) {\n    return element && element !== document.body.parentElement;\n  }\n\n  private onFocusIn(e: FocusEvent) {\n    if (!this.enabled) {\n      return;\n    }\n    const oldElement = e.relatedTarget as HTMLElement;\n    const handledByFocusOut = this.elementIsInPage(oldElement);\n    if (handledByFocusOut) {\n      return;\n    }\n    const newElement = e.target as HTMLElement;\n    if (!this.elementIsInPage(newElement)) {\n      return;\n    }\n    if (!this.focusIsAllowed(newElement)) {\n      this.onLosingFocus(null, newElement);\n    }\n  }\n\n  private onFocusOut(e: FocusEvent) {\n    if (!this.enabled) {\n      return;\n    }\n    const newElement = e.relatedTarget as HTMLElement;\n    if (!this.elementIsInPage(newElement)) {\n      return;\n    }\n    if (!newElement || !this.focusIsAllowed(newElement)) {\n      this.onLosingFocus(e.target as HTMLElement, newElement);\n    }\n  }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/FocusTrap/FocusTrap.ts"],"sourceRoot":""}