1import{a as v}from"./chunk-4K6VCNOB.js";import{a as y}from"./chunk-NRDTV7CC.js";import"./chunk-XKD2CT6A.js";import{a as m}from"./chunk-IV53BKVI.js";import"./chunk-LMHNMI66.js";import{b as x}from"./chunk-XJBAP45I.js";import{a as g,d as f}from"./chunk-SGO6C47O.js";import{a as e}from"./chunk-X6IOVEKU.js";import{c as d}from"./chunk-UX4IXQ24.js";import"./chunk-6QKRXUVD.js";import"./chunk-Z47A3HLT.js";function S(r,t){let n=null,l=null,o=(...i)=>{o.clear(),l=()=>{o.clear(),r.call(o,...i)},n=setTimeout(l,t)};return o.clear=()=>{typeof n=="number"&&(clearTimeout(n),n=null,l=null)},o.flush=()=>{l?.()},Object.defineProperty(o,"pending",{get:()=>typeof n=="number"}),o}var T=g(null),h=g(!1),k=y.vtex.loaders.intelligentSearch.suggestions,E=S(async(r,t)=>{try{T.value=await k({query:r,count:t})}catch(n){console.error(`Something went wrong while fetching suggestions 2`,n)}finally{h.value=!1}},250),z={setSearch:(r,t=4)=>{h.value=!0,E(r,t)},loading:h,suggestions:T},w=()=>z;function R(){let r=f(""),{setSearch:t,suggestions:n,loading:l}=w(),{products:o=[],searches:i=[]}=n.value||{};function p(a){r.value=a,a&&v({name:"search",params:{search_term:a}}),t(a)}return{setSearchTerm:p,searchTerm:r.value,loading:l.value,products:o,searches:i}}function P(){if(x)return"SpeechRecognition"in globalThis?new SpeechRecognition:"webkitSpeechRecognition"in self?new webkitSpeechRecognition:void 0}function q({placeholder:r}){let{searchTerm:t,setSearchTerm:n,loading:l,searches:o}=R(),i=d(null),p=d(null),a=f(!1);function D(s){s.preventDefault();let c=p.current;if(!c)return;let u=P();u&&(u.lang="pt-BR",u.addEventListener("result",F=>{let b=F.results[0][0].transcript.trim();b&&(i.current?.focus(),n(b))}),c.dataset.recording="",u.start(),setTimeout(()=>{u.stop(),delete c.dataset.recording},5e3))}return e("div",{class:"group/search-bar relative z-10 w-full lg:w-auto flex flex-col items-end",children:[e("form",{class:"relative flex items-center w-full lg:w-[420px] h-9",onSubmit:s=>{s.preventDefault(),t.length!==0&&(location.href=`/s?q=${t}`)},children:[e("input",{class:"header-transition h-full w-full bg-default-mobile-header-gray lg:bg-default-header-gray rounded-xl text-white placeholder:text-white placeholder:text-xs placeholder:leading-none pl-9 outline-none",id:"search-bar-input",onFocus:()=>a.value=!0,onBlur:()=>setTimeout(()=>a.value=!1,200),type:"text",onInput:s=>{let{value:c}=s.currentTarget;n(c)},placeholder:r,value:t,ref:i,autocomplete:"off"}),e("button",{class:"absolute right-px py-2 text-white h-full aspect-square pointable flex items-center justify-center",type:"submit","aria-label":"Realizar pesquisa",children:l?e("span",{class:"loading loading-spinner loading-xs"}):e(m,{id:"Lupa",class:"header-transition text-white w-full h-full"})}),e("button",{class:"absolute left-0 text-white font-bold h-full aspect-square py-2 flex items-center justify-center pointable data-[recording]:text-red-600 data-[recording]:animate-ping",onClick:D,ref:p,"aria-label":"Realizar pesquisa por voz",children:e(m,{id:"Microphone",class:"h-full w-full"})})]}),t&&o.length>0&&a.value&&e("div",{class:"absolute z-[-1] top-[calc(100%-12px)] flex flex-col w-full lg:w-[420px] bg-secondary px-4 pb-3 pt-4 border rounded-b-xl",children:e("div",{class:"flex flex-col gap-6",children:e("ul",{id:"search-suggestion",class:"flex flex-col",children:o.map(({term:s})=>e("li",{children:e("a",{href:`/s?q=${s}`,class:"block py-1 hover:underline",children:e("span",{children:[t," em ",e("strong",{children:s})]})})}))})})})]})}export{q as default};
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.