PageSourceSearch

https://www.sperry.com/cdn/shop/t/485/assets/data-utils.js?v=119260431070031174001789062892

js sperry.com collected 2026-09-25 14:22:09 UTC 8,125 bytes, 2 lines download raw bytes

1window.utilities=window.utilities||{},window.utilities.cardHelpers=window.utilities.cardHelpers||{},window.utilities.cardHelpers.extractCompanionProductsJson=product=>{if(!product||typeof product!="object")return null;const fromReference=product.companionProducts?.reference?.field?.value;return fromReference||(product.companionProducts?.value?product.companionProducts.value:(Array.isArray(product.metafields)?product.metafields:[]).find(m=>m?.key==="companionProducts")?.value??null)},window.utilities.cardHelpers.buildSwatchesFromCompanionProducts=(companionJson,productId)=>{if(!companionJson)return[];let parsed=companionJson;if(typeof companionJson=="string"&&(parsed=window.utilities.safeParseJSON(companionJson,null)),parsed&&typeof parsed=="object"&&parsed.product_json?.value&&(parsed=parsed.product_json.value),!Array.isArray(parsed))return[];const localeCode=window.localeCode||`${window.locale||"en"}-${window.Shopify?.country||"US"}`,shortLocale=window.locale||"en",numericId=window.utilities.extractIdFromGid?window.utilities.extractIdFromGid(productId):String(productId||"").replace(/\D/g,""),fullProductGid=String(productId||"").startsWith("gid://")?String(productId):`gid://shopify/Product/${numericId}`,swatches=parsed.map(item=>{const color=item.color||{},label=color[localeCode]||color[shortLocale]||color["en-US"]||color["en-CA"]||color.en||color["fr-CA"]||color.fr||Object.values(color)[0]||"",swatchProductId=item.productID||"",swatchNumericId=window.utilities.extractIdFromGid?window.utilities.extractIdFromGid(swatchProductId):String(swatchProductId).replace(/\D/g,""),isChecked=swatchProductId===fullProductGid||numericId.length>0&&swatchNumericId===numericId;return{productID:swatchProductId,image:item.swatch_image||"",label,isChecked}}).filter(swatch=>swatch.productID&&swatch.image),checkedIndex=swatches.findIndex(swatch=>swatch.isChecked);if(checkedIndex>0){const[checked]=swatches.splice(checkedIndex,1);swatches.unshift(checked)}return swatches};const parseMetafieldBoolean=value=>typeof value=="boolean"?value:value==="true",BADGE_FLAG_METAFIELD_MAP=[["bestseller_us","bestsellerUS"],["bestseller_ca","bestsellerCA"],["trending_us","trendingUS"],["trending_ca","trendingCA"],["isNewArrivalUS","isNewArrivalUS"],["isNewArrivalCA","isNewArrivalCA"],["sellingFastUS","sellingFastUS"],["sellingFastCA","sellingFastCA"]],createMetafieldAccessors=metafields=>{const entries=Array.isArray(metafields)?metafields.filter(Boolean):[];return{getMetafieldValue:key=>entries.find(m=>m?.key===key)?.value??null,hasMetafield:key=>entries.some(m=>m?.key===key)}};window.utilities.cardHelpers.buildBadgeFlagsFromMetafields=(getMetafieldValue,hasMetafield)=>{const flags={};for(const[metafieldKey,flagKey]of BADGE_FLAG_METAFIELD_MAP)hasMetafield(metafieldKey)&&(flags[flagKey]=parseMetafieldBoolean(getMetafieldValue(metafieldKey)));const socialConfidenceKey=`socialConfidence${window.Shopify?.country||"US"}`;return hasMetafield(socialConfidenceKey)&&(flags.socialConfidence=getMetafieldValue(socialConfidenceKey)),flags},window.utilities.cardHelpers.transformProductBadgeMetadataToCardData=product=>{if(!product||typeof product!="object")return null;const{getMetafieldValue,hasMetafield}=createMetafieldAccessors(product.metafields),badgeData={id:product.id,flags:window.utilities.cardHelpers.buildBadgeFlagsFromMetafields(getMetafieldValue,hasMetafield)};return hasMetafield("collaboration")&&(badgeData.logoBadge=getMetafieldValue("collaboration")),badgeData},window.utilities.cardHelpers.transformProductMetadataToCardData=product=>{if(!product||typeof product!="object")return null;const{getMetafieldValue,hasMetafield}=createMetafieldAccessors(product.metafields),highlightsRaw=getMetafieldValue("highlights"),logoBadge=getMetafieldValue("collaboration"),highlights=typeof highlightsRaw=="string"?highlightsRaw.split(",").map(label=>({label:label.trim()})):[],defaultDimensions={width:1e3,height:1e3},featuredImageUrl=product.featuredImage?.url||"",featuredImage=featuredImageUrl?{src:featuredImageUrl,width:1e3,height:1e3}:null;let image=featuredImage,imageFallback=null;const mediaGalleryRaw=getMetafieldValue("media_gallery_assets"),mediaGallery=(()=>
1{if(!mediaGalleryRaw)return[];const parsed=typeof mediaGalleryRaw=="string"?window.utilities.safeParseJSON(mediaGalleryRaw):mediaGalleryRaw;return Array.isArray(parsed)?parsed:[]})();if(mediaGallery.length>0){const contextualOrder=["campaign-full","look-full","campaign-part","look-part"],imageOrder=["main","spotlight","contextual","alt1","alt2","video","alt3","alt4","alt5","alt6","contextual"],findByType=type=>mediaGallery.find(e=>e?.imageType===type&&e?.imageUrl),getContextual=()=>contextualOrder.map(findByType).find(Boolean),orderedEntries=[];for(const order of imageOrder)if(order==="contextual"){const ctx=getContextual();ctx&&orderedEntries.push(ctx)}else{const entry=findByType(order);entry&&orderedEntries.push(entry)}const videoEntry=findByType("video"),firstImage=orderedEntries.find(e=>e?.imageType!=="video");videoEntry?.imageUrl?(image={src:videoEntry.imageUrl,...defaultDimensions},imageFallback=firstImage?.imageUrl?{src:firstImage.imageUrl,...defaultDimensions}:featuredImage):firstImage?.imageUrl&&(image={src:firstImage.imageUrl,...defaultDimensions})}image||(image={src:"",width:1e3,height:1e3});const customMediaGalleryAssets=typeof mediaGalleryRaw=="string"&&mediaGalleryRaw.trim()?mediaGalleryRaw:mediaGallery.length>0?JSON.stringify(mediaGallery):null,price=product.priceRange?.maxVariantPrice?.amount?`$${parseFloat(product.priceRange.maxVariantPrice.amount)}`:null,compareAtPrice=product.compareAtPriceRange?.maxVariantPrice?.amount&&parseFloat(product.compareAtPriceRange.maxVariantPrice.amount)!==0?`$${parseFloat(product.compareAtPriceRange.maxVariantPrice.amount)}`:null,flags={publishDateUS:getMetafieldValue("publish_date_us"),publishDateCA:getMetafieldValue("publish_date_ca"),nonReturnableType:getMetafieldValue("non_returnable_type"),silhouette:getMetafieldValue("silhouette"),heelType:getMetafieldValue("heelType"),promotionalMessageUSEN:getMetafieldValue("promotional_message_us_en"),promotionalMessageCAEN:getMetafieldValue("promotional_message_ca_en"),promotionalMessageCAFR:getMetafieldValue("promotional_message_ca_fr"),promotionalPriceMessageUSEN:getMetafieldValue("promo_applied_message_us_en"),promotionalPriceMessageCAEN:getMetafieldValue("promo_applied_message_ca_en"),promotionalPriceMessageCAFR:getMetafieldValue("promo_applied_message_ca_fr"),onlineExclusive:getMetafieldValue("onlineExclusive")==="true",comingSoonUS:getMetafieldValue("comingSoonUS"),comingSoonCA:getMetafieldValue("comingSoonCA"),preOrderUS:getMetafieldValue("preOrderUS"),preOrderCA:getMetafieldValue("preOrderCA"),...window.utilities.cardHelpers.buildBadgeFlagsFromMetafields(getMetafieldValue,hasMetafield)};return{id:product.id,title:product.title,productType:product.productType,color:getMetafieldValue("color"),gender:getMetafieldValue("gender"),category:getMetafieldValue("category"),silhouette:getMetafieldValue("silhouette"),url:window.Shopify.routes.root+`products/${product.handle}`,availableForSale:product.availableForSale,totalInventory:product.totalInventory,tags:product.tags||[],price,compareAtPrice,image,imageFallback:imageFallback||void 0,customMediaGalleryAssets,highlights,flags,logoBadge,swatches:window.utilities.cardHelpers.buildSwatchesFromCompanionProducts(window.utilities.cardHelpers.extractCompanionProductsJson(product),product.id)}},window.utilities.cardHelpers.isLowStock=data=>{const lowStockThreshold=window.product.lowStockValue;return typeof data.totalInventory=="number"?data.totalInventory<=lowStockThreshold:data.flags[`inventoryStock${window.Shopify.country}`]&&data.flags[`inventoryStock${window.Shopify.country}`].toLowerCase()==="lowstock"},window.utilities.cardHelpers.isInStock=data=>typeof data.totalInventory=="number"?data.totalInventory>0:data.flags[`inventoryStock${window.Shopify.country}`]&&data.flags[`inventoryStock${window.Shopify.country}`].toLowerCase()!=="outofstock";
2//# sourceMappingURL=/cdn/shop/t/485/assets/data-utils.js.map?v=119260431070031174001789062892

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.