1import{l as e}from"./helpers-ePuekpbm.js";import{n as t}from"./debounce-B316v5qs.js";import{O as n,at as r,g as i,st as a}from"./reactivity.esm-bundler-DQcBDaMz.js";import{D as ee,E as te,T as o,_ as s,c,d as l,g as u,j as d,k as f,m as p,p as m}from"./runtime-dom.esm-bundler-DLvR9iDk.js";import{m as ne,r as h}from"./utlitities-DC5Jib6W.js";import{t as g}from"./dataLayerHelper-C7H3oDYN.js";import{t as _}from"./Icon-Drug-C_G.js";var v=[`data-label`,`data-loading`],re={class:`ndsmetasearch-site-search__wrap filter-phrase__combobox-wrap`},ie=[`aria-expanded`,`aria-label`],ae={class:`filter-phrase__fields-wrap`},oe={id:`site-search-search-phrase-fields`,class:`filter-phrase__fields`},se=[`placeholder`,`value`,`aria-label`,`aria-activedescendant`,`aria-expanded`],ce=[`aria-label`],le=[`aria-label`],ue={key:0,class:`visually-hidden`,role:`alert`},de=[`aria-label`,`aria-hidden`],fe=[`id`],pe={class:`filter-listbox__value`},y=[`aria-label`],b={__name:`SiteSearch`,props:{target:{type:String,default:``},submitBehavior:{type:String,default:`default`,validator:e=>[`default`,`emit`].includes(e)},popoverId:{type:String,default:`ndsmetasearch-site-search-popover`}},emits:[`submitSearch`],setup(b,{emit:me}){let x=b,he=me,S=i(``),C=i(null),w=i(null),T=i(null),E=i(null),D=i(null),O=i(!0),k=i(0),A=i(0),j=i(0),M=i(-1),N=i(``),P=i(``),F=i(),I=i(!1),L=i(!1),R=i(!1),z=null,B=null,V=new ResizeObserver(()=>{q()}),ge=e=>{switch(e.key){case`Enter`:e.preventDefault(),R.value=!0,N.value&&Z(),$();break;case`Escape`:K(),E.value.focus();break;case`ArrowDown`:M.value===-1?X(`first`):X(`next`);break;case`ArrowUp`:e.preventDefault(),X(`prev`)}},H=t.debounce(async e=>{switch(e.preventDefault(),e.key){case`Enter`:case`Escape`:case`ArrowDown`:case`ArrowUp`:case`Tab`:break;default:if(!R.value&&P.value.trim()){I.value=!1,Q(E.value?.value);let e=window.location.origin+window.location.pathname;e.endsWith(`/`)||(e+=`/`),F.value=await h(e,{searchString:E.value?.value}),F.value.length&&ye()}else K()}},500),_e=e=>{R.value=!1,I.value=!0,P.value=e.target.value},ve=(e,t=!1)=>{t&&(e.preventDefault(),e.stopPropagation()),R.value=!0,E.value.value=``,P.value=``,S.value=``,K(),S.value=``,F.value=void 0,E.value.focus(),G()},ye=()=>{o(()=>{X(`reset`),O.value=!1,T.value=w.value.parentNode,V.observe(T.value),T.value.addEventListener(`scroll`,q),document.addEventListener(`click`,J),L.value=!1,clearTimeout(B),B=setTimeout(()=>{W()},100)})},U=e=>{e.newState!==`open`&&G()},W=()=>{let e=w.value?.closest(`.js-popover-modal`);if(e){z!==e&&(z?.removeEventListener(`beforetoggle`,U),z=e,z.addEventListener(`beforetoggle`,U));let t=e.querySelector(`.js-popover-modal-content`);e.scrollHeight>e.offsetHeight?t.style.setProperty(`--min-height`,e.scrollHeight+`px`):t.style.removeProperty(`--min-height`)}},G=()=>{let e=w.value?.closest(`.js-popover-modal-content`);e&&e.style.removeProperty(`--min-height`)},K=()=>{O.value||(N.value=``,M.value=-1,O.value=!0,F.value=void 0,T.value.removeEventListener(`scroll`,q),V.unobserve(T.value),document.removeEventListener(`click`,J),W())},q=()=>{let e=C.value;if(e){let t=e.getBoundingClientRect();A.value=t.height,k.value=0,j.value=t.width}},J=e=>{D.value&&!D.value.contains(e.target)&&K()},be=!1,Y=t=>{t.detail.state===`open`?(L.value=!1,o(()=>{let t=w.value?.closest(`.js-popover-modal`);if(t){be||=(e(t),!0);let n=t.querySelector(`.js-popover-modal-controls button`);n&&(n.focus({focusVisible:!1}),n.classList.add(`focus-hidden`),n.addEventListener(`blur`,()=>n.classList.remove(`focus-hidden`),{once:!0}))}else E.value?.focus()})):t.detail.state===`closed`&&t.detail.trigger&&t.detail.trigger.focus()};ee(()=>{window.addEventListener(`event-${x.popoverId}`,Y)}),te(()=>{clearTimeout(B),window.removeEventListener(`event-${x.popoverId}`,Y),document.removeEventListener(`click`,J),z?.removeEventListener(`beforetoggle`,U),z=null,T.value&&(T.value.removeEventListener(`scroll`,q),V.unobserve(T.value)),V.disconnect(),G()});let X=e=>{let t=D.value.querySelectorAll(`[role="option"]`),n=M.value;switch(e){case`next`:n=n===t.length?0:n+1<t.length?n+1:0;break;case`prev`:n=n===0?t.length-1:n-1>0?n-1:0;break;case`first`:n=0;break;case`reset`:n=-1;break;case`last`:n=t.length;break;default:n=parseInt(e)}
1t.forEach(e=>{e.setAttribute(`aria-selected`,`false`)}),n>=0&&(t[n].setAttribute(`aria-selected`,`true`),t[n].focus(),N.value=`site-search-search-phrase-option`+n),M.value=n},Z=()=>{let e=document.getElementById(N.value),t=e.querySelector(`.filter-listbox__value`);e&&t&&t.textContent&&Q(t.textContent)},xe=e=>{let t=e.target.closest(`[role="option"]`);N.value=t.id,Z(),$()},Q=e=>{P.value=e},$=()=>{if(P.value.trim()!==``){if(K(),R.value=!0,L.value=!0,g.push({event:`track_site_search`,searchString:P.value}),window.dispatchEvent(new CustomEvent(`close-${x.popoverId}`)),x.submitBehavior===`emit`){L.value=!1,he(`submitSearch`,P.value);return}window.location.href=ne(x.target,{searchString:P.value})}};return(e,t)=>(f(),p(`div`,{ref_key:`wrap`,ref:w,class:`ndsmetasearch-site-search__filter filter filter-phrase filter-toggle`,"data-label":e.$t(`filter.searchPhrase`),"data-loading":L.value},[t[1]||=l(`div`,{class:`ndsmetasearch-site-search__loader`,"aria-hidden":`true`},null,-1),l(`div`,re,[l(`div`,{ref_key:`combobox`,ref:C,class:`filter-combobox`,"aria-expanded":!O.value,"aria-controls":`site-search-search-phrase-fields`,"aria-label":e.$t(`filter.searchPhrase.showSearchBar`),tabindex:`0`,role:`combobox`},[l(`div`,ae,[l(`div`,oe,[l(`input`,{ref_key:`input`,ref:E,type:`search`,class:`filter-phrase__input`,placeholder:e.$t(`filter.searchPhrase.placeholder`),value:P.value,role:`combobox`,"aria-label":e.$t(`filter.searchPhrase.searchBar`),"aria-controls":`site-search-search-phrase-listbox`,"aria-autocomplete":`list`,"aria-activedescendant":N.value,"aria-expanded":!O.value,onInput:_e,onKeydown:ge,onKeyup:t[0]||=(...e)=>n(H)&&n(H)(...e)},null,40,se),l(`button`,{class:`filter-phrase__inline-button`,"aria-label":e.$t(`filter.clear`),onClick:ve},[s(_,{name:`close`})],8,ce)]),l(`button`,{class:`filter-btn filter-phrase__btn filter-btn--primary`,"aria-label":e.$t(`filter.searchPhrase.submit`),onClick:$},[s(_,{name:`search`,modifier:`filter-btn__icon`})],8,le)])],8,ie),F.value?(f(),p(`div`,ue,[F.value.length===1?(f(),p(c,{key:0},[u(a(e.$t(`filter.searchPhrase.optionInTotal`)),1)],64)):(f(),p(c,{key:1},[u(a(F.value.length)+` `+a(e.$t(`filter.searchPhrase.optionsInTotal`)),1)],64))])):m(`v-if`,!0),F.value?(f(),p(`ul`,{key:1,id:`site-search-search-phrase-listbox`,ref_key:`listbox`,ref:D,class:`filter-phrase__listbox filter-listbox`,role:`listbox`,"aria-label":e.$t(`filter.searchPhrase.searchSuggestions`),"aria-hidden":O.value,style:r({left:k.value+`px`,top:A.value+`px`,width:j.value+`px`}),onClick:q},[(f(!0),p(c,null,d(F.value,(t,n)=>(f(),p(`li`,{id:`site-search-search-phrase-option`+n,key:n,class:`filter-listbox__option`,role:`option`,"aria-selected":`false`,onClick:xe},[l(`span`,pe,a(t.Term),1),l(`span`,{class:`filter-listbox__count`,"aria-label":e.$t(`general.showResultCount`,{count:t.Count})},a(t.Count),9,y)],8,fe))),128))],12,de)):m(`v-if`,!0)])],8,v))}};export{b as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.