import.meta;var Fa=Object.defineProperty,Ua=Object.defineProperties,$a=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,xr=Object.prototype.hasOwnProperty,Mr=Object.prototype.propertyIsEnumerable,zt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Fr=t=>{throw TypeError(t)},qt=(t,e,n)=>e in t?Fa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,_=(t,e)=>{for(var n in e||(e={}))xr.call(e,n)&&qt(t,n,e[n]);if(mt)for(var n of mt(e))Mr.call(e,n)&&qt(t,n,e[n]);return t},T=(t,e)=>Ua(t,$a(e)),Ur=(t,e)=>{var n={};for(var r in t)xr.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&mt)for(var r of mt(t))e.indexOf(r)<0&&Mr.call(t,r)&&(n[r]=t[r]);return n},d=(t,e,n)=>qt(t,typeof e!="symbol"?e+"":e,n),$r=(t,e,n)=>e.has(t)||Fr("Cannot "+n),C=(t,e,n)=>($r(t,e,"read from private field"),n?n.call(t):e.get(t)),x=(t,e,n)=>e.has(t)?Fr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),L=(t,e,n,r)=>($r(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),Z=function(t,e){this[0]=t,this[1]=e},Ne=(t,e,n)=>{var r=(o,s,l,c)=>{try{var u=n[o](s),h=(s=u.value)instanceof Z,p=u.done;Promise.resolve(h?s[0]:s).then(y=>h?r(o==="return"?o:"next",s[1]?{done:y.done,value:y.value}:y,l,c):l({value:y,done:p})).catch(y=>r("throw",y,l,c))}catch(y){c(y)}},a=o=>i[o]=s=>new Promise((l,c)=>r(o,s,l,c)),i={};return n=n.apply(t,e),i[zt("asyncIterator")]=()=>i,a("next"),a("throw"),a("return"),i},ee=(t,e,n)=>(e=t[zt("asyncIterator")])?e.call(t):(t=t[zt("iterator")](),e={},n=(r,a)=>(a=t[r])&&(e[r]=i=>new Promise((o,s,l)=>(i=a.call(t,i),l=i.done,Promise.resolve(i.value).then(c=>o({value:c,done:l}),s)))),n("next"),n("return"),e);const Ba=":host{display:flex;align-items:center;justify-content:center}";class Ha extends HTMLElement{constructor(){var e,n;super(),d(this,"size"),d(this,"color"),this.size=(e=this.getAttribute("size"))!=null?e:"18px",this.color=(n=this.getAttribute("color"))!=null?n:"gray",this.attachShadow({mode:"open"})}connectedCallback(){this.render();const e=document.createElement("style");e.textContent=Ba,this.shadowRoot.appendChild(e)}render(){const e=this.shadowRoot,n='\n width="'.concat(this.size,'"\n height="').concat(this.size,'"\n xmlns="http://www.w3.org/2000/svg"\n aria-hidden="true"\n ');e.innerHTML="\n \n \n \n ')}}const Ga="#overlay{position:fixed;width:100%;height:100%;background:#0006;top:0;left:0;z-index:2147483647;animation:modalPop .3s ease-out}#modal{position:fixed;top:20%;left:50%;width:100%;max-width:383px;transform:translate(-50%,-100%);background:#fff;color:#000;border-radius:5px;animation:modalSlideInFromTop .3s forwards}@keyframes modalPop{0%{opacity:0}to{opacity:1}}@keyframes modalSlideInFromTop{0%{transform:translate(-50%,-100%)}to{transform:translate(-50%)}}@keyframes modalSlideInFromBottom{0%{transform:translate(-50%,100%)}to{transform:translate(-50%)}}@media only screen and (max-width: 640px){#modal{top:auto;bottom:0;animation:modalSlideInFromBottom .3s forwards}}#modal footer{padding:0 21px 21px}#modal header{display:flex;justify-content:space-between;padding:21px 21px 16px}#title{font-size:21px;font-weight:600;line-height:25.2px;margin:0}.capitalize:first-letter{display:inline-block;text-transform:capitalize}#content{text-align:left;padding:0 21px 16px;overflow:auto;max-height:50vh}#modal #content p{margin:0;font-size:14px;line-height:21px}#close-icon,#close-button{cursor:pointer}#close-icon{min-width:24px;background:transparent;padding:0;border:none}#close-button{width:100%;padding:16px 21px;color:#fff;background-color:#1773b0;border:none;border-radius:5px;font-size:14px;line-height:21px;font-family:inherit}#close-button:hover,#close-button:active{background:#136f99}#close-button:active,#close-button:focus{box-shadow:0 0 0 4px #1990c640}";function Va(t){return _n(t).map(e=>e instanceof Error?e:new En("[".concat(typeof e,"] ").concat(za(e).slice(0,10240))))}function _n(t,e=0){return e>=20?[t,"Truncated cause stack"]:t instanceof Error&&"cause"in t?[t,..._n(t.cause,e+1)]:[t]}function za(t){var e;if(typeof t!="string")try{return(e=JSON.stringify(t))!=null?e:typeof t}catch(n){}return"".concat(t)}var En=class extends Error{constructor(){super(...arguments),d(this,"name","BugsnagInvalidError")}},An=/^\s*at .*(\S+:\d+|\(native\))/m,qa=/^(eval@)?(\[native code])?$/;function ja(t){return t.stack?t.stack.match(An)?Ya(t):Wa(t):[]}function Cn(t){if(t.indexOf(":")===-1)return[t];let e=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(t.replace(/[()]/g,""));return[e[1],e[2]?Number(e[2]):void 0,e[3]?Number(e[3]):void 0]}function Ya(t){return t.stack.split("\n").filter(e=>!!e.match(An)).map(e=>{let n=e.replace(/^\s+/,"").replace(/^.*?\s+/,""),r=n.match(/ (\(.+\)$)/);n=r?n.replace(r[0],""):n;let a=Cn(r?r[1]:n),i=r&&n||void 0,o=["eval",""].indexOf(a[0])>-1?void 0:a[0];return{method:i,file:o,lineNumber:a[1],columnNumber:a[2]}})}function Wa(t){return t.stack.split("\n").filter(e=>!e.match(qa)).map(e=>{if(e.indexOf("@")===-1&&e.indexOf(":")===-1)return{method:e};let n=/((.*".+"[^@]*)?[^@]*)(?:@)/,r=e.match(n),a=r&&r[1]?r[1]:void 0,i=Cn(e.replace(n,""));return{method:a,file:i[0],lineNumber:i[1],columnNumber:i[2]}})}var Br="5",Ka=class{constructor(t){d(this,"breadcrumbs",[]),d(this,"apiKey"),d(this,"plugins"),d(this,"appId"),d(this,"appType"),d(this,"appVersion"),d(this,"releaseStage"),d(this,"locale"),d(this,"userAgent"),d(this,"metadata"),d(this,"persistedMetadata"),d(this,"onError"),d(this,"onPostErrorListeners",[]),d(this,"endpoints");var e,n;this.apiKey=t.apiKey,this.appType=t.appType,this.appId=t.appId,this.appVersion=t.appVersion,this.releaseStage=t.releaseStage,this.locale=t.locale,this.userAgent=t.userAgent,this.metadata=t.metadata,this.onError=t.onError,this.persistedMetadata={},this.endpoints=(e=t.endpoints)!=null?e:{notify:"https://notify.bugsnag.com/",sessions:"https://sessions.bugsnag.com"},this.plugins=(n=t.plugins)!=null?n:[],this.plugins.forEach(r=>r.load(this)),this.leaveBreadcrumb("Bugsnag started",void 0,"state")}addMetadata(t){for(let e of Object.keys(t))this.persistedMetadata[e]=t[e]}leaveBreadcrumb(t,e,n="manual"){this.breadcrumbs.push({name:t,metaData:e,type:n,timestamp:new Date().toISOString()})}notify(t,{errorClass:e,severity:n,severityType:r,handled:a=!0,metadata:i,context:o,groupingHash:s}={}){var l,c;let u=Va(t),h=_(_(_({},this.metadata),this.persistedMetadata),i),p=this.buildBugsnagEvent(u,{errorClass:e,severityType:r,handled:a,severity:n,metadata:h,context:o,groupingHash:s});if(((c=(l=this.onError)==null?void 0:l.call(this,p,t))==null||c)&&this.releaseStage!=="development"){let y=this.sendToBugsnag(p);return this.onPostErrorListeners.forEach(E=>E(p)),y}return Promise.resolve()}addOnPostError(t){this.onPostErrorListeners.push(t)}buildBugsnagEvent(t,{errorClass:e,severity:n="error",severityType:r="handledException",handled:a,metadata:i={},context:o,groupingHash:s}){let l=new Date().toISOString(),{breadcrumbs:c,appId:u,appType:h,appVersion:p,releaseStage:y,locale:E,userAgent:f}=this,A=t.map((I,O)=>({errorClass:O===0&&e!=null?e:I.name,stacktrace:Sn(u,I),message:I.message}));return{payloadVersion:Br,exceptions:A,severity:n,severityReason:{type:r},unhandled:!a,app:{id:u,type:h,version:p,releaseStage:y},device:{time:l,locale:E,userAgent:f},breadcrumbs:c,context:o,metaData:i,groupingHash:s}}async sendToBugsnag(t){let{apiKey:e}=this,n={apiKey:e,notifier:{name:"Bugsnag JavaScript",version:"7.22.2",url:"https://github.com/bugsnag/bugsnag-js"},events:[t]};try{await fetch(this.endpoints.notify,{method:"POST",headers:{"Content-Type":"application/json","Bugsnag-Api-Key":e,"Bugsnag-Payload-Version":Br,"Bugsnag-Sent-At":t.device.time},body:JSON.stringify(n)})}catch(r){console.warn("[bugsnag-light] failed to send an event"),console.warn(r)}}};function Sn(t,e){let n=ja(e).map(r=>{var a,i,o,s;let l=(a=r.file)==null?void 0:a.includes(t);return{method:(i=r.method)!=null?i:"",file:(o=r.file)!=null?o:"",lineNumber:(s=r.lineNumber)!=null?s:0,columnNumber:r.columnNumber,inProject:l}});if(e instanceof En){let r=n.findIndex(a=>a.method.endsWith("notify"));r>-1&&(n=n.slice(r+1))}return n}var Qa=class ou extends Error{constructor(e){super(e),d(this,"reason"),this.name="BreadcrumbsPluginFetchError",Object.setPrototypeOf(this,ou.prototype)}};function Xa(t){let e=window.onerror;window.onerror=(n,r,a,i,o)=>{o&&t.notify(o,{severityType:"unhandledException",handled:!1}),typeof e=="function"&&e.apply(window.onerror,[n,r,a,i,o])}}function Ja(t){window.addEventListener("unhandledrejection",e=>{e.reason&&!(e.reason instanceof Qa)&&t.notify(e.reason,{severityType:"unhandledPromiseRejection",handled:!1})})}function at(t){try{const e=new RegExp("(^| )".concat(t,"=([^;]+)")).exec(document.cookie);if(e){const n=e[2];try{return decodeURIComponent(n)}catch(r){return n}}return null}catch(e){return null}}const nr={BRANDED_BUTTON:"shopify-payment-button__button shopify-payment-button__button--branded",UNBRANDED_BUTTON:"shopify-payment-button__button shopify-payment-button__button--unbranded",MORE_PAYMENT_OPTION_BUTTON:"shopify-payment-button__more-options"},Za={DARK:"apple-pay--dark",LIGHT:"apple-pay--light"},ei=44,ti="_shopify_y",Pn=6,ri="discount_code",mr="https://static-na.payments-amazon.com",yr="".concat(mr,"/checkout.js"),Dn="https://www.paypal.com",vn="https://pay.google.com",je={CURRENCY_CHANGE:"wallet_currency_change",CAPTCHA_REQUIRED:"wallet_captcha_required",NOT_ENOUGH_STOCK:"wallet_not_enough_stock",CART_NOT_READY:"wallet_cart_not_ready",DYNAMIC_TAX:"wallet_dynamic_tax"},Et="VALIDATION_CUSTOM",Rn="portable-wallets",Pe={BUTTON:"accelerated-checkout-button",CONTAINER:"accelerated-checkout-button-container"},Nn="unknown",Tn={name:"buy_it_now",wallet_params:{}};function kn(t){try{return!t.toString().includes("[native code]")}catch(e){return!0}}const jt=new Map,ni={checkDuplicate({errorClass:t,message:e}){if(jt.has(t)){const n=jt.get(t);if(n.has(e))return!0;n.add(e)}else jt.set(t,new Set([e]));return!1},reset(){}},ut="DeveloperError";class gr extends Error{constructor({code:e,message:n}){const r="An unexpected error happened likely because of customizations made to HTML/JavaScript on this site ".concat(n);super("[".concat(e,"]: ").concat(r)),d(this,"name",ut),d(this,"code","unknown"),this.code=e}}const fr="SilencedError";class Tt extends Error{constructor(){super(...arguments),d(this,"name",fr)}}class ai extends Error{constructor(){super(...arguments),d(this,"name","MissingConfigError")}}function v(t,e){if(!{}.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}var ii=0;function ue(t){return"__private_"+ii+++"_"+t}function kt(t){return Object.entries(t).map(([e,n])=>({key:e,value:{stringValue:String(n)}}))}function oi(t){return Object.entries(t).map(([e,n])=>({key:e,value:Ln(n)}))}function Ln(t){if(Array.isArray(t))return{arrayValue:{values:t.map(e=>Ln(e))}};switch(typeof t){case"boolean":return{boolValue:!!t};case"number":return{doubleValue:Number(t)};case"string":default:return{stringValue:String(t)}}}const br=1,si=li(5,2,12);function li(t,e,n){const r=[0];for(let a=0;a{switch(r.attributes=_(_({},v(this,Q)[Q]),r.attributes),r.type){case"histogram":di(e,r);break;case"exponential_histogram":ui(e,r);break;case"counter":hi(e,r);break;case"gauge":pi(e,r);break}});const n=Object.values(e);n.length!==0&&(v(this,z)[z]=[],await v(this,ye)[ye].exportMetrics(n))}async exportLogs(){const e=v(this,ge)[ge].map(n=>{const r={timeUnixNano:n.timeUnixNano,observedTimeUnixNano:n.timeUnixNano,attributes:oi(_(_({},v(this,Q)[Q]),n.attributes))};return n.body&&(r.body={stringValue:n.body}),r});e.length!==0&&(v(this,ge)[ge]=[],await v(this,ye)[ye].exportLogs(e))}}function di(t,e){var n;const{name:r,value:a,unit:i,timeUnixNano:o,attributes:s}=e,l=(n=e.bounds)!==null&&n!==void 0?n:si,c=new Array(l.length+1).fill(0);t[r]||(t[r]={name:r,unit:i||"1",histogram:{aggregationTemporality:br,dataPoints:[]}});for(let u=0;u0?h:0,bucketCounts:r>0?[1]:[]};t[n].exponentialHistogram.dataPoints.push({attributes:kt(o!=null?o:{}),startTimeUnixNano:i,timeUnixNano:i,count:1,sum:l,scale:c,zeroCount:p,positive:E,negative:y,min:l,max:l,zeroThreshold:0})}function hi(t,e){const{name:n,value:r,unit:a,timeUnixNano:i,attributes:o}=e;t[n]||(t[n]={name:n,unit:a||"1",sum:{aggregationTemporality:br,isMonotonic:!0,dataPoints:[]}}),t[n].sum.dataPoints.push({startTimeUnixNano:i,timeUnixNano:i,asDouble:r,attributes:kt(o!=null?o:{})})}function pi(t,e){const{name:n,value:r,unit:a,timeUnixNano:i,attributes:o}=e;t[n]||(t[n]={name:n,unit:a||"1",gauge:{dataPoints:[]}}),t[n].gauge.dataPoints.push({startTimeUnixNano:i,timeUnixNano:i,asDouble:r,attributes:kt(o!=null?o:{})})}var Ye=ue("url"),fe=ue("serviceName"),We=ue("logger"),Ke=ue("fetchFn");class mi{constructor(e,n,r){Object.defineProperty(this,Ye,{writable:!0,value:void 0}),Object.defineProperty(this,fe,{writable:!0,value:void 0}),Object.defineProperty(this,We,{writable:!0,value:void 0}),Object.defineProperty(this,Ke,{writable:!0,value:void 0}),v(this,Ye)[Ye]=e.replace(/\/v1\/(logs|metrics|traces)\/?$/,""),v(this,fe)[fe]=n,v(this,We)[We]=r==null?void 0:r.logger,v(this,Ke)[Ke]=r==null?void 0:r.fetchFn}async exportMetrics(e){const n={resourceMetrics:[{resource:{attributes:[{key:"service.name",value:{stringValue:v(this,fe)[fe]}}]},scopeMetrics:[{scope:{name:"open-telemetry-mini-client",version:"1.1.0",attributes:[]},metrics:e}]}]};await this.exportTo(n,"/v1/metrics")}async exportLogs(e){const n={resourceLogs:[{resource:{attributes:[{key:"service.name",value:{stringValue:v(this,fe)[fe]}}]},scopeLogs:[{scope:{name:"open-telemetry-mini-client",version:"1.1.0",attributes:[]},logRecords:e}]}]};await this.exportTo(n,"/v1/logs")}async exportTo(e,n){var r;const a=await this.exporterFetch()("".concat(v(this,Ye)[Ye]).concat(n),{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if((r=v(this,We)[We])===null||r===void 0||r.log({status:a.status}),!a.ok){if(a.status===400){const i=await a.text();throw new tt("Invalid OpenTelemetry Data: ".concat(i))}if(a.status===429||a.status===503){const i=await a.text(),o=a.headers.get("Retry-After"),s=o?{seconds:Number(o)}:void 0;throw new tt("Server did not accept data",{errorData:i,retryAfter:s,body:e})}throw new tt("Server responded with ".concat(a.status))}}exporterFetch(){return v(this,Ke)[Ke]||fetch}}class tt extends Error{constructor(e,n){super(e),this.metadata=void 0,this.name="OpenTelemetryClientError",this.metadata=n}}const yi="https://otlp-http-production.shopifysvc.com",gi="portable_wallets";var Me;class fi{constructor(e){x(this,Me),L(this,Me,e)}async exportMetrics(e){var n;try{await C(this,Me).exportMetrics(e)}catch(r){if(r instanceof tt){const a=(n=r.metadata)==null?void 0:n.retryAfter;if(a){await new Promise(i=>{setTimeout(()=>{this.exportMetrics(e),i()},a.seconds*1e3)});return}}throw new Hr("Unable to export metrics",{cause:r})}}async exportLogs(e){var n;try{await C(this,Me).exportLogs(e)}catch(r){if(r instanceof tt){const a=(n=r.metadata)==null?void 0:n.retryAfter;if(a){await new Promise(i=>{setTimeout(()=>{this.exportLogs(e),i()},a.seconds*1e3)});return}}throw new Hr("Unable to export logs",{cause:r})}}}Me=new WeakMap;const bi=new mi(yi,gi),wi=new fi(bi),P=new ci({exporter:wi}),On="TelemetryExportError";class Hr extends Error{constructor(){super(...arguments),d(this,"name",On)}}const _i=["Load failed","Failed to fetch","when attempting to fetch resource","GraphQL mutation failed with status 404","Component closed",ut,fr],Gr=new Map([["TypeError","Illegal constructor"],["BugsnagInvalidError",'"isTrusted":true']]),Ei=[fr,On,"OpenTelemetryClientError"],Ai=["Chrome-Lighthouse"];function Ci(t){const e=t.exceptions[0];return Si()?"silenced-user-agent":Ii(t)?"empty-stack-trace":Pi(e)?"spin":Di()?"monkey-patch":Ni(t)?"external-error":Ti(t)?"unactionable-fetch-issue":Li(t)?"developer-error":ki(e.message)?"discarded-message":Oi(t)?"discarded-error-class":xi(e)?"discarded-class-message":Mi(t)?"unactionable-invalid-error":vi(t)||null}function Si(){return Ai.some(t=>navigator.userAgent.includes(t))}function Ii(t){return t.exceptions[0].stacktrace.length===0}function Pi(t){return t.stacktrace.some(e=>{var n;return(n=e.file)==null?void 0:n.includes("spin.dev")})}function Di(){return[HTMLElement,Event,document.createElement].some(kn)}function vi(t){const e=t.exceptions.map(n=>n.stacktrace.filter(r=>!Ri(r)));return e.some(n=>{var r;return!((r=n[0])!=null&&r.inProject)})?"external-trigger":e.some(n=>n.every(r=>[Dn,mr,vn].some(a=>r.file.startsWith(a))))?"wallet-sdk-stack-trace":null}function Ri(t){return t.file.includes("native code")||t.file.includes("/cdn/wpm/")}function Ni(t){return!t.exceptions[0].stacktrace.some(e=>e.inProject)}function Ti(t){var e;return(e=t.metaData.custom)!=null&&e.customFetch?t.exceptions.some(n=>{var r;return(r=n.message)==null?void 0:r.includes("GraphQL Client: API multipart response did not return an iterable body")}):!1}function ki(t){return _i.some(e=>t==null?void 0:t.includes(e))}function Li(t){const e=t.exceptions.some(n=>n.errorClass===ut);return e&&console.error(t.exceptions[0]),e}function Oi(t){return t.exceptions.some(e=>Ei.includes(e.errorClass))}function xi(t){const e=t.errorClass,n=t.message;return Gr.has(e)&&(n==null?void 0:n.includes(Gr.get(e)))}function Mi(t){return t.exceptions[0].errorClass==="BugsnagInvalidError"&&t.unhandled}var R=(t=>(t.ButtonRender="portable_wallets_button_render",t.Decelerated="portable_wallets_decelerated",t.InitCompleted="portable_wallets_init_completed",t.InstrumentLoadEligibility="portable_wallets_instrument_load_eligibility",t.InstrumentLoadTime="portable_wallets_instrument_load_time",t.InstrumentLoadTimeFromPageLoad="portable_wallets_instrument_load_time_from_page_load",t.MonorailProduceError="portable_wallets_monorail_produce_error",t.SheetClicked="portable_wallets_sheet_clicked",t.SheetCancelled="portable_wallets_sheet_cancelled",t.SheetFailed="portable_wallets_sheet_failed",t.UpdateFailed="portable_wallets_update_failed",t.AuthorizationAttempt="portable_wallets_authorization_attempt",t.AuthorizationComplete="portable_wallets_authorization_complete",t.CartTokenMissing="portable_wallets_cart_token_missing",t.RemovePersonalDataResult="portable_wallets_cart_remove_personal_data_result",t.GooglePayNotEligibleWebview="portable_wallets_google_pay_not_eligible_webview",t.WalletConfigDeveloperError="portable_wallets_wallet_config_developer_error",t.LegacyCartCookie="portable_wallets_legacy_cart_cookie",t.StyleBackwardsCompatibility="portable_wallets_style_backwards_compatibility",t.AmazonPayLoadRetries="portable_wallets_amazon_pay_sdk_load_retries",t.DynamicTaxFailed="portable_wallets_dynamic_tax_failed",t.DynamicShippingFailed="portable_wallets_dynamic_shipping_failed",t.ErrorTriggered="portable_wallets_error_triggered",t))(R||{}),Ce=(t=>(t.InstrumentSdkLoaded="portable_wallets_instrument_sdk_loaded",t.InstrumentSdkFailed="portable_wallets_instrument_sdk_failed",t.InstrumentSdkEligible="portable_wallets_instrument_sdk_eligible",t.InstrumentSdkNotEligible="portable_wallets_instrument_sdk_not_eligible",t))(Ce||{}),b=(t=>(t.BuyItNow="BuyItNow",t.MoreOptions="MoreOptions",t.ApplePay="ApplePay",t.PayPal="PayPal",t.Venmo="Venmo",t.GooglePay="GooglePay",t.ShopPay="ShopPay",t.MetaPay="FacebookPay",t.BuyWithPrime="BuyWithPrime",t.AmazonPay="AmazonPay",t.Unknown="Unknown",t))(b||{}),S=(t=>(t.CartPage="cart_page",t.CartAjax="cart_ajax",t.ProductPage="product",t.Checkout="checkout",t.Unknown="unknown",t))(S||{}),Xe=(t=>(t.CartChange="/cart/change",t.CartUpdate="/cart/update",t.CartAdd="/cart/add",t.CartClear="/cart/clear",t))(Xe||{}),Ie=(t=>(t.OneTimePurchase="ONE_TIME_PURCHASE",t.Subscription="SUBSCRIPTION",t))(Ie||{});let Lt=Fi();function Fi(){return{shopId:Nn,debug:!1,pageType:S.Unknown}}function Ui(t){Object.assign(Lt,t)}function wr(){const t=Lt,{debug:e}=t;return Ur(t,["debug"])}function $i(){return Lt.debug}function xn(){return Lt.pageType}function Bi(t){const e=t.exceptions[0];if(!e||!e.message||ni.checkDuplicate(e))return!1;Hi(t);let n=null;try{n=Ci(t)}catch(r){const a=r;console.error(a);const i={errorClass:"UnfilterableError",message:"Could not properly filter error with message: ".concat(a.message),stacktrace:Sn(Rn,a)};t.exceptions.unshift(i)}return Vi(n),$i()&&zi({errorClass:e.errorClass,message:e.message,stacktrace:JSON.stringify(e.stacktrace),filterResult:n}),n==null}function Hi(t){var e,n,r,a,i;t.context=window.location.pathname,t.request||(t.request={}),t.request.url=window.location.href,t.device.orientation=(n=(e=window.screen)==null?void 0:e.orientation)==null?void 0:n.type,Gi(t);const o=(i=(a=(r=window.ShopifyAnalytics)==null?void 0:r.lib)==null?void 0:a.trekkie)==null?void 0:i.defaultAttributes;t.metaData=T(_({},t.metaData),{shop:_(_({},wr()),t.metaData.shop),custom:T(_({},t.metaData.custom),{customFetch:kn(fetch)}),monorail:o})}function Gi(t){for(const e of t.exceptions)for(const n of e.stacktrace)[Dn,mr,vn].some(r=>n.file.startsWith(r))&&(n.inProject=!0)}function Vi(t){P.counter({name:R.ErrorTriggered,value:1,attributes:{filterResult:t||"valid-error"}})}function zi(t){P.log({body:"Bugsnag Error",attributes:_(_({},wr()),t)})}var wn;const qi={apiKey:"cb577dc231be1c7494db8a63441ef66b",appId:Rn,appVersion:"0.0.0-a85e50f3ce699adb1de41595ad2c9c89e9195686",releaseStage:"production",locale:"en",userAgent:navigator.userAgent,metadata:{user:{id:(wn=at(ti))!=null?wn:"unknown"}},onError:Bi},w=new Ka(qi);w.addOnPostError(t=>{w.leaveBreadcrumb("Bugsnag Error Notified",{errorClass:t.exceptions[0].errorClass,message:t.exceptions[0].message},"error")});var Mn={en:{express_checkout:"Express checkout",instruments_copy:{checkout:{buy_now:"Buy it now"}},error_dialogs:{checkout:{title:"Transaction failed",generic_error:"Checkout is currently unavailable due to technical problems. Please try again in a few minutes.",button_text:"Close"},product:{out_of_stock:"This item is no longer available."},wallet:{title:"%{wallet} unavailable",generic_error:"There was an issue with %{wallet}. Try again or use a different payment method.",eligibility_error:"Items that were eligible for %{wallet} are no longer in your cart."}},more_payment_options:"More payment options",action:{view:"View %{content}"},subscriptions:{cancellation_policy:"Cancellation policy",policy_not_found:"The subscription policy could not be found. Refresh the page or contact us for more information."},shipping_methods:{connect_shipping_methods:"%{methodOne} and %{methodTwo}",choose_delivery_strategy:"Choose a delivery method"},delivery_promises:{connect_delivery_promises:"%{promiseOne} and %{promiseTwo}"},order_summary:{total:"Total",subtotal:"Subtotal",duties:"Duties",taxes:"Taxes",shipping:"Shipping",shipping_one_time_purchase:"Shipping (One-time purchase)",shipping_subscription:"Shipping (Subscription)",discount:"Discount",subscriptions:{recurring_total_tooltip_line:"Does not include shipping, tax, duties, or any applicable discounts",recurring_totals:"%{fixedPrice} every %{interval}",recurring_totals_with_policies:{one:"First payment %{fixedPrice}, then %{recurringPrice} every %{interval}",other:"First %{count} payments %{fixedPrice} each, then %{recurringPrice} every %{interval}"},recurring_total_intervals:{day:{one:"day",other:"%{count} days"},month:{one:"month",other:"%{count} months"},week:{one:"week",other:"%{count} weeks"},year:{one:"year",other:"%{count} years"}}}},brand:{amazon_pay:"Amazon Pay",apple_pay:"Apple Pay",buy_with_prime:"Buy with Prime",paypal:"PayPal",google_pay:"Google Pay",shop_pay:"Shop Pay"},buy_with_button_content:"Buy with %{wallet}",shop_promise_delivery:{same_day:"Same-day delivery",next_day:"Next-day delivery",two_day:"2-day delivery"},errors:{address_unserviceable:"%{shopName} does not currently deliver to this address. Use a different address to complete your purchase.",missing:{email:"Enter an email address",first_name:"Enter a first name",last_name:"Enter a last name",address1:"Enter an address",address2:"Enter an apartment, suite, etc.",city:"Enter a city",zone:"Select a state / province",country:"Select a country",phone:"Enter a phone number",postal_code:"Enter a ZIP / postal code",shipping_option:"Select a shipping method",emirate:"Enter an emirate"},invalid:{email:"Enter a valid email",first_name:"Enter a valid first name",last_name:"Enter a valid last name",address1:"Enter a valid address",address2:"Enter a valid apartment, suite, etc.",city:"Enter a valid city",zone:"Select a valid state / province",country:"Select a country / region",phone:"Enter a valid phone number",postal_code:"Enter a valid zip / postal code",billing_address:"Invalid billing address",shipping_address:"Invalid shipping address",payment_method:"Invalid payment method",discount:"Invalid discount",emirate:"Enter a valid emirate"},emojis:{first_name:"First name cannot contain emojis",last_name:"Last name cannot contain emojis",city:"City cannot contain emojis",address1:"Address line cannot contain emojis",address2:"Second address line cannot contain emojis",postal_code:"Postal code/zip cannot contain emojis"},too_long:{address1:"Address line is too long",address2:"Second address line is too long",first_name:"First name is too long",last_name:"Last name is too long",city:"City is too long"},url:{first_name:"First name cannot contain a URL",last_name:"Last name cannot contain a URL"},html_tags:{first_name:"First name cannot contain HTML tags",last_name:"Last name cannot contain HTML tags",city:"City cannot contain HTML tags",address1:"Address line cannot contain HTML tags",address2:"Second address line cannot contain HTML tags"},currency:{mismatch:"Your cart and currency has been updated based on your shipping country."}}}};Mn.en;let Yt;class Vr extends Error{constructor(e,n){const r="i18n: Missing or invalid translation '".concat(e,"' in '").concat(n,"'");super(r)}}class ji extends Error{constructor(e,n,r){const a="i18n: Missing translation template key '".concat(e,"' for '").concat(n,"' in '").concat(r,"'");super(a)}}class Yi extends Error{constructor(e,n,r){const a="i18n: Invalid pluralization for '".concat(e,"':'").concat(n,"' in '").concat(r,"'");super(a)}}function Ot(){return Yt==null&&(Yt=Wi(Mn)),Yt}function Wi(t){const e=(i,o)=>typeof i!="string"&&o.count!=="undefined",n=(i,o)=>{let s=o===1?"one":"other";return o===0&&typeof i!="string"&&i.zero!=="undefined"&&(s="zero"),s},r=(i,o={})=>{const s=i.match(/%\{.+?\}/g);return s?s.reduce((l,c)=>{const u=c.replace(/%\{(.*)\}/,"$1");return o[u]?l.replace(c,o[u]):(w.notify(new ji(u,i,a)),l)},i):i},a=Ki();return{locale:a,translate(i,o={}){var s;const l=i.split(".");let c=t[a];try{for(const u of l)switch(typeof c){case"object":c=c[u];break;case"string":case"undefined":throw new Vr(i,a)}if(e(c,o)){if(typeof c=="string")throw new Yi(i,c,a);c=c[n(c,o.count)]}if(typeof c!="string")throw new Vr(i,a);return r(c,o)}catch(u){return w.notify(u),(s=o.defaultValue)!=null?s:i}}}}function Ki(){return"en"}function Qi(t){const e=document.querySelectorAll("shopify-accelerated-checkout .shopify-payment-button__skeleton, shopify-accelerated-checkout-cart .wallet-cart-button__skeleton"),n=document.getElementById("shopify-buyer-consent");for(let r=0;re.toString(16)).join("")}function no(t){const e={"Content-Type":"application/json; charset=utf-8","X-Monorail-Edge-Event-Created-At-Ms":(t&&t.eventCreatedAtMs||Date.now()).toString(),"X-Monorail-Edge-Event-Sent-At-Ms":Date.now().toString(),"X-Monorail-Edge-Client-Message-Id":(t&&t.clientMessageId||ro()).toString()};return t&&t.userAgent&&(e["User-Agent"]=t.userAgent),t&&t.remoteIp&&(e["X-Forwarded-For"]=t.remoteIp),t&&t.deviceInstallId&&(e["X-Monorail-Edge-Device-Install-Id"]=t.deviceInstallId),t&&t.client&&(e["X-Monorail-Edge-Client"]=t.client),t&&t.clientOs&&(e["X-Monorail-Edge-Client-OS"]=t.clientOs),e}async function ao({endpoint:t,event:e,keepalive:n}){return fetch(t!=null?t:eo+to,{method:"post",headers:no(e.metadata),body:JSON.stringify(qr(qr({schema_id:e.schemaId,payload:e.payload},e.metadata&&{metadata:{client_message_id:e.metadata.clientMessageId,event_created_at_ms:e.metadata.eventCreatedAtMs}}),e.consent&&{consent:e.consent,consent_provider:e.consent_provider,consent_version:e.consent_version})),keepalive:n})}const io="2.1",oo="3",Wt={NO_VALUE:"",ACCEPTED:"1",DECLINED:"0"},K={PREFERENCES:"p",ANALYTICS:"a",MARKETING:"m",SALE_OF_DATA:"t"},ne={MARKETING:"m",ANALYTICS:"a",PREFERENCES:"p",SALE_OF_DATA:"s"},so=()=>typeof __CtaTestEnv__>"u"?!1:__CtaTestEnv__==="true",lo="_tracking_consent";function Un(t,e=!1){const n=document.cookie?document.cookie.split("; "):[];for(let r=0;ry.charCodeAt(0).toString(16).padStart(2,"0")).join("");l=[8,13,18,23].reduce((y,E)=>y.slice(0,E)+"-"+y.slice(E),p)}function c(h){const p=n.split(".")[0];return p.includes(h.toLowerCase())?Wt.DECLINED:p.includes(h.toUpperCase())?Wt.ACCEPTED:Wt.NO_VALUE}function u(h){return n.includes(h.replace("t","s").toUpperCase())}return{v:oo,con:{CMP:{[ne.ANALYTICS]:c(ne.ANALYTICS),[ne.PREFERENCES]:c(ne.PREFERENCES),[ne.MARKETING]:c(ne.MARKETING),[ne.SALE_OF_DATA]:c(ne.SALE_OF_DATA)}},region:r||"",cus:s,purposes:{[K.ANALYTICS]:u(K.ANALYTICS),[K.PREFERENCES]:u(K.PREFERENCES),[K.MARKETING]:u(K.MARKETING),[K.SALE_OF_DATA]:u(K.SALE_OF_DATA)},sale_of_data_region:i=="t",display_banner:a=="t",consent_id:l}}function xt(t){const e=mo();if(!e||!e.purposes)return!0;const n=e.purposes[t];return typeof n=="boolean"?n:!0}function bo(){return xt(K.PREFERENCES)}function wo(){return xt(K.ANALYTICS)}function _o(){return xt(K.MARKETING)}function Eo(){return xt(K.SALE_OF_DATA)}function Ao(){return wo()}function Co(){return bo()}function So(){return _o()}function Io(){return Eo()}function Po(){return So()}function Do(){return Ao()}function vo(){return Co()}function Ro(){return Io()}function No(){const t=[];return Do()&&t.push("analytics"),Po()&&t.push("marketing"),Ro()&&t.push("sale_of_data"),vo()&&t.push("preferences"),t}function To(t,e){switch(e){case"v1":{const n=No();return T(_({},t),{metadata:T(_({},t==null?void 0:t.metadata),{consent:n,consent_provider:"consent-tracking-api",consent_version:e})})}default:throw new _r(e)}}class _r extends Error{constructor(e){super("Version ".concat(e," is not supported by the consent-tracking-api provider")),this.name="MonorailConsentTrackingApiProviderVersionError",Object.setPrototypeOf(this,_r.prototype)}}const ko=["Chrome-Lighthouse"];function Lo(){const t=navigator.userAgent;return ko.some(e=>t.includes(e))}async function Oo(t){if(Lo())return;const e=To(t,"v1");let n;try{n=await ao({event:e})}catch(r){}if(!(n!=null&&n.ok))try{P.counter({name:R.MonorailProduceError,value:1,attributes:{schemaId:e.schemaId}})}catch(r){}}const yt="shopify_wallet_checkout_track/6.2";async function j(t){var e,n,r,a,i,o,s;let l=null;try{const c=await xo();if(l={schemaId:yt,payload:{app_name:"storefront",page_type:ds(),checkout_one:!0,event:t.event,event_subtype:t.eventSubtype,checkout_token:t.checkoutToken,instrument_id:t.instrumentId,ttl:t.ttl,error_reason:t.errorReason,uniq_token:(e=c==null?void 0:c.uniqToken)!=null?e:"",visit_token:(n=c==null?void 0:c.visitToken)!=null?n:"",micro_session_id:(r=c==null?void 0:c.microSessionId)!=null?r:"",micro_session_count:(a=c==null?void 0:c.microSessionCount)!=null?a:0,shop_id:(i=c==null?void 0:c.shopId)!=null?i:0,theme_id:c==null?void 0:c.themeId,theme_city_hash:(o=c==null?void 0:c.themeCityHash)!=null?o:"",content_language:(s=c==null?void 0:c.contentLanguage)!=null?s:"",referer:c==null?void 0:c.referer}},!(t!=null&&t.event)){w.notify(new Error("Event is required"),{metadata:{request:{monorail:{schemaId:yt,payload:JSON.stringify(l)}}}});return}w.leaveBreadcrumb("monorail event produced to ".concat(yt),{schemaId:yt,payload:t}),await Oo(l)}catch(c){w.notify(new Mo("Failed to send monorail event: ".concat(c),{cause:c}),{metadata:{request:{monorail:{payload:JSON.stringify(l!=null?l:t)}}}})}}async function xo(){var t,e,n,r,a;return(e=(t=window==null?void 0:window.ShopifyAnalytics)==null?void 0:t.lib)!=null&&e.trekkie||await new Promise(i=>{const o=setInterval(()=>{var l,c;(c=(l=window==null?void 0:window.ShopifyAnalytics)==null?void 0:l.lib)!=null&&c.trekkie&&(clearInterval(o),i())},100),s=setTimeout(()=>{clearInterval(o),clearTimeout(s),i()},7e3)}),(a=(r=(n=window.ShopifyAnalytics)==null?void 0:n.lib)==null?void 0:r.trekkie)==null?void 0:a.defaultAttributes}class Mo extends Error{constructor(){super(...arguments),d(this,"name","MonorailError")}}var H=(t=>(t.CartInitCalled="portable_wallets_cart_init_called",t.ClickSheetCancelled="portable_wallets_instrument_click_sheet_cancelled",t.ClickSheetFailed="portable_wallets_instrument_click_sheet_failure",t.ClickSheetSuccess="portable_wallets_instrument_click_sheet_success",t.SheetFailed="portable_wallets_instrument_sheet_failed",t.AuthorizationAttempt="portable_wallets_authorization_attempt",t.AuthorizationComplete="portable_wallets_authorization_complete",t.InitCalled="portable_wallets_init_called",t.InitFailed="portable_wallets_init_failed",t.InitSuccess="portable_wallets_init_success",t.UpdateFailed="portable_wallets_instrument_update_failed",t.InstrumentLoaded="portable_wallets_instrument_loaded",t.InstrumentLoadFailed="portable_wallets_instrument_load_failed",t.FirstVisible="portable_wallets_first_visible",t.FirstVisibleNotAvailable="portable_wallets_first_visible_not_available",t))(H||{});const jr={[S.Checkout]:"bwp_checkout_widget_click",[S.CartAjax]:"bwp_cart_widget_click",[S.CartPage]:"bwp_cart_widget_click",[S.ProductPage]:"bwp_widget_click",[S.Unknown]:"bwp_widget_click"};function Fo({apiClientId:t,skus:e,pageType:n}){var r;if(!((r=window.Shopify)!=null&&r.analytics))return;const a=n&&jr[n]||"bwp_widget_click";a===jr[S.Checkout]&&window.Shopify.analytics.publish("shopify:app:pixels:load:".concat(t),{},{sendTo:"PIXEL-LOADER"}),window.Shopify.analytics.publish(a,{skus:e},{sendTo:t})}function $(t){return _({pageType:xn()},t)}function Uo(){const t=xn()===S.CartPage?H.CartInitCalled:H.InitCalled;j({event:t})}function $o(t){var e,n;const r=t?"Failed":"Success",a=t&&as(t)?"[".concat(t.name,"]: ").concat(t.code):void 0,i=H["Init".concat(r)];j({event:i,eventSubtype:a}),P.counter({name:R.InitCompleted,value:1,attributes:$({result:r.toLowerCase(),eventType:a,recoveredFailure:!!((n=(e=window.Shopify)==null?void 0:e.PaymentButton)!=null&&n.failedToLoad)})})}function Bo({instrumentOrComponentName:t,result:e,measurement:n}){j({event:e==="success"?H.InstrumentLoaded:H.InstrumentLoadFailed,instrumentId:t,ttl:n}),n!=null&&(P.histogram({name:R.InstrumentLoadTime,value:n,attributes:$({instrument:t}),unit:"ms"}),P.histogram({name:R.InstrumentLoadTimeFromPageLoad,value:window.performance.now(),attributes:$({instrument:t}),unit:"ms"}))}function Ho({instrument:t,measurement:e,result:n}){const r=n==="success"?Ce.InstrumentSdkLoaded:Ce.InstrumentSdkFailed;j({event:r,instrumentId:t,ttl:e,errorReason:n==="success"?void 0:n}),e!=null&&P.histogram({name:Ce.InstrumentSdkLoaded,value:e,attributes:$({instrument:t,result:n}),unit:"ms"})}function Go({instrument:t,result:e,reason:n}){const r=e==="success"?Ce.InstrumentSdkEligible:Ce.InstrumentSdkNotEligible;j({event:r,instrumentId:t}),P.counter({name:Ce.InstrumentSdkEligible,value:1,attributes:$({instrument:t,reason:n,result:e})})}function Vo({instrument:t,result:e,reason:n}){P.counter({name:R.InstrumentLoadEligibility,value:1,attributes:$({instrument:t,result:e,reason:n})})}function zo(t){P.counter({name:R.ButtonRender,value:1,attributes:$({result:"success",instrument:t})})}function qo(t){P.counter({name:R.ButtonRender,value:1,attributes:$({result:"failed",instrument:t})})}function jo({instrument:t,result:e,webPixelMetaData:n}){j({event:e==="success"?H.ClickSheetSuccess:H.ClickSheetFailed,instrumentId:t}),P.counter({name:R.SheetClicked,value:1,attributes:$({instrument:t,result:e})}),t===b.BuyWithPrime&&n&&Fo(n)}function Yo(t,e){j({event:"".concat(H.UpdateFailed,"-").concat(e),instrumentId:t}),P.counter({name:R.UpdateFailed,value:1,attributes:$({instrument:t,request:e})})}function Wo(t){j({event:H.ClickSheetCancelled,instrumentId:t}),P.counter({name:R.SheetCancelled,value:1,attributes:$({instrument:t})})}function Ko(t,e){j({event:H.SheetFailed,instrumentId:t,errorReason:e==null?void 0:e.message}),P.counter({name:R.SheetFailed,value:1,attributes:$({instrument:t})})}function Qo(t){j({event:H.AuthorizationAttempt,instrumentId:t}),P.counter({name:R.AuthorizationAttempt,value:1,attributes:$({instrument:t})})}function Xo({instrument:t,measurement:e,result:n}){j({event:H.AuthorizationComplete,eventSubtype:n,ttl:e,instrumentId:t}),e!=null&&P.histogram({name:R.AuthorizationComplete,value:e,attributes:$({instrument:t,result:n}),unit:"ms"})}function Jo({instrument:t,reason:e}){P.counter({name:R.Decelerated,value:1,attributes:$({instrument:t,reason:e})}),g.flushTelemetry()}function Zo({reason:t}){P.counter({name:R.CartTokenMissing,value:1,attributes:{reason:t}})}function es({success:t}){P.counter({name:R.RemovePersonalDataResult,value:1,attributes:$({success:t})})}function ts(){P.counter({name:R.WalletConfigDeveloperError,value:1})}function rs(){P.counter({name:R.LegacyCartCookie,value:1})}function ns(){window.setInterval(()=>{$n()},1e3)}function as(t){return(t==null?void 0:t.name)===ut}function $n(){P.exportMetrics(),P.exportLogs()}function is(t){const{body:e,attributes:n}=t;P.log({body:e,attributes:_(_({},wr()),n)})}function os(){P.counter({name:R.StyleBackwardsCompatibility,value:1})}function ss({retries:t}){P.counter({name:R.AmazonPayLoadRetries,value:1,attributes:{retries:t}})}function ls({instrument:t}){P.counter({name:R.DynamicTaxFailed,value:1,attributes:{instrument:t}})}function cs({instrument:t}){P.counter({name:R.DynamicShippingFailed,value:1,attributes:{instrument:t}})}const g={initStarted:D(Uo),initCompleted:D($o),instrumentLoaded:D(Bo),instrumentLoadEligibility:D(Vo),instrumentSDKLoaded:D(Ho),instrumentSDKEligible:D(Go),renderSucceeded:D(zo),renderFailed:D(qo),sheetClicked:D(jo),sheetCancelled:D(Wo),sheetFailed:D(Ko),updateFailed:D(Yo),authorizationAttempt:D(Qo),authorizationComplete:D(Xo),startExporter:D(ns),decelerated:D(Jo),cartTokenMissing:D(Zo),removePersonalDataResult:D(es),walletConfigDeveloperError:D(ts),legacyCartCookie:D(rs),flushTelemetry:D($n),styleBackwardsCompatibility:D(os),amazonPaySDKLoadRetries:D(ss),dynamicTaxFailed:D(ls),dynamicShippingFailed:D(cs),log:D(is,{logErrors:!1})};function D(t,{logErrors:e=!0}={}){return(...n)=>{try{t(...n)}catch(r){e&&g.log({body:"Error calling telemetry function",attributes:{error:"".concat(r)}})}}}const Je=[];function he(t,e,n){if(window.customElements!=null)try{const r=e;window.customElements.get(t)||(window.customElements.define(t,r),n!=null&&n.isChildCustomElement&&Je.push(t))}catch(r){w.notify(r),Qi()}}function At(){const t=new URLSearchParams(window.location.search);return function(e){return!!t.get(e)}}function ds(){var t,e,n,r;const a=(t=window.Shopify)==null?void 0:t.CartType;if(a===S.CartAjax)return S.CartAjax;if(a===S.CartPage)return S.CartPage;const i=(r=(n=(e=window.ShopifyAnalytics)==null?void 0:e.meta)==null?void 0:n.page)==null?void 0:r.pageType;if(i)switch(i.toLowerCase()){case"product":return S.ProductPage;case"cart":return S.CartPage}const o=document.querySelector("#shop-js-analytics");if(o)try{const s=JSON.parse(o.textContent||"{}");if(s.pageType)switch(s.pageType.toLowerCase()){case"product":return S.ProductPage;case"cart":return S.CartPage}}catch(s){console.error("Error parsing JSON script tag:",s)}return S.Unknown}function Se(t){return Number(t).toFixed(2)}function Bn(t){if(!(!t||!t.id||!t.id.includes("gid://shopify/Cart/")))return t.id.replace("gid://shopify/Cart/","").split("?")[0]}function ie(){let t;return[new Promise(e=>t=e),t]}const us={force_shop_pay_product:"direct_checkout_product",force_shop_pay_cart:"direct_checkout_cart"};function ce(t,e="no_redirect_for_checkout"){g.flushTelemetry();const n=new URL(t);switch(e){case"skip_shop_pay":n.searchParams.set("skip_shop_pay","true");break;case"no_redirect_for_checkout":n.searchParams.set("storefront_wallet","true");break;case"force_shop_pay_cart":case"force_shop_pay_product":case"force_shop_pay":{n.searchParams.set("payment","shop_pay");const r=us[e];r&&n.searchParams.set("redirect_source",r);break}}window.location.assign(n.toString())}function Hn(){return!!document.querySelector('[data-source-attribution="shopify.shop-promise-pdp"]')}function Ze(){return new Date().getTime()}function Er(t){return t.find(e=>typeof e=="object"&&(e==null?void 0:e.code)===Et)}class hs extends HTMLElement{constructor(){super(),d(this,"overflow"),d(this,"formerFocus"),this.attachShadow({mode:"open"}),this.overflow="",this.formerFocus=document.activeElement}connectedCallback(){const e=Ot();this.render(e);const n=this.shadowRoot,r=n.getElementById("modal");n.querySelectorAll("button").forEach(o=>o.addEventListener("click",this.closeModal.bind(this)));const a=n.getElementById("overlay");a==null||a.addEventListener("click",o=>this.handleOutsideClick(o,r)),document.addEventListener("keydown",this.handleEscapeKey.bind(this));const i=document.createElement("style");i.textContent=Ga,n.appendChild(i),this.overflow=document.body.style.overflow,document.body.style.overflow="hidden",this.trapFocus(r,n),he("svg-icon",Ha)}trapFocus(e,n){if(!e)return;const r=e.querySelectorAll("a[href], button"),a=Array.from(r),i=a[0],o=a[a.length-1];e.addEventListener("keydown",s=>{s.key==="Tab"&&!s.shiftKey&&n.activeElement===o&&(s.preventDefault(),i.focus()),s.key==="Tab"&&s.shiftKey&&n.activeElement===i&&(s.preventDefault(),o.focus())}),i.focus()}handleOutsideClick(e,n){n&&(n.contains(e.target)||this.closeModal())}handleEscapeKey(e){e.key==="Escape"&&this.closeModal()}closeModal(){var e;document.body.style.overflow=this.overflow,this.remove(),this.formerFocus&&"focus"in(this==null?void 0:this.formerFocus)&&typeof this.formerFocus.focus=="function"&&((e=this.formerFocus)==null||e.focus())}render(e){const n=this.getAttribute("title"),r=this.getAttribute("has-close-button"),a=e.translate("error_dialogs.checkout.button_text"),i='\n
\n \n
\n ");this.shadowRoot.innerHTML='\n
\n \n
\n ")}}const ps="@keyframes topLevelModalLoadingSkeleton{50%{opacity:1}75%{opacity:.5}to{opacity:1}}top-level-modal .text-skeleton{display:inline-block;width:100%;height:14px;margin-bottom:7px;animation:topLevelModalLoadingSkeleton 4s ease infinite;animation-delay:-.168s;text-decoration:none!important;background-color:#dedede}top-level-modal .text-skeleton:last-of-type{width:50%}";function Mt({type:t="button",label:e=void 0}={}){const n=document.createElement("button");return n.type=t,e&&n.setAttribute("aria-label",e),n}function Ft(t,e){for(const[n,r]of Object.entries(e))t.setAttribute(n,r)}function Yr(t,e){for(const[n,r]of Object.entries(e))t.style.setProperty(n,r)}function De(t,e){const n=document.createElement("top-level-modal");n.textContent=e,Ft(n,{"data-testid":"top-level-modal","has-close-button":"true",title:t}),document.body.appendChild(n)}function Ar(t,e,n){const r=document.createElement("top-level-modal");Ft(r,{"data-testid":"top-level-modal",title:t}),e instanceof Promise?(r.innerHTML="\n \n  \n  \n  \n  \n  \n '),e.then(a=>{a&&a!==""?r.innerHTML=a:r.innerHTML=n!=null?n:""}).catch(()=>{r.innerHTML=n!=null?n:""})):r.innerHTML=e,document.body.appendChild(r)}function J(t,e){De(e.translate("error_dialogs.wallet.title",{wallet:t}),e.translate("error_dialogs.wallet.generic_error",{wallet:t}))}function ve(t,e){De(t.translate("error_dialogs.checkout.title"),e)}he("top-level-modal",hs);var Fe;class Ut extends HTMLElement{constructor(){super(...arguments),x(this,Fe)}get buyerCountry(){return this.getAttribute("buyer-country")}get recommendedInstrument(){return this.getAttribute("recommended-instrument")}get buyerCurrency(){const e=this.getAttribute("buyer-currency");if(e==null)throw new Error("WalletElement buyer-currency is null");return e}get accessToken(){return this.getAttribute("access-token")}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get hasSellingPlan(){const e=this.getAttribute("has-selling-plan");return e==="true"||e===""}set hasSellingPlan(e){e?this.setAttribute("has-selling-plan",""):this.removeAttribute("has-selling-plan")}get isShippingRequired(){const e=this.getAttribute("requires-shipping");return e==="true"||e===""}set isShippingRequired(e){e?this.setAttribute("requires-shipping",""):this.removeAttribute("requires-shipping")}get pciEnabled(){return this.hasAttribute("pci-enabled")}isFlagEnabled(e){return C(this,Fe)==null&&L(this,Fe,this.getEnabledFlags()),C(this,Fe).includes(e)}getEnabledFlags(){const e=this.getAttribute("enabled-flags");if(!e)return[];try{return JSON.parse(e)}catch(n){return console.warn("Invalid enabled-flags attribute value:",e),[]}}}Fe=new WeakMap;const ms="#more-payment-options-link{cursor:pointer}";function ys(t){const e=n=>{n.persisted&&(t(),window.removeEventListener("pageshow",e))};window.addEventListener("pageshow",e)}var m=(t=>(t.InvalidLanguage="Variable $language of type LanguageCode was provided invalid value",t.InvalidCountry="Variable $country of type CountryCode was provided invalid value",t.MissingCartId="Variable $cartId of type ID! was provided invalid value",t.BuyerIdentityInvalidCountry="Variable $buyerIdentity of type CartBuyerIdentityInput! was provided invalid value for countryCode",t.BuyerIdentityInvalidPhone="INVALID: buyerIdentity.phone",t.BuyerIdentityEmailRequired="BUYER_IDENTITY_EMAIL_REQUIRED",t.BuyerIdentityEmailDomainInvalid="BUYER_IDENTITY_EMAIL_DOMAIN_IS_INVALID",t.BuyerIdentityEmailNotExpectedPattern="BUYER_IDENTITY_EMAIL_DOES_NOT_MATCH_EXPECTED_PATTERN",t.BuyerIdentityEmailInvalid="INVALID: buyerIdentity.email",t.CaptchaCompletionRequired="CAPTCHA_COMPLETION_REQUIRED",t.CustomValidation="".concat(Et),t.DeliveryFirstNameInvalid="DELIVERY_FIRST_NAME_INVALID",t.DeliveryFirstNameRequired="DELIVERY_FIRST_NAME_REQUIRED",t.BuyerIdentityDeliveryFirstNameRequired="ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.firstName",t.DeliveryFirstNameContainsEmojis="ADDRESS_FIELD_CONTAINS_EMOJIS: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.firstName",t.DeliveryFirstNameTooLong="ADDRESS_FIELD_IS_TOO_LONG: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.firstName",t.DeliveryFirstNameContainsUrl="ADDRESS_FIELD_CONTAINS_URL: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.firstName",t.DeliveryFirstNameContainsHtmlTags="ADDRESS_FIELD_CONTAINS_HTML_TAGS: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.firstName",t.DeliveryFirstNameDoesNotMatchExpectedPattern="ADDRESS_FIELD_DOES_NOT_MATCH_EXPECTED_PATTERN: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.firstName",t.DeliveryLastNameInvalid="DELIVERY_LAST_NAME_INVALID",t.DeliveryLastNameRequired="DELIVERY_LAST_NAME_REQUIRED",t.BuyerIdentityDeliveryLastNameRequired="ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.lastName",t.DeliveryLastNameContainsEmojis="ADDRESS_FIELD_CONTAINS_EMOJIS: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.lastName",t.DeliveryLastNameTooLong="ADDRESS_FIELD_IS_TOO_LONG: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.lastName",t.DeliveryLastNameContainsUrl="ADDRESS_FIELD_CONTAINS_URL: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.lastName",t.DeliveryLastNameContainsHtmlTags="ADDRESS_FIELD_CONTAINS_HTML_TAGS: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.lastName",t.DeliveryLastNameDoesNotMatchExpectedPattern="ADDRESS_FIELD_DOES_NOT_MATCH_EXPECTED_PATTERN: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.lastName",t.BuyerIdentityDeliveryAddress1Required="ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.address1",t.DeliveryAddress1Required="DELIVERY_ADDRESS1_REQUIRED",t.DeliveryAddress1Invalid="DELIVERY_ADDRESS1_INVALID",t.DeliveryAddress1TooLong="ADDRESS_FIELD_IS_TOO_LONG: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.address1",t.DeliveryAddress1ContainsHtmlTags="ADDRESS_FIELD_CONTAINS_HTML_TAGS: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.address1",t.DeliveryAddress1ContainsEmojis="ADDRESS_FIELD_CONTAINS_EMOJIS: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.address1",t.DeliveryAddress2Required="DELIVERY_ADDRESS2_REQUIRED",t.DeliveryAddress2AddressFieldRequired="ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.address2",t.DeliveryAddress2Invalid="DELIVERY_ADDRESS2_INVALID",t.DeliveryAddress2TooLong="ADDRESS_FIELD_IS_TOO_LONG: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.address2",t.DeliveryAddress2ContainsHtmlTags="ADDRESS_FIELD_CONTAINS_HTML_TAGS: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.address2",t.DeliveryAddress2ContainsEmojis="ADDRESS_FIELD_CONTAINS_EMOJIS: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.address2",t.DeliveryCityRequired="DELIVERY_CITY_REQUIRED",t.DeliveryCityAddressFieldRequired="ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.city",t.DeliveryCityInvalid="DELIVERY_CITY_INVALID",t.DeliveryCityTooLong="ADDRESS_FIELD_IS_TOO_LONG: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.city",t.DeliveryCityContainsHtmlTags="ADDRESS_FIELD_CONTAINS_HTML_TAGS: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.city",t.DeliveryCityContainsEmojis="ADDRESS_FIELD_CONTAINS_EMOJIS: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.city",t.DeliveryZoneNotFound="DELIVERY_ZONE_NOT_FOUND",t.DeliveryZoneRequiredForCountry="DELIVERY_ZONE_REQUIRED_FOR_COUNTRY",t.DeliveryProvinceRequired="ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.province",t.DeliveryPostalCodeInvalid="DELIVERY_POSTAL_CODE_INVALID",t.DeliveryInvalidPostalCodeForZone="DELIVERY_INVALID_POSTAL_CODE_FOR_ZONE",t.DeliveryInvalidPostalCodeForCountry="DELIVERY_INVALID_POSTAL_CODE_FOR_COUNTRY",t.DeliveryPostalCodeRequired="DELIVERY_POSTAL_CODE_REQUIRED",t.DeliveryPostalCodeAddressFieldRequired="ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.zip",t.DeliveryZipInvalidForProvince="INVALID_ZIP_CODE_FOR_PROVINCE",t.BuyerIdentityDeliveryZipInvalidForProvince="INVALID_ZIP_CODE_FOR_PROVINCE: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.zip",t.DeliveryZipInvalidForCountry="INVALID_ZIP_CODE_FOR_COUNTRY: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.zip",t.DeliveryPostalCodeContainsEmojis="ADDRESS_FIELD_CONTAINS_EMOJIS: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.zip",t.DeliveryCountryRequired="ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.country",t.DeliveryCountryInvalid="INVALID: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.country",t.DeliveryPhoneNumberRequired="DELIVERY_PHONE_NUMBER_REQUIRED",t.BuyerIdentityDeliveryPhoneNumberRequired="ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.phone",t.DeliveryOptionsPhoneNumberRequired="DELIVERY_OPTIONS_PHONE_NUMBER_REQUIRED",t.DeliveryPhoneNumberInvalid="DELIVERY_PHONE_NUMBER_INVALID",t.DeliveryPhoneDoesNotMatchExpectedPattern="ADDRESS_FIELD_DOES_NOT_MATCH_EXPECTED_PATTERN: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.phone",t.MerchandiseOutOfStock="MERCHANDISE_OUT_OF_STOCK",t.MerchandiseNotEnoughStock="MERCHANDISE_NOT_ENOUGH_STOCK",t.InvalidQuantity="INVALID: input.lines.0.quantity",t.DeliveryOutOfStockAtOrigin="DELIVERY_OUT_OF_STOCK_AT_ORIGIN_LOCATION",t.DeliveryExternalPromiseUnfulfillable="DELIVERY_EXTERNAL_PROMISE_UNFULFILLABLE",t.MerchandiseNotApplicable="MERCHANDISE_NOT_APPLICABLE",t.MerchandiseVariantNotFound="MERCHANDISE_PRODUCT_VARIANT_NOT_FOUND",t.MerchandiseNotFound="MERCHANDISE_NOT_FOUND",t.MerchandiseNotPublished="MERCHANDISE_PRODUCT_NOT_PUBLISHED",t.MerchandiseNotSupportedForB2B="MERCHANDISE_SELLING_PLANS_NOT_SUPPORTED_FOR_B2B",t.MerchandiseBundleRequiresComponents="MERCHANDISE_BUNDLE_REQUIRES_COMPONENTS",t.MerchandiseGiftCardsNotSupported="MERCHANDISE_GIFT_CARDS_COMPONENTS_NOT_SUPPORTED",t.MerchandiseGiftCardGreaterThanZero="MERCHANDISE_GIFT_CARD_PRICE_MUST_BE_GREATER_THAN_ZERO",t.MerchandiseGiftCardCannotExceedLimit="MERCHANDISE_GIFT_CARD_PRICE_MUST_NOT_EXCEED_LIMIT",t.UnacceptablePaymentsAmount="PAYMENTS_UNACCEPTABLE_PAYMENT_AMOUNT",t.DiscountNotApplicable="DISCOUNT_NOT_APPLICABLE",t.DeliveryNotAvailable="DELIVERY_NO_DELIVERY_AVAILABLE",t.DeliveryNoStrategyAvailable="DELIVERY_NO_DELIVERY_STRATEGY_AVAILABLE",t.DeliveryNoLocalPickupStrategyAvailable="DELIVERY_LOCAL_PICKUP_NO_DELIVERY_STRATEGY_AVAILABLE",t.DeliveryLineChanged="DELIVERY_DELIVERY_LINE_DETAIL_CHANGED",t.DeliveryLocalPickupLineChanged="DELIVERY_LOCAL_PICKUP_DELIVERY_LINE_DETAIL_CHANGED",t.DeliveryNoDeliveryAvailableForMerchandise="DELIVERY_NO_DELIVERY_STRATEGY_AVAILABLE_FOR_MERCHANDISE_LINE",t.DeliveryFulfillmentConstraintNotSatisfied="DELIVERY_MUST_FULFILL_FROM_CONSTRAINT_NOT_SATISFIED",t.DeliveryFulfillmentLocationConstraint="DELIVERY_MUST_FULFILL_FROM_SAME_LOCATION_CONSTRAINT_NOT_SATISFIED",t.NoDeliveryGroupSelected="NO_DELIVERY_GROUP_SELECTED",t.DeliveryOptionInvalid="INVALID_DELIVERY_OPTION: selectedDeliveryOptions",t.DeliveryGroupInvalid="INVALID_DELIVERY_GROUP: selectedDeliveryOptions",t.DeliveryDetailChanged="DELIVERY_DETAIL_CHANGED",t.PendingDeliveryGroups="PENDING_DELIVERY_GROUPS",t.InvalidPaymentAmount="INVALID_PAYMENT: amount",t.InvalidPaymentPaymentAmount="INVALID_PAYMENT: payment.amount",t.NewTaxMustBeAccepted="TAX_NEW_TAX_MUST_BE_ACCEPTED",t.MerchandiseExpectedPriceMismatch="MERCHANDISE_EXPECTED_PRICE_MISMATCH",t.InvalidPaymentApplePayBillingAddress="INVALID_PAYMENT: payment.walletPaymentMethod.applePayWalletContent.billingAddress",t.InvalidPaymentGooglePayBillingAddress="INVALID_PAYMENT: payment.walletPaymentMethod.googlePayWalletContent.billingAddress",t.InvalidPaymentBillingAddress="INVALID_PAYMENT: payment.freePaymentMethod.billingAddress",t.UnsupportedGooglePayPaymentMethod="PAYMENT_METHOD_NOT_SUPPORTED: payment.walletPaymentMethod.googlePayWalletContent",t.UnsupportedApplePayPaymentMethod="PAYMENT_METHOD_NOT_SUPPORTED: payment.walletPaymentMethod.applePayWalletContent",t))(m||{});const gs=["DELIVERY_FIRST_NAME_REQUIRED","ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.firstName"],fs=["DELIVERY_FIRST_NAME_INVALID","ADDRESS_FIELD_DOES_NOT_MATCH_EXPECTED_PATTERN: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.firstName"],bs=["DELIVERY_LAST_NAME_REQUIRED","ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.lastName"],ws=["DELIVERY_LAST_NAME_INVALID","ADDRESS_FIELD_DOES_NOT_MATCH_EXPECTED_PATTERN: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.lastName"],_s=["DELIVERY_ADDRESS1_REQUIRED","ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.address1"],Es=["DELIVERY_ADDRESS2_REQUIRED","ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.address2"],As=["DELIVERY_CITY_REQUIRED","ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.city"],Cs=["DELIVERY_POSTAL_CODE_REQUIRED","ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.zip"],Gn=["DELIVERY_POSTAL_CODE_INVALID","INVALID_ZIP_CODE_FOR_COUNTRY: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.zip","INVALID_ZIP_CODE_FOR_PROVINCE","DELIVERY_INVALID_POSTAL_CODE_FOR_ZONE","DELIVERY_INVALID_POSTAL_CODE_FOR_COUNTRY","INVALID_ZIP_CODE_FOR_PROVINCE: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.zip"],Ss=["DELIVERY_PHONE_NUMBER_REQUIRED","ADDRESS_FIELD_IS_REQUIRED: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.phone"],Is=["INVALID: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.country","Variable $buyerIdentity of type CartBuyerIdentityInput! was provided invalid value for countryCode"],Ps=["DELIVERY_PHONE_NUMBER_INVALID","INVALID: buyerIdentity.phone","ADDRESS_FIELD_DOES_NOT_MATCH_EXPECTED_PATTERN: buyerIdentity.deliveryAddressPreferences.0.deliveryAddress.phone"],Vn=["INVALID_DELIVERY_OPTION: selectedDeliveryOptions","INVALID_DELIVERY_GROUP: selectedDeliveryOptions","DELIVERY_NO_DELIVERY_AVAILABLE","DELIVERY_DETAIL_CHANGED","NO_DELIVERY_GROUP_SELECTED","DELIVERY_NO_DELIVERY_STRATEGY_AVAILABLE","DELIVERY_LOCAL_PICKUP_NO_DELIVERY_STRATEGY_AVAILABLE"],zn=["INVALID_PAYMENT: amount","INVALID_PAYMENT: payment.amount"],Cr=["TAX_NEW_TAX_MUST_BE_ACCEPTED","PAYMENTS_UNACCEPTABLE_PAYMENT_AMOUNT"],Ds=["DELIVERY_DELIVERY_LINE_DETAIL_CHANGED","DELIVERY_LOCAL_PICKUP_DELIVERY_LINE_DETAIL_CHANGED"],vs=["INVALID_PAYMENT: payment.freePaymentMethod.billingAddress","INVALID_PAYMENT: payment.walletPaymentMethod.applePayWalletContent.billingAddress"],qn=["DELIVERY_NO_DELIVERY_STRATEGY_AVAILABLE_FOR_MERCHANDISE_LINE","DELIVERY_OUT_OF_STOCK_AT_ORIGIN_LOCATION","DELIVERY_MUST_FULFILL_FROM_CONSTRAINT_NOT_SATISFIED","DELIVERY_MUST_FULFILL_FROM_SAME_LOCATION_CONSTRAINT_NOT_SATISFIED","DELIVERY_EXTERNAL_PROMISE_UNFULFILLABLE","MERCHANDISE_OUT_OF_STOCK","MERCHANDISE_PRODUCT_VARIANT_NOT_FOUND","MERCHANDISE_NOT_FOUND","MERCHANDISE_PRODUCT_NOT_PUBLISHED","MERCHANDISE_SELLING_PLANS_NOT_SUPPORTED_FOR_B2B","MERCHANDISE_BUNDLE_REQUIRES_COMPONENTS","MERCHANDISE_GIFT_CARDS_COMPONENTS_NOT_SUPPORTED","MERCHANDISE_GIFT_CARD_PRICE_MUST_BE_GREATER_THAN_ZERO","MERCHANDISE_GIFT_CARD_PRICE_MUST_NOT_EXCEED_LIMIT","INVALID: input.lines.0.quantity","MERCHANDISE_NOT_APPLICABLE"],Rs={currency_changed:je.CURRENCY_CHANGE,captcha_required:je.CAPTCHA_REQUIRED,not_enough_stock:je.NOT_ENOUGH_STOCK,cart_not_ready:je.CART_NOT_READY,dynamic_tax:je.DYNAMIC_TAX,cart_throttled:null,out_of_stock:null};function wt({warnings:t,cartStatus:e}){if(e==="CartStatusNotReady")return"cart_not_ready";if(e==="CartThrottled")return"cart_throttled";if(!(!t||t.length===0)){if(t.includes("MERCHANDISE_OUT_OF_STOCK"))return"out_of_stock";if(t.includes("MERCHANDISE_NOT_ENOUGH_STOCK"))return"not_enough_stock"}}function Sr({currentCartTotal:t,initialBuyerCurrency:e}){const n=t.amount;return!(!n||Number(n)===0||e.toUpperCase()===t.currencyCode.toUpperCase())}function M({checkoutUrl:t,instrumentName:e,reason:n}){if(!t)throw new Error("Invalid Checkout URL");const r=new URL(t),a=Rs[n];a&&r.searchParams.set(a,"true"),g.decelerated({instrument:e,reason:n}),ce(r.toString())}class Ns extends Error{constructor(e){super("[".concat(e.name,"] ").concat(e.message)),this.stack=e.stack,this.name="HandleCreateCartError"}}async function pe({element:t,instrumentName:e,dataSource:n}){try{const r=await n.getInitialCart(e),{cart:a,errors:i,warnings:o}=r;ys(()=>{t&&(t.disabled=!1)});const s=Er(i);if(!a&&!s)throw new Error("[".concat(e,"] Failed to create cart"));if(a&&!a.id)throw new Error("[".concat(e,"] received invalid cart"));if(a&&!a.checkoutUrl)throw new Error("[".concat(e,"] Created cart with no checkout URL"));const l=i.length===1&&i[0]===m.InvalidQuantity;if(i.length>0&&!(l||s))throw new Error("Failed to create cart: ".concat(JSON.stringify(i)));return{cart:a,warnings:o,customValidationError:s,decelerationReason:wt({warnings:o})}}catch(r){throw new Ns(r)}finally{t.disabled=!1}}class Ts extends Ut{constructor(){super(),d(this,"name",b.MoreOptions),d(this,"anchor"),d(this,"i18n"),d(this,"dataSource"),d(this,"classNames"),d(this,"setI18n"),d(this,"setDataSource"),d(this,"setClassNames"),[this.i18n,this.setI18n]=ie(),[this.dataSource,this.setDataSource]=ie(),[this.classNames,this.setClassNames]=ie()}static get observedAttributes(){return["disabled"]}connectedCallback(){this.anchor||this.render()}attributeChangedCallback(e,n,r){n!==r&&e==="disabled"&&this.anchor&&(r===""?this.anchor.setAttribute("aria-disabled","true"):this.anchor.removeAttribute("aria-disabled"),this.setAccessibilityAttributes())}async handleClick(e){var n,r;if(e.preventDefault(),this.disabled||!this.anchor)return;this.disabled=!0;const[a,i]=await Promise.all([this.i18n,this.dataSource]);try{const{decelerationReason:o,cart:s,customValidationError:l}=await pe({element:this,instrumentName:b.MoreOptions,dataSource:i});if(l){ve(a,l.message);return}if(o){M({checkoutUrl:(n=s==null?void 0:s.checkoutUrl)!=null?n:"",instrumentName:b.MoreOptions,reason:o});return}const c=this.recommendedInstrument===b.ShopPay?"skip_shop_pay":"allow_redirect";g.sheetClicked({instrument:b.MoreOptions,result:"success"}),ce((r=s==null?void 0:s.checkoutUrl)!=null?r:"",c)}catch(o){g.sheetClicked({instrument:b.MoreOptions,result:"failed"}),w.notify(o),De(a.translate("error_dialogs.checkout.title"),a.translate("error_dialogs.checkout.generic_error"))}}async render(){const e=await this.i18n,n=await this.classNames;this.anchor=document.createElement("a"),this.anchor.textContent=e.translate("more_payment_options"),this.anchor.className=n,this.anchor.setAttribute("id","more-payment-options-link"),this.anchor.onclick=a=>this.handleClick(a),this.setAccessibilityAttributes(),this.appendChild(this.anchor);const r=document.createElement("style");r.textContent=ms,this.appendChild(r)}setAccessibilityAttributes(){this.anchor&&(this.disabled?(this.anchor.removeAttribute("href"),this.anchor.role="link"):(this.anchor.removeAttribute("role"),this.anchor.href="#"))}}var B=(t=>(t.ButtonDisplay="buttonDisplay",t.LoadInstrument="loadInstrument",t.LoadSdk="loadSDK",t.AuthorizationLatency="authorizationLatency",t))(B||{});function jn(){var t,e;return!!((t=window.performance)!=null&&t.mark)&&!!((e=window.performance)!=null&&e.measure)}function $t(t,e){return ht(t,e),()=>de(t,e)}function ht(t,e){jn()&&window.performance.mark("".concat(t,"-").concat(e,"-start"))}function de(t,e){var n,r;if(jn())try{const a="".concat(t,"-").concat(e,"-start"),i="".concat(t,"-").concat(e,"-end"),o="".concat(t,"-").concat(e,"-duration");window.performance.mark(i);const s=(r=window.performance.measure(o,a,i))!=null?r:(n=window.performance.getEntriesByName(o,"measure"))==null?void 0:n[0],l=s==null?void 0:s.duration;return l==null?void 0:l}catch(a){return}}function Ir(t,e,n){if(Je!=null&&Je.length){const r=Je.join(",");t.querySelectorAll(r).forEach(a=>{n===null?a.removeAttribute(e):a.setAttribute(e,n)})}}function ks(t,e){try{const n=JSON.parse(t!=null?t:"[]");if(!(n instanceof Array))throw new Error("[".concat(e,"] invalid walletConfigs found"));return n}catch(n){throw new Error("[".concat(e,"] Error while parsing walletConfigs JSON: ").concat(n))}}function Ls(t,e){try{return t?JSON.parse(t):null}catch(n){throw new Error("[".concat(e,"] Error while parsing walletConfig JSON: ").concat(n))}}function Ct(t,e){var n;const r=e==null?void 0:e.getLoadEligibility(t);return g.instrumentLoadEligibility({instrument:e==null?void 0:e.getInstrumentName(),result:r!=null&&r.eligible?"success":"failed",reason:r!=null&&r.eligible||r==null?void 0:r.reason}),(n=r==null?void 0:r.eligible)!=null?n:!1}function Os(t,e){return e.filter(n=>Ct(t,n))}async function Yn({walletInstrument:t,instanceNumber:e}){const n=t.getInstrumentName(),r=$t(B.LoadSdk,"".concat(n,":").concat(e));try{await t.loadWalletSDK(),g.instrumentSDKLoaded({instrument:n,measurement:r(),result:"success"})}catch(i){return w.notify(i),g.instrumentSDKLoaded({instrument:n,measurement:r(),result:"failed"}),null}let a;try{a=t.getPartnerSDKEligibility()}catch(i){w.notify(i),a={eligible:!1,reason:"uncaught exception"}}return a.eligible?(g.instrumentSDKEligible({instrument:n,result:"success"}),t):(g.instrumentSDKEligible({instrument:n,reason:a.reason,result:"failed"}),null)}function Ve(t,...e){try{const n=window[t];if(typeof n=="function")return new n(...e)}catch(n){}return null}class Pr extends Ut{constructor(){super(),d(this,"apiClient"),d(this,"i18n"),d(this,"policy"),d(this,"isFetchingPolicy",!1),d(this,"intersectionObserver",null),this.mountIntersectionObserver()}get shopId(){return this.getAttribute("shop-id")}get cartId(){return this.getAttribute("cart-id")}get walletConfigs(){return this.getAttribute("wallet-configs")}get recommendedWallet(){return this.getAttribute("recommended")}get fallbackWallet(){return this.getAttribute("fallback")}get variantParams(){var e;try{return JSON.parse((e=this.getAttribute("variant-params"))!=null?e:"[]")}catch(n){throw new gr({code:"invalid-variant-params",message:"variant-params must be a valid JSON string. Received variant-params: ".concat(this.getAttribute("variant-params"),", received error: ").concat(n)})}}get styleExtractorDisabled(){return this.hasAttribute("disable-compat")}get onlySdk(){return this.hasAttribute("only-sdk")}get debug(){return this.hasAttribute("debug")}triggerLoadedEvent(){document.dispatchEvent(new Event("shopify:payment_button:loaded",{bubbles:!0,cancelable:!0}))}async attributeChangedCallback(e,n,r){n!==r&&Ir(this,e,r)}showBuyerConsent(e,n){var r,a,i;!e||!n||(i=(a=(r=window.Shopify)==null?void 0:r.PaymentButton)==null?void 0:a.showBuyerConsent)==null||i.call(a,o=>this.onClickSubscriptionPolicy(o,e,n))}hideBuyerConsent(){var e,n,r;(r=(n=(e=window.Shopify)==null?void 0:e.PaymentButton)==null?void 0:n.hideBuyerConsent)==null||r.call(n)}clearUI(){this.innerHTML=""}async onClickSubscriptionPolicy(e,n,r){if(e.preventDefault(),this.isFetchingPolicy)return;if(this.policy){this.showPolicy(this.policy,r);return}this.isFetchingPolicy=!0;const a=this.fetchSubscriptionPolicy(n).then(i=>(this.policy=i,i)).catch(i=>(w.notify(i),r.translate("subscriptions.policy_not_found"))).finally(()=>{this.isFetchingPolicy=!1});this.showPolicy(a,r)}async fetchSubscriptionPolicy(e){const n=await e.fetchSubscriptionPolicy();return this.policy=n,n}showPolicy(e,n){Ar(n.translate("subscriptions.cancellation_policy"),e,n.translate("subscriptions.policy_not_found"))}mountIntersectionObserver(){this.intersectionObserver=Ve("IntersectionObserver",this.handleIntersection),this.intersectionObserver?this.intersectionObserver.observe(this):j({event:H.FirstVisibleNotAvailable})}handleIntersection(e,n){e.some(r=>r.isIntersecting)&&(n.disconnect(),j({event:H.FirstVisible}))}}function Dr(t){var e,n;Ui({shopId:(e=t.shopId)!=null?e:Nn,cartId:(n=t.cartId)!=null?n:void 0,debug:t.debug,pageType:t.pageType})}function Wn({type:t,form:e}){if(!e)return[];const n=document.querySelectorAll('[name^="'.concat(t,'"][form^="').concat(CSS.escape(e.getAttribute("id")||""),'"]')),r=e.querySelectorAll('[name^="'.concat(t,'"]')),a=[...n,...r],i={};return a.forEach(o=>{const s=xs(o),l=Ms(o);s&&typeof l<"u"&&l.trim()!==""&&(i[s]=l)}),Object.entries(i!=null?i:{}).map(([o,s])=>({key:o,value:s}))}function Bt({page:t,element:e}){const n=t==="product"?'[data-shopify="payment-button"]':'[data-shopify="dynamic-checkout-cart"]',r=Wr(e,n)||document.querySelector(n);return Wr(r,"form")}const Qe=Element.prototype;function Wr(t,e){if(Qe.matches=Qe.matches||Qe.webkitMatchesSelector||Qe.msMatchesSelector||Qe.mozMatchesSelector,!t||t.matches(e))return t;let n=t;for(;n&&n!==document.body;)if(n=n.parentElement,n&&n.matches(e))return n;return null}function xs(t){const e=t.getAttribute("name");if(e===null)return null;const n=e.indexOf("["),r=e.lastIndexOf("]");return n===-1||r===-1?null:e.substring(n+1,r)}function Ms(t){if(!(["radio","checkbox"].includes(t.type)&&!t.checked)&&!(t.value===""||typeof t.value>"u"))return t.value}function vr(t){const e=Bt({page:"product",element:t});return Kn(e)}function Kn(t){var e;const n=t==null?void 0:t.elements;if(!n)return null;const r=_t(n,"id");if(!r||isNaN(Number(r)))return null;const a=Number((e=_t(n,"quantity"))!=null?e:"1"),i="gid://shopify/ProductVariant/".concat(r),o=_t(n,"selling_plan"),s=o?"gid://shopify/SellingPlan/".concat(o):void 0,l=Wn({type:"properties",form:t});return{variantId:r,quantity:a,merchandiseId:i,sellingPlanId:s,lineItemProperties:l}}function Fs(t){const e=t==null?void 0:t.elements;return e?!!_t(e,"selling_plan"):!1}function _t(t,e){var n;const r=t.namedItem(e);return r&&"value"in r&&(n=r.value)!=null?n:null}class Qn{constructor(e,n){d(this,"addToCartMutationObserver"),d(this,"addToCartForm"),d(this,"addToCartButtons"),this.element=e,this.onFormChanged=n,this.addToCartMutationObserver=null,this.addToCartForm=null,this.addToCartButtons=[]}setupMutationObservers(){if(this.findAndSetAddToCartButtons(),!this.addToCartForm)return;this.syncComponentStateWithForm();const e=new MutationObserver(()=>this.reobserveOnFormChanges());this.addToCartMutationObserver=new MutationObserver(()=>this.syncComponentStateWithForm()),e.observe(this.addToCartForm,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),this.observeAddToCartButtons()}syncComponentStateWithForm(){if(!this.addToCartForm){this.onFormChanged({disabled:!0,hasSellingPlan:!1});return}const e=Kn(this.addToCartForm),n=!!(this.addToCartButtons.length>0&&this.addToCartButtons.every(r=>r.hasAttribute("disabled")||r.getAttribute("aria-disabled")==="true"));this.onFormChanged({disabled:n||e===null,hasSellingPlan:Fs(this.addToCartForm),variantId:e==null?void 0:e.variantId,sellingPlanId:e==null?void 0:e.sellingPlanId})}observeAddToCartButtons(){this.addToCartButtons.forEach(e=>{this.addToCartMutationObserver.observe(e,{attributes:!0})})}reobserveOnFormChanges(){var e;(e=this.addToCartMutationObserver)==null||e.disconnect(),this.findAndSetAddToCartButtons(),this.observeAddToCartButtons(),this.syncComponentStateWithForm()}findAndSetAddToCartButtons(){this.addToCartForm=Bt({page:"product",element:this.element}),this.addToCartForm&&(this.addToCartButtons=[...this.addToCartForm.querySelectorAll("[type=submit]")])}}function Us(t,e,n){try{const r=JSON.parse(t!=null?t:"{}"),a=JSON.parse(e!=null?e:JSON.stringify(Tn));if(r===null||Object.keys(r).length===0){if(!(a instanceof Object))throw new Error("[".concat(n,"] Invalid fallback wallet configs JSON"));return{recommendedWallet:null,fallbackWallet:a}}return{recommendedWallet:r,fallbackWallet:a}}catch(r){throw r instanceof SyntaxError?(g.walletConfigDeveloperError(),new gr({code:"invalid-recommended-fallback-json",message:"recommended / fallback must be valid JSON"})):new Error("[".concat(n,"] Error while parsing recommended/fallback JSON: ").concat(r))}}const $s=".shopify-payment-button__button--hidden{visibility:hidden}.shopify-payment-button__button{height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 44px),55px);min-height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 44px),55px);border-radius:var(--shopify-accelerated-checkout-button-border-radius, 0px);width:100%;border:none;box-shadow:0 0 0 0 transparent;color:#fff;cursor:pointer;display:block;font-size:1em;font-weight:500;line-height:1;text-align:center;transition:background .2s ease-in-out}.shopify-payment-button__button[disabled]{opacity:.6;cursor:default}.shopify-payment-button__button--unbranded{background-color:#1990c6;padding:1em 2em}.shopify-payment-button__button--unbranded:hover:not([disabled]){background-color:#136f99}.shopify-payment-button__more-options{background:transparent;border:0 none;cursor:pointer;display:block;font-size:1em;margin-top:1em;text-align:center;text-decoration:underline;width:100%}.shopify-payment-button__more-options.shopify-payment-button__skeleton{height:auto!important;min-height:0!important;border-radius:4px!important;width:50%;margin-left:25%;margin-right:25%}.shopify-payment-button__more-options[disabled]{opacity:.6;cursor:default!important}.shopify-payment-button__button.shopify-payment-button__button--branded{display:flex;flex-direction:column;position:relative;z-index:1}.shopify-payment-button__button.shopify-payment-button__button--branded .shopify-cleanslate{flex:1!important;display:flex!important;flex-direction:column!important}.shopify-payment-button__button.button.loading{position:relative;color:transparent}.shopify-payment-button__button.button.loading>.loading-overlay__spinner{top:50%;left:50%;transform:translate(-50%,-50%);position:absolute;height:100%;display:flex;align-items:center}.shopify-payment-button__button.button.loading>.loading-overlay__spinner .spinner{width:-moz-fit-content;width:-webkit-fit-content;width:fit-content}.button.loading>.loading-overlay__spinner .path{stroke:#fff}.shopify-payment-button__button .loading-overlay__spinner{width:1.8rem;display:inline-block}.shopify-payment-button__button .spinner{animation:shopify-rotator 1.4s linear infinite}@keyframes shopify-rotator{0%{transform:rotate(0)}to{transform:rotate(270deg)}}.shopify-payment-button__button .path{stroke-dasharray:280;stroke-dashoffset:0;transform-origin:center;stroke:#121212;animation:shopify-dash 1.4s ease-in-out infinite}@media screen and (forced-colors: active){.shopify-payment-button__button .path{stroke:CanvasText}}@keyframes shopify-dash{0%{stroke-dashoffset:280}50%{stroke-dashoffset:75;transform:rotate(135deg)}to{stroke-dashoffset:280;transform:rotate(450deg)}}#shopify-buyer-consent{margin-top:1em;display:inline-block;width:100%}#shopify-buyer-consent.hidden{display:none}#shopify-subscription-policy-button{background:none;border:none;padding:0;text-decoration:underline;font-size:inherit;cursor:pointer}#shopify-subscription-policy-button:before{box-shadow:none}@keyframes acceleratedCheckoutLoadingSkeleton{50%{opacity:var(--shopify-accelerated-checkout-skeleton-animation-opacity-start, 1)}75%{opacity:var(--shopify-accelerated-checkout-skeleton-animation-opacity-end, .5)}to{opacity:var(--shopify-accelerated-checkout-skeleton-animation-opacity-start, 1)}}.shopify-payment-button__skeleton{animation:acceleratedCheckoutLoadingSkeleton var(--shopify-accelerated-checkout-skeleton-animation-duration, 4s) var(--shopify-accelerated-checkout-skeleton-animation-timing-function, ease) infinite;animation-delay:-.168s;background-color:var(--shopify-accelerated-checkout-skeleton-background-color, #dedede);box-sizing:border-box;text-decoration:none!important;height:var(--shopify-accelerated-checkout-button-block-size, inherit);min-height:25px;max-height:55px;border-radius:var( --shopify-accelerated-checkout-button-border-radius, inherit )}",Bs='.accelerated-checkout-button{height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 44px),55px);min-height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 44px),55px);border-radius:var(--shopify-accelerated-checkout-button-border-radius, 0px);box-shadow:var(--shopify-accelerated-checkout-button-box-shadow);min-width:150px}:host([page-type="cart_page"]) .accelerated-checkout-button{height:100%;width:100%;border-radius:var(--shopify-accelerated-checkout-button-border-radius, 4px);box-shadow:var(--shopify-accelerated-checkout-button-box-shadow)}@media (forced-colors: active){.accelerated-checkout-button{border:1px solid transparent!important}:host([page-type="cart_page"]) .accelerated-checkout-button{border:1px solid transparent!important}}',Hs=70;class rt{constructor(e,n,r,a){d(this,"red"),d(this,"green"),d(this,"blue"),d(this,"opacity"),this.red=e||0,this.green=n||0,this.blue=r||0,this.opacity=typeof a>"u"?1:a}getLuminance(){const e=this.red&255,n=this.green&255,r=this.blue&255;return e*.2126+n*.7152+r*.0722}isDark(){return this.opacity===0?!1:this.getLuminance()/this.opacity0&&a.opacity>0?(r=new rt(0,0,0,0),r.blendWith(a,n)):a.opacity>0?r=a:r=n,n=r,a=e.shift();return r}const ar=new rt(255,255,255,1);function Vs(t){const e=[];let n=t;for(;n.parentElement;){n=n.parentElement;const r=window.getComputedStyle(n).backgroundColor,a=zs(r);if(r&&e.push(a),a.opacity===1)break}try{return Gs(e.reverse())}catch(r){return w.notify(new Xn("[BackgroundDetection] Failed to blend colors for element ".concat(t.outerHTML),{cause:r})),ar}}function zs(t){if(!t)return ar;try{const e=t.split("(")[1].split(")")[0].replace(" ","").split(",");return new rt(Number(e[0]),Number(e[1]),Number(e[2]),typeof e[3]>"u"?1:Number(e[3]))}catch(e){w.notify(new Xn("[BackgroundDetection] Failed to convert rgbString to array ".concat(t),{cause:e}))}return ar}class Xn extends Error{constructor(){super(...arguments),d(this,"name","ColorProcessingError")}}class Re extends Ut{constructor(){super(),d(this,"name",null),d(this,"i18n"),d(this,"dataSource"),d(this,"apiClient"),d(this,"classNames"),d(this,"containerInstanceNumber"),d(this,"onRendered"),d(this,"setI18n"),d(this,"setDataSource"),d(this,"setApiClient"),d(this,"setClassNames"),d(this,"setContainerInstanceNumber"),d(this,"parsedWalletParams"),this.onRendered=()=>{},[this.i18n,this.setI18n]=ie(),[this.dataSource,this.setDataSource]=ie(),[this.apiClient,this.setApiClient]=ie(),[this.classNames,this.setClassNames]=ie(),[this.containerInstanceNumber,this.setContainerInstanceNumber]=ie()}async cleanupOnFailure(e,n){var r;try{await e()}catch(a){w.notify(new qs("An error occurred requiring cleanup when attempting to render the ".concat(n," instrument: ").concat(a),{cause:a}));const i=await this.containerInstanceNumber;g.instrumentLoaded({instrumentOrComponentName:n,result:"failed",measurement:de(B.ButtonDisplay,"".concat(n,":").concat(i))}),(r=this.parentElement)==null||r.remove()}}attributeChangedCallback(e,n,r,a){n!==r&&e==="disabled"&&a&&(r===""?(a.setAttribute("aria-disabled","true"),a.setAttribute("disabled","")):(a.removeAttribute("aria-disabled"),a.removeAttribute("disabled")))}get pageType(){return this.getAttribute("page-type")||S.Unknown}get buttonTheme(){return Vs(this).isDark()?"LIGHT":"DARK"}get isCTA(){return this.hasAttribute("call-to-action")}get walletParams(){var e;if(this.parsedWalletParams===void 0)try{this.parsedWalletParams=JSON.parse((e=this.getAttribute("wallet-params"))!=null?e:"{}")}catch(n){throw new Error("Error while parsing wallet-params JSON: ".concat(n))}return this.parsedWalletParams}async initializeShadowStyles(e,n=""){const r=document.createElement("style");r.innerHTML=[Bs,n].join("\n"),e.appendChild(r)}async ensureLightDOMIsNotEmpty(){this.textContent="\xA0"}dispatchWalletEvent({eventName:e,detail:n={}}){var r;(r=this.parentElement)==null||r.dispatchEvent(new CustomEvent(e,{detail:n}))}}class qs extends Error{constructor(){super(...arguments),d(this,"name","CleanupOnFailureError")}}class js extends Re{constructor(){super(...arguments),d(this,"name",b.BuyItNow),d(this,"button",null)}static get observedAttributes(){return["disabled"]}connectedCallback(){this.cleanupOnFailure(this.render.bind(this),this.name)}attributeChangedCallback(e,n,r){super.attributeChangedCallback(e,n,r,this.button)}async handleClick(){var e,n;if(this.disabled||!this.button||this.button.getAttribute("aria-disabled"))return;this.disabled=!0;const[r,a]=await Promise.all([this.i18n,this.dataSource]);try{const{decelerationReason:i,cart:o,customValidationError:s}=await pe({element:this,instrumentName:this.name,dataSource:a});if(g.sheetClicked({instrument:this.name,result:"success"}),s){ve(r,s.message);return}if(i){M({checkoutUrl:(e=o==null?void 0:o.checkoutUrl)!=null?e:"",instrumentName:this.name,reason:i});return}ce((n=o==null?void 0:o.checkoutUrl)!=null?n:"","allow_redirect")}catch(i){w.notify(i),g.sheetClicked({instrument:this.name,result:"failed"}),De(r.translate("error_dialogs.checkout.title"),r.translate("error_dialogs.checkout.generic_error"))}}async render(){var e;this.button||(this.button=Mt());const n=await this.classNames;this.button.textContent=(await this.i18n).translate("instruments_copy.checkout.buy_now"),this.button.className=n,this.disabled&&this.button.setAttribute("aria-disabled","true"),this.button.onclick=()=>this.handleClick(),this.appendChild(this.button),(e=this.onRendered)==null||e.call(this)}}function Ys(){const t=navigator.userAgent,e=t.indexOf("Android")>-1,n=t.indexOf("Chrome/")>-1,r=parseInt((/Chrome\/([0-9]+)/.exec(t)||["0","0"])[1],10);return e&&n&&r===114}class me{constructor(e){d(this,"walletParams"),this.walletParams=e.wallet_params}static walletName(){throw new Error("Must define walletName for WalletInstrument subclass")}createWebComponent({walletContainer:e,dataSource:n,i18n:r,apiClient:a,containerInstanceNumber:i,classNames:o="",callToAction:s,pageType:l=S.ProductPage,slot:c="button",onRendered:u=()=>{}}){var h,p,y;const E=this.getWebComponentName();he(E,this.getWebComponentClass(),{isChildCustomElement:!0});const f=document.createElement(E),A={"access-token":(h=e.accessToken)!=null?h:"","buyer-country":(p=e.buyerCountry)!=null?p:"","buyer-currency":e.buyerCurrency,"wallet-params":JSON.stringify((y=this.walletParams)!=null?y:{}),"page-type":l,slot:c};try{e.disabled&&f.setAttribute("disabled",""),Ft(f,A),e.isShippingRequired&&f.setAttribute("requires-shipping",""),e.hasSellingPlan&&f.setAttribute("has-selling-plan",""),e.pciEnabled&&f.setAttribute("pci-enabled","")}catch(I){const O=I;throw O.message.includes("setAttribute is not a function")&&Ys()?new Tt(O.message):O}return s&&f.setAttribute("call-to-action",""),f.setDataSource(n),f.setApiClient(a),f.setI18n(r),f.setClassNames(o),f.setContainerInstanceNumber(i),f.onRendered=u,f}loadWalletSDK(){return Promise.resolve()}getLoadEligibility(e){return{eligible:!0}}getPartnerSDKEligibility(){return{eligible:!0}}}class Ws extends me{static walletName(){return"buy_it_now"}getWebComponentName(){return"shopify-buy-it-now-button"}getInstrumentName(){return b.BuyItNow}getWebComponentClass(){return js}}const Ks="shopify-paypal-button[disabled]{opacity:.5;cursor:not-allowed}shopify-paypal-button div.paypal-buttons>iframe{z-index:auto!important;border-radius:0!important;box-shadow:none}",Qs="::slotted(div){height:100%}";async function xe(t){const{cartId:e,cartClient:n,instrumentName:r,abortSignal:a}=t;try{if(!e)throw new Error("[".concat(r,"] provided no cart ID when updating buyer identity"));if(!n)throw new Error("[".concat(r,"] provided invalid cart client when updating buyer identity"));return await n.updateCartBuyerIdentity(t,a)}catch(i){throw g.updateFailed(r,"updateBuyerIdentity"),i}}async function Rr({cartId:t,totalAmount:e,paymentMethod:n,billingAddress:r,cartClient:a,instrumentName:i,abortSignal:o,hasSellingPlan:s,canUsePaymentMethodForFreeOrder:l}){try{if(!t)throw new Error("[".concat(i,"] provided no cart ID when updating payment"));if(!e)throw new Error("[".concat(i,"] provided no total amount when updating payment"));if(!n)throw new Error("[".concat(i,"] provided no apple pay wallet content when updating payment"));if(!a)throw new Error("[".concat(i,"] provided invalid cart client when updating payment"));const c={freePaymentMethod:{billingAddress:r}};return await a.updateCartPayment(t,_({amount:{amount:e.amount,currencyCode:e.currencyCode}},Number(e.amount)<=0&&!l&&!s?c:n),i,o)}catch(c){throw g.updateFailed(i,"updatePayment"),c}}function Jn(t){return window[Zn(t)]}function Zn(t){return"paypal-".concat(t.replace(/[^a-zA-Z0-9]/g,""))}function St(t){if(!t)return null;const e=getComputedStyle(t).borderRadius;return e.includes("px")?parseInt(e,10):null}function It(t){if(!t)return null;const e=getComputedStyle(t).height;return e.includes("px")?parseInt(e,10):null}const Kt=25,Kr=55,Xs=["cart_not_ready","cart_throttled"];var be;class Js extends Re{constructor(){super(),d(this,"name",b.PayPal),d(this,"abortController"),d(this,"cartId"),d(this,"sdkButtonsComponent"),d(this,"container",null),d(this,"resizeObserver",null),d(this,"buttonHeight"),d(this,"rendering",!1),d(this,"prevBorderRadius",0),d(this,"prevHeight",0),x(this,be),L(this,be,this.attachShadow({mode:"closed"})),this.abortController=Ve("AbortController"),this.resizeObserver=Ve("ResizeObserver",()=>this.onResize())}connectedCallback(){this.cleanupOnFailure(this.render.bind(this),this.name)}async disconnectedCallback(){this.innerHTML="",C(this,be).innerHTML="",await this.teardownPayPalButton(),this.resizeObserver&&this.resizeObserver.disconnect()}async teardownPayPalButton(){var e;try{await((e=this.sdkButtonsComponent)==null?void 0:e.close().catch(()=>{}))}catch(n){}finally{this.sdkButtonsComponent=void 0}}async onResize(){const e=St(this.container),n=It(this.container),r=e!==null&&this.prevBorderRadius!==e||n!==null&&this.prevHeight!==n;!this.rendering&&r&&(await this.teardownPayPalButton(),this.container.innerHTML="",await this.cleanupOnFailure(()=>this.renderFromPayPalSDK(),this.name))}async render(){var e;const n=document.createElement("div");n.className=Pe.BUTTON;const r=document.createElement("style");r.innerHTML=Ks,this.appendChild(r),await this.initializeShadowStyles(C(this,be),Qs),C(this,be).appendChild(n),this.container=n,this.renderFromPayPalSDK(),(e=this.resizeObserver)==null||e.observe(this.container)}getHeight(){const e=It(this.container);return e?e>=Kt&&e<=Kr?e:ethis.createToken(this.apiClient);let i,o;this.requiresBillingAgreement()?o=a:i=a;const s=St(this.container),l=this.getHeight();this.prevHeight=l;const c={color:"gold",label:this.isCTA?"pay":"paypal",disableMaxWidth:!0,height:l,shape:"sharp"};s&&s>0&&(c.borderRadius=s,this.prevBorderRadius=s),this.sdkButtonsComponent=(n=(e=Jn(this.walletParams.sdkUrl))==null?void 0:e.Buttons)==null?void 0:n.call(e,{fundingSource:"paypal",style:c,createOrder:i,createBillingAgreement:o,onApprove:async u=>{await this.onApprove(u)},onCancel:()=>{var u;g.sheetCancelled(this.name),(u=this.abortController)==null||u.abort()},onClick:this.onClick.bind(this),onError:this.onError.bind(this)}),await((r=this.sdkButtonsComponent)==null?void 0:r.render(this.container)),this.rendering=!1,this.onRendered()}async onClick(e,n){var r,a;if(this.disabled)return n.reject();const i=this.getBoundingClientRect(),o=i.left+i.width/2,s=i.top+i.height/2,l=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1,clientX:o,clientY:s,screenX:window.screenX+o,screenY:window.screenY+s});this.dispatchEvent(l);const[c,u]=await Promise.all([this.dataSource,this.i18n]);try{const{decelerationReason:h,cart:p,customValidationError:y}=await pe({element:this,instrumentName:this.name,dataSource:c});if(y)return ve(u,y.message),n.reject();const{hasManagedSellingPlanState:E}=this.walletParams;return E!=null&&E!==this.hasSellingPlan?(ce((r=p==null?void 0:p.checkoutUrl)!=null?r:""),n.reject()):h?(M({checkoutUrl:(a=p==null?void 0:p.checkoutUrl)!=null?a:"",instrumentName:this.name,reason:h}),n.reject()):(this.cartId=p.id,n.resolve())}catch(h){return g.sheetClicked({instrument:this.name,result:"failed"}),w.notify(h),De(u.translate("error_dialogs.checkout.title"),u.translate("error_dialogs.checkout.generic_error")),n.reject()}}async createToken(e){const n=await e;try{if(!this.cartId)throw new Error("cartId not found when creating token");const r=await n.paypalTokenCreate(this.cartId);return g.sheetClicked({instrument:this.name,result:"success"}),r}catch(r){throw g.sheetClicked({instrument:this.name,result:"failed"}),r}}async onApprove({orderID:e,payerID:n,billingToken:r}){var a;try{if(g.authorizationAttempt(this.name),ht(B.AuthorizationLatency,this.name),!this.cartId)throw new Error("Cart not found");const i=await this.apiClient,o=this.requiresBillingAgreement()&&r!=null?r:e,{billingAddress:s,destinationAddress:l,expiresAt:c,email:u,remoteOrderId:h}=await i.paypalBuyerDetailsFetch(o,this.cartId),{data:p,decelerationReason:y}=await xe({cartId:this.cartId,cartClient:i,instrumentName:this.name,emailAddress:u,streetAddress:l});if(!p)throw new Error("Cart not found");const{id:E,checkoutUrl:f,totalAmount:A}=p;if(this.shouldDecelerate(y)){M({checkoutUrl:f,instrumentName:this.name,reason:y});return}const{decelerationReason:I}=await Rr({abortSignal:(a=this.abortController)==null?void 0:a.signal,cartClient:i,cartId:E,instrumentName:b.PayPal,billingAddress:s!=null?s:l,paymentMethod:{walletPaymentMethod:{paypalWalletContent:{billingAddress:s!=null?s:l,email:u,expiresAt:c,payerId:n,token:h!=null?h:e,acceptedSubscriptionTerms:!1,vaultingAgreement:!1,merchantId:this.walletParams.merchantId}}},canUsePaymentMethodForFreeOrder:!0,totalAmount:A});if(this.shouldDecelerate(I)){M({checkoutUrl:f,instrumentName:this.name,reason:I});return}if(Sr({currentCartTotal:A,initialBuyerCurrency:this.buyerCurrency})){M({checkoutUrl:f,instrumentName:this.name,reason:"currency_changed"});return}g.authorizationComplete({instrument:this.name,result:"success",measurement:de(B.AuthorizationLatency,this.name)}),ce(f)}catch(i){throw g.authorizationComplete({instrument:this.name,result:"failed",measurement:de(B.AuthorizationLatency,this.name)}),i}}async onError(e){var n;if(e.message==="Window is closed, can not determine type"){g.sheetCancelled(this.name),(n=this.abortController)==null||n.abort();return}e.message==="RESTRICTED_WALLET_ACCOUNT"?g.log({body:"PayPal modal closed due to error: ".concat(e)}):w.notify(e);const r=await this.i18n,a=r.translate("brand.paypal");J(a,r)}requiresBillingAgreement(){return this.walletParams.hasManagedSellingPlanState||this.walletParams.requiresBillingAgreement}shouldDecelerate(e){return!!(e&&Xs.includes(e))}}be=new WeakMap;const Te=class eu extends me{static walletName(){return"paypal"}constructor(e){super(e)}getWebComponentName(){return"shopify-paypal-button"}getInstrumentName(){return b.PayPal}getWebComponentClass(){return Js}loadWalletSDK(){let e=eu.paypalSDKPromiseByUrl.get(this.walletParams.sdkUrl);if(e)return e;const n=document.createElement("script");return n.setAttribute("src",this.walletParams.sdkUrl),e=new Promise((r,a)=>{n.setAttribute("data-namespace",Zn(this.walletParams.sdkUrl)),n.onload=()=>r(),n.onerror=i=>{eu.paypalSDKPromiseByUrl.delete(this.walletParams.sdkUrl),n&&document.body.contains(n)&&document.body.removeChild(n),a(i)},document.body.appendChild(n)}),eu.paypalSDKPromiseByUrl.set(this.walletParams.sdkUrl,e),e}getLoadEligibility(){return{eligible:!0}}getPartnerSDKEligibility(){var e,n;try{return(n=(e=Jn(this.walletParams.sdkUrl))==null?void 0:e.Buttons)!=null&&n.call(e).isEligible()?{eligible:!0}:{eligible:!1,reason:"PayPal SDK not eligible"}}catch(r){throw new gr({code:"paypal-sdk-eligibility-check-failed",message:"PayPal SDK 'isEligible' method failed unexpectedly: ".concat(r)})}}};d(Te,"paypalSDKPromiseByUrl",new Map);let ir=Te;const Zs=".apple-pay-button{display:flex;align-items:center;justify-content:center;width:100%;padding:0!important;cursor:pointer;border:none}.apple-pay-button:hover:not(:disabled){filter:brightness(92%)}.apple-pay-button:disabled{opacity:.5;cursor:not-allowed}.apple-pay-button svg{height:100%;flex-shrink:0}.apple-pay--content{font-size:16px;font-family:San Francisco,sans-serif;width:100%;height:100%;flex-grow:1;display:flex;align-items:center;justify-content:center;white-space:pre}.apple-pay--light{background:#fff;color:#000}.apple-pay--light svg{fill:#000}.apple-pay--dark{background:#000;color:#fff}.apple-pay--dark svg{fill:#fff}",or={UK:"GB",JA:"JP"},ea=["AS","GU","MP","PR","VI"];ea.forEach(t=>{or[t]="US"});function gt(t){var e,n;const r=t.countryCode,a={firstName:t.givenName||void 0,lastName:t.familyName||void 0,address1:(e=t==null?void 0:t.addressLines)==null?void 0:e[0],address2:((n=t==null?void 0:t.addressLines)==null?void 0:n[1])||void 0,city:t.locality||void 0,zip:t.postalCode||void 0,province:t.administrativeArea||t.subLocality||void 0,country:el(t.countryCode),phone:t.phoneNumber||void 0};return a.country==="HK"&&(a.zip=void 0,a.province=t.postalCode),r&&ea.includes(r)&&(a.province=r),a.lastName||(a.lastName=a.firstName),a}function el(t){if(!t)return"ZZ";const e=t.toUpperCase();return Object.keys(or).includes(e)?or[e]:e}function tl(t,e){return t.map(n=>{const{title:r,deliveryPromise:a}=al(n,e);return{title:r,estimatedCost:{amount:nl(n),currencyCode:n[0].estimatedCost.currencyCode},handle:ra(n),deliveryPromise:a}})}function rl(t,e){return t.map(n=>{const{title:r,description:a}=il(n,e);return{title:r,description:a,handle:ra(n)}})}function ta({deliveryGroups:t}){return t.map(e=>e.deliveryOptions.filter(({deliveryMethodType:n})=>n==="SHIPPING").map(n=>T(_({},n),{groupType:e.groupType}))).reduce((e,n)=>e.flatMap(r=>n.map(a=>[...r,a])),[[]])}function nl(t){return t.reduce((e,n)=>e+Number(n.estimatedCost.amount),0).toFixed(2)}function al(t,e){const n=t.find(l=>l.groupType===Ie.OneTimePurchase),r=t.find(l=>l.groupType===Ie.Subscription),a=[...new Set([n==null?void 0:n.title,r==null?void 0:r.title])].filter(Boolean),i=[...new Set([n==null?void 0:n.deliveryPromise,r==null?void 0:r.deliveryPromise])].filter(Boolean),o=a.length===2?e.translate("shipping_methods.connect_shipping_methods",{methodOne:a[0],methodTwo:a[1]}):a[0],s=i.length===2?e.translate("delivery_promises.connect_delivery_promises",{promiseOne:i[0],promiseTwo:i[1]}):i[0];return{title:o,deliveryPromise:s}}function il(t,e){const n=t.find(o=>o.groupType===Ie.OneTimePurchase),r=t.find(o=>o.groupType===Ie.Subscription),a=t.map(ol).filter(Boolean).join(", ");let i=(n==null?void 0:n.title)||(r==null?void 0:r.title);return n&&r&&(i=e.translate("shipping_methods.connect_shipping_methods",{methodOne:n.title,methodTwo:r.title})),{title:i,description:a}}function ol(t){const e=Number(t.estimatedCost.amount).toFixed(2),n=t.estimatedCost.currencyCode,r=t.deliveryPromise;return r?"(".concat(r,") ").concat(e," ").concat(n):"".concat(e," ").concat(n)}function ra(t){return t.map(e=>e.handle).join(",")}function na({deliveryGroups:t,i18n:e}){const n=t.some(r=>r.groupType===Ie.Subscription);return t.map(r=>{var a;let i=e.translate("order_summary.shipping");return n&&(i=r.groupType===Ie.Subscription?e.translate("order_summary.shipping_subscription"):e.translate("order_summary.shipping_one_time_purchase")),{label:i,amount:Se(((a=r.selectedDeliveryOption)==null?void 0:a.estimatedCost.amount)||0)}})}function sl(t,e){return et({label:t,possibleLines:[e]})[0]}function ll({subtotal:t,deliveryGroups:e,duties:n,taxes:r,discountAllocations:a,i18n:i,formattedRecurringTotals:o}){var s;const l=et({label:i.translate("order_summary.subtotal"),possibleLines:[t]}),c=na({deliveryGroups:e,i18n:i}),u=et({label:i.translate("order_summary.duties"),possibleLines:[n]}),h=et({label:i.translate("order_summary.taxes"),possibleLines:[r]}),p=o.map(f=>({label:f,amount:"0.00",type:"pending"})),y=p.length?[{label:i.translate("order_summary.subscriptions.recurring_total_tooltip_line"),amount:"0.00",type:"pending"}]:[],E=(s=a==null?void 0:a.flatMap(f=>{var A;const I=(A=f.title)!=null?A:f.code;return et({label:I!=null?I:i.translate("order_summary.discount"),possibleLines:[f.discountedAmount],isDiscount:!0})}))!=null?s:[];return[...l,...c,...u,...h,...E,...p,...y]}function et({label:t,possibleLines:e,isDiscount:n=!1}){return e.filter(r=>(r==null?void 0:r.amount)!==void 0).map(r=>({label:t,amount:n?"-".concat(Se(r.amount)):Se(r.amount)}))}function cl(t,e){if(!t.length)return[];const n=ta({deliveryGroups:t});return tl(n,e).map(r=>{var a;return{label:r.title||"",amount:r.estimatedCost.amount,identifier:r.handle,detail:(a=r.deliveryPromise)!=null?a:""}})}const Qt=async({paymentSheetAction:t,onProceed:e,terminateSession:n})=>{switch(t.action){case"abort":n();break;case"show_error":await e(t.errors);break;case"update":await e(t.errors);break;default:throw new Error('Missing handler for payment sheet action "'.concat(t.action,'"'))}},dl=["decelerate","abort","show_error","complete","update"];class Pt extends Error{constructor(){super(...arguments),d(this,"name","UnhandledActionError")}}class aa{constructor(){d(this,"generatePrioritizedPaymentSheetAction",(e,n)=>{let r;const a=[],i=[],o=[],s=n.filter(c=>c!==m.UnacceptablePaymentsAmount).some(c=>e[c]!==void 0);for(const c of Object.keys(e))if(!(c===m.UnacceptablePaymentsAmount&&s)){const u=e[c]();u.effects&&i.push(...u.effects),u.action!=="complete"&&u.errors&&o.push(...u.errors),a.push(u)}const l=(c=>dl.map(u=>c.find(h=>h.action===u)).find(u=>!!u))(a);return l&&(r=l,r.effects=i,r.action!=="complete"&&(r.errors=o)),r})}getMergedPaymentSheetAction({result:e,errorActions:n}){const r={};n.forEach(i=>{i.errors.forEach(o=>{e.errors.includes(o)&&(r[o]=i.generateAction)})});let a;for(const i of e.errors){const o=r[i];if(o){a=o();break}}return{firstPaymentSheetAction:a,prioritizedPaymentSheetAction:this.generatePrioritizedPaymentSheetAction(r,e.errors)}}getUnhandledErrors(e,n){const r=n.flatMap(a=>a.errors);return e.filter(a=>!r.includes(a))}decelerateOrAbort({reason:e,instrumentName:n,errorOrWarning:r,result:a}){var i,o;return a?((i=a.data)==null?void 0:i.__typename)==="SubmitFailed"?{action:"decelerate",redirectUrl:(o=a.data)==null?void 0:o.checkoutUrl,reason:e}:{action:"abort",effects:[()=>{var s;w.notify(new Error("[".concat(n,"] unexpected ").concat(r," received in ").concat((s=a.data)==null?void 0:s.__typename," response, aborting")))}]}:{action:"abort"}}}class ul extends aa{constructor(e){super(),d(this,"completionResult"),this.i18n=e,this.completionResult=null}mapMutationResultToPaymentSheetAction(e,n){var r;const a=this.mapCustomValidationFunctionErrorToAction(e.errors);if(a)return a;const i=this.getErrorActions({shippingCountryCode:n==null?void 0:n.shippingCountryCode}),o=e.errors,s=this.getUnhandledErrors(o,i);if(s.forEach(c=>{w.notify(new Pt("[".concat(b.ApplePay,"] mutation result error not handled: ").concat(c)))}),((r=e.data)==null?void 0:r.deliveryGroups.length)===0&&n!=null&&n.shippingRequired)return{action:"show_error",errors:[new ApplePayError("addressUnserviceable")]};const{firstPaymentSheetAction:l}=this.getMergedPaymentSheetAction({result:e,errorActions:i});return l||(s.length>0?{action:"abort"}:{action:"update",errors:[]})}mapCompletionResultToPaymentSheetAction(e,n){if(!e.data)throw new Error("[".concat(b.ApplePay,"] completion returned null result"));switch(this.completionResult=e,e.data.__typename){case"SubmitSuccess":return{action:"complete",redirectUrl:e.data.redirectUrl};case"SubmitAlreadyAccepted":case"SubmitThrottled":case"SubmitFailed":{const r=this.mapCustomValidationFunctionErrorToAction(e.errors);if(r)return r;const a=this.getErrorActions({shippingCountryCode:n==null?void 0:n.shippingCountryCode}),i=e.errors;this.getUnhandledErrors(i,a).forEach(s=>{w.notify(new Error("[".concat(b.ApplePay,"] completion result error not handled: ").concat(s)))});const{prioritizedPaymentSheetAction:o}=this.getMergedPaymentSheetAction({result:e,errorActions:a});return o||{action:"abort"}}default:throw new Error("[".concat(b.ApplePay,"] unknown completion result type: ").concat(e.data.__typename))}}getErrorActions({shippingCountryCode:e}){return[{errors:[m.CaptchaCompletionRequired],generateAction:()=>this.decelerateOrAbort({reason:"captcha_required",instrumentName:b.ApplePay,errorOrWarning:m.CaptchaCompletionRequired,result:this.completionResult})},{errors:[m.InvalidLanguage],generateAction:()=>({action:"abort",effects:[()=>{w.notify(new Error("[".concat(b.ApplePay,"] mutation provided invalid language, aborting")))}]})},{errors:[m.InvalidCountry],generateAction:()=>({action:"abort",effects:[()=>{w.notify(new Error("[".concat(b.ApplePay,"] mutation provided invalid country, aborting")))}]})},{errors:[m.MissingCartId],generateAction:()=>({action:"abort",effects:[()=>{w.notify(new Error("[".concat(b.ApplePay,"] mutation provided invalid cart ID, aborting")))}]})},{errors:Cr,generateAction:()=>this.decelerateOrAbort({reason:"dynamic_tax",instrumentName:b.ApplePay,errorOrWarning:m.NewTaxMustBeAccepted,result:this.completionResult})},{errors:zn,generateAction:()=>({action:"abort"})},{errors:[m.MerchandiseNotEnoughStock],generateAction:()=>this.decelerateOrAbort({reason:"not_enough_stock",instrumentName:b.ApplePay,errorOrWarning:m.MerchandiseNotEnoughStock,result:this.completionResult})},{errors:qn,generateAction:()=>this.decelerateOrAbort({reason:"out_of_stock",instrumentName:b.ApplePay,errorOrWarning:m.MerchandiseOutOfStock,result:this.completionResult})},{errors:Vn,generateAction:()=>({action:"show_error",errors:[new ApplePayError("addressUnserviceable")]})},{errors:[m.BuyerIdentityEmailRequired],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","emailAddress",this.i18n.translate("errors.missing.email"))]})},{errors:gs,generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","name",this.i18n.translate("errors.missing.first_name"))]})},{errors:fs,generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","name",this.i18n.translate("errors.invalid.first_name"))]})},{errors:bs,generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","name",this.i18n.translate("errors.missing.last_name"))]})},{errors:ws,generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","name",this.i18n.translate("errors.invalid.last_name"))]})},{errors:_s,generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","addressLines",this.i18n.translate("errors.missing.address1"))]})},{errors:[m.DeliveryAddress1Invalid],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","addressLines",this.i18n.translate("errors.invalid.address1"))]})},{errors:Es,generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","addressLines",this.i18n.translate("errors.missing.address2"))]})},{errors:[m.DeliveryAddress2Invalid],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","addressLines",this.i18n.translate("errors.invalid.address2"))]})},{errors:As,generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","locality",this.i18n.translate("errors.missing.city"))]})},{errors:[m.DeliveryCityInvalid],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","locality",this.i18n.translate("errors.invalid.city"))]})},{errors:[m.DeliveryZoneRequiredForCountry],generateAction:()=>({action:"show_error",errors:[this.createApplePayZoneError(this.i18n.translate("errors.missing.zone"),this.i18n.translate("errors.missing.emirate"),"shippingContactInvalid",e)]})},{errors:[m.DeliveryZoneNotFound],generateAction:()=>({action:"show_error",errors:[this.createApplePayZoneError(this.i18n.translate("errors.invalid.zone"),this.i18n.translate("errors.invalid.emirate"),"shippingContactInvalid",e)]})},{errors:Cs,generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","postalCode",this.i18n.translate("errors.missing.postal_code"))]})},{errors:Gn,generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","postalCode",this.i18n.translate("errors.invalid.postal_code"))]})},{errors:[m.DeliveryCountryRequired],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","country",this.i18n.translate("errors.missing.country"))]})},{errors:Ss,generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","phoneNumber",this.i18n.translate("errors.missing.phone"))]})},{errors:Ps,generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","phoneNumber",this.i18n.translate("errors.invalid.phone"))]})},{errors:Is,generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","country",this.i18n.translate("errors.invalid.country"))]})},{errors:vs,generateAction:()=>({action:"show_error",errors:[new ApplePayError("billingContactInvalid")]})},{errors:[m.UnsupportedApplePayPaymentMethod],generateAction:()=>({action:"abort",effects:[()=>{J(this.i18n.translate("brand.apple_pay"),this.i18n)},()=>{w.notify(new Pt("[".concat(b.ApplePay,"] payment method is not supported")))}]})},{errors:[m.DeliveryLastNameContainsEmojis],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","name",this.i18n.translate("errors.emojis.last_name"))]})},{errors:[m.DeliveryFirstNameContainsEmojis],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","name",this.i18n.translate("errors.emojis.first_name"))]})},{errors:[m.DeliveryAddress1TooLong],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","addressLines",this.i18n.translate("errors.too_long.address1"))]})},{errors:[m.DeliveryAddress2TooLong],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","addressLines",this.i18n.translate("errors.too_long.address2"))]})},{errors:[m.DeliveryFirstNameTooLong],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","name",this.i18n.translate("errors.too_long.first_name"))]})},{errors:[m.DeliveryLastNameTooLong],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","name",this.i18n.translate("errors.too_long.last_name"))]})},{errors:[m.DeliveryCityTooLong],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","locality",this.i18n.translate("errors.too_long.city"))]})},{errors:[m.DeliveryFirstNameContainsUrl],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","name",this.i18n.translate("errors.url.first_name"))]})},{errors:[m.DeliveryLastNameContainsUrl],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","name",this.i18n.translate("errors.url.last_name"))]})},{errors:[m.DeliveryAddress1ContainsHtmlTags],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","addressLines",this.i18n.translate("errors.html_tags.address1"))]})},{errors:[m.DeliveryAddress2ContainsHtmlTags],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","addressLines",this.i18n.translate("errors.html_tags.address2"))]})},{errors:[m.DeliveryCityContainsHtmlTags],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","locality",this.i18n.translate("errors.html_tags.city"))]})},{errors:[m.DeliveryFirstNameContainsHtmlTags],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","name",this.i18n.translate("errors.html_tags.first_name"))]})},{errors:[m.DeliveryLastNameContainsHtmlTags],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","name",this.i18n.translate("errors.html_tags.last_name"))]})},{errors:[m.DeliveryCityContainsEmojis],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","locality",this.i18n.translate("errors.emojis.city"))]})},{errors:[m.DeliveryAddress1ContainsEmojis],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","addressLines",this.i18n.translate("errors.emojis.address1"))]})},{errors:[m.DeliveryAddress2ContainsEmojis],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","addressLines",this.i18n.translate("errors.emojis.address2"))]})},{errors:[m.DeliveryPostalCodeContainsEmojis],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","postalCode",this.i18n.translate("errors.emojis.postal_code"))]})},{errors:[m.BuyerIdentityEmailInvalid],generateAction:()=>({action:"show_error",errors:[new ApplePayError("shippingContactInvalid","emailAddress",this.i18n.translate("errors.invalid.email"))]})},{errors:[m.DiscountNotApplicable],generateAction:()=>({action:"show_error",errors:[new ApplePayError("couponCodeInvalid",void 0,this.i18n.translate("errors.invalid.discount"))]})}]}mapCustomValidationFunctionErrorToAction(e){const n=Er(e);return n?{action:"abort",effects:[()=>{const r=this.i18n.translate("brand.apple_pay");Ar(this.i18n.translate("error_dialogs.wallet.title",{wallet:r}),n.message)}]}:null}createApplePayZoneError(e,n,r,a){const i=a==="AE"?"subLocality":"administrativeArea";return new ApplePayError(r,i,a==="AE"?n:e)}}const Qr=["name","postalAddress"];function hl({shippingRequired:t,walletParams:e,buyerCurrency:n}){const{phoneRequired:r,emailRequired:a}=e,i=[...a?["email"]:[],...r?["phone"]:[]],o=t?[...Qr,...i]:i;return{countryCode:e.countryCode,currencyCode:n,merchantCapabilities:e.merchantCapabilities,supportedNetworks:e.supportedNetworks,total:{type:"pending",label:e.merchantName,amount:"1.00"},requiredBillingContactFields:Qr,requiredShippingContactFields:o,shippingType:e.shippingType}}const pl=t=>{const e=t.lineItems.flatMap(n=>n.discountAllocations);return[...t.discountCodes.filter(n=>n.applicable&&t.discountAllocations.findIndex(r=>r.code===n.code)===-1&&e.findIndex(r=>r.code===n.code)===-1).map(n=>({code:n.code,discountedAmount:{amount:"0",currencyCode:t.totalAmount.currencyCode}})),...t.discountAllocations,...e]},ia=t=>{const e=t.lineItems.reduce((n,r)=>n+Number(r.subtotalAmount.amount),0);return{amount:String(e),currencyCode:t.totalAmount.currencyCode}};function ml(t,e){return t.reduce((n,r)=>{if(!r.sellingPlanAllocation)return n;const{sellingPlanAllocation:{sellingPlan:a,priceAdjustments:i},quantity:o}=r;if(!a.recurringDeliveries||!a.billingPolicy)return n;const s=yl({billingPolicy:a.billingPolicy,i18n:e});if(i.length===0){const l=ft({price:Number(r.subtotalAmount.amount)*o,currencyCode:r.subtotalAmount.currencyCode,locale:e.locale});return[...n,e.translate("order_summary.subscriptions.recurring_totals",{fixedPrice:l,interval:s})]}else if(i.length===1){const l=ft({price:Number(i[0].price.amount)*o,currencyCode:i[0].price.currencyCode,locale:e.locale});return[...n,e.translate("order_summary.subscriptions.recurring_totals",{fixedPrice:l,interval:s})]}else if(i.length===2){const l=ft({price:Number(i[0].price.amount)*o,currencyCode:i[0].price.currencyCode,locale:e.locale}),c=ft({price:Number(i[1].price.amount)*o,currencyCode:i[1].price.currencyCode,locale:e.locale}),u=a.priceAdjustments[0].orderCount;return[...n,e.translate("order_summary.subscriptions.recurring_totals_with_policies",{count:u,fixedPrice:l,recurringPrice:c,interval:s})]}return n},[])}function ft({price:t,currencyCode:e,locale:n}){return Intl.NumberFormat(n,{style:"currency",currency:e,currencyDisplay:"narrowSymbol"}).format(t)}function yl({billingPolicy:t,i18n:e}){const{interval:n,intervalCount:r}=t,a={YEAR:"order_summary.subscriptions.recurring_total_intervals.year",MONTH:"order_summary.subscriptions.recurring_total_intervals.month",WEEK:"order_summary.subscriptions.recurring_total_intervals.week",DAY:"order_summary.subscriptions.recurring_total_intervals.day"}[n];if(!a)throw new Error("Unknown selling plan interval provided: ".concat(n));return e.translate(a,{count:r})}const Ht="GraphQL Client",Xr=0,Jr=3,oa="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",sa="Response returned unexpected Content-Type:",la="An unknown error has occurred. The API did not return a data object or any errors in its response.",sr={json:"application/json",multipart:"multipart/mixed"},Zr="X-SDK-Variant",en="X-SDK-Version",gl="shopify-graphql-client",fl="1.3.0",ca=1e3,bl=[429,503],da=/@(defer)\b/i,tn="\r\n",wl=/boundary="?([^=";]+)"?/i,rn=tn+tn;function le(t,e=Ht){return t.startsWith("".concat(e))?t:"".concat(e,": ").concat(t)}function ze(t){return t instanceof Error?t.message:JSON.stringify(t)}function ua(t){return t instanceof Error&&t.cause?t.cause:void 0}function ha(t){return t.flatMap(({errors:e})=>e!=null?e:[])}function pa({client:t,retries:e}){if(e!==void 0&&(typeof e!="number"||eJr))throw new Error("".concat(t,': The provided "retries" value (').concat(e,") is invalid - it cannot be less than ").concat(Xr," or greater than ").concat(Jr))}function V(t,e){return e&&(typeof e!="object"||Array.isArray(e)||typeof e=="object"&&Object.keys(e).length>0)?{[t]:e}:{}}function ma(t,e){if(t.length===0)return e;const n={[t.pop()]:e};return t.length===0?n:ma(t,n)}function ya(t,e){return Object.keys(e||{}).reduce((n,r)=>(typeof e[r]=="object"||Array.isArray(e[r]))&&t[r]?(n[r]=ya(t[r],e[r]),n):(n[r]=e[r],n),Array.isArray(t)?[...t]:_({},t))}function ga([t,...e]){return e.reduce(ya,_({},t))}function _l({clientLogger:t,customFetchApi:e=fetch,client:n=Ht,defaultRetryWaitTime:r=ca,retriableCodes:a=bl}){const i=async(o,s,l)=>{const c=s+1,u=l+1;let h;try{if(h=await e(...o),t({type:"HTTP-Response",content:{requestParams:o,response:h}}),!h.ok&&a.includes(h.status)&&c<=u)throw new Error;return h}catch(p){if(c<=u){const y=h==null?void 0:h.headers.get("Retry-After");return await El(y?parseInt(y,10):r),t({type:"HTTP-Retry",content:{requestParams:o,lastResponse:h,retryAttempt:s,maxRetries:l}}),i(o,c,l)}throw new Error(le("".concat(l>0?"Attempted maximum number of ".concat(l," network retries. Last message - "):"").concat(ze(p)),n))}};return i}async function El(t){return new Promise(e=>setTimeout(e,t))}function Al({headers:t,url:e,customFetchApi:n=fetch,retries:r=0,logger:a}){pa({client:Ht,retries:r});const i={headers:t,url:e,retries:r},o=Cl(a),s=_l({customFetchApi:n,clientLogger:o,defaultRetryWaitTime:ca}),l=Sl(s,i),c=Il(l),u=kl(l);return{config:i,fetch:l,request:c,requestStream:u}}function Cl(t){return e=>{t&&t(e)}}async function fa(t){const{errors:e,data:n,extensions:r}=await t.json();return _(T(_(_({},V("data",n)),V("extensions",r)),{headers:t.headers}),e||!n?{errors:T(_({networkStatusCode:t.status,message:le(e?oa:la)},V("graphQLErrors",e)),{response:t})}:{})}function Sl(t,{url:e,headers:n,retries:r}){return async(a,i={})=>{const{variables:o,headers:s,url:l,retries:c,keepalive:u,signal:h}=i,p=JSON.stringify({query:a,variables:o});pa({client:Ht,retries:c});const y=Object.entries(_(_({},n),s)).reduce((f,[A,I])=>(f[A]=Array.isArray(I)?I.join(", "):I.toString(),f),{});!y[Zr]&&!y[en]&&(y[Zr]=gl,y[en]=fl);const E=[l!=null?l:e,{method:"POST",headers:y,body:p,signal:h,keepalive:u}];return t(E,1,c!=null?c:r)}}function Il(t){return async(...e)=>{if(da.test(e[0]))throw new Error(le("This operation will result in a streamable response - use requestStream() instead."));try{const n=await t(...e),{status:r,statusText:a}=n,i=n.headers.get("content-type")||"";return n.ok?i.includes(sr.json)?fa(n):{errors:{networkStatusCode:r,message:le("".concat(sa," ").concat(i)),response:n}}:{errors:{networkStatusCode:r,message:le(a),response:n}}}catch(n){return{errors:{message:ze(n)}}}}}function Pl(t){return Ne(this,null,function*(){const e=new TextDecoder;if(t.body[Symbol.asyncIterator])try{for(var n=ee(t.body),r,a,i;r=!(a=yield new Z(n.next())).done;r=!1){const o=a.value;yield e.decode(o)}}catch(o){i=[o]}finally{try{r&&(a=n.return)&&(yield new Z(a.call(n)))}finally{if(i)throw i[0]}}else{const o=t.body.getReader();let s;try{for(;!(s=yield new Z(o.read())).done;)yield e.decode(s.value)}finally{o.cancel()}}})}function Dl(t,e){return{[Symbol.asyncIterator](){return Ne(this,null,function*(){try{let o="";try{for(var n=ee(t),r,a,i;r=!(a=yield new Z(n.next())).done;r=!1){const s=a.value;if(o+=s,o.indexOf(e)>-1){const l=o.lastIndexOf(e),c=o.slice(0,l).split(e).filter(u=>u.trim().length>0).map(u=>u.slice(u.indexOf(rn)+rn.length).trim());c.length>0&&(yield c),o=o.slice(l+e.length),o.trim()==="--"&&(o="")}}}catch(s){i=[s]}finally{try{r&&(a=n.return)&&(yield new Z(a.call(n)))}finally{if(i)throw i[0]}}}catch(o){throw new Error("Error occured while processing stream payload - ".concat(ze(o)))}})}}}function vl(t){return{[Symbol.asyncIterator](){return Ne(this,null,function*(){const e=yield new Z(fa(t));yield T(_({},e),{hasNext:!1})})}}}function Rl(t){return t.map(e=>{try{return JSON.parse(e)}catch(n){throw new Error("Error in parsing multipart response - ".concat(ze(n)))}}).map(e=>{const{data:n,incremental:r,hasNext:a,extensions:i,errors:o}=e;if(!r)return T(_(_({data:n||{}},V("errors",o)),V("extensions",i)),{hasNext:a});const s=r.map(({data:l,path:c,errors:u})=>_({data:l&&c?ma(c,l):{}},V("errors",u)));return T(_({data:s.length===1?s[0].data:ga([...s.map(({data:l})=>l)])},V("errors",ha(s))),{hasNext:a})})}function Nl(t,e){if(t.length>0)throw new Error(oa,{cause:{graphQLErrors:t}});if(Object.keys(e).length===0)throw new Error(la)}function Tl(t,e){var n,r;const a=(e!=null?e:"").match(wl),i="--".concat(a?a[1]:"-");if(!((n=t.body)!=null&&n.getReader)&&!((r=t.body)!=null&&r[Symbol.asyncIterator]))throw new Error("API multipart response did not return an iterable body",{cause:t});const o=Pl(t);let s={},l;return{[Symbol.asyncIterator](){return Ne(this,null,function*(){var c,u;try{let f=!0;try{for(var h=ee(Dl(o,i)),p,y,E;p=!(y=yield new Z(h.next())).done;p=!1){const A=y.value,I=Rl(A);l=(u=(c=I.find(F=>F.extensions))==null?void 0:c.extensions)!=null?u:l;const O=ha(I);s=ga([s,...I.map(({data:F})=>F)]),f=I.slice(-1)[0].hasNext,Nl(O,s),yield T(_(_({},V("data",s)),V("extensions",l)),{hasNext:f})}}catch(A){E=[A]}finally{try{p&&(y=h.return)&&(yield new Z(y.call(h)))}finally{if(E)throw E[0]}}if(f)throw new Error("Response stream terminated unexpectedly")}catch(f){const A=ua(f);yield T(_(_({},V("data",s)),V("extensions",l)),{errors:T(_({message:le(ze(f)),networkStatusCode:t.status},V("graphQLErrors",A==null?void 0:A.graphQLErrors)),{response:t}),hasNext:!1})}})}}}function kl(t){return async(...e)=>{if(!da.test(e[0]))throw new Error(le("This operation does not result in a streamable response - use request() instead."));try{const n=await t(...e),{statusText:r}=n;if(!n.ok)throw new Error(r,{cause:n});const a=n.headers.get("content-type")||"";switch(!0){case a.includes(sr.json):return vl(n);case a.includes(sr.multipart):return Tl(n,a);default:throw new Error("".concat(sa," ").concat(a),{cause:n})}}catch(n){return{[Symbol.asyncIterator](){return Ne(this,null,function*(){const r=ua(n);yield{errors:_(_({message:le(ze(n))},V("networkStatusCode",r==null?void 0:r.status)),V("response",r)),hasNext:!1}})}}}}}const Ll="mutation cartCreate($input:CartInput!$country:CountryCode$language:LanguageCode$withCarrierRates:Boolean=false)@inContext(country:$country language:$language){result:cartCreate(input:$input){...@defer(if:$withCarrierRates){cart{...CartParts}errors:userErrors{...on CartUserError{message field code}}warnings:warnings{...on CartWarning{code}}}}}",Ol="mutation cartAttributesUpdate($cartId:ID!$attributes:[AttributeInput!]!$country:CountryCode=CA$language:LanguageCode=EN$withCarrierRates:Boolean=false$prepareCart:Boolean=false)@inContext(country:$country language:$language){result:cartAttributesUpdate(cartId:$cartId attributes:$attributes){...@defer(if:$withCarrierRates)@skip(if:$prepareCart){cart{...CartParts}errors:userErrors{...CartErrorParts}warnings:warnings{...on CartWarning{code}}}...@include(if:$prepareCart){errors:userErrors{...CartErrorParts}warnings:warnings{...on CartWarning{code}}}}...PreparedCartFragment}",xl="mutation cartBillingAddressUpdate($cartId:ID!$billingAddress:MailingAddressInput$country:CountryCode$language:LanguageCode$withCarrierRates:Boolean=false$prepareCart:Boolean=false)@inContext(country:$country language:$language){result:cartBillingAddressUpdate(cartId:$cartId billingAddress:$billingAddress){...@defer(if:$withCarrierRates)@skip(if:$prepareCart){cart{...CartParts}errors:userErrors{...CartErrorParts}warnings:warnings{...on CartWarning{code}}}...@include(if:$prepareCart){errors:userErrors{...CartErrorParts}warnings:warnings{...on CartWarning{code}}}}...PreparedCartFragment}",Ml="mutation cartBuyerIdentityUpdate($cartId:ID!$buyerIdentity:CartBuyerIdentityInput!$country:CountryCode$language:LanguageCode$withCarrierRates:Boolean=false$prepareCart:Boolean=false)@inContext(country:$country language:$language){result:cartBuyerIdentityUpdate(cartId:$cartId buyerIdentity:$buyerIdentity){...@defer(if:$withCarrierRates)@skip(if:$prepareCart){cart{...CartParts}errors:userErrors{...CartErrorParts}warnings:warnings{...on CartWarning{code}}}...@include(if:$prepareCart){errors:userErrors{...CartErrorParts}warnings:warnings{...on CartWarning{code}}}}...PreparedCartFragment}",Fl="mutation cartSelectedDeliveryOptionsUpdate($cartId:ID!$selectedDeliveryOptions:[CartSelectedDeliveryOptionInput!]!$country:CountryCode=CA$language:LanguageCode=EN$withCarrierRates:Boolean=false$prepareCart:Boolean=false)@inContext(country:$country language:$language){result:cartSelectedDeliveryOptionsUpdate(cartId:$cartId selectedDeliveryOptions:$selectedDeliveryOptions){...@defer(if:$withCarrierRates)@skip(if:$prepareCart){cart{...CartParts}errors:userErrors{...CartErrorParts}warnings:warnings{...on CartWarning{code}}}...@include(if:$prepareCart){errors:userErrors{...CartErrorParts}warnings:warnings{...on CartWarning{code}}}}...PreparedCartFragment}",Ul="mutation applePaySessionCreate($validationUrl:URL!){applePaySessionCreate(validationUrl:$validationUrl){...@defer{applePaySession{body}}}}",$l="mutation PayPalBuyerDetailsFetch($token:String!$cartId:ID){paypalBuyerDetailsFetch(token:$token cartId:$cartId){...@defer{paypalDetails{email expiresAt remoteOrderId destinationAddress{...on MailingAddress{address1 address2 city company country firstName lastName phone province zip}}billingAddress{...on MailingAddress{address1 address2 city company country firstName lastName phone province zip}}}}}}",Bl="mutation PayPalTokenCreate($cartId:ID!){paypalTokenCreate(cartId:$cartId){...@defer{paypalToken{token}}}}",Hl="query cartQuery($id:ID!$country:CountryCode$language:LanguageCode$withCarrierRates:Boolean=false)@inContext(country:$country language:$language){cart(id:$id){...@defer(if:$withCarrierRates){...CartParts}}}",Gl="query limitedCartQuery($id:ID!$country:CountryCode$language:LanguageCode)@inContext(country:$country language:$language){cart(id:$id){id lines(first:50){edges{node{merchandise{...on ProductVariant{requiresShipping}}sellingPlanAllocation{sellingPlan{id}}}}}}}",Vl="query subscriptionPolicyQuery($country:CountryCode$language:LanguageCode)@inContext(country:$country language:$language){shop{subscriptionPolicy(sanitized:true){body}}}",zl="mutation cartPaymentUpdate($cartId:ID!$input:CartPaymentInput!$country:CountryCode$language:LanguageCode$withCarrierRates:Boolean=false$prepareCart:Boolean=false)@inContext(country:$country language:$language){result:cartPaymentUpdate(cartId:$cartId payment:$input){...@defer(if:$withCarrierRates)@skip(if:$prepareCart){cart{...CartParts}errors:userErrors{...CartErrorParts}warnings:warnings{...on CartWarning{code}}}...@include(if:$prepareCart){errors:userErrors{...CartErrorParts}warnings:warnings{...on CartWarning{code}}}}...PreparedCartFragment}",bt="fragment CartParts on Cart{id checkoutUrl deliveryGroups(first:10 withCarrierRates:$withCarrierRates){edges{node{id groupType selectedDeliveryOption{code title handle deliveryPromise deliveryMethodType estimatedCost{amount currencyCode}}deliveryOptions{code title handle deliveryPromise deliveryMethodType estimatedCost{amount currencyCode}}}}}cost{subtotalAmount{amount currencyCode}totalAmount{amount currencyCode}totalTaxAmount{amount currencyCode}totalDutyAmount{amount currencyCode}}discountAllocations{discountedAmount{amount currencyCode}...on CartCodeDiscountAllocation{code}...on CartAutomaticDiscountAllocation{title}...on CartCustomDiscountAllocation{title}}discountCodes{code applicable}lines(first:10){edges{node{quantity cost{subtotalAmount{amount currencyCode}totalAmount{amount currencyCode}}discountAllocations{discountedAmount{amount currencyCode}...on CartCodeDiscountAllocation{code}...on CartAutomaticDiscountAllocation{title}...on CartCustomDiscountAllocation{title}}merchandise{...on ProductVariant{requiresShipping}}sellingPlanAllocation{priceAdjustments{price{amount currencyCode}}sellingPlan{billingPolicy{...on SellingPlanRecurringBillingPolicy{interval intervalCount}}priceAdjustments{orderCount}recurringDeliveries}}}}}}",Xt="fragment CartErrorParts on CartUserError{message field code}",nn="fragment PreparedCartFragment on Mutation{preparedCart:cartPrepareForCompletion(cartId:$cartId)@include(if:$prepareCart){...@defer{result{__typename ...on CartStatusReady{cart{...CartParts}}...on CartStatusNotReady{cart{...CartParts}errors{code message}}...on CartThrottled{cart{...CartParts}pollAfter}}errors:userErrors{...CartErrorParts}}}}",ql="mutation prepareCart($cartId:ID!$country:CountryCode$language:LanguageCode$withCarrierRates:Boolean=false$prepareCart:Boolean=true)@inContext(country:$country language:$language){...PreparedCartFragment}",jl="mutation cartSubmitForCompletion($cartId:ID!$attemptToken:String!$country:CountryCode$language:LanguageCode)@inContext(country:$country language:$language){cartSubmitForCompletion(cartId:$cartId attemptToken:$attemptToken){result{__typename ...on SubmitSuccess{redirectUrl}...on SubmitThrottled{pollAfterV2:pollAfter}...on SubmitFailed{errors{code message}checkoutUrl}}errors:userErrors{...on CartUserError{code field message}}}}",Yl="mutation cartRemovePersonalData($cartId:ID!){cartRemovePersonalData(cartId:$cartId){errors:userErrors{...CartErrorParts}warnings:warnings{...on CartWarning{code}}}}",Wl="unstable",an="RESTRICTED_WALLET_ACCOUNT";class ae extends Error{constructor(e="No response"){super(e),this.name="NoResponseError"}}class Gt{constructor({accessToken:e,country:n,locale:r,apiVersion:a=Wl,withCarrierRates:i=!1,cartPrepareMigrationEnabled:o=!1}){if(d(this,"OPERATION_NAME_REGEX",/[^ ]+ (\w+)/),d(this,"client"),d(this,"country"),d(this,"url"),d(this,"locale"),d(this,"withCarrierRates"),d(this,"lastValidCart"),d(this,"cartPrepareMigrationEnabled"),!e)throw new Error("StorefrontApiClient constructed with no access token");if(!n)throw new Error("StorefrontApiClient constructed with no buyer country");if(!r)throw new Error("StorefrontApiClient constructed with no locale");this.country=n,this.locale=r,this.withCarrierRates=i,this.cartPrepareMigrationEnabled=o,this.url="/api/".concat(a,"/graphql.json"),this.client=Al({headers:{"Content-Type":"application/json",Accept:"application/json","X-Shopify-Storefront-Access-Token":e,"X-SDK-Variant":"portable-wallets"},url:this.url,retries:0,logger:s=>{if(s.type==="HTTP-Response"){const[l,c]=s.content.requestParams;w.leaveBreadcrumb("POST: ".concat(l),{statusCode:s.content.response.status,statusText:s.content.response.statusText,url:l,method:c==null?void 0:c.method,headers:c==null?void 0:c.headers,body:c==null?void 0:c.body},"request")}}})}async createCart(e){var n,r,a;const i=await this.requestStream([Ll,bt],{input:{lines:[{merchandiseId:e.merchandiseId,quantity:e.quantity,sellingPlanId:e.sellingPlanId,attributes:e.lineItemProperties}],discountCodes:e.discountCodes,buyerIdentity:e.buyerIdentity},country:this.country,language:this.formatLanguage(this.locale)},{instrumentName:e.instrumentName,startingCheckout:!0});try{for(var o=ee(i),s,l,c;s=!(l=await o.next()).done;s=!1){const u=l.value;u.errors&&this.onError(u.errors);const h=(n=u.data)==null?void 0:n.result;if(h&&!u.hasNext){h.errors&&this.onResultError(h.errors);const p=this.parseMutationWarnings((a=(r=u.data)==null?void 0:r.result)==null?void 0:a.warnings);return{data:h.cart?this.parseCartResponse(h.cart):null,errors:this.parseMutationErrors(u,"result"),warnings:p,decelerationReason:wt({warnings:p})}}}}catch(u){c=[u]}finally{try{s&&(l=o.return)&&await l.call(o)}finally{if(c)throw c[0]}}throw new ae("Cart create operation returned no response")}async updateCartBillingAddress(e){const{cartId:n,billingAddress:r,instrumentName:a}=e;return this.requestDeferredCart(xl,{cartId:n,billingAddress:r},{instrumentName:a})}async updateCartBuyerIdentity(e,n){const{cartId:r,instrumentName:a}=e;return this.requestDeferredCart(Ml,{cartId:r,buyerIdentity:Ql(e)},{instrumentName:a,abortSignal:n})}async updateSelectedDeliveryOptions(e,n,r,a){let i=n;const o=Ze()+2e4;for(;Ze()typeof c=="string"&&c.startsWith(m.PendingDeliveryGroups))))return s;const l=s.data.deliveryGroups.flatMap(c=>c.deliveryOptions.map(u=>({deliveryOptionHandle:u.handle,deliveryGroupId:c.id})));i=i.map(c=>{var u;return(u=l.find(h=>h.deliveryOptionHandle===c.deliveryOptionHandle))!=null?u:c})}throw new Error("Selected delivery options update operation timed out")}async applePaySessionCreate(e){var n,r,a;const i=await this.requestStream([Ul],{validationUrl:e.toString()},{instrumentName:b.ApplePay});try{for(var o=ee(i),s,l,c;s=!(l=await o.next()).done;s=!1){const u=l.value;u.errors&&this.onError(u.errors);const h=(a=(r=(n=u.data)==null?void 0:n.applePaySessionCreate)==null?void 0:r.applePaySession)==null?void 0:a.body;if(h)return h}}catch(u){c=[u]}finally{try{s&&(l=o.return)&&await l.call(o)}finally{if(c)throw c[0]}}throw new ae("Apple Pay session create operation returned no response")}async paypalBuyerDetailsFetch(e,n){var r,a;const i=await this.requestStream([$l],{token:e,cartId:n},{instrumentName:b.PayPal});try{for(var o=ee(i),s,l,c;s=!(l=await o.next()).done;s=!1){const u=l.value;if(u.hasNext)continue;u.errors&&this.onError(u.errors);const h=(a=(r=u.data)==null?void 0:r.paypalBuyerDetailsFetch)==null?void 0:a.paypalDetails;if(h)return h}}catch(u){c=[u]}finally{try{s&&(l=o.return)&&await l.call(o)}finally{if(c)throw c[0]}}throw new ae("PayPal buyer details fetch operation returned no response")}async paypalTokenCreate(e){var n,r,a,i;const o=await this.requestStream([Bl],{cartId:e},{instrumentName:b.PayPal});try{for(var s=ee(o),l,c,u;l=!(c=await s.next()).done;l=!1){const h=c.value;if(h.errors){if((n=h.errors.graphQLErrors)!=null&&n.find(y=>{var E;return((E=y.extensions)==null?void 0:E.code)===an}))throw new Tt(an);this.onError(h.errors)}const p=(i=(a=(r=h.data)==null?void 0:r.paypalTokenCreate)==null?void 0:a.paypalToken)==null?void 0:i.token;if(p)return p}}catch(h){u=[h]}finally{try{l&&(c=s.return)&&await c.call(s)}finally{if(u)throw u[0]}}throw new ae("PayPal token create operation returned no response")}async fetchLimitedCart({id:e,startingCheckout:n,instrumentName:r}){var a;const i=await this.request([Gl],{id:e},{instrumentName:r,startingCheckout:n});if(i.errors&&this.onError(i.errors),!((a=i.data)!=null&&a.cart))throw new ae("Limited cart query returned no response");return w.leaveBreadcrumb("limitedCartQuery response",{operationName:"limitedCartQuery",body:i.data.cart},"log"),{id:i.data.cart.id,shippingRequired:i.data.cart.lines.edges.some(o=>o.node.merchandise.requiresShipping),sellingPlan:i.data.cart.lines.edges.some(o=>o.node.sellingPlanAllocation!=null)}}async fetchCart({id:e,startingCheckout:n,instrumentName:r}){var a;const i=this.formatLanguage(this.locale),o=this.cartPrepareMigrationEnabled?"Prepare cart":"Fetch cart",s=this.cartPrepareMigrationEnabled?ql:Hl,l=this.cartPrepareMigrationEnabled?[bt,Xt,nn]:[bt],c=this.cartPrepareMigrationEnabled?{cartId:e,country:this.country,language:i,withCarrierRates:this.withCarrierRates,prepareCart:!0}:{id:e,country:this.country,language:i,withCarrierRates:this.withCarrierRates},u=await this.requestStream([s,...l],c,{instrumentName:r,startingCheckout:n});try{for(var h=ee(u),p,y,E;p=!(y=await h.next()).done;p=!1){const f=y.value;f.errors&&this.onError(f.errors);let A=null,I;if(!f.data)throw new ae("".concat(o," operation returned no data in response"));if(Kl(f.data)){const O=f.data.preparedCart;A=(a=O==null?void 0:O.result)==null?void 0:a.cart,I=this.parsePreparedCartMutationErrors(f.errors,this.extractPreparedCartMutationErrors(O))}else A=f.data.cart;if(w.leaveBreadcrumb("".concat(o," response"),{operationName:o,body:A,errors:I,hasNext:f.hasNext},"log"),A&&!f.hasNext){const O=this.parseCartResponse(A);return this.lastValidCart=O,O}}}catch(f){E=[f]}finally{try{p&&(y=h.return)&&await y.call(h)}finally{if(E)throw E[0]}}throw new ae("".concat(o," operation returned no response"))}async updateCartPayment(e,n,r,a){var i,o;const s={cartId:e,input:n},{amount:l,currencyCode:c}=n.amount;let u;const h=Ze()+1e4;for(;Ze()setTimeout(y,500)),s.input.amount={amount:p.data.totalAmount.amount,currencyCode:p.data.totalAmount.currencyCode};continue}return(p.data.totalAmount.amount===l||parseFloat(p.data.totalAmount.amount)<=parseFloat(l))&&p.data.totalAmount.currencyCode===c?p:u}throw new Error("Payment update operation timed out")}async updateCartAttributes({cartId:e,attributes:n,instrumentName:r,startingCheckout:a}){const i={cartId:e,attributes:n};return await this.requestDeferredCart(Ol,i,{instrumentName:r,startingCheckout:a})}async submitForCompletion(e,n,r){var a,i;const o=this.formatLanguage(this.locale),s=await this.request([jl],{cartId:e,attemptToken:n,country:this.country,language:o,withCarrierRates:this.withCarrierRates},{instrumentName:r});return{data:(i=(a=s.data)==null?void 0:a.cartSubmitForCompletion)==null?void 0:i.result,errors:this.parseCompletionErrors(s)}}async fetchSubscriptionPolicy(){var e,n;const{data:r}=await this.request([Vl],{country:this.country,language:this.formatLanguage(this.locale)},{});return(n=(e=r==null?void 0:r.shop)==null?void 0:e.subscriptionPolicy)==null?void 0:n.body}async cartRemovePersonalData({cartId:e,shopId:n,instrumentName:r}){var a,i;let o,s,l;try{const u=await this.request([Yl,Xt],{cartId:e},{instrumentName:r,keepalive:!0});o=this.parseMutationWarnings((i=(a=u.data)==null?void 0:a.cartRemovePersonalData)==null?void 0:i.warnings),s=this.parseMutationErrors(u,"cartRemovePersonalData")}catch(u){l=u.toString()}const c=!(o!=null&&o.length||s!=null&&s.length||l);g.removePersonalDataResult({success:c}),c||g.log({body:"cartRemovePersonalData failed",attributes:{cartId:e,shopId:n,warnings:o,errors:s,exception:l}})}generateURLWithOperationName(e){const n=e.match(this.OPERATION_NAME_REGEX);if(n){const r=this.url.includes("?")?"&":"?",a="operation_name=".concat(n[1]);return"".concat(this.url).concat(r).concat(a)}return this.url}async request(e,n,r){return this.client.request(e.join(""),{variables:n,headers:on(r),url:this.generateURLWithOperationName(e[0]),keepalive:r.keepalive})}async requestStream(e,n,r){return this.client.requestStream(e.join(""),{variables:n,headers:on(r),url:this.generateURLWithOperationName(e[0]),signal:r.abortSignal})}async requestDeferredCart(e,n,r){var a,i,o,s,l,c,u,h,p;const y=this.formatLanguage(this.locale),E=await this.requestStream([e,bt,Xt,nn],T(_({},n),{country:this.country,language:y,withCarrierRates:this.withCarrierRates,prepareCart:this.cartPrepareMigrationEnabled}),r);try{for(var f=ee(E),A,I,O;A=!(I=await f.next()).done;A=!1){const F=I.value;F.errors&&this.onError(F.errors);const qe=this.extractMutationErrors(F),N=(i=(a=F.data)==null?void 0:a.preparedCart)==null?void 0:i.result,G=(l=(s=(o=F.data)==null?void 0:o.result)==null?void 0:s.cart)!=null?l:N==null?void 0:N.cart;if(G&&!F.hasNext){let U;this.cartPrepareMigrationEnabled||(U=await this.fetchCart({id:G.id,instrumentName:r.instrumentName,startingCheckout:!1}));const k=this.parseMutationWarnings((u=(c=F.data)==null?void 0:c.result)==null?void 0:u.warnings);return{data:U!=null?U:this.parseCartResponse(G),errors:this.parsePreparedCartMutationErrors(F.errors,qe),warnings:k,decelerationReason:wt({warnings:k,cartStatus:N==null?void 0:N.__typename})}}if(this.lastValidCart&&qe.length>0){this.onResultError(qe);const U=this.parseMutationWarnings((p=(h=F.data)==null?void 0:h.result)==null?void 0:p.warnings);return{data:this.lastValidCart,errors:this.parsePreparedCartMutationErrors(F.errors,qe),warnings:U,decelerationReason:wt({warnings:U})}}}}catch(F){O=[F]}finally{try{A&&(I=f.return)&&await I.call(f)}finally{if(O)throw O[0]}}throw new ae("Deferred cart operation returned no response")}onError(e){var n,r;if(!e)return;w.leaveBreadcrumb("GraphQL response error",e,"error");const a=(r=(n=e.graphQLErrors)==null?void 0:n.map(s=>s.message).join(", "))!=null?r:"",i="".concat(e.message).concat(a.length>0?" - ".concat(a):""),o=e!=null&&e.networkStatusCode?"with status ".concat(e.networkStatusCode," => ").concat(i):"=> ".concat(i);throw new Error("GraphQL mutation failed ".concat(o))}onResultError(e){w.leaveBreadcrumb("GraphQL result error",e,"error")}formatLanguage(e){return e.includes("-")?e.split("-")[0].toUpperCase():e.toUpperCase()}parseCartResponse(e){var n,r,a;const i=e.lines.edges.map(s=>{var l,c;const u=s.node;return{quantity:u.quantity,totalAmount:{amount:u.cost.totalAmount.amount,currencyCode:u.cost.totalAmount.currencyCode},subtotalAmount:{amount:(l=u.cost.subtotalAmount)==null?void 0:l.amount,currencyCode:(c=u.cost.subtotalAmount)==null?void 0:c.currencyCode},merchandise:{requiresShipping:u.merchandise.requiresShipping},discountAllocations:u.discountAllocations,sellingPlanAllocation:u.sellingPlanAllocation}}),o=e.deliveryGroups.edges.map(s=>s.node);return{id:e.id,totalAmount:e.cost.totalAmount,subtotalAmount:(n=e.cost.subtotalAmount)!=null?n:void 0,totalTaxAmount:(r=e.cost.totalTaxAmount)!=null?r:void 0,totalDutyAmount:(a=e.cost.totalDutyAmount)!=null?a:void 0,discountAllocations:e.discountAllocations,discountCodes:e.discountCodes,lineItems:i,deliveryGroups:o,checkoutUrl:e.checkoutUrl}}parseGraphQlErrors(e){var n,r;return(r=(n=e==null?void 0:e.graphQLErrors)==null?void 0:n.map(a=>a.message.replace(/\(Expected.*\)/,"").trim()))!=null?r:[]}parseMutationError(e){return e.code===Et?{code:Et,message:e.message}:e.field&&e.field.length>0?"".concat(e.code,": ").concat(e.field.join(".")):e.code}parseMutationErrors(e,n){var r,a,i;const o=this.parseGraphQlErrors(e.errors),s=((i=(a=(r=e.data)==null?void 0:r[n])==null?void 0:a.errors)==null?void 0:i.map(this.parseMutationError).filter(c=>c))||[],l=[...o,...s];return w.leaveBreadcrumb("GraphQL errors on mutation",l,"error"),l}parseMutationWarnings(e){return!e||e.length===0?[]:e.map(n=>n.code)}filterErrors(e){var n;return!((n=e.code)!=null&&n.startsWith("PENDING_DELIVERY_GROUPS")||e.code==="INVALID_PAYMENT")}extractPreparedCartMutationErrors(e){var n,r;const a=(n=e==null?void 0:e.errors)!=null?n:[];return((r=e==null?void 0:e.result)==null?void 0:r.__typename)==="CartStatusNotReady"&&a.push(...e.result.errors),a}extractMutationErrors(e){var n,r,a,i;let o=(a=(r=(n=e.data)==null?void 0:n.result)==null?void 0:r.errors)!=null?a:[];return this.cartPrepareMigrationEnabled&&(o=o.filter(this.filterErrors)),[...o,...this.extractPreparedCartMutationErrors((i=e.data)==null?void 0:i.preparedCart)]}parsePreparedCartMutationErrors(e,n){const r=this.parseGraphQlErrors(e),a=n.map(this.parseMutationError).filter(o=>o),i=[...r,...a];return w.leaveBreadcrumb("GraphQL errors on mutation",i,"error"),i}parseCompletionErrors(e){var n,r,a,i;const o=this.parseGraphQlErrors(e.errors);let s=[];((a=(r=(n=e.data)==null?void 0:n.cartSubmitForCompletion)==null?void 0:r.result)==null?void 0:a.__typename)==="SubmitFailed"&&(s=(i=e.data.cartSubmitForCompletion.result.errors.map(c=>c.code))!=null?i:[]);const l=[...o,...s];return w.leaveBreadcrumb("GraphQL errors on completion",l,"error"),l}}function Kl(t){return!("cart"in t)}function Ql({emailAddress:t,countryCode:e,phone:n,streetAddress:r,validateAddress:a,preferences:i}){return{email:t,countryCode:e!=null?e:r==null?void 0:r.country,phone:n!=null?n:r==null?void 0:r.phone,deliveryAddressPreferences:r?[{deliveryAddressValidationStrategy:a?"STRICT":"COUNTRY_CODE_ONLY",deliveryAddress:r}]:[],preferences:i}}function on({instrumentName:t,startingCheckout:e}){const n={};return t&&(n["X-Wallet-Name"]="".concat(t)),e&&(n["X-Start-Wallet-Checkout"]="".concat(e)),n}async function ba({cartId:t,cartClient:e,instrumentName:n,selectedDeliveryOptions:r,abortSignal:a}){try{if(!t)throw new Error("[".concat(n,"] provided no cart ID when updating shipping method"));if(!e)throw new Error("[".concat(n,"] provided invalid cart client when updating shipping method"));return await e.updateSelectedDeliveryOptions(t,r,n,a)}catch(i){throw g.updateFailed(n,"updateSelectedDeliveryOptions"),i}}async function wa({cartId:t,token:e,cartClient:n,instrumentName:r}){try{if(!t)throw new Error("[".concat(r,"] provided no cart ID when submitting for completion"));if(!n)throw new Error("[".concat(r,"] provided invalid cart client when submitting for completion"));if(!e)throw new Error("[".concat(r,"] provided no token when submitting for completion"));const a=await n.submitForCompletion(t,e,r),i=a==null?void 0:a.errors;return i&&(sn({instrument:r,errors:i,errCodes:Cr,telemetryMethod:g.dynamicTaxFailed,logBody:"Dynamic tax failed"}),sn({instrument:r,errors:i,errCodes:Ds,telemetryMethod:g.dynamicShippingFailed,logBody:"Dynamic shipping failed"})),a}catch(a){throw g.updateFailed(r,"submitForCompletion"),a}}function sn({instrument:t,errors:e,errCodes:n,telemetryMethod:r,logBody:a}){const i=e.filter(o=>n.includes(o));i.length>0&&(r({instrument:t}),g.log({body:a,attributes:{instrument:t,error:i}}))}function _a({selectedDeliveryOptionHandles:t,deliveryGroups:e,instrumentName:n}){return e.map(r=>{const a=r.deliveryOptions.filter(i=>t.includes(i.handle));if(!a.length)throw new Error("[".concat(n,"] could not find delivery option for group: ").concat(r.id));if(a.length>1)throw new Error("[".concat(n,"] found multiple delivery options with selectedDeliverOptionHandle in group: ").concat(r.id));return{deliveryGroupId:r.id,deliveryOptionHandle:a[0].handle}})}async function Xl(t){const{cartClient:e,instrumentName:n}=t;try{if(!t.cartId)throw new Error("[".concat(n,"] provided no cart ID when updating billing address"));if(!e)throw new Error("[".concat(n,"] provided invalid cart client when updating billing address"));return await e.updateCartBillingAddress(t)}catch(r){throw g.updateFailed(n,"updateBillingAddress"),r}}const Jl=["cart_not_ready","cart_throttled"];class Zl{constructor({accessToken:e,buyerCountry:n,buyerCurrency:r,button:a,i18n:i,merchantName:o,dataSource:s,apiClient:l,walletParams:c}){d(this,"name",b.ApplePay),d(this,"accessToken"),d(this,"button"),d(this,"buyerCountry"),d(this,"cart"),d(this,"apiClient"),d(this,"dataSource"),d(this,"i18n"),d(this,"merchantName"),d(this,"session"),d(this,"paymentSheetActionGenerator"),d(this,"cancelled"),d(this,"buyerCurrency"),d(this,"customerAccountEmail"),d(this,"abortController",null),d(this,"isPersonalDataCleared",!1),d(this,"onvalidatemerchant",async u=>{var h,p,y;try{const E=new URL(u.validationURL),f=this.getMerchantSession(E),{cart:A,decelerationReason:I,customValidationError:O}=await pe({element:this.button,instrumentName:this.name,dataSource:this.dataSource});if(O){this.session.abort(),(h=this.abortController)==null||h.abort(),ve(this.i18n,O.message);return}this.cart=A;const F=await f;if(w.leaveBreadcrumb("ApplePay Session completeMerchantValidation",{session:F},"log"),I){this.session.abort(),(p=this.abortController)==null||p.abort(),M({checkoutUrl:(y=A==null?void 0:A.checkoutUrl)!=null?y:"",instrumentName:this.name,reason:I});return}if(this.sessionIsCancelled())return;this.session.completeMerchantValidation(F)}catch(E){g.sheetClicked({instrument:b.ApplePay,result:"failed"}),this.terminateSession(E)}}),d(this,"onshippingcontactselected",async u=>{try{const h=gt(u.shippingContact),p=await xe({cartId:this.cart.id,streetAddress:h,cartClient:this.apiClient,instrumentName:this.name});if(!p.data)throw new Error("Missing cart during Apple Pay Session creation");if(await this.decelerateIfNeeded(p))return;await this.applyPaymentSheetActions(p,y=>this.completeShippingContactSelection(p.data,y),{shippingRequired:this.isShippingRequired,shippingCountryCode:h.country})}catch(h){this.terminateSession(h)}}),d(this,"onshippingmethodselected",async u=>{var h;try{const p=u.shippingMethod.identifier.split(","),y=_a({selectedDeliveryOptionHandles:p,deliveryGroups:this.cart.deliveryGroups,instrumentName:this.name}),E=await ba({cartId:this.cart.id,cartClient:this.apiClient,instrumentName:this.name,selectedDeliveryOptions:y,abortSignal:(h=this.abortController)==null?void 0:h.signal});await this.applyPaymentSheetActions(E,()=>this.completeShippingMethodSelection(E.data),{shippingRequired:this.isShippingRequired,shippingCountryCode:void 0})}catch(p){this.terminateSession(p)}}),d(this,"onpaymentmethodselected",async u=>{try{const{billingContact:h}=u.paymentMethod;if(!this.isShippingRequired&&h){const E=gt(h),f=await xe({cartId:this.cart.id,countryCode:E.country,cartClient:this.apiClient,instrumentName:this.name});if(!f.data)throw new Error("Missing cart during Apple Pay Session creation");if(await this.decelerateIfNeeded(f))return;await this.applyPaymentSheetActions(f,()=>this.cart=f.data,{shippingRequired:this.isShippingRequired,shippingCountryCode:E.country});const A=await Xl({billingAddress:E,cartId:this.cart.id,cartClient:this.apiClient,instrumentName:this.name});await this.applyPaymentSheetActions(A,()=>this.cart=A.data,{shippingRequired:this.isShippingRequired,shippingCountryCode:E.country})}const{newTotal:p,newLineItems:y}=this.getNewTotalAndLineItems(this.cart);if(w.leaveBreadcrumb("ApplePay Session completePaymentMethodSelection",{newTotal:p,newLineItems:y},"log"),this.sessionIsCancelled())return;this.session.completePaymentMethodSelection({newTotal:p,newLineItems:y})}catch(h){this.terminateSession(h)}}),d(this,"oncancel",()=>{var u;this.cancelled=!0,this.removePersonalData(),g.sheetCancelled(this.name),this.button.disabled=!1,(u=this.abortController)==null||u.abort()}),d(this,"onpaymentauthorized",async u=>{g.authorizationAttempt(this.name),ht(B.AuthorizationLatency,this.name);const h=N=>{g.authorizationComplete({instrument:this.name,measurement:de(B.AuthorizationLatency,this.name),result:"failed"}),this.terminateSession(N)},p=async N=>{var G,U;switch((G=N.effects)==null||G.forEach(k=>k()),N.action){case"complete":{const k=ApplePaySession.STATUS_SUCCESS;try{await this.completePayment(k),ce(N.redirectUrl)}catch(re){h(re)}break}case"show_error":{const k=(U=N.errors)!=null?U:[];try{await this.completePayment(ApplePaySession.STATUS_FAILURE,k)}catch(re){h(re)}break}case"abort":{try{await this.completePayment(ApplePaySession.STATUS_FAILURE),this.button.disabled=!1,this.removePersonalData()}catch(k){h(k)}break}case"decelerate":{try{await this.completePayment(ApplePaySession.STATUS_FAILURE),await this.removePersonalData(),M({checkoutUrl:N.redirectUrl,instrumentName:this.name,reason:N.reason})}catch(k){h(k)}break}default:h(new Error("[".concat(this.name,"] completion action not handled: ").concat(N.action)))}},{token:y,billingContact:E,shippingContact:f}=u.payment;let A=null,I=null;try{if(!E){await this.completePayment(ApplePaySession.STATUS_FAILURE);return}if(A=gt(T(_({},E),{phoneNumber:f==null?void 0:f.phoneNumber})),this.isShippingRequired){if(!f){await this.completePayment(ApplePaySession.STATUS_FAILURE);return}I=gt(f)}}catch(N){h(N);return}const O=async()=>{var N;try{const G=this.isShippingRequired?{validateAddress:!0,streetAddress:I}:{},U=(N=this.customerAccountEmail)!=null?N:f==null?void 0:f.emailAddress,k=await xe(_({cartId:this.cart.id,emailAddress:U,cartClient:this.apiClient,instrumentName:this.name},G));if(await this.decelerateIfNeeded(k))return;const re=this.paymentSheetActionGenerator.mapMutationResultToPaymentSheetAction(k,{shippingRequired:this.isShippingRequired,shippingCountryCode:I==null?void 0:I.country});await Qt({paymentSheetAction:re,onProceed:async pt=>{pt&&pt.length>0?await this.completePayment(ApplePaySession.STATUS_FAILURE,pt):await F()},terminateSession:h})}catch(G){h(G)}},F=async()=>{var N;try{const G=this.cart.lineItems.some(re=>!!re.sellingPlanAllocation),U=await Rr({cartId:this.cart.id,totalAmount:this.cart.totalAmount,paymentMethod:{walletPaymentMethod:{applePayWalletContent:{billingAddress:A,data:y.paymentData.data,header:y.paymentData.header,lastDigits:y.paymentMethod.displayName.split(" ")[1],signature:y.paymentData.signature,version:y.paymentData.version}}},canUsePaymentMethodForFreeOrder:!1,billingAddress:A,cartClient:this.apiClient,instrumentName:this.name,hasSellingPlan:G,abortSignal:(N=this.abortController)==null?void 0:N.signal});if(await this.decelerateIfNeeded(U))return;const k=this.paymentSheetActionGenerator.mapMutationResultToPaymentSheetAction(U,{shippingRequired:this.isShippingRequired,shippingCountryCode:I==null?void 0:I.country});await Qt({paymentSheetAction:k,onProceed:async re=>{re&&re.length>0?await this.completePayment(ApplePaySession.STATUS_FAILURE,re):await qe()},terminateSession:h})}catch(G){h(G)}},qe=async()=>{try{const N=await wa({cartId:this.cart.id,token:y.transactionIdentifier,cartClient:this.apiClient,instrumentName:this.name}),G=this.paymentSheetActionGenerator.mapCompletionResultToPaymentSheetAction(N,{shippingRequired:this.isShippingRequired,shippingCountryCode:I==null?void 0:I.country});await p(G)}catch(N){h(N)}};await O()}),d(this,"terminateSession",async u=>{var h;try{this.button.disabled=!1,u&&w.notify(u),g.sheetFailed(this.name,u);try{w.leaveBreadcrumb("ApplePay Session abort",{},"log"),this.session.abort(),(h=this.abortController)==null||h.abort()}catch(p){console.debug("[DEBUG] InvalidAccessError occurred during Apple Pay terminateSession")}if(u){const p=this.i18n.translate("brand.apple_pay");J(p,this.i18n)}}finally{await this.removePersonalData()}}),d(this,"getMostRecentNonNullCart",(u,h)=>u?(this.cart=u,u):h),d(this,"handleNullCart",u=>{if(!u)throw new Error("[".concat(this.name,"] no cart returned on mutation, aborting"))}),d(this,"completeShippingContactSelection",(u,h)=>{try{const p=this.getMostRecentNonNullCart(u,this.cart),{newTotal:y,newLineItems:E}=this.getNewTotalAndLineItems(p),f=cl(p.deliveryGroups,this.i18n);w.leaveBreadcrumb("ApplePay Session completeShippingContactSelection",{errors:h,newTotal:y,newLineItems:E,newShippingMethods:f},"log"),this.session.completeShippingContactSelection({errors:h!=null?h:[],newTotal:y,newLineItems:E,newShippingMethods:f})}catch(p){this.terminateSession(p)}}),d(this,"completeShippingMethodSelection",u=>{try{this.handleNullCart(u),this.cart=u;const{newTotal:h,newLineItems:p}=this.getNewTotalAndLineItems(u);w.leaveBreadcrumb("ApplePay Session completeShippingContactSelection",{newTotal:h,newLineItems:p},"log"),this.session.completeShippingMethodSelection({newTotal:h,newLineItems:p})}catch(h){this.terminateSession(h)}}),d(this,"sessionIsCancelled",()=>this.cancelled),this.accessToken=e,this.buyerCountry=n,this.button=a,this.cart=null,this.apiClient=l,this.dataSource=s,this.i18n=i,this.merchantName=o,this.cancelled=!1,this.buyerCurrency=r,this.customerAccountEmail=c.customerAccountEmail,this.session=new ApplePaySession(Pn,hl({shippingRequired:this.isShippingRequired,walletParams:c,buyerCurrency:r})),this.session.onvalidatemerchant=this.onvalidatemerchant,this.session.onshippingcontactselected=this.onshippingcontactselected,this.session.onshippingmethodselected=this.onshippingmethodselected,this.session.onpaymentmethodselected=this.onpaymentmethodselected,this.session.oncancel=this.oncancel,this.session.onpaymentauthorized=this.onpaymentauthorized,this.paymentSheetActionGenerator=new ul(i)}begin(){w.leaveBreadcrumb("ApplePay Session begin",{},"log"),this.abortController=Ve("AbortController"),this.session.begin()}async applyPaymentSheetActions(e,n,r){var a;const i=this.paymentSheetActionGenerator.mapMutationResultToPaymentSheetAction(e,r);(a=i.effects)==null||a.forEach(o=>o()),!this.sessionIsCancelled()&&await Qt({paymentSheetAction:i,onProceed:n,terminateSession:this.terminateSession})}async getMerchantSession(e){const n=await new Gt({accessToken:this.accessToken,country:this.buyerCountry,locale:this.i18n.locale,apiVersion:"unstable"}).applePaySessionCreate(e);return JSON.parse(n)}async completePayment(e,n=void 0){w.leaveBreadcrumb("ApplePay Session completePayment",{status:e,errors:n},"log"),this.session.completePayment({status:e,errors:n}),g.authorizationComplete({instrument:this.name,measurement:de(B.AuthorizationLatency,this.name),result:e===ApplePaySession.STATUS_SUCCESS?"success":"failed"})}getNewTotalAndLineItems(e){return{newTotal:sl(this.merchantName,e.totalAmount),newLineItems:ll({subtotal:ia(e),discountAllocations:pl(e),deliveryGroups:e.deliveryGroups,duties:e.totalDutyAmount,taxes:e.totalTaxAmount,i18n:this.i18n,formattedRecurringTotals:ml(this.cart.lineItems,this.i18n)})}}async decelerateIfNeeded(e){if(!e.data)return!1;const{checkoutUrl:n,totalAmount:r}=e.data;let a;if(e.decelerationReason&&Jl.includes(e.decelerationReason)?a=e.decelerationReason:Sr({currentCartTotal:r,initialBuyerCurrency:this.buyerCurrency})&&(a="currency_changed"),a){try{await this.terminateSession()}finally{M({checkoutUrl:n,instrumentName:this.name,reason:a})}return!0}return!1}get isShippingRequired(){return this.button.isShippingRequired}async removePersonalData(){this.isPersonalDataCleared||(await this.apiClient.cartRemovePersonalData({cartId:this.cart.id,instrumentName:this.name}),this.isPersonalDataCleared=!0)}}function Nr({translate:t,logoElement:e,setAriaHidden:n}){const r=document.createElement("div");return t("buy_with_button_content",{wallet:"LOGO_PLACEHOLDER"}).split(new RegExp("(LOGO_PLACEHOLDER)")).filter(Boolean).forEach(a=>{let i;a==="LOGO_PLACEHOLDER"?i=e:(i=document.createElement("span"),i.innerText=a,n&&i.setAttribute("aria-hidden","true")),r.appendChild(i)}),r}var Ue;class ec extends Re{constructor(){super(),d(this,"name",b.ApplePay),d(this,"button",null),x(this,Ue),L(this,Ue,this.attachShadow({mode:"closed"}))}static get observedAttributes(){return["disabled"]}get merchantName(){return this.walletParams.merchantName}connectedCallback(){this.cleanupOnFailure(this.render.bind(this),this.name)}attributeChangedCallback(e,n,r){super.attributeChangedCallback(e,n,r,this.button)}async handleClick(e){if(e.preventDefault(),this.disabled||!this.button||this.button.hasAttribute("aria-disabled"))return;this.disabled=!0;const[n,r,a]=await Promise.all([this.i18n,this.dataSource,this.apiClient]);let i;try{if(i=new Zl({accessToken:this.accessToken,buyerCountry:this.buyerCountry,buyerCurrency:this.buyerCurrency,button:this,i18n:n,merchantName:this.merchantName,dataSource:r,apiClient:a,walletParams:this.walletParams}),!i)throw new Error("missing ApplePaySession");i.begin(),g.sheetClicked({instrument:this.name,result:"success"})}catch(o){w.notify(o),g.sheetClicked({instrument:this.name,result:"failed"}),i==null||i.terminateSession()}}async render(){var e;const{translate:n}=await this.i18n,r=new DOMParser().parseFromString(Aa.applePayLogo,"image/svg+xml").documentElement;if(!this.button){const a=this.isCTA?n("buy_with_button_content",{wallet:n("brand.apple_pay")}):n("brand.apple_pay");if(this.button=Mt({label:a}),this.button.onclick=i=>this.handleClick(i),this.button.classList.add("apple-pay-button",Za[this.buttonTheme],Pe.BUTTON),this.isCTA){const i=Nr({translate:n,logoElement:r,setAriaHidden:!0});i.classList.add("apple-pay--content"),this.button.appendChild(i)}else this.button.appendChild(r);this.initializeShadowStyles(C(this,Ue),Zs),C(this,Ue).appendChild(this.button),this.ensureLightDOMIsNotEmpty(),(e=this.onRendered)==null||e.call(this)}this.disabled&&(this.button.setAttribute("disabled",""),this.button.setAttribute("aria-disabled","true"))}}Ue=new WeakMap;function Tr(t){return function(e,n,r){const a=r.value;return r.value=function(...i){const o=a.apply(this,i);return o.eligible||console.debug("[DEBUG] ".concat(t," could not be rendered. Reason: ").concat(o.reason)),o},r}}var tc=Object.defineProperty,rc=Object.getOwnPropertyDescriptor,Ea=(t,e,n,r)=>{for(var a=rc(e,n),i=t.length-1,o;i>=0;i--)(o=t[i])&&(a=o(e,n,a)||a);return a&&tc(e,n,a),a},se;const kr=(se=class extends me{constructor(t){super(t),d(this,"companyFieldRequired"),this.companyFieldRequired=!!this.walletParams.companyRequired}static walletName(){return"apple_pay"}getWebComponentName(){return"shopify-apple-pay-button"}getWebComponentClass(){return ec}getInstrumentName(){return b.ApplePay}applePayInIframe(){return typeof window>"u"||window.self!==window.top}getLoadEligibility(){return this.applePayInIframe()?{eligible:!1,reason:"cannot be loaded in an iframe"}:{eligible:!0}}getPartnerSDKEligibility(){var t,e,n,r;return typeof window>"u"||window.ApplePaySession===void 0?{eligible:!1,reason:"window or ApplePaySession is undefined"}:(e=(t=window.ApplePaySession).supportsVersion)!=null&&e.call(t,Pn)?(r=(n=window.ApplePaySession).canMakePayments)!=null&&r.call(n)?{eligible:!0}:{eligible:!1,reason:"failed SDK eligibility check"}:{eligible:!1,reason:"SDK does not meet minimum version requirement"}}async loadWalletSDK(){await this.loadAppleLogo()}async loadAppleLogo(){if(se.applePayLogo=(await import("./apple-pay-logo-BZB6IYWC.js")).default,!se.applePayLogo)throw new Error("Apple Pay logo is empty")}},d(se,"applePayLogo",""),se);Ea([Tr("Apple Pay")],kr.prototype,"getLoadEligibility"),Ea([Tr("Apple Pay")],kr.prototype,"getPartnerSDKEligibility");let Aa=kr;const nc=".buy-with-prime-button{width:100%;height:100%;padding:12px 10px 8px;display:flex;align-items:center;justify-content:center;gap:5px;opacity:1;border-width:0px}.buy-with-prime-button:hover:enabled{background-color:#0684eb!important}.buy-with-prime-button:focus{box-shadow:0 0 0 2px #1a98ff,inset 0 0 0 2px rgb(var(--color-background))!important;outline:none!important}.buy-with-prime-button:active,.buy-with-prime-button:hover:enabled:active{background-color:#0066cd!important;box-shadow:none!important}";class Dt extends Error{constructor(){super(...arguments),d(this,"name","MissingAccessTokenError")}}class Lr extends Error{constructor(){super(...arguments),d(this,"name","FetchingWalletsPlatformConfigError")}}class Or extends Error{constructor(){super(...arguments),d(this,"name","EmptyLineItemsWalletsPlatformConfigError")}}async function Ca({configOptionsEndpoint:t,checkoutUrl:e,sourceId:n,accessToken:r,instrument:a}){try{const i=JSON.stringify({checkout_url:e,checkout_cancel_url:window.location.href,cart_id:n}),o=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":r},body:i});if(o.ok)return o.json();const s=await o.json();throw s.error?new Error(s.error):new Error("Could not fetch wallets platform configs: [".concat(o.status,"] ").concat(o.statusText))}catch(i){const{message:o}=i!=null?i:{};switch(o){case"empty_line_items":throw new Or("[Fetch Pay Config][".concat(a,"] No eligible line items provided in the config request."));default:throw new Lr("[Fetch Pay Config][".concat(a,"] ").concat(o))}}}const ac={[S.Checkout]:"Checkout",[S.CartAjax]:"Cart",[S.CartPage]:"Cart",[S.ProductPage]:"Product",[S.Unknown]:"Product"};var st;const ke=class tu extends Re{constructor(){super(...arguments),d(this,"name",b.BuyWithPrime),d(this,"button",null),d(this,"apiClientId",""),x(this,st,this.attachShadow({mode:"closed"}))}connectedCallback(){this.cleanupOnFailure(this.render.bind(this),this.name),this.handleOnSendCheckoutAction=this.handleOnSendCheckoutAction.bind(this)}async createButton(){const{translate:e}=await this.i18n,n=Mt({label:e("brand.buy_with_prime")});return n.type="button",n.className="buy-with-prime-button",this.applyEnabledStyles(n),n}applyEnabledStyles(e){e.innerHTML=it.primeLogo,e.disabled=!1,Yr(e,{"background-color":"#1A98FF",color:"#FFFFFF",cursor:"pointer"})}applyDisabledStyles(e){e.innerHTML=it.primeLogoDark,e.disabled=!0,Yr(e,{"background-color":"#C0E3FF",color:"#7292AC",cursor:"not-allowed"})}async handleClick(){var e,n,r;if(!this.button)return;const[a,i]=await Promise.all([this.i18n,this.dataSource]);let o=[];try{this.applyDisabledStyles(this.button);let s=this.walletParams;if(this.apiClientId=this.apiClientId||s.appId||"",!s.createCheckoutSessionConfig){const{cart:c,decelerationReason:u,customValidationError:h}=await pe({element:this,instrumentName:this.name,dataSource:i});if(h){ve(a,h.message);return}if(u){M({checkoutUrl:(e=c==null?void 0:c.checkoutUrl)!=null?e:"",instrumentName:this.name,reason:u});return}if(!this.accessToken)throw new Dt("[Fetch Pay Config] could not fetch pay configs since required accessToken is missing.");s=_({},await Ca({configOptionsEndpoint:tu.OPTIMUS_CONFIG_REST_API_URL,checkoutUrl:(n=c==null?void 0:c.checkoutUrl)!=null?n:"",sourceId:(r=Bn(c))!=null?r:"",accessToken:this.accessToken,instrument:this.name}))}s.placement=this.getPlacement(),o=this.extractSKUs(s),delete s.checkoutSupportsSplitCart,delete s.appId;const l=s;this.pciEnabled&&(l.onSendCheckoutAction=this.handleOnSendCheckoutAction),window.amazon.buywithprime.initCheckout({amazonPayOptions:l}),g.sheetClicked({instrument:this.name,result:"success",webPixelMetaData:this.apiClientId?{apiClientId:this.apiClientId,skus:o,pageType:this.pageType}:void 0})}catch(s){tu.EXPECTED_ERRORS.some(u=>s instanceof u)||w.notify(s),g.sheetClicked({instrument:this.name,result:"failed",webPixelMetaData:this.apiClientId?{apiClientId:this.apiClientId,skus:o,pageType:this.pageType}:void 0});const{name:l}=s!=null?s:{name:"unknown"},{translate:c}=a;De(c("error_dialogs.wallet.title",{wallet:c("brand.buy_with_prime")}),this.getModalContent(l,c))}finally{this.applyEnabledStyles(this.button)}}getModalContent(e,n){return e==="EmptyLineItemsWalletsPlatformConfigError"?n("error_dialogs.wallet.eligibility_error",{wallet:n("brand.buy_with_prime")}):n("error_dialogs.wallet.generic_error",{wallet:n("brand.buy_with_prime")})}extractSKUs(e){var n;return(n=e.createCheckoutSessionConfig)!=null&&n.payloadJSON?JSON.parse(e.createCheckoutSessionConfig.payloadJSON).cartDetails.lineItems.map(r=>r&&r.sku).filter(r=>r):[]}getPlacement(){return this.pageType&&ac[this.pageType]||"Other"}async render(){var e;this.button||(this.button=await this.createButton(),this.button.onclick=()=>this.handleClick(),this.button.classList.add("buy-with-prime-button"),this.getPlacement().includes("Checkout")||this.button.classList.add(Pe.BUTTON),await this.initializeShadowStyles(C(this,st),nc),C(this,st).appendChild(this.button),(e=this.onRendered)==null||e.call(this))}buildBwpEventData(e){const n={};return e.createCheckoutSessionConfig&&(n.skus=this.extractSKUs(e),n.apiClientId=this.apiClientId),n}async handleOnSendCheckoutAction(e){const{eventName:n,redirect:r,redirectUrl:a,requestPayload:i}=e;if(r&&a){this.dispatchWalletEvent({eventName:"wallet-redirect",detail:{redirectUrl:a,requestPayload:i}});return}switch(n){case"initCheckout":{const o=this.walletParams;this.dispatchWalletEvent({eventName:"wallet-clicked",detail:{bwpEventData:this.buildBwpEventData(o)}});break}case"initChange":this.dispatchWalletEvent({eventName:"wallet-clicked"});break;case"cancelCheckout":this.dispatchWalletEvent({eventName:"wallet-cancel"});break}}};st=new WeakMap,d(ke,"OPTIMUS_CONFIG_REST_API_URL","".concat(window.location.origin,"/wallets/config/optimus")),d(ke,"EXPECTED_ERRORS",[Lr,Dt,Or]);let lr=ke;async function Sa({fn:t,maxRetries:e=3,delay:n=1e3,retryPolicyFn:r=()=>!0,onFinishedFn:a=()=>{}}){const i=()=>new Promise(l=>{setTimeout(l,n)});let o=0;const s=async()=>{try{return await t()}catch(l){if(o++,o{if(document.querySelector('script[src="'.concat(t,'"]'))&&window.amazon){e();return}const r=document.createElement("script");r.src=t,r.onload=()=>{window.amazon?e():n(new Error("Amazon SDK not present after loading"))},r.onerror=()=>{n(new Tt("Error loading Amazon SDK"))},document.head.append(r)})}async function Ia({sdkUrl:t=yr,maxRetries:e=3}){return Sa({fn:()=>ic(t),maxRetries:e,delay:200,retryPolicyFn:()=>!0,onFinishedFn:n=>{g.amazonPaySDKLoadRetries({retries:n})}})}const Y=class In extends me{static walletName(){return"buy_with_prime"}constructor(e){super(e)}getWebComponentName(){return"shopify-buy-with-prime-button"}getInstrumentName(){return b.BuyWithPrime}getWebComponentClass(){return lr}async loadWalletSDK(){await Ia({sdkUrl:In.SDK_URL,maxRetries:In.MAX_RETRIES}),await this.loadLogos()}async loadLogos(){await Promise.all([this.loadPrimeLogo(),this.loadPrimeLogoDark()])}async loadPrimeLogo(){if(In.primeLogo=(await import("./prime-logo-DoVHKBSO.js")).default,!In.primeLogo)throw new Error("Buy with Prime logo is empty")}async loadPrimeLogoDark(){if(In.primeLogoDark=(await import("./prime-logo-dark-DJIA6J0w.js")).default,!In.primeLogoDark)throw new Error("Buy with Prime logo dark is empty")}};d(Y,"MAX_RETRIES",3),d(Y,"SDK_URL",yr),d(Y,"primeLogo",""),d(Y,"primeLogoDark","");let it=Y;const oc="shopify-amazon-pay-button div[role=button][slot=amazon-pay-slot][data-testid=amazon-pay-button]{border-radius:0!important}",ln="amazon-pay-slot";var lt,ct,$e,W,oe,we,_e;const Le=class nu extends Re{constructor(){super(),d(this,"name",b.AmazonPay),d(this,"resizeObserver",null),x(this,lt,0),x(this,ct,0),x(this,$e,!1),x(this,W,null),x(this,oe,null),x(this,we,null),x(this,_e),L(this,_e,this.attachShadow({mode:"closed"})),this.resizeObserver=Ve("ResizeObserver",()=>this.onResize())}connectedCallback(){this.cleanupOnFailure(this.render.bind(this),this.name)}async disconnectedCallback(){var e;this.innerHTML="",C(this,_e).innerHTML="",this.teardownAmazonButtonContainer(),(e=this.resizeObserver)==null||e.disconnect()}async handleClick(e){var n,r;const[a,i]=await Promise.all([this.i18n,this.dataSource]);try{const{cart:o,decelerationReason:s,customValidationError:l}=await pe({element:this,instrumentName:this.name,dataSource:i});if(l){ve(a,l.message);return}if(s){M({checkoutUrl:(n=o==null?void 0:o.checkoutUrl)!=null?n:"",instrumentName:this.name,reason:s});return}const{totalAmount:{amount:c},checkoutUrl:u}=o;let h=this.walletParams;if(!h.createCheckoutSessionConfig){if(!this.accessToken)throw new Dt("[Fetch Pay Config] could not fetch pay configs since required accessToken is missing.");h=T(_({},await Ca({configOptionsEndpoint:nu.CV2_CONFIG_REST_API_URL,checkoutUrl:u,sourceId:(r=Bn(o))!=null?r:"",accessToken:this.accessToken,instrument:this.name})),{placement:this.pageType===S.ProductPage?"Product":"Cart"})}delete h.appId,e.initCheckout(_(_({},h),Number(c)!==0&&{estimatedOrderAmount:{amount:c,currencyCode:this.buyerCurrency}})),g.sheetClicked({instrument:this.name,result:"success"})}catch(o){nu.EXPECTED_ERRORS.some(l=>o instanceof l)||w.notify(o),g.sheetClicked({instrument:this.name,result:"failed"});const s=a.translate("brand.amazon_pay");J(s,a)}}createContainer({containerID:e,height:n}){const r=document.createElement("div");return r.id=e,r.style.display="flex",n!=null&&(r.style.height="".concat(n,"px")),r.slot=ln,r.setAttribute("data-testid","amazon-pay-button"),r}async onResize(){const e=St(C(this,W))||0,n=It(C(this,W))||0,r=C(this,lt)!==e||C(this,ct)!==n;!C(this,$e)&&r&&(this.teardownAmazonButtonContainer(),await this.cleanupOnFailure(()=>this.renderFromAmazonSDK(),this.name))}async render(){var e;try{const n=document.createElement("slot");n.name=ln;const r=document.createElement("style");r.textContent=oc,this.appendChild(r),await this.initializeShadowStyles(C(this,_e));const a=await this.containerInstanceNumber;L(this,oe,"AcceleratedCheckoutAmazonPayButtonContainer".concat(this.pageType).concat(a)),L(this,W,document.createElement("div")),C(this,W).classList.add(Pe.BUTTON),C(this,W).appendChild(n),C(this,_e).appendChild(C(this,W)),(e=this.resizeObserver)==null||e.observe(C(this,W)),await this.renderFromAmazonSDK()}catch(n){w.notify(n)}}async renderFromAmazonSDK(){var e;try{L(this,$e,!0);const n=It(C(this,W))||0;L(this,we,this.createContainer({containerID:C(this,oe),height:n})),this.appendChild(C(this,we));const r=St(C(this,W))||0,a={buttonBorderRadius:"".concat(r,"px")},i=window.amazon.Pay.renderButton("#".concat(C(this,oe)),T(_({},this.walletParams),{style:a,placement:this.pageType===S.ProductPage?"Product":"Cart"}));i==null||i.onClick(()=>this.handleClick(i)),L(this,ct,n),L(this,lt,r),g.renderSucceeded(this.name),(e=this.onRendered)==null||e.call(this)}catch(n){g.renderFailed(this.name);const r="Amazon Pay Button not able to render into container #".concat(C(this,oe),".");console.error(r),g.log({body:r,attributes:{pageType:this.pageType,containerID:C(this,oe),error:n==null?void 0:n.toString()}})}finally{L(this,$e,!1)}}teardownAmazonButtonContainer(){var e;(e=C(this,we))==null||e.remove(),L(this,we,null)}};lt=new WeakMap,ct=new WeakMap,$e=new WeakMap,W=new WeakMap,oe=new WeakMap,we=new WeakMap,_e=new WeakMap,d(Le,"CV2_CONFIG_REST_API_URL","".concat(window.location.origin,"/wallets/config/amazon_pay")),d(Le,"EXPECTED_ERRORS",[Lr,Dt,Or]);let cr=Le;const Oe=class ru extends me{static walletName(){return"amazon_pay"}constructor(e){super(e)}getWebComponentName(){return"shopify-amazon-pay-button"}getInstrumentName(){return b.AmazonPay}getWebComponentClass(){return cr}async loadWalletSDK(){await Ia({sdkUrl:ru.SDK_URL,maxRetries:ru.MAX_RETRIES})}getLoadEligibility(e){return e.getRootNode()instanceof ShadowRoot?{eligible:!1,reason:"Cannot load Amazon Pay within Shadow DOM"}:{eligible:!0}}};d(Oe,"MAX_RETRIES",3),d(Oe,"SDK_URL",yr);let dr=Oe;var Jt={Purple:{D0:"#4524DB",Primary:"#5433EB"},Grayscale:{White:"#FFFFFF"}},sc={s:16},lc=class extends HTMLElement{static get observedAttributes(){return["disabled"]}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this._updateButton()}attributeChangedCallback(){this._updateButton()}_updateButton(){var t;let e=this.shadowRoot;e&&(e.innerHTML=dc,this.hasAttribute("disabled")&&((t=this.shadowRoot.querySelector("button"))==null||t.setAttribute("disabled","")))}};function cc(){window.customElements&&(customElements.get("gravity-button")||customElements.define("gravity-button",lc))}var dc="\n\n\n\n');const uc=".button-content{display:flex;align-items:center;justify-content:center;width:100%;height:100%;gap:3px;white-space:nowrap;container-type:inline-size;container-name:bc}.ShopPromise>.separator{margin:0 8px}@container bc (width <= 338px){.ShopPromise{display:none!important}}gravity-button{display:block}",hc='.accelerated-checkout-button{height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 44px),55px);min-height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 44px),55px);border-radius:var(--shopify-accelerated-checkout-button-border-radius, 0px);box-shadow:var(--shopify-accelerated-checkout-button-box-shadow);min-width:150px}:host([page-type="cart_page"]) .accelerated-checkout-button{height:100%;width:100%;border-radius:var(--shopify-accelerated-checkout-button-border-radius, 4px);box-shadow:var(--shopify-accelerated-checkout-button-box-shadow)}@media (forced-colors: active){.accelerated-checkout-button{border:1px solid transparent!important}:host([page-type="cart_page"]) .accelerated-checkout-button{border:1px solid transparent!important}}.accelerated-checkout-button{--gravity-button-height: clamp(25px, var(--shopify-accelerated-checkout-button-block-size, 44px), 55px);--gravity-button-min-height: clamp(25px, var(--shopify-accelerated-checkout-button-block-size, 44px), 55px);--gravity-button-border-radius: var(--shopify-accelerated-checkout-button-border-radius, 0px);--gravity-button-padding: 0px 10px;--gravity-button-width: 100%}:host([page-type="cart_page"]) .accelerated-checkout-button{--gravity-button-height: 100%;--gravity-button-min-height: 100%;--gravity-button-border-radius: var(--shopify-accelerated-checkout-button-border-radius, 4px);--gravity-button-width: 100%}';class Pa extends Error{constructor(){const e="DeliveryEstimatesResponseIsNullError";super("deliveryEstimates is null or undefined"),this.name=e}}class Zt extends Error{constructor(){const e="DeliveryPromiseAPIClientError";super("window.Shopify.ShopPromise.deliveryPromiseAPIClient is undefined"),this.name=e}}const pc=15,mc=200;class yc{constructor(e){d(this,"storefrontAPIToken"),this.storefrontAPIToken=e}async fetchDeliveryPromise({variant:e,postalCode:n,defaultPostalCode:r,sellingPlanId:a}){const i=await Sa({fn:async()=>this.fetchDeliveryOptions(e,n,r,a),maxRetries:pc,delay:mc,retryPolicyFn:o=>o instanceof Zt}).catch(o=>{if(o instanceof Zt)throw o;return null});if(!i)throw new Pa;return i}async fetchDeliveryOptions(e,n,r,a){var i,o;const s={variantId:e,sellingPlanId:a,postalCode:n||r,isPostalCodeOverride:!!n},l=(o=(i=window==null?void 0:window.Shopify)==null?void 0:i.ShopPromise)==null?void 0:o.deliveryPromiseAPIClient;if(!l)throw new Zt;return l(s,this.storefrontAPIToken)}}function gc(t,e){switch(t){case 0:return(e==null?void 0:e.translate("shop_promise_delivery.same_day"))||null;case 1:return(e==null?void 0:e.translate("shop_promise_delivery.next_day"))||null;case 2:return(e==null?void 0:e.translate("shop_promise_delivery.two_day"))||null;default:return null}}const fc="delivery_promise_default_address",bc="delivery_promise_postal_code";class wc extends Ut{constructor(){super(...arguments),d(this,"lastFetchedProductVariantId"),d(this,"lastFetchSellingPlan"),d(this,"fetching",!1),d(this,"i18n",null),d(this,"daysToDelivery"),d(this,"formObserver",null)}async connectedCallback(){this.formObserver=new Qn(this,({variantId:e,sellingPlanId:n})=>{this.fetchDeliveryPromise(e,n)}),this.formObserver.setupMutationObservers()}setTranslations(e){this.i18n=e,this.render()}get postalCode(){try{return JSON.parse(at(bc)||"null")||null}catch(e){return null}}get defaultDeliveryAddress(){try{return JSON.parse(at(fc)||"null")}catch(e){return null}}async fetchDeliveryPromise(e,n){var r,a,i,o;if(!(!e||!this.accessToken)&&!(e===this.lastFetchedProductVariantId&&n===this.lastFetchSellingPlan))try{this.lastFetchedProductVariantId=e,this.lastFetchSellingPlan=n;const s=((r=this.defaultDeliveryAddress)==null?void 0:r.zip)||"",l=await new yc(this.accessToken).fetchDeliveryPromise({variant:e,postalCode:this.postalCode||"",defaultPostalCode:s,sellingPlanId:n||""}),c=vr(this),u=(i=(a=l==null?void 0:l.selectedShippingOption)==null?void 0:a.brandedPromise)==null?void 0:i.handle;if((c==null?void 0:c.sellingPlanId)!==n||(c==null?void 0:c.variantId)!==e||u!=="shop_promise")return;this.daysToDelivery=(o=l==null?void 0:l.selectedShippingOption)==null?void 0:o.maxCalendarDaysToDelivery,this.render()}catch(s){s instanceof Pa&&(this.daysToDelivery=null)}}render(){const e=gc(this.daysToDelivery,this.i18n);this.classList.add("ShopPromise"),this.innerHTML=e?'|'.concat(e,""):""}}var Ee;class _c extends Re{constructor(){super(),d(this,"name",b.ShopPay),d(this,"button",null),d(this,"shopPromiseProductPageContent",null),d(this,"shopPromiseEligible",!1),x(this,Ee),L(this,Ee,this.attachShadow({mode:"closed"}))}static get observedAttributes(){return["disabled"]}connectedCallback(){this.shopPromiseEligible=Hn(),this.cleanupOnFailure(async()=>{cc(),await this.render()},this.name)}attributeChangedCallback(e,n,r){super.attributeChangedCallback(e,n,r,this.button)}async addButtonContent(){if(!this.button)return;let e;const n=await this.i18n,r=new DOMParser().parseFromString(va.shopPayLogoElement,"image/svg+xml").documentElement;this.isCTA?e=Nr({translate:n.translate,logoElement:r,setAriaHidden:!1}):(e=document.createElement("div"),e.appendChild(r)),e.classList.add("button-content"),this.shopPromiseEligible&&!this.shopPromiseProductPageContent&&(this.shopPromiseProductPageContent=document.createElement("shop-promise-product-page-content"),this.shopPromiseProductPageContent.setTranslations(n),this.shopPromiseProductPageContent.setAttribute("access-token",this.accessToken||""),e.appendChild(this.shopPromiseProductPageContent)),this.button.appendChild(e)}getShopPayBehavior(){return this.pageType===S.ProductPage?"force_shop_pay_product":this.pageType===S.CartPage?"force_shop_pay_cart":"force_shop_pay"}async handleClick(e){var n,r;if(e.preventDefault(),this.disabled||!this.button||this.button.getAttribute("disabled"))return;this.disabled=!0;const[a,i]=await Promise.all([this.i18n,this.dataSource]);try{const{decelerationReason:o,cart:s,customValidationError:l}=await pe({element:this,instrumentName:b.ShopPay,dataSource:i});if(g.sheetClicked({instrument:this.name,result:"success"}),l){ve(a,l.message);return}if(o){M({checkoutUrl:(n=s==null?void 0:s.checkoutUrl)!=null?n:"",instrumentName:this.name,reason:o});return}ce((r=s==null?void 0:s.checkoutUrl)!=null?r:"",this.getShopPayBehavior())}catch(o){w.notify(new Ec("An error occurred when attempting to create a cart using the Shop Pay Button. Details: ".concat(o),{cause:o})),g.sheetClicked({instrument:this.name,result:"failed"}),De(a.translate("error_dialogs.checkout.title"),a.translate("error_dialogs.checkout.generic_error"))}}async render(){if(C(this,Ee).innerHTML)return;this.button||(this.button=document.createElement("gravity-button"));const e=document.createElement("style");e.innerHTML=[hc,uc].join("\n"),C(this,Ee).appendChild(e),await this.addButtonContent(),this.disabled&&this.button.setAttribute("disabled",""),this.button.classList.add(Pe.BUTTON),this.button.onclick=n=>this.handleClick(n),C(this,Ee).appendChild(this.button),this.ensureLightDOMIsNotEmpty(),this.onRendered()}}Ee=new WeakMap,he("shop-promise-product-page-content",wc);class Ec extends Error{constructor(){super(...arguments),d(this,"name","ShopPayButtonError")}}var Ac=Object.defineProperty,Cc=Object.getOwnPropertyDescriptor,Sc=(t,e,n,r)=>{for(var a=Cc(e,n),i=t.length-1,o;i>=0;i--)(o=t[i])&&(a=o(e,n,a)||a);return a&&Ac(e,n,a),a},Ae;const Da=(Ae=class extends me{static walletName(){return"shop_pay"}constructor(t){super(t)}getWebComponentName(){return"shop-pay-wallet-button"}getWebComponentClass(){return _c}getInstrumentName(){return b.ShopPay}async loadWalletSDK(){await this.loadLogo()}getLoadEligibility(){return{eligible:!0}}async loadLogo(){Ae.shopPayLogoElement=(await import("./shop-pay-logo-CYhOC7ye.js")).default}},d(Ae,"shopPayLogoElement"),Ae);Sc([Tr("Shop Pay")],Da.prototype,"getLoadEligibility");let va=Da;const Ic=".button{display:flex;justify-content:center;align-items:center;width:100%;border:none}.button:hover:not(:disabled){filter:brightness(92%);cursor:pointer}.button:disabled{opacity:.5;cursor:not-allowed}.logo-only>svg{width:50px}.dark{background:#000;color:#fff}.light{background:#fff;color:#000;outline:1px solid #3c4043}@media (forced-colors: active){.light{outline:none}}.content{display:flex;justify-content:center;align-items:center;white-space:pre}";function er({cart:t,i18n:e}){const n=ia(t),r={label:e.translate("order_summary.subtotal"),type:"SUBTOTAL",price:Se(n.amount)},a=na({deliveryGroups:t.deliveryGroups,i18n:e}).map(s=>Pc({lineItem:s,type:"LINE_ITEM"})),i=Dc(t,e),o=[r,...a,...i];if(t.totalDutyAmount){const s={label:e.translate("order_summary.duties"),type:"LINE_ITEM",price:Se(t.totalDutyAmount.amount)};o.push(s)}if(t.totalTaxAmount){const s={label:e.translate("order_summary.taxes"),type:"TAX",price:Se(t.totalTaxAmount.amount)};o.push(s)}return{totalPrice:t.totalAmount.amount,currencyCode:t.totalAmount.currencyCode,totalPriceStatus:"ESTIMATED",totalPriceLabel:e.translate("order_summary.total"),displayItems:o}}function Pc({lineItem:t,type:e,status:n="FINAL"}){return{label:t.label,type:e,price:t.amount,status:n}}function Dc(t,e){return[...t.lineItems.flatMap(n=>n.discountAllocations),...t.discountAllocations].flatMap(n=>{var r;const a=(r=n.title)!=null?r:n.code;return{label:a!=null?a:e.translate("order_summary.discount"),type:"LINE_ITEM",price:"-".concat(Se(Number(n.discountedAmount.amount)))}})}const Ra=["PAYMENT_AUTHORIZATION"],vc=Ra.concat(["SHIPPING_ADDRESS","SHIPPING_OPTION"]),Rc=["PAN_ONLY"];function Nc({walletParams:t,isShippingRequired:e,hasSellingPlan:n,i18n:r,buyerCurrency:a,authJwt:i}){const o={totalPrice:"0.01",currencyCode:a,totalPriceStatus:"ESTIMATED",totalPriceLabel:r.translate("order_summary.total"),displayItems:[{label:r.translate("order_summary.subtotal"),type:"SUBTOTAL",price:"0.01"}]},s=T(_({},t.paymentData),{shippingAddressRequired:e,shippingOptionRequired:e,transactionInfo:o});return s.merchantInfo.authJwt=i,e||delete s.shippingAddressParameters,s.callbackIntents=e?vc:Ra,n&&Tc(s),s}function Tc(t){t.allowedPaymentMethods.forEach(e=>{e.parameters.allowedAuthMethods=e.parameters.allowedAuthMethods.filter(n=>Rc.includes(n))})}class kc extends aa{constructor(e){super(),d(this,"brandName"),d(this,"completionResult"),this.i18n=e,this.brandName=this.i18n.translate("brand.google_pay"),this.completionResult=void 0}mapMutationResultToPaymentSheetAction(e){const n=this.mapCustomValidationFunctionErrorToAction(e.errors);if(n)return n;const r=this.getErrorActions(),a=e.errors,i=this.getUnhandledErrors(a,r);i.forEach(s=>{w.notify(new Pt("[".concat(b.GooglePay,"] mutation result error not handled: ").concat(s)))});const{firstPaymentSheetAction:o}=this.getMergedPaymentSheetAction({result:e,errorActions:r});return o||(i.length>0?{action:"abort"}:{action:"update",errors:[]})}mapCompletionResultToPaymentSheetAction(e){if(!e.data)throw new Error("[".concat(b.GooglePay,"] completion returned null result"));switch(this.completionResult=e,e.data.__typename){case"SubmitSuccess":return{action:"complete",redirectUrl:e.data.redirectUrl};case"SubmitAlreadyAccepted":case"SubmitThrottled":case"SubmitFailed":{const n=this.mapCustomValidationFunctionErrorToAction(e.errors);if(n)return n;const r=this.getErrorActions(),a=e.errors;this.getUnhandledErrors(a,r).forEach(o=>{w.notify(new Error("[".concat(b.GooglePay,"] completion result error not handled: ").concat(o)))});const{prioritizedPaymentSheetAction:i}=this.getMergedPaymentSheetAction({result:e,errorActions:r});return i||(J(this.brandName,this.i18n),{action:"abort"})}default:throw new Error("[".concat(b.GooglePay,"] unknown completion result type: ").concat(e.data.__typename))}}getErrorActions(){return[{errors:[m.CaptchaCompletionRequired],generateAction:()=>this.decelerateOrAbort({reason:"captcha_required",instrumentName:b.GooglePay,errorOrWarning:m.CaptchaCompletionRequired,result:this.completionResult})},{errors:[m.InvalidLanguage],generateAction:()=>({action:"abort",effects:[()=>{w.notify(new Error("[".concat(b.GooglePay,"] mutation provided invalid language, aborting")))},()=>J(this.brandName,this.i18n)]})},{errors:[m.InvalidCountry],generateAction:()=>({action:"abort",effects:[()=>{w.notify(new Error("[".concat(b.GooglePay,"] mutation provided invalid country, aborting")))},()=>J(this.brandName,this.i18n)]})},{errors:[m.MissingCartId],generateAction:()=>({action:"abort",effects:[()=>{w.notify(new Error("[".concat(b.GooglePay,"] mutation provided invalid cart ID, aborting")))},()=>J(this.brandName,this.i18n)]})},{errors:Cr,generateAction:()=>this.decelerateOrAbort({reason:"dynamic_tax",instrumentName:b.GooglePay,errorOrWarning:m.NewTaxMustBeAccepted,result:this.completionResult})},{errors:[m.MerchandiseExpectedPriceMismatch,m.DeliveryLineChanged,m.DeliveryLocalPickupLineChanged,...zn],generateAction:()=>({action:"abort",effects:[()=>J(this.brandName,this.i18n)]})},{errors:[m.UnsupportedGooglePayPaymentMethod],generateAction:()=>({action:"abort",effects:[()=>J(this.brandName,this.i18n),()=>{w.notify(new Pt("[".concat(b.GooglePay,"] payment method is not supported")))}]})},{errors:[m.MerchandiseNotEnoughStock],generateAction:()=>this.decelerateOrAbort({reason:"not_enough_stock",instrumentName:b.GooglePay,errorOrWarning:m.MerchandiseNotEnoughStock,result:this.completionResult})},{errors:qn,generateAction:()=>this.decelerateOrAbort({reason:"out_of_stock",instrumentName:b.GooglePay,errorOrWarning:m.MerchandiseOutOfStock,result:this.completionResult})},{errors:Vn,generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_UNSERVICEABLE",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.invalid.shipping_address")}]})},{errors:Gn,generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.invalid.postal_code")}]})},{errors:[m.NoDeliveryGroupSelected],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_OPTION_INVALID",intent:"SHIPPING_OPTION",message:this.i18n.translate("errors.missing.shipping_option")}]})},{errors:[m.BuyerIdentityEmailDomainInvalid,m.BuyerIdentityEmailNotExpectedPattern,m.BuyerIdentityEmailInvalid],generateAction:()=>({action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.invalid.email")}]})},{errors:[m.BuyerIdentityEmailRequired],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.missing.email")}]})},{errors:[m.DeliveryAddress2Required,m.DeliveryAddress2AddressFieldRequired],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.missing.address2")}]})},{errors:[m.DeliveryAddress2Invalid],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.invalid.address2")}]})},{errors:[m.DeliveryCityAddressFieldRequired,m.DeliveryCityRequired],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.missing.city")}]})},{errors:[m.DeliveryCityInvalid],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.invalid.city")}]})},{errors:[m.DeliveryZoneRequiredForCountry],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.missing.zone")}]})},{errors:[m.DeliveryZoneNotFound],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.invalid.zone")}]})},{errors:[m.DeliveryPostalCodeRequired,m.DeliveryPostalCodeAddressFieldRequired],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.missing.postal_code")}]})},{errors:[m.DeliveryPostalCodeInvalid,m.DeliveryInvalidPostalCodeForZone,m.DeliveryInvalidPostalCodeForCountry,m.DeliveryZipInvalidForCountry],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.invalid.postal_code")}]})},{errors:[m.DeliveryPhoneNumberRequired],generateAction:()=>({action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.missing.phone_number")}]})},{errors:[m.DeliveryPhoneNumberInvalid,m.BuyerIdentityInvalidPhone,m.DeliveryPhoneDoesNotMatchExpectedPattern],generateAction:()=>({action:"show_error",errors:[{reason:"OTHER_ERROR",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.invalid.phone_number")}]})},{errors:[m.BuyerIdentityInvalidCountry,m.DeliveryCountryInvalid],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.invalid.country")}]})},{errors:[m.DeliveryFirstNameRequired],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.missing.first_name")}]})},{errors:[m.DeliveryFirstNameInvalid],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.invalid.first_name")}]})},{errors:[m.DeliveryLastNameRequired],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.missing.last_name")}]})},{errors:[m.DeliveryLastNameInvalid],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.invalid.last_name")}]})},{errors:[m.DeliveryAddress1Required],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.missing.address1")}]})},{errors:[m.DeliveryAddress1Invalid],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.invalid.address1")}]})},{errors:[m.DeliveryLastNameContainsEmojis],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.emojis.last_name")}]})},{errors:[m.DeliveryCityContainsEmojis],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.emojis.city")}]})},{errors:[m.DeliveryAddress1ContainsEmojis],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.emojis.address1")}]})},{errors:[m.DeliveryAddress2ContainsEmojis],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.emojis.address2")}]})},{errors:[m.DeliveryPostalCodeContainsEmojis],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.emojis.postal_code")}]})},{errors:[m.DeliveryAddress1TooLong],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.too_long.address1")}]})},{errors:[m.DeliveryAddress2TooLong],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.too_long.address2")}]})},{errors:[m.DeliveryFirstNameTooLong],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.too_long.first_name")}]})},{errors:[m.DeliveryLastNameTooLong],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.too_long.last_name")}]})},{errors:[m.DeliveryCityTooLong],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.too_long.city")}]})},{errors:[m.DeliveryFirstNameContainsUrl],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.url.first_name")}]})},{errors:[m.DeliveryLastNameContainsUrl],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.url.last_name")}]})},{errors:[m.DeliveryAddress1ContainsHtmlTags],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.html_tags.address1")}]})},{errors:[m.DeliveryAddress2ContainsHtmlTags],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.html_tags.address2")}]})},{errors:[m.DeliveryCityContainsHtmlTags],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.html_tags.city")}]})},{errors:[m.DeliveryFirstNameContainsHtmlTags],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.html_tags.first_name")}]})},{errors:[m.DeliveryLastNameContainsHtmlTags],generateAction:()=>({action:"show_error",errors:[{reason:"SHIPPING_ADDRESS_INVALID",intent:"SHIPPING_ADDRESS",message:this.i18n.translate("errors.html_tags.last_name")}]})},{errors:[m.InvalidPaymentGooglePayBillingAddress],generateAction:()=>({action:"show_error",errors:[{reason:"PAYMENT_DATA_INVALID",intent:"PAYMENT_METHOD",message:this.i18n.translate("errors.invalid.billing_address")}]})}]}mapCustomValidationFunctionErrorToAction(e){const n=Er(e);return n?(w.notify(new Error("[".concat(b.GooglePay,"] custom validation function error: ").concat(JSON.stringify(e)))),Ar(this.i18n.translate("error_dialogs.wallet.title",{wallet:this.brandName}),n.message),{action:"abort"}):null}}function Lc({deliveryGroups:t,i18n:e}){var n;const r=rl(ta({deliveryGroups:t}),e),a=r.map(({handle:o,title:s,description:l})=>({id:o,label:s!=null?s:"",description:l})),i=(n=r.find(o=>{var s;return o.handle.includes(((s=t[0].selectedDeliveryOption)==null?void 0:s.handle)||"")}))==null?void 0:n.handle;return{shippingOptions:a,defaultSelectedOptionId:i}}function tr(t){let e=t.administrativeArea,n=t.locality;t.countryCode==="AE"&&(n=t.administrativeArea,t.administrativeArea in cn&&(e=cn[t.administrativeArea])),t.countryCode==="MX"&&e&&(e=Oc(e));let r,a;if(t.name){const[i,...o]=(t.name||"").split(" ");o.length===0?a=i:a=o.join(" "),r=i}return{firstName:r,lastName:a,address1:t.address1,address2:t.address2,city:n,province:e,country:t.countryCode,phone:t.phoneNumber,zip:t.postalCode}}const cn={"\u0623\u0628\u0648 \u0638\u0628\u064A":"AZ","\u0625\u0645\u0627\u0631\u0629 \u0627\u0644\u0634\u0627\u0631\u0642\u0629\u0651":"SH",\u0627\u0644\u0641\u062C\u064A\u0631\u0629:"FU",\u0639\u062C\u0645\u0627\u0646:"AJ","\u0631\u0623\u0633 \u0627\u0644\u062E\u064A\u0645\u0629":"RK","\u0625\u0645\u0627\u0631\u0629 \u0631\u0623\u0633 \u0627\u0644\u062E\u064A\u0645\u0629":"RK","\u0623\u0645 \u0627\u0644\u0642\u064A\u0648\u064A\u0646":"UQ","\u0627\u0645 \u0627\u0644\u0642\u064A\u0648\u064A\u0646":"UQ",\u062F\u0628\u064A:"DU","\u0625\u0645\u0627\u0631\u0629 \u062F\u0628\u064A\u0651":"DU"},Oc=t=>t==="M\xE9x."?"MEX":t==="Q.R."?"Q ROO":t.replace(/\./g,"").toUpperCase();class rr extends Error{constructor(){super(...arguments),d(this,"name","GooglePayError")}}function Na(t){const e=t.auth;if(!(Array.isArray(e)&&e.length>0))return{result:"error",reason:"invalidAuthParams"};const n=Ze();for(const r of e)if(n{var y;const{callbackTrigger:E,shippingAddress:f,shippingOptionData:A}=p,{translate:I}=this.i18n;switch(E){case"INITIALIZE":{if(!this.cart)try{const{cart:F,customValidationError:qe,decelerationReason:N}=await pe({element:this.button,instrumentName:b.GooglePay,dataSource:this.dataSource});if(qe)return this.customValidationError=qe,this.showPaymentDataRequestError({error:{reason:"OTHER_ERROR",message:this.customValidationError.message,intent:"SHIPPING_ADDRESS"}});if(N)return M({checkoutUrl:(y=F==null?void 0:F.checkoutUrl)!=null?y:"",instrumentName:this.name,reason:N}),this.showPaymentDataRequestError({error:{intent:"SHIPPING_ADDRESS",reason:"OTHER_ERROR",message:""}});this.cart=F,g.sheetClicked({instrument:this.name,result:"success"})}catch(F){return g.sheetClicked({instrument:this.name,result:"failed"}),this.showPaymentDataRequestError({intent:"SHIPPING_ADDRESS"})}let O=!1;if(f)try{return await this.handleShippingAddressChange(this.cart.id,f)}catch(F){O=!0}return _({newTransactionInfo:er({cart:this.cart,i18n:this.i18n})},O?this.showPaymentDataRequestError():{})}case"SHIPPING_ADDRESS":return this.customValidationError?this.showPaymentDataRequestError({error:{reason:"OTHER_ERROR",message:this.customValidationError.message,intent:"SHIPPING_ADDRESS"}}):this.cart?f?this.handleShippingAddressChange(this.cart.id,f):{newTransactionInfo:er({cart:this.cart,i18n:this.i18n})}:this.showPaymentDataRequestError({intent:E});case"SHIPPING_OPTION":{if(!this.cart)return this.showPaymentDataRequestError({intent:E});if(!A||!A.id)return{error:{reason:"SHIPPING_OPTION_INVALID",message:I("shipping_methods.choose_delivery_strategy"),intent:"SHIPPING_OPTION"}};const O=await this.handleDeliveryOptionChange(A.id.split(","));return O.data?(this.cart=O.data,this.handlePaymentDataRequestUpdate({result:O,intent:E})):this.showPaymentDataRequestError({intent:E})}default:return this.logException("Payment data changed callback returned unexpected intent: ".concat(E),{severity:"warning"}),this.showPaymentDataRequestError({intent:"SHIPPING_ADDRESS"})}}),d(this,"onPaymentAuthorized",async p=>{var y,E,f;g.authorizationAttempt(this.name),ht(B.AuthorizationLatency,this.name);const A=(y=p.paymentMethodData.info)==null?void 0:y.billingAddress,I=p.shippingAddress,{signature:O,signedMessage:F,protocolVersion:qe}=JSON.parse(p.paymentMethodData.tokenizationData.token);if(!A)return this.handlePaymentAuthorizationError({error:{reason:"PAYMENT_DATA_INVALID",intent:"PAYMENT_AUTHORIZATION",message:this.i18n.translate("errors.invalid.billing_address")}});if(this.isShippingRequired&&!I)return this.handlePaymentAuthorizationError({error:{reason:"SHIPPING_ADDRESS_INVALID",intent:"PAYMENT_AUTHORIZATION",message:this.i18n.translate("errors.invalid.shipping_address")}});const N=async()=>{var U,k;const re=(U=C(this,dt))!=null?U:p.email,pt=this.isShippingRequired?{validateAddress:!0,streetAddress:tr(I)}:{};return await xe(_({cartClient:this.cartClient,cartId:this.cart.id,instrumentName:this.name,emailAddress:re,abortSignal:(k=C(this,te))==null?void 0:k.signal},pt))},G=async()=>{var U;const k=tr(A);return await Rr({cartId:this.cart.id,totalAmount:this.cart.totalAmount,paymentMethod:{walletPaymentMethod:{googlePayWalletContent:{billingAddress:k,signature:O,signedMessage:F,protocolVersion:qe}}},canUsePaymentMethodForFreeOrder:!1,billingAddress:k,cartClient:this.cartClient,instrumentName:this.name,hasSellingPlan:this.hasSellingPlan,abortSignal:(U=C(this,te))==null?void 0:U.signal})};try{const U=setTimeout(()=>{var iu;(iu=C(this,te))==null||iu.abort("Google Pay Timeout")},xc),k=await N(),re=this.handleIntermediatePaymentAuthorizationResult(k);if(re)return re;const pt=await G(),au=this.handleIntermediatePaymentAuthorizationResult(pt);if(au)return au;if(clearTimeout(U),(f=(E=C(this,te))==null?void 0:E.signal)!=null&&f.aborted)throw new rr("Abort Controller was not aborted");const uu=await wa({cartId:this.cart.id,token:O,cartClient:this.cartClient,instrumentName:this.name}),du=this.actionGenerator.mapCompletionResultToPaymentSheetAction(uu);return this.handlePaymentAuthorizationResult(du)}catch(U){const{message:k}=U;return k!=null&&k.includes(Mc)?this.handlePaymentAuthorizationError({status:"timeout"}):(this.logException(k),this.handlePaymentAuthorizationError())}}),d(this,"handlePaymentAuthorizationResult",async p=>{var y,E;switch((y=p.effects)==null||y.forEach(f=>f()),p.action){case"complete":return this.emitAuthorizationCompleteMetric("success"),ce(p.redirectUrl),{transactionState:"SUCCESS"};case"show_error":return this.handlePaymentAuthorizationError({error:(E=p.errors)==null?void 0:E[0]});case"decelerate":return M({checkoutUrl:p.redirectUrl,instrumentName:this.name,reason:p.reason}),this.emitAuthorizationCompleteMetric("failed"),{transactionState:"SUCCESS"};case"abort":default:return this.emitAuthorizationCompleteMetric("failed"),{transactionState:"SUCCESS"}}}),this.walletParams=e,this.isShippingRequired=n,this.hasSellingPlan=r,this.dataSource=a,this.button=i,this.i18n=o,this.cartClient=s,this.initialBuyerCurrency=l,L(this,dt,e.customerAccountEmail),L(this,te,c);const u=Na(this.walletParams);if(u.result==="error")throw w.leaveBreadcrumb("Google Pay Invalid AuthJwt detected on click",{reason:u.reason,walletParams:this.walletParams},"error"),new rr(u.reason);L(this,Be,u.jwt);const h={environment:this.walletParams.environment,merchantInfo:T(_({},this.walletParams.paymentData.merchantInfo),{authJwt:C(this,Be)}),paymentDataCallbacks:{onPaymentDataChanged:this.isShippingRequired?this.onPaymentDataChanged:void 0,onPaymentAuthorized:this.onPaymentAuthorized}};this.paymentsClient=new window.google.payments.api.PaymentsClient(h),this.actionGenerator=new kc(this.i18n)}async handleClick(){if(!this.isShippingRequired)throw new Tt("Google Pay checkout started for digital cart");const e=Nc({walletParams:this.walletParams,isShippingRequired:this.isShippingRequired,hasSellingPlan:this.hasSellingPlan,i18n:this.i18n,buyerCurrency:this.initialBuyerCurrency,authJwt:C(this,Be)});await this.paymentsClient.loadPaymentData(e)}showPaymentDataRequestError({error:e,intent:n="SHIPPING_ADDRESS"}={}){return e?{error:e}:{error:{intent:n,reason:"OTHER_ERROR",message:this.i18n.translate("error_dialogs.wallet.generic_error",{wallet:this.i18n.translate("brand.google_pay")})}}}handlePaymentAuthorizationError({error:e,status:n="failed"}={}){return this.emitAuthorizationCompleteMetric(n),_({transactionState:"ERROR"},this.showPaymentDataRequestError({error:e,intent:"PAYMENT_AUTHORIZATION"}))}handlePaymentDataRequestUpdate({result:e,intent:n}){var r,a;const i=this.actionGenerator.mapMutationResultToPaymentSheetAction(e);switch(i.action){case"update":{const o=i,{data:s,decelerationReason:l}=e;return s?l?(M({checkoutUrl:s.checkoutUrl,instrumentName:this.name,reason:l}),this.showPaymentDataRequestError({error:{reason:"OTHER_ERROR",message:"",intent:"OFFER"}})):this.isShippingRequired&&s.deliveryGroups.length===0?this.showPaymentDataRequestError({error:{reason:"SHIPPING_ADDRESS_INVALID",message:this.i18n.translate("errors.address_unserviceable",{shopName:this.walletParams.paymentData.merchantInfo.merchantName}),intent:"SHIPPING_ADDRESS"}}):{newTransactionInfo:er({cart:s,i18n:this.i18n}),newShippingOptionParameters:this.isShippingRequired?Lc({deliveryGroups:s.deliveryGroups,i18n:this.i18n}):void 0,error:(r=o.errors)==null?void 0:r[0]}:this.showPaymentDataRequestError({intent:n})}case"show_error":return{error:(a=i.errors)==null?void 0:a[0]};case"abort":return this.showPaymentDataRequestError({intent:n});default:return this.logException("Payment sheet update returned unexpected action (see request tab for details)",{metadata:{request:{action:i.action,intent:n}}}),this.showPaymentDataRequestError({intent:n})}}handleIntermediatePaymentAuthorizationResult(e){var n,r,a,i;if(e.decelerationReason)return M({checkoutUrl:(r=(n=e.data)==null?void 0:n.checkoutUrl)!=null?r:"",instrumentName:this.name,reason:e.decelerationReason}),{transactionState:"SUCCESS"};const o=this.actionGenerator.mapMutationResultToPaymentSheetAction(e);if(((a=e.errors)==null?void 0:a.length)>0){const s=o;if(s.action==="show_error")return this.handlePaymentAuthorizationError({error:(i=s.errors)==null?void 0:i[0]})}}handleCurrencyChange(e,n){Sr({currentCartTotal:n,initialBuyerCurrency:this.initialBuyerCurrency})&&M({checkoutUrl:e,instrumentName:this.name,reason:"currency_changed"})}async handleShippingAddressChange(e,n){var r;let a=await xe({cartClient:this.cartClient,cartId:e,streetAddress:n?tr(n):{},instrumentName:b.GooglePay,abortSignal:(r=C(this,te))==null?void 0:r.signal});if(!a.data)return this.showPaymentDataRequestError({intent:"SHIPPING_ADDRESS"});this.cart=a.data;const i=this.cart.deliveryGroups.length>0&&(this.cart.deliveryGroups.some(s=>{var l;return((l=s.selectedDeliveryOption)==null?void 0:l.deliveryMethodType)==="LOCAL"})||this.cart.deliveryGroups.every(s=>s.selectedDeliveryOption==null));let o=[];if(i?o=this.cart.deliveryGroups.map(s=>s.deliveryOptions.filter(({deliveryMethodType:l})=>l==="SHIPPING")).map(s=>{var l;return(l=s[0])==null?void 0:l.handle}).filter(Boolean):o=this.cart.deliveryGroups.map(({selectedDeliveryOption:s,deliveryOptions:l})=>{var c;return s!=null&&s.handle?s.handle:(c=l.filter(({deliveryMethodType:u})=>u==="SHIPPING")[0])==null?void 0:c.handle}).filter(Boolean),o.length>0){if(a=await this.handleDeliveryOptionChange(o),!a.data)return this.showPaymentDataRequestError({intent:"SHIPPING_ADDRESS"});this.cart=a.data}return this.handleCurrencyChange(this.cart.checkoutUrl,this.cart.totalAmount),this.handlePaymentDataRequestUpdate({result:a,intent:"SHIPPING_ADDRESS"})}async handleDeliveryOptionChange(e){var n;const r=_a({deliveryGroups:this.cart.deliveryGroups,instrumentName:b.GooglePay,selectedDeliveryOptionHandles:e});return await ba({cartClient:this.cartClient,cartId:this.cart.id,instrumentName:b.GooglePay,selectedDeliveryOptions:r,abortSignal:(n=C(this,te))==null?void 0:n.signal})}logException(e,{severity:n,metadata:r}={}){w.notify(new rr(e),{severity:n!=null?n:"error",metadata:r})}emitAuthorizationCompleteMetric(e){g.authorizationComplete({instrument:this.name,measurement:de(B.AuthorizationLatency,this.name),result:e})}}dt=new WeakMap,te=new WeakMap,Be=new WeakMap;const Uc={LIGHT:"light",DARK:"dark"};var He;class $c extends Re{constructor(){super(),d(this,"name",b.GooglePay),d(this,"paymentsClient",null),d(this,"button",null),x(this,He),d(this,"handleClick",async()=>{if(this.disabled)return;this.disabled=!0;const e=Ve("AbortController");try{await this.createPaymentsClient(e),await this.paymentsClient.handleClick()}catch(n){if(this.disabled=!1,n.statusCode==="CANCELED"){e==null||e.abort("Payment sheet cancelled"),g.sheetCancelled(b.GooglePay);return}e==null||e.abort("Payment sheet failure"),w.notify(n),g.sheetClicked({instrument:this.name,result:"failed"});const r=await this.i18n,a=r.translate("brand.google_pay");J(a,r)}}),L(this,He,this.attachShadow({mode:"closed"}))}static get observedAttributes(){return["disabled"]}attributeChangedCallback(e,n,r){super.attributeChangedCallback(e,n,r,this.button)}async connectedCallback(){this.cleanupOnFailure(this.render.bind(this),this.name)}async createPaymentsClient(e){this.paymentsClient=new Fc({walletParams:this.walletParams,isShippingRequired:this.isShippingRequired,hasSellingPlan:this.hasSellingPlan,dataSource:await this.dataSource,button:this,cartClient:await this.apiClient,i18n:await this.i18n,buyerCurrency:this.buyerCurrency,abortController:e})}async render(){if(this.button)return;await this.initializeShadowStyles(C(this,He),Ic);const{translate:e}=await this.i18n,n=this.isCTA?e("buy_with_button_content",{wallet:e("brand.google_pay")}):e("brand.google_pay"),r=Mt({label:n});this.disabled&&r.setAttribute("disabled",""),r.classList.add("button",Pe.BUTTON,Uc[this.buttonTheme]),r.onclick=this.handleClick,await this.renderButtonContent(r,e),this.button=r,C(this,He).appendChild(r),this.ensureLightDOMIsNotEmpty(),this.onRendered()}async renderButtonContent(e,n){const r=this.buttonTheme==="DARK"?ot.googlePayLogoDark:ot.googlePayLogo,a=new DOMParser().parseFromString(r,"image/svg+xml").documentElement;if(e.style.font=window.getComputedStyle(this).font,this.isCTA){const i=Nr({translate:n,logoElement:a,setAriaHidden:!0});i.classList.add("content"),e.appendChild(i)}else e.classList.add("logo-only"),e.appendChild(a)}}He=new WeakMap;const q=class Vt extends me{static walletName(){return"google_pay"}constructor(e){super(e)}getWebComponentName(){return"shopify-google-pay-button"}getInstrumentName(){return b.GooglePay}getWebComponentClass(){return $c}async loadWalletSDK(){if(Vt.googlePaySDKPromise)return Vt.googlePaySDKPromise;const e=document.createElement("script");e.setAttribute("src",this.walletParams.sdkUrl);const n=new Promise((r,a)=>{e.onload=()=>r(),e.onerror=i=>{document.body.removeChild(e),a(i)},document.body.appendChild(e)});return Vt.googlePaySDKPromise=Promise.all([n,this.loadLogos()]),Vt.googlePaySDKPromise}getLoadEligibility(){const e=Na(this.walletParams);switch(e.result){case"success":return{eligible:!0};case"error":return{eligible:!1,reason:e.reason}}}getPartnerSDKEligibility(){return{eligible:!0}}async loadLogos(){return Promise.all([this.loadGooglePayLogo(),this.loadGooglePayLogoDark()])}async loadGooglePayLogo(){if(Vt.googlePayLogo=(await import("./google-pay-logo-BgkSiJGq.js")).default,!Vt.googlePayLogo)throw new Error("Google Pay logo is empty")}async loadGooglePayLogoDark(){if(Vt.googlePayLogoDark=(await import("./google-pay-logo-dark-DmTdfep2.js")).default,!Vt.googlePayLogoDark)throw new Error("Google Pay logo dark is empty")}};d(q,"googlePaySDKPromise"),d(q,"googlePayLogo",""),d(q,"googlePayLogoDark","");let ot=q;const Bc=[Ws,ir,Aa,ot,it,dr,va],Hc=new Map(Bc.map(t=>[t.walletName(),e=>new t(e)]));function nt(t){if(!t)return null;const e=Hc.get(t.name);return e?e(t):(console.debug("Can't build wallet with name ".concat(t.name)),null)}function Gc(t){return t.map(e=>nt(e)).filter(e=>e!=null)}const Ta="*{box-sizing:border-box}.wallet-button-fade-in{animation:animation-fade-in .3s cubic-bezier(.1,.79,1,1)}@keyframes animation-fade-in{0%{opacity:0}to{opacity:1}}button[aria-disabled=true]{opacity:.5;cursor:not-allowed}";class Vc{constructor(e,n,r){this.element=e,this.apiClient=n,this.instrumentName=r}async getInitialCart(e){const n=vr(this.element);if(!n)throw new Error("[".concat(this.instrumentName,"] unable to find product form"));const r=at(ri),{data:a,errors:i,warnings:o}=await this.apiClient.createCart(T(_({},n),{discountCodes:r?[r]:[],instrumentName:e}));return{cart:a,errors:i,warnings:o}}}function zc({instanceNumber:t,styleId:e,styles:n,cssFileName:r}){var a,i;t===1&&(i=(a=window.Shopify)==null?void 0:a.PaymentButton)!=null&&i.isStorefrontPortableWallets&&(qc({styleId:e})||jc({styleId:e,styles:n}))}function qc({styleId:t}){return!!document.querySelector("style#".concat(t))}function jc({styleId:t,styles:e}){const n=document.createElement("style");n.id=t,n.innerHTML=e,document.head.appendChild(n)}const X={buttonBlockSize:"--shopify-accelerated-checkout-button-block-size",buttonBorderRadius:"--shopify-accelerated-checkout-button-border-radius",buttonBoxShadow:"--shopify-accelerated-checkout-button-box-shadow",inlineAlignment:"--shopify-accelerated-checkout-inline-alignment"};function dn(t){let e=0,n=0,r=0;const a=t.split(/\s+/);for(let i=0;i"&&(o.includes("#")&&(e+=(o.match(/#/g)||[]).length),o.includes(".")&&(n+=(o.match(/\./g)||[]).length),o.includes("[")&&(n+=(o.match(/\[/g)||[]).length),o.includes(":")&&(n+=(o.match(/:[^:]/g)||[]).length),/^[A-Za-z]/.test(o)&&(r+=1))}return[e,n,r]}function Yc(t,e){for(let n=0;n<3;n++)if(t[n]!==e[n])return e[n]-t[n];return 0}function un(t){return[...t].sort((e,n)=>{const r=dn(e.selector),a=dn(n.selector);return Yc(r,a)})}const Wc=/\.cart__dynamic-checkout-buttons|\.dynamic-checkout-buttons\s*(>\s*)?li(?![a-zA-Z0-9_.:#-])/,Kc=/\.cart__dynamic-checkout-buttons|\.dynamic-checkout-buttons\s*\[role="?button"?\](?![:\w-])/,Qc=/\.additional-checkout-buttons\s*(?:div\s*)?\[role="?button"?\](?![:\w-])/,ka=/\[data-shopify-buttoncontainer\](?![:\w-])/,La=/.dynamic-checkout-buttons .shopify-payment-button__button/,Xc=/(?!.*\.shopify-cleanslate)\.shopify-payment-button__button(?:--branded)?(?![\w-:.#>])/,Jc=/\.(shopify-payment-button|shopify-payment-button__button|shopify-payment-button__button--branded)\s*\[role="?button"?\](?![:\w-])/,Zc=/(?:only\s+)?(?:screen\s+and\s+)?\((?:min|max)-(?:width|height):\s*\d+px\)/,ed=[Kc,ka,Wc,Qc,La],td=[Xc,Jc,La];function Oa(t){const e=t.pageType,n=[...document.styleSheets].filter(rd),r=[],a=[];n.forEach(N=>{try{const G=[...N.cssRules].filter(k=>k instanceof CSSMediaRule),U=[...N.cssRules].filter(k=>k instanceof CSSStyleRule);a.push(...G.filter(k=>Zc.test(k.conditionText)).flatMap(k=>[...k.cssRules].filter(re=>re instanceof CSSStyleRule).flatMap(re=>re.selectorText.split(",").map(pt=>pt.trim()).map(pt=>_({selector:pt,conditionText:k.conditionText},gn(re)))))),r.push(...U.flatMap(k=>k.selectorText.split(",").map(re=>re.trim()).map(re=>_({selector:re},gn(k)))))}catch(G){At()("shopify-support-debug")&&(console.debug("[shopify-support-debug] stylesheet origin: ".concat(N.href)),console.debug(G))}});const i=e===S.ProductPage?td:ed,o=new Set;function s(N,G){const U=G.selector.match(N);return U?(o.add(U[0]),!0):!1}const l=r.filter(N=>i.some(G=>s(G,N))).reverse(),c=a.filter(N=>i.some(G=>s(G,N))).reverse(),u=At()("shopify-support-debug");u&&console.table(Array.from(o));const h=un(l),p=un(c),y={},E=hn(e)?document.querySelector(".cart__blocks .button"):document.querySelector(".product-form__buttons .button");E&&(y.boxShadow=getComputedStyle(E,":before").boxShadow);for(const N of h){const G=["height","minHeight","borderRadius","marginTop"];hn(e)&&N.selector.match(ka)&&G.push("justifyContent");for(const U of G)y[U]=id({rule:N,property:U,currentPropertyValue:y[U]})}const{height:f,borderRadius:A,minHeight:I,marginTop:O,justifyContent:F,boxShadow:qe}=y;return u&&console.table([{property:"height",value:f},{property:"borderRadius",value:A},{property:"minHeight",value:I},{property:"marginTop",value:O},{property:"justifyContent",value:F},{property:"boxShadow",value:qe}]),e===S.ProductPage?yn({styles:{height:f,minHeight:I,borderRadius:A,marginTop:O,boxShadow:qe},mediaRules:p,element:t}):yn({styles:{borderRadius:A,boxShadow:qe,justifyContent:F},mediaRules:p,element:t})}function xa(t,e){var n,r,a;if(!e)return;g.styleBackwardsCompatibility();const i=(a=(r=(n=window.ShopifyAnalytics)==null?void 0:n.lib)==null?void 0:r.trekkie)==null?void 0:a.defaultAttributes,o=i==null?void 0:i.shopId,s=i==null?void 0:i.themeId;o&&s&&g.log({body:"Style backwards compatibility used",attributes:{shopId:"".concat(o),themeId:"".concat(s)}});const l="global-".concat(t.tagName.toLowerCase(),"-styles");if(document.head.querySelector("style#".concat(l))==null){const c=document.createElement("style");c.id=l,c.innerHTML=e,document.head.appendChild(c)}}function rd(t){const e=t.ownerNode instanceof HTMLLinkElement&&(t.ownerNode.getAttribute("crossorigin")==="anonymous"||t.ownerNode.getAttribute("crossorigin")==="");return t.href==null||t.href.startsWith(window.location.origin)||e}function hn(t){return t===S.CartPage||t===S.CartAjax}function pn({height:t,minHeight:e}){let n=t,r=e;return(n!=null&&n.includes("var(".concat(X.buttonBlockSize))||n==="auto")&&(n=null),(r!=null&&r.includes("var(".concat(X.buttonBlockSize))||r==="auto")&&(r=null),n===r?n:r&&n?"max(".concat(n,",").concat(r,")"):n||r}function mn({existingProperties:t,mediaCondition:e,selector:n,styles:r}){const a=_({},r);for(const i of t)delete a[i];for(const[i,o]of Object.entries(a))o!=null&&o.startsWith("var(".concat(i))&&delete a[i];return Object.keys(a).length===0?"":nd({mediaCondition:e,selector:n,styles:a})}function nd({mediaCondition:t,selector:e,styles:n}){let r="".concat(t?"@media ".concat(t," { "):"").concat(e," {");for(const[a,i]of Object.entries(n))i&&(r+="\n ".concat(a,": ").concat(i,";"));return r+="\n}",t&&(r+="}"),r+="\n",r}function yn({styles:t,element:e,mediaRules:n}){const{height:r,minHeight:a,borderRadius:i,marginTop:o,justifyContent:s,boxShadow:l}=t,c=e.tagName.toLowerCase(),u=getComputedStyle(e),h=new Set;for(const y of Object.values(X))u.getPropertyValue(y)&&h.add(y);let p=mn({existingProperties:h,selector:c,styles:{[X.buttonBlockSize]:pn({height:r,minHeight:a}),[X.buttonBorderRadius]:i,[X.buttonBoxShadow]:l,[X.inlineAlignment]:s,"margin-top":o,display:o?"block":void 0}});return n.forEach(y=>{(y.height||y.minHeight||y.borderRadius||y.boxShadow||y.justifyContent||y.marginTop)&&(p+=mn({existingProperties:h,mediaCondition:y.conditionText,selector:c,styles:{[X.buttonBlockSize]:pn({height:y.height,minHeight:y.minHeight}),[X.buttonBorderRadius]:y.borderRadius,[X.buttonBoxShadow]:y.boxShadow,[X.inlineAlignment]:y.justifyContent,"margin-top":y.marginTop,display:y.marginTop?"block":void 0}}))}),p.trim()}function gn(t){return[["height"],["minHeight","min-height"],["borderRadius","border-radius"],["marginTop","margin-top"],["justifyContent","justify-content"]].reduce((e,[n,r])=>(e[n]=ad({rule:t,property:r!=null?r:n}),e),{})}function ad({rule:t,property:e}){const n=t.style.getPropertyValue(e);return t.style.getPropertyPriority(e)?"".concat(n," !important"):n||null}function id({rule:t,property:e,currentPropertyValue:n}){const r=t[e];return!(n!=null&&n.includes("!important"))&&r!=null&&r.includes("!important")?r:n!=null?n:r}const Ma="d6d12da0",fn=2e3;class bn extends Error{constructor(){super(...arguments),d(this,"name","AcceleratedCheckoutError")}}const vt=class su extends Pr{constructor(){super(),d(this,"instanceNumber",++su.instanceCount),d(this,"pageType",S.ProductPage),d(this,"formObserver"),d(this,"dataSource"),d(this,"wrapper"),d(this,"shopPromiseEligible"),d(this,"didInitiateRender",!1),this.wrapper=document.createElement("div"),zc({instanceNumber:this.instanceNumber,styleId:"shopify-accelerated-checkout",styles:$s,cssFileName:"AcceleratedCheckout.css"}),this.shopPromiseEligible=Hn()}static get observedAttributes(){return["access-token","disabled","has-selling-plan","requires-shipping"]}async connectedCallback(){var e,n;try{if((n=(e=this.wrapper)==null?void 0:e.children)!=null&&n.length||this.didInitiateRender)return;if(!this.validateRenderingSurface()){this.clearUI();return}this.instanceNumber===1&&(Dr(this),g.initStarted(),this.extractStyles());const r=$t(B.ButtonDisplay,"dc:".concat(this.instanceNumber));this.i18n=Ot(),this.setupFormObserver(),this.didInitiateRender=!0;const a=await this.loadWallet(),i=a.getInstrumentName();this.apiClient=new Gt({accessToken:this.accessToken,country:this.buyerCountry,locale:this.i18n.locale,withCarrierRates:!0,cartPrepareMigrationEnabled:this.isFlagEnabled(Ma)}),this.dataSource=new Vc(this,this.apiClient,i);const o=a.createWebComponent({walletContainer:this,dataSource:this.dataSource,i18n:this.i18n,apiClient:this.apiClient,classNames:od(i),callToAction:"true",pageType:this.pageType,containerInstanceNumber:this.instanceNumber,onRendered:()=>g.instrumentLoaded({instrumentOrComponentName:i,result:"success",measurement:r()})});if(!o)throw new bn("No web component instance found for instrument ".concat(i));this.render(o,i),g.initCompleted(),this.instanceNumber===1&&this.triggerLoadedEvent()}catch(r){if(this.clearUI(),g.initCompleted(r),r.name===ut)throw r;w.notify(new bn("An error occurred while attempting to render AcceleratedCheckout: ".concat(r),{cause:r}))}}async attributeChangedCallback(e,n,r){n!==r&&(Ir(this,e,r),e==="has-selling-plan"&&r===""?this.showBuyerConsent(this.apiClient,this.i18n):e==="has-selling-plan"&&r===null&&this.hideBuyerConsent())}async render(e,n){this.clearUI();const r=this.attachShadow({mode:"closed"}),a=document.createElement("style");a.innerHTML=Ta,r.appendChild(a),this.wrapper.className="wallet-button-fade-in wallet-button-wrapper";const i=document.createElement("slot");i.name="button",this.wrapper.appendChild(i);const o=document.createElement("slot");o.name="promise",this.wrapper.appendChild(o);const s=document.createElement("slot");s.name="more-options",this.wrapper.appendChild(s),r==null||r.appendChild(this.wrapper),this.hasSellingPlan?this.showBuyerConsent(this.apiClient,this.i18n):this.hideBuyerConsent();const l=new DocumentFragment;l.appendChild(e);const c=this.getShopPromiseSlot();c&&l.appendChild(c);const u=this.getMorePaymentOptionsLink(n);u&&l.appendChild(u),this.appendChild(l)}getMorePaymentOptionsLink(e){var n,r;if(e===b.BuyItNow)return null;const a=document.createElement("more-payment-options-link");return Ft(a,{"buyer-country":(n=this.buyerCountry)!=null?n:"","access-token":(r=this.accessToken)!=null?r:"","recommended-instrument":e,slot:"more-options"}),a.disabled=this.disabled,a.setDataSource(this.dataSource),a.setI18n(this.i18n),a.setClassNames(nr.MORE_PAYMENT_OPTION_BUTTON),a}getShopPromiseSlot(){if(!this.shopPromiseEligible)return null;const e=document.createElement("div");return e.setAttribute("data-shopify","shop-promise-payment-button-slot"),e.style.height="100%",e.slot="promise",e}validateRenderingSurface(){return Bt({page:"product",element:this})!=null}async loadWallet(){const e=Us(this.recommendedWallet,this.fallbackWallet,"AcceleratedCheckout");return await ld(this,T(_({},e),{instanceNumber:this.instanceNumber}))}setupFormObserver(){this.formObserver||(this.formObserver=new Qn(this,({disabled:e,hasSellingPlan:n})=>{this.disabled=e,this.hasSellingPlan=n,this.isShippingRequired=sd(this,this.variantParams)}),this.formObserver.setupMutationObservers())}extractStyles(){if(this.styleExtractorDisabled){At()("shopify-support-debug")&&console.debug("[shopify-support-debug] styling backward compatibility disabled");return}const e=Oa(this);e&&xa(this,e)}};d(vt,"instanceCount",0);let ur=vt;function od(t){return t===b.BuyItNow?nr.UNBRANDED_BUTTON:nr.BRANDED_BUTTON}function sd(t,e){var n;const r=vr(t);return!!((n=e.find(a=>a.id===Number(r==null?void 0:r.variantId)))!=null&&n.requiresShipping)}async function ld(t,{recommendedWallet:e,fallbackWallet:n,instanceNumber:r}){const a=e?nt(e):null,i=nt(n),o=async s=>{const l=Yn({walletInstrument:s,instanceNumber:r}),c="timeout",u=await Promise.race([l,new Promise(h=>setTimeout(()=>h(c),fn))]);if(u===c)g.instrumentSDKLoaded({instrument:s.getInstrumentName(),measurement:fn,result:"timeout"});else if(u instanceof me)return u;return null};if(Ct(t,a)){const s=await o(a);if(s)return s}if(Ct(t,i)){const s=await o(i);if(s)return s}return nt(Tn)}he("shopify-accelerated-checkout",ur),he("more-payment-options-link",Ts,{isChildCustomElement:!0});const cd=t=>{const e=new PerformanceObserver(n=>{n.getEntriesByType("resource").some(r=>r.name.includes(Xe.CartUpdate)||r.name.includes(Xe.CartChange)||r.name.includes(Xe.CartAdd)||r.name.includes(Xe.CartClear))&&t()});return e.observe({entryTypes:["resource"]}),e},dd=".wallet-cart-button__skeleton{animation:acceleratedCheckoutLoadingSkeleton var(--shopify-accelerated-checkout-skeleton-animation-duration, 4s) var(--shopify-accelerated-checkout-skeleton-animation-timing-function, ease) infinite;animation-delay:-.168s;background-color:var(--shopify-accelerated-checkout-skeleton-background-color, #dedede)}.wallet-button-wrapper{container-type:inline-size;container-name:wrapper;width:100%}.wallet-cart-grid{margin:0 -5px -5px;padding:0;display:flex;justify-content:var(--shopify-accelerated-checkout-inline-alignment, start)}.wallet-cart-button-container{position:relative;margin:0 5px 5px}.wallet-cart-button-container,.wallet-cart-button{width:150px;height:clamp(25px,var(--shopify-accelerated-checkout-button-inline-size, 42px),55px);border-radius:var(--shopify-accelerated-checkout-button-border-radius, 4px);list-style-type:none!important;text-align:center;flex-shrink:0;flex-grow:0}.wallet-cart-grid.wallet-cart-grid--vertical,.additional-checkout-buttons--vertical .wallet-cart-grid{justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-grid.wallet-cart-grid--vertical .wallet-cart-button-container,.additional-checkout-buttons--vertical .wallet-cart-grid .wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-grid.wallet-cart-grid--vertical .wallet-cart-button-container:first-child,.additional-checkout-buttons--vertical .wallet-cart-grid .wallet-cart-button-container:first-child{margin:0}.wallet-cart-grid.wallet-cart-grid--vertical .wallet-cart-button,.additional-checkout-buttons--vertical .wallet-cart-grid .wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}@container wrapper (width >= 150px) and (width <= 500px){.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(1)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(2))){justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(1)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(2))) .wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(1)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(2))) .wallet-cart-button-container:first-child{margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(1)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(2))) .wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}}@container wrapper (width <= 310px){.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(2)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(3))){justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(2)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(3))) .wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(2)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(3))) .wallet-cart-button-container:first-child{margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(2)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(3))) .wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}}@container wrapper (width <= 470px){.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(3)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(4))){justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(3)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(4))) .wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(3)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(4))) .wallet-cart-button-container:first-child{margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(3)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(4))) .wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}}@container wrapper (width <= 630px){.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(4)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(5))){justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(4)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(5))) .wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(4)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(5))) .wallet-cart-button-container:first-child{margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(4)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(5))) .wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}}@container wrapper (width <= 790px){.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(5)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(6))){justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(5)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(6))) .wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(5)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(6))) .wallet-cart-button-container:first-child{margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(5)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(6))) .wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(6)){justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(6)) wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(6)) .wallet-cart-button-container:first-child{margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(6)) .wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}@media screen and (max-width: 750px){.wallet-cart-grid{justify-content:flex-start;flex-direction:column;margin:0;max-width:none}.wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0;max-width:none}.wallet-cart-button-container:first-child{margin:0}.wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}}@supports (not (container-type: inline-size)) or (not (selector(:has(*)))){.wallet-cart-grid{justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-button-container:first-child{margin:0}.wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}}.screen-reader-text{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}",ud=".wallet-cart-button__skeleton{animation:acceleratedCheckoutLoadingSkeleton var(--shopify-accelerated-checkout-skeleton-animation-duration, 4s) var(--shopify-accelerated-checkout-skeleton-animation-timing-function, ease) infinite;animation-delay:-.168s;background-color:var(--shopify-accelerated-checkout-skeleton-background-color, #dedede)}.wallet-button-wrapper{container-type:inline-size;container-name:wrapper;width:100%}.wallet-cart-grid{margin:0 -5px -5px;padding:0;display:flex;justify-content:var(--shopify-accelerated-checkout-inline-alignment, start)}.wallet-cart-button-container{position:relative;margin:0 5px 5px}.wallet-cart-button-container,.wallet-cart-button{width:150px;height:clamp(25px,var(--shopify-accelerated-checkout-button-inline-size, 42px),55px);border-radius:var(--shopify-accelerated-checkout-button-border-radius, 4px);list-style-type:none!important;text-align:center;flex-shrink:0;flex-grow:0}.wallet-cart-grid.wallet-cart-grid--vertical,.additional-checkout-buttons--vertical .wallet-cart-grid{justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-grid.wallet-cart-grid--vertical .wallet-cart-button-container,.additional-checkout-buttons--vertical .wallet-cart-grid .wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-grid.wallet-cart-grid--vertical .wallet-cart-button-container:first-child,.additional-checkout-buttons--vertical .wallet-cart-grid .wallet-cart-button-container:first-child{margin:8px 0 0}.wallet-cart-grid.wallet-cart-grid--vertical .wallet-cart-button,.additional-checkout-buttons--vertical .wallet-cart-grid .wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}@container wrapper (width >= 150px) and (width <= 500px){.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(1)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(2))){justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(1)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(2))) .wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(1)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(2))) .wallet-cart-button-container:first-child{margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(1)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(2))) .wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}}@container wrapper (width <= 310px){.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(2)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(3))){justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(2)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(3))) .wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(2)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(3))) .wallet-cart-button-container:first-child{margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(2)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(3))) .wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}}@container wrapper (width <= 470px){.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(3)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(4))){justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(3)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(4))) .wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(3)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(4))) .wallet-cart-button-container:first-child{margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(3)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(4))) .wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}}@container wrapper (width <= 630px){.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(4)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(5))){justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(4)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(5))) .wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(4)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(5))) .wallet-cart-button-container:first-child{margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(4)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(5))) .wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}}@container wrapper (width <= 790px){.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(5)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(6))){justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(5)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(6))) .wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(5)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(6))) .wallet-cart-button-container:first-child{margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(5)).wallet-cart-grid:not(:has(>.wallet-cart-button-container:nth-of-type(6))) .wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(6)){justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(6)) wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(6)) .wallet-cart-button-container:first-child{margin:8px 0 0}.wallet-cart-grid:has(>.wallet-cart-button-container:nth-of-type(6)) .wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}@media screen and (max-width: 750px){.wallet-cart-grid{justify-content:flex-start;flex-direction:column;margin:0;max-width:none}.wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0;max-width:none}.wallet-cart-button-container:first-child{margin:8px 0 0}.wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}}@supports (not (container-type: inline-size)) or (not (selector(:has(*)))){.wallet-cart-grid{justify-content:flex-start;flex-direction:column;margin:0}.wallet-cart-button-container{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px);margin:8px 0 0}.wallet-cart-button-container:first-child{margin:8px 0 0}.wallet-cart-button{width:100%;height:clamp(25px,var(--shopify-accelerated-checkout-button-block-size, 54px),55px)}}.screen-reader-text{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}";function hd(t){const e=Bt({page:"cart",element:t});return Wn({type:"attributes",form:e})}class pd{constructor(e,n,r){this.element=e,this.cartToken=n,this.apiClient=r}async getInitialCart(e){const n="gid://shopify/Cart/".concat(this.cartToken),r=hd(this.element);let a,i=[];if(r.length){const o=await this.apiClient.updateCartAttributes({cartId:n,attributes:r,instrumentName:e,startingCheckout:!0});a=o.data,i=o.errors}else a=await this.apiClient.fetchCart({id:n,instrumentName:e,startingCheckout:!0});return{cart:a,errors:i}}}var Ge;const Rt=class lu extends Pr{constructor(){super(),d(this,"instanceNumber",++lu.instanceCount),d(this,"pageType",S.CartPage),d(this,"cartObserver",null),d(this,"dataSource",null),d(this,"wrapper"),d(this,"didInitiateRender",!1),x(this,Ge),this.wrapper=document.createElement("div")}static get observedAttributes(){return["access-token","has-selling-plan","requires-shipping"]}createDataSource(){if(!this.cartToken)throw new Error("[AcceleratedCheckoutCart] cart cookie does not exist");this.i18n=Ot(),this.apiClient=new Gt({accessToken:this.accessToken,country:this.buyerCountry,locale:this.i18n.locale,withCarrierRates:!0,cartPrepareMigrationEnabled:this.isFlagEnabled(Ma)}),this.dataSource=new pd(this,this.cartToken,this.apiClient)}async createWebComponents({shouldRefetchCartAttributes:e}){if(!this.walletConfigs)throw new Error("[AcceleratedCheckoutCart] walletConfigs does not exist");const n=ks(this.walletConfigs,"AcceleratedCheckoutCart");if(!(n instanceof Array))throw new Error("[AcceleratedCheckoutCart] invalid walletConfigs found");const r=B.ButtonDisplay,a=o=>"".concat(o,":").concat(this.instanceNumber),i=await md(this,{walletConfigs:n,startButtonDisplayBenchmark:o=>ht(r,a(o))});return this.createDataSource(),e&&await this.updateAttributes(),i.map(o=>{const s=o.getInstrumentName();return o.createWebComponent({walletContainer:this,dataSource:this.dataSource,i18n:this.i18n,apiClient:this.apiClient,pageType:this.pageType,containerInstanceNumber:this.instanceNumber,slot:"button-".concat(o.getInstrumentName()),onRendered:(()=>{let l=!1;return()=>{l||(l=!0,g.instrumentLoaded({instrumentOrComponentName:s,result:"success",measurement:de(r,a(s))}))}})()})})}async cartChangedCallback(){try{if(!this.dataSource&&this.cartToken){await this.render({shouldRefetchCartAttributes:!0}),g.initCompleted();return}else if(!this.cartToken){g.cartTokenMissing({reason:"cartChangedCallback"});return}await this.updateAttributes()}catch(e){this.clearUI(),w.notify(e)}}async updateAttributes(){var e,n;if(!this.cartToken||!this.apiClient)return;const r=await this.apiClient.fetchLimitedCart({id:"gid://shopify/Cart/".concat(this.cartToken),instrumentName:b.Unknown});if(!r.id)throw new Error("[".concat(this.updateAttributes,"] received invalid cart"));this.hasSellingPlan=(e=r.sellingPlan)!=null?e:!1,this.isShippingRequired=(n=r.shippingRequired)!=null?n:!1}async connectedCallback(){try{if(this.didInitiateRender)return;if(this.instanceNumber===1&&Dr(this),g.initStarted(),this.cartObserver=cd(()=>this.cartChangedCallback()),!this.cartToken){g.cartTokenMissing({reason:"connectedCallback"});return}await this.render({shouldRefetchCartAttributes:!1}),g.initCompleted()}catch(e){this.clearUI(),g.initCompleted(e),w.notify(e)}}disconnectedCallback(){var e;(e=this.cartObserver)==null||e.disconnect()}async attributeChangedCallback(e,n,r){n!==r&&(Ir(this,e,r),e==="has-selling-plan"&&r===""?this.showBuyerConsent(this.apiClient,this.i18n):e==="has-selling-plan"&&r===null&&this.hideBuyerConsent())}get cartToken(){return at("cart")}async render({shouldRefetchCartAttributes:e}){var n;if(this.hasLegacyCartCookie()){g.legacyCartCookie(),this.clearUI();return}this.didInitiateRender=!0;const r=$t(B.ButtonDisplay,"cart:".concat(this.instanceNumber)),a=await this.createWebComponents({shouldRefetchCartAttributes:e});if(this.clearUI(),a.length===0)return;const i=new DocumentFragment,o=this.getOrCreateShadowRoot(),s=document.createElement("style");s.innerHTML=[Ta,dd].join("\n"),o.appendChild(s),this.extractStyles(),this.wrapper=document.createElement("div"),this.wrapper.className="wallet-button-fade-in wallet-button-wrapper";const l=document.createElement("h2");l.className="screen-reader-text",l.textContent=((n=this.i18n)==null?void 0:n.translate("express_checkout"))||"",this.wrapper.appendChild(l);const c=document.createElement("div");c.className="wallet-cart-grid ".concat(Pe.CONTAINER),yd()&&c.classList.add("wallet-cart-grid--vertical"),a.forEach(u=>{const h=document.createElement("div"),p=document.createElement("div"),y=document.createElement("slot");y.name="button-".concat(u.name),h.className="wallet-cart-button-container",p.className="wallet-cart-button",h.setAttribute("data-testid","grid-cell"),h.appendChild(p),p.appendChild(y),c.appendChild(h),i.appendChild(u)}),this.wrapper.appendChild(c),this.hasSellingPlan?this.showBuyerConsent(this.apiClient,this.i18n):this.hideBuyerConsent(),o.appendChild(this.wrapper),this.appendChild(i),g.instrumentLoaded({instrumentOrComponentName:"AcceleratedCheckoutCart",result:"success",measurement:r()})}getOrCreateShadowRoot(){return C(this,Ge)||L(this,Ge,this.attachShadow({mode:"closed"})),C(this,Ge)}hasLegacyCartCookie(){var e;return this.cartToken?(e=this.cartToken)==null?void 0:e.match(/^[a-z0-9]+$/):!1}extractStyles(){if(this.styleExtractorDisabled){At()("shopify-support-debug")&&console.debug("[shopify-support-debug] styling backward compatibility disabled");return}const e=Oa(this);if(e){xa(this,e);const n=this.getOrCreateShadowRoot(),r=document.createElement("style");r.innerHTML=ud,n.appendChild(r)}}};Ge=new WeakMap,d(Rt,"instanceCount",0);let hr=Rt;async function md(t,{walletConfigs:e,startButtonDisplayBenchmark:n=()=>{}}){const r=Os(t,Gc(e));return(await Promise.all(r.map(a=>(n(a.getInstrumentName()),Yn({walletInstrument:a,instanceNumber:t.instanceNumber}))))).filter(a=>a!=null)}function yd(){return!!document.querySelector(".additional-checkout-buttons--vertical shopify-accelerated-checkout-cart")}he("shopify-accelerated-checkout-cart",hr);class gd{getInitialCart(){throw new Error('[NoOpDataSource] Unexpected call to "getCart"')}}const Nt=class cu extends Pr{constructor(){super(...arguments),d(this,"instanceNumber",++cu.instanceCount),d(this,"pageType",S.Checkout)}get walletConfig(){return this.getAttribute("wallet-config")}async connectedCallback(){var e;try{if(this.children.length)return;this.instanceNumber===1&&(Dr(this),g.initStarted());const n=$t(B.ButtonDisplay,"dc:".concat(this.instanceNumber)),r=Ls(this.walletConfig,"WalletButton");if(!r)throw new ai("[WalletButton] No config provided.");const a=nt(r);if(!a)return;if(!await this.eligibleToShow(a)){this.pciEnabled&&this.dispatchEvent(new CustomEvent("wallet-rendered",{detail:{status:"failure",message:"ineligible"}}));return}if(this.onlySdk){g.initCompleted(),this.pciEnabled&&this.dispatchEvent(new CustomEvent("wallet-rendered",{detail:{status:"success"}}));return}const i=a.getInstrumentName();this.i18n=Ot(),this.apiClient=new Gt({accessToken:this.accessToken,country:this.buyerCountry,locale:this.i18n.locale});const o=this.createWebComponent(a,this.i18n,this.apiClient,i,n);this.innerHTML="",this.appendChild(o),g.initCompleted(),this.instanceNumber===1&&this.triggerLoadedEvent()}catch(n){this.innerHTML="",this.pciEnabled&&this.dispatchEvent(new CustomEvent("wallet-rendered",{detail:{status:"failure",message:(e=n.message)!=null?e:"Error loading wallet SDK"}})),g.initCompleted(n),w.notify(n)}}createWebComponent(e,n,r,a,i){const o=e.createWebComponent({walletContainer:this,dataSource:new gd,i18n:n,apiClient:r,containerInstanceNumber:this.instanceNumber,pageType:this.pageType});return o.onRendered=()=>{this.pciEnabled&&this.dispatchEvent(new CustomEvent("wallet-rendered",{detail:{status:"success"}})),g.instrumentLoaded({instrumentOrComponentName:a,result:"success",measurement:i()})},o}async eligibleToShow(e){return!(!Ct(this,e)||(await e.loadWalletSDK(),!e.getPartnerSDKEligibility().eligible))}};d(Nt,"instanceCount",0);let pr=Nt;he("shopify-wallet-button",pr),Xa(w),Ja(w),g.startExporter();