1const CONSTANTS={SELECTORS:{COLOR_SELECTOR:".color-selector",PRODUCT_TILE:".c-product-tile",PRODUCT_LABEL:".c-product-tile__product-label",PRICE_LABEL:".c-product-tile__price-label",PRICE_LABEL_CONTAINER:".c-product-tile-info",PRODUCT_IMAGE:".image-button__image",IMAGE_WRAPPER:".image-button__image-wrapper",LOGO_BADGE:"[data-replaceable-card-logo], .c-product-tile__logo-badge__wrapper",PRODUCT_TITLE:".c-product-tile__product-name span.fixed-utility-s",PRODUCT_LINK:".image-button__link.c-product-tile-decorator__content-wrapper",PRICE_CONTAINER:".c-product-price",PRICE_ELEMENT:".c-product-price__formatted-price",DISCOUNTED_PRICE:".c-product-price__formatted-price--discounted",LIST_ITEM:".o-style-option__list-item"},CLASSES:{CHECKED:"is-checked",HAS_DISCOUNT:"c-product-price--has-discount",LABEL_CONTENT:"c-product-tile__product-label-content fixed-utility-s",DISCOUNTED_PRICE:"c-product-price__formatted-price c-product-price__formatted-price--discounted fixed-utility-s one-liner-height-trim",SR_ONLY:"sr-only"},COLORS:{URGENCY:"c-product-text-color--urgency",REGULAR:"c-product-text-color--regular"},THRESHOLDS:{NEW_PRODUCT_DAYS:60},PATTERNS:{SHOPIFY_PRODUCT_ID:/^gid:\/\/shopify\/Product\//g}};class GlobalProductDataManager{constructor(){const{endpoint,token}=window.storefrontApi?.createStorefrontClient()||{};this.endpoint=endpoint,this.token=token,this.productCache=new Map,this.isInitialized=!1,this.initializationPromise=null}async initialize(){if(!this.isInitialized)return this.initializationPromise?this.initializationPromise:(this.initializationPromise=this._performInitialization(),this.initializationPromise)}async _performInitialization(){try{const swatches=document.querySelectorAll(".color-selector__radio"),productIds=new Set;if(swatches.forEach(swatch=>{const productId=swatch.dataset.productId;productId&&productId.startsWith("gid://shopify/Product/")&&productIds.add(productId)}),productIds.size===0){this.isInitialized=!0;return}const startTime=performance.now();(await this.fetchProducts([...productIds])).forEach(product=>{product?.id&&this.productCache.set(product.id,product)});const endTime=performance.now();this.isInitialized=!0,this._notifyProductCardsReady()}catch(error){console.error("Failed to initialize global product data:",error),this.isInitialized=!0}}_notifyProductCardsReady(){document.querySelectorAll("shared-product-card").forEach(card=>{card.tryUpgradeInitialImage&&card.tryUpgradeInitialImage(),card.onGlobalDataReady&&card.onGlobalDataReady()}),document.dispatchEvent(new CustomEvent("globalProductDataReady",{detail:{productCount:this.productCache.size}}))}getProduct(productId){return this.productCache.get(productId)||null}hasProduct(productId){return this.productCache.has(productId)}getCacheStats(){return{size:this.productCache.size,productIds:Array.from(this.productCache.keys()),isInitialized:this.isInitialized}}isConfigured(){return!!(this.endpoint&&this.token)}async fetchProducts(productIds){if(!this.isConfigured())throw new Error("Storefront API not configured");if(!productIds.length)return[];try{const response=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.token},body:JSON.stringify({query:window.storefrontApi?.PRODUCT_CARD_QUERY,variables:{ids:productIds}})});if(!response.ok)throw new Error(`HTTP ${response.status}: ${response.statusText}`);const data=await response.json();if(data.errors)throw new Error(`GraphQL errors: ${JSON.stringify(data.errors)}`);return data.data?.nodes||[]}catch(error){throw console.error("Failed to fetch products",error),error}}}class StorefrontApiService{constructor(){const{endpoint,token}=window.storefrontApi?.createStorefrontClient()||{};this.endpoint=endpoint,this.token=token,this.cache=new Map}isConfigured(){return!!(this.endpoint&&this.token)}async fetchProducts(productIds){if(!this.isConfigured())throw new Error("Storefront API not configured");if(!productIds.length)return[];try{const response=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.token},body:JSON.stringify({query:window.storefrontApi?.PRODUCT_CARD_QUERY,variables:{ids:productIds}})});if(!response.ok)throw new Error(`HTTP ${response.status}: ${response.statusText}`);const data=await response.json();if(data.errors)throw new Error(`GraphQL errors: ${JSON.stringify(data.errors)}`);return data.data?.nodes||[]}catch(error){throw console.error("StorefrontApiService: Failed to fetch products",error),error}}}class DomHelperService{static safeParseJSON(jsonString,fallback={}){try{return jsonString?JSON.parse(jsonString):fallback}catch(error){return console.warn("Failed to parse JSON:",error),fallback}}static announceToScreenReader(message){const announcement=document.createElement("div");announcement.setAttribute("aria-live","polite"),announcement.setAttribute("aria-atomic","true"),announcement.className="sr-only",announcement.textContent=message,document.body.appendChild(announcement),setTimeout(()=>{document.body.contains(announcement)&&document.body.removeChild(announcement)},1e3)}static extractProductIds(swatches){const productIds=new Set,invalidIds=[],pattern=/^gid:\/\/shopify\/Product\//g;
1return swatches.forEach(swatch=>{const productId=swatch.dataset?.productId;productId&&(pattern.test(productId)?productIds.add(productId):invalidIds.push(productId))}),invalidIds.length>0&&console.warn("Found invalid product IDs:",invalidIds),Array.from(productIds)}}window.PRODUCT_CARD_CONSTANTS=CONSTANTS,window.StorefrontApiService=StorefrontApiService,window.GlobalProductDataManager=GlobalProductDataManager,window.DomHelperService=DomHelperService,window.globalProductData=new GlobalProductDataManager,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{window.globalProductData.initialize()}):window.globalProductData.initialize(); 2//# sourceMappingURL=/cdn/shop/t/82/assets/product-card-element-utils.js.map?v=137747264296611402711789043205
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.