PageSourceSearch

https://us.usm.com/cdn/shopifycloud/checkout-web/assets/c1/ExtensionsInner.RcvndSBV.js

js usm.com collected 2026-09-24 17:44:13 UTC 45,257 bytes, 1 lines download raw bytes

1import{f as xe,ab as X,A as P,h as k,n as $e,j as je,R as Fe,a3 as re,y as H,o as qe,e as Ee,q as ee,p as Ge,G as Ve,u as $,T as ye,k as He,_ as ze}from"./esnext-vendor.BBoIVOQW.js";import{es as We,fD as Ke,bw as te,o as j,fE as Xe,bW as Qe,dk as be,fF as Je,fG as Ye,f as Ze,aY as et,a$ as tt,fH as nt,fI as st,fJ as it,fK as ot,fL as rt,dj as ve,ez as at,cj as ct,fM as dt,fN as ut,fO as lt,a_ as ht,fP as pt,fQ as ft}from"./hydrate.Tsur0pib.js";import{T as R,a5 as gt,gq as mt,aq as we,bn as ae,gr as xt,gs as ne,ad as z,D as Te,gt as Et,gu as yt,gv as bt,aE as vt,S as wt,ah as Se,gw as Tt}from"./addresses-is-address-empty.ZJ1ThpFy.js";import{i as St,A as It,D as At}from"./shared-permissions.DW7FOCqf.js";import{i as Ct,s as kt}from"./ImpressionEventCapture.IVS9ZWTI.js";import{e as L,c as Rt,b as Nt,d as _t,f as Lt,g as Mt,h as Pt,j as Dt,s as Ot,k as Ut,l as Bt,m as $t,n as jt,o as Ft,p as Ie,R as qt,q as Gt,r as Vt,t as Ht,u as zt,v as Wt,w as Kt,x as Xt,y as Qt,z as Jt}from"./extension-targets-rendering-extension-targets.r3iA_rtw.js";import{a as Yt}from"./hooks-useForceShopPayUrl.z4AJBm7B.js";import{e as _}from"./performance-index.mu6MOGR9.js";import{E as Zt,i as en,b as tn}from"./app.CUBUOQtX.js";import{v as nn}from"./dist-v4.EwEgHOG0.js";import{T as Y,a as sn,b as ce,c as V,d as Q,e as on,A as Z,f as de,H as rn,M as an,i as cn,g as J,E as Ae,h as dn,L as un,j as ln,k as hn,l as pn,m as fn,n as gn}from"./utilities-extension-execution-errors.DiES5O5t.js";import{a as mn,i as xn,c as En}from"./AnnouncementRuntimeExtensions.C0O5WcH_.js";import{a as yn}from"./adapter-host.WRlCcYVc.js";import{L as ue}from"./extensions-remote-dom.DLP6cFL6.js";import{c as bn}from"./amazon-pay-useAmazonPayPaymentLine.CMgi35Fb.js";import"./hooks-useShopPayExternalAppContext.YLtTu3k6.js";import"./consent-manager-shared.D79dm3f4.js";import"./shared-negotiation-input-redeemable.DoYPkwkm.js";import"./AddressPresenter.Ce4uWLSc.js";import"./QRCode.OrXXMCLJ.js";import"./Checkbox.dqdh-9I_.js";import"./Choice.18syyoW7.js";import"./shop-pay-installments-types._vopm3yK.js";import"./utilities-dates.ChO2GdxN.js";import"./components-RedirectionNotice.module.qsrQCJ0v.js";import"./PaymentIcon.CEAvn1dM.js";import"./NumberField.D9yAw9rS.js";import"./Switch.DcsaOS_H.js";import"./EmailField.C8ocsqns.js";import"./TextArea.An2gFfWj.js";import"./Sheet.Dx28vgYD.js";import"./styles-floating-layer.module.BESFBxYZ.js";import"./PhoneField.D8EvZ0Pm.js";import"./shipping-methods-grouping.S_i1LuzE.js";import"./hooks-useSuppressShopPayModalOnLoad.CwH45iIp.js";import"./hooks-useShowShopPayOptin.BPTq9EIX.js";function vn(){const i=We(),{i18n:e}=R();return xe(()=>i.value?{id:"cart",label:e.translate("general.cart"),route:"",features:[]}:void 0)}function wn(i,e){const t=X(i?.translations[i.defaultLocale]??{}),n=Ce(e),s=X(i?.translations[n]??{}),o=X(i?.translations[e]??{});return Sn(new Map([...t,...s,...o]))}function Tn(i,e){if(!i)return e;const t=new Set(Object.keys(i.translations));if(t.size===0||t.has(e))return e;const n=Ce(e);return t.has(n)?n:i.defaultLocale}function Sn(i){const e={};for(const[t,n]of i)e[t]=n;return e}function Ce(i){return i.split("-")[0]}function In(i,e){let t=!0;const n=new WebSocket(i),s=({data:o})=>{try{const{type:r}=JSON.parse(o);if(r==="ok"||r==="warnings"){if(t){t=!1;return}e()}}catch(r){console.log(`error parsing update message from ${i} : ${r}`)}};return n.addEventListener("message",s),()=>{n.removeEventListener("message",s),n.close()}}function ke(i){let e,t;return i.type!=="local"&&(e="targetPublicIdentifier"in i?i.targetPublicIdentifier:void 0,t=i.publicIdentifier),{extensionId:Ke(i),extensionPoint:{target:i.extensionPoint.target,metafields:i.extensionPoint.metafields},placementReference:i.placementReference,type:i.type,appId:i.appId,appApiKey:i.appApiKey??null,apiVersion:i.apiVersion,version:i.version,registrationId:i&&"registrationId"in i?i.registrationId:"",targetPublicIdentifier:e,publicIdentifier:t}}function An(i){const e=te(),{currentPage:t,currentDetour:n}=j().value,s=P(t),o=P(n);k(()=>{s.current=t},[t]),k(()=>{o.current=n},[n]),k(()=>{if(i)return i.on("apiRead",r=>{const a=o.current?.type??s.current?.id??"";for(const c of r.apiPropertyNames)e("extensionLifecycle",{apiPropertyName:c,extension:ke(r.extension),initialPageLoad:r.initialLoad,page:a,phase:"apiRead",section:"extension",timestamp:r.timestamp})})},[e,i])}function Cn(){const{shop:i}=R(),e=gt().buyerIdentity;return xe(()=>({isoCode:e.value?.presentmentCurrency??i.currencyCode}))}function kn({renderManager:i}){const{client:e}
1=R(),t=te(),{currentPage:n,currentDetour:s}=j().value,o=e.unstable_legacyNavigationPerformance,r=P(n),a=P(s),c=P(i);k(()=>{r.current=n},[n]),k(()=>{a.current=s},[s]),k(()=>{c.current=i},[i]),k(()=>{if(!o)return;const l=o.on("navigation",()=>{_.setEndOfInitialLoad()});return()=>{l()}},[o]),k(()=>_.subscribe(u=>{u.forEach(d=>{const p=a.current?.type??r.current?.id??"";switch(d.type){case"iframe-loader-metric":case"sandbox-fetch-metric":{const{mark:g,duration:x,timestamp:b,initialLoad:v}=d;t("extensionLifecycle",{duration:x,extension:null,phase:g,section:"extension",page:p,timestamp:b,initialPageLoad:!!v,transferredBundleSize:d.type==="sandbox-fetch-metric"?d.transferredBundleSize:void 0,bundleSize:d.type==="sandbox-fetch-metric"?d.bundleSize:void 0});break}case"extension-fetch-call-metric":{const{duration:g,timestamp:x,httpStatus:b,httpMethod:v,errorType:E,destination:y,extension:m,origin:T,requestUrl:I}=d;t("extensionFetchCall",{duration:g,destination:y,httpStatus:b,httpMethod:v,errorType:E,timestamp:x,extension:{extensionId:m.extensionId,extensionPoint:{target:m.extensionPoint.target,metafields:m.extensionPoint.metafields},placementReference:m.placementReference,type:m.type,appId:m.appId,appApiKey:m.appApiKey??null,apiVersion:m.apiVersion,version:m.version,registrationId:"registrationId"in m?m.registrationId:void 0,publicIdentifier:"publicIdentifier"in m?m.publicIdentifier:void 0,targetPublicIdentifier:"targetPublicIdentifier"in m?m.targetPublicIdentifier:void 0},section:"extension",origin:T,requestUrl:I});break}case"extension-metric":{const{mark:g,extension:x,duration:b,timestamp:v,instanceId:E,transferredBundleSize:y,bundleSize:m,initialLoad:T,ttsCompletionReason:I,ttsRenderObserved:f,ttsRequestCount:A}=d;t("extensionLifecycle",{duration:b,instanceId:E,extension:ke(x),phase:g,section:"extension",page:p,timestamp:v,initialPageLoad:!!T,transferredBundleSize:y,bundleSize:m,ttsCompletionReason:I,ttsRenderObserved:f,ttsRequestCount:A});break}}})}),[t])}function Rn(){const{client:i}=R();return{isTreatment:i.unstable_getSerialization("experiments")?.find(({clientHandle:n})=>n===Zt)?.variant===mt.Treatment}}const le=250;function Nn({localExtensions:i=[]}){const{checkout:{extensibility:e}}=R(),{isTreatment:t}=Rn(),{extensionSkeletonBatchStateSignal:n,extensionSkeletonBatchReleaseIdSignal:s,extensionSkeletonPendingCountSignal:o}=we(),r=n.value,a=t?o.value:0,c=P(null),l=e.ui.search().value,u=Xe(),p=[...i,...l].filter(u).length<=1;return k(()=>{if(r!=="collecting"){c.current=null;return}const h=c.current??Date.now();c.current=h;const g=()=>{$e(()=>{s.value+=1,n.value="idle"})};if(t?a===0:p){g();return}const b=t?Math.max(0,le-(Date.now()-h)):le,v=setTimeout(g,b);return()=>clearTimeout(v)},[r,t,a,n,s,p]),null}class _n{#e;constructor(e){this.domain=e.domain,this.action=e.action,this.#e=[e.domain,e.action,nn()].join(":"),Object.freeze(this)}get eventId(){return this.#e}}const Ln=3,Mn=200,Pn=100,he=100;function Dn(i){return new On(i)}class On{constructor({proposal:e,observability:t,negotiationRateLimiter:n}){this.queue=[],this.isProcessingQueue=!1,this.debounceTimer=null,this.debouncedNegotiations=[],this.negotiate=async({options:s,extension:o,validateCanNegotiate:r})=>(this.throwIfThrottled(o),s.customizeNegotiation?this.enqueue({options:s,extension:o,validateCanNegotiate:r}):this.debounceNegotiation({options:s,extension:o,validateCanNegotiate:r})),this.throwIfThrottled=s=>{if(this.negotiationRateLimiter.isThrottled(s.id))throw new Y(this.negotiationRateLimiter.reason)},this.recordAndCheckThrottle=(s,o)=>{const{isThrottled:r,isFirstThrottled:a}=this.negotiationRateLimiter.record(s.id,o);if(a){if(s.type!=="local"){const l=L(s),u=!0;this.observability.log("extension_sliding_window_throttle_exceeded","[Extensions::Negotiator] Extension exceeded the sliding window throttle (enforced=true)",{reason:this.negotiationRateLimiter.reason,requestCount:this.negotiationRateLimiter.maxRequests,windowMs:this.negotiationRateLimiter.windowMs,enforced:!0,isHighValueExtension:l.isHighValueExtension,extension:l,eventIds:this.negotiationRateLimiter.eventIds(s.id)},{exportImmediately:u}),this.observability.counter({name:"extension_sliding_window_throttle_exceeded",value:1,attributes:{enforced:!0,isHighValueExtension:l.isHighValueExtension},exportImmediately:u})}const c=s.appName?`${s.appName} (${s.name})`:s.name;console.warn(`Checkout UI extension ${c} has exceeded the maximum number of allowed API requests and has been blocked for this session.`)}return r?new Y(this.negotiationRateLimiter.reason):null},this.enqueue=async({options:s,extension:o,validateCanNegotiate:r})=>{if(this.queue.length>=Pn)throw new sn("There are too many negotiations waiting to be processed. Please wait and try again.");return new Promise((a,c)=>{this.queue.push({options:s,extension:o,resolve:a,reject:c,retryCount:0,validateCanNegotiate:r}),this.processQueue()})},this.processQueue=async()=>
1{if(!this.isProcessingQueue){for(this.isProcessingQueue=!0;this.queue.length>0;){const s=this.queue.shift();try{this.observability.debug("extensions_negotiator_negotiation_processed","[Extensions::Negotiator] Performing queued negotiation",{...L(s.extension),queueLength:this.queue.length});const o=await this.executeSingleNegotiation({options:s.options,extension:s.extension,validateCanNegotiate:s.validateCanNegotiate});s.resolve(o)}catch(o){if(o instanceof ce&&s.retryCount<Ln){const r=Mn*2**s.retryCount;this.observability.debug("extensions_negotiator_negotiation_processed","[Extensions::Negotiator] Retrying stale negotiation",{...L(s.extension),retryCount:s.retryCount,delayMs:r}),await Qe(r),s.retryCount++,this.queue.unshift(s)}else s.reject(o)}}this.isProcessingQueue=!1}},this.debounceNegotiation=({options:s,extension:o,validateCanNegotiate:r})=>{if(this.debounceTimer!==null){const a=this.debouncedNegotiations.length+1;return this.observability.debug("extension_negotiation_debounced",`[Extensions::Negotiator] Debounce: collapsing call ${a} into open window`,{callNumber:a,newOptions:s}),this.observability.log("extension_negotiation_debounced","[Extensions::Negotiator] Extension negotiation debounced — collapsing into pending window",{callNumber:a}),new Promise((c,l)=>{this.debouncedNegotiations.push({resolve:c,reject:l,extension:o,options:s,validateCanNegotiate:r})})}return this.observability.debug("extension_negotiation_debounced","[Extensions::Negotiator] Debounce: opening window",{options:s,delayMs:he}),new Promise((a,c)=>{this.debouncedNegotiations.push({resolve:a,reject:c,extension:o,options:s,validateCanNegotiate:r}),this.debounceTimer=setTimeout(async()=>{const l=[...this.debouncedNegotiations];this.debouncedNegotiations=[],this.debounceTimer=null,await this.executeDebouncedNegotiations(l)},he)})},this.executeDebouncedNegotiations=async s=>{this.observability.debug("extension_negotiation_debounced",`[Extensions::Negotiator] Debounce: firing for ${s.length} collapsed call(s)`),this.observability.histogram({name:"extension_negotiation_debounce_window_size",value:s.length});const o=this.rejectInvalidNegotiations(s),r=this.rejectThrottledExtensions(o);await Promise.all(r.map(async a=>{try{const c=await this.executeNegotiation({options:a.options});a.resolve(c)}catch(c){a.reject(c)}}))},this.rejectInvalidNegotiations=s=>{const o=[];for(const r of s)try{r.validateCanNegotiate(),o.push(r)}catch(a){r.reject(a)}return o},this.rejectThrottledExtensions=s=>{const o=new Map,r=[];for(const a of s){o.has(a.extension.id)||o.set(a.extension.id,this.recordAndCheckThrottle(a.extension,a.options.reason?.eventId));const c=o.get(a.extension.id);c?a.reject(c):r.push(a)}return r},this.executeSingleNegotiation=({options:s,extension:o,validateCanNegotiate:r})=>{r();const a=this.recordAndCheckThrottle(o,s.reason?.eventId);if(a!==null)throw a;return this.executeNegotiation({options:s})},this.executeNegotiation=async({options:s})=>{const{runListenersOnError:o=!0}=s,r=await this.proposal.negotiate({...s,negotiationStage:"negotiation"});switch(r.status){case"success":{const a={type:r.status,errors:r.errors,violations:r.violations,negotiationStage:"negotiation"};return this.proposal.lastJourneyProgression.value=a,await this.proposal.runListeners(a),r}case"error":{const a={type:r.status,errors:r.errors,violations:r.violations,negotiationStage:"negotiation"};return o&&(this.proposal.lastJourneyProgression.value=a,await this.proposal.runListeners(a)),r}case"invalid":throw r.reasons.includes(ae.SubmittedForCompletion)?new V("The buyer has already submitted the checkout.",{cause:{code:ae.SubmittedForCompletion}}):new Q(`Negotiation was invalid. Reasons: ${r.reasons.join(", ")}`,{cause:{code:"INVALID_NEGOTIATION"}});case"stale":throw new ce("Negotiation was stale.",{cause:{code:"STALE_NEGOTIATION"}});case"denied":throw new Q("A checkpoint was denied during negotiation.",{cause:{code:"DENIED_NEGOTIATION"}});case"throttled":throw new Q("The negotiation was throttled.",{cause:{code:"THROTTLED_NEGOTIATION"}});case"tooManyRequests":throw new V("The negotiation was halted due to too many requests.",{cause:{code:"TOO_MANY_REQUESTS_IN_NEGOTIATION"}});case"alreadyCompleted":throw new V("Negotiation was already completed.",{cause:{code:"ALREADY_COMPLETED_NEGOTIATION"}});case"fetch_failed":throw new V("The negotiation fetch failed.",{cause:{code:"NEGOTIATION_FETCH_FAILED"}});default:return(c=>{throw new on("Unknown negotiation result.",{cause:{code:"UNKNOWN_NEGOTIATION_RESULT"}})})()}},this.proposal=e,this.observability=t,this.negotiationRateLimiter=n}}const Un="unknownChange";function Bn({captureEvent:i,journeyCompletedSignal:e,wallets:t,proposal:n,observability:s,extensionPerformance:o,negotiationRateLimiter:r}){const{negotiate:a}=Dn({proposal:n,observability:s,negotiationRateLimiter:r});function c(d,{error:p,changeTypeName:h,startTimestamp:g,extension:x,extensionInstanceId:b,initialLoad:v,eventId:E}){i("extensionInteraction",{interaction:`${h}${d}`,error:p,duration:d==="Start"||g===void 0?void 0:performance.now()-g,extension:x,section:"extension",extensionInstanceId:b??"",timestamp:new Date,initialLoad:v,eventId:E,throttleCounter:r.count(x.id)})}function l({changeTypeName:d,message:p,extension:h,eventId:g,changeIsNoOp:x}){s.leaveErrorBreadcrumb(`Extensions::API::${d}`,{message:p,eventId:g,throttleCounter:r.count(h.id),extension:{appId:h.appId,id:h.id,registrationId:h.type==="local"?void 0:h.registrationId},...x!==void 0&&{changeIsNoOp:x}})}function u({changeTypeName:d,change:p,result:h,error:g,extension:x,extensionInstanceId:b,initialLoad:v,changeIsNoOp:E}){const y=g?"failed":"successful",m={...L(x),change:p,result:h,...g&&{error:g},...E!==void 0&&{changeIsNoOp:E},extensionInstanceId:b,initialLoad:v};s.debug("extenstions_change_applied",`[Extensions::ApplyChange::${d}] ${y}`,m)}return async function({unknownChange:p,extension:h,allowChangeAfterJourneyCompletion:g=!1,allowChangeDuringAcceleratedWallet:x=!1,handlers:b,errorResult:v,extensionInstanceId:E}){const y=Re(p)?p.type:Un,m=be(h),T=o.initialLoad,I=new _n({domain:"extensibility",action:y}),f=I.eventId;c("Start",{changeTypeName:y,extension:h,extensionInstanceId:E,initialLoad:T,eventId:f});const A=performance.now();try{Fn(p,b);const C=p;pe({journeyCompletedSignal:e,wallets:t,allowChangeAfterJourneyCompletion:g,allowChangeDuringAcceleratedWallet:x}),qn({negotiationRateLimiter:r,extension:h});const S=b[C.type];let w=!1;const D=await S({change:C,negotiate(N){return a({options:{...N,reason:I},extension:h,validateCanNegotiate:()=>pe({journeyCompletedSignal:e,wallets:t,allowChangeAfterJourneyCompletion:g,allowChangeDuringAcceleratedWallet:x})})},markChangeAsNoOp(){w=!0}});return c("Success",{changeTypeName:y,extension:h,extensionInstanceId:E,startTimestamp:A,initialLoad:T,eventId:f}),l({changeTypeName:y,message:`Applied change ${y} successfully`,extension:h,eventId:f,changeIsNoOp:w}),u({changeTypeName:y,change:C,result:D,extension:h,extensionInstanceId:E,initialLoad:T,changeIsNoOp:w}),D}catch(C){const S=Gn(C);Vn(S)?c("Success",{error:S,changeTypeName:y,extension:h,startTimestamp:A,extensionInstanceId:E,initialLoad:T,eventId:f}):c("Error",{error:S,changeTypeName:y,extension:h,startTimestamp:A,extensionInstanceId:E,initialLoad:T,eventId:f}),s.error(S,{metadata:{extension:m,change:{type:y}}}),l({changeTypeName:y,message:`Could not apply change ${y}. Error: ${S.message}`,extension:h,eventId:f});const w=v(S);return u({changeTypeName:y,change:p,result:w,error:{name:S.name,message:S.message,cause:S.cause},extension:h,extensionInstanceId:E,initialLoad:T}),w}}}function Re(i){return $n(i)?!!jn(i.type):!1}function $n(i){return typeof i=="object"&&i!==null&&"type"in i&&typeof i.type=="string"}function jn(i){return Je.includes(i)}function Fn(i,e){if(!Re(i)||!Object.keys(e).includes(i.type))throw new Z(`Unknown change type "${i?.type}". Valid change types include: ${Object.keys(e).map(t=>`"${t}"`).join(", ")}.`)}function pe({journeyCompletedSignal:i,wallets:e,allowChangeAfterJourneyCompletion:t,allowChangeDuringAcceleratedWallet:n}){if(!t&&i.peek())throw new Z("The buyer journey is completed");if(!n&&e.activeSession.value)throw new Z("The buyer is using an accelerated wallet")}function qn({negotiationRateLimiter:i,extension:e}){if(i.isThrottled(e.id))throw new Y(i.reason)}function Gn(i){return i instanceof Error?i:typeof i=="string"?new de(i):new de("unknown")}function Vn(i){return xt(i.name)||en(i)||tn(i)}function Ne(i){const{shop:e,extension:t}=i,{attributes:n}=Rt(i),{billingAddress:s,shippingAddress:o}=Nt(i),{metafields:r}=_t(i),{appMetafields:a}=Lt(i);return{...Ft(i),...jt(i),...$t(i),...Bt(i),...mn(i),appMetafields:a,attributes:n,billingAddress:s,extension:Ut(i),...Ot(t.apiVersion)?{metafields:r}:{},settings:Dt(i),shippingAddress:o,shop:Pt(e),storage:Mt(i),version:t.apiVersion}}const fe=Ie({name:"purchase.address-autocomplete.suggest",api(i){return{signal:void 0,target:{},...Ne(i)}}}),ge=Ie({name:"purchase.address-autocomplete.format-suggestion",api(i){return{target:{},...Ne(i)}}}
1),se={[fe.name]:fe,[ge.name]:ge},Hn={...qt,...se};function _e(i,e,t){const n=r(),s=ne(n.extensionInstance.target);return a(n);function o(c){return s in se?c.value:Gt({get current(){return c.value},subscribe:l=>{const u=je(()=>{l(c.value)}),d=i.on("restart",()=>{h()}),p=i.on("destroy",()=>{h()}),h=()=>{u(),d(),p()};return h}})}function r(){return{extensionInstance:i,createSubscribableFromSignal:o,...e}}function a(c){return Hn[s].api(c,t)}}class ie{static#e=3e4;#t;#n;#r;#s=null;#o;#a=()=>{};#c=()=>{};#d=[];#u=!1;#i=new Set;constructor(e){this.#n=new MessageChannel,this.#r=this.#n.port2,this.#o=new Promise((t,n)=>{this.#a=t,this.#c=n}),this.#t=bn({id:e.id,url:e.sandboxUrl,privileges:["allow-scripts","allow-same-origin"],name:e.name}),this.#p(e.sandboxUrl)}get rpcPort(){return this.#r}get portReady(){return this.#o}register(e){this.#i.has(e)||Fe(e),this.#i.add(e)}unregister(e){this.#i.has(e)&&(re(e),this.#i.delete(e))}emit(e){this.#i.forEach(t=>{try{t(e)}catch(n){throw new z(`HostedIframe relay listener threw: ${n}`)}})}onMessage(e){let t=!1;return this.#s?this.#s.addEventListener("message",e):this.#o.then(n=>{t||n.addEventListener("message",e)}).catch(()=>{}),()=>{t=!0,this.#s?.removeEventListener("message",e)}}postMessage(e){this.#s?.postMessage(e)}destroy(){this.#u||(this.#u=!0,this.#d.forEach(e=>e()),this.#s?.close(),this.#i.forEach(e=>{re(e)}),this.#i.clear(),this.#t.remove())}get relayApi(){return{register:e=>this.register(e),unregister:e=>this.unregister(e),emit:e=>this.emit(e),postMessage:e=>this.postMessage(e),destroy:()=>this.destroy()}}#l(e){return e.source===this.#t.contentWindow}#h(e,t){return typeof e.data=="object"&&e.data!==null&&e.data.eventName===t}#p(e){const t=this.#f(e);if(!t)return;const n=this.#n.port1;let s=!1;const o=c=>{if(!(!this.#h(c,"app-bridge-checkout::handshake")||c.origin!==t||!this.#l(c))){try{c.source?.postMessage({eventName:"checkout-web::rpc-host-port"},{targetOrigin:t,transfer:[n]}),s=!0}catch(l){if(l instanceof Error&&l.message.includes("already neutered"))return;throw l}window.removeEventListener("message",o),s&&window.addEventListener("message",r)}},r=c=>{!this.#h(c,"app-bridge-checkout::port-transfer")||c.origin!==t||!this.#l(c)||!c.ports||c.ports.length!==1||(c.source?.postMessage({eventName:"checkout-web::port-received"},{targetOrigin:t}),this.#s=c.ports[0],this.#s.start(),this.#a(this.#s),clearTimeout(a),window.removeEventListener("message",r))},a=setTimeout(()=>{window.removeEventListener("message",o),window.removeEventListener("message",r),this.#c(new rn("HostedIframe handshake timed out"))},ie.#e);window.addEventListener("message",o),this.#d.push(()=>{clearTimeout(a),window.removeEventListener("message",o),window.removeEventListener("message",r)})}#f(e){try{return new URL(e).origin}catch{return null}}}const me=100;class Le{constructor({context:e,extension:t,id:n,extensionInstanceCache:s,options:o}){this.#e=H(new Set),this.teardowns=[],this.sandboxListenerCleanups=[],this.id=n,this.target=t.extensionPoint.target,this.extension=t,this.options=o,this.extensionInstanceCache=s;const r={...e},{addDeactivatedExtension:a,defaultCacheDuration:c,sandboxCache:l,...u}=r;this.sandboxCache=l,this.createApiContext=u,this.eventMap=new Map,this.blocking=qe(()=>this.#e.value.size>0)}#e;markBlocking(e){if(this.isDestroyed)return;const t=this.#e.value;if(!t.has(e)){const n=new Set(t);n.add(e),this.#e.value=n}this.emit("block")}markNotBlocking(e){if(this.isDestroyed)return;const t=this.#e.value;if(!t.has(e))return;const n=new Set(t);n.delete(e),this.#e.value=n,n.size===0&&this.emit("unblock")}on(e,t){let n=this.eventMap.get(e);return n==null&&(n=new Set,this.eventMap.set(e,n)),n.add(t),()=>{n.delete(t)}}emit(e){const t=this.eventMap.get(e);if(t!=null)for(const n of t)n()}initializeSandbox(){if(!this.sandboxCache)throw new an("Attempted to create a sandbox in an environment that does not support them");this.sandbox=this.sandboxCache.getOrCreate({extension:this.extension,storefrontUrl:this.createApiContext.shop.storefrontUrl,myshopifyDomain:this.createApiContext.shop.myshopifyDomain}),this.sandboxListenerCleanups=this.installSandboxListeners(this.sandbox)}notifyError({error:e,isDeactivated:t=!1}){this.createApiContext.observability.error(e,{severity:"error",metadata:{...t?{deactivatedExtension:{id:this.extension.id}}:{},extension:{...be(this.extension),extensionInstanceId:this.id},source:{type:this.createApiContext.sourceType}}})}performCleanup(e){this.createApiContext.observability.leaveErrorBreadcrumb("ExtensionInstance: Destroy set to true",{isDestroyed:this.isDestroyed,rendered:this.rendered,extensionId:this.id,reason:e.reason}),this.#e.value.size>
10&&(this.#e.value=new Set,this.emit("unblock"));for(const n of this.sandboxListenerCleanups)n();this.sandboxListenerCleanups=[];const t=this.teardowns;this.teardowns=[],this.extensionInstanceCache.delete(this.id),this.executeTeardowns(t),this.sandboxCache?.release(this.sandbox),this.emit("destroy"),this.eventMap.clear(),this.createApiContext.observability.leaveErrorBreadcrumb("ExtensionInstance: Destroy event emitted",{isDestroyed:this.isDestroyed,rendered:this.rendered,extensionId:this.id,reason:e.reason})}addTeardown(e){this.isDestroyed?this.executeTeardowns([e]):(this.teardowns.length>=me&&(this.teardowns.shift(),this.createApiContext.observability.log("extension_teardown_queue_overflow",`[Extensions::Teardown] Teardown queue exceeded ${me}, dropping oldest`,{appId:this.extension.appId,extensionId:this.extension.extensionId,registrationId:"registrationId"in this.extension?this.extension.registrationId:void 0})),this.teardowns.push(e))}executeTeardowns(e){Promise.allSettled(e.map(t=>{try{return t()}catch(n){return Promise.reject(n)}})).then(t=>{for(const n of t){if(n.status!=="rejected")continue;const s=n.reason;xn(s)||cn(s)||this.createApiContext.observability.log("extension_teardown_error","[Extensions::Teardown] Teardown failed",{errorClass:s instanceof Error?s.constructor.name:typeof s,errorMessage:String(s),errorStack:s instanceof Error?s.stack??"":""})}})}}function Me({createApiContext:i,extension:e,phase:t,instanceId:n,mountId:s,mountStartTime:o,page:r="",error:a}){const{captureEvent:c,observability:l}=i,u=t==="mountStart"||o==null?void 0:Date.now()-o,d=a instanceof Error?a:void 0;if(c("extensionLifecycle",{duration:u,extension:e,phase:t,section:"extension",page:r,timestamp:new Date,instanceId:n,...s&&{mountId:s},...d&&{error:d},initialPageLoad:_.initialLoad}),t==="mountSuccess"||t==="mountError"){const p={...L(e),duration:u,...s&&{mountId:s},...d&&{error:{...d,message:d?.message??String(d)}}};(e.type==="persisted"||e.type==="global")&&l.log("extensions_lifecycle_event_phase_captured",`[Extensions::Lifecycle] ${t}`,p),l.debug("extensions_lifecycle_event_phase_captured",`[Extensions::Lifecycle] ${t}`,p)}}const zn=Object.keys(En({notifyError(){}}));function Wn(i){return new Kn(i)}class Kn extends Le{constructor({context:e,extension:t,id:n,options:s,extensionInstanceCache:o}){super({context:e,extension:t,id:n,options:s,extensionInstanceCache:o});const{addDeactivatedExtension:r,defaultCacheDuration:a,sandboxCache:c,mountRateLimiter:l,announcementEmitter:u}=e;this.receiver=new ue(t),this.addDeactivatedExtension=d=>{this.deactivated=!0,r(d)},this.deactivated=!1,this.defaultCacheDuration=a,this.mountRateLimiter=l,this.sandboxCache=c,this.announcementEmitter=u,this.isMounted=!1,this.destroyed=!1,this.renderCount=0,Xn(t.extensionPoint.target)&&typeof document<"u"&&(this.hostedIframe=new ie({sandboxUrl:e.sandboxAppBridgeUrl,id:`checkout.shopify.com-${this.id}`,name:"checkout.shopify.com/app-bridge-checkout"}))}get mounted(){return this.isMounted}get rendered(){return this.renderCount>0}get isDestroyed(){return this.destroyed}async initialize(e){try{await this.mount(e)}catch(t){this.notifyError({error:t,isDeactivated:this.deactivated})}this.leaveBreadcrumbForMountedExtension()}render(){if(this.destroyed)throw new J(`Can't render extension ${this.extension.id} because it has already been destroyed`);if(this.destroyTimeout&&clearTimeout(this.destroyTimeout),this.renderCount+=1,this.extension.type!=="local"){const e=this.mountRateLimiter.checkRate(this.id);if(!e.allowed){const t=this.extension.registrationId!=null&&Ye.has(this.extension.registrationId);this.createApiContext.observability.counter({name:"extension_mount_rate_exceeded",value:1,attributes:{reason:"rapid_mounting_detected",isHighValueExtension:t}}),this.createApiContext.observability.leaveErrorBreadcrumb("RenderExtensionInstance: Mount rate limit exceeded - possible infinite reload loop",{reason:e.reason,extensionId:this.extension.id,extensionType:this.extension.type,extensionPoint:this.extension.extensionPoint.target,appId:this.extension.appId,renderCount:this.renderCount}),this.createApiContext.observability.log("extension_mount_rate_exceeded","Extension mount rate limit exceeded - possible infinite reload loop",{...L(this.extension),renderCount:this.renderCount,retryAfterSeconds:e.retryAfterSeconds,reason:e.reason})}}return this.mount().catch(e=>{this.notifyError({error:e,isDeactivated:this.deactivated})}
1),this.emit("render"),({cache:e=this.defaultCacheDuration}={})=>{this.destroyWithCache({cache:e,reason:"render_timeout"})}}destroy(e){this.destroyed||(this.destroyTimeout&&(clearTimeout(this.destroyTimeout),this.destroyTimeout=void 0),this.hostedIframe?.destroy(),this.destroyed=!0,this.performCleanup(e),e.reason==="checkout_profile_change"&&this.captureExtensionLifecycleEvent("checkoutProfileChangeDestroy"))}installSandboxListeners(e){const t=e.on("error",s=>{if(this.destroyed)return;const o=s.name==="ExtensionSandboxError"?new Ae(String(s)):new z(String(s));this.notifyError({error:o})}),n=e.on("restart",()=>{this.isMounted=!1,this.receiver=new ue(this.extension),this.mountPromise=this.renderAndMountExtension(this.api),this.emit("restart")});return[t,n]}destroyWithCache(e){this.renderCount>0&&(this.renderCount-=1);const t=e.cache??this.defaultCacheDuration,n=Date.now(),s=Math.max(this.cacheUntil??n,n+t);if(this.cacheUntil=s,this.emit("remove"),this.createApiContext.observability.debug("extensions_lifecycle_event_phase_captured","[Extensions::Lifecycle] Remove event emitted",{...L(this.extension),isDestroyed:this.destroyed,rendered:this.rendered,extensionInstanceId:this.id,extensionDestroyedReason:e.reason}),this.destroyTimeout||this.destroyed||this.renderCount>0)return;const o=Math.max(0,this.cacheUntil-n);o<=0?this.destroy(e):this.destroyTimeout=setTimeout(()=>{this.destroy(e)},o)}async mount(e){return this.destroyed?Promise.reject(new J(`Can't mount extension ${this.extension.id} because it has already been destroyed`)):this.mountPromise!=null?this.mountPromise:(this.initializeSandbox(),_.markStarted("api-object",{extension:this.extension,instanceId:this.id,type:"extension"}),this.api=_e(this,{...this.createApiContext,extension:this.extension,storefrontTokens:this.createApiContext.storefrontTokens},this.options),_.markFinished("api-object",{extension:this.extension,instanceId:this.id,type:"extension"}),this.stepOnMount=e?.currentStep,this.mountPromise=this.renderAndMountExtension(this.api),this.mountPromise)}async renderAndMountExtension(e){const t=Te();this.deactivated=!1;const n=this.receiver,s=()=>this.receiver===n;let o=!1,r;const a=(async()=>{try{const u=this.extension.extensionPoint.target,d=Et(u),p=u===d?u:[u,d];if(this.mountStartTime=Date.now(),this.captureExtensionLifecycleEvent("mountStart",void 0,t),!this.destroyed){let h;if(St(this.extension.apiVersion))h=n.connection;else{const x=yn(n.connection);h=(...b)=>{o||this.destroyed||!s()||x(...b)}}const g=await this.sandbox?.render(p,h,zn,e,this.createApiContext.storefrontTokens,this.id,this.extension.id,this.announcementEmitter,{acceptSmsMarketing:this.createApiContext.proposal.parts.acceptSmsMarketing.peek(),smsMarketingPhone:this.createApiContext.proposal.parts.smsMarketingPhone.peek()},this.hostedIframe?.relayApi);g?.teardown&&this.addTeardown(g.teardown)}}catch(u){if(this.destroyed&&u?.message?.includes("terminated web worker"))r=u;else{this.addDeactivatedExtension(this.extension.id);let d;switch(u?.name){case"ExtensionUsageError":case"ExtensionAssetFetchError":case"ExtensionSandboxAssetFetchError":d=u;break;case"DataCloneError":d=new z("DataCloneError occurred: failed to render extension",{cause:u});break;default:d=new dn(String(u),{cause:u,groupingHash:`ExtensionRenderError::${u.name??"Unknown"}`})}throw d.name==="ExtensionUsageError"&&(this.extension.type==="persisted"||this.extension.type==="global")&&this.createApiContext.observability.log("render_extension_instance_usage_error_occurred","Extension usage error occurred: failed to render extension",{...L(this.extension),errorMessage:u.message}),d}}if(this.destroyed){const u=`${this.extension.extensionPoint.target}:${this.extension.placementReference}`,d=r?{cause:r}:void 0;throw this.extension.type==="local"?new un(`Local extension ${this.extension.id} was destroyed before it finished mounting at ${u}`,d):this.sandbox?.isWorkerAvailable()?new ln(`Extension ${this.extension.id} was destroyed before it finished mounting at ${u}`,d):new J(`Extension ${this.extension.id} was destroyed before it finished mounting at ${u}`,d)}if(!s())throw this.extension.type==="local"?new hn(`Local extension ${this.extension.id} was restarted before it finished mounting`):new pn(`Extension ${this.extension.id} was restarted before it finished mounting`);o||(this.isMounted=!0),_.markFinished("execution",{instanceId:this.id,extension:this.extension,type:"extension"}),_.markStarted("wait-time-after-execution",{instanceId:this.id,extension:this.extension,type:"extension"})})(),c=this.getExtensionMountTimeout(this.extension),l=new Promise((u,d)=>setTimeout(()=>{if(c===0)return;if(this.destroyed||this.isMounted||!s()){u();return}o=!0,this.addDeactivatedExtension(this.extension.id);const p=new fn(`Extension ${this.extension.id} timed out while mounting`);d(p)},c));try{await Promise.race([a,l]),!this.destroyed&&s()&&this.captureExtensionLifecycleEvent("mountSuccess",void 0,t),this.emit
1("mount")}catch(u){throw this.captureExtensionLifecycleEvent("mountError",u,t),u}}captureExtensionLifecycleEvent(e,t,n){Me({createApiContext:this.createApiContext,extension:this.extension,phase:e,instanceId:this.id,mountId:n,mountStartTime:this.mountStartTime,page:this.stepOnMount||"",error:t})}leaveBreadcrumbForMountedExtension(){const{id:e,extensionId:t,extensionPoint:{target:n},placementReference:s,appId:o,apiVersion:r}=this.extension;this.createApiContext.observability.leaveErrorBreadcrumb("Extensions:mountExtension",{id:e,extensionId:t,extensionPoint:n,placementReference:s,appId:o,apiVersion:r,currentStep:this.stepOnMount??""})}getExtensionMountTimeout(e){return this.createApiContext.shop.extendedExtensionTimeout?0:e.capabilities?.blockProgress?3e4:0}}function Xn(i){return i==="purchase.checkout.chat.render"||i==="purchase.thank-you.chat.render"}function Qn(i){return new Jn(i)}class Jn extends Le{constructor({context:e,extension:t,extensionInstanceCache:n,id:s,options:o}){super({context:e,id:s,extension:t,extensionInstanceCache:n,options:o}),this.rendered=!1,this.destroyed=!1,this.initialized=!1,this.hasAttemptedMount=!1,this.hasMounted=!1}get isDestroyed(){return this.destroyed}async initialize(){this.initialized||(this.initializeSandbox(),this.createStaticApi(),this.initialized=!0)}async run(e){const{target:t}=this.extension.extensionPoint;if(this.initialize(),this.destroyed)return;const n=!this.hasAttemptedMount;n&&(this.hasAttemptedMount=!0,this.mountId=Te(),this.mountStartTime=Date.now(),this.captureExtensionLifecycleEvent("mountStart"));try{const{output:s,teardown:o}=await this.sandbox.run(t,{...this.createStaticApi(),...e},this.id,this.extension.id,void 0);return this.addTeardown(o),!this.hasMounted&&!this.destroyed&&(this.hasMounted=!0,this.captureExtensionLifecycleEvent("mountSuccess")),s}catch(s){if(this.destroyed&&s?.message?.includes("terminated web worker"))return;const o=s?.name==="ExtensionUsageError"||s?.name==="ExtensionAssetFetchError"?s:new gn(String(s));n&&!this.hasMounted&&!this.destroyed&&this.captureExtensionLifecycleEvent("mountError",o),this.notifyError({error:o})}}destroy(e){this.destroyed=!0,this.performCleanup(e)}installSandboxListeners(e){return[e.on("error",n=>{if(this.destroyed)return;const s=n.name==="ExtensionSandboxError"?new Ae(String(n),{cause:n}):new z(String(n),{cause:n});this.notifyError({error:s})})]}captureExtensionLifecycleEvent(e,t){try{Me({createApiContext:this.createApiContext,extension:this.extension,phase:e,instanceId:this.id,mountId:e==="mountStart"||e==="mountSuccess"||e==="mountError"?this.mountId:void 0,mountStartTime:this.mountStartTime,error:t})}catch(n){this.createApiContext.observability.leaveErrorBreadcrumb("RunnableExtensionInstance: failed to capture lifecycle event",{phase:e,extensionId:this.id,error:n instanceof Error?n.message:String(n)})}}createStaticApi(){return _e(this,{...this.createApiContext,extension:this.extension,storefrontTokens:this.createApiContext.storefrontTokens},this.options)}}function Yn(i){return new Zn(i)}class Zn{constructor(e){this.context=e,this.cache=new Map,this.#e=new Map,this.#t=H([]),this.context.checkout.extensibility.ui.unstable_registerExtensionsManager(this),this.blockingExtensions=this.#t}#e;#t;get(e,t){const n=this.createFullIdentifier({id:e.id,target:e.extensionPoint.target,options:t}),s=this.cache.get(n);if(s)return s;const o=this.context.interceptorRegistrationResolversSignal.peek(),r=Vt(o,e.id),a=this.createExtensionInstance({context:this.context,extension:e,id:n,options:t,extensionInstanceCache:this.cache});return a.on("block",()=>{this.#e.set(a.id,e),this.#n()}),a.on("unblock",()=>{this.#e.delete(a.id),this.#n()}),a.on("destroy",()=>{this.#e.delete(a.id),this.#n();for(const c of this.cache.values())if(c.extension.id===e.id)return;Ht(o,e.id,r)}),this.cache.set(n,a),a}findAll(e){const t=this.createFullIdentifier(e),n=this.cache.get(t);return n?[n]:Array.from(this.cache.values()).filter(s=>s.id.startsWith(t))}#n(){const e=new Map;for(const t of this.#e.values())e.has(t.id)||e.set(t.id,t);this.#t.value=[...e.values()]}createExtensionInstance(e){const{extension:t}=e;return ne(t.extensionPoint.target)in se?Qn(e):Wn(e)}createFullIdentifier({id:e,target:t,options:n}){const s=`${e}:${t}`;if(n==null)return s;const o=Object.keys(n);if(o.length===0)return s;let r="";for(const a of o.sort((c,l)=>c.localeCompare(l)))r.length>0&&(r+="&"),r+=`${a}=${JSON.stringify(n[a])}`;return`${s}?${r}`}}function es(i,e){const t=[];for(const n of i)switch(ne(n.extensionPoint.target)){case"Checkout::ThankYou::CartLineDetails::RenderAfter":case"Checkout::CartLineDetails::RenderLineComponents":case"Checkout::CartLineDetails::RenderAfter":{const s=e.merchandiseLines?.lines?.filter(o=>o.variantId)?.flatMap(o=>o.lineAllocations)?.reduce((o,r)=>r.stableId?[...o,{extension:n,options:{stableId:r.stableId}}]:o,[])??[];t.push(...s);break}case"Checkout::GiftCard::Render":case"Checkout::PickupPoints::RenderBefore":case"Checkout::PickupPoints::RenderAfter":case"Checkout::PickupLocations::RenderBefore":case"Checkout::PickupLocations::RenderAfter":case"Checkout::PaymentMethod::Render":case"Checkout::PaymentMethod::HostedFields::RenderAfter":case"Checkout::ShippingMethodDetails::RenderAfter":case"Checkout::ShippingMethodDetails::RenderExpanded":break;case"Checkout::ShippingMethods::RenderBefore":case"Checkout::ShippingMethods::RenderAfter":{["2023-04","2023-07","2023-10"].includes(n.apiVersion)&&t.push({extension:n});break}default:t.push({extension:n})}return t}const ts=20,ns=6e4,ss="Too many checkout changes. See https://shopify.dev/docs/api/checkout-ui-extensions/latest#apply-changes-update-the-cart-and-checkout for details";function is(){return new os({maxRequests:ts,windowMs:ns,reason:ss})}class os{#e=new Map;#t=new Set;constructor(e){this.maxRequests=e.maxRequests,this.windowMs=e.windowMs,this.reason=e.reason}isThrottled(e){return this.#t.has(e)}record(e,t){if(this.#t.has(e))return{isThrottled:!0,isFirstThrottled:!1};const n=Date.now();let s=this.#e.get(e);s||(s=[],this.#e.set(e,s));const o=n-this.windowMs,r=s.filter(a=>a.timestamp>o);return this.#e.set(e,r),r.length>=this.maxRequests?(this.#t.add(e),{isThrottled:!0,isFirstThrottled:!0}):(r.push({timestamp:n,eventId:t}),{isThrottled:!1,isFirstThrottled:!1})}eventIds(e){return this.#n(e).map(t=>t.eventId).filter(t=>t!=null)}count(e){return this.#n(e).length}#n(e){const t=this.#e.get(e)??[];if(this.#t.has(e))return t;const n=Date.now()-this.windowMs;return t.filter(s=>s.timestamp>n)}}class rs{#e=new Map;#t;constructor(e){this.#t=e}checkRate(e){const t=Date.now();let n=this.#e.get(e);n||(n={tokens:this.#t.maxTokens,lastCheck:t},this.#e.set(e,n));const r=(t-n.lastCheck)/1e3*this.#t.refillRate;if(n.tokens=Math.min(this.#t.maxTokens,n.tokens+r),n.lastCheck=t,n.tokens<1){const c=(1-n.tokens)/this.#t.refillRate;return{allowed:!1,reason:this.#t.reason,retryAfterSeconds:Math.ceil(c)}}return n.tokens-=1,{allowed:!0,tokensRemaining:Math.floor(n.tokens)}}}function as(){const i=Ze(),e=Ee(void 0),t=ee(n=>{if(n){const[s,o]=n;i.detour(s,o)}},[i]);return Ge(()=>{const n=e.value;return Ve(()=>t(n))}),e}const cs=60*1e3,ds=10*1e3;function Js(i){return $(fs,{children:$(us,{...i})})}function us({children:i,renderManager:e}){const{checkout:{extensibility:t},i18n:n,observability:s,shop:o}=R(),r=Yt(),a=j();function c(T,I){const f=Tn(I,T),A=wn(I,T);return[f,A]}const l=t.ui.sandboxCache,d=et().workspace,p=ye(()=>{const T=d?.extensions??[],I=tt(a.value);return T.flatMap((f,A)=>{const C="development"in f?f.development.hidden:!1;return(f.extensionPoints.length?f.extensionPoints.map(w=>typeof w=="string"?{target:w,metafields:[]}:{...w,metafields:w.metafields??[]}):[{target:"Checkout::Dynamic::Render",metafields:f.metafields??[]}]).map((w,D)=>{let N,F=n.locale,q={},O={apiAccess:!1,networkAccess:!1,blockProgress:!1,collectBuyerConsent:{smsMarketing:!1,customerPrivacy:!1}},M=new Set,U="local";Ct(f)?(M=new Set(f.approvalScopes),f.capabilities.networkAccess&&M.add(It.NetworkAccessScope),N=f.assets.main.url,[F,q]=c(n.locale,f.localization),O={...O,...f.capabilities,collectBuyerConsent:{...O.collectBuyerConsent,...f.capabilities.collectBuyerConsent}},U=f.name):N=f.scriptUrl;const B=`${A}${D}`,G=f.uuid??`gid://shopify/LocalExtension/${B}
1`,Pe=`gid://shopify/LocalActivatedExtension/${B}`,De=d&&"app"in d?d.app?.title:"local",Oe=d.app?.apiKey??d?.apiKey,Ue=yt(w.target);if("preloads"in w&&typeof w.preloads=="object")try{const W=new URL(N).origin;Object.entries(w.preloads).forEach(([K,Be])=>{const oe=bt(K,Be,W);oe?w.preloads[K]=oe:delete w.preloads?.[K]})}catch(W){s.error(W)}return{type:"local",id:Pe,extensionId:G,appId:d?.appId??"",appName:De,appApiKey:Oe??"",handle:f.handle,apiVersion:f.apiVersion??At,extensionPoint:w,scriptUrl:N,extensionLocale:F,metafields:f.metafields,translations:q,placementReference:Ue?r??I:void 0,approvalScopes:M,name:U,capabilities:O,behaviors:H({showInExpressCheckout:!0,alwaysReveal:!0,blockProgress:!0}),extensionSkeletons:null,configuration:H({}),hidden:C,version:f.version??"",metafieldRequests:[]}})}).filter(f=>!f.hidden)},[d,r,n,a.value,s]),h=t.ui.search().value,g=zt([...h,...p]),x=t.ui.storefrontTokens,b=ps(l,x,g),v=e??b,E=o?.storefrontUrl??"",y=o?.myshopifyDomain??"",m=ee((T,I)=>{const f=p.filter(A=>A.extensionId===T);if(f.length!==0){if(I!==void 0){const[A,C]=c(n.locale,I);f.forEach(S=>{S.extensionLocale=A,S.translations=C})}f.forEach(A=>{l?.getOrCreate({extension:A,storefrontUrl:E,myshopifyDomain:y}).restart()})}}
1,[p,l,n,E,y]);return k(()=>{if(!(!d||!d.extensions.length))return nt(d)?kt(d,m):In(d.extensions[0].socketUrl,()=>m(p[0].extensionId))},[p,d,m]),ls(v,p,g),An(l),kn({renderManager:v}),$(it.Provider,{value:v,children:$(st.Provider,{value:p,children:[$(Nn,{localExtensions:p}),i]})})}function ls(i,e,t){const{currentPage:n}=j().value,s=Se(),o=ve(),r=ht(),{observability:a,source:c,checkout:{extensibility:l}}=R();pt(async()=>{const d=l.ui.search().peek(),p=s.current.peek(),h=t.peek(),g=ft(n,p,o.deactivatedExtensionIds,r,c.type),x=[...d,...e].filter(g);Jt(h,x);const b=await hs(x,p,i,n?.id??"");a.leaveErrorBreadcrumb("[Extensions] Finished blocking extensions check",{awaitableCount:b.length});const v=b.map(E=>h.get(E.id)?.promise||Promise.resolve());await Promise.race([new Promise((E,y)=>setTimeout(E,1e3)),Promise.all(v)])})}function hs(i,e,t,n){const s=es(i,e);return Promise.all(s.map(async({extension:o,options:r})=>(await t.get(o,r).initialize({currentStep:n}),o)))}function ps(i,e,t){const n=vt(),{checkout:s,consentManager:o,i18n:r,shop:a,source:c,observability:l,url:u,graphql:{coreGraphql:d}}=R(),p=j().value,{completed:h,journeyState:g}=p,{pageBeforeDetour:x}=wt(rt),b=vn(),v=Cn(),E=Se(),{addDeactivatedExtension:y}=ve(),m=at(),T=te(),I=ct(),{closeOverlay:f}=dt(),A=s.configuration.layout.isOnePage.value,C=as(),S=Ee(Wt),w=Kt(),D=ut(),{appMetafieldsSignal:N,currentDiscountCodeAttemptSignal:F,bankIdNumberSignal:q,cartLineChangeLoadingSignal:O}=we(),M=a.hasFlagEnabled(Tt),U=P();if(ze(()=>{try{S.value=M?Xt(o):Qt()}catch(B){l.error(B)}},[l,S,o,M]),!U.current){const B=new rs({maxTokens:10,refillRate:1,reason:"Rate limit exceeded. Extension is mounting/unmounting too rapidly."}),G=is();U.current=Yn({addDeactivatedExtension:y,captureEvent:T,defaultCacheDuration:I?ds:cs,coreGraphql:d,currencySignal:v,locale:r.locale,negotiated:E.current,proposal:n,proposed:n.parts,sandboxCache:i,mountRateLimiter:B,negotiationRateLimiter:G,shop:a,timezone:r.timeZone,webPixels:m,sourceId:c.sourceId,sourceType:c.type,isCheckoutEditor:I,journeyCompletedSignal:h,checkout:s,journeyStateSignal:g,pageBeforeDetourSignal:x,storefrontTokens:e,ui:{overlay:{close:f}},publicCheckoutSessionId:lt(c),isOnePageCheckout:A,stableDetourSignal:C,customerPrivacySignal:S,bankIdNumberSignal:q,cartPageSignal:b,cartInstructionsSignal:w,interceptorRegistrationResolversSignal:t,observability:l,consentManager:M?o:void 0,currentDiscountCodeAttemptSignal:F,cartLineChangeLoadingSignal:O,applyChange:Bn({captureEvent:T,journeyCompletedSignal:h,wallets:s.wallets,proposal:n,observability:l,extensionPerformance:_,negotiationRateLimiter:G}),announcementEmitter:D,appMetafieldsSignal:N,sandboxAppBridgeUrl:u.sandboxAppBridge()})}return U.current}function fs({children:i}){const[e,t]=He(new Set),{observability:n,checkout:{extensibility:s}}=R(),o=s.ui.search().value;k(()=>{n.addErrorMetadata("extensions",{active:o.map(({id:c})=>c)})},[n,o]);const r=ee(c=>{t(l=>{const u=new Set([...l,c]);return n.addErrorMetadata("extensions",{deactivated:Array.from(u)}),u})},[n]),a=ye(()=>({deactivatedExtensionIds:e,addDeactivatedExtension:r}),[e,r]);return $(ot.Provider,{value:a,children:i})}export{Js as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.