1export const requestIdleCallback=typeof window.requestIdleCallback=="function"?window.requestIdleCallback:setTimeout;export function supportsViewTransitions(){return typeof document.startViewTransition=="function"}export const viewTransition={current:void 0};const viewTransitionTypes={"product-grid":async()=>{const grid=document.querySelector(".product-grid"),productCards=[...document.querySelectorAll(".product-grid .product-grid__item")];if(!(!grid||!productCards.length))return await new Promise(resolve=>requestIdleCallback(()=>{const cardsToAnimate=getCardsToAnimate(grid,productCards);productCards.forEach((card,index)=>{index<cardsToAnimate?card.style.setProperty("view-transition-name",`product-card-${card.dataset.productId}`):card.style.setProperty("content-visibility","hidden")}),resolve(null)})),()=>productCards.forEach(card=>{card.style.removeProperty("view-transition-name"),card.style.removeProperty("content-visibility")})}};export function startViewTransition(callback,types){return new Promise(async resolve=>{if(supportsViewTransitions()&&!prefersReducedMotion()){let cleanupFunctions=[];if(types){for(const type of types)if(viewTransitionTypes[type]){const cleanupFunction=await viewTransitionTypes[type]();cleanupFunction&&cleanupFunctions.push(cleanupFunction)}}const transition=document.startViewTransition(callback);viewTransition.current||(viewTransition.current=transition.finished),types&&types.forEach(type=>transition.types.add(type)),transition.finished.then(()=>{viewTransition.current=void 0,cleanupFunctions.forEach(cleanupFunction=>cleanupFunction()),resolve()});return}callback(),resolve()})}export function fetchConfig(type="json",config={}){const headers={"Content-Type":"application/json",Accept:`application/${type}`,...config.headers};return type==="javascript"&&(headers["X-Requested-With"]="XMLHttpRequest",delete headers["Content-Type"]),{method:"POST",headers,body:config.body}}export function debounce(fn,wait){let timeout;function debounced(...args){clearTimeout(timeout),timeout=setTimeout(()=>fn.apply(this,args),wait)}return debounced.cancel=()=>{clearTimeout(timeout)},debounced}export function throttle(fn,delay){let lastCall=0;function throttled(...args){const now=performance.now();now-lastCall>=delay&&(lastCall=now,fn.apply(this,args))}return throttled.cancel=()=>{lastCall=performance.now()},throttled}const reducedMotion=matchMedia("(prefers-reduced-motion: reduce)");export function prefersReducedMotion(){return reducedMotion.matches}export function normalizeString(str){return str.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase()}export function formatMoney(value){let valueWithNoSpaces=value.replace(" ","");return valueWithNoSpaces.indexOf(",")===-1?valueWithNoSpaces:valueWithNoSpaces.indexOf(",")<valueWithNoSpaces.indexOf(".")?valueWithNoSpaces.replace(",",""):valueWithNoSpaces.indexOf(".")<valueWithNoSpaces.indexOf(",")?valueWithNoSpaces.replace(".","").replace(",","."):valueWithNoSpaces.indexOf(",")!==-1?valueWithNoSpaces.replace(",","."):valueWithNoSpaces}export function onDocumentReady(callback){document.readyState==="complete"?callback():window.addEventListener("load",callback)}export function onAnimationEnd(elements,callback,options={subtree:!0}){const animationPromises=(Array.isArray(elements)?elements.flatMap(element=>element.getAnimations(options)):elements.getAnimations(options)).reduce((acc,animation)=>(animation.timeline instanceof DocumentTimeline&&acc.push(animation.finished),acc),[]);return Promise.allSettled(animationPromises).then(callback)}export function isClickedOutside(event,element){return event.target instanceof HTMLDialogElement||!(event.target instanceof Element)?!isPointWithinElement(event.clientX,event.clientY,element):!element.contains(event.target)}export function isPointWithinElement(x,y,element){const{left,right,top,bottom}=element.getBoundingClientRect();return x>=left&&x<=right&&y>=top&&y<=bottom}export const mediaQueryLarge=matchMedia("(width >= 750px)");export function isMobileBreakpoint(){return!mediaQueryLarge.matches}export function isDesktopBreakpoint(){return mediaQueryLarge.matches}
1export function clamp(value,min,max){return Math.max(min,Math.min(value,max))}export function center(element,axis){const{left,width,top,height}=element.getBoundingClientRect(),point={x:left+width/2,y:top+height/2};return axis?point[axis]:point}export function start(element,axis){const{left,top}=element.getBoundingClientRect(),point={x:left,y:top};return axis?point[axis]:point}export function closest(values,target){return values.reduce(function(prev,curr){return Math.abs(curr-target)<Math.abs(prev-target)?curr:prev})}export function preventDefault(event){event.preventDefault()}export function getVisibleElements(root,elements,ratio=1,axis){if(!elements?.length)return[];const rootRect=root.getBoundingClientRect();return elements.filter(element=>{const{width,height,top,right,left,bottom}=element.getBoundingClientRect();if(ratio<1){const intersectionLeft=Math.max(rootRect.left,left),intersectionRight=Math.min(rootRect.right,right),intersectionWidth=Math.max(0,intersectionRight-intersectionLeft);if(axis==="x")return width>0&&intersectionWidth/width>=ratio;const intersectionTop=Math.max(rootRect.top,top),intersectionBottom=Math.min(rootRect.bottom,bottom),intersectionHeight=Math.max(0,intersectionBottom-intersectionTop);if(axis==="y")return height>0&&intersectionHeight/height>=ratio;const intersectionArea=intersectionWidth*intersectionHeight,elementArea=width*height;return elementArea>0&&intersectionArea/elementArea>=ratio}const isWithinX=left>=rootRect.left&&right<=rootRect.right;if(axis==="x")return isWithinX;const isWithinY=top>=rootRect.top&&bottom<=rootRect.bottom;return(axis==="y"||isWithinX)&&isWithinY})}function getCardsToAnimate(grid,cards){if(!grid||!cards||cards.length===0)return 0;const itemSample=cards[0];if(!itemSample)return 0;const gridRect=grid.getBoundingClientRect(),visibleArea={top:Math.max(0,gridRect.top),bottom:Math.min(window.innerHeight,gridRect.bottom)},visibleHeight=Math.round(visibleArea.bottom-visibleArea.top);if(visibleHeight<=0)return 0;const cardSample=itemSample.querySelector("product-card"),gridStyle=getComputedStyle(grid),galleryAspectRatio=cardSample?.refs?.cardGallery?.style.getPropertyValue("--gallery-aspect-ratio")||"";let aspectRatio=parseFloat(galleryAspectRatio)||.5;if(galleryAspectRatio?.includes("/")){const[width="1",height="2"]=galleryAspectRatio.split("/");aspectRatio=parseInt(width,10)/parseInt(height,10)}const cardGap=parseInt(cardSample?.refs?.productCardLink?.style.getPropertyValue("--product-card-gap")||"")||12,gridGap=parseInt(gridStyle.getPropertyValue("--product-grid-gap"))||12,detailsSize=((parseInt(gridStyle.fontSize)||16)+2)*2,isMobile=window.innerWidth<750,cardWidth=isMobile?Math.round((gridRect.width-gridGap)/2):100,cardHeight=Math.round(cardWidth/aspectRatio)+cardGap+detailsSize,columnsInGrid=isMobile?2:Math.floor((gridRect.width+gridGap)/(cardWidth+gridGap)),rowsInGrid=Math.ceil((visibleHeight-gridGap)/(cardHeight+gridGap));return columnsInGrid*rowsInGrid}export function preloadImage(src){const image=new Image;image.src=src}export class TextComponent extends HTMLElement{shimmer(){this.setAttribute("shimmer","")}}customElements.get("text-component")||customElements.define("text-component",TextComponent);export function resetShimmer(container=document.body){container.querySelectorAll("[shimmer]").forEach(item=>item.removeAttribute("shimmer"))}export function changeMetaThemeColor(colorSourceElement){const metaThemeColor=document.head.querySelector('meta[name="theme-color"]'),containerStyle=window.getComputedStyle(colorSourceElement);metaThemeColor&&metaThemeColor.setAttribute("content",containerStyle.backgroundColor)}class Scheduler{#queue=new Set;#scheduled=!1;schedule=async task=>{this.#queue.add(task),this.#scheduled||(this.#scheduled=!0,viewTransition.current&&await viewTransition.current,requestAnimationFrame(this.flush))};flush=()=>{for(const task of this.#queue)task();this.#queue.clear(),this.#scheduled=!1}}
1export const scheduler=new Scheduler;Theme.utilities={...Theme.utilities,scheduler}; 2//# sourceMappingURL=/cdn/shop/t/139/assets/utilities.js.map?v=127314618558186079721764898162
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.