1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[45959],{45959:(e,t,r)=>{r.d(t,{MarketplaceFilters:()=>x});var a=r(95155),n=r(12115),s=r(35695),l=r(47863),c=r(66474),i=r(70257);let o=[1e3,2e3,3e3,5e3,7e3],u=[30,40,50,60,70],d=[{value:"price-low-to-high",label:"Low to High"},{value:"price-high-to-low",label:"High to Low"}],h=[{suffix:"-price-low-to-high",value:"price-low-to-high"},{suffix:"-price-high-to-low",value:"price-high-to-low"}];function g(e){let{title:t,children:r,defaultOpen:s=!1}=e,[i,o]=(0,n.useState)(s);return(0,a.jsxs)("div",{className:"py-3",children:[(0,a.jsxs)("button",{onClick:()=>o(!i),className:"flex items-center justify-between w-full text-left",children:[(0,a.jsx)("span",{className:"text-[11px] font-semibold text-gray-500 uppercase tracking-widest",children:t}),i?(0,a.jsx)(l.A,{className:"w-3.5 h-3.5 text-gray-300"}):(0,a.jsx)(c.A,{className:"w-3.5 h-3.5 text-gray-300"})]}),i&&(0,a.jsx)("div",{className:"mt-2.5",children:r})]})}function p(){let{categoryFilter:e,categorySlug:t,subdomain:r,businessId:p,multiStore:x,storeSubdomains:m,desktopMode:y="sidebar",mobileTriggerStyle:f="full"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},b=(0,s.useRouter)(),j=(0,s.useSearchParams)(),v=(0,s.usePathname)(),[N,w]=(0,n.useState)({colors:[],sizes:[],productTypes:[],brands:[],categories:[],saleFacets:[]}),[k,S]=(0,n.useState)(!0),[F,P]=(0,n.useState)("sidebar"===y),C=(0,n.useRef)(0),R=(0,n.useRef)(null),A=(0,n.useRef)(null),M=v.match(/^\/clicky2-1\/category\/([^/?#]+)/i),z=t||(null==M?void 0:M[1])||"",O=!!z,L=z?function(e){let t=String(e||"").trim().toLowerCase(),r={},a=!0;for(;a&&t;){a=!1;let e=h.find(e=>{let{suffix:r}=e;return t.endsWith(r)});if(e&&!r.sort){t=t.slice(0,-e.suffix.length),r.sort=e.value,a=!0;continue}let n=[...o].sort((e,t)=>t-e).find(e=>t.endsWith("-under-".concat(e)));if(n&&!r.maxPrice){t=t.slice(0,-"-under-".concat(n).length),r.maxPrice=n,a=!0;continue}let s=[...u].sort((e,t)=>t-e).find(e=>t.endsWith("-".concat(e,"-off")));s&&!r.minDiscountPercent&&(t=t.slice(0,-"-".concat(s,"-off").length),r.minDiscountPercent=s,a=!0)}return{baseSlug:t.replace(/-+$/g,""),filters:r}}(z):null,D=(null==L?void 0:L.filters)||{},U=(()=>{if(e)return e;let t=v.match(/\/category\/(.+)/);if(t&&"all"!==t[1].toLowerCase())return t[1].split("/").map(e=>e.replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())).join(" > ")})();(0,n.useEffect)(()=>{!async function(){let e=++C.current,t=performance.now();try{let a=new URLSearchParams;a.set("limit","1"),a.set("facetsOnly","1"),x?(a.set("scope","marketplace"),a.set("marketplace","clicky21"),m&&m.length>0&&a.set("storeSubdomains",m.join(","))):r&&(a.set("subdomain",r),a.set("scope","business")),p&&!x&&a.set("businessId",p),U&&a.set("categories",U),console.log("[RefineFilters] taxonomy fetch start",{runId:e,path:v,categoryFromPath:U||null,multiStore:!!x,subdomain:r||null,businessId:p||null,storeSubdomainsCount:(null==m?void 0:m.length)||0,query:a.toString()});let n=performance.now(),s=await fetch("/api/marketplace/products?".concat(a.toString())),l=performance.now(),c=await s.json(),i=performance.now();console.log("[RefineFilters] taxonomy fetch response",{runId:e,status:s.status,fetchMs:Math.round(l-n),parseMs:Math.round(i-l),totalMs:Math.round(i-t),products:Array.isArray(null==c?void 0:c.products)?c.products.length:0,brandFacets:Array.isArray(null==c?void 0:c.brandFacets)?c.brandFacets.length:0});{let r=[],a=Array.isArray(null==c?void 0:c.categoryFacets)?c.categoryFacets.map(e=>{let t="string"==typeof(null==e?void 0:e.categoryPath)?e.categoryPath:"",r=Number((null==e?void 0:e.count)||0),a=t.split(" > ").map(e=>e.trim()).filter(Boolean);return{path:t,count:r,tier1:a[0],tier2:a[1],tier3:a[2]}}).filter(e=>e.path).sort((e,t)=>e.path.localeCompare(t.path)):[];Array.isArray(null==c?void 0:c.products)&&c.products.forEach(e=>{e.brand&&"string"==typeof e.brand&&e.brand.trim()&&r.push(e.brand.trim())});let n=Array.isArray(null==c?void 0:c.brandFacets)?c.brandFacets:[],s=n.length>0?n.map(e=>({name:e.brand,count:e.count})):(function(e){let t=new Map;
1e.forEach(e=>{let r=e.toLowerCase().replace(/[^a-z]/g,"");if(!r)return;let a=t.get(r);a?a.push(e):t.set(r,[e])});let r=Array.from(t.keys()),a=new Map,n=new Set;for(let e of r){if(n.has(e))continue;let s=e,l=[...t.get(e)||[]];for(let a of r)!(a===e||n.has(a))&&function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;if(Math.abs(e.length-t.length)>r)return!1;let a=[];for(let r=0;r<=e.length;r++){a[r]=[r];for(let n=1;n<=t.length;n++){if(0===r){a[r][n]=n;continue}a[r][n]=Math.min(a[r-1][n]+1,a[r][n-1]+1,a[r-1][n-1]+ +(e[r-1]!==t[n-1]))}}return a[e.length][t.length]<=r}(e,a,2)&&(l.push(...t.get(a)||[]),n.add(a),a.length>s.length&&(s=a));n.add(e),a.set(s,l)}let s=[];return a.forEach(e=>{let t=e.sort((e,t)=>{let r=+!!e.includes(" "),a=+!!t.includes(" ");return a!==r?a-r:t.length-e.length})[0];s.push(t)}),s.sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:"base"}))})(r).map(e=>({name:e,count:0})),l=[],i=Array.isArray(null==c?void 0:c.sizeFacets)?c.sizeFacets.map(e=>({size:String((null==e?void 0:e.size)||"").trim(),count:Number((null==e?void 0:e.count)||0)})).filter(e=>e.size):[],o=[],u=Array.isArray(null==c?void 0:c.saleFacets)?c.saleFacets.map(e=>({threshold:Number((null==e?void 0:e.threshold)||0),count:Number((null==e?void 0:e.count)||0)})).filter(e=>Number.isFinite(e.threshold)&&e.threshold>0):[],d=new Map;a.forEach(e=>{let t=e.tier3||e.tier2||e.tier1||e.path;if(!t)return;let r=d.get(t);r?d.set(t,{...r,count:r.count+e.count}):d.set(t,{...e,path:t,count:e.count})});let h=Array.from(d.values()).sort((e,t)=>e.path.localeCompare(t.path));w({colors:l,sizes:i,productTypes:o,brands:s,categories:h,saleFacets:u,priceRange:void 0}),requestAnimationFrame(()=>{console.log("[RefineFilters] taxonomy render complete",{runId:e,totalMs:Math.round(performance.now()-t),colors:l.length,sizes:i.length,brands:s.length,productTypes:o.length,saleFacets:u.length})})}}catch(e){console.error("Failed to fetch and aggregate taxonomy:",e)}finally{S(!1),console.log("[RefineFilters] taxonomy fetch end",{runId:e,totalMs:Math.round(performance.now()-t)})}}()},[r,p,x,null==m?void 0:m.join(","),U,v]),(0,n.useEffect)(()=>{R.current&&(console.log("[RefineFilters] route updated after filter action",{action:A.current,pathname:v,search:j.toString(),routeUpdateMs:Math.round(performance.now()-R.current)}),R.current=null,A.current=null)},[v,j]);let E=(e,t)=>{let r=new URLSearchParams(j.toString());if(null===t)r.delete(e);else{let a=r.get(e);if(a){let n=a.split(",");if(n.includes(t)){let a=n.filter(e=>e!==t);a.length>0?r.set(e,a.join(",")):r.delete(e)}else r.set(e,[...n,t].join(","))}else r.set(e,t)}let a="?".concat(r.toString());R.current=performance.now(),A.current="".concat(e,":").concat(null!=t?t:"clear"),console.log("[RefineFilters] filter click",{key:e,value:t,currentSearch:j.toString(),nextUrl:a}),b.push(a)},T=(e,t)=>{if(!O||!L)return;let r=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=String(e||"").trim().replace(/^-+|-+$/g,"");return r?(t.maxPrice&&Number.isFinite(t.maxPrice)&&t.maxPrice>0&&(r+="-under-".concat(Math.round(t.maxPrice))),t.minDiscountPercent&&Number.isFinite(t.minDiscountPercent)&&t.minDiscountPercent>0&&(r+="-".concat(Math.round(t.minDiscountPercent),"-off")),t.sort&&(r+="-".concat(t.sort)),r):""}(L.baseSlug,{...D,...e});R.current=performance.now(),A.current=t,b.push("/clicky2-1/category/".concat(r))},_=(e,t)=>{let r=j.get(e);return!!r&&r.split(",").includes(t)},W=j.toString().length>0,q=(0,a.jsxs)("div",{className:F?"divide-y divide-gray-100":"hidden",children:[O&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(g,{title:"Sort",defaultOpen:!0,children:(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer group",children:[(0,a.jsx)("input",{type:"radio",name:"category-sort",className:"w-3.5 h-3.5 rounded border-gray-300 text-gray-900 focus:ring-gray-900",onChange:()=>T({sort:void 0},"sort:featured"),checked:!D.sort}),(0,a.jsx)("span",{className:"text-[13px] text-gray-600 group-hover:text-gray-900 transition-colors",children:"Featured"})]}),d.map(e=>(0,a.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer group",children:[(0,a.jsx)("input",{type:"radio",name:"category-sort",className:"w-3.5 h-3.5 rounded border-gray-300 text-gray-900 focus:ring-gray-900",onChange:()=>T({sort:e.value},"sort:".concat(e.value)),checked:D.sort===e.value}),(0,a.jsx)("span",{className:"text-[13px] text-gray-600 group-hover:text-gray-900 transition-colors",children:e.label})]},e.value))]})}),(0,a.jsx)(g,{title:"Price",defaultOpen:!0,children:(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer group",children:[(0,a.jsx)("input",{type:"radio",name:"category-price-bucket",className:"w-3.5 h-3.5 rounded border-gray-300 text-gray-900 focus:ring-gray-900",onChange:()=>T({maxPrice:void 0},"price:all"),checked:!D.maxPrice}),(0,a.jsx)("span",{className:"text-[13px] text-gray-600 group-hover:text-gray-900 transition-colors",children:"All Prices"})]}),o.map(e=>(0,a.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer group",children:[(0,a.jsx)("input",{type:"radio",name:"category-price-bucket",className:"w-3.5 h-3.5 rounded border-gray-300 text-gray-900 focus:ring-gray-900",onChange:()=>T({maxPrice:e},"price:under-".concat(e)),checked:D.maxPrice===e}),(0,a.jsxs)("span",{className:"text-[13px] text-gray-600 group-hover:text-gray-900 transition-colors",children:["Under Rs. ",e.toLocaleStr
1ing()]})]},e))]})}),(0,a.jsx)(g,{title:"Sale",defaultOpen:!0,children:(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer group",children:[(0,a.jsx)("input",{type:"radio",name:"category-sale-threshold",className:"w-3.5 h-3.5 rounded border-gray-300 text-gray-900 focus:ring-gray-900",onChange:()=>T({minDiscountPercent:void 0},"sale:all"),checked:!D.minDiscountPercent}),(0,a.jsx)("span",{className:"text-[13px] text-gray-600 group-hover:text-gray-900 transition-colors",children:"All Deals"})]}),N.saleFacets.filter(e=>e.count>0||D.minDiscountPercent===e.threshold).map(e=>(0,a.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer group",children:[(0,a.jsx)("input",{type:"radio",name:"category-sale-threshold",className:"w-3.5 h-3.5 rounded border-gray-300 text-gray-900 focus:ring-gray-900",onChange:()=>T({minDiscountPercent:e.threshold},"sale:".concat(e.threshold,"-off")),checked:D.minDiscountPercent===e.threshold}),(0,a.jsxs)("span",{className:"text-[13px] text-gray-600 group-hover:text-gray-900 transition-colors",children:[e.threshold,"% OFF and above"]})]},e.threshold))]})}),N.sizes.length>0&&(0,a.jsx)(g,{title:"Size",defaultOpen:!0,children:(0,a.jsx)("div",{className:"space-y-1.5",children:N.sizes.map(e=>(0,a.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer group",children:[(0,a.jsx)("input",{type:"checkbox",className:"w-3.5 h-3.5 rounded border-gray-300 text-gray-900 focus:ring-gray-900",onChange:()=>E("sizes",e.size),checked:_("sizes",e.size)}),(0,a.jsx)("span",{className:"text-[13px] text-gray-600 group-hover:text-gray-900 transition-colors flex-1",children:e.size}),e.count>0&&(0,a.jsx)("span",{className:"text-[11px] text-gray-300",children:e.count})]},e.size))})})]}),!O&&!k&&N.priceRange&&(0,a.jsx)(g,{title:"Price",defaultOpen:!1,children:(0,a.jsx)("div",{className:"space-y-1.5",children:(()=>{let{max:e}=N.priceRange,t=[];return e<=3e3?t.push({label:"Under Rs. ".concat(Math.ceil(.5*e).toLocaleString()),min:"0",max:String(Math.ceil(.5*e))},{label:"Rs. ".concat(Math.ceil(.5*e).toLocaleString()," - ").concat(Math.ceil(.75*e).toLocaleString()),min:String(Math.ceil(.5*e)),max:String(Math.ceil(.75*e))},{label:"Over Rs. ".concat(Math.ceil(.75*e).toLocaleString()),min:String(Math.ceil(.75*e)),max:""}):e<=1e4?t.push({label:"Under Rs. 2,000",min:"0",max:"2000"},{label:"Rs. 2,000 - 5,000",min:"2000",max:"5000"},{label:"Rs. 5,000 - 7,000",min:"5000",max:"7000"},{label:"Over Rs. 7,000",min:"7000",max:""}):t.push({label:"Under Rs. 5,000",min:"0",max:"5000"},{label:"Rs. 5,000 - 10,000",min:"5000",max:"10000"},{label:"Rs. 10,000 - 20,000",min:"10000",max:"20000"},{label:"Over Rs. 20,000",min:"20000",max:""}),t.map((e,t)=>(0,a.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer group",children:[(0,a.jsx)("input",{type:"radio",name:"price",className:"w-3.5 h-3.5 rounded border-gray-300 text-gray-900 focus:ring-gray-900",onChange:()=>{let t=new URLSearchParams(j.toString());t.set("minPrice",e.min),e.max?t.set("maxPrice",e.max):t.delete("maxPrice");let r="?".concat(t.toString());R.current=performance.now(),A.current="price:".concat(e.min,"-").concat(e.max||"max"),console.log("[RefineFilters] price click",{label:e.label,min:e.min,max:e.max||null,nextUrl:r}),b.push(r)},checked:j.get("minPrice")===e.min}),(0,a.jsx)("span",{className:"text-[13px] text-gray-500 group-hover:text-gray-900 transition-colors",children:e.label})]},t))})()})}),!k&&N.colors.length>0&&(0,a.jsx)(g,{title:"Color",defaultOpen:!1,children:(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:N.colors.slice(0,16).map(e=>(0,a.jsx)("button",{onClick:()=>E("colors",e),className:"px-2.5 py-1 text-[11px] font-medium rounded-full border transition-all capitalize ".concat(_("colors",e)?"bg-gray-900 text-white border-gray-900":"text-gray-600 border-gray-200 hover:border-gray-400"),children:e},e))})}),!k&&N.brands.length>0&&(0,a.jsx)(g,{title:"Brand",defaultOpen:!1,children:(0,a.jsx)("div",{className:"space-y-1.5",children:N.brands.map(e=>(0,a.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer group",children:[(0,a.jsx)("input",{type:"checkbox",className:"w-3.5 h-3.5 rounded border-gray-300 text-gray-900 focus:ring-gray-900",onChange:()=>E("brands",e.name),checked:_("brands",e.name)}),(0,a.jsx)("span",{className:"text-[13px] text-gray-500 group-hover:text-gray-900 transition-colors truncate flex-1",children:e.name}),e.count>0&&(0,a.jsx)("span",{className:"text-[11px] text-gray-300",children:e.count})]},e.name))})}),!k&&N.productTypes.length>1&&(0,a.jsx)(g,{title:"Type",defaultOpen:!1,children:(0,a.jsx)("div",{className:"space-y-1.5",children:N.productTypes.slice(0,10).map(e=>(0,a.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer group",children:[(0,a.jsx)("input",{type:"checkbox",className:"w-3.5 h-3.5 rounded border-gray-300 text-gray-900 focus:ring-gray-900",onChange:()=>E("productType",e.name),checked:_("productType",e.name)}),(0,a.jsx)("span",{className:"text-[13px] text-gray-500 group-hover:text-gray-900 transition-colors flex-1 truncate",children:e.name}),(0,a.jsx)("span",{className:"text-[11px] text-gray-300",children:e.count})]},e.name))})})]});if("drawer"===y){let e="icon"===f;return(0,a.jsxs)("div",{className:"relative z-40 block",children:[(0,a.jsx)("div",{className:"flex w-full items-center justify-end",children:(0,a.jsxs)("button",{type:"button",onClick:()=>P(!0),className:"inline-flex items-center justify-center rounded-[12px] border border-gray-200 bg-white text-gray-700 transition-colors hover:border-gray-300 hover:bg-gray-50 hover:text-gray-900 ".concat(e?"relative h-10 w-10 p-0 lg:h-11 lg:w-auto lg:gap-2 lg:rounded-[14px] lg:px-4":"h-9 gap-2 px-3 text-[12px] font-medium tracking-tight lg:h-11 lg:w-auto lg:justify-center lg:gap-2 lg:rounded-[14px] lg:px-4 lg:text-[13px]"),"aria-label":"Open filters",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,a.jsx)(i.A,{className:"h-4 w-4"}),e?(0,a.jsx)("span",{className:"hidden lg:inline",children:"Filter"}):(0,a.jsx)("span",{children:"Filter"})]}),(0,a.jsx)("span",{className:"inline-flex items-center ".concat(e?"absolute -right-1 -top-1":"gap-2"),children:W&&(0,a.jsx)("span",{className:"inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-gray-900 px-1.5 text-[10px] text-white",children:Array.from(j.keys()).length})})]})}),F&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button","aria-label":"Close filters",className:"fixed inset-0 z-40 bg-black/15",onClick:()=>P(!1)}),(0,a.jsxs)("div",{className:"fixed inset-x-0 bottom-0 z-50 overflow-y-auto rounded-t-[24px] border-t border-gray-200 bg-white px-5 py-5 shadow-2xl sm:inset-x-auto sm:right-0 sm:w-[320px] sm:rou
1nded-none sm:border-l sm:border-t-0",style:{top:"var(--clicky-header-offset, 88px)",height:"calc(100vh - var(--clicky-header-offset, 88px))"},children:[(0,a.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>P(!1),className:"inline-flex items-center gap-2 text-left",children:[(0,a.jsx)(i.A,{className:"h-4 w-4 text-gray-500"}),(0,a.jsx)("h3",{className:"text-xs font-bold text-gray-900 uppercase tracking-wider",children:"Filter"}),(0,a.jsx)(l.A,{className:"w-3.5 h-3.5 text-gray-400"})]}),W&&(0,a.jsx)("button",{type:"button",onClick:()=>{R.current=performance.now(),A.current="clear_all",b.push(O&&L?"/clicky2-1/category/".concat(L.baseSlug):window.location.pathname),P(!1)},className:"text-[11px] text-gray-400 hover:text-gray-900 transition-colors",children:"Clear"})]}),q]})]})]})}return(0,a.jsx)("div",{className:"relative z-40 w-56 flex-shrink-0 hidden lg:block",children:(0,a.jsxs)("div",{className:"sticky top-24 z-40",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>P(e=>!e),className:"inline-flex items-center gap-2 text-left",children:[(0,a.jsx)(i.A,{className:"h-4 w-4 text-gray-500"}),(0,a.jsx)("h3",{className:"text-xs font-bold text-gray-900 uppercase tracking-wider",children:"Filter"}),F?(0,a.jsx)(l.A,{className:"w-3.5 h-3.5 text-gray-400"}):(0,a.jsx)(c.A,{className:"w-3.5 h-3.5 text-gray-400"})]}),W&&(0,a.jsx)("button",{type:"button",onClick:()=>{R.current=performance.now(),A.current="clear_all",console.log("[RefineFilters] clear all click",{currentSearch:j.toString(),destination:O&&L?"/clicky2-1/category/".concat(L.baseSlug):window.location.pathname}),b.push(O&&L?"/clicky2-1/category/".concat(L.baseSlug):window.location.pathname)},className:"text-[11px] text-gray-400 hover:text-gray-900 transition-colors",children:"Clear"})]}),q]})})}function x(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)("div",{className:"min-h-[120px]","aria-hidden":"true"}),children:(0,a.jsx)(p,{...e})})}}}]);
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.