1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,242330,e=>{"use strict";var a=e.i(843476),r=e.i(271645),t=e.i(885198),s=e.i(530319),l=e.i(232521),i=e.i(24610),o=e.i(543187);function n(){return e.A(969071)}function c(){let e=(0,s.useLocation)(),c=(0,o.useReferralArrival)(),d=c?.arrivalKey,u=(0,r.useMemo)(()=>void 0===d?null:(0,r.lazy)(n),[d]),m=(0,i.useStoredCustomerToken)(),{storedCause:g,isCauseResolved:h,isLoading:f}=(0,l.useActiveCause)();return(0,r.useEffect)(()=>{if(c){if(c&&!h&&!f)return void(0,o.dismissReferralArrival)(c.arrivalKey);(0,o.reconcileReferralArrival)({pathname:e.pathname,locationKey:e.key,customerToken:m,cause:g,resolved:h},c)}},[e.pathname,e.key,m,g,h,f,c]),c?.presentation==="greeting"&&c.customerToken===m&&"/shop"===e.pathname&&(!c.destinationKey||c.destinationKey===e.key)&&h&&g?.nonprofit_id===c.cause.nonprofit_id&&"referral_link"===g.source&&u?(0,a.jsx)(t.OptionalOverlayBoundary,{onError:()=>(0,o.dismissReferralArrival)(c.arrivalKey),children:(0,a.jsx)(r.Suspense,{fallback:null,children:(0,a.jsx)(u,{cause:c.cause,onChangeCause:()=>(0,o.openReferralCausePicker)(c.arrivalKey),onDismiss:()=>(0,o.dismissReferralArrival)(c.arrivalKey)})})},c.arrivalKey):null}var d=e.i(389911),u=e.i(555436),m=e.i(373375),g=e.i(463059),h=e.i(283086),f=e.i(958377),x=e.i(878894),p=e.i(16715),y=e.i(13587),b=e.i(59992),v=e.i(398284),w=e.i(621482),S=e.i(372645),j=e.i(561138);let N=e=>({searchParams:(0,y.normalizeCatalogSearchParams)(e.searchParams).toString(),preferences:(0,j.parseShopPreferences)(e.preferences),limit:e.limit??12,preserveBareSubcategory:!0===e.preserveBareSubcategory});var k=e.i(519455),L=e.i(352940),C=e.i(665024),P=e.i(357135),A=e.i(972520);function B({current:e}){return(0,a.jsxs)("nav",{"aria-label":"Breadcrumb",className:"flex min-w-0 flex-wrap items-center gap-2 py-0 text-[11px] text-stone",children:[(0,a.jsx)(s.Link,{to:"/",className:"hover:text-forest-deep",children:"Home"}),(0,a.jsx)("span",{"aria-hidden":"true",children:"/"}),e?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.Link,{to:"/shop",className:"hover:text-forest-deep",children:"Shop All"}),(0,a.jsx)("span",{"aria-hidden":"true",children:"/"}),(0,a.jsx)("span",{"aria-current":"page",className:"min-w-0 break-words font-medium text-ink",children:e})]}):(0,a.jsx)("span",{"aria-current":"page",className:"font-medium text-ink",children:"Shop All"})]})}function R({onRetry:e,message:r="We couldnât load all products. Please try again."}){return(0,a.jsxs)("div",{role:"alert",className:"my-6 rounded-xl2 bg-card p-6",children:[(0,a.jsx)("p",{className:"mb-3",children:r}),(0,a.jsx)(k.Button,{variant:"outline",onClick:e,children:"Try Again"})]})}var T=e.i(383263),E=e.i(765757);let K=[{name:"Food & Beverage",imageBasePath:"/images/category-grocery",directoryImageBasePath:"/images/category-grocery-directory",homepage:{label:"Grocery & Pantry",order:0}},{name:"Beauty & Personal Care",imageBasePath:"/images/category-bath",directoryImageBasePath:"/images/category-bath-directory",homepage:{label:"Bath & Body",order:1}},{name:"Health & Wellness",imageBasePath:"/images/category-wellness",directoryImageBasePath:"/images/category-wellness-directory",homepage:{label:"Wellness",order:3}},{name:"Home & Garden",imageBasePath:"/images/category-home",directoryImageBasePath:"/images/category-home-directory",homepage:{label:"Home & Clean",order:2}},{name:"Pet Supplies",imageBasePath:"/images/category-pets",directoryImageBasePath:"/images/category-pets-directory",homepage:null},{name:"Baby & Toddler",imageBasePath:"/images/category-baby",directoryImageBasePath:"/images/category-baby-directory",homepage:null}];K.flatMap(({name:e,imageBasePath:a,homepage:r})=>r?[{category:e,imageBasePath:a,...r}]:[]).sort((e,a)=>e.order-a.order);let F=[400,600,800];function z(e,a){let r=e=>{let a=K.findIndex(a=>(0,E.navigationLabelKey)(a.name)===(0,E.navigationLabelKey)(e));return a<0?K.length:a};return r(e.name)-r(a.name)||e.name.localeCompare(a.name)}var $=e.i(982071),M=e.i(960788);let O="(min-width: 1280px) 395px, (min-width: 1024px) 33vw, (min-width: 640px) 50vw, 100vw";function U({departments:e,isCatalogComplete:t,isError:l,onRetry:i}){let o=(0,r.useMemo)(()=>{let a=e.filter(({name:e})=>(0,M.isBrowsableTaxonomyLabel)(e));return(a.length||t?a:K.map(({name:e})=>({name:e,subcategories:[]}))).sort(z)},[e,t]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h1",{className:"font-display text-4xl md:text-5xl",children:"Shop All"}),(0,a.jsx)("div",{className:"py-4",children:(0,a.jsx)(B,{})}),l?(0,a.jsx)(R,{onRetry:i,message:"We couldnât load all categories. Please try again."}):!t&&(0,a.jsx)("p",{role:"status",className:"sr-only",children:"Loading c
1ategories"}),t&&!o.length?(0,a.jsx)("p",{className:"py-12 text-stone",children:"No categories are available right now. Please check back soon."}):(0,a.jsx)("ul",{"aria-label":"Shop categories",className:"grid grid-cols-1 gap-x-6 gap-y-10 pb-16 pt-4 sm:grid-cols-2 lg:grid-cols-3",children:o.map(({name:e,subcategories:r},t)=>{let l=(0,E.formatNavigationLabel)(e),i=new URLSearchParams({category:e}),o=`/shop?${i}`,n=K.find(a=>(0,E.navigationLabelKey)(a.name)===(0,E.navigationLabelKey)(e))?.directoryImageBasePath;return(0,a.jsxs)("li",{className:"group min-w-0",children:[(0,a.jsx)(s.Link,{to:o,"aria-label":l,className:"block aspect-[8/5] overflow-hidden rounded-xl2 bg-blush-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:n?(0,a.jsxs)("picture",{children:[(0,a.jsx)("source",{type:"image/avif",srcSet:(0,$.localImageSrcSet)(n,F,"avif"),sizes:O}),(0,a.jsx)("img",{src:`${n}-800.webp`,srcSet:(0,$.localImageSrcSet)(n,F,"webp"),sizes:O,alt:"",width:800,height:500,loading:0===t?"eager":"lazy",fetchPriority:0===t?"high":void 0,decoding:"async",className:"size-full object-cover transition-transform duration-700 motion-safe:group-hover:scale-[1.04]"})]}):(0,a.jsx)("span",{"aria-hidden":"true",className:"flex h-full items-center justify-center bg-forest-soft p-8 text-center font-display text-3xl text-forest-deep",children:l})}),(0,a.jsx)("h2",{className:"mt-4 min-w-0 break-words font-display text-xl",children:(0,a.jsx)(s.Link,{to:o,className:"hover:text-forest",children:l})}),(0,a.jsx)("ul",{className:"mt-2 space-y-1 text-[13px] text-stone",children:r.slice(0,5).map(r=>(0,a.jsx)("li",{children:(0,a.jsx)(s.Link,{className:"block min-h-6 break-words hover:text-forest",to:`/shop?${new URLSearchParams({category:e,subcategory:r.name})}`,children:(0,E.formatNavigationLabel)(r.name)})},r.name))}),(0,a.jsxs)(s.Link,{to:o,className:"mt-2 inline-flex min-h-6 max-w-full items-center gap-1 text-[13px] font-semibold text-forest hover:underline",children:[(0,a.jsxs)("span",{className:"min-w-0 break-words",children:["All ",l]}),(0,a.jsx)(A.ArrowRight,{"aria-hidden":"true",className:"h-4 w-4 shrink-0"})]})]},e)})}),(0,a.jsxs)("section",{className:"flex flex-wrap items-center justify-between gap-6 border-t border-line py-12","aria-labelledby":"directory-cause-heading",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{id:"directory-cause-heading",className:"font-display text-2xl md:text-3xl",children:"Not sure where to start?"}),(0,a.jsx)("p",{className:"mt-2 max-w-md text-stone",children:"Pick your cause first â every order you place afterwards funds it automatically."})]}),(0,a.jsxs)(k.Button,{size:"marketing",className:"bg-lime-bright text-forest-deep hover:bg-lime",onClick:T.openCausePicker,children:["Choose your cause",(0,a.jsx)(A.ArrowRight,{"aria-hidden":"true",className:"h-4 w-4"})]})]})]})}var q=e.i(302747);function I({title:e,count:r,hideCount:t=!1,children:s}){let l=null===r?null:`${r.toLocaleString()} ${1===r?"product":"products"}`;return(0,a.jsxs)("div",{className:"mb-6 flex min-w-0 flex-wrap items-center justify-between gap-x-6 gap-y-4",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-2",children:[(0,a.jsx)("h1",{className:"min-w-0 break-words font-display text-3xl md:text-[34px] md:leading-[42.5px]",children:e}),(0,a.jsx)("div",{role:"status","aria-live":"polite",className:t?"sr-only":"shrink-0 font-display text-xl text-stone",children:l??(t?"Loading product count":(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"sr-only",children:"Loading product count"}),(0,a.jsx)(q.Skeleton,{"data-testid":"product-count-skeleton","aria-hidden":"true",className:"h-4 w-24"})]}))})]}),s]})}function Q(e){return e.get("q")?.trim()?"results":e.get("category")?.trim()?"category":e.get("subcategory")?.trim()||e.get("tag")?.trim()||e.getAll("filter").includes("subscribe-save")?"results":"directory"}var V=e.i(337011);function W({categories:e,selectedCategory:r,subcategories:t,selectedSubcategory:s,isSearchActive:l,onSelectCategory:i,onSelectSubcategory:o}){let n="all"!==r,c=l||n,d=(c?t:e).filter(({name:e})=>(0,M.isBrowsableTaxonomyLabel)(e)),u=n?(0,E.formatNavigationLabel)(r):"Shop All",m=l?"Search result subcategories":n?`${u} subcategories`:"Shop categories",g=e=>`shrink-0 rounded-full border px-4 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${e?"border-forest bg-forest text-paper":"border-line bg-card text-forest-deep hover:border-forest/40 hover:bg-forest-soft/60"}`;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"border-b border-line bg-card",children:(0,a.jsx)("nav",{"aria-label":m,className:"mx-auto max-w-7xl overflow-x-auto px-6 py-3 md:py-4",children:(0,a.jsxs)("div",{className:"flex w-max min-w-full flex-nowrap gap-2 whitespace-nowrap",children:[(0,a.jsx)("button",{type:"button","aria-current":(c?"all"===s:"all"===r)?"page":void 0,className:g(c?"all"===s:"all"===r),onClick:()=>{c?o("all"):i("all")},children:"All"}),d.map(({name:e})=>{let t=c?(0,E.navigationLabelKey)(s)===(0,E.navigationLabelKey)(e):(0,E.navigationLabelKey)(r)===(0,E.navigationLabelKey)(e);return(0,a.jsx)("button",{type:"button","aria-current":t?"page":void 0,className:g(t),onClick:()=>c?o(e):i(e),children:(0,E.formatNavigationLabel)(e)},e)})]})})}),(0,a.jsx)("div",{className:"mx-auto max-w-7xl px-6 pt-6",children:(0,a.jsx)(B,{current:l?"Search results":n?u:"Shop products"})})]})}var H=e.i(975157);function _({className:e,...r}){return(0,a.jsx)("div",{className:(0,H.cn)("grid grid-cols-2 gap-x-4 gap-y-10 sm:gap-x-5 md:grid-cols-3 md:gap-y-14 xl:grid-cols-4",e),...r})}var D=e.i(741462);let G=(0,e.i(475254).default)("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);var J=e.i(262484),Y=e.i(72809);let X=()=>e.A(219758).then(e=>e.ShopFilterSheetPanel);function Z({filters:e}){let[t,s]=(0,J.useReferralOverlayState)(),{Component:l,failed:i,load:o}=(0,Y.useDeferredComponent)(X,"Mobile filters unavailable"),n=(0,r.useRef)(null);return(0,r.useEffect)(()=>{i&&s(!1)},[i,s]),(0,r.useEffect)(()=>
1{if(!t||l)return;let e=e=>{"Escape"===e.key&&(s(!1),n.current?.focus())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,l,s]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(k.Button,{ref:n,variant:"outline",size:"sm",className:"relative rounded-md sm:rounded-pill lg:hidden","aria-haspopup":"dialog","aria-expanded":t,"aria-label":e.hasActiveFilters?"Filters, active filters applied":"Filters",onPointerEnter:()=>{o()},onFocus:()=>{o()},onClick:()=>{o(),s(!t)},children:[(0,a.jsx)(G,{className:"h-4 w-4 sm:mr-2"}),(0,a.jsx)("span",{className:"sr-only sm:not-sr-only",children:"Filters"}),e.hasActiveFilters&&(0,a.jsx)("span",{"aria-hidden":"true",className:"absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-full bg-primary text-xs text-primary-foreground",children:"!"})]}),i&&(0,a.jsx)("span",{role:"status",className:"text-sm text-destructive",children:"Filters could not load. Try again."}),t&&!l&&(0,a.jsx)("span",{role:"status",className:"sr-only",children:"Loading filtersâ¦"}),l&&(0,a.jsx)(l,{open:t,setOpen:s,triggerRef:n,filters:e})]})}var ee=e.i(402971),ea=e.i(348174),er=e.i(13642),et=e.i(990715);let es=(0,r.lazy)(()=>e.A(396279).then(e=>({default:e.ShopSortSelect}))),el={category:"Category",subcategory:"Subcategory",tag:"Tag",vendor:"Vendor",newArrivals:"New Arrivals",bestSellers:"Best Sellers",lowStock:"Low Stock",subscribeAndSave:"Subscribe & Save"};function ei(e,a,r){let t=new URLSearchParams;return e.forEach((e,s)=>{(s!==a||e!==r)&&t.append(s,e)}),t}e.s(["default",0,({initialView:e,initialInput:t}={})=>{let l=(0,s.useLocation)(),[i,n]=(0,s.useSearchParams)(),A=(0,y.normalizeCatalogQuery)(i.get("q")||""),B=i.get("tag")||"",T=i.getAll("filter").includes("subscribe-save"),K=(0,v.useVisitorState)(),F=(0,r.useMemo)(()=>(0,j.parseShopPreferences)(K.snapshot.state.preferences),[K.snapshot.state.preferences]),[z,$]=(0,r.useState)(!1),O=(0,j.parseShopPreferences)(t?.preferences??F),q=function({query:e,locationKey:a,locationSearch:t,onCommit:s}){let l=(0,o.useReferralArrival)(),[i,n]=(0,r.useState)(()=>(0,y.normalizeCatalogQuery)(e)),[c,d]=(0,r.useState)(()=>(0,y.normalizeCatalogQuery)(e)),[u,m]=(0,r.useState)(a),[g,h]=(0,r.useState)(0),f=(0,r.useRef)(0),x=(0,r.useRef)(null),p=(0,r.useRef)(null),v=u!==a,w=v||null!==x.current&&x.current!==t,S=(0,b.useDebouncedValue)(i,300);(0,r.useEffect)(()=>{let e=()=>{f.current+=1,h(f.current);let e=new URLSearchParams(window.location.search);x.current=e.size?`?${e}`:"",p.current=null;let a=(0,y.normalizeCatalogQuery)(e.get("q")??"");n(a),d(a)};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]),(0,r.useEffect)(()=>{v&&(m(a),p.current!==t&&(x.current!==t&&n((0,y.normalizeCatalogQuery)(e)),d((0,y.normalizeCatalogQuery)(e))),p.current=null,x.current===t&&(x.current=null))},[v,a,t,e]),(0,r.useEffect)(()=>{l&&n(c)},[l,c]);let j=(0,r.useCallback)(()=>!l&&!(0,o.isReferralArrivalPending)()&&f.current===g,[l,g]),N=(0,r.useCallback)(e=>{p.current=e,x.current=null},[]),k=(0,r.useCallback)(e=>{if(!j())return;let a=(0,y.normalizeCatalogQuery)(e);n(a),d(a),p.current=s(a)},[s,j]);(0,r.useEffect)(()=>{w||i!==S||S!==c&&k(S)},[i,S,c,k,w]);let L=(0,r.useCallback)(e=>{j()&&(e.trim()?n(e.slice(0,y.MAX_CATALOG_QUERY_LENGTH)):k(""))},[k,j]),C=(0,r.useCallback)((e=i)=>k(e),[k,i]);return{query:i,committedQuery:c,isPending:(0,y.normalizeCatalogQuery)(i)!==c||w,isNavigating:w,changeQuery:L,submitQuery:C,preserveDraftOnNavigation:N,canCommitNavigation:j}}({query:A,locationKey:l.key,locationSearch:l.search,onCommit:function(e){let a=!!(!e&&H.trim()&&"all"===eI&&"all"!==eQ),r=l.search;return Y(t=>{let s=new URLSearchParams(t);return e?s.set("q",e):s.delete("q"),r=s.size?`?${s}`:"",eC.current=a?{sourceKey:l.key,search:r,targetKey:null}:null,s},{replace:!0}),r}}),H=q.query,{preserveDraftOnNavigation:G,canCommitNavigation:J}=q,Y=(0,r.useCallback)((e,a)=>{J()&&n(a=>{let r=new URLSearchParams("function"==typeof e?e(a):e);return G(r.size?`?${r}`:""),r},{...a,shallow:!0})},[n,G,J]),[X,eo]=(0,r.useState)(B||"all"),[en,ec]=(0,r.useState)(O.selectedVendor),[ed,eu]=(0,r.useState)(O.sortBy),[em,eg]=(0,r.useState)(O.showBestSellers),[eh,ef]=(0,r.useState)(O.showNewArrivals),[ex,ep]=(0,r.useState)(O.showLowStock),[ey,eb]=(0,r.useState)(O.showSubscribeAndSave),ev=(0,r.useRef)(JSON.stringify(O)),[ew,eS]=(0,r.useState)(!1),[ej,eN]=(0,r.useState)(null),ek=(0,r.useRef)(0),eL=(0,r.useRef)(null),eC=(0,r.useRef)(null),eP=eC.current,eA=!!(eP&&eP.search===l.search&&(null===eP.targetKey||eP.targetKey===l.ke
1y));(0,r.useEffect)(()=>{let e=eC.current;e&&(null===e.targetKey&&e.search===l.search?e.targetKey=l.key:e.targetKey!==l.key&&e.sourceKey!==l.key&&(eC.current=null))},[l.key,l.search]),(0,r.useEffect)(()=>{if(K.loading)return;let e=JSON.stringify({selectedVendor:en,sortBy:ed,showBestSellers:em,showNewArrivals:eh,showLowStock:ex,showSubscribeAndSave:ey})===ev.current;ev.current=JSON.stringify(F),e&&(ec(F.selectedVendor),eu(F.sortBy),eg(F.showBestSellers),ef(F.showNewArrivals),ep(F.showLowStock),eb(F.showSubscribeAndSave))},[F,K.loading,en,ed,em,eh,ex,ey]),(0,r.useEffect)(()=>{eo(B||"all")},[B]);let eB=q.committedQuery,eR=new URLSearchParams(i);eB?eR.set("q",eB):eR.delete("q");let eT=function(e,{initialView:a,initialInput:t,enabled:s=!0,fetcher:l=(e,a)=>(0,S.catalogRequest)("view",e,a)}={}){let i=N(e),o=a&&JSON.stringify(i)===JSON.stringify(N(t??{})),n=(0,w.useInfiniteQuery)({queryKey:["catalog-view",i],queryFn:({pageParam:e,signal:a})=>l({...i,...e},a),initialPageParam:{offset:0,generation:void 0},getNextPageParam:e=>e.hasMore?{offset:e.offset+e.limit,generation:e.generation}:void 0,initialData:o?{pages:[a],pageParams:[{offset:0,generation:void 0}]}:void 0,staleTime:18e5,refetchOnWindowFocus:!1,enabled:s}),c=(0,r.useRef)(n.data);(0,r.useEffect)(()=>{n.data&&(c.current=n.data)},[n.data]);let d=(n.data??c.current)?.pages??[],u=n.data?.pages.at(-1),m=d.at(-1),g=!n.data&&!!m,h=0;d.forEach((e,a)=>{0===e.offset&&(h=a)});let f=d.slice(Math.max(0,h)).flatMap(e=>e.products);return{...n,data:u,displayData:m,products:f,isPreviousData:g,hasNextPage:!g&&n.hasNextPage}}({searchParams:eR.toString(),preferences:{selectedVendor:en,sortBy:ed,showBestSellers:em,showNewArrivals:eh,showLowStock:ex,showSubscribeAndSave:ey},preserveBareSubcategory:eA},{initialView:e,initialInput:t,enabled:!q.isNavigating}),eE=eT.displayData??eT.data,eK=eT.isLoading,eF=eT.isError&&!eE,ez=eT.isError&&!!eE,e$=!!eT.data,eM=eT.refetch,eO=q.isPending||eT.isPreviousData?Q(eR):eE?.view??Q(i),eU="category"===eO,eq=(0,r.useMemo)(()=>eE?.filters??{...(0,j.parseShopPreferences)({selectedVendor:en,sortBy:ed,showBestSellers:em,showNewArrivals:eh,showLowStock:ex,showSubscribeAndSave:ey}),selectedType:i.get("category")||"all",selectedSubcategory:i.get("subcategory")||"all",selectedTag:B||"all",selectedLetter:null},[eE,en,ed,em,eh,ex,ey,i,B]),eI=eq.selectedType,eQ=eq.selectedSubcategory,eV=(0,r.useMemo)(()=>({departments:eE?.departments??[],subcategories:(eE?.departments??[]).flatMap(e=>e.subcategories.map(a=>({...a,department:e.name}))),tags:(eE?.facets.tags??[]).map(({type:e,count:a})=>({name:e,count:a}))}),[eE]),eW=!!eB.trim(),eH=(0,y.normalizeCatalogQuery)(H)===A&&X===(B||"all"),e_=!q.isPending&&!eT.isPreviousData&&eH;(0,r.useEffect)(()=>{if("directory"===eO||!eE||!e_||K.loading)return;let e={selectedVendor:eq.selectedVendor,sortBy:eq.sortBy,showBestSellers:eq.showBestSellers,showNewArrivals:eq.showNewArrivals,showLowStock:eq.showLowStock,showSubscribeAndSave:ey&&eq.showSubscribeAndSave};if(Object.entries(e).every(([e,a])=>K.snapshot.state.preferences[e]===a))return;let a=setTimeout(()=>{J()&&K.store.setPreferences(e).then(()=>$(!1)).catch(()=>$(!0))},500);return()=>clearTimeout(a)},[eO,eE,e_,K.loading,K.snapshot.state.preferences,K.store,eq,ey,J]),(0,r.useEffect)(()=>{if(!eE||!e_||!J())return;let e=eE.filters;X!==e.selectedTag&&eo(e.selectedTag),en!==e.selectedVendor&&ec(e.selectedVendor),em!==e.showBestSellers&&eg(e.showBestSellers),eh!==e.showNewArrivals&&ef(e.showNewArrivals),ex!==e.showLowStock&&ep(e.showLowStock),ey&&!e.showSubscribeAndSave&&eb(!1),eE.cleared.length&&(ek.current+=1,eN({id:ek.current,message:`Unavailable filters cleared: ${eE.cleared.map(e=>el[e]).join(", ")}.`})),eE.canonicalSearch!==i.toString()&&Y(new URLSearchParams(eE.canonicalSearch),{replace:!0})},[eE,e_,X,en,em,eh,ex,ey,i,Y,J]),(0,r.useEffect)(()=>{if(!ej)return;let e=ej.id,a=window.setTimeout(()=>{eN(a=>a?.id===e?null:a)},1e3);return()=>window.clearTimeout(a)},[ej]);let eD=(0,r.useCallback)(e=>{if(eb(e),e||!T)return;let a=ei(i,"filter","subscribe-save");a.toString()!==i.toString()&&Y(a)},[T,i,Y]),eG=(0,r.useCallback)(e=>{let a="all"!==e&&(0,M.isBrowsableTaxonomyLabel)(e)?(0,D.findCategoryName)(eV,e)??e:"all";if("all"!==a&&eq.selectedType.trim().toLowerCase()===a.trim().toLowerCase())return;eC.current=null;let r=new URLSearchParams(i);"all"===a?(r.delete("category"),r.delete("subcategory")):(r.set("category",a),eI.trim().toLowerCase()!==a.trim().toLowerCase()&&r.delete("subcategory")),r.toString()!==i.toString()&&Y(r)},[eI,eq.selectedType,i,Y,eV]),eJ=(0,r.useCallback)(e=>{eC.current=null;let a=new URLSearchParams(i);"all"!==e&&(0,M.isBrowsableTaxonomyLabel)(e)?a.set("subcategory",(0,D.findSubcategoryName)(eV,eI,e)??e):a.delete("subcategory"),a.toString()!==i.toString()&&Y(a)},[eI,i,Y,eV]),eY=(0,r.useCallback)(e=>{let a=new URLSearchParams(i);"all"!==e&&(0,M.isBrowsableTaxonomyLabel)(e)?a.set("tag",e):a.delete("tag"),a.toString()!==i.toString()&&Y(a)},[i,Y]),{changeQuery:eX,submitQuery:eZ}=q,e0=(0,r.useCallback)(()=>eX(""),[eX]),e1=(0,r.useCallback)(e=>
1eZ(e),[eZ]),e2=(0,r.useMemo)(()=>eE?.facets??{categories:[],subcategories:[],tags:[],vendors:[],filterCounts:{newArrivals:0,bestSellers:0,lowStock:0,subscribeAndSave:0}},[eE]),e4=(0,ea.useHeaderSearchSuggestions)(H),e3=(0,r.useCallback)(e=>{eZ(e.label)},[eZ]),e6=(0,r.useMemo)(()=>({query:H,onQueryChange:eX,onClear:e0,onSubmit:e1,suggestions:e4,onSuggestionSelect:e3}),[H,eX,e0,e1,e4,e3]),e5=(0,r.useMemo)(()=>e2.categories.map(({type:e})=>({name:e})),[e2.categories]),e8=(0,r.useMemo)(()=>e2.subcategories.map(({type:e})=>({name:e})),[e2.subcategories]),e7=eT.products,e9=e7.length,ae=eE?.total??0,aa=e$&&e_,ar=!!eT.hasNextPage,at=(0,r.useCallback)(()=>{aa&&!eT.isFetching&&eT.hasNextPage&&eT.fetchNextPage()},[eT,aa]),as=ar?(0,a.jsx)("div",{ref:eL,className:"flex flex-col items-center justify-center py-8 gap-4",children:(0,a.jsxs)(k.Button,{variant:"outline",onClick:at,disabled:!aa||eT.isFetching,className:"min-w-[200px]",children:["Load More (",ae-e9," remaining)"]})}):null;(0,r.useEffect)(()=>{if("directory"===eO)return;let e=new IntersectionObserver(e=>{e[0].isIntersecting&&ar&&at()},{threshold:.1,rootMargin:"100px"});return eL.current&&e.observe(eL.current),()=>e.disconnect()},[ar,eO,at]);let al=(0,r.useCallback)(()=>{eX(""),eo("all"),ec("all"),eu("newest"),eg(!1),ef(!1),ep(!1),eb(!1);let e=new URLSearchParams(i);for(let a of["q","subcategory","tag"])e.delete(a);eU||e.delete("category"),Y(ei(e,"filter","subscribe-save")),K.store.setPreferences({...(0,j.parseShopPreferences)(null)}).then(()=>$(!1)).catch(()=>$(!0))},[Y,i,eU,K.store,eX]),{selectedVendor:ai,selectedType:ao,selectedSubcategory:an,selectedTag:ac}=eq,ad=["all"!==ai&&{id:"vendor",label:`Vendor: ${ai}`,removeLabel:`Remove vendor ${ai}`,remove:()=>ec("all")},!eU&&"all"!==ao&&{id:"category",label:`Category: ${(0,E.formatNavigationLabel)(ao)}`,removeLabel:`Remove category ${(0,E.formatNavigationLabel)(ao)}`,remove:()=>eG("all")},"all"!==an&&{id:"subcategory",label:`Subcategory: ${(0,E.formatNavigationLabel)(an)}`,removeLabel:`Remove subcategory ${(0,E.formatNavigationLabel)(an)}`,remove:()=>eJ("all")},"all"!==ac&&{id:"tag",label:`Tag: ${(0,E.formatNavigationLabel)(ac)}`,removeLabel:`Remove tag ${(0,E.formatNavigationLabel)(ac)}`,remove:()=>eY("all")},eq.showNewArrivals&&{id:"new-arrivals",label:"New Arrivals",removeLabel:"Remove New Arrivals filter",icon:h.Sparkles,remove:()=>ef(!1)},eq.showBestSellers&&{id:"best-sellers",label:"Best Sellers",removeLabel:"Remove Best Sellers filter",icon:f.Flame,className:"bg-lime/20 text-forest-deep",remove:()=>eg(!1)},eq.showLowStock&&{id:"low-stock",label:"Low Stock",removeLabel:"Remove Low Stock filter",icon:x.AlertTriangle,className:"bg-warning-soft text-warning",remove:()=>ep(!1)},eq.showSubscribeAndSave&&{id:"subscribe-save",label:"Subscribe & Save",removeLabel:"Remove Subscribe & Save filter",icon:p.RefreshCw,remove:()=>eD(!1)}].filter(e=>!!e),au=!!(H||eq.selectedLetter||ad.length>0),am=(0,r.useMemo)(()=>({filterCounts:e2.filterCounts,showNewArrivals:eq.showNewArrivals,setShowNewArrivals:ef,showBestSellers:eq.showBestSellers,setShowBestSellers:eg,showLowStock:eq.showLowStock,setShowLowStock:ep,showSubscribeAndSave:eq.showSubscribeAndSave,setShowSubscribeAndSave:eD,hasActiveFilters:au,onClearFilters:al,selectedVendor:eq.selectedVendor,setSelectedVendor:ec,vendorsWithCounts:e2.vendors,selectedCategory:eq.selectedType,setSelectedCategory:eG,categoriesWithCounts:e2.categories,showCategoryFilter:!eU,selectedSubcategory:eq.selectedSubcategory,setSelectedSubcategory:eJ,subcategoriesWithCounts:e2.subcategories,selectedTag:eq.selectedTag,setSelectedTag:eY,tagsWithCounts:e2.tags}),[e2,eU,eq,au,al,eG,eJ,eY,eD]);return(0,a.jsxs)("div",{className:"min-h-screen bg-background",children:[(0,a.jsx)(ee.default,{search:e6}),z&&(0,a.jsx)("p",{role:"alert",className:"px-6 py-3 text-center text-sm",children:"Your shopping preferences could not be saved. Please try changing the filter again."}),(0,a.jsxs)(d.MainContent,{children:["directory"!==eO&&(0,a.jsx)(W,{categories:e5,selectedCategory:eq.selectedType,subcategories:e8,selectedSubcategory:eq.selectedSubcategory,isSearchActive:eW,onSelectCategory:eG,onSelectSubcategory:eJ}),(0,a.jsxs)("div",{className:`mx-auto max-w-7xl px-6 ${"directory"===eO?"py-8 md:py-10":"pb-16 pt-5"}`,children:[ej&&(0,a.jsx)("p",{role:"status","aria-live":"polite",className:"sr-only",children:ej.message},ej.id),"directory"===eO?(0,a.jsx)(U,{departments:eV.departments,isCatalogComplete:e$,isError:eF||ez,onRetry:()=>{eM()}}):(0,a.jsxs)("div",{className:"flex gap-8",children:[(0,a.jsx)("aside",{"aria-label":"Filters",className:`hidden lg:block flex-shrink-0 transition-all duration-300 ${ew?"w-12":"w-60"}`,children:(0,a.jsxs)("div",{className:"sticky top-[var(--storefront-header-height)] max-h-[calc(100vh-var(--storefront-header-height)-15px)] bg-card rounded-xl2 border border-line overflow-hidden flex flex-col",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-4 pb-2",children:[!ew&&(0,a.jsx)("p",{className:"font-semibold text-foreground",children:"Filters"}),(0,a.jsx)("button",{onClick:()=>eS(!ew),className:"p-1.5 hover:bg-muted rounded-md transition-colors ml-auto",title:ew?"Expand filters":"Collapse filters",children:ew?(0,a.jsx)(g.ChevronRight,{className:"h-4 w-4"}):(0,a.jsx)(m.ChevronLeft,{className:"h-4 w-4"})})]}),!ew&&(0,a.jsx)("div",{className:"overflow-y-auto px-6 pb-6 flex-1 scrollbar-thin",children:(0,a.jsx)(V.FilterContent,{...am})}),ew&&au&&(0,a.jsx)("div",{className:"flex justify-center py-2",children:(0,a.jsx)("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 text-xs flex items-center justify-center",children:"!"})})]})}),(0,a.jsxs)("section",{"aria-label":"Products",className:"min-w-0 flex-1",children:[(0,a.jsx)(I,{title:eU?(0,E.formatNavigationLabel)(eq.selectedType):A.trim()?`Search results for â${A.trim()}â`:"Shop products",count:aa?ae:null,hideCount:eU,children:(0,a.jsxs)("div",{role:"toolbar","aria-label":"Product results",className:"flex items-center gap-2 sm:gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"hidden text-sm text-muted-foreground sm:inline",children:"Sort"}),(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)(k.Button,{variant:"outline",disabled:!0,className:"w-32 rounded-pill bg-card sm:w-44","aria-label":"Loading sort products",children:D.SHOP_SORT_OPTIONS.find(e=>e.value===eq.sortBy)?.label}),children:(0,a.jsx)(es,{value:eq.sortBy,onChange:eu})})]}),(0,a.jsx)(Z,{filters:am})]})}),(ad.length>0||eq.selectedLetter)&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-4",children:[(0,a.jsx)(P.RemovableChipList,{label:"Applied filters",chips:ad,size:"md",onRemove:e=>ad.find(a=>
1a.id===e)?.remove(),removeClassName:"hover:bg-foreground/10",className:"min-w-0"}),(0,a.jsx)("button",{onClick:al,className:"text-sm text-muted-foreground hover:text-foreground transition-colors underline",children:"Clear all"})]}),(0,a.jsx)("h2",{className:"sr-only",children:"Products"}),ez&&(0,a.jsx)(R,{onRetry:()=>{eM()}}),!aa&&e7.length>0&&!ez&&(0,a.jsx)("p",{role:"status",className:"mb-4 text-sm text-stone",children:"Updating productsâ¦"}),(!eK||0!==e7.length)&&(eF||ez||aa||0!==ae)?eF?(0,a.jsx)(R,{onRetry:()=>{eM()}}):ae>0?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(_,{"aria-busy":!aa,className:aa?"animate-fade-in":"opacity-60",children:e7.map(e=>(0,a.jsx)(L.ProductCard,{product:e},e.id))}),as,!ar&&e$&&ae>12&&(0,a.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"Youâve reached the end"})]}):ez?null:(0,a.jsxs)("div",{className:"text-center py-16",children:[(0,a.jsx)(u.Search,{className:"h-16 w-16 mx-auto text-muted-foreground/50 mb-4"}),(0,a.jsx)("p",{className:"text-lg text-muted-foreground mb-2",children:"No products found"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Try adjusting your search or filters"}),au&&(0,a.jsx)(k.Button,{variant:"outline",onClick:al,children:"Clear Filters"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{role:"status","aria-label":"Loading products",className:"sr-only",children:"Loading products"}),(0,a.jsx)(_,{"aria-busy":"true",children:(0,a.jsx)(C.ProductGridSkeleton,{count:12})})]})]})]})]})]}),(0,a.jsx)(er.default,{}),(0,a.jsx)(c,{}),(0,a.jsx)(et.BackToTop,{})]})}],242330)}]);
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.