"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9318],{2130:(e,r,t)=>{t.d(r,{Qp:()=>s,UN:()=>n});let a=["categories","search","cart","auth","language"];function s(e){let r=e?.customButtons??[];if(e?.headerLayout&&e.headerLayout.length>0){let t=new Set(r.map(e=>e.id)),a=e.headerLayout.filter(e=>"customButton"!==e.kind||!!e.customButtonId&&t.has(e.customButtonId)),s=new Set(a.filter(e=>"customButton"===e.kind).map(e=>e.customButtonId).filter(e=>!!e));return[...a,...r.filter(e=>!s.has(e.id)).map(e=>({id:`cb-${e.id}`,kind:"customButton",customButtonId:e.id}))]}let t=(e?.widgetOrder??a).filter((e,r,t)=>a.includes(e)&&t.indexOf(e)===r);return[{id:"logo",kind:"logo"},{id:"spacer-pre-search",kind:"spacer"},{id:"search",kind:"search"},{id:"spacer-post-search",kind:"spacer"},...[...t,...a.filter(e=>!t.includes(e))].filter(e=>"search"!==e).map(e=>({id:e,kind:e})),...r.map(e=>({id:`cb-${e.id}`,kind:"customButton",customButtonId:e.id}))]}function n(e,r){let t=function(e){switch(e){case"categories":return"showCategoriesLink";case"search":return"showSearch";case"cart":return"showCart";case"auth":return"showAuth";case"language":return"showLanguage";default:return null}}(e.kind);return!t||(r?.[t]??!0)}},15777:(e,r,t)=>{t.d(r,{U:()=>a});function a(e){if(e&&0!==e.length)return e[0]}},19630:(e,r,t)=>{t.d(r,{k:()=>s});var a=t(12115);function s(e){let{max:r=12,namespace:t="default",caseInsensitive:s=!0}=e||{},n=(0,a.useMemo)(()=>`search-history:${t}`,[t]),[l,i]=(0,a.useState)([]);(0,a.useEffect)(()=>{try{let e=localStorage.getItem(n);e&&i(JSON.parse(e))}catch{}},[n]);let o=(0,a.useCallback)(e=>{i(e);try{localStorage.setItem(n,JSON.stringify(e))}catch{}},[n]),c=(0,a.useCallback)(e=>{let t=e.trim();if(!t)return;let a=e=>s?e.toLowerCase():e,n=Date.now(),i=l.findIndex(e=>a(e.term)===a(t)),c=[...l];if(i>=0){let e=c[i];c.splice(i,1),c.unshift({term:e.term,ts:n,count:e.count+1})}else c.unshift({term:t,ts:n,count:1});c.length>r&&(c=c.slice(0,r)),o(c)},[l,r,s,o]),d=(0,a.useCallback)(e=>{let r=e.trim(),t=e=>s?e.toLowerCase():e;o(l.filter(e=>t(e.term)!==t(r)))},[l,s,o]);return{items:l,add:c,remove:d,clear:(0,a.useCallback)(()=>o([]),[o])}}},27397:(e,r,t)=>{t.d(r,{A:()=>N});var a=t(95155),s=t(12115),n=t(20063),l=t(56401),i=t(36982),o=t(51336),c=t(26497),d=t(64555),m=t(15239),u=t(95740),x=t(17268),h=t(36300),p=t(88873),f=t(19630),g=t(39607),b=t(12976),y=t(32985),v=t(38199),j=t(67093),w=t(22660);let N=({searchQuery:e,setSearchQuery:r,isModalOpen:t,setSearchModalOpen:N,containerClassName:k,leadingIcon:C})=>{let{t:S}=(0,b.k)(),{config:I}=(0,w.Ku)(),A=function(){let[e,r]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{let e=window.matchMedia("(max-width: 767px)"),t=()=>r(e.matches);return r(e.matches),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),e}(),[T,E]=(0,s.useState)(t),[_,P]=(0,s.useState)(!1),[B,$]=(0,s.useState)(null),[F,z]=(0,s.useState)([]),[O,R]=(0,s.useState)([]),L=(0,s.useRef)(null),{trackSearchQuery:M}=(0,g.y)(),U=(0,n.useSearchParams)(),W=(0,n.useRouter)(),D=(0,n.usePathname)(),q=D?.split("/")[1]||"",Q=/^[a-z]{2,3}$/.test(q)?q:"ka",{items:J,add:K,remove:H,clear:V}=(0,f.k)({namespace:"global",max:15});(0,s.useEffect)(()=>{E(t)},[t]),(0,s.useEffect)(()=>(window.dispatchEvent(new CustomEvent("komero:search-state",{detail:{open:T}})),()=>{window.dispatchEvent(new CustomEvent("komero:search-state",{detail:{open:!1}}))}),[T]),(0,s.useEffect)(()=>{let e=U.get("q")||"";e&&(r(e),Y(e))},[U]);let Z=A?6:8,Y=async e=>{let r=e?.trim()??"";if(!r||r.length<2){z([]),R([]),P(!1),$(null);return}try{P(!0),$(null),M(r),(0,v.Jz)("Search",{search_string:r,content_type:"product"});let[e,t]=await Promise.all([(0,p.zh)(r,"name","asc",1,Z),I?.ui?.enableSemanticSearch===!0?(0,j.Ec)({query:r,topK:4}).catch(()=>[]):Promise.resolve([])]),a=e.items??[];z(a.map(e=>({id:e.id,name:e.name??"Unnamed product",slug:e.slug,images:e.images,price:e.price}))),R(t.filter(e=>e.score>.7))}catch(e){$(e?.message??"Search failed"),z([]),R([])}finally{P(!1)}},G=(0,s.useMemo)(()=>(e?.trim().length??0)>=2,[e]);return(0,a.jsxs)("div",{className:"relative w-full",children:[(0,a.jsxs)("div",{className:k??"flex items-center gap-1 bg-muted/50 rounded-full shadow-md border cursor-pointer w-full mx-auto p-0 px-4 transition focus-within:border-brand-primary focus-within:ring focus-within:ring-brand-primary/30",children:[C??(0,a.jsx)(x.WI,{className:"text-gray-500"}),(0,a.jsx)(l.p,{"aria-expanded":T,"aria-label":S("components.searchDropdown.searchProducts","Search products"),autoComplete:"off",className:"w-full pl-2 py-3 bg-transparent rounded-full text-foreground placeholder-muted-foreground transition-all outline-none focus:outline-none ring-0 focus:ring-0 focus:border-transparent",id:"search-input",placeholder:S("search.placeholder","Search products..."),role:"combobox",type:"search",value:e,onBlur:()=>{setTimeout(()=>{E(!1),N(!1)},200)},onChange:e=>{let t=e.target.value;r(t),L.current&&window.clearTimeout(L.current),P(!0),z([]),R([]),L.current=window.setTimeout(()=>Y(t),300)},onFocus:()=>{E(!0),N(!0)},onKeyDown:r=>{"Enter"===r.key&&(r.preventDefault(),e.trim().length>0&&(K(e),W.push((0,y.nb)(`/category?q=${encodeURIComponent(e)}`,Q))))}})]}),(0,a.jsx)(c.N,{children:T&&(0,a.jsx)(d.P.div,{animate:{opacity:1,y:0},className:"absolute left-0 right-0 mt-5 z-50",exit:{opacity:0,y:-10},initial:{opacity:0,y:-10},transition:{duration:.2},id:"search-results",onMouseDown:e=>e.preventDefault(),children:(0,a.jsx)(i.Z,{children:(0,a.jsxs)(o.U,{className:"p-5",children:[!G&&J.length>0&&(0,a.jsxs)("div",{className:"mb-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("span",{className:"font-primary text-sm text-gray-500",children:S("search.recentSearches","Recent Searches")}),(0,a.jsx)("button",{className:"font-primary text-xs text-gray-500 underline hover:text-gray-700",onClick:V,children:S("search.clearAll","Clear all")})]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:J.map(({term:e})=>(0,a.jsxs)("div",{className:"group flex items-center gap-2 px-3 py-1 rounded-full border text-sm hover:bg-brand-primary/5",children:[(0,a.jsx)("button",{className:"font-primary hover:underline",onClick:()=>(e=>{r(e),K(e),W.push((0,y.nb)(`/category?q=${encodeURIComponent(e)}`,Q)),setTimeout(()=>{E(!1),N(!1)},50)})(e),children:e}),(0,a.jsx)("button",{"aria-label":S("search.removeTerm","Remove {term}",{term:e}),className:"opacity-60 group-hover:opacity-100",title:S("search.remove","Remove"),onClick:()=>H(e),children:"\xd7"})]},e))})]}),G&&_&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-gray-400 animate-pulse",children:[(0,a.jsx)(x.WI,{className:"h-12 w-12 mb-2 opacity-30"}),(0,a.jsx)("p",{className:"font-primary text-sm",children:S("search.searching","Searching...")})]}),G&&!!B&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-6 text-red-500",children:[(0,a.jsxs)("p",{className:"font-primary text-sm",children:[S("search.error","Error"),": ",B]}),(0,a.jsx)("p",{className:"font-primary text-xs text-gray-500 mt-1",children:S("search.tryAgain","Please try again")})]}),G&&!_&&!B&&0===F.length&&0===O.length&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-gray-400",children:[(0,a.jsx)(x.WI,{className:"h-12 w-12 mb-2 opacity-20"}),(0,a.jsx)("p",{className:"font-primary text-sm",children:S("search.noResults","No results found")})]}),!G&&0===J.length&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 text-gray-400",children:[(0,a.jsx)(x.WI,{className:"h-12 w-12 mb-3 opacity-30"}),(0,a.jsx)("p",{className:"font-primary text-sm",children:S("search.noHistory","No search history")}),(0,a.jsx)("p",{className:"font-primary text-xs text-gray-500 mt-1",children:S("search.startTyping","Start typing to search...")})]}),G&&!_&&!B&&(F.length>0||O.length>0)&&(0,a.jsxs)("div",{className:"space-y-4",children:[O.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"font-primary text-[10px] uppercase tracking-widest text-brand-primary font-bold mb-2 block px-2",children:S("search.aiSuggestions","Semantic Hits / AI Suggestions")}),(0,a.jsx)("ul",{className:"space-y-1",children:O.map(r=>(0,a.jsx)(d.P.li,{animate:{opacity:1,x:0},className:"p-2 hover:bg-brand-primary/5 rounded-md cursor-pointer border border-transparent hover:border-brand-primary/10 transition-colors",initial:{opacity:0,x:-5},onClick:()=>{K(e),W.push((0,y.nb)(`/product/${r.productId}`,Q)),E(!1)},children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"h-8 w-8 rounded-full bg-brand-primary/10 flex items-center justify-center text-brand-primary",children:(0,a.jsx)(u.A,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,a.jsx)("span",{className:"font-primary text-sm line-clamp-1 font-medium",children:r.text}),(0,a.jsxs)("span",{className:"font-primary text-[10px] text-gray-400",children:[r.brand," • ",r.category]})]})]})},r.productId))})]}),F.length>0&&(0,a.jsxs)("div",{children:[O.length>0&&(0,a.jsx)("span",{className:"font-primary text-[10px] uppercase tracking-widest text-gray-400 font-bold mb-2 block px-2 mt-2",children:S("search.exactMatches","Catalog Matches")}),(0,a.jsx)("ul",{className:"space-y-1",children:F.map(r=>(0,a.jsx)(d.P.li,{animate:{opacity:1,y:0},className:"p-2 hover:bg-gray-100 hover:text-black rounded-md cursor-pointer",exit:{opacity:0,y:-5},initial:{opacity:0,y:-5},transition:{duration:.1},onClick:()=>{K(e),W.push((0,y.nb)(`/product/${r.slug||r.id}`,Q)),E(!1)},onMouseDown:e=>e.preventDefault(),children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,h.my)(r.images)?(0,a.jsx)("div",{className:"relative h-10 w-10 flex-shrink-0 rounded-md overflow-hidden border",children:(0,a.jsx)(m.default,{fill:!0,alt:r.name??S("search.product","Product"),className:"object-cover",sizes:"40px",src:(0,h.my)(r.images)})}):(0,a.jsx)("div",{className:"h-10 w-10 rounded-md flex items-center justify-center bg-gray-100 text-gray-500",children:(0,a.jsx)(x.WI,{className:"h-5 w-5"})}),(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("span",{className:"font-primary text-sm line-clamp-1",children:r.name??S("search.unnamedProduct","Unnamed product")}),(0,a.jsx)("span",{className:"font-primary text-xs text-gray-500",children:"number"==typeof r.price?`₾${r.price}`:""})]})]})},r.id))})]})]})]})})})})]})}},28973:(e,r,t)=>{t.d(r,{E:()=>i});var a=t(95155),s=t(90368),n=t(95684),l=t(12976);let i=(