!function(e){"use strict";class n extends TypeError{constructor(e){super(e),this.name="ConsentValidationError",Object.setPrototypeOf(this,n.prototype)}}const t={TRACKING_ACCEPTED:"trackingConsentAccepted",TRACKING_DECLINED:"trackingConsentDeclined",MARKETING_ACCEPTED:"firstPartyMarketingConsentAccepted",SALE_OF_DATA_ACCEPTED:"thirdPartyMarketingConsentAccepted",ANALYTICS_ACCEPTED:"analyticsConsentAccepted",PREFERENCES_ACCEPTED:"preferencesConsentAccepted",MARKETING_DECLINED:"firstPartyMarketingConsentDeclined",SALE_OF_DATA_DECLINED:"thirdPartyMarketingConsentDeclined",ANALYTICS_DECLINED:"analyticsConsentDeclined",PREFERENCES_DECLINED:"preferencesConsentDeclined",CONSENT_COLLECTED:"visitorConsentCollected",CONSENT_TRACKING_API_LOADED:"consentTrackingApiLoaded"},o="2.1",r="3",i={ACCEPTED:"yes",DECLINED:"no",NO_INTERACTION:"no_interaction",NO_VALUE:""},c={NO_VALUE:"",ACCEPTED:"1",DECLINED:"0"},a={PREFERENCES:"p",ANALYTICS:"a",MARKETING:"m",SALE_OF_DATA:"t"},s={MARKETING:"m",ANALYTICS:"a",PREFERENCES:"p",SALE_OF_DATA:"s"},u={MARKETING:"marketing",ANALYTICS:"analytics",PREFERENCES:"preferences",SALE_OF_DATA:"sale_of_data",EMAIL:"email"},l="headlessStorefront",d="rootDomain",f="checkoutRootDomain",E="storefrontRootDomain",p="storefrontAccessToken",A="isExtensionToken",C="metafields";function g(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function h(e){for(var n=1;n{m()||console.warn(e)},w.error=e=>{m()||console.error(e)},w.info=e=>{m()||console.info(e)},w.debug=e=>{m()||console.debug(e)},w.trace=e=>{m()||console.trace(e)};const v=w;function _(e){try{return decodeURIComponent(e)}catch(e){return""}}function T(){return"undefined"==typeof window}function S(e,n){if(null===e)return"null";if(Array.isArray(e)){const n=e.map((e=>S(e,!0))).join(",");return"[".concat(n,"]")}if("object"==typeof e){let t=[];for(const n in e)e.hasOwnProperty(n)&&void 0!==e[n]&&""!==e[n]&&t.push("".concat(n,":").concat(S(e[n],!0)));const o=t.join(",");return n?"{".concat(o,"}"):o}return"string"==typeof e?'"'.concat(e,'"'):"".concat(e)}function N(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const t=function(){try{return document.cookie}catch(e){return!1}}()?document.cookie.split("; "):[];for(let n=0;n0&&void 0!==arguments[0]?arguments[0]:"/";const n=new XMLHttpRequest;n.open("HEAD",e,!1),n.withCredentials=!0,n.send()}(),window.localStorage.setItem("tracking_consent_fetched","true"),N(e,!1)}}function D(e){return e===encodeURIComponent(_(e))}function P(e,n,t,o){if(!D(o))throw new TypeError("Cookie value is not correctly URI encoded.");if(!D(e))throw new TypeError("Cookie name is not correctly URI encoded.");let r="".concat(e,"=").concat(o);r+="; path=/",n&&(r+="; domain=".concat(n)),r+="; expires=".concat(new Date((new Date).getTime()+t).toUTCString()),document.cookie=r}class I{constructor(){if(I.instance)return I.instance;I.instance=this}produce(e,n){if(!T())try{const t={schema_id:"customer_privacy_api_events/2.0",payload:{shop_domain:window.location.host,method_name:e,call_details:n||null}},o={accept:"*/*","accept-language":"en-GB,en-US;q=0.9,en;q=0.8","content-type":"application/json; charset=utf-8","x-monorail-edge-event-created-at-ms":String(Date.now()),"x-monorail-edge-event-sent-at-ms":String(Date.now())};window.location.host.endsWith("spin.dev")?console.log("Monorail event from consent API:",o,t):fetch("https://monorail-edge.shopifysvc.com/v1/produce",{headers:o,body:JSON.stringify(t),method:"POST",mode:"cors",credentials:"omit"}).catch((()=>{}))}catch(e){}}}I.instance=void 0;const R="_cmp";function L(){try{var e;if(!O()&&!function(){try{const e=performance.getEntriesByType("navigation")[0].serverTiming;return!!e&&0!=e.length}catch(e){return!1}}()){const e=new I;let n="failed_to_fetch";try{n=navigator.userAgent}catch(e){}e.produce("navigationServerTiming",JSON.stringify({failed:!0,userAgent:n})),function(){if(O())return;try{const e=window;e.Shopify||(e.Shopify={}),e.Shopify.customerPrivacy||(e.Shopify.customerPrivacy={}),e.Shopify.customerPrivacy.serverTimingSupportVerified=!0}catch(e){}}()}const[n]=null===(e=performance)||void 0===e?void 0:e.getEntriesByType("navigation"),t=null==n?void 0:n.serverTiming.find((e=>e.name===R));let o=null==t?void 0:t.description;if(!o){let e;try{e=sessionStorage.getItem("consentHeader")}catch(e){}return e||void 0}try{o=decodeURIComponent(o)}catch(e){}try{sessionStorage.setItem("consentHeader",o)}catch(e){}return o}catch(e){return}}function O(){try{var e,n,t;return!!T()||(null===(e=window)||void 0===e||null===(n=e.Shopify)||void 0===n||null===(t=n.customerPrivacy)||void 0===t?void 0:t.serverTimingSupportVerified)}catch(e){return!0}}let k;const b="_tracking_consent",M=31536e6;function F(){const e=function(){if(T())return k;{var e,n;const t=null===(e=window.Shopify)||void 0===e||null===(n=e.customerPrivacy)||void 0===n?void 0:n.injectedConsent;return t?_(t):void 0}}()||function(){var e,n;const t=null===(e=window.Shopify)||void 0===e||null===(n=e.customerPrivacy)||void 0===n?void 0:n.cachedConsent;return t?_(t):void 0}()||N(b)||L();if(void 0!==e)return function(e){if("%"==e.slice(0,1))try{e=decodeURIComponent(e)}catch(e){}const n=e.slice(0,1);if("{"==n)return function(e){var n;let t;try{t=JSON.parse(e)}catch(e){return}if(t.v!==o)return;if(null===(n=t.con)||void 0===n||!n.CMP)return;return t}(e);if("3"==n)return function(e){const n=e.slice(1).split("_"),[t,o,i,u,l]=n;let d,f;try{d=n[5]?JSON.parse(n.slice(5).join("_")):void 0}catch(e){}if(l){const e=l.replace(/\*/g,"/").replace(/-/g,"+"),n=atob(e);let t="";for(let e=0;ee.slice(0,n)+"-"+e.slice(n)),t)}function E(e){const n=t.split(".")[0];return n.includes(e.toLowerCase())?c.DECLINED:n.includes(e.toUpperCase())?c.ACCEPTED:c.NO_VALUE}function p(e){return t.includes(e.replace("t","s").toUpperCase())}return{v:r,con:{CMP:{[s.ANALYTICS]:E(s.ANALYTICS),[s.PREFERENCES]:E(s.PREFERENCES),[s.MARKETING]:E(s.MARKETING),[s.SALE_OF_DATA]:E(s.SALE_OF_DATA)}},region:o||"",cus:d,purposes:{[a.ANALYTICS]:p(a.ANALYTICS),[a.PREFERENCES]:p(a.PREFERENCES),[a.MARKETING]:p(a.MARKETING),[a.SALE_OF_DATA]:p(a.SALE_OF_DATA)},sale_of_data_region:"t"==u,display_banner:"t"==i,consent_id:f}}(e);return}(e)}function j(){try{let e=F();if(!e)return;return e}catch(e){return}}function G(){return{m:B(s.MARKETING),a:B(s.ANALYTICS),p:B(s.PREFERENCES),s:B(s.SALE_OF_DATA)}}function K(){return G()[s.SALE_OF_DATA]}function U(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return null===e&&(e=j()),void 0===e}function x(e){switch(e){case c.ACCEPTED:return i.ACCEPTED;case c.DECLINED:return i.DECLINED;default:return i.NO_VALUE}}function Y(e){switch(e){case s.ANALYTICS:return u.ANALYTICS;case s.MARKETING:return u.MARKETING;case s.PREFERENCES:return u.PREFERENCES;case s.SALE_OF_DATA:return u.SALE_OF_DATA}}function B(e){const n=j();if(!n)return c.NO_VALUE;const t=n.con.CMP;return t?t[e]:c.NO_VALUE}function V(){const e=j();return U(e)?"":e.region||""}function q(e){const n=j();if(!n||!n.purposes)return!0;const t=n.purposes[e];return"boolean"!=typeof t||t}function H(){return q(a.PREFERENCES)}function J(){return q(a.ANALYTICS)}function W(){return q(a.MARKETING)}function $(){return q(a.SALE_OF_DATA)}function X(){const e=j();return!!e&&("boolean"==typeof e.display_banner&&e.display_banner)}function Z(){const e=j();return e&&e.sale_of_data_region||!1}function z(){const e=j();return e&&e.consent_id||""}function Q(e){void 0!==e.granular_consent&&function(e){const n=e[a.MARKETING],o=e[a.SALE_OF_DATA],r=e[a.ANALYTICS],i=e[a.PREFERENCES];!0===n?ee(t.MARKETING_ACCEPTED):!1===n&&ee(t.MARKETING_DECLINED);!0===o?ee(t.SALE_OF_DATA_ACCEPTED):!1===o&&ee(t.SALE_OF_DATA_DECLINED);!0===r?ee(t.ANALYTICS_ACCEPTED):!1===r&&ee(t.ANALYTICS_DECLINED);!0===i?ee(t.PREFERENCES_ACCEPTED):!1===i&&ee(t.PREFERENCES_DECLINED);const c=function(e){const n={marketingAllowed:e[a.MARKETING],saleOfDataAllowed:e[a.SALE_OF_DATA],analyticsAllowed:e[a.ANALYTICS],preferencesAllowed:e[a.PREFERENCES],firstPartyMarketingAllowed:e[a.MARKETING],thirdPartyMarketingAllowed:e[a.SALE_OF_DATA]};return n}(e);ee(t.CONSENT_COLLECTED,c);const s=[r,i,n,o];s.every((e=>!0===e))&&ee(t.TRACKING_ACCEPTED);s.every((e=>!1===e))&&ee(t.TRACKING_DECLINED)}({[a.PREFERENCES]:H(),[a.ANALYTICS]:J(),[a.MARKETING]:W(),[a.SALE_OF_DATA]:$()})}function ee(e,n){try{document.dispatchEvent(new CustomEvent(e,{detail:n||{}}))}catch(n){console.error('[Shopify Customer Privacy] Error in event listener for "'.concat(e,'":'),n)}}const ne="95ba910bcec4542ef2a0b64cd7ca666c";function te(e,n,t){try{var o;!function(e){const n=new XMLHttpRequest;n.open("POST","https://error-analytics-production.shopifysvc.com",!0),n.setRequestHeader("Content-Type","application/json"),n.setRequestHeader("Bugsnag-Api-Key",ne),n.setRequestHeader("Bugsnag-Payload-Version","5");const t=function(e){var n;const t=function(e){return e?e.stackTrace||e.stack||e.description||e.name:void 0}(e.error);let o,r;if(null!==(n=e.error)&&void 0!==n&&n.name){var i,c;o=e.error.name,r=null!==(i=null===(c=e.error)||void 0===c?void 0:c.message)&&void 0!==i?i:""}else{const n=(t||"unknown error").split("\n")[0],i=n.indexOf(":");var a,s,u;if(i>0)o=n.substring(0,i).trim(),r=n.substring(i+1).trim();else o=n.trim()||"unknown error",r=(null===(a=e.error)||void 0===a?void 0:a.message)||(null===(s=e.error)||void 0===s?void 0:s.error)||(null===(u=e.error)||void 0===u?void 0:u.toString())||"No error message available"}return JSON.stringify({payloadVersion:5,notifier:{name:"ConsentTrackingAPI",version:"latest",url:"-"},events:[{exceptions:[{errorClass:o,message:r,stacktrace:[{file:"consent-tracking-api.js",lineNumber:"1",method:t}],type:"browserjs"}],context:e.context||"general",app:{id:"ConsentTrackingAPI",version:"latest"},metaData:{request:{shopId:e.shopId,shopUrl:window.location.href},device:{userAgent:window.navigator.userAgent},"Additional Notes":e.notes},unhandled:!1}]})}(e);n.send(t)}({error:e,context:n,shopId:re()||(null===(o=window.Shopify)||void 0===o?void 0:o.shop),notes:t})}catch(e){}}function oe(e){return function(){try{return e(...arguments)}catch(e){throw e instanceof n||te(e),e}}}function re(){try{const e=document.getElementById("shopify-features").textContent;return JSON.parse(e).shopId}catch(e){return null}}function ie(){return W()}function ce(){return $()}function ae(){const e={},n=G();for(const t of Object.keys(n))e[Y(t)]=x(n[t]);return e}function se(e,t){const r=new I;return J()&&r.produce("setTrackingConsent"),"object"==typeof e&&e.headlessStorefront&&!e.storefrontAccessToken?(v.warn("Headless consent has been updated. Please read shopify.dev/docs/api/customer-privacy to integrate."),r.produce("setTrackingConsent-Headless"),function(e,n){function t(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c.NO_VALUE;return!0===e?c.ACCEPTED:!1===e?c.DECLINED:n}const r={[s.ANALYTICS]:t(e[u.ANALYTICS],c.DECLINED),[s.MARKETING]:t(e[u.MARKETING],c.DECLINED),[s.PREFERENCES]:t(e[u.PREFERENCES],c.DECLINED),[s.SALE_OF_DATA]:t(e[u.SALE_OF_DATA])},i={v:o,reg:"",con:{CMP:r}},a=encodeURIComponent(JSON.stringify(i));return P(b,e.rootDomain,M,a),n(null),new Promise(((e,n)=>{}))}(e,t||(()=>{}))):function(e,t){if(function(e){if("boolean"!=typeof e&&"object"!=typeof e)throw new n('setTrackingConsent received an invalid argument of type "'.concat(typeof e,'". ')+"Expected an object with consent keys. Example: setTrackingConsent({ analytics: true, marketing: false }). "+"See ".concat(ve," for documentation."));if("object"==typeof e){const t=Object.keys(e);if(0===t.length)throw new n("The submitted consent object is empty. "+"Expected at least one consent key: ".concat(we,". ")+"Example: setTrackingConsent({ analytics: true, marketing: false }). "+"See ".concat(ve," for documentation."));for(const e of t)if(!me.includes(e))throw new n('The submitted consent object contains an invalid key: "'.concat(e,'". ')+"Valid keys are: ".concat(we,". ")+"Example: setTrackingConsent({ analytics: true, marketing: false }). "+"See ".concat(ve," for documentation."))}}(e),void 0!==t&&"function"!=typeof t)throw new n('setTrackingConsent received an invalid callback of type "'.concat(typeof t,'". ')+"The second argument must be a function if provided. Example: setTrackingConsent({ analytics: true }, (error, result) => { ... }). "+"See ".concat(ve," for documentation."));let o;if(!0===e||!1===e){v.warn("Binary consent is deprecated. Please update to granular consent (shopify.dev/docs/api/consent-tracking)");o={analytics:e,preferences:e,marketing:e}}else o=e;const r=function(e){if(!e)return null;try{return Pe()?document.referrer:""}catch(e){return""}}(o.analytics),i=function(e){if(!e)return null;if(!Pe())return"/";try{return window.location.pathname+window.location.search}catch(e){return"/"}}(o.analytics);return he(h(h({granular_consent:o},null!==r&&{referrer:r}),null!==i&&{landing_page:i}),t)}(e,t)}const ue=e=>{let{useBugsnagReporting:n}=e;K()!=c.DECLINED&&!1===Le()&&_e(!1,(()=>!1));const t={getTrackingConsent:Te,setTrackingConsent:se,userCanBeTracked:Re,getRegulation:Se,isRegulationEnforced:Ie,getShopPrefs:Ne,shouldShowGDPRBanner:ke,userDataCanBeSold:Oe,setCCPAConsent:_e,getCCPAConsent:be,shouldShowCCPABanner:Me,doesMerchantSupportGranularConsent:Fe,analyticsProcessingAllowed:J,preferencesProcessingAllowed:H,marketingAllowed:ie,firstPartyMarketingAllowed:ie,saleOfDataAllowed:ce,thirdPartyMarketingAllowed:ce,currentVisitorConsent:ae,shouldShowBanner:X,saleOfDataRegion:Z,getRegion:De,getTrackingConsentMetafield:je,consentId:Ge,unstable:{analyticsProcessingAllowed:J,preferencesProcessingAllowed:H,marketingAllowed:ie,saleOfDataAllowed:ce,currentVisitorConsent:ae,shouldShowBanner:X,saleOfDataRegion:Z},__metadata__:{name:"@shopify/consent-tracking-api",version:"v0.1",description:"Shopify Consent Tracking API"}};if(!n)return t;const o=["unstable","__metadata__"];for(const e in t)t.hasOwnProperty(e)&&(t[e]=o.includes(e)?t[e]:oe(t[e]));return t};function le(){return ue(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{useBugsnagReporting:!1})}function de(e){if(!e)return;const n=function(e){const n=new URL(e,window.location.origin),t=Ee(e)?fe(n):fe(n).replace(window.location.origin,"");return document.querySelectorAll('a[href^="'.concat(t,'"]'))}(e);if(!n.length)return;const t=z(),o=function(){const e=ae();if(!e)return null;if(!("analytics"in e&&"marketing"in e&&"preferences"in e))return null;const n=pe(e.analytics),t=pe(e.marketing),o=pe(e.preferences);return""===n&&""===t&&""===o?null:"a".concat(n,"m").concat(t,"p").concat(o)}();for(let r=0;r{if(e.ok)return e.json();throw new Error("Server error")})).then((o=>{var r,i;const c=31536e6,a=12096e5,s=o.data.consentManagement.cookies.cookieDomain,u=s||t.checkoutRootDomain||window.location.hostname,l=t.storefrontRootDomain||s||window.location.hostname,d=o.data.consentManagement.cookies.trackingConsentCookie,f=o.data.consentManagement.cookies.landingPageCookie,E=o.data.consentManagement.cookies.origReferrerCookie,p=null!==(r=null===(i=o.data.consentManagement)||void 0===i?void 0:i.customerAccountUrl)&&void 0!==r?r:"";return d&&function(e){var n;null!==(n=window.Shopify)&&void 0!==n&&n.customerPrivacy||(window.Shopify=window.Shopify||{},window.Shopify.customerPrivacy={}),window.Shopify.customerPrivacy.cachedConsent=e}(d),t.headlessStorefront&&(P(b,u,c,d),f&&E&&(P(Ae,u,a,f),P(Ce,u,a,E)),l!==u&&(P(b,l,c,d),f&&E&&(P(Ae,l,a,f),P(Ce,l,a,E)))),Q(e),de(p),void 0!==n&&n(null,o),o})).catch((e=>{const t="Error while setting storefront API consent: "+e.message;if(void 0===n)throw{error:t};n({error:t})}))}const ye=[u.MARKETING,u.ANALYTICS,u.PREFERENCES,u.SALE_OF_DATA],me=[...ye,u.EMAIL,d,f,E,p,l,A,C],we=ye.map((e=>'"'.concat(e,'"'))).join(", "),ve="https://shopify.dev/docs/api/customer-privacy";function _e(e,n){if(v.warn("This method is deprecated. Please read shopify.dev/docs/api/customer-privacy for the latest information."),"boolean"!=typeof e)throw TypeError("setCCPAConsent must be called with a boolean consent value");if("function"!=typeof n)throw TypeError("setCCPAConsent must be called with a callback function");return he({granular_consent:{sale_of_data:e}},n)}function Te(){const e=new I;if(J()&&e.produce("getTrackingConsent"),U())return i.NO_VALUE;const n=G();return n[s.MARKETING]===c.ACCEPTED&&n[s.ANALYTICS]===c.ACCEPTED?i.ACCEPTED:n[s.MARKETING]===c.DECLINED||n[s.ANALYTICS]===c.DECLINED?i.DECLINED:i.NO_INTERACTION}function Se(){(new I).produce("getRegulation"),v.warn("getRegulation is deprecated and will be removed.");const e=V();return""===e?"":["AT","BE","BG","HR","CY","CZ","DK","EE","FI","FR","DE","GR","HU","IS","IE","IT","LV","LI","LT","LU","MT","NL","NO","PL","PT","RO","SI","SK","ES","SE","GB"].includes(e.slice(0,2))?"GDPR":"US"===e.slice(0,2)&&["CA","VA"].includes(e.slice(2,4))?"CCPA":""}function Ne(){return(new I).produce("getShopPrefs"),v.warn("getShopPrefs is deprecated and will be removed."),{limit:[]}}function De(){return V()}function Pe(){try{if(""===document.referrer)return!0;const e=document.createElement("a");return e.href=document.referrer,window.location.hostname!=e.hostname}catch(e){return!0}}function Ie(){return(new I).produce("isRegulationEnforced"),v.warn("isRegulationEnforced is deprecated and will be removed."),!0}function Re(){return!!U()||W()&&J()}function Le(){return Z()?"string"==typeof navigator.globalPrivacyControl?"1"!==navigator.globalPrivacyControl:"boolean"==typeof navigator.globalPrivacyControl?!navigator.globalPrivacyControl:null:null}function Oe(){return v.warn("userDataCanBeSold is deprecated and will be replaced with saleOfDataAllowed."),$()}function ke(){return X()&&Te()===i.NO_INTERACTION}function be(){return!1===Le()?i.DECLINED:(e=K(),U()?i.NO_VALUE:e===c.NO_VALUE?i.NO_INTERACTION:x(e));var e}function Me(){return(new I).produce("shouldShowCCPABanner"),v.warn("shouldShowCCPABanner is deprecated and will be removed."),Z()&&be()===i.NO_INTERACTION}function Fe(){return!0}function je(e){return function(e){const n=j();if(U(n)||!n.cus)return;const t=n.cus[encodeURIComponent(e)];return t?_(t):t}(e)}function Ge(){return z()}function Ke(){var e,n,o,r;const i=le({useBugsnagReporting:!0});if((null===(e=window.Shopify.trackingConsent)||void 0===e?void 0:e.__metadata__)||(null===(n=window.Shopify.customerPrivacy)||void 0===n?void 0:n.__metadata__)){const e=null===(o=window.Shopify.customerPrivacy.__metadata__)||void 0===o?void 0:o.version,n=null===(r=i.__metadata__)||void 0===r?void 0:r.version,t=`Multiple versions of Shopify.trackingConsent or Shopify.customerPrivacy loaded - Version '${e}' is already loaded but replacing with version '${n}'.\n\nThis could result in unexpected behavior. See documentation https://shopify.dev/docs/api/customer-privacy for more information.`,c="Shopify.trackingConsent or Shopify.customerPrivacy already exists.\n\nLoading multiple versions could result in unexpected behavior. See documentation https://shopify.dev/docs/api/customer-privacy for more information.";try{console.warn(e&&n?t:c)}catch(e){if(!(e instanceof ReferenceError))throw e}}const c=Object.assign(Object.assign({},window.Shopify.customerPrivacy),i);window.Shopify.customerPrivacy=window.Shopify.trackingConsent=c,ee(t.CONSENT_TRACKING_API_LOADED)}window.Shopify=window.Shopify?window.Shopify:{},Ke(),e.default=le,e.setGlobalObject=Ke,Object.defineProperty(e,"__esModule",{value:!0})}({}); //# sourceMappingURL=consent-tracking-api.js.map