1(function(){"use strict";var COOKIE_NAME="_fct_attribution",ATTRIBUTE_KEYS=["gclid","gbraid","wbraid","utm_source","utm_medium","utm_campaign","ga_client_id"],CART_ATTRIBUTE_PREFIX="_";function readCookie(name){var match=document.cookie.match(new RegExp("(?:^|; )"+name+"=([^;]*)"));return match?decodeURIComponent(match[1]):null}function storedAttribution(){var raw=readCookie(COOKIE_NAME);if(!raw)return null;try{var parsed=JSON.parse(raw);return parsed&&typeof parsed=="object"?parsed:null}catch(e){return null}}function consentAllows(){try{return!!(window.Shopify&&window.Shopify.customerPrivacy&&window.Shopify.customerPrivacy.saleOfDataAllowed())}catch(e){return!1}}function grantsBehavioralAdvertising(consent,purposeConfig){var granted=consent&&consent.purposes||{};return(purposeConfig||[]).some(function(purpose){return granted[purpose.code]&&purpose.canonicalPurposeCodes&&purpose.canonicalPurposeCodes.indexOf("behavioral_advertising")!==-1})}var CONSENT_BRIDGE_POLL_MS=50,CONSENT_BRIDGE_TIMEOUT_MS=2e3;function waitForConsentBridge(onReady){var waited=0;(function poll(){if(consentAllows()){onReady();return}waited>=CONSENT_BRIDGE_TIMEOUT_MS||(waited+=CONSENT_BRIDGE_POLL_MS,setTimeout(poll,CONSENT_BRIDGE_POLL_MS))})()}function cartRoute(){return window.Shopify&&window.Shopify.routes&&window.Shopify.routes.root?window.Shopify.routes.root:"/"}function cartFetch(url,body){return fetch(url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(body)}).then(function(res){return res.ok?res.json():res.text().then(function(t){throw new Error("Cart request failed: "+res.status+" "+t)})})}function desiredAttributes(stored){var attributes={};return ATTRIBUTE_KEYS.forEach(function(key){stored[key]&&(attributes[CART_ATTRIBUTE_PREFIX+key]=stored[key])}),attributes}function needsSync(cart,desired){var current=cart&&cart.attributes||{};return Object.keys(desired).some(function(key){return current[key]!==desired[key]})}function syncFromCart(cart){if(!consentAllows())return Promise.resolve(cart);var stored=storedAttribution();if(!stored)return Promise.resolve(cart);var desired=desiredAttributes(stored);return Object.keys(desired).length===0||!needsSync(cart,desired)?Promise.resolve(cart):cartFetch(cartRoute()+"cart/update.js",{attributes:desired}).catch(function(err){console.error("[cart-attribution-sync] sync:",err)})}function fetchAndSync(){return fetch(cartRoute()+"cart.js").then(function(r){return r.json()}).then(syncFromCart).catch(function(err){console.error("[cart-attribution-sync] fetch:",err)})}function init(){fetchAndSync(),document.addEventListener("cart:change",function(event){var cart=event.detail&&event.detail.cart;cart?syncFromCart(cart):fetchAndSync()},!1),document.addEventListener("cart:refresh",fetchAndSync,!1),document.addEventListener("sample:added",fetchAndSync,!1),window.ketch&&window.ketch("on","consent",function(consent){window.ketch("getConfig",function(config){grantsBehavioralAdvertising(consent,config&&config.purposes)&&waitForConsentBridge(fetchAndSync)})})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",init):init()})(); 2//# sourceMappingURL=/cdn/shop/t/18/assets/cart-attribution-sync.js.map?v=21075532323470099351789149475
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.