{"version":3,"sources":["webpack://@verndale/toolkit/./src/js/modules/coveo/engine.js","webpack://@verndale/toolkit/./src/js/modules/coveo/components/search-box-global.js","webpack://@verndale/toolkit/./src/js/modules/react-components/header-search/HeaderSearch.js","webpack://@verndale/toolkit/./src/js/modules/react-components/header-search/index.js"],"names":["wrapper","dataset","coveoConfig","config","response","result","request","clientOrigin","body","headlessEngine","buildSearchEngine","SearchBoxGlobal","props","controller","labels","state","setState","useState","searchURI","searchValue","setSearchValue","inputRef","useRef","buttonRef","blured","setBlured","isSearching","setIsSearching","useEffect","suggestionStyle","handleSuggestionClick","e","targetPage","handleSubmit","React","focusedElement","firstSuggestion","lastSuggestion","suggestion","CoveoListing","localization","searchFields","searchBoxHeader","buildSearchBox","setPipeline","loadPipelineActions","setSearchHub","loadSearchHubActions","registerFieldsToInclude","loadFieldActions","registerAdvancedSearchQueries","loadAdvancedSearchQueryActions","HeaderSearch"],"mappings":"2KAMA,MAAMA,EAAU,SAAS,uBAAuB,oCAAoC,EAAE,IAAM,SAAS,uBAAuB,yCAAyC,EAAE,GAEjK,CAAC,QAAAC,CAAO,EAAID,EAEZE,EAAc,KAAK,MAAMD,EAAQ,KAAK,EAEtCE,EAAS,CACX,eAAgBD,EAAY,eAC5B,YAAaA,EAAY,OACzB,OAAQ,CACN,mCAAqCE,IACnCA,EAAS,KAAK,QAAQ,QAASC,GAAWA,CAAM,EACzCD,GAET,wCAA0CA,GAAaA,EACvD,yCAA2CA,GAAaA,CAC1D,EACA,kBAAmB,CAACE,EAASC,IAAiB,CAC5C,GAAIA,IAAiB,iBAAkB,CACrC,MAAMC,EAAO,KAAK,MAAMF,EAAQ,IAAI,EAGpCA,EAAQ,KAAO,KAAK,UAAUE,CAAI,CACpC,CAKF,CACJ,EAEaC,G,EAAiBC,MAAkB,CAC9C,cAAeP,CACjB,CAAC,C,+FCpCM,MAAMQ,EAAmBC,GAAU,CACxC,KAAM,CAAC,WAAAC,CAAU,EAAID,EACf,CAAC,OAAAE,CAAM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,GAAc,EACpD,CAAC,wBAAAuC,CAAuB,G,EAAIC,MAAiBxC,GAAc,EAC3D,CAAC,8BAAAyC,CAA6B,G,EAAIC,MAA+B1C,GAAc,EACrFA,aAAwByC,EAA+B,CAAE,GAAI,iBAAiBtC,EAAM,UAAU,CAAE,CAAC,EACjGH,aAAwBuC,EAAwBP,CAAY,CAAC,EAC7DhC,aAAwBqC,EAAa5C,EAAY,kBAAkB,CAAC,EACpEO,aAAwBmC,EAAY1C,EAAY,iBAAiB,CAAC,CACpE,CAAC,EAKGgC,gBAAC,OAAI,UAAU,0CAA0C,EACvDA,gBAACvB,EAAA,CAAgB,WAAY+B,EAAiB,OAAQF,EAAc,YAAa5B,EAAM,YAAa,SAAS,UAAU,CAAC,CAC1H,CAEN,CAEA,MAAe2B,EClDf,EAAeL,OAAWkB,CAAY,C","file":"scripts/556.dc0acfcb.js","sourcesContent":["/* eslint-disable no-unused-vars */\nimport {\n buildSearchEngine,\n getSampleSearchEngineConfiguration,\n} from '@coveo/headless';\n\nconst wrapper = document.getElementsByClassName('coveo-search-results__main-wrapper')[0] || document.getElementsByClassName('coveo-search-results__global-search-box')[0] ;\n\nconst {dataset} = wrapper;\n\nconst coveoConfig = JSON.parse(dataset.coveo);\n\nconst config = {\n organizationId: coveoConfig.OrganizationId,\n accessToken: coveoConfig.ApiKey,\n search: {\n preprocessSearchResponseMiddleware: (response) => {\n response.body.results.forEach((result) => result);\n return response;\n },\n preprocessFacetSearchResponseMiddleware: (response) => response,\n preprocessQuerySuggestResponseMiddleware: (response) => response,\n },\n preprocessRequest: (request, clientOrigin) => {\n if (clientOrigin === 'searchApiFetch') {\n const body = JSON.parse(request.body);\n // E.g., modify facet requests\n // body.facets = [...];\n request.body = JSON.stringify(body);\n }\n\n if (clientOrigin === 'analyticsFetch') {\n // E.g., send data to a third party\n }\n }\n}\n\nexport const headlessEngine = buildSearchEngine({\n configuration: config,\n});\n","/* eslint-disable react/prop-types */\nimport React, {useEffect, useState, useRef} from 'react';\n\nexport const SearchBoxGlobal = (props) => {\n const {controller} = props;\n const {labels} = props;\n const [state, setState] = useState(controller.state);\n const searchURI = props.resultsPage;\n const [searchValue, setSearchValue] = useState('');\n const inputRef = useRef(null);\n const buttonRef = useRef(null);\n const [blured, setBlured] = useState(false);\n const [isSearching, setIsSearching] = useState(false);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), [\n controller,\n ]);\n\n useEffect(() => setBlured(true), []);\n\n const suggestionStyle = {\n cursor: 'pointer',\n };\n\n const handleSuggestionClick = (e) => {\n e.preventDefault();\n const targetPage = `${searchURI}#q=${e.target.innerText}`;\n if(window.location.toString().split('#')[0] === targetPage.split('#')[0]) {\n window.location = targetPage;\n window.location.reload();\n } else {\n window.location = targetPage;\n }\n }\n\n const handleSubmit = (e) => {\n e?.preventDefault();\n const targetPage = `${searchURI}#q=${searchValue}`;\n controller.clear();\n if(window.location.toString().split('#')[0] === targetPage.split('#')[0]) {\n window.location = targetPage;\n window.location.reload();\n } else {\n window.location = targetPage;\n }\n setIsSearching(true);\n setBlured(false);\n }\n\n return (\n
{\n if(e.key === 'ArrowDown' && state.suggestions.length > 0) {\n e.preventDefault();\n const focusedElement = document.querySelector('.coveo-search-results__search-box-suggestion:focus');\n const firstSuggestion = document.querySelector('.coveo-search-results__search-box-suggestion:first-child');\n const lastSuggestion = document.querySelector('.coveo-search-results__search-box-suggestion:last-child');\n\n if(focusedElement === null) {\n firstSuggestion.focus();\n } else if(focusedElement === lastSuggestion) {\n // firstSuggestion.focus();\n document.getElementById('coveo-search-results-search-box-header').focus();\n } else {\n focusedElement.nextSibling.focus();\n }\n }\n\n if(e.key === 'ArrowUp' && state.suggestions.length > 0) {\n e.preventDefault();\n const focusedElement = document.querySelector('.coveo-search-results__search-box-suggestion:focus');\n const firstSuggestion = document.querySelector('.coveo-search-results__search-box-suggestion:first-child');\n const lastSuggestion = document.querySelector('.coveo-search-results__search-box-suggestion:last-child');\n\n if(focusedElement === null) {\n lastSuggestion.focus();\n } else if(focusedElement === firstSuggestion) {\n // lastSuggestion.focus();\n document.getElementById('coveo-search-results-search-box-header').focus();\n } else {\n focusedElement.previousSibling.focus();\n }\n }\n }}\n >\n \n {\n controller.updateText(e.target.value);\n setBlured(false);\n setSearchValue(e.target.value);\n }\n }\n onKeyDown={(e) => {\n setBlured(false);\n if (e.key === 'Enter') {\n handleSubmit(e)\n }\n }}\n placeholder={labels.searchPlaceholder}\n onBlur={(e) => {\n if(e.relatedTarget && (e.relatedTarget.classList.contains('coveo-search-results__search-box-search'))) {\n setBlured(false);\n } else if(window.innerWidth >= 1280) {\n setBlured(true);\n } else {\n setBlured(false);\n }\n }}\n\n />\n \n {\n if(props.modifier !== '--header') {\n setSearchValue('');\n }\n controller.clear();\n setBlured(true);\n }}\n className={`coveo-search-results__search-box-clear ${searchValue ? 'coveo-search-results__search-box-clear--active' : ''} ${blured ?'coveo-search-results__search-box-clear--blured':''}`}\n >\n \n \n \n \n {state.suggestions.length > -8 && (\n
\n {state.suggestions.map((suggestion) => (\n handleSuggestionClick(e)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n handleSuggestionClick(e)\n }\n }}\n dangerouslySetInnerHTML={{__html: suggestion.highlightedValue}}\n >\n ))}\n
\n )}\n {\n if (searchValue.length > 0){\n handleSubmit();\n }\n }}\n className={`coveo-search-results__search-box-search ${state.value ? '' : ''}`}\n >\n \n \n \n \n
\n );\n};\n","/* eslint-disable react/prop-types */\n\nimport React, {useEffect} from 'react';\nimport {\n loadPipelineActions,\n loadSearchHubActions,\n loadFieldActions,\n loadAdvancedSearchQueryActions,\n buildSearchBox\n} from '@coveo/headless';\nimport {SearchBoxGlobal} from '../../coveo/components/search-box-global';\nimport {headlessEngine} from '../../coveo/engine';\n\nfunction CoveoListing(props) {\n const localization = JSON.parse(props.localization);\n const searchFields = JSON.parse(props.searchFields);\n const coveoConfig = JSON.parse(props.coveo);\n const searchBoxHeader = buildSearchBox(headlessEngine, {\n options: {\n highlightOptions: {\n notMatchDelimiters: {\n open: '',\n close: '',\n },\n correctionDelimiters: {\n open: '',\n close: '',\n },\n },\n },\n });\n\n // Setting up the custom properties for the search engine (Pipeline, SearchHub, fields, etc.)\n useEffect(() => {\n const {setPipeline} = loadPipelineActions(headlessEngine);\n const {setSearchHub} = loadSearchHubActions(headlessEngine);\n const {registerFieldsToInclude} = loadFieldActions(headlessEngine);\n const {registerAdvancedSearchQueries} = loadAdvancedSearchQueryActions(headlessEngine);\n headlessEngine.dispatch(registerAdvancedSearchQueries(({ aq: `@bil_language=${props.language}`})));\n headlessEngine.dispatch(registerFieldsToInclude(searchFields));\n headlessEngine.dispatch(setSearchHub(coveoConfig.QuerySearchHubName));\n headlessEngine.dispatch(setPipeline(coveoConfig.QueryPipelineName));\n });\n\n // Setting up the custom properties for the search engine (Pipeline, SearchHub, fields, etc.)\n\n return (\n
\n \n
\n );\n}\n\nexport default CoveoListing;\n","import React from 'react';\nimport HeaderSearch from './HeaderSearch';\n\nexport default React.memo(HeaderSearch);\n"],"sourceRoot":""}