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AG5F,KACb,C,SAEgB6F,gBAAgBD,GAC9B,QAASA,EAAG5F,KACd,C","sources":["../node_modules/@coveo/atomic/dist/esm|sync","../node_modules/@coveo/atomic/dist/esm/src/components/search/search-box-suggestions/atomic-search-box-query-suggestions/atomic-search-box-query-suggestions.tsx","../node_modules/@coveo/atomic/dist/esm/src/components/search/search-box-suggestions/atomic-search-box-recent-queries/atomic-search-box-recent-queries.tsx","../node_modules/@coveo/atomic/dist/esm/src/utils/event-utils.ts","../node_modules/@coveo/atomic/dist/esm/src/utils/local-storage-utils.tsx","../node_modules/@coveo/atomic/dist/esm/src/components/common/suggestions/query-suggestions.tsx","../node_modules/@coveo/atomic/dist/esm/src/components/common/suggestions/recent-queries.tsx","../node_modules/@coveo/atomic/dist/esm/src/utils/string-utils.ts","../node_modules/@coveo/atomic/dist/esm/src/components/common/suggestions/suggestions-common.ts"],"sourcesContent":["function webpackEmptyContext(req) {\n\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\te.code = 'MODULE_NOT_FOUND';\n\tthrow e;\n}\nwebpackEmptyContext.keys = function() { return []; };\nwebpackEmptyContext.resolve = webpackEmptyContext;\nwebpackEmptyContext.id = 40781;\nmodule.exports = webpackEmptyContext;","import {\n loadQuerySuggestActions,\n SearchBox,\n SearchEngine,\n Suggestion,\n} from '@coveo/headless';\nimport {\n QuerySetSection,\n QuerySuggestionSection,\n} from '@coveo/headless/dist/definitions/state/state-sections';\nimport {Component, Element, Prop, State, h} from '@stencil/core';\nimport SearchIcon from '../../../../images/search.svg';\nimport {\n getPartialSearchBoxSuggestionElement,\n QuerySuggestionContainer,\n QuerySuggestionIcon,\n QuerySuggestionText,\n} from '../../../common/suggestions/query-suggestions';\nimport {\n dispatchSearchBoxSuggestionsEvent,\n SearchBoxSuggestionElement,\n SearchBoxSuggestions,\n SearchBoxSuggestionsBindings,\n} from '../../../common/suggestions/suggestions-common';\n\n/**\n * The `atomic-search-box-query-suggestions` component can be added as a child of an `atomic-search-box` component, allowing for the configuration of query suggestion behavior.\n */\n@Component({\n tag: 'atomic-search-box-query-suggestions',\n shadow: true,\n})\nexport class AtomicSearchBoxQuerySuggestions {\n private bindings!: SearchBoxSuggestionsBindings;\n @Element() private host!: HTMLElement;\n\n @State() public error!: Error;\n\n /**\n * The SVG icon to display.\n *\n * - Use a value that starts with `http://`, `https://`, `./`, or `../`, to fetch and display an icon from a given location.\n * - Use a value that starts with `assets://`, to display an icon from the Atomic package.\n * - Use a stringified SVG to display it directly.\n */\n @Prop() public icon?: string;\n\n /**\n * The maximum number of suggestions that will be displayed if the user has typed something into the input field.\n */\n @Prop({reflect: true}) public maxWithQuery?: number;\n /**\n * The maximum number of suggestions that will be displayed initially when the input field is empty.\n */\n @Prop({reflect: true}) public maxWithoutQuery?: number;\n\n componentWillLoad() {\n try {\n dispatchSearchBoxSuggestionsEvent((bindings) => {\n this.bindings = bindings;\n return this.initialize();\n }, this.host);\n } catch (error) {\n this.error = error as Error;\n }\n }\n\n private initialize(): SearchBoxSuggestions {\n const engine = this.bindings.engine as SearchEngine<\n QuerySuggestionSection & QuerySetSection\n >;\n const {registerQuerySuggest, fetchQuerySuggestions} =\n loadQuerySuggestActions(engine);\n\n engine.dispatch(\n registerQuerySuggest({\n id: this.bindings.id,\n count: this.bindings.numberOfQueries,\n })\n );\n\n return {\n position: Array.from(this.host.parentNode!.children).indexOf(this.host),\n onInput: () =>\n engine.dispatch(\n fetchQuerySuggestions({\n id: this.bindings.id,\n })\n ),\n renderItems: () => this.renderItems(),\n };\n }\n\n private renderItems(): SearchBoxSuggestionElement[] {\n const hasQuery = this.bindings.searchBoxController.state.value !== '';\n const max = hasQuery ? this.maxWithQuery : this.maxWithoutQuery;\n return this.bindings.searchBoxController.state.suggestions\n .slice(0, max)\n .map((suggestion) => this.renderItem(suggestion));\n }\n\n private renderItem(suggestion: Suggestion) {\n const hasQuery = this.bindings.searchBoxController.state.value !== '';\n const partialItem = getPartialSearchBoxSuggestionElement(\n suggestion,\n this.bindings.i18n\n );\n\n return {\n ...partialItem,\n content: (\n \n 1}\n />\n\n \n \n ),\n onSelect: () => {\n this.bindings.searchBoxController.selectSuggestion(suggestion.rawValue);\n },\n };\n }\n\n public render() {\n if (this.error) {\n return (\n \n );\n }\n }\n}\n","import {\n buildRecentQueriesList,\n RecentQueriesList,\n SearchBox,\n} from '@coveo/headless';\nimport {Component, Element, Prop, State, h} from '@stencil/core';\nimport Clock from '../../../../images/clock.svg';\nimport {SafeStorage, StorageItems} from '../../../../utils/local-storage-utils';\nimport {once} from '../../../../utils/utils';\nimport {\n getPartialRecentQueryClearElement,\n getPartialRecentQueryElement,\n RecentQueriesContainer,\n RecentQueryClear,\n RecentQueryIcon,\n RecentQueryText,\n} from '../../../common/suggestions/recent-queries';\nimport {\n dispatchSearchBoxSuggestionsEvent,\n SearchBoxSuggestionElement,\n SearchBoxSuggestions,\n SearchBoxSuggestionsBindings,\n} from '../../../common/suggestions/suggestions-common';\nimport {Bindings} from '../../atomic-search-interface/atomic-search-interface';\n\n/**\n * The `atomic-search-box-recent-queries` component can be added as a child of an `atomic-search-box` component, allowing for the configuration of recent query suggestions.\n *\n * @part recent-query-title - The 'Recent queries' title.\n * @part recent-query-clear - The 'Clear' button for clearing recent queries .\n */\n@Component({\n tag: 'atomic-search-box-recent-queries',\n shadow: true,\n})\nexport class AtomicSearchBoxRecentQueries {\n private bindings!: SearchBoxSuggestionsBindings;\n private recentQueriesList!: RecentQueriesList;\n private storage!: SafeStorage;\n\n @Element() private host!: HTMLElement;\n\n @State() public error!: Error;\n\n /**\n * The SVG icon to display.\n *\n * - Use a value that starts with `http://`, `https://`, `./`, or `../`, to fetch and display an icon from a given location.\n * - Use a value that starts with `assets://`, to display an icon from the Atomic package.\n * - Use a stringified SVG to display it directly.\n */\n @Prop() public icon?: string;\n\n /**\n * The maximum number of suggestions that will be displayed if the user has typed something into the input field.\n */\n @Prop({reflect: true}) public maxWithQuery = 3;\n /**\n * The maximum number of suggestions that will be displayed initially when the input field is empty.\n */\n @Prop({reflect: true}) public maxWithoutQuery?: number;\n\n componentWillLoad() {\n try {\n dispatchSearchBoxSuggestionsEvent((bindings) => {\n this.bindings = bindings;\n return this.initialize();\n }, this.host);\n } catch (error) {\n this.error = error as Error;\n }\n }\n\n private renderIcon() {\n return this.icon || Clock;\n }\n\n private initialize(): SearchBoxSuggestions {\n this.storage = new SafeStorage();\n this.recentQueriesList = buildRecentQueriesList(this.bindings.engine, {\n initialState: {queries: this.retrieveLocalStorage()},\n options: {maxLength: 1000, clearFilters: this.bindings.clearFilters},\n });\n\n this.recentQueriesList.subscribe(() => this.updateLocalStorage());\n\n return {\n position: Array.from(this.host.parentNode!.children).indexOf(this.host),\n renderItems: () => this.renderItems(),\n };\n }\n\n private retrieveLocalStorage() {\n return this.storage.getParsedJSON(StorageItems.RECENT_QUERIES, []);\n }\n\n private updateLocalStorage() {\n if (!this.recentQueriesList.state.analyticsEnabled) {\n return this.disableFeature();\n }\n\n return this.storage.setJSON(\n StorageItems.RECENT_QUERIES,\n this.recentQueriesList.state.queries\n );\n }\n\n private warnUser = once(() =>\n this.bindings.engine.logger.warn(\n 'Because analytics are disabled, the recent queries feature is deactivated.'\n )\n );\n\n private disableFeature() {\n this.warnUser();\n this.storage.removeItem(StorageItems.RECENT_QUERIES);\n }\n\n private renderItems(): SearchBoxSuggestionElement[] {\n if (!this.recentQueriesList.state.analyticsEnabled) {\n return [];\n }\n\n const query = this.bindings.searchBoxController.state.value;\n const hasQuery = query !== '';\n const max = hasQuery ? this.maxWithQuery : this.maxWithoutQuery;\n const filteredQueries = this.recentQueriesList.state.queries\n .filter(\n (recentQuery) =>\n recentQuery !== query &&\n recentQuery.toLowerCase().startsWith(query.toLowerCase())\n )\n .slice(0, max);\n\n const suggestionElements: SearchBoxSuggestionElement[] =\n filteredQueries.map((value) => this.renderItem(value));\n if (suggestionElements.length) {\n suggestionElements.unshift(this.renderClear());\n }\n\n return suggestionElements;\n }\n\n private renderClear(): SearchBoxSuggestionElement {\n const partialItem = getPartialRecentQueryClearElement(this.bindings.i18n);\n\n return {\n ...partialItem,\n content: ,\n onSelect: () => {\n this.recentQueriesList.clear();\n this.bindings.triggerSuggestions();\n },\n };\n }\n\n private renderItem(value: string): SearchBoxSuggestionElement {\n const query = this.bindings.searchBoxController.state.value;\n const partialItem = getPartialRecentQueryElement(value, this.bindings.i18n);\n return {\n ...partialItem,\n content: (\n \n \n \n \n ),\n\n onSelect: () => {\n if (this.bindings.isStandalone) {\n this.bindings.searchBoxController.updateText(value);\n this.bindings.searchBoxController.submit();\n return;\n }\n\n this.recentQueriesList.executeRecentQuery(\n this.recentQueriesList.state.queries.indexOf(value)\n );\n },\n };\n }\n\n public render() {\n if (this.error) {\n return (\n \n );\n }\n }\n}\n","export function buildCustomEvent(name: string, detail: T) {\n return new CustomEvent(name, {\n detail,\n // Event will bubble up the DOM until it is caught\n bubbles: true,\n // Allows to verify if event is caught (cancelled). If it's not caught, it won't be initialized.\n cancelable: true,\n // Allows to compose Atomic components inside one another, event will go across DOM/Shadow DOM\n composed: true,\n });\n}\n\nexport function listenOnce(\n element: HTMLElement,\n type: K,\n listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => void,\n options?: boolean | AddEventListenerOptions\n): void;\nexport function listenOnce(\n element: HTMLElement,\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions\n): void;\nexport function listenOnce(\n element: HTMLElement,\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions\n): void {\n const _listener: EventListener = (evt: Event) => {\n element.removeEventListener(type, _listener, options);\n typeof listener === 'object'\n ? listener.handleEvent.call(element, evt)\n : listener.call(element, evt);\n };\n element.addEventListener(type, _listener, options);\n}\n","import {StandaloneSearchBoxAnalytics} from '@coveo/headless';\n\nexport enum StorageItems {\n RECENT_QUERIES = 'coveo-recent-queries',\n STANDALONE_SEARCH_BOX_DATA = 'coveo-standalone-search-box-data',\n GENERATED_ANSWER_DATA = 'coveo-generated-answer-data',\n}\n\nexport interface StandaloneSearchBoxData {\n value: string;\n enableQuerySyntax?: boolean;\n analytics: StandaloneSearchBoxAnalytics;\n}\n\nexport interface GeneratedAnswerData {\n isVisible: boolean;\n}\n\nexport class SafeStorage implements Storage {\n constructor() {}\n public clear() {\n return this.tryAccessLocalStorageOrWarn(\n () => localStorage.clear(),\n () => {}\n );\n }\n\n public getItem(key: StorageItems) {\n return this.tryAccessLocalStorageOrWarn(\n () => localStorage.getItem(key),\n () => null\n );\n }\n\n public getParsedJSON(key: StorageItems, fallback: T) {\n const item = this.getItem(key);\n if (!item) {\n return fallback;\n }\n return this.tryJSONOrWarn(\n key,\n () => JSON.parse(item) as T,\n () => fallback\n );\n }\n\n public key(index: number) {\n return this.tryAccessLocalStorageOrWarn(\n () => localStorage.key(index),\n () => null\n );\n }\n\n public get length() {\n return this.tryOrElse(\n () => localStorage.length,\n () => 0\n );\n }\n\n public removeItem(key: StorageItems) {\n return this.tryAccessLocalStorageOrWarn(\n () => localStorage.removeItem(key),\n () => {}\n );\n }\n\n public setItem(key: StorageItems, value: string) {\n return this.tryAccessLocalStorageOrWarn(\n () => localStorage.setItem(key, value),\n () => {}\n );\n }\n\n public setJSON(key: StorageItems, obj: unknown) {\n const stringified = this.tryJSONOrWarn(\n key,\n () => JSON.stringify(obj),\n () => JSON.stringify({})\n );\n return this.setItem(key, stringified);\n }\n\n private tryAccessLocalStorageOrWarn(\n tryTo: () => OnSuccess,\n orElse: () => OnFailure\n ) {\n return this.tryOrElse(tryTo, () => {\n console.warn(\n 'Error while trying to read or modify local storage. This can be caused by browser specific settings.'\n );\n return orElse();\n });\n }\n\n private tryJSONOrWarn(\n key: StorageItems,\n tryTo: () => OnSuccess,\n orElse: () => OnFailure\n ) {\n return this.tryOrElse(tryTo, () => {\n console.warn(\n `Error while trying to do JSON manipulation with local storage entry. ${key}`\n );\n return orElse();\n });\n }\n\n private tryOrElse(\n tryTo: () => OnSuccess,\n orElse: () => OnFailure\n ) {\n try {\n return tryTo();\n } catch (e) {\n console.warn(e as Error);\n return orElse();\n }\n }\n}\n","import {FunctionalComponent, h} from '@stencil/core';\nimport {i18n} from 'i18next';\nimport {encodeForDomAttribute} from '../../../utils/string-utils';\nimport {SearchBoxSuggestionElement} from './suggestions-common';\n\ninterface Suggestion {\n highlightedValue: string;\n rawValue: string;\n}\n\nexport const getPartialSearchBoxSuggestionElement = (\n suggestion: Suggestion,\n i18n: i18n\n): Pick => {\n return {\n part: 'query-suggestion-item',\n key: `qs-${encodeForDomAttribute(suggestion.rawValue)}`,\n query: suggestion.rawValue,\n ariaLabel: i18n.t('query-suggestion-label', {\n query: suggestion.rawValue,\n interpolation: {escapeValue: false},\n }),\n };\n};\n\nexport const QuerySuggestionContainer: FunctionalComponent = (_, children) => {\n return (\n
\n {children}\n
\n );\n};\n\ninterface QuerySuggestionIconProps {\n icon: string;\n hasSuggestion: boolean;\n}\n\nexport const QuerySuggestionIcon: FunctionalComponent<\n QuerySuggestionIconProps\n> = ({icon, hasSuggestion}) => {\n if (!hasSuggestion) {\n return;\n }\n\n return (\n \n );\n};\n\ninterface QuerySuggestionTextProps {\n suggestion: Suggestion;\n hasQuery: boolean;\n}\n\nexport const QuerySuggestionText: FunctionalComponent<\n QuerySuggestionTextProps\n> = ({suggestion, hasQuery}) => {\n if (hasQuery) {\n return (\n \n );\n }\n\n return (\n \n {suggestion.rawValue}\n \n );\n};\n","import {HighlightUtils} from '@coveo/headless';\nimport {FunctionalComponent, h} from '@stencil/core';\nimport {i18n} from 'i18next';\nimport {encodeForDomAttribute} from '../../../utils/string-utils';\nimport {SearchBoxSuggestionElement} from './suggestions-common';\n\nexport const getPartialRecentQueryElement = (\n value: string,\n i18n: i18n\n): Pick => {\n return {\n part: 'recent-query-item',\n query: value,\n key: `recent-${encodeForDomAttribute(value)}`,\n ariaLabel: i18n.t('recent-query-suggestion-label', {\n query: value,\n interpolation: {escapeValue: false},\n }),\n };\n};\n\nexport const getPartialRecentQueryClearElement = (\n i18n: i18n\n): Pick<\n SearchBoxSuggestionElement,\n 'ariaLabel' | 'key' | 'part' | 'hideIfLast'\n> => {\n return {\n key: 'recent-query-clear',\n ariaLabel: i18n.t('clear-recent-searches', {\n interpolation: {escapeValue: false},\n }),\n part: 'recent-query-title-item suggestion-divider',\n hideIfLast: true,\n };\n};\n\nexport const RecentQueriesContainer: FunctionalComponent = (_, children) => {\n return (\n \n {children}\n \n );\n};\n\ninterface RecentQueryIconProps {\n icon: string;\n}\n\nexport const RecentQueryIcon: FunctionalComponent = ({\n icon,\n}) => {\n return (\n \n );\n};\n\ninterface RecentQueryTextProps {\n query: string;\n value: string;\n}\n\nexport const RecentQueryText: FunctionalComponent = ({\n query,\n value,\n}) => {\n if (query === '') {\n return (\n \n {value}\n \n );\n }\n return (\n ',\n closingDelimiter: '',\n highlights: [\n {\n offset: query.length,\n length: value.length - query.length,\n },\n ],\n })}\n >\n );\n};\n\ninterface RecentQueryClearProps {\n i18n: i18n;\n}\n\nexport const RecentQueryClear: FunctionalComponent = ({\n i18n,\n}) => {\n return (\n
\n \n {i18n.t('recent-searches')}\n \n {i18n.t('clear')}\n
\n );\n};\n","export function regexEncode(value: string): string {\n return value.replace(/[-[\\]/{}()*+?.\\\\^$|]/g, '\\\\$&');\n}\n\nexport function encodeForDomAttribute(str: string) {\n return str\n .split('')\n .map((ch) => (ch.match(/(\\d|\\w)+/g) ? ch : ch.charCodeAt(0)))\n .join('');\n}\n","import {VNode} from '@stencil/core';\nimport {buildCustomEvent} from '../../../utils/event-utils';\nimport {closest} from '../../../utils/utils';\nimport {AnyBindings} from '../interface/bindings';\n\n/**\n * Element which will be rendered in the list of suggestions.\n */\nexport interface SearchBoxSuggestionElement {\n /**\n * Stable identity which enables Stencil to reuse DOM elements for better performance.\n * The best way to pick a key is to use a string that uniquely identifies that list item among its siblings (often your data will already have IDs).\n */\n key: string;\n /**\n * Rendered content of the element.\n */\n content: Element | VNode;\n /**\n * Hook called when the suggestion is selected.\n * @param e DOM event.\n */\n onSelect?(e: Event): void;\n /**\n * The query associated with the suggestion which will replace the query in the search box if the suggestion is selected.\n */\n query?: string;\n /**\n * For improved accessibility, set this property with additional information.\n * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label\n */\n ariaLabel?: string;\n /**\n * Adds a specific shadow part attribute that can be selected with the CSS ::part pseudo-element.\n * https://developer.mozilla.org/en-US/docs/Web/CSS/::part\n */\n part?: string;\n /**\n * Whether to hide the suggestion when it's the last one in the list.\n */\n hideIfLast?: boolean;\n}\n\n/**\n * Element which will be rendered in the list of suggestions.\n */\nexport interface SearchBoxSuggestionElement {\n /**\n * Stable identity which enables Stencil to reuse DOM elements for better performance.\n * The best way to pick a key is to use a string that uniquely identifies that list item among its siblings (often your data will already have IDs).\n */\n key: string;\n /**\n * Rendered content of the element.\n */\n content: Element | VNode;\n /**\n * Hook called when the selection is selected.\n * @param e DOM event.\n */\n onSelect?(e: Event): void;\n /**\n * The query associated with the suggestion which will replace the query in the search box if the suggestion is selected.\n */\n query?: string;\n /**\n * For improved accessibility, provide this property with additional information.\n * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label\n */\n ariaLabel?: string;\n /**\n * Adds a specific shadow part attribute that can be selected with the CSS ::part pseudo-element.\n * https://developer.mozilla.org/en-US/docs/Web/CSS/::part\n */\n part?: string;\n /**\n * Hide the suggestion if it's the last in the list.\n */\n hideIfLast?: boolean;\n}\n\n/**\n * List of suggestions that will be displayed along other lists (e.g recent queries) when the search box's input is selected.\n */\nexport interface SearchBoxSuggestions {\n /**\n * The search box will sort the position of suggestions using this value. The lowest value being first.\n * By default, the DOM position will be used.\n */\n position: number;\n /**\n * Whether the suggestions should be listed in the right or left panel. By default, the suggestions are listed in the right panel.\n */\n panel?: 'left' | 'right';\n /**\n * Method that returns the list of elements which will be rendered in the list of suggestions.\n */\n renderItems(): SearchBoxSuggestionElement[];\n /**\n * Hook called when the user changes the search box's input value. This can lead to all the query suggestions being updated.\n */\n onInput?(): Promise | void;\n /**\n * Hook called when the suggested query changes as a user traverses through the list of suggestions.\n * This is used for instant results, which are rendered based on the current suggested query.\n * @param q The new suggested query.\n */\n onSuggestedQueryChange?(q: string): Promise | void;\n}\n\n/**\n * Event sent from the registered query suggestions to the parent search box.\n */\nexport type SearchBoxSuggestionsEvent<\n SearchBoxController,\n Bindings = AnyBindings,\n> = (\n /**\n * The bindings passed from the search box to the suggestions.\n */\n bindings: SearchBoxSuggestionsBindings\n) => SearchBoxSuggestions;\n\nconst searchBoxElements = [\n 'atomic-search-box',\n 'atomic-insight-search-box',\n 'atomic-commerce-search-box',\n];\n\n/**\n * The bindings passed from the search box to the suggestions.\n */\nexport type SearchBoxSuggestionsBindings<\n SearchBoxController,\n Bindings = AnyBindings,\n> = Bindings & {\n /**\n * The unique id of the search box.\n */\n id: string;\n /**\n * Whether the search box is [standalone](https://docs.coveo.com/en/atomic/latest/usage/ssb/).\n */\n isStandalone: boolean;\n /**\n * The search box headless controller.\n */\n searchBoxController: SearchBoxController;\n /**\n * The number of queries to display when the user interacts with the search box.\n */\n numberOfQueries: number;\n /**\n * Whether to clear all active query filters when the end user submits a new query from the search box.\n */\n clearFilters: boolean;\n /**\n * Retrieves the suggested query, meaning the query that would be sent if the search is executed.\n * The suggested query changes as a user traverses through the list of suggestions.\n */\n suggestedQuery(): string;\n /**\n * Removes the current suggestions.\n */\n clearSuggestions(): void;\n /**\n * Triggers update & retrieval of all suggestions.\n */\n triggerSuggestions(): void;\n /**\n * Retrieves the current suggestions.\n */\n getSuggestions(): SearchBoxSuggestions[];\n /**\n * Retrieves the current suggestions elements.\n */\n getSuggestionElements(): SearchBoxSuggestionElement[];\n};\n\n/**\n * Dispatches an event which retrieves the `SearchBoxSuggestionsBindings` on a configured parent search box.\n * @param event Event sent from the registered query suggestions to the parent search box.\n * @param element Element on which to dispatch the event, which must be the child of a configured search box.\n */\nexport const dispatchSearchBoxSuggestionsEvent = <\n SearchBoxController,\n Bindings = AnyBindings,\n>(\n event: SearchBoxSuggestionsEvent,\n element: HTMLElement\n) => {\n element.dispatchEvent(\n buildCustomEvent('atomic/searchBoxSuggestion/register', event)\n );\n\n if (!closest(element, searchBoxElements.join(', '))) {\n throw new Error(\n `The \"${element.nodeName.toLowerCase()}\" component was not handled, as it is not a child of the following elements: ${searchBoxElements.join(\n ', '\n )}`\n );\n }\n};\n\nexport function elementHasNoQuery(el: SearchBoxSuggestionElement) {\n return !el.query;\n}\n\nexport function elementHasQuery(el: SearchBoxSuggestionElement) {\n return !!el.query;\n}\n"],"names":["webpackEmptyContext","req","e","Error","code","keys","resolve","id","module","exports","AtomicSearchBoxQuerySuggestions","componentWillLoad","_this","dispatchSearchBoxSuggestionsEvent","bindings","initialize","this","host","error","key","value","_this2","engine","_qSe","qSe","registerQuerySuggest","fetchQuerySuggestions","dispatch","count","numberOfQueries","position","Array","from","parentNode","children","indexOf","onInput","renderItems","_this3","max","searchBoxController","state","maxWithQuery","maxWithoutQuery","suggestions","slice","map","suggestion","renderItem","_this4","hasQuery","partialItem","getPartialSearchBoxSuggestionElement","i18n","_objectSpread","content","h","QuerySuggestionContainer","QuerySuggestionIcon","icon","SearchIcon","hasSuggestion","getSuggestions","length","QuerySuggestionText","onSelect","selectSuggestion","rawValue","render","element","get","AtomicSearchBoxRecentQueries","warnUser","once","_this5","logger","warn","_this6","renderIcon","Clock","_this7","storage","SafeStorage","recentQueriesList","QT","initialState","queries","retrieveLocalStorage","options","maxLength","clearFilters","subscribe","updateLocalStorage","getParsedJSON","StorageItems","RECENT_QUERIES","analyticsEnabled","setJSON","disableFeature","removeItem","_this8","query","suggestionElements","filter","recentQuery","toLowerCase","startsWith","unshift","renderClear","_this9","getPartialRecentQueryClearElement","RecentQueryClear","clear","triggerSuggestions","_this10","getPartialRecentQueryElement","RecentQueriesContainer","RecentQueryIcon","RecentQueryText","isStandalone","updateText","submit","executeRecentQuery","buildCustomEvent","name","detail","CustomEvent","bubbles","cancelable","composed","listenOnce","type","listener","addEventListener","_listener","evt","removeEventListener","handleEvent","call","_classCallCheck","_createClass","tryAccessLocalStorageOrWarn","localStorage","getItem","fallback","item","tryJSONOrWarn","JSON","parse","index","tryOrElse","setItem","obj","stringified","stringify","tryTo","orElse","console","concat","part","encodeForDomAttribute","ariaLabel","t","interpolation","escapeValue","_","class","_ref","_ref2","innerHTML","highlightedValue","hideIfLast","vg","highlightString","openingDelimiter","closingDelimiter","highlights","offset","_ref3","regexEncode","replace","str","split","ch","match","charCodeAt","join","searchBoxElements","event","dispatchEvent","closest","nodeName","elementHasNoQuery","el","elementHasQuery"],"sourceRoot":""}