(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2786],{7588:(e,r,t)=>{"use strict";t.d(r,{a:()=>s});var a=t(12115);function s(){let[e,r]=a.useState(void 0);return a.useEffect(()=>{let e=window.matchMedia("(max-width: 767px)"),t=()=>{r(window.innerWidth<768)};return e.addEventListener("change",t),r(window.innerWidth<768),()=>e.removeEventListener("change",t)},[]),!!e}},15777:(e,r,t)=>{"use strict";function a(e){if(e&&0!==e.length)return e[0]}t.d(r,{U:()=>a})},19630:(e,r,t)=>{"use strict";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)=>{"use strict";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),h=t(17268),p=t(36300),x=t(88873),f=t(19630),g=t(39607),y=t(12976),b=t(32985),j=t(38199),v=t(67093),w=t(22660);let N=({searchQuery:e,setSearchQuery:r,isModalOpen:t,setSearchModalOpen:N,containerClassName:k})=>{let{t:C}=(0,y.k)(),{config:S}=(0,w.Ku)(),E=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}(),[A,I]=(0,s.useState)(t),[T,F]=(0,s.useState)(!1),[P,q]=(0,s.useState)(null),[R,_]=(0,s.useState)([]),[M,z]=(0,s.useState)([]),$=(0,s.useRef)(null),{trackSearchQuery:U}=(0,g.y)(),B=(0,n.useSearchParams)(),D=(0,n.useRouter)(),O=(0,n.usePathname)(),W=O?.split("/")[1]||"",L=/^[a-z]{2,3}$/.test(W)?W:"ka",{items:G,add:J,remove:K,clear:Q}=(0,f.k)({namespace:"global",max:15});(0,s.useEffect)(()=>{I(t)},[t]),(0,s.useEffect)(()=>(window.dispatchEvent(new CustomEvent("komero:search-state",{detail:{open:A}})),()=>{window.dispatchEvent(new CustomEvent("komero:search-state",{detail:{open:!1}}))}),[A]),(0,s.useEffect)(()=>{let e=B.get("q")||"";e&&(r(e),Z(e))},[B]);let V=E?6:8,Z=async e=>{let r=e?.trim()??"";if(!r||r.length<2){_([]),z([]),F(!1),q(null);return}try{F(!0),q(null),U(r),(0,j.Jz)("Search",{search_string:r,content_type:"product"});let[e,t]=await Promise.all([(0,x.zh)(r,"name","asc",1,V),S?.ui?.enableSemanticSearch===!0?(0,v.Ec)({query:r,topK:4}).catch(()=>[]):Promise.resolve([])]),a=e.items??[];_(a.map(e=>({id:e.id,name:e.name??"Unnamed product",slug:e.slug,images:e.images,price:e.price}))),z(t.filter(e=>e.score>.7))}catch(e){q(e?.message??"Search failed"),_([]),z([])}finally{F(!1)}},H=(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:[(0,a.jsx)(h.WI,{className:"text-gray-500"}),(0,a.jsx)(l.p,{"aria-expanded":A,"aria-label":C("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:C("search.placeholder","Search products..."),role:"combobox",type:"search",value:e,onBlur:()=>{setTimeout(()=>{I(!1),N(!1)},200)},onChange:e=>{let t=e.target.value;r(t),$.current&&window.clearTimeout($.current),F(!0),_([]),z([]),$.current=window.setTimeout(()=>Z(t),300)},onFocus:()=>{I(!0),N(!0)},onKeyDown:r=>{"Enter"===r.key&&(r.preventDefault(),e.trim().length>0&&(J(e),D.push((0,b.nb)(`/category?q=${encodeURIComponent(e)}`,L))))}})]}),(0,a.jsx)(c.N,{children:A&&(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:[!H&&G.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:C("search.recentSearches","Recent Searches")}),(0,a.jsx)("button",{className:"font-primary text-xs text-gray-500 underline hover:text-gray-700",onClick:Q,children:C("search.clearAll","Clear all")})]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:G.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),J(e),D.push((0,b.nb)(`/category?q=${encodeURIComponent(e)}`,L)),setTimeout(()=>{I(!1),N(!1)},50)})(e),children:e}),(0,a.jsx)("button",{"aria-label":C("search.removeTerm","Remove {term}",{term:e}),className:"opacity-60 group-hover:opacity-100",title:C("search.remove","Remove"),onClick:()=>K(e),children:"\xd7"})]},e))})]}),H&&T&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-gray-400 animate-pulse",children:[(0,a.jsx)(h.WI,{className:"h-12 w-12 mb-2 opacity-30"}),(0,a.jsx)("p",{className:"font-primary text-sm",children:C("search.searching","Searching...")})]}),H&&!!P&&(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:[C("search.error","Error"),": ",P]}),(0,a.jsx)("p",{className:"font-primary text-xs text-gray-500 mt-1",children:C("search.tryAgain","Please try again")})]}),H&&!T&&!P&&0===R.length&&0===M.length&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-gray-400",children:[(0,a.jsx)(h.WI,{className:"h-12 w-12 mb-2 opacity-20"}),(0,a.jsx)("p",{className:"font-primary text-sm",children:C("search.noResults","No results found")})]}),!H&&0===G.length&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 text-gray-400",children:[(0,a.jsx)(h.WI,{className:"h-12 w-12 mb-3 opacity-30"}),(0,a.jsx)("p",{className:"font-primary text-sm",children:C("search.noHistory","No search history")}),(0,a.jsx)("p",{className:"font-primary text-xs text-gray-500 mt-1",children:C("search.startTyping","Start typing to search...")})]}),H&&!T&&!P&&(R.length>0||M.length>0)&&(0,a.jsxs)("div",{className:"space-y-4",children:[M.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:C("search.aiSuggestions","Semantic Hits / AI Suggestions")}),(0,a.jsx)("ul",{className:"space-y-1",children:M.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:()=>{J(e),D.push((0,b.nb)(`/product/${r.productId}`,L)),I(!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))})]}),R.length>0&&(0,a.jsxs)("div",{children:[M.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:C("search.exactMatches","Catalog Matches")}),(0,a.jsx)("ul",{className:"space-y-1",children:R.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:()=>{J(e),D.push((0,b.nb)(`/product/${r.slug||r.id}`,L)),I(!1)},onMouseDown:e=>e.preventDefault(),children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,p.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??C("search.product","Product"),className:"object-cover",sizes:"40px",src:(0,p.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)(h.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??C("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)=>{"use strict";t.d(r,{E:()=>i});var a=t(95155),s=t(90368),n=t(95684),l=t(12976);let i=({className:e,size:r=25,onClick:t})=>{let{t:i}=(0,l.k)();return(0,a.jsx)(n.T,{isIconOnly:!0,"aria-label":i("components.goBackButton.goBack","Go back"),className:`flex items-center bg-transparent gap-2 ${e||""}`,onPress:t,children:(0,a.jsx)(s.A,{size:r})})}},33461:(e,r,t)=>{"use strict";t.d(r,{A:()=>s});var a=t(95155);function s({size:e=40,className:r="",style:t={}}){return(0,a.jsxs)("div",{className:`santa-hat ${r}`,style:{position:"absolute",top:-(.6*e),right:-(.3*e),width:e,height:e,zIndex:10,animation:"santa-hat-wiggle 2s ease-in-out infinite",...t},children:[(0,a.jsxs)("svg",{fill:"none",style:{width:"100%",height:"100%",filter:"drop-shadow(2px 2px 4px rgba(0,0,0,0.2))"},viewBox:"0 0 100 100",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.jsx)("path",{d:"M20 60 Q30 20, 50 15 Q70 20, 80 60 L70 65 Q50 30, 30 65 Z",fill:"#DC2626",stroke:"#B91C1C",strokeWidth:"1"}),(0,a.jsx)("ellipse",{cx:"50",cy:"65",fill:"#FFFFFF",rx:"32",ry:"6"}),(0,a.jsx)("ellipse",{cx:"50",cy:"64",fill:"#F3F4F6",rx:"32",ry:"5"}),(0,a.jsx)("circle",{cx:"50",cy:"12",fill:"#FFFFFF",r:"8"}),(0,a.jsx)("circle",{cx:"50",cy:"12",fill:"#F9FAFB",r:"7"}),(0,a.jsx)("circle",{cx:"48",cy:"10",fill:"#E5E7EB",opacity:"0.6",r:"2"}),(0,a.jsx)("circle",{cx:"53",cy:"13",fill:"#E5E7EB",opacity:"0.6",r:"1.5"}),(0,a.jsx)("path",{d:"M35 35 Q40 25, 45 30 Q42 35, 37 40 Z",fill:"#EF4444",opacity:"0.6"})]}),(0,a.jsx)("style",{children:` @keyframes santa-hat-wiggle { 0