1import{e as m}from"./ScrollTrigger.js";import{c as Ce,w as S,r as w,o as Le,x as he,m as O}from"./vue.esm-bundler.js";import{k as Ae,l as Fe,m as Ee,b as Pe,a as Te}from"./analytics-data.js";import{u as Re,i as Ie,F as g,b as y}from"./use-amplitude-experiment.js";import{u as ve}from"./use-filter-dropdown.js";import{u as Oe}from"./use-master-product-card.js";import{u as ye}from"./use-quick-add-modal.js";import{F as f,S as _e,E as be,T as _,n as b}from"./wunderkind-api.js";import{B as ke,r as De}from"./base-section.js";import"./validator.js";import"./use-scroll-lock.js";import"./use-viewport-size.js";import"./use-focus-management.js";import"./use-post-atc-modal.js";import"./navigation.js";import"./create-element-if-not-defined.js";import"./swiper-core.js";import"./pagination.js";import"./classes-to-selector.js";import"./animations.js";import"./swiper.js";import"./currency.js";import"./cookies.js";import"./_commonjsHelpers.js";const l="collection-product-grid",s="collection-filter-dropdown-state";let k=!1;const C={FILTER:"filter",SORT:"sort"};class Ge extends ke{constructor(){super(`[data-section-type="${l}"]`)}init(D){const o=D.container;if(!o){m("[Allbirds section] - Collection Product Grid - init - Container not found",{},new Error("Container not found"));return}Ce({name:"CollectionProductGridSection",setup(){const{addToCartWithoutEvent:G,cardRefs:d,getVariantDescription:N,getVariantLabel:B,handleAddToCart:U,handleImageHover:M,handleImageLeave:z,initializeAllCards:Y,isDesktopQuickAddEnabled:x,isHoverGalleryEnabled:L,nextGalleryImage:H,prevGalleryImage:K,setActiveColorway:V,setActiveVariant:h,setHoverGalleryEnabled:$,setupFirstHoverGalleryPrefetch:j,teardownFirstHoverGalleryPrefetch:A,toggleSizeSelector:q}=Oe(),F="plp-hover-gallery",{getFlag:E,reportExposure:P}=Re(),J=O(()=>E(F));S(J,e=>{if(e?.status===g.SUCCESS){const r=e.value==="treatment";$(r),r&&P(F)}},{immediate:!0});const u=w(!Ie()),Q=O(()=>E(y));S(Q,e=>{if(e?.status===g.ERROR){u.value=!0;return}e?.status===g.SUCCESS&&(k||(k=!0,P(y)),u.value=e.value!=="treatment")},{immediate:!0}),S(L,e=>{e?j(o):A(o)});const W=new URL(window.location.href),T=w(W.searchParams.get(f.SORT_BY)||_e.MANUAL),R=w(o),c=ye({cardRefs:d,containerRef:R,setActiveVariant:h}),X=()=>{try{window.sessionStorage.setItem(s,JSON.stringify({isOpen:v.value}))}catch{}},Z=()=>{try{const e=window.sessionStorage.getItem(s);return e?(window.sessionStorage.removeItem(s),!!JSON.parse(e)?.isOpen):!1}catch{return window.sessionStorage.removeItem(s),!1}},I=async({featureLinkDestination:e=null,featureName:r=null,featureType:a=null,triggerType:i=null})=>{X();try{await De(["collection-product-grid","collection-header"],{preserveScroll:!0},()=>{if(window.BaseSection&&typeof window.BaseSection.getInstance=="function"){const n=o.getAttribute("data-section-id"),t=window.BaseSection.getInstance(n);t&&t.section&&(t.initialized=!1,t.section._initInstance(t))}if(ue(),i){const n=JSON.parse(o.getAttribute("data-collection-object")),t=window?.ALLBIRDS?.page?.collectionPage?.collection;switch(window.ALLBIRDS.page.collectionPage.collection={...t,...n},i){case C.FILTER:Te();break;case C.SORT:Pe({collection:n,featureLinkDestination:e,featureName:r,featureType:a});break}}},n=>{m("[Allbirds section] - CollectionProductGrid - Failed to rerender sections",{},n)})}catch(n){m("[Allbirds section] - CollectionProductGrid - Error in rerenderSectionsForFilterChange",{},n)}},{activeFilterDropdowns:ee,cleanupFilterDropdown:te,closeFilterDropdown:oe,handleClearAllFilters:re,handleClearPriceFilter:ne,handleFilterClear:ae,handleFilterDropdownChange:ie,handleFilterSubmit:ce,handlePriceRangeChange:le,initializeFilterDropdown:se,isFiltering:de,showFilterDropdown:v,syncPriceCheckboxStates:ue,toggleFilterDropdown:pe,toggleFilterMenu:me}=ve({containerRef:R,preserveParams:[f.SORT_BY],rerenderCallback:I,sectionName:l}),Se=async e=>{const r=e.target.value;T.value=r;const a=new URL(window.location.href);a.searchParams.set(f.SORT_BY,r),be(a,!0);const i=r?.toUpperCase(),n=`${window.location.pathname}?sort_by=${r}`,t=_.SORTING.KEY;await I({featureLinkDestination:n,featureName:i,featureType:t,triggerType:C.SORT})},we=e=>{const a=e.currentTarget.getAttribute("href");if(!window.location.search)return;e.preventDefault();const n=new URL(window.location.href),t=new URL(a,window.location.origin);
1for(const[p,fe]of n.searchParams.entries())t.searchParams.append(p,fe);window.location.href=t.toString()},ge=e=>{const r=o.querySelector(`[data-product-card][data-product-id="${e}"]`);if(r?.getAttribute("data-product-one-size")==="true"){G(e);return}const a=d.value[e],i=r?.getAttribute("data-product-name")||"",n=r?.getAttribute("data-product-unisex")==="true",t=a?.currentVariants||[],p=t.length>0&&t[0].title?.includes("UK ");c.open(e,{colorway:a?.selectedColorway||"",isUkSize:p,isUnisex:n,productImage:a?.selectedImage?.src||"",productName:i,variants:t})};return Le(()=>{se(o,{consumePersistedState:Z}),Y(o),c.init(),Ae({collection:window.ALLBIRDS.page.collectionPage.collection,sectionName:l}),Fe({collection:window.ALLBIRDS.page.collectionPage.collection,featureType:_.PILL_TOGGLE.KEY,sectionName:l}),Ee({locationParam:b.LOCATIONS.COLLECTION,sectionName:l,typeParam:b.TYPES.LINK,valueParam:window.ALLBIRDS.page.collectionPage.collection?.url||""})}),he(()=>{te(),A(o),c.cleanup(),o._sizeSelectorMouseLeaveHandler&&(o.removeEventListener("mouseleave",o._sizeSelectorMouseLeaveHandler),o._sizeSelectorMouseLeaveHandler=null)}),{activeFilterDropdowns:ee,cardRefs:d,closeFilterDropdown:oe,closeSizeModal:c.close,getVariantDescription:N,getVariantLabel:B,handleAddToCart:U,handleClearAllFilters:re,handleClearPriceFilter:ne,handleFilterClear:ae,handleFilterDropdownChange:ie,handleFilterSubmit:ce,handleGenderToggleClick:we,handleImageHover:M,handleImageLeave:z,handlePriceRangeChange:le,handleQuickAddVariantSelect:c.handleVariantSelect,handleSortByChange:Se,isDesktopQuickAddEnabled:x,isFiltering:de,isHoverGalleryEnabled:L,nextGalleryImage:H,openSizeModal:ge,prevGalleryImage:K,quickAddModalState:c.quickAddModal,setActiveColorway:V,setActiveVariant:h,showCollectionFilter:u,showFilterDropdown:v,sortBy:T,toggleFilterDropdown:pe,toggleFilterMenu:me,toggleSizeSelector:q}}}).mount(o)}}new Ge;
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.