!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{y()||console.warn(e)},w.error=e=>{y()||console.error(e)},w.info=e=>{y()||console.info(e)},w.debug=e=>{y()||console.debug(e)},w.trace=e=>{y()||console.trace(e)};const _=w;function T(e){try{return decodeURIComponent(e)}catch(e){return""}}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 v(e){return e===encodeURIComponent(T(e))}function D(e,n,t,o){if(!v(o))throw new TypeError("Cookie value is not correctly URI encoded.");if(!v(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}const I="_cmp";const P="_tracking_consent",R=31536e6;function L(){const e=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(t):void 0}()||N(P)||function(){try{var 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===I));let o=null==t?void 0:t.description;if(!o)return;try{o=decodeURIComponent(o)}catch(e){}return o}catch(e){return}}();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=Array.from(atob(e)).map((e=>e.charCodeAt(0).toString(16).padStart(2,"0"))).join("");f=[8,13,18,23].reduce(((e,n)=>e.slice(0,n)+"-"+e.slice(n)),n)}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 O(){try{let e=L();if(!e)return;return e}catch(e){return}}function k(){return{m:G(s.MARKETING),a:G(s.ANALYTICS),p:G(s.PREFERENCES),s:G(s.SALE_OF_DATA)}}function b(){return k()[s.SALE_OF_DATA]}function M(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return null===e&&(e=O()),void 0===e}function F(e){switch(e){case c.ACCEPTED:return i.ACCEPTED;case c.DECLINED:return i.DECLINED;default:return i.NO_VALUE}}function j(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 G(e){const n=O();if(!n)return c.NO_VALUE;const t=n.con.CMP;return t?t[e]:c.NO_VALUE}function K(){const e=O();return M(e)?"":e.region||""}function U(e){const n=L();if(!n||!n.purposes)return!0;const t=n.purposes[e];return"boolean"!=typeof t||t}function Y(){return U(a.PREFERENCES)}function x(){return U(a.ANALYTICS)}function B(){return U(a.MARKETING)}function V(){return U(a.SALE_OF_DATA)}function q(){const e=L();return!!e&&("boolean"==typeof e.display_banner&&e.display_banner)}function H(){const e=L();return e&&e.sale_of_data_region||!1}function J(){const e=L();return e&&e.consent_id||""}class W{constructor(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.useInstrumentation=void 0,W.instance)return W.instance;W.instance=this,this.useInstrumentation=e}instrumentationEnabled(){return this.useInstrumentation}setUseInstrumentation(e){this.useInstrumentation=e}produce(e,n){if(this.instrumentationEnabled()&&x())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())};if(!window.location.host.endsWith("spin.dev"))return fetch("https://monorail-edge.shopifysvc.com/v1/produce",{headers:o,body:JSON.stringify(t),method:"POST",mode:"cors",credentials:"omit"});console.log("Monorail event from consent API:",o,t)}catch(e){}}}function $(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?X(t.MARKETING_ACCEPTED):!1===n&&X(t.MARKETING_DECLINED);!0===o?X(t.SALE_OF_DATA_ACCEPTED):!1===o&&X(t.SALE_OF_DATA_DECLINED);!0===r?X(t.ANALYTICS_ACCEPTED):!1===r&&X(t.ANALYTICS_DECLINED);!0===i?X(t.PREFERENCES_ACCEPTED):!1===i&&X(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);X(t.CONSENT_COLLECTED,c);const s=[r,i,n,o];s.every((e=>!0===e))&&X(t.TRACKING_ACCEPTED);s.every((e=>!1===e))&&X(t.TRACKING_DECLINED)}({[a.PREFERENCES]:Y(),[a.ANALYTICS]:x(),[a.MARKETING]:B(),[a.SALE_OF_DATA]:V()})}function X(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)}}W.instance=void 0;const Z="95ba910bcec4542ef2a0b64cd7ca666c";function z(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",Z),n.setRequestHeader("Bugsnag-Payload-Version","5");const t=function(e){const n=function(e){return e.stackTrace||e.stack||e.description||e.name}(e.error),[t,o]=(n||"unknown error").split("\n")[0].split(":");return JSON.stringify({payloadVersion:5,notifier:{name:"ConsentTrackingAPI",version:"latest",url:"-"},events:[{exceptions:[{errorClass:(t||"").trim(),message:(o||"").trim(),stacktrace:[{file:"consent-tracking-api.js",lineNumber:"1",method:n}],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:ee()||(null===(o=window.Shopify)||void 0===o?void 0:o.shop),notes:t})}catch(e){}}function Q(e){return function(){try{return e(...arguments)}catch(e){throw e instanceof n||z(e),e}}}function ee(){try{const e=document.getElementById("shopify-features").textContent;return JSON.parse(e).shopId}catch(e){return null}}function ne(){return B()}function te(){return V()}function oe(){const e={},n=k();for(const t of Object.keys(n))e[j(t)]=F(n[t]);return e}function re(e,t){const r=new W;return r.produce("setTrackingConsent"),"object"==typeof e&&e.headlessStorefront&&!e.storefrontAccessToken?(_.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 D(P,e.rootDomain,R,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(he," 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(ge,". ")+"Example: setTrackingConsent({ analytics: true, marketing: false }). "+"See ".concat(he," for documentation."));for(const e of t)if(!Ce.includes(e))throw new n('The submitted consent object contains an invalid key: "'.concat(e,'". ')+"Valid keys are: ".concat(ge,". ")+"Example: setTrackingConsent({ analytics: true, marketing: false }). "+"See ".concat(he," 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(he," for documentation."));let o;if(!0===e||!1===e){_.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;return Se()?document.referrer:""}(o.analytics),i=function(e){if(!e)return null;return Se()?window.location.pathname+window.location.search:"/"}(o.analytics);return pe(h(h({granular_consent:o},null!==r&&{referrer:r}),null!==i&&{landing_page:i}),t)}(e,t)}const ie=e=>{let{useBugsnagReporting:n,useInstrumentation:t}=e;b()!=c.DECLINED&&!1===De()&&me(!1,(()=>!1));const o={getTrackingConsent:ye,setTrackingConsent:re,userCanBeTracked:ve,getRegulation:we,isRegulationEnforced:Ne,getShopPrefs:_e,shouldShowGDPRBanner:Pe,userDataCanBeSold:Ie,setCCPAConsent:me,getCCPAConsent:Re,shouldShowCCPABanner:Le,doesMerchantSupportGranularConsent:Oe,analyticsProcessingAllowed:x,preferencesProcessingAllowed:Y,marketingAllowed:ne,firstPartyMarketingAllowed:ne,saleOfDataAllowed:te,thirdPartyMarketingAllowed:te,currentVisitorConsent:oe,shouldShowBanner:q,saleOfDataRegion:H,getRegion:Te,getTrackingConsentMetafield:ke,consentId:be,unstable:{analyticsProcessingAllowed:x,preferencesProcessingAllowed:Y,marketingAllowed:ne,saleOfDataAllowed:te,currentVisitorConsent:oe,shouldShowBanner:q,saleOfDataRegion:H},__metadata__:{name:"@shopify/consent-tracking-api",version:"v0.1",description:"Shopify Consent Tracking API"}};if(new W(t),!n)return o;const r=["unstable","__metadata__"];for(const e in o)o.hasOwnProperty(e)&&(o[e]=r.includes(e)?o[e]:Q(o[e]));return o};function ce(){return ie(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{useBugsnagReporting:!1,useInstrumentation:!1})}function ae(e){if(!e)return;const n=function(e){const n=new URL(e,window.location.origin),t=ue(e)?se(n):se(n).replace(window.location.origin,"");return document.querySelectorAll('a[href^="'.concat(t,'"]'))}(e);if(!n.length)return;const t=J(),o=function(){const e=oe();if(!e)return null;if(!("analytics"in e&&"marketing"in e&&"preferences"in e))return null;const n=le(e.analytics),t=le(e.marketing),o=le(e.preferences);return""===n&&""===t&&""===o?null:"a".concat(n,"m").concat(t,"p").concat(o)}();for(const r of Array.from(n)){const n=r.getAttribute("href");if(!n)continue;const i=new URL(n,window.location.origin);if(t&&i.searchParams.set("consent_id",t),o&&i.searchParams.set("consent",o),t||o){const n=ue(e)?i.toString():i.toString().replace(window.location.origin,"");r.setAttribute("href",n)}}}function se(e){return"".concat(e.origin).concat(e.pathname.replace(/\/$/,""))}function ue(e){return e.startsWith("http://")||e.startsWith("https://")}function le(e){switch(e){case i.ACCEPTED:return"1";case i.DECLINED:return"0";default:return""}}const de="_landing_page",fe="_orig_referrer";function Ee(e){const n=e.granular_consent,t=S(h(h({visitorConsent:h({marketing:n.marketing,analytics:n.analytics,preferences:n.preferences,saleOfData:n.sale_of_data},n.metafields&&{metafields:n.metafields})},n.email&&{visitorEmail:n.email}),{},{origReferrer:e.referrer,landingPage:e.landing_page}));return{query:"query { consentManagement { cookies(".concat(t,") { trackingConsentCookie cookieDomain landingPageCookie origReferrerCookie } customerAccountUrl } }"),variables:{}}}function pe(e,n){const t=e.granular_consent,o=t.storefrontAccessToken||function(){const e=document.documentElement.querySelector("#shopify-features"),n="Could not find liquid access token";if(!e)return void _.warn(n);const t=e.textContent;if(!t)return void _.warn(n);let o;try{o=JSON.parse(t).accessToken}catch(e){return void _.warn(n)}if(!o)return void _.warn(n);return o}(),r=t.checkoutRootDomain||window.location.host,i=t.isExtensionToken?"Shopify-Storefront-Extension-Token":"x-shopify-storefront-access-token",c={headers:h({"content-type":"application/json",[i]:o},!1),body:JSON.stringify(Ee(e)),method:"POST"};return fetch("https://".concat(r,"/api/unstable/graphql.json"),c).then((e=>{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&&(D(P,u,c,d),f&&E&&(D(de,u,a,f),D(fe,u,a,E)),l!==u&&(D(P,l,c,d),f&&E&&(D(de,l,a,f),D(fe,l,a,E)))),$(e),ae(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 Ae=[u.MARKETING,u.ANALYTICS,u.PREFERENCES,u.SALE_OF_DATA],Ce=[...Ae,u.EMAIL,d,f,E,p,l,A,C],ge=Ae.map((e=>'"'.concat(e,'"'))).join(", "),he="https://shopify.dev/docs/api/customer-privacy";function me(e,n){if(_.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 pe({granular_consent:{sale_of_data:e}},n)}function ye(){if((new W).produce("getTrackingConsent"),M())return i.NO_VALUE;const e=k();return e[s.MARKETING]===c.ACCEPTED&&e[s.ANALYTICS]===c.ACCEPTED?i.ACCEPTED:e[s.MARKETING]===c.DECLINED||e[s.ANALYTICS]===c.DECLINED?i.DECLINED:i.NO_INTERACTION}function we(){(new W).produce("getRegulation"),_.warn("getRegulation is deprecated and will be removed.");const e=K();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 _e(){return(new W).produce("getShopPrefs"),_.warn("getShopPrefs is deprecated and will be removed."),{limit:[]}}function Te(){return K()}function Se(){if(""===document.referrer)return!0;const e=document.createElement("a");return e.href=document.referrer,window.location.hostname!=e.hostname}function Ne(){return(new W).produce("isRegulationEnforced"),_.warn("isRegulationEnforced is deprecated and will be removed."),!0}function ve(){return!!M()||B()&&x()}function De(){return H()?"string"==typeof navigator.globalPrivacyControl?"1"!==navigator.globalPrivacyControl:"boolean"==typeof navigator.globalPrivacyControl?!navigator.globalPrivacyControl:null:null}function Ie(){return _.warn("userDataCanBeSold is deprecated and will be replaced with saleOfDataAllowed."),V()}function Pe(){return q()&&ye()===i.NO_INTERACTION}function Re(){return!1===De()?i.DECLINED:(e=b(),M()?i.NO_VALUE:e===c.NO_VALUE?i.NO_INTERACTION:F(e));var e}function Le(){return(new W).produce("shouldShowCCPABanner"),_.warn("shouldShowCCPABanner is deprecated and will be removed."),H()&&Re()===i.NO_INTERACTION}function Oe(){return!0}function ke(e){return function(e){const n=O();if(M(n)||!n.cus)return;const t=n.cus[encodeURIComponent(e)];return t?T(t):t}(e)}function be(){return J()}function Me(){var e,n,o,r;const i=ce({useBugsnagReporting:!0,useInstrumentation:!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,X(t.CONSENT_TRACKING_API_LOADED)}window.Shopify=window.Shopify?window.Shopify:{},Me(),e.default=ce,e.setGlobalObject=Me,Object.defineProperty(e,"__esModule",{value:!0})}({}); //# sourceMappingURL=consent-tracking-api.js.map