PageSourceSearch

https://www.aimn.co.nz/cdn/shop/t/132/assets/nosto-search-header.js?v=137896563665077337881790672546

js aimn.co.nz collected 2026-10-04 13:28:26 UTC 45,109 bytes, 259 lines download raw bytes

1function nostoSearchHeaderCnvString(key,fallback){const s=window.theme&&window.theme.strings&&window.theme.strings[key];return typeof s=="string"&&s.length?s:fallback}function nostoRoundedDiscountPerc(strikePrice,salePrice){const strike=parseFloat(strikePrice),sale=parseFloat(salePrice);return Number.isNaN(strike)||Number.isNaN(sale)||strike<=sale?0:Math.round((strike-sale)/strike*100)}function nostoSearchHeaderPriceDecimals(){return nostoSearchHeaderUseRoundPrices()?0:2}function nostoSearchHeaderUseRoundPrices(){return!!(window.theme&&window.theme.settings&&window.theme.settings.nostoRoundPrices)}async function waitForNostojs(){return new Promise(resolve=>{const interval=setInterval(()=>{typeof nostojs<"u"&&(clearInterval(interval),resolve())},100)})}async function fetchSessionParams(){return await waitForNostojs(),new Promise(resolve=>{nostojs(api=>{api.getSearchSessionParams().then(response=>{resolve(response)})})})}document.addEventListener("DOMContentLoaded",async function(){const body=document.querySelector("html"),searchInput=document.querySelectorAll(".search__input"),mobileInput=document.getElementById("mobile-search"),desktopInput=document.getElementById(window.theme&&window.theme.settings&&window.theme.settings.nostoSearchInputId||"nosto-search"),searchResults=document.querySelector(".search-results"),searchContainer=document.querySelector(".nosto-search-container"),autocompleteResults=document.querySelector(".autocomplete"),searchBar=document.querySelector(".nosto-search-bar"),closeButton=document.querySelector(".nosto-close"),closeButtonDesktop=document.querySelector(".nosto-close-desktop"),backdrop=document.querySelector(".nosto-search-backdrop");function getNostoStoreCurrencySymbol(){if(typeof window.theme<"u"&&window.theme.settings&&window.theme.settings.storeCurrencyGlobalSetting)return window.theme.settings.storeCurrencyGlobalSetting;if(typeof document<"u"&&document.documentElement){var attr=document.documentElement.getAttribute("data-nosto-currency-symbol");if(attr)return attr}return""}const storeCurrencyGlobalSetting=getNostoStoreCurrencySymbol(),accountId=window.theme&&window.theme.settings&&window.theme.settings.nostoAccountId||"",sessionParams=await fetchSessionParams(),sessionParamsString=JSON.stringify(sessionParams).replace(/"([^"]+)":/g,"$1:");document.querySelector(".site-search-left")?.addEventListener("click",function(){if(searchBar.style.display==="none"||searchBar.style.display===""){searchBar.style.display="block";var headWrap=document.querySelector(".template-index #HeaderWrapper");headWrap?.classList.remove("is-light");var headWrapWidth=document.querySelector(".template-index #HeaderWrapper .page-width");headWrapWidth&&(headWrapWidth.style.backgroundColor="white");var searchBarNostoMobile=document.querySelector(".nosto-search-bar");searchBarNostoMobile&&(searchBarNostoMobile.style.backgroundColor="white")}else{searchBar.style.display="none";var headWrap2=document.querySelector(".template-index #HeaderWrapper");headWrap2?.classList.add("is-light");var headWrapWidth2=document.querySelector(".template-index #HeaderWrapper .page-width");headWrapWidth2&&(headWrapWidth2.style.backgroundColor="transparent")}});function debounce(func,wait){let timeout;return function(...args){clearTimeout(timeout),timeout=setTimeout(()=>func.apply(this,args),wait)}}const nostoApi=await new Promise(resolve=>{nostojs(api=>resolve(api))});function recordSearch(type,query,searchResult,options){nostoApi.recordSearch(type,query,searchResult,options)}function recordSearchSubmit(query){nostoApi.recordSearchSubmit(query)}function recordSearchClick(type,hit){nostoApi.recordSearchClick(type,hit)}function handleSearchKey(event){if(event.key!=="Enter")return;const searchTerm=event.target.value.trim();if(!searchTerm.length){event.preventDefault(),fetchAndRenderPopular();return}recordSearchSubmit(searchTerm);const searchUrl=`/search?q=${encodeURIComponent(searchTerm)}`;window.location.href=searchUrl}function handleAutocompleteClick(event){const el=event.target.closest(".autocomplete-suggestion");if(!el)return;const type=el.dataset.type||"unknown",position=Number(el.dataset.position||0),queryText=el.dataset.keyword||el.innerText.trim(),redirectUrl=(el.dataset.redirect||"").trim(),targetUrl=redirectUrl.length>0?redirectUrl:`/search?q=${encodeURIComponent(queryText)}`;recordSearchClick("autocomplete",{url:targetUrl,type,query:queryText,position}),window.location.href=targetUrl}function renderAutocompleteResults({keywords=[],popular=[]}={}){const hasKeywords=Array.isArray(keywords)&&keywords.length>0,hasPopular=Array.isArray(popular)&&popular.length>0;if(!hasKeywords&&!hasPopular){autocompleteResults.innerHTML="",autocompleteResults.style.display="none";return}let html="";if(hasPopular){const filteredPopularSearches=[...popular].filter(popularSearch=>typeof popularSearch.query=="string"&&popularSearch.query.trim().length>1).slice(0,6);html+="<h4>POPULAR SEARCHES</h4>
1",filteredPopularSearches.forEach((item,index)=>{const label=item?.query||"",redirectUrl=`/search?q=${encodeURIComponent(label)}`||"";index===filteredPopularSearches.length-1?html+=`
2            <a 
3            href="${redirectUrl}"
4              class="autocomplete-suggestion"
5              data-type="popular"
6              data-keyword="${label}"
7              data-querytext="${label}"
8              data-redirect="${redirectUrl}"
9              data-position="${index}"
10              role="button"
11              tabindex="0"
12              style="margin-bottom: 15px; cursor: pointer;"
13            >
14              ${label}
15            </a>
16          `:html+=`
17            <a 
18            href="${redirectUrl}"
19              class="autocomplete-suggestion"
20              data-type="popular"
21              data-keyword="${label}"
22              data-querytext="${label}"
23              data-redirect="${redirectUrl}"
24              data-position="${index}"
25              role="button"
26              tabindex="0"
27              style="cursor: pointer;"
28            >
29              ${label}
30            </a>
31          `})}hasKeywords&&(html+="<h4>SEARCH SUGGESTIONS</h4>",keywords.forEach((item,index)=>{const label=item?._highlight?.keyword||item?.keyword||"",keyword=item?.keyword||"",redirectUrl=`/search?q=${encodeURIComponent(label)}`||"";index===keywords.length-1?html+=`
32            <a  
33            href="${redirectUrl}"
34              class="autocomplete-suggestion"
35              data-type="keyword"
36              data-keyword="${keyword}"
37              data-redirect="${redirectUrl}"
38              data-position="${index}"
39              style="margin-bottom: 15px"
40            >
41              ${label}
42            </a>
43          `:html+=`
44            <a 
45             href="${redirectUrl}"
46              class="autocomplete-suggestion"
47              data-type="keyword"
48              data-keyword="${keyword}"
49              data-redirect="${redirectUrl}"
50              data-position="${index}"
51            >
52              ${label}
53            </a>
54          `})),autocompleteResults.innerHTML=html,autocompleteResults.style.display="flex",searchContainer.style.display="flex",document.querySelectorAll(".autocomplete-suggestion").forEach(suggestion=>{suggestion.addEventListener("click",handleAutocompleteClick),suggestion.addEventListener("keydown",e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),handleAutocompleteClick({target:suggestion}))})})}async function fetchAndRenderPopular(){backdrop.style.display="block",closeButtonDesktop.style.display="block";try{const popular=(await(await fetch("https://search.nosto.com/v1/graphql",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:`
55            query ($query: String) {
56              search(
57                accountId: "${accountId}",
58                sessionParams: ${sessionParamsString},
59                query: $query,
60                products: { size: 0 },
61                keywords: { size: 0, emptyQueryMatchesAll: true },
62                popularSearches: { size: 12, emptyQueryMatchesAll: true }
63              ) {
64                popularSearches {
65                  hits {
66                    query
67                  }
68                }
69              }
70            }
71          `,variables:{query:""}})})).json())?.data?.search?.popularSearches?.hits||[];renderAutocompleteResults({keywords:[],popular})}catch(e){console.error("[popular searches] Error:",e)}}searchInput.forEach(input=>{input.addEventListener("keyup",handleSearchKey),input.addEventListener("focus",async()=>{(input.value||"").trim().length?(backdrop.style.display="block",closeButtonDesktop.style.display="block"):await fetchAndRenderPopular()})}),searchInput.forEach(input=>{input.addEventListener("input",debounce(async function(event){backdrop.style.display="block",closeButtonDesktop.style.display="block";const searchQuery=event.target.value.trim();if(searchQuery.length===0){searchResults.style.display="none",searchResults.innerHTML="",await fetchAndRenderPopular();return}recordSearch("autocomplete",{query:searchQuery},{},{isKeyword:!1});try{const result=await(await fetch("https://search.nosto.com/v1/graphql",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:`
72                query ($query: String) {
73                  search(
74                    accountId: "${accountId}",
75                    sessionParams: ${sessionParamsString},
76                    query: $query,
77                    products: { size: 6 },
78                    keywords: { size: 6, emptyQueryMatchesAll: true },
79                    popularSearches: { 
80                      size: 6,
81                      emptyQueryMatchesAll: true
82                    }
83                  ) {
84                    products {
85                      hits {
86                        productId
87                        categoryIds
88                        name
89                        datePublished
90                        url
91                        imageUrl
92                        alternateImageUrls
93                        price
94                        listPrice
95                        priceCurrencyCode
96                        reviewCount
97                        tags1
98                        customFields {
99                          key
100                          value
101                        }
102                        skus {
103                          name
104                          price
105                          url
106                          availability
107                          id
108                          customFields {
109                            key 
110                            value
111                          }
112                        }
113                      }
114                      total
115                    }
116                    keywords {
117                      hits {
118                        keyword
119                        _redirect
120                        _highlight {
121                          keyword
122                        }
123                      }
124                    }
125                    popularSearches {
126                      hits {
127                        query
128                      }
129                    }
130                  }
131                }
132              `,variables:{query:searchQuery}})})).json();recordSearch("serp",{query:searchQuery,products:{sort:[],filter:[]}},{products:{hits:(result?.data?.search?.products?.hits||[]).map(hit=>({productId:hit.productId})),fuzzy:!1,total:result?.data?.search?.products?.total||0,size:(result?.data?.search?.products?.hits||[]).length,from:0}}),renderSearchResults(result?.data?.search?.products?.hits||[]),renderAutocompleteResults({keywords:result?.data?.search?.keywords?.hits||[],popular:result?.data?.search?.popularSearches?.hits||[]})}catch(error){console.error("Error:",error)}},250))});function renderBadges(productElement,product,excludeTags){const badgesContainer=productElement.querySelector(".replace-badges-search");if(!badgesContainer||badgesContainer.innerHTML.trim()==="")return;const badgesDiv=badgesContainer.previousElementSibling;if(!badgesDiv)return;const content=badgesContainer.textContent.trim();try{let parsedContent=JSON.parse(content);const storeBadges=document.querySelectorAll(".store-badges .badge"),badgeMap={};
132storeBadges.forEach(badge=>{const badgeId=badge.getAttribute("data-badge-id");badgeMap[badgeId]=badge.outerHTML}),parsedContent.forEach(id=>{let newContent=badgeMap[id]||id;const newElement=document.createElement("div");newElement.innerHTML=newContent;const badgeIdNumericPart=id.split("/").pop();excludeTags.includes(badgeIdNumericPart)&&(newElement.style.display="none"),badgesDiv.appendChild(newElement)});const badges=badgesDiv.querySelectorAll(".badge"),badgeGroups={};badges.forEach(badge=>{const groupClass=Array.from(badge.classList).find(cls=>cls.match(/^q-\d+-p-\d+$/));groupClass&&(badgeGroups[groupClass]||(badgeGroups[groupClass]=[]),badgeGroups[groupClass].push(badge))});let zIndex=100;Object.entries(badgeGroups).forEach(([,group])=>{group.forEach(badge=>{badge.style.zIndex=zIndex}),zIndex--})}catch(error){console.error("[renderBadges] Error details:",{message:error.message,stack:error.stack,content})}}function renderSearchResults(results){if(!results||results.length===0){searchResults.style.display="none",searchResults.innerHTML="";return}let html="";const skuAddToCartLabel=nostoSearchHeaderCnvString("nostoSearchSkuAddToCart","Add to cart");results.forEach(product=>{const pd=nostoSearchHeaderPriceDecimals(),formattedPrice=Number(product.price||0).toFixed(pd),formattedListPrice=Number(product.listPrice||0).toFixed(pd),lowest30dPriceField=product?.skus?.[0]?.customFields?.find(field=>field.key==="frykland_pricehistory-lowest");let lowest30dPriceAmount=null;const productTitleCustom=(product?.url?.split("/products/")?.[1]||"").split("?")[0].split("#")[0];if(lowest30dPriceField)try{const lowest30dPrice=JSON.parse(lowest30dPriceField.value);lowest30dPriceAmount=parseFloat(lowest30dPrice.amount).toFixed(pd)}catch{lowest30dPriceAmount=null}typeof window<"u"&&window.theme&&window.theme.settings&&window.theme.settings.showProductPriceHistory||(lowest30dPriceAmount=null);const reviewsRatingField=product.customFields?.find(field=>field.key==="reviews-rating"),reviewsRatingRaw=reviewsRatingField?JSON.parse(reviewsRatingField.value).value:null,reviewsRating=reviewsRatingRaw==null?null:String(reviewsRatingRaw).split("(")[0].trim()||null,hasBundleTag=Array.isArray(product.tags1)&&product.tags1.includes("bundle"),customBadgesField=product.customFields?.find(field=>field.key==="custom-badges");let badgeData="[]";customBadgesField&&(badgeData=customBadgesField.value);const wcategories=product?.categoryIds||[],discountBoxes=document.querySelector(".logged-in-discounts-box-overview-page");let bestDiscount=null;if(Array.isArray(wcategories)&&discountBoxes){let i=1;for(;;){const idsSpan=discountBoxes.querySelector(`.discount-ids-${i}`),percentageSpan=discountBoxes.querySelector(`.discount-percentage-${i}`),titleSpan=discountBoxes.querySelector(`.discount-title-${i}`);if(!idsSpan||!percentageSpan||!titleSpan)break;const discountIds=idsSpan.innerText.split(",").map(id=>id.trim());if(wcategories.some(catId=>discountIds.includes(String(catId)))){const percentage=parseFloat(percentageSpan.innerText.trim());(!bestDiscount||percentage>bestDiscount.percentage)&&(bestDiscount={discountIdGroup:i,percentage,title:titleSpan.innerText.trim(),ids:discountIds})}i++}}const discountHTML=bestDiscount?`<div class="nosto-discount-banner"> ${bestDiscount.title} </div>`:"",discountPercentage=bestDiscount?.percentage??0,discountedPriceLoggedIn=product.price*discountPercentage/100,newPriceLoggedInF=product.price-discountedPriceLoggedIn,newPriceLoggedIn=Number(newPriceLoggedInF).toFixed(pd),isOnSale=product.listPrice>product.price,hasMemberDiscount=!!discountHTML,reviewsRatingCountField=product.customFields?.find(field=>field.key==="reviews-rating_count"),reviewsRatingCount=reviewsRatingCountField?reviewsRatingCountField.value:0,reviewsRatingCountSuffix=Number(reviewsRatingCount)>0?` (${reviewsRatingCount})`:"",productColorVariantsField=product.customFields?.find(field=>field.key==="product-color_variants"),productColorVariants=productColorVariantsField?productColorVariantsField.value:"",productColorVariantsCount=productColorVariants?productColorVariants.split("|").length-1:0,pricedif=lowest30dPriceAmount!==null?lowest30dPriceAmount-product.price:0;let discountPercentageC="";
132if(lowest30dPriceAmount==null){const perc=nostoRoundedDiscountPerc(product.listPrice,product.price);perc>0&&(discountPercentageC=`-${perc}%`)}else if(pricedif>1&&lowest30dPriceAmount>product.price){const perc=nostoRoundedDiscountPerc(lowest30dPriceAmount,product.price);perc>0&&(discountPercentageC=`-${perc}%`)}let priceContainerInnerHtml="";hasMemberDiscount?priceContainerInnerHtml=`
133          <span class="search-result__price money grid-product__price price discounted-price-custom">${newPriceLoggedIn} ${storeCurrencyGlobalSetting}</span>
134          <span class="search-result__price money grid-product__price price-compare-nosto product__price--compare">${formattedPrice} ${storeCurrencyGlobalSetting}</span>
135          ${discountHTML}`:isOnSale?priceContainerInnerHtml=`
136          <span class="search-result__price money grid-product__price price discounted-price-custom">${formattedPrice} ${storeCurrencyGlobalSetting}</span>
137          <span class="search-result__price money grid-product__price price-compare-nosto product__price--compare" style="${lowest30dPriceAmount==null?"":"display:none;"}">${formattedListPrice} ${storeCurrencyGlobalSetting}</span>
138          <span class="search-result__price money grid-product__price price-compare-nosto app-price product__price--compare" style="${lowest30dPriceAmount!==null&&pricedif>1&&lowest30dPriceAmount>product.price?"":"display:none;"}">${lowest30dPriceAmount} ${storeCurrencyGlobalSetting}</span>
139          <div class="custom-tooltip-notice" style="${lowest30dPriceAmount!==null&&pricedif>1&&lowest30dPriceAmount>=product.price&&lowest30dPriceAmount!==formattedListPrice?"display:flex;":"display:none;"}">
140            <div class="tooltip-content">
141              <p>${nostoSearchHeaderCnvString("nostoSearchPriceHistoryTooltip","Strikethrough price = lowest price in the last 30 days.")}</p>
142              <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x-circle"><circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>
143            </div>
144            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-info tooltip-btn" style="width: 15px;margin-right:5px;"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>
145          </div>
146          <span class="sale-perc-s-h" style="${discountPercentageC?"":"display:none;"}">${discountPercentageC}</span>`:priceContainerInnerHtml=`<span class="search-result__price money grid-product__price price">${formattedPrice} ${storeCurrencyGlobalSetting}</span>`,html+=`
147<div class="search-result nosto-product-info product-search-bundle-${hasBundleTag}" data-product-handle="${productTitleCustom}" data-variant-id="${product?.skus?.[0]?.id||""}" data-product-url="${product.url}" data-product-id="${product.productId}" data-product-image-url="${product.imageUrl}">
148  <div class="top-container">
149    <a href="${product.url}">
150      <div class="nosto-product-images"> 
151        <img src="${product.imageUrl}" alt="${product.name}" class="search-result__image"> 
152        <div class="badges-wrapper"></div>
153        <div class="replace-badges-search" style="display:none;">${badgeData}</div>
154      </div>
155    </a>
156
157    <div class="wishlist-new-pdp">
158      <button class="grid-product__action wishlist flip-animation" type="button" data-button-action="wishlist" data-empi="${product.productId}" data-with-epi="true" data-product-handle="${productTitleCustom}" data-product-id="${product.productId}" data-variant-id="${product?.skus?.[0]?.id||""}" data-product-image-url="${product.imageUrl}" data-product-url="${product.url}">
159        <div class="front-side">
160          <svg aria-hidden="true" focusable="false" role="presentation" class="header-icon" xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 26.724 23.5">
161            <g id="Icon_-_Heart" transform="translate(0.75 0.75)">
162              <path id="Path" d="M24.569,4.444a6.638,6.638,0,0,0-9.389,0L13.9,5.722,12.623,4.444a6.638,6.638,0,0,0-9.389,9.387l1.28,1.279L13.9,24.5l9.387-9.389,1.28-1.279A6.636,6.636,0,0,0,24.569,4.444Z" transform="translate(-1.29 -2.499)" fill="none" stroke="#222" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/>
163            </g>
164          </svg>
165          <span class="icon__fallback-text">Add To Wishlist</span>
166        </div>
167        <div class="back-side" aria-hidden="true">
168          <svg aria-hidden="true" focusable="false" role="presentation" class="header-icon" xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 26.724 23.5">
169            <g id="Icon_-_Heart" transform="translate(0.75 0.75)">
170              <path id="Path" d="M24.569,4.444a6.638,6.638,0,0,0-9.389,0L13.9,5.722,12.623,4.444a6.638,6.638,0,0,0-9.389,9.387l1.28,1.279L13.9,24.5l9.387-9.389,1.28-1.279A6.636,6.636,0,0,0,24.569,4.444Z" transform="translate(-1.29 -2.499)" fill="#fff" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/>
171            </g>
172          </svg>
173          <span class="icon__fallback-text">Remove From Wishlist</span>
174        </div>
175      </button>
176    </div>
177  </div>
178
179  <div class="bottom-container">
180    <a class="pdp-name-bottom-container" href="${product.url}">
181      <span class="search-result__name">${product.name}</span>
182    </a>
183
184    <div class="nosto-bottom-bar">
185      <a href="${product.url}">
186        <div class="price-container-nosto-api ${hasMemberDiscount?" price-container-nosto-api-logged-in-discounts ":""}">
187          ${priceContainerInnerHtml}
188        </div>
189      </a>
190
191      <div data-product-handle="${productTitleCustom}" class="mobile-atc-size-drawer" aria-label="Add to cart">
192        <span>+</span>
193      </div>
194    </div>
195
196    <div class="product-extra-data"> 
197      <a href="${product.url}" style="${productColorVariantsCount>0?"":"display:none;"} ">
198        <span> Colors +${productColorVariantsCount}</span>
199      </a>
200      <a href="${product.url}">
201        <span style="${reviewsRating==null?"display:none;":""}"> \u2605 ${reviewsRating}${reviewsRatingCountSuffix} </span>
202      </a>
203    </div>
204
205    <div class="sku-container-new">
206      <span class="sku-new-add-to-cart-sign">${skuAddToCartLabel} </span>
207      <div class="sku-list-new">
208        ${(product.skus||[]).filter(sku=>sku.price>0).map(sku=>`
209              <div data-variant-id="${sku.id}" class="${sku.price} sku-item ${sku.availability==="OutOfStock"?"unavailable":""}">
210                <span class="sku-name">${sku.name}</span>
211              </div>
212            `).join("")}
213      </div>
214    </div>
215  </div>
216</div>
217`}),searchResults.innerHTML=html,searchResults.style.display="flex",searchContainer.style.display="flex",attachEventListenersToButtons(),typeof bindSkuListAddToCartButtons=="function"&&bindSkuListAddToCartButtons();const excludeTags=["tag-to-exclude"];document.querySelectorAll(".nosto-product-info").forEach((productElement,index)=>{const currentProduct=results[index];renderBadges(productElement,currentProduct,excludeTags)});function reinitializeQuickShopSliders(){setTimeout(()=>{document.querySelectorAll(".quickshop .product-single__color-variants").forEach(sli
217der=>{if(slider.querySelectorAll(".quickshop .product-single__color-variant").length>4){const qsflickityInstance=Flickity.data(slider);qsflickityInstance&&qsflickityInstance.destroy(),new Flickity(slider,{cellAlign:"left",contain:!0,pageDots:!1,prevNextButtons:!0,draggable:!0})}}),document.querySelectorAll(".quickshop .product-slideshow").forEach(slider=>{const qsmainflickityInstance=Flickity.data(slider);qsmainflickityInstance&&qsmainflickityInstance.destroy(),new Flickity(slider,{cellAlign:"left",contain:!0,pageDots:!1,prevNextButtons:!1,draggable:!0})})},300)}document.querySelectorAll(".mobile-atc-size-drawer").forEach(button=>{button.addEventListener("click",async event=>{event.preventDefault(),document.getElementById("quickshop")?.classList.add("open");const productHandle=button.getAttribute("data-product-handle");if(!productHandle){console.error("Product handle not found.");return}try{const response=await fetch(`/products/${productHandle}?view=ajax`);if(!response.ok)throw new Error("Failed to fetch product page.");const productHTML=await response.text(),drawerContent=document.querySelector(".quickshop");if(drawerContent){let updateProductDetails2=function(productUrl){const newTitle=document.querySelector(".quickshop .product-single__title")?.textContent;newTitle&&(document.title=newTitle),typeof initNoDrawerCheckoutCTA=="function"&&initNoDrawerCheckoutCTA()},onVariantChange2=function({target:optionValueElement}){const productElement=document.querySelector(".quickshop .combined-product"),sectionId=document.querySelector(".quickshop #productSection")?.dataset?.sectionId;if(!productElement||!sectionId)return;const oldProductUrl=productElement.dataset.productUrl,newProductUrl=optionValueElement.dataset.productUrl,productUrl=newProductUrl||oldProductUrl,newVariantId=optionValueElement.dataset.variantId;let params=`section_id=${sectionId}&`;if(newVariantId)params+=`variant=${newVariantId}`;else{const selectedOptionValues=Array.from(document.querySelectorAll(".quickshop fieldset input:checked")).map(element=>element.dataset.optionValueId).join(",");params+=`option_values=${selectedOptionValues}`}document.querySelectorAll(".quickshop variant-input").forEach(div=>div.classList.remove("selected")),document.querySelectorAll('.quickshop input[type="radio"]').forEach(input=>input.classList.remove("selected")),optionValueElement.classList.add("selected"),optionValueElement.closest(".variant-input")?.classList.add("selected"),fetch(`${productUrl}?${params}`).then(response2=>response2.text()).then(responseText=>{const html2=new DOMParser().parseFromString(responseText,"text/html");if(newProductUrl&&oldProductUrl!==newProductUrl){if(productElement.parentNode.insertBefore(html2.querySelector(".combined-product"),productElement),productElement.remove(),updateProductDetails2(newProductUrl),reinitializeQuickShopSliders(),typeof window.cleanupPdpLengthNoticeOrphans=="function"&&window.cleanupPdpLengthNoticeOrphans(),typeof window.initPdpLengthNoticeIn=="function"){var cpLenNsh=document.querySelector(".quickshop .combined-product");cpLenNsh&&window.initPdpLengthNoticeIn(cpLenNsh)}document.querySelectorAll(".quickshop .size-selector-button").forEach(function(button2){button2.addEventListener("click",function(){theme?.SizeGuideModal?.open?.()})}),document.querySelector(`#${optionValueElement.id}`)?.focus?.(),typeof initNoDrawerCheckoutCTA=="function"&&initNoDrawerCheckoutCTA(),window.theme&&typeof window.theme.initPdpWishlist=="function"&&window.theme.initPdpWishlist(document.querySelector(".quickshop"));return}const ovs=document.querySelector(".quickshop .optionValueSelectors"),ovsNew=html2.querySelector(".optionValueSelectors");ovs&&ovsNew&&(ovs.innerHTML=ovsNew.innerHTML),typeof window.cleanupPdpLengthNoticeOrphans=="function"&&window.cleanupPdpLengthNoticeOrphans(),typeof window.initPdpLengthNoticeIn=="function"&&ovs&&window.initPdpLengthNoticeIn(ovs),document.querySelector(`#${optionValueElement.id}`)?.focus?.();const priceEl=document.querySelector(".quickshop .product__price"),priceNew=html2.querySelector(".product__price");priceEl&&(priceEl.innerHTML=priceNew?priceNew.innerHTML:""),document.querySelectorAll(".quickshop .size-selector-button").forEach(function(button2){button2.addEventListener("click",function(){theme?.SizeGuideModal?.open?.()})});const addToCartForm=document.querySelector(".quickshop .product-form"),newVariantInput=html2.querySelector('.product-form input[name="id"]');if(addToCartForm&&newVariantInput){const hidden=addToCartForm.querySelector('input[name="id"]');hidden&&(hidden.value=newVariantInput.value)}window.theme&&typeof window.theme.updatePdpWishlistFromHtml=="function"&&window.theme.updatePdpWishlistFromHtml(document.querySelector(".quickshop"),html2)}
217)};var updateProductDetails=updateProductDetails2,onVariantChange=onVariantChange2;const headerHTML=`
218              <div class="quickshop-header">
219                <div class="drawer__close">
220                  <button type="button" class="drawer__close-button js-drawer-close">
221                    <svg aria-hidden="true" focusable="false" role="presentation" class="icon icon-close" xmlns="http://www.w3.org/2000/svg" width="19.799" height="19.799" viewBox="0 0 19.799 19.799">
222                      <g id="Group_4" data-name="Group 4" transform="translate(0.707 0.707)">
223                        <line id="Line_1" data-name="Line 1" x2="26" transform="translate(0 0) rotate(45)" fill="none" stroke="#222" stroke-width="2"/>
224                        <line id="Line_2" data-name="Line 2" x2="26" transform="translate(0 18.385) rotate(-45)" fill="none" stroke="#222" stroke-width="2"/>
225                      </g>
226                    </svg>
227                    <span class="icon__fallback-text">{{ 'cart.general.close_cart' | t }}</span>
228                  </button>
229                </div>
230                <div class="h1 site-header__logo" itemscope="" itemtype="https://schema.org/Organization" aria-label="to homepage">
231                  <a href="/" itemprop="url" class="site-header__logo-link">
232                    <svg xmlns="http://www.w3.org/2000/svg" width="98.439" height="26" viewBox="0 0 404.29 98.61"><polygon points="95.05 8.05 112.93 8.05 112.93 98.44 95.05 98.22 95.05 8.05" fill="currentColor"></polygon><path d="M336.18,243h17.93v9.27s9.48-9.54,26.66-9.44c22.42-.1,36,17.86,36,17.86s10.6-17.86,36.25-17.86c37.4,0,43.08,35.8,43.08,36.89v53.66H479l0-49.62s-.95-22.95-26-22.9c-24.85,0-27.52,22.9-27.52,22.9v49.61H407.67l-.06-49.62s-2.37-22.95-26.76-22.9c-24.16,0-26.74,22.9-26.74,22.9l-.06,49.62H336.18Z" transform="translate(-218.18 -234.99)" fill="currentColor"></path><path d="M306.88,243l-.05,90.39h-18v-8s-13.35,9.15-26.26,8c-1.1-.11-43.47,1.11-44.35-47.13C218,245.49,258.12,243,258.12,243Zm-45.12,17.82s-25.49-2.35-25.71,25.51c1.8,29.34,26.81,28.7,26.81,28.7s22.95,1.9,25.91-21.78V260.86Z" transform="translate(-218.18 -234.99)" fill="currentColor"></path><path d="M501.08,243.1H519v9.27s9.48-9.54,26.66-9.44c22.42-.1,36,17.86,36,17.86a38.24,38.24,0,0,1,8.73,23.07c0,1.76,0,49.61,0,49.61H572.57l-.06-49.62s-2.37-22.95-26.76-22.9c-24.16,0-26.74,22.9-26.74,22.9L519,333.48H501.08Z" transform="translate(-218.18 -234.99)" fill="currentColor"></path><path d="M495.61,235l-16.31,0,0,8.81a39.37,39.37,0,0,1,8.22,7.26c1.49,1.82,2.34,1.43,8.07,12.58Z" transform="translate(-218.18 -234.99)" fill="currentColor"></path><path d="M591.18,258.69c0-9.11,6.49-15.76,15.68-15.76s15.6,6.65,15.6,15.76-6.49,15.83-15.6,15.83S591.18,267.8,591.18,258.69Zm4.31,0c0,6.85,4.38,11.65,11.3,11.65s11.37-4.8,11.37-11.65S613.64,247,606.79,247,595.49,251.84,595.49,258.69Zm14.69,1.7,4.33,6.41-4.87.08-3.71-6.18h-1.31v6.18h-4v-16.6H608c3.47,0,5.79,2,5.79,5.17A4.92,4.92,0,0,1,610.18,260.39Zm-5.56-6.49v3.48h3.17a1.77,1.77,0,0,0,2-1.78c0-1.23-.93-1.7-2-1.7Z" transform="translate(-218.18 -234.99)" fill="currentColor"></path></svg> 
233                  </a>
234                </div>
235                <div class="drawer__empty-right"></div>
236              </div>
237            `;drawerContent.innerHTML=headerHTML+productHTML,window.theme&&typeof window.theme.initQuickshopWishlist=="function"&&window.theme.initQuickshopWishlist(drawerContent),reinitializeQuickShopSliders(),window.lipscore?.reInitWidgets&&lipscore.reInitWidgets();const closeButtonQS=document.querySelector(".quickshop-header .drawer__close-button");closeButtonQS&&closeButtonQS.addEventListener("click",()=>{const quickshop=document.querySelector(".quickshop");quickshop&&(quickshop.innerHTML="",quickshop.style.display="none");const existingOverlay=document.querySelector(".quickshop-overlay");existingOverlay&&existingOverlay.remove()});const overlay=document.createElement("div");overlay.className="quickshop-overlay",overlay.style.cssText=`
238              width: 100%;
239              height: 100%;
240              position: fixed;
241              background: black;
242              left: 50%;
243              z-index: 1;
244              top: 50%;
245              transform: translate(-50%, -50%);
246              opacity: 0.3;
247            `,document.body.appendChild(overlay);const closeQuickShop=()=>{const quickshop=document.querySelector(".quickshop");quickshop&&(quickshop.innerHTML="",quickshop.style.display="none");const existingOverlay=document.querySelector(".quickshop-overlay");existingOverlay&&existingOverlay.remove()};overlay.addEventListener("click",closeQuickShop),drawerContent.style.display="flex",document.querySelectorAll(".quickshop .variant-input").forEach(input=>{input.addEventListener("click",()=>{document.querySelectorAll(".quickshop .variant-input").forEach(el=>el.classList.remove("var-inpt-selected")),input.classList.add("var-inpt-selected")})}),document.querySelector(".quickshop #productSection")?.addEventListener("change",onVariantChange2),typeof initNoDrawerCheckoutCTA=="function"&&initNoDrawerCheckoutCTA()}}catch(error){console.error("Error loading product page:",error)}})})}function attachEventListenersToButtons(){window.theme&&typeof window.theme.bindWishlistButtons=="function"&&(window.theme.bindWishlistButtons(document,".n
247osto-search-container .grid-product__action.wishlist"),window._swat&&typeof window._swat.fetch=="function"?window.theme.updateWishList():(window.SwymCallbacks=window.SwymCallbacks||[],window.SwymCallbacks.push(function(){window._swat&&typeof window._swat.fetch=="function"&&window.theme.updateWishList()})))}function isMobileDevice(){return window.innerWidth<769}function addFixedClass(){isMobileDevice()&&(searchBar.classList.add("fullscreen-trigger"),body.style.overflow="hidden",closeButton.classList.add("show"),searchContainer.classList.add("show"))}mobileInput&&(mobileInput.addEventListener("click",addFixedClass),mobileInput.addEventListener("keyup",handleSearchKey),mobileInput.addEventListener("focus",async()=>{(mobileInput.value||"").trim().length||await fetchAndRenderPopular()})),backdrop?.addEventListener("click",function(){searchContainer.style.display="none",backdrop.style.display="none",desktopInput&&(desktopInput.value=""),searchResults.innerHTML="",autocompleteResults.innerHTML="",closeButtonDesktop.style.display="none"}),closeButton?.addEventListener("click",function(){closeButton.classList.remove("show"),searchBar.classList.remove("fullscreen-trigger"),body.style.overflow="auto",searchBar.style.display="none",mobileInput&&(mobileInput.value=""),searchContainer.classList.remove("show"),searchResults.innerHTML="",autocompleteResults.innerHTML="",searchContainer.style.display="none",backdrop.style.display="none";const headWrap=document.querySelector(".template-index #HeaderWrapper");if(headWrap){headWrap.classList.add("is-light");const headWrapWidth=headWrap.querySelector(".page-width");headWrapWidth&&(headWrapWidth.style.backgroundColor="transparent")}}),closeButtonDesktop?.addEventListener("click",function(){searchContainer.style.display="none",backdrop.style.display="none",desktopInput&&(desktopInput.value=""),searchResults.innerHTML="",autocompleteResults.innerHTML="",closeButtonDesktop.style.display="none"})});function initNoDrawerCheckoutCTA(){(function(){const VER="CNV-PDP NoDrawer Checkout CTA v1.6 (Nosto moves after ATC under .under-atc-text)";if(window.__cnvNoDrawerCheckoutCTA_v16){console.warn(`[${VER}] already applied`);return}window.__cnvNoDrawerCheckoutCTA_v16=!0;const q=(s,r=document)=>r.querySelector(s),qa=(s,r=document)=>Array.prototype.slice.call(r.querySelectorAll(s)),on=(el,ev,fn,opts)=>el&&el.addEventListener(ev,fn,opts||!1),FORM_SEL='.product-form, .product-single__form, form[action="/cart/add"]';(function(){if(q("#cnv-nodrawer-style"))return;const css=`
248        #cnv-checkout-cta { display:none; width:100%; clear:both; margin-top:10px; overflow:hidden; transition:max-height .25s ease; }
249        #cnv-checkout-cta.cnv-open { display:block; max-height:160px; }
250        #cnv-checkout-cta:not(.cnv-open) { max-height:0; }
251        #cnv-checkout-cta .cnv-checkout-btn {
252          display:block; width:100%; text-align:center;
253          background:#000; color:#fff; border:0; border-radius:0px;
254          padding:14px 16px; font-weight:600; cursor:pointer; text-decoration:none;
255        }
256        #cnv-checkout-cta .cnv-checkout-btn:focus { outline:2px solid #111; outline-offset:2px; }
257        .cnv-nosto-below-cta { width:100% !important; display:block !important; clear:both !important; }
258      `,s=document.createElement("style");s.id="cnv-nodrawer-style",s.textContent=css,document.head.appendChild(s)})();function getCheckoutHref(){const candidates=['#CartDrawer a[href*="/check"]','.ajaxcart__checkout[href*="/check"]','.mini-cart a[href*="/check"]','.cart__checkout[href*="/check"]','a.btn--checkout[href*="/check"]','a[href^="/checkout"]'];for(const sel of candidates){const a=q(sel);if(a&&a.getAttribute("href"))return a.getAttribute("href")}return"/cart"}function ensureCheckoutCTA(){const btnWrap=q(".pdp-button-container")||q(FORM_SEL);if(!btnWrap)return null;let cta=q("#cnv-checkout-cta",btnWrap)||q("#cnv-checkout-cta");if(!cta||cta&&cta.parentElement!==btnWrap){if(cta&&cta.parentElement!==btnWrap)btnWrap.appendChild(cta);else if(!cta){cta=document.createElement("div"),cta.id="cnv-checkout-cta";const a=document.createElement("a");
258a.className="cnv-checkout-btn",a.textContent=nostoSearchHeaderCnvString("cnvCheckoutCta","Go to checkout"),a.href=getCheckoutHref(),a.rel="nofollow",cta.appendChild(a),btnWrap.appendChild(cta)}}else{const a=cta.querySelector(".cnv-checkout-btn");a&&(a.href=getCheckoutHref())}return cta}function revealCheckoutCTA(){const cta=ensureCheckoutCTA();if(cta){const a=cta.querySelector(".cnv-checkout-btn");a&&(a.href=getCheckoutHref()),cta.classList.add("cnv-open")}}function getCandidateNostoEls(){const found=(typeof window.theme<"u"&&typeof window.theme.getNostoMoveUnderCtaSelectors=="function"?window.theme.getNostoMoveUnderCtaSelectors():["#productpage_nosto_8","#productpage-nosto-8","#productpage-nosto_2","#pdp-rec-bundle-1",".nosto_element#pdp-rec-bundle-1","#pdp-rec-1","#pdp-rec-3","#pdp-rec-4","#pdp-rec-5",".nosto_element#productpage_nosto_8",".nosto_element#productpage-nosto-2"]).map(sel=>q(sel)).filter(Boolean);return qa(".product-single__meta .nosto_element").forEach(el=>{found.includes(el)||found.push(el)}),found}function nostoHasContent(root){if(!root)return!1;const sel=[".nosto-list-item",".nosto-product",".product, .grid-product, .product-card","img[src], img[data-src], img[data-srcset]",'a[href*="/products/"]'].join(",");return root.querySelector(sel)?!0:(root.textContent||"").replace(/\s+/g," ").trim().length>80}function moveNostoUnderATCTextWhenReady(timeoutMs=15e3){const underAtc=q(".under-atc-text");if(!underAtc)return;const nostos=getCandidateNostoEls();if(!nostos.length)return;const doMove=el=>{el&&(el.classList.add("cnv-nosto-below-cta"),underAtc.insertAdjacentElement("afterend",el))},ready=nostos.find(n=>nostoHasContent(n));if(ready){doMove(ready);return}const observers=[],stopAll=()=>observers.forEach(o=>o.disconnect());nostos.forEach(nosto=>{const obs=new MutationObserver(()=>{nostoHasContent(nosto)&&(stopAll(),doMove(nosto))});obs.observe(nosto,{childList:!0,subtree:!0}),observers.push(obs)}),setTimeout(stopAll,timeoutMs)}function getCurrentVariantId(scope=document){let cand=scope.querySelector('input[type="radio"][data-variant-id].selected')||scope.querySelector('input[type="radio"][data-variant-id]:checked');if(cand&&cand.getAttribute("data-variant-id"))return cand.getAttribute("data-variant-id");const checked=scope.querySelector('input[type="radio"]:checked');if(checked){const wrapper=checked.closest(".variant-input");if(wrapper&&wrapper.getAttribute("data-variant-id"))return wrapper.getAttribute("data-variant-id")}const selWrap=scope.querySelector(".variant-input.selected");if(selWrap&&selWrap.getAttribute("data-variant-id"))return selWrap.getAttribute("data-variant-id");const sel=scope.querySelector('select[name="id"]');if(sel&&sel.value)return sel.value;const hidden=scope.querySelector('input[name="id"]');return hidden&&hidden.value?hidden.value:null}function syncVariantIdIntoForm(form){if(!form)return null;const current=getCurrentVariantId(form)||getCurrentVariantId(document);if(!current)return null;const hidden=form.querySelector('input[name="id"]'),select=form.querySelector('select[name="id"]');return hidden&&hidden.value!==String(current)&&(hidden.value=String(current)),select&&select.value!==String(current)&&(select.value=String(current)),String(current)}function setATCStateSuccess(form){const atcBtn=form.querySelector('.add-to-cart, .combined-atc-btn, button[name="add"]');if(!atcBtn)return;const txt=atcBtn.querySelector('[id^="AddToCartText-"]')||atcBtn;atcBtn.classList.add("cnv-atc-success");const original=txt.getAttribute("data-default-text")||nostoSearchHeaderCnvString("cnvAddToCartDefault","Add to cart");txt.setAttribute("data-original-text",original),txt.textContent=nostoSearchHeaderCnvString("cnvAddedToCart","Added")}function resetATCState(form){const atcBtn=form&&form.querySelector('.add-to-cart, .combined-atc-btn, button[name="add"]');if(!atcBtn)return;atcBtn.classList.remove("cnv-atc-success");const txt=atcBtn.querySelector('[id^="AddToCartText-"]')||atcBtn,def=(txt.getAttribute("data-default-text")||txt.getAttribute("data-original-text")||nostoSearchHeaderCnvString("cnvAddToCartDefault","Add to cart")).trim();txt.textContent=def;const cta=ensureCheckoutCTA();cta&&cta.classList.remove("cnv-open")}function refreshCartQuietly(){try{fetch("/cart.js",{headers:{Accept:"application/json"}}).then(r=>r.ok?r.json():null).then(cart=>{cart&&(document.dispatchEvent(new CustomEvent("cart:refresh",{detail:{cart}})),document.dispatchEvent(new CustomEvent("cart:build",{detail:{cart}})))}).catch(()=>{})}catch{}}let guardUntil=0;function armDrawerGuard(ms=5e3){guardUntil=Date.now()+ms}const CART_OPEN_SEL=[".js-drawer-open-cart",'[data-action="open-drawer"]','[data-drawer="cart"]','[data-drawer-trigger="cart"]',".cart-toggle",".header-cart",".site-header__cart-toggle"].join(",");on(document,"click",function(e){e.target&&e.target.closest&&e.target.closest(CART_OPEN_SEL)&&Date.now()<guardUntil&&(e.preventDefault(),e.stopPropagation(),typeof e.stopImmediatePropagation=="function"&&e.stopImmediatePropagation())},!0),on(document,"submit",function(e){const form=e.target;if(!form||!form.matches(FORM_SEL))return;e.preventDefault(),e.stopPropagation(),typeof e.stopImmediatePropagation=="function"&&e.stopImmediatePropagation();const currentVariantId=syncVariantIdIntoForm(form);
258if(!currentVariantId)return;armDrawerGuard(5e3);const atcBtn=form.querySelector('.add-to-cart, .combined-atc-btn, button[name="add"]');atcBtn&&(atcBtn.disabled=!0,atcBtn.setAttribute("aria-busy","true"));const fd=new FormData(form);fd.set("id",String(currentVariantId)),fetch("/cart/add.js",{method:"POST",body:fd,headers:{"X-Requested-With":"XMLHttpRequest",Accept:"application/json"}}).then(r=>{if(!r.ok)throw new Error("Add to cart failed");return r.json()}).then(()=>{setATCStateSuccess(form),revealCheckoutCTA(),moveNostoUnderATCTextWhenReady(),refreshCartQuietly()}).catch(err=>{console.error("[NoDrawer] ATC error",err)}).finally(()=>{atcBtn&&(atcBtn.disabled=!1,atcBtn.removeAttribute("aria-busy"))})},!0),(function(){const root=q("#productSection")||q(".combined-product")||q(".product-single__meta")||document.documentElement;new MutationObserver(()=>{const form=q(FORM_SEL);form&&syncVariantIdIntoForm(form),ensureCheckoutCTA()}).observe(root,{childList:!0,subtree:!0})})(),(function(){const container=q("#productSection")||q(".product-single__meta")||document;on(container,"change",function(e){if(e.target&&e.target.matches('input[type="radio"], select')){const form=q(FORM_SEL);syncVariantIdIntoForm(form),resetATCState(form),ensureCheckoutCTA()}},!0),on(document,"variant:change",function(){const form=q(FORM_SEL);syncVariantIdIntoForm(form),resetATCState(form),ensureCheckoutCTA()}),on(document,"variantSwitched",function(){const form=q(FORM_SEL);syncVariantIdIntoForm(form),resetATCState(form),ensureCheckoutCTA()})})(),(function(){const form=q(FORM_SEL);form&&syncVariantIdIntoForm(form),ensureCheckoutCTA()})()})()}
259//# sourceMappingURL=/cdn/shop/t/132/assets/nosto-search-header.js.map?v=137896563665077337881790672546

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.