import{t as e}from"./chunk.document_DMcRsBXN.esm.js";import{t}from"./chunk.window_CAbVMZox.esm.js";import{c as n,i as r,l as o,n as i,o as s,r as a,s as c,u}from"./chunk.casing_U_9x-Om3.esm.js";import{t as l}from"./chunk.v4_C3N_0s0v.esm.js";import{n as d,t as p}from"./chunk.networkErrorMessages_Du380vAr.esm.js";import{a as h,i as f,n as v,o as m,r as y,s as g,t as _}from"./chunk.utils_Cjeq_SSZ.esm.js";var b,w,k,E,P=0,S=[],I=u,C=I.__b,M=I.__r,A=I.diffed,x=I.__c,T=I.unmount,O=I.__;function j(e,t){I.__h&&I.__h(w,e,P||t),P=0;var n=w.__H||(w.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function B(e){return P=1,D(G,e)}function D(e,t,n){var r=j(b++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):G(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=w,!w.__f)){var o=function(e,t,n){if(!r.__c.__H)return!0;var o=r.__c.__H.__.filter((function(e){return!!e.__c}));if(o.every((function(e){return!e.__N})))return!i||i.call(this,e,t,n);var s=r.__c.props!==e;return o.forEach((function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(s=!0)}})),i&&i.call(this,e,t,n)||s};w.__f=!0;var i=w.shouldComponentUpdate,s=w.componentWillUpdate;w.componentWillUpdate=function(e,t,n){if(this.__e){var r=i;i=void 0,o(e,t,n),i=r}s&&s.call(this,e,t,n)},w.shouldComponentUpdate=o}return r.__N||r.__}function N(e,t){var n=j(b++,3);!I.__s&&X(n.__H,t)&&(n.__=e,n.u=t,w.__H.__h.push(n))}function U(e,t){var n=j(b++,4);!I.__s&&X(n.__H,t)&&(n.__=e,n.u=t,w.__h.push(n))}function L(e){return P=5,R((function(){return{current:e}}),[])}function H(e,t,n){P=6,U((function(){if("function"==typeof e){var n=e(t());return function(){e(null),n&&"function"==typeof n&&n()}}if(e)return e.current=t(),function(){return e.current=null}}),null==n?n:n.concat(e))}function R(e,t){var n=j(b++,7);return X(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function $(e,t){return P=8,R((function(){return e}),t)}function V(e){var t=w.context[e.__c],n=j(b++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(w)),t.props.value):e.__}function q(){var e=j(b++,11);if(!e.__){for(var t=w.__v;null!==t&&!t.__m&&null!==t.__;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__="P"+n[0]+"-"+n[1]++}return e.__}function F(){for(var e;e=S.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(W),e.__H.__h.forEach(J),e.__H.__h=[]}catch(t){e.__H.__h=[],I.__e(t,e.__v)}}I.__b=function(e){w=null,C&&C(e)},I.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),O&&O(e,t)},I.__r=function(e){M&&M(e),b=0;var t=(w=e.__c).__H;t&&(k===w?(t.__h=[],w.__h=[],t.__.forEach((function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0}))):(t.__h.forEach(W),t.__h.forEach(J),t.__h=[],b=0)),k=w},I.diffed=function(e){A&&A(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==S.push(t)&&E===I.requestAnimationFrame||((E=I.requestAnimationFrame)||z)(F)),t.__H.__.forEach((function(e){e.u&&(e.__H=e.u),e.u=void 0}))),k=w=null},I.__c=function(e,t){t.some((function(e){try{e.__h.forEach(W),e.__h=e.__h.filter((function(e){return!e.__||J(e)}))}catch(n){t.some((function(e){e.__h&&(e.__h=[])})),t=[],I.__e(n,e.__v)}})),x&&x(e,t)},I.unmount=function(e){T&&T(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach((function(e){try{W(e)}catch(e){t=e}})),n.__H=void 0,t&&I.__e(t,n.__v))};var K="function"==typeof requestAnimationFrame;function z(e){var t,n=function(){clearTimeout(r),K&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);K&&(t=requestAnimationFrame(n))}function W(e){var t=w,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),w=t}function J(e){var t=w;e.__c=e.__(),w=t}function X(e,t){return!e||e.length!==t.length||t.some((function(t,n){return t!==e[n]}))}function G(e,t){return"function"==typeof t?t(e):t}const Z=c({createdAt:0,devMode:!1,element:null,instanceId:""}),Q=()=>V(Z);function Y(e){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Y(e)}function ee(e){var t=function(e,t){if("object"!=Y(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Y(t)?t:t+""}function te(e,t,n){return(t=ee(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ne(e){return re(e).map((e=>e instanceof Error?e:new oe(`[${typeof e}] ${function(e){if("function"==typeof e)return`${e.name||"anonymous"}`;if("string"!=typeof e)try{var t;return null!==(t=JSON.stringify(e))&&void 0!==t?t:typeof e}catch(e){}return`${e}`}(e).slice(0,10240)}`)))}function re(e,t=0){return t>=20?[e,"Truncated cause stack"]:e instanceof Error&&e.cause?[e,...re(e.cause,t+1)]:[e]}var oe=class extends Error{constructor(...e){super(...e),te(this,"name","BugsnagInvalidError")}},ie=/^\s*at .*(\S+:\d+|\(native\))/m,se=/^(eval@)?(\[native code])?$/;function ae(e){return e.stack?e.stack.match(ie)?function(e){return e.stack.split("\n").filter((e=>!!e.match(ie))).map((e=>{let t=e.replace(/^\s+/,"").replace(/^.*?\s+/,""),n=t.match(/ (\(.+\)$)/);t=n?t.replace(n[0],""):t;let r=ce(n?n[1]:t);return{method:n&&t||void 0,file:["eval",""].indexOf(r[0])>-1?void 0:r[0],lineNumber:r[1],columnNumber:r[2]}}))}(e):function(e){return e.stack.split("\n").filter((e=>!e.match(se))).map((e=>{if(-1===e.indexOf("@")&&-1===e.indexOf(":"))return{method:e};let t=/((.*".+"[^@]*)?[^@]*)(?:@)/,n=e.match(t),r=n&&n[1]?n[1]:void 0,o=ce(e.replace(t,""));return{method:r,file:o[0],lineNumber:o[1],columnNumber:o[2]}}))}(e):[]}function ce(e){if(-1===e.indexOf(":"))return[e];let t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));return[t[1],t[2]?Number(t[2]):void 0,t[3]?Number(t[3]):void 0]}var ue=class{constructor(e){var t,n,r;te(this,"breadcrumbs",[]),te(this,"apiKey",void 0),te(this,"plugins",void 0),te(this,"appId",void 0),te(this,"appType",void 0),te(this,"appVersion",void 0),te(this,"releaseStage",void 0),te(this,"locale",void 0),te(this,"userAgent",void 0),te(this,"metadata",void 0),te(this,"persistedMetadata",void 0),te(this,"onError",void 0),te(this,"onPostErrorListeners",[]),te(this,"endpoints",void 0),te(this,"session",void 0),this.apiKey=e.apiKey,this.appType=e.appType,this.appId=e.appId,this.appVersion=e.appVersion,this.releaseStage=e.releaseStage,this.locale=e.locale,this.userAgent=e.userAgent,this.metadata=e.metadata,this.onError=e.onError,this.persistedMetadata={},this.endpoints=null!==(t=e.endpoints)&&void 0!==t?t:{notify:"https://error-analytics-production.shopifysvc.com",sessions:"https://error-analytics-sessions-production.shopifysvc.com/observeonly"},this.plugins=null!==(n=e.plugins)&&void 0!==n?n:[],this.plugins.forEach((e=>e.load(this))),this.leaveBreadcrumb("Bugsnag started",void 0,"state"),(null===(r=e.withSessionTracking)||void 0===r||r)&&(this.session={id:this.getRandomUUID(),startedAt:(new Date).toISOString(),events:{handled:0,unhandled:0}},this.startSession())}addMetadata(e){for(let t of Object.keys(e))this.persistedMetadata[t]=e[t]}getSessionId(){var e;return null===(e=this.session)||void 0===e?void 0:e.id}leaveBreadcrumb(e,t,n="manual"){this.breadcrumbs.push({name:e,metaData:t,type:n,timestamp:(new Date).toISOString()})}notify(e,{errorClass:t,severity:n,severityType:r,handled:o=!0,metadata:i,context:s,groupingHash:a}={}){var c,u;let l=ne(e),d={...this.metadata,...this.persistedMetadata,...i},p=this.buildBugsnagEvent(l,{errorClass:t,severityType:r,handled:o,severity:n,metadata:d,context:s,groupingHash:a});if((null===(c=null===(u=this.onError)||void 0===u?void 0:u.call(this,p,e))||void 0===c||c)&&"development"!==this.releaseStage){this.updateAndAppendSessionInformation(p);let t=this.sendToBugsnag(p);return this.onPostErrorListeners.forEach((t=>t(p,e))),t}return Promise.resolve()}addOnPostError(e){this.onPostErrorListeners.push(e)}updateAndAppendSessionInformation(e){this.session&&(e.unhandled?this.session.events.unhandled++:this.session.events.handled++,e.session=this.session)}buildBugsnagEvent(e,{errorClass:t,severity:n="error",severityType:r="handledException",handled:o,metadata:i={},context:s,groupingHash:a}){let c=(new Date).toISOString(),{breadcrumbs:u,appId:l,appType:d,appVersion:p,releaseStage:h,locale:f,userAgent:v}=this;return{payloadVersion:"5",exceptions:e.map(((e,n)=>({errorClass:0===n&&null!=t?t:e.name,stacktrace:le(l,e),message:e.message,type:"browserjs"}))),severity:n,severityReason:{type:r},unhandled:!o,app:{id:l,type:d,version:p,releaseStage:h},device:{time:c,locale:f,userAgent:v},breadcrumbs:u,context:s,metaData:i,groupingHash:a}}async startSession(){if("development"===this.releaseStage)return void console.log("Skipping error logging session tracking in development mode");let{apiKey:e}=this,t={notifier:{name:"Bugsnag JavaScript",version:"7.22.2",url:"https://github.com/bugsnag/bugsnag-js"},app:{version:this.appVersion,releaseStage:this.releaseStage,type:this.appType},device:{id:this.appId,locale:this.locale,userAgent:this.userAgent},sessions:[this.session]};try{var n,r;await fetch(this.endpoints.sessions,{method:"POST",headers:{"Content-Type":"application/json","Bugsnag-Api-Key":e,"Bugsnag-Payload-Version":"5","Bugsnag-Sent-At":null!==(n=null===(r=this.session)||void 0===r?void 0:r.startedAt)&&void 0!==n?n:(new Date).toISOString()},body:JSON.stringify(pe(t))})}catch(e){console.warn("[bugsnag-light] failed to start session"),console.warn(e)}}async sendToBugsnag(e){let{apiKey:t}=this,n={apiKey:t,notifier:{name:"Bugsnag JavaScript",version:"7.22.2",url:"https://github.com/bugsnag/bugsnag-js"},events:[e]};try{await fetch(this.endpoints.notify,{method:"POST",headers:{"Content-Type":"application/json","Bugsnag-Api-Key":t,"Bugsnag-Payload-Version":"5","Bugsnag-Sent-At":e.device.time},body:JSON.stringify(pe(n))})}catch(e){console.warn("[bugsnag-light] failed to send an event"),console.warn(e)}}getRandomUUID(){try{return crypto.randomUUID()}catch(e){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}}};function le(e,t){let n=ae(t).map((t=>{var n,r,o,i;let s=null===(n=t.file)||void 0===n?void 0:n.includes(e);return{method:null!==(r=t.method)&&void 0!==r?r:"",file:null!==(o=t.file)&&void 0!==o?o:"",lineNumber:null!==(i=t.lineNumber)&&void 0!==i?i:0,columnNumber:t.columnNumber,inProject:s}}));if(t instanceof oe){let e=n.findIndex((e=>e.method.endsWith("notify")));e>-1&&(n=n.slice(e+1))}return n}var de=50;function pe(e,t=new Set,n=0){if(null===e||"object"!=typeof e)return e;if(n>=de)return"[MaxDepth]";if(t.has(e))return"[Circular]";let r=new Set(t);if(r.add(e),Array.isArray(e))return e.map((e=>pe(e,r,n+1)));let o={};for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(o[t]=pe(e[t],r,n+1));return o}var he=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function fe(e){return"string"==typeof e&&he.test(e)}var ve=class extends Error{constructor(e,t,n=l()){super(e),this.name=t,this.analyticsTraceId=n;const r=a(t);this.analyticsTraceId=n,this.code=r,this.name=t}};const me=["maximum call stack size exceeded","too much recursion"];const ye=["challenge","checkout_token","login_hint","shop_consent_token","shop_id_token","shopify_essential","transaction_params"],ge="REDACTED";function _e(e,t){let n=!1;for(const[r,o]of[...e.entries()]){if(ye.includes(r)){e.set(r,ge),n=!0;continue}if(t>=2)continue;const i=Se(o,t+1);null!==i&&(e.set(r,i),n=!0)}return n}const be="https://relative.invalid";function we(e){const t=e.replace(/%([0-7][0-9a-f])/gi,((e,t)=>String.fromCharCode(Number.parseInt(t,16))));return ye.some((e=>t.includes(e)))}function ke(e){try{return{relative:!1,url:new URL(e)}}catch(e){}if(!/^[/?#]/.test(e))return null;try{return{relative:!0,url:new URL(e,be)}}catch(e){return null}}function Ee({original:e,relative:t,url:n}){return t?e.startsWith("//")?`//${n.host}${n.pathname}${n.search}${n.hash}`:e.startsWith("/")?`${n.pathname}${n.search}${n.hash}`:e.startsWith("?")?`${n.search}${n.hash}`:n.hash:n.toString()}function Pe(e,t){const n=_e(e.searchParams,t),r=function(e,t){const n=e.hash.slice(1);if(!n.includes("="))return!1;if(t>=2)return!!we(n)&&(e.hash=ge,!0);const r=Se(n,t+1);return null!==r&&(e.hash=r,!0)}(e,t);return n||r}function Se(e,t){if(!we(e))return null;const n=ke(e);if(n)return Pe(n.url,t)?Ee({...n,original:e}):null;const r=new URLSearchParams(e);return _e(r,t)?r.toString():e.includes("?")?`${e.split("?")[0]}?${ge}`:ge}function Ie(e){try{const t=ke(e);if(t)return Pe(t.url,0)?Ee({...t,original:e}):e}catch(e){}return we(e)?`${e.split("?")[0]}?${ge}`:e}var Ce="e35d7136cee78d344ccffdbd5ca710fa",Me=class extends g{counter(e){super.counter(e),this.exportMetrics()}gauge(e){super.gauge(e),this.exportMetrics()}histogram(e){super.histogram(e),this.exportMetrics()}log(e){try{super.log(e),this.exportLogs().catch((()=>{}))}catch(e){}}};const Ae=["Failed to fetch dynamically imported module","error loading dynamically imported module","Importing a module script failed"],xe=new Set(["ShopPayPaymentRequest","ShopPayPaymentRequestButton","ShopPayPaymentRequestLogin"]),Te=["NotFoundError","NotSupportedError","ReferenceError","SyntaxError","TypeError"],Oe=["pc","android"],je=[{bucket:"lightpanda",marker:"lightpanda/"},{bucket:"googleother",marker:"(compatible; googleother)"},{bucket:"yeti",marker:"naver.me/spd"}],Be=e=>{const{errorClass:t,message:n}=e;return"NetworkError"===t||p(n)||(r=n,Boolean((null==r?void 0:r.includes("A network failure may have prevented the request from completing"))||(null==r?void 0:r.includes("Backpressure applied"))));var r},De=({event:n,metadata:r,onBotLikeUserAgentError:o,onNetworkError:i})=>{var s,a,c,u,l;const p=n.exceptions[0];if(!p)return!1;const h=(e=>{var t;const n=null==e?void 0:e.trim().toLowerCase();if(n)return Oe.includes(n)?n:null===(t=je.find((({marker:e})=>n.includes(e))))||void 0===t?void 0:t.bucket})(d.userAgent);if(h)return o(h),!1;const f=null===(s=r.custom)||void 0===s?void 0:s.feature;if(((e,t)=>{const{errorClass:n,message:r}=e,o="SecurityError"===n&&(null==r?void 0:r.includes("Failed to read the 'cookie' property from 'Document'"))&&(null==r?void 0:r.includes("sandboxed")),i="SecurityError"===n&&(null==r?void 0:r.includes("Blocked a frame with origin"))&&(null==r?void 0:r.includes("from accessing a cross-origin frame")),s="Error"===n&&"TooManyContexts"===r,a="string"==typeof t&&xe.has(t),c=e.stacktrace.some((e=>e.inProject));return Boolean(!c||o||s||i&&a)})(p,"string"==typeof f?f:void 0))return!1;if((e=>Te.includes(e.errorClass))(p))return!1;if((e=>"BugsnagInvalidError"===e.errorClass)(p))return!1;if((e=>{const{message:t}=e;return Ae.some((e=>null==t?void 0:t.includes(e)))})(p))return i("DynamicImportError"),!1;if(Be(p))return i(),!1;const v=null===(a=t.Shopify)||void 0===a||null===(a=a.featureAssets)||void 0===a?void 0:a["shop-js"],m=Boolean(v&&Object.keys(v).length>0),y=Array.from(e.querySelectorAll('script[src*="/shop-js/"]')).map((e=>e.src));n.device={locale:d.userLanguage||d.language,userAgent:d.userAgent,orientation:null===(c=t.screen)||void 0===c||null===(c=c.orientation)||void 0===c?void 0:c.type,time:(new Date).toISOString()},n.metaData={...n.metaData,...r,custom:{...null===(u=n.metaData)||void 0===u?void 0:u.custom,...r.custom,beta:!0,bundleLocale:"",compactUX:!0,domain:null==t||null===(l=t.location)||void 0===l?void 0:l.hostname,shopJsUrls:y,shopJsFeatureAssetsExist:m}},n.request={url:Ie(t.location.href)}};var Ne=class{constructor(e){this.opentelClient=new Me({exporter:v()});const t=function({metadata:e,onBotLikeUserAgentError:t,onNetworkError:n}){return{apiKey:Ce,appId:"shop-js",appVersion:"1.1.1-beta",onError:r=>De({event:r,metadata:e,onBotLikeUserAgentError:t,onNetworkError:n}),releaseStage:"production",withSessionTracking:!1}}({metadata:{custom:{feature:e}},onBotLikeUserAgentError:this.handleBotLikeUserAgentError.bind(this),onNetworkError:this.recordNetworkError.bind(this)});this.client=new ue(t),this.feature=e||"",this.leaveBreadcrumb=this.leaveBreadcrumb.bind(this),this.notify=this.notify.bind(this)}leaveBreadcrumb(e,t,n){if(!this.client)return void console.log("Bugsnag.leaveBreadcrumb() called before client creation.");const r=function(e){const t={};for(const[n,r]of Object.entries(e))t[n]="string"==typeof r&&/[?#]/.test(r)?Ie(r):r;return t}(t);this.client.leaveBreadcrumb(e,r,n)}async notify(e,t){var n,r;this.client?!function(e){const t=String(null==e?void 0:e.message).toLowerCase();return me.some((e=>t.includes(e)))}(e)?this.client.notify(e,t):this.opentelClient.counter({attributes:{error:"StackOverflowError",feature:this.feature},name:"shop_js_handle_silent_error",value:1}):null===(n=(r=console).warn)||void 0===n||n.call(r,"Bugsnag.notify() called before client creation.")}recordNetworkError(e="NetworkError"){this.opentelClient.counter({attributes:{feature:this.feature,error:e},name:"shop_js_network_error",value:1})}handleBotLikeUserAgentError(e){this.opentelClient.counter({attributes:{feature:this.feature,userAgentBucket:e},name:"shop_js_suppressed_bot_like_user_agent_error",value:1})}};const Ue=c({client:void 0,leaveBreadcrumb:()=>{throw new Error("Invalid attempt to call leaveBreadcrumb outside of context.")},notify:()=>{throw new Error("Invalid attempt to call notify outside of context.")}});var Le=0;Array.isArray;function He(e,t,n,r,o,i){t||(t={});var s,a,c=t;if("ref"in c)for(a in c={},t)"ref"==a?s=t[a]:c[a]=t[a];var l={type:e,props:c,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Le,__i:-1,__u:0,__source:o,__self:i};if("function"==typeof e&&(s=e.defaultProps))for(a in s)void 0===c[a]&&(c[a]=s[a]);return u.vnode&&u.vnode(l),l}const Re=({children:e})=>{const{featureName:t}=Q(),n=R((()=>{const{client:e,leaveBreadcrumb:n,notify:r}=new Ne(t);return{client:e,leaveBreadcrumb:n,notify:r}}),[t]);return He(Ue.Provider,{value:n,children:e})},$e=()=>{const e=V(Ue);if(!e)throw new Error("Invalid attempt to use useBugsnag outside of BugsnagProvider.");return e};function Ve({children:e}){const[t]=function(e){var t=j(b++,10),n=B();return t.__=e,w.componentDidCatch||(w.componentDidCatch=function(e,r){t.__&&t.__(e,r),n[1](e)}),[n[0],function(){n[1](void 0)}]}(),{notify:n}=$e();return N((()=>{t&&n(t instanceof Error?t:new ve(t,"UnhandledError"),{context:"Error in Preact tree"})}),[t,n]),He(o,{children:e})}function qe(e,t=200,n=!1){const r=L(),o=L(e);return o.current=e,$(((...e)=>{const i=n&&!r.current;var s;("number"==typeof r.current&&clearTimeout(r.current),r.current=setTimeout(((...e)=>{var t;(r.current=void 0,n)||(null===(t=o.current)||void 0===t||t.call(o,...e))}),t,...e),i)&&(null===(s=o.current)||void 0===s||s.call(o,...e))}),[t,n])}function Fe(){return Boolean(d.userAgent)&&/(android|iphone|ipad|mobile|phone)/i.test(d.userAgent)||function(){const e=d.userAgent.toLowerCase();return e.includes("fban/fbios")||e.includes("fb_iab/fb4a")}()||d.userAgent.toLowerCase().includes("instagram")||d.userAgent.toLowerCase().includes("messenger")||function(){const e=d.userAgent;return RegExp(Je).test(e)||RegExp(Xe).test(e)}()||/Mozilla\/5.0 \([^)]*Android[^)]*; wv\).+Chrome\//.test(d.userAgent)}function Ke(e){return"/"===e?e:e.endsWith("/")?e.slice(0,-1):e}function ze(){const e=d.userAgent,t=Boolean(e.match(/iPad/i))||Boolean(e.match(/iPhone/i)),n=Boolean(e.match(/WebKit/i));return t&&n&&!e.match(/CriOS/i)}function We(){return Boolean("undefined"!=typeof IntersectionObserver&&IntersectionObserver)}const Je="(iPod|iPod touch|iPhone|iPad);.*CPU.*OS[ +](\\d+)_(\\d+)(?:_(\\d+)|).* AppleNews",Xe="(iPod|iPod touch|iPhone|iPad);.*CPU.*OS[ +](\\d+)_(\\d+)(?:_(\\d+)|)(?!.*Version).*Mobile(?!.*Safari)",Ge=c({log:()=>{throw new Error("Invalid attempt to call log outside of context.")},recordCounter:()=>{throw new Error("Invalid attempt to call recordCounter outside of context.")},recordGauge:()=>{throw new Error("Invalid attempt to call recordGauge outside of context.")},recordHistogram:()=>{throw new Error("Invalid attempt to call recordHistogram outside of context.")},client:void 0}),Ze=()=>V(Ge),Qe=c({analyticsData:{analyticsTraceId:""},getTrekkieAttributes:async()=>Promise.resolve({}),produceMonorailEvent:()=>{throw new Error("Invalid attempt to call produceMonorailEvent outside of context.")},trackModalStateChange:()=>{throw new Error("Invalid attempt to call trackModalStateChange outside of context.")},trackPageImpression:async()=>{throw new Error("Invalid attempt to call trackPageImpression outside of context.")},trackUserAction:()=>{throw new Error("Invalid attempt to call trackUserAction outside of context.")},trackPostMessageTransmission:()=>{throw new Error("Invalid attempt to call trackPostMessageTransmission outside of context.")}}),Ye=Symbol("monorail-provider-data");function et(e){return e[Ye]}function tt(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function rt(e){for(var t=1;te.toString(16))).join("")}function lt(e,t=!0){return e&&Object.keys(e).length&&t?Object.keys(e).map((t=>({[dt(t)]:e[t]}))).reduce(((e,t)=>rt(rt({},e),t))):e}function dt(e){return e.split(/(?=[A-Z])/).join("_").toLowerCase()}function pt(e){return e.events.map((e=>{let t=!0,n=!0;return e&&e.options&&Object.prototype.hasOwnProperty.call(e.options,"convertEventCase")&&(t=Boolean(e.options.convertEventCase)),e&&e.options&&Object.prototype.hasOwnProperty.call(e.options,"convertMetaDataCase")&&(n=Boolean(e.options.convertMetaDataCase)),rt({schema_id:e.schemaId,payload:lt(e.payload,t)},e.metadata&&{metadata:lt(e.metadata,n)})}))}var ht=class e extends Error{constructor(t){super(`Error producing to the Monorail Edge. Response received: ${JSON.stringify(t)}`),tt(this,"name","MonorailUnableToProduceError"),this.response=t,Object.setPrototypeOf(this,e.prototype)}},ft=class e extends Error{constructor(t){super(`Response not from Monorail Edge. Response received: ${JSON.stringify(t)}`),tt(this,"name","MonorailInterceptedProduceError"),this.response=t,Object.setPrototypeOf(this,e.prototype)}},vt=class e extends Error{constructor(t){super(`Error producing to the Monorail Edge. Response received: ${JSON.stringify(t)}`),tt(this,"name","MonorailBatchProduceError"),Object.setPrototypeOf(this,e.prototype),this.response=t}},mt=class e extends Error{constructor(t,n){super(`Error completing request. A network failure may have prevented the request from completing. Error: ${t}. Schemas: ${Array.from(new Set(n)).join(", ")}`),tt(this,"name","MonorailRequestError"),Object.setPrototypeOf(this,e.prototype)}},yt=class e extends Error{constructor(t,n){super(`Error reading response from Monorail Edge. Status: ${n||"unknown"}. Error: ${(null==t?void 0:t.message)||"Unknown error"}`),tt(this,"name","MonorailResponseReadError"),this.error=t,this.status=n,Object.setPrototypeOf(this,e.prototype)}},gt=class e{static withEndpoint(t){return new e(`https://${new URL(t).hostname}`)}constructor(e=ot,t={}){var n,r;if(this.edgeDomain=e,this.optionsOrKeepalive=t,"boolean"==typeof t)return this.keepalive=t,void(this.detectInterceptedErrorEnabled=!1);this.keepalive=null!==(n=t.keepalive)&&void 0!==n&&n,this.detectInterceptedErrorEnabled=null!==(r=t.detectInterceptedErrorEnabled)&&void 0!==r&&r}async produceBatch(e){const t={events:pt(e),metadata:lt(e.metadata)};let n,r;try{var o,i;n=await fetch(this.produceBatchEndpoint(),{method:"post",headers:_t(e.metadata),body:JSON.stringify(t),keepalive:null!==(o=null===(i=e.options)||void 0===i?void 0:i.keepalive)&&void 0!==o?o:this.resolveKeepaliveFromEvents(e.events)})}catch(t){throw new mt(t,e.events.map((e=>e.schemaId)))}if(207===n.status){const e=await n.json();throw new vt(e)}try{r=await n.text()}catch(e){throw new yt(e,n.status)}if(!n.ok){if(!Boolean(n.headers.get("x-request-id"))&&this.detectInterceptedErrorEnabled)throw new ft({status:n.status,message:r});throw new ht({status:n.status,message:r})}return{status:n.status}}async produce(e){let t,n,r=!0;e&&e.options&&Object.prototype.hasOwnProperty.call(e.options,"convertEventCase")&&(r=Boolean(e.options.convertEventCase));try{var o,i;t=await async function({endpoint:e,event:t,keepalive:n}){var r,o,i,s,a;const c=t.metadata?{clientMessageId:null===(r=t.metadata)||void 0===r?void 0:r.clientMessageId,eventCreatedAtMs:null===(o=t.metadata)||void 0===o?void 0:o.eventCreatedAtMs,consent:null===(i=t.metadata)||void 0===i?void 0:i.consent,consent_provider:null===(s=t.metadata)||void 0===s?void 0:s.consent_provider,consent_version:null===(a=t.metadata)||void 0===a?void 0:a.consent_version}:void 0;return fetch(null!=e?e:it+st,{method:"post",headers:_t(t.metadata),body:JSON.stringify({schema_id:t.schemaId,payload:t.payload,metadata:c&<(c,!0)}),keepalive:n})}({endpoint:this.produceEndpoint(),keepalive:null!==(o=null===(i=e.options)||void 0===i?void 0:i.keepalive)&&void 0!==o?o:this.keepalive,event:rt(rt({},e),{},{payload:lt(e.payload,r)})})}catch(t){throw new mt(t,[e.schemaId])}if(!t)throw new ht({message:"No response from edge"});try{n=await t.text()}catch(e){throw new yt(e,t.status)}if(!t.ok){if(!Boolean(t.headers.get("x-request-id"))&&this.detectInterceptedErrorEnabled)throw new ft({status:t.status,message:n});throw new ht({status:t.status,message:n})}return{status:t.status}}resolveKeepaliveFromEvents(e){for(const n of e){var t;if(!0===(null===(t=n.options)||void 0===t?void 0:t.keepalive))return!0}return this.keepalive}produceBatchEndpoint(){return this.edgeDomain+"/unstable/produce_batch"}produceEndpoint(){return this.edgeDomain+st}};function _t(e){const t={"Content-Type":"application/json; charset=utf-8","X-Monorail-Edge-Event-Created-At-Ms":(e&&e.eventCreatedAtMs||Date.now()).toString(),"X-Monorail-Edge-Event-Sent-At-Ms":Date.now().toString(),"X-Monorail-Edge-Client-Message-Id":(e&&e.clientMessageId||ut()).toString()};return e&&e.userAgent&&(t["User-Agent"]=e.userAgent),e&&e.remoteIp&&(t["X-Forwarded-For"]=e.remoteIp),e&&e.deviceInstallId&&(t["X-Monorail-Edge-Device-Install-Id"]=e.deviceInstallId),e&&e.client&&(t["X-Monorail-Edge-Client"]=e.client),e&&e.clientOs&&(t["X-Monorail-Edge-Client-OS"]=e.clientOs),t}var bt=class e{static printWelcomeMessage(e){console.log(`%c👋 from Monorail%c\n\nWe've noticed that you're${e?"":" not"} running in debug mode. As such, we will ${e?"produce":"not produce"} Monorail events to the console. \n\nIf you want Monorail events to ${e?"stop":"start"} appearing here, %cset debugMode=${(!e).toString()}%c, for the Monorail Log Producer in your code.`,"font-size: large;","font-size: normal;","font-weight: bold;","font-weight: normal;")}constructor(t){this.sendToConsole=t,t&&e.printWelcomeMessage(t)}async produce(e){return this.sendToConsole&&console.log("Monorail event produced",e),new Promise((t=>{t(e)}))}produceBatch(e){return this.sendToConsole&&console.log("Monorail Batch event produced",e),new Promise((t=>{t(e)}))}},wt=class{constructor(e){this.version=e.version}},kt=class{constructor(e,t=()=>!1){if(tt(this,"eventsAwaitingConsent",[]),null==e||!e.provider)throw new Et("ConsentTrackingMiddleware requires an instance of ConsentTrackingProvider");this.isStrictlyNecessary=t,this.provider=e.provider}async do(e,t){if(at(e)){const n=await this.provider.annotateEvent(e);return this.isConsentGivenForEmission(n)?(await this.processBufferedEvents(t),t(n)):this.isStrictlyNecessary(n)?t(n):(this.eventsAwaitingConsent.push(e),Promise.resolve({status:0,message:"Consent not granted and event not marked strictly necessary, event not sent"}))}{if(this.isConsentGivenForEmission(await this.provider.annotateEvent(e.events[0]))){await this.processBufferedEvents(t);const n=await Promise.all(e.events.map((e=>this.provider.annotateEvent(e))));return t(rt(rt({},e),{},{events:n}))}const n=e.events.filter((e=>!!this.isStrictlyNecessary(e)||(this.eventsAwaitingConsent.push(e),!1)));if(n.length>0){const r=await Promise.all(n.map((e=>this.provider.annotateEvent(e))));return t(rt(rt({},e),{},{events:r}))}return Promise.resolve({status:0,message:"Consent not granted for any event, and no event marked strictly necessary, event batch not sent"})}}isConsentGivenForEmission(e){var t;const n=null===(t=e.metadata)||void 0===t?void 0:t.consent,r=this.provider.getRequiredConsentForEmission();return Boolean(Array.isArray(n)&&n.some((e=>r.includes(e))))}async processBufferedEvents(e){if(0===this.eventsAwaitingConsent.length)return;const t=this.eventsAwaitingConsent;this.eventsAwaitingConsent=[],await e({events:await Promise.all(t.map((e=>this.provider.annotateEvent(e))))})}},Et=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function Pt(e,t){var n,r,o;if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&void 0!==(null===(n=e.toString)||void 0===n?void 0:n.call(e))&&(null===(r=e.toString)||void 0===r?void 0:r.call(e))===(null===(o=t.toString)||void 0===o?void 0:o.call(t)))return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;let n,r;const o=Object.keys(e);if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;0!=r--;)if(!Pt(e[r],t[r]))return!1;return!0}if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(n=o.length,n!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,o[r]))return!1;for(r=n;0!=r--;){const n=o[r];if(!Pt(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}const St="",It="1",Ct="0",Mt="p",At="a",xt="m",Tt="t",Ot="m",jt="a",Bt="p",Dt="s",Nt=()=>"undefined"==typeof window;function Ut(e){try{return decodeURIComponent(e)}catch(e){return""}}function Lt(e){const t=function(){try{return document.cookie}catch(e){return!1}}()?document.cookie.split("; "):[];for(let n=0;nfunction(e=Ht){var t,n;const r=null===(t=performance)||void 0===t||null===(n=t.getEntriesByType)||void 0===n?void 0:n.call(t,"navigation");if(!r)return;const o=r.map((t=>function(e,t=Ht){var n,r;if(!e)return;return null===(n=e.serverTiming)||void 0===n||null===(r=n.find((e=>e.name==t)))||void 0===r?void 0:r.description}(t,e))).find((e=>e));o&&e===Ht&&function(e){if(!Nt()){try{e=decodeURIComponent(e)}catch(e){}try{sessionStorage.setItem(Rt,e)}catch(e){}}}(o);return o}(e))),!t){if(e!==Ht)return;let t;try{t=sessionStorage.getItem(Rt)}catch(e){}return t||void 0}try{t=decodeURIComponent(t)}catch(e){}return t}function Vt(){var e,t;if(!Nt()){var n,r;const o=(null===(n=window.Shopify)||void 0===n||null===(r=n.customerPrivacy)||void 0===r?void 0:r.injectedConsent)||(Nt()?{}:(null===(e=window.Shopify)||void 0===e||null===(t=e.customerPrivacy)||void 0===t?void 0:t.config)||{}).injectedConsent;return o?Ut(o):void 0}}function qt(){let e;if(e=Nt()?Vt():function(){var e,t;const n=null===(e=window.Shopify)||void 0===e||null===(t=e.customerPrivacy)||void 0===t?void 0:t.cachedConsent;return n?Ut(n):void 0}()||Vt()||new URLSearchParams(window.location.search).get("_cs")||void 0||Lt("_shopify_cmp")||$t(),void 0!==e)return function(e){if("%"==e.slice(0,1))try{e=decodeURIComponent(e)}catch(e){}const t=e.slice(0,1);if("{"==t)return function(e){var t;let n;try{n=JSON.parse(e)}catch(e){return}if("2.1"!==n.v)return;if(null===(t=n.con)||void 0===t||!t.CMP)return;return n}(e);if("3"==t)return function(e){const{base:t}=function(e){const t=e.replace(/#+$/,""),n=t.lastIndexOf("#");if(n<0)return{base:t};const r=t.slice(0,n),o=t.slice(n+1);return o.includes("}")?{base:t}:{base:r,comment:o}}(e);e=t;const n=e.slice(1).split("_"),[r,o,i,s,a]=n;let c,u;try{c=n[5]?JSON.parse(n.slice(5).join("_")):void 0}catch(e){}if(a){const e=a.replace(/\*/g,"/").replace(/-/g,"+"),t=atob(e);let n="";for(let e=0;ee.slice(0,t)+"-"+e.slice(t)),n)}function l(e){const t=r.split(".")[0];return t.includes(e.toLowerCase())?Ct:t.includes(e.toUpperCase())?It:St}function d(e){return r.includes(e.replace("t","s").toUpperCase())}return{v:"3",con:{CMP:{[jt]:l(jt),[Bt]:l(Bt),[Ot]:l(Ot),[Dt]:l(Dt)}},region:o||"",cus:c,purposes:{[At]:d(At),[Mt]:d(Mt),[xt]:d(xt),[Tt]:d(Tt)},sale_of_data_region:"t"==s,display_banner:"t"==i,consent_id:u}}(e)}(e)}function Ft(e){const t=function(){try{let e=qt();if(!e)return;return e}catch(e){return}}();if(!t||!t.purposes)return!0;const n=t.purposes[e];return"boolean"!=typeof n||n}function Kt(){const e=[];return Ft(At)&&e.push("analytics"),Ft(xt)&&e.push("marketing"),Ft(Tt)&&e.push("sale_of_data"),Ft(Mt)&&e.push("preferences"),e}var zt=class extends wt{async annotateEvent(e){return Promise.resolve(function(e,t){if("v1"===t){const n=Kt();return{...e,metadata:{...null==e?void 0:e.metadata,consent:n,consent_provider:"consent-tracking-api",consent_version:t}}}throw new Wt(t||"unknown")}(e,this.version))}getRequiredConsentForEmission(){if("v1"===this.version)return["analytics","marketing"];throw new Wt(this.version||"unknown")}},Wt=class e extends Error{constructor(t){super(`Version ${t} is not supported by the consent-tracking-api provider`),this.name="MonorailConsentTrackingApiProviderVersionError",Object.setPrototypeOf(this,e.prototype)}};function Jt(){var t;const n=null===(t=e.querySelector("script#shop-js-analytics"))||void 0===t?void 0:t.innerHTML;return n?JSON.parse(n):{}}async function Xt(){let e;return Promise.race([new Promise((t=>e=setTimeout((()=>t({})),1e4))),new Promise((e=>{var n,r;const o=(null===(n=t.ShopifyAnalytics)||void 0===n||null===(n=n.lib)||void 0===n?void 0:n.ready)||(null===(r=t.analytics)||void 0===r?void 0:r.ready);null==o||o((()=>{var n,r,o;const i=(null===(n=t.ShopifyAnalytics)||void 0===n||null===(n=n.lib)||void 0===n?void 0:n.trekkie)||(null===(r=t.analytics)||void 0===r?void 0:r.trekkie);e(null!==(o=null==i?void 0:i.defaultAttributes)&&void 0!==o?o:{})}))}))]).finally((()=>clearTimeout(e)))}async function Gt(...e){var n;if(!t.ShopifyAnalytics&&!t.analytics)return{};let r;Boolean(null===(n=t.trekkie)||void 0===n?void 0:n.ready)?r=Xt():(t.trekkie=t.trekkie||[],r=new Promise((e=>{t.trekkie.push(["ready",()=>{e(Xt())}])})));const o=await r;return e.reduce(((e,t)=>{const n=o[t];return void 0!==n&&(e[t]=n),e}),{})}const Zt="unspecified",Qt=function(){const e=new zt({version:"v1"});return[new kt({provider:e})]}(),Yt=["completed","emailsubmitted","namesubmitted","sheetmodalclosed","sheetmodalopened"],en=class e{static createLogProducer(t){return new e(new bt(t.debugMode),t.middleware||[])}static createHttpProducerWithEndpoint(t,n=[]){return new e(gt.withEndpoint(t),n)}static createHttpProducer(t){return new e(t.production?new gt(it,t.options):new gt(ot,t.options),t.middleware||[])}static buildMiddlewareChain(e,t=0){return t===e.length?this.identityFn:n=>e[t].do(n,this.buildMiddlewareChain(e,t+1))}constructor(t,n){this.producer=t,this.middleware=n,this.executeChain=e.buildMiddlewareChain(this.middleware.concat(new ct(t)))}produce(e){return e.metadata=rt({eventCreatedAtMs:Date.now(),clientMessageId:ut()},e.metadata),this.executeChain(e)}produceBatch(e){return this.executeChain(e)}}.createHttpProducer({production:!0,middleware:Qt});var tn=new WeakMap,nn=class{constructor({analyticsData:e,devMode:t=!1,notify:n,recordCounter:r}){var o;m(this,tn,void 0),this.featureInitializationEventAlreadyEmitted=!1,this.trackedPageImpressions=new Set,h(tn,this,{...e,flowVersion:null!==(o=e.flowVersion)&&void 0!==o?o:Zt}),this.devMode=t,this.notify=n,this.recordCounter=r,this.clearTrackedPageImpressions=this.clearTrackedPageImpressions.bind(this),this.produceMonorailEvent=this.produceMonorailEvent.bind(this),this.trackFeatureInitialization=this.trackFeatureInitialization.bind(this),this.trackModalStateChange=this.trackModalStateChange.bind(this),this.trackPageImpression=this.trackPageImpression.bind(this),this.trackUserAction=this.trackUserAction.bind(this),this.trackPostMessageTransmission=this.trackPostMessageTransmission.bind(this)}get analyticsData(){return f(tn,this)}set analyticsData(e){const t={...f(tn,this),...e};Pt(t,f(tn,this))||h(tn,this,t)}clearTrackedPageImpressions(){this.trackedPageImpressions.clear()}produceMonorailEvent({event:e,onError:t,trekkieAttributes:n}){this.devMode||(!n||Object.keys(n).length?(Object.assign(e.payload,n),en.produce(e).catch((e=>{if(null==t||t(e),function(e){var t,n,r,o,i,s,a;const c=e instanceof yt&&200===e.status;return!(e instanceof mt||e instanceof ht||(null==e||null===(t=e.message)||void 0===t?void 0:t.includes("Invalid agent:"))||(null==e||null===(n=e.message)||void 0===n?void 0:n.includes(".text is not a function"))||(null==e||null===(r=e.message)||void 0===r?void 0:r.includes("event_sent_at_ms metadata field cannot be empty"))||(null==e||null===(o=e.message)||void 0===o?void 0:o.includes("event_created_at_ms metadata field cannot be empty."))||(null==e||null===(i=e.message)||void 0===i?void 0:i.match(/Cannot read properties of (null|undefined) \(reading 'status'\)/))||(null==e||null===(s=e.message)||void 0===s?void 0:s.match(/(null|undefined) is not an object \(evaluating '[a-zA-Z]+\.status'\)/))||(null==e||null===(a=e.message)||void 0===a?void 0:a.match(/[a-zA-Z]+ is (null|undefined)/))||c)}(e)){var n;const t=e instanceof Error?e:new ve(String(e),"MonorailProducerError");if(null===(n=this.notify)||void 0===n||n.call(this,t),this.recordCounter){const e=y(t);this.recordCounter("shop_js_monorail_producer_error",{attributes:{error:e}})}}}))):null==t||t({message:"trekkie attributes are empty"}))}async trackFeatureInitialization(){var e,n,r;const{analyticsTraceId:o,apiKey:i,checkoutToken:s,flow:a,flowVersion:c=Zt,shopId:u,source:l="unspecified",uxMode:d}=this.analyticsData;if(!a)return;var p;this.featureInitializationEventAlreadyEmitted&&(null===(p=this.notify)||void 0===p||p.call(this,new ve(`Feature Initialize Event already emitted once for the feature ${a}`,"MonorailLogicError",o)));const h=Jt(),f=null!==(e=null==h?void 0:h.pageType)&&void 0!==e?e:"",v={...i&&{apiKey:i},...s&&{checkoutToken:s},...u&&{shopId:u},...await Gt("customerId","isPersistentCookie","path","uniqToken","visitToken"),analyticsTraceId:o,flow:a,flowVersion:c,sdkVersion:"1.1.1-beta",shopPermanentDomain:null!==(n=null===(r=t.Shopify)||void 0===r?void 0:r.shop)&&void 0!==n?n:"",source:l,storefrontPageType:f,uxMode:d};this.featureInitializationEventAlreadyEmitted=!0,this.produceMonorailEvent({event:{schemaId:"shopify_pay_login_with_shop_sdk_feature_initialize/1.2",payload:v}})}trackModalStateChange({currentState:e,dismissMethod:n,reason:r}){var o;const{analyticsTraceId:i,checkoutToken:s,flow:a,flowVersion:c="unspecified"}=this.analyticsData;a&&(this.produceMonorailEvent({event:{schemaId:"shop_identity_modal_state_change/1.4",payload:{analyticsTraceId:i,checkoutToken:s,currentState:e,dismissMethod:n,flow:a,flowVersion:c,previousState:this.previousModalState,reason:r,zoom:`${null===(o=t.visualViewport)||void 0===o?void 0:o.scale}`}}}),this.previousModalState=e)}async trackPageImpression({allowDuplicates:e=!1,analyticsTraceId:n=this.analyticsData.analyticsTraceId,flow:r=this.analyticsData.flow,page:o,shopAccountUuid:i}){var s,a,c;if(!e&&this.trackedPageImpressions.has(o))return;const{apiKey:u,checkoutToken:l,flowVersion:d=Zt}=this.analyticsData;if(!r)return;this.trackedPageImpressions.add(o);const p=Jt(),h=null!==(s=null==p?void 0:p.pageType)&&void 0!==s?s:"",f=await Gt("customerId","isPersistentCookie","path","uniqToken","visitToken"),v={...u&&{apiKey:u},...l&&{checkoutToken:l},...i&&{shopAccountUuid:i},...f,analyticsTraceId:n,flow:r,flowVersion:d,pageName:o,sdkVersion:"1.1.1-beta",shopPermanentDomain:null!==(a=null===(c=t.Shopify)||void 0===c?void 0:c.shop)&&void 0!==a?a:"",storefrontPageType:h};this.produceMonorailEvent({event:{payload:v,schemaId:"shopify_pay_login_with_shop_sdk_page_impressions/3.3"},onError:()=>{this.trackedPageImpressions.delete(o)},trekkieAttributes:f})}trackUserAction({userAction:e}){var n,r;const{analyticsTraceId:o,apiKey:i,checkoutToken:s,checkoutVersion:a,flow:c,flowVersion:u=Zt,shopId:l}=this.analyticsData;if(!c)return;const d={...i&&{apiKey:i},...s&&{checkoutToken:s},...a&&{checkoutVersion:a},...l&&{shopId:l},analyticsTraceId:o,flow:c,flowVersion:u,sdkVersion:"1.1.1-beta",shopPermanentDomain:null!==(n=null===(r=t.Shopify)||void 0===r?void 0:r.shop)&&void 0!==n?n:"",userAction:e};this.produceMonorailEvent({event:{schemaId:"shopify_pay_login_with_shop_sdk_user_actions/2.2",payload:d}})}trackPostMessageTransmission({direction:e,event:t}){var n;const r=t.type;if(!Yt.includes(r))return;const o=Date.now(),i=t.messageId,{analyticsTraceId:s,checkoutToken:a,shopPermanentDomain:c}=this.analyticsData,u=function(e){return"email"in e}(t)?t.email:void 0,l={eventType:r,direction:e,actor:"shop-js"};null===(n=this.recordCounter)||void 0===n||n.call(this,"shop_js_post_message_transmission",{attributes:l}),this.produceMonorailEvent({event:{schemaId:"shop_identity_post_message_transmission/1.0",payload:{messageId:i,messageDirection:e,actor:"shop-js",payloadType:r,clientTimestampMs:o,analyticsTraceId:s,checkoutToken:a,shopifyDomain:c,email:u}}})}};function rn(e){if(!e)return!1;try{return fe(e)&&4===function(e){if(!fe(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}(e)}catch(e){return!1}}const on=({analyticsContext:e="loginWithShop",analyticsTraceId:n,apiKey:r,checkoutVersion:o,checkoutToken:i,children:s,flow:a,flowVersion:c,shopId:u=0,shopPermanentDomain:l,source:d,uxMode:p})=>{const{notify:h}=$e(),{recordCounter:f}=Ze(),{devMode:v,element:m,featureName:y,instanceId:g}=Q(),_=R((()=>{const e=(r="analytics_trace_id",new URLSearchParams(t.location.search).get(r));var r;return rn(e)?e:("ShopPayPaymentRequestButton"===y||"ShopPayPaymentRequestLogin"===y)&&n||g}),[y,g,n]);U((()=>{if(m)return function(e,t){Object.defineProperty(e,Ye,{configurable:!0,value:Object.freeze({...t})})}(m,{analyticsTraceId:_}),()=>{!function(e){delete e[Ye]}(m)}}),[_,m]);const b=L({analyticsContext:e,analyticsTraceId:_,apiKey:r,checkoutVersion:o,checkoutToken:i,flow:a,flowVersion:c,shopId:u,shopPermanentDomain:l,source:d,uxMode:p}),w=R((()=>new nn({analyticsData:b.current,devMode:v,notify:h,recordCounter:f})),[v,h,f]);w.analyticsData={...b.current,analyticsTraceId:_,analyticsContext:e,apiKey:r,checkoutVersion:o,checkoutToken:i,flow:a,flowVersion:c,shopId:u,shopPermanentDomain:l,source:d,uxMode:p},N((()=>()=>{w.clearTrackedPageImpressions()}),[w]);const k=qe((()=>{w.trackFeatureInitialization()}),100);N((()=>{k()}),[k]);const E=R((()=>({analyticsData:w.analyticsData,getTrekkieAttributes:Gt,produceMonorailEvent:w.produceMonorailEvent,trackModalStateChange:w.trackModalStateChange,trackPageImpression:w.trackPageImpression,trackUserAction:w.trackUserAction,trackPostMessageTransmission:w.trackPostMessageTransmission})),[w.analyticsData,w.produceMonorailEvent,w.trackModalStateChange,w.trackPageImpression,w.trackUserAction,w.trackPostMessageTransmission]);return He(Qe.Provider,{value:E,children:s})},sn="shop_js_csp_violation",an=["pay.shopify.com","monorail-edge.shopifysvc.com",new URL(_).hostname],cn="cdn.shopify.com",un="/shopifycloud/shop-js/",ln=Symbol.for("shopify.shop-js.csp-violation-listener");function dn({entrypoint:n}){const r=e;if(!r[ln]){r[ln]=!0;try{e.addEventListener("securitypolicyviolation",function({entrypoint:e,logSampleRate:n=.1,telemetry:r}){const o=new Set;return i=>{try{var s;const a=i.effectiveDirective||i.violatedDirective,c=function(e){let t;try{t=new URL(e)}catch(e){return}const{hostname:n,pathname:r,search:o}=t;return n===cn?"/"===r&&""===o||r.startsWith(un)?n:void 0:"shop.app"===n||n.endsWith(".shop.app")||"shop.com"===n||n.endsWith(".shop.com")||an.includes(n)?n:void 0}(i.blockedURI);if(!c)return;const u={blockedHost:c,directive:a,entrypoint:e},{disposition:l}=i,d=JSON.stringify({...u,disposition:l});if(o.has(d))return;if(o.add(d),"report"!==l&&r.counter({name:sn,value:1,attributes:u}),Math.random()>=n)return;r.log({body:sn,attributes:{...u,disposition:l,merchantHost:null===(s=t.location)||void 0===s?void 0:s.hostname}})}catch(e){}}}({entrypoint:n,telemetry:new Me({exporter:v()})}))}catch(e){}}}function pn({children:e}){const{featureName:t}=Q(),n=R((()=>new Me({exporter:v()})),[]);N((()=>{dn({entrypoint:"components"})}),[]);const r=$((({body:e,attributes:r})=>{n.log({body:e,attributes:{beta:!0,feature:t,...r}})}),[n,t]),o=$(((e,r={})=>{const{attributes:o,unit:i,value:s=1}=r;n.counter({attributes:{beta:!0,feature:t,...o},name:e,value:s,unit:i})}),[n,t]),i=$(((e,r={})=>{const{attributes:o,unit:i,value:s=1}=r;n.gauge({attributes:{beta:!0,feature:t,...o},name:e,value:s,unit:i})}),[n,t]),s=$(((e,r={})=>{const{attributes:o,unit:i,value:s=1,bounds:a}=r;n.histogram({attributes:{beta:!0,feature:t,...o},bounds:a,name:e,value:s,unit:i})}),[n,t]),a=R((()=>({client:n,log:r,recordCounter:o,recordGauge:i,recordHistogram:s})),[n,r,o,i,s]);return He(Ge.Provider,{value:a,children:e})}function hn({children:e,monorailProps:t}){return He(Re,{children:He(Ve,{children:He(pn,{children:He(on,{...t,children:e})})})})}const fn=({children:e,devMode:t=!1,element:n,featureName:r})=>{const o=R((()=>l()),[]),i=R((()=>performance.now()),[]);N((()=>{n&&n.setAttribute("data-instance-id",o)}),[n,o]);const s=R((()=>({createdAt:i,devMode:t,element:n,featureName:r,instanceId:o})),[i,t,n,r,o]);return He(Z.Provider,{value:s,children:e})},vn=t.HTMLElement,mn=e=>{const n=t.HTMLElement;t.HTMLElement=vn;const r=e();return t.HTMLElement=n,r},yn=t=>mn((()=>e.createElement(t))),gn={boolean:{stringify:e=>""===e?"true":e?/^[ty1-9]/i.test(e).toString():"false",parse:(e,t,n)=>""===e||(e?/^[ty1-9]/i.test(e):n.hasAttribute(t)&&null===e)},function:{stringify:e=>"function"==typeof e?e.name.replace("bound ",""):"string"==typeof e?e.replace("bound ",""):e,parse:(e,t,n)=>{if(!e)return null;const r="undefined"!=typeof window?window[e]:"undefined"!=typeof global?global[e]:void 0;return"function"==typeof r?r.bind(n):void 0}},number:{stringify:e=>`${e}`,parse:e=>{if(e)return parseFloat(e)}},string:{stringify:e=>e,parse:e=>{if(e)return e}}};function _n(e,{getters:t,methods:o,name:a,props:c,shadow:u,singleton:l}){var d,p;if("undefined"==typeof window)return;const{notify:h}=new Ne(a);function f(){const t=(e=>mn((()=>Reflect.construct(HTMLElement,[],e))))(f);return t._eventListenerReadyPromise=new Promise((e=>{t._eventListenerReadyPromiseResolve=e})),t._vdomComponent=e,t._root=u?t.attachShadow({mode:u}):t,t}const v=new Map;Object.entries(c||{}).forEach((([e,t])=>{const n=i(e);v.set(n,{attribute:n,preactProp:e,type:t})}));const m=Array.from(v.values()).map((({attribute:e})=>e));function y(e){this.getChildContext=()=>e.context;const{context:t,children:n,...r}=e;return s(n,r)}function g(e){return n("slot",{...e})}function _(e,t){if(3===e.nodeType)return e.data;if(1!==e.nodeType)return null;const r={},o=[],{childNodes:i}=e;v.forEach((({attribute:t,preactProp:n,type:o})=>{const i=gn[o],s=e.getAttribute(t);let a=s;("boolean"===o||s)&&(a=i.parse(s,t,e)),null!==a&&(r[t]=a,r[n]=a)}));for(const e of i){const t=_(e,null);o.push(t)}const s=t?n(g,null,o):o;return n(t,r,s)}return f.prototype=Object.create(HTMLElement.prototype),f.prototype.constructor=f,f.observedAttributes=m,f.prototype.attributeChangedCallback=function(e,t,n){if(!this._vdom)return;const o=v.get(e);if(!o)return;const{preactProp:i,type:a}=o,c=gn[a],u={};if(n||"boolean"!==a){if(a&&n){const t=c.parse(n,e,this);u[e]=t,u[i]=t}}else{const t=c.parse(n,e,this);u[e]=t,u[i]=t}this._vdom=s(this._vdom,u),r(this._vdom,this._root)},f.prototype.connectedCallback=function(){if(l&&document.querySelectorAll(a).length>1)return void this.remove();const e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e);const t=e.detail.context;this._vdom=n(y,{...this._props,context:t,element:this},_(this,this._vdomComponent)),r(this._vdom,this._root)},null==o||o.forEach((e=>{f.prototype[e]=function(t){this._eventListenerReadyPromise.then((()=>{this.dispatchEvent(new CustomEvent(e,{detail:t}))})).catch((()=>{h(new ve(`Custom element ${a}: Error listening for methods`,"CustomElementMethodListenerError"))}))}})),Object.entries(t||{}).forEach((([e,t])=>{e in HTMLElement.prototype||e in f.prototype?h(new ve(`Custom element ${a}: getter "${e}" collides with an existing property`,"CustomElementGetterCollisionError")):Object.defineProperty(f.prototype,e,{get:t,configurable:!0,enumerable:!0})})),f.prototype.disconnectedCallback=function(){r(this._vdom=null,this._root)},v.forEach((({attribute:e,preactProp:t,type:n})=>{const o=gn[n];Object.defineProperty(f.prototype,e,{get(){return this._vdom&&this._vdom.props?this._vdom.props[e]:null},set(t){let r=t;this._vdom?this.attributeChangedCallback(e,null,t):(("boolean"===n||t)&&(r=o.parse(t,e,this)),this._props||(this._props={}),this._props[e]=r,this.connectedCallback()),this.setAttribute(e,o.stringify(r))}}),"function"===n&&t!==e&&Object.defineProperty(f.prototype,t,{get(){return this._vdom&&this._vdom.props?this._vdom.props[t]:null},set(n){if("function"!=typeof n&&null!==n)return;const o={};o[e]=n,o[t]=n,this._vdom?(this._vdom=s(this._vdom,o),r(this._vdom,this._root)):(this._props||(this._props={}),this._props[e]=n,this._props[t]=n)},configurable:!0,enumerable:!0})})),customElements.get(a)?void 0:(null===(d=(p=Reflect).defineProperty)||void 0===d||d.call(p,f,"componentVersion",{value:"preact"}),((e,t)=>{mn((()=>{customElements.define(e,t)}))})(a,f))}export{V as A,H as C,q as D,B as E,D as O,L as S,U as T,He as _,nn as a,ve as b,et as c,We as d,ze as f,$e as g,qe as h,hn as i,N as j,$ as k,Qe as l,Ke as m,yn as n,Gt as o,Fe as p,fn as r,Pt as s,_n as t,Ze as u,Ne as v,R as w,Q as x,Me as y}; //# sourceMappingURL=chunk.register_Cnn1s0Rw.esm.js.map