PageSourceSearch

https://ironstudios.com.br/cdn/shopifycloud/checkout-web/assets/c1/ExtensionsInner.4NlwuKmT.js

js ironstudios.com.br collected 2026-09-25 18:47:24 UTC 45,202 bytes, 1 lines download raw bytes

1import{f as me,ac as K,A as P,h as C,n as $e,V as je,j as Fe,R as qe,a4 as oe,y as G,o as Ve,e as xe,q as Z,p as Ge,G as He,u as B,T as Ee,k as ze,_ as We}from"./esnext-vendor.B9Da21W6.js";import{eN as Ke,fU as Xe,bI as ee,n as j,fV as Qe,dI as ye,fW as Je,fX as Ye,f as Ze,b8 as et,bb as tt,fY as nt,fZ as st,f_ as it,f$ as ot,g0 as rt,dH as be,eV as at,cs as ct,g1 as dt,g2 as ut,g3 as lt,ba as ht,g4 as pt,g5 as gt}from"./hydrate.DZ4YTm7p.js";import{i as ft,A as mt,D as xt}from"./hooks-useReplaceShopPayInHistory.DPpLejwu.js";import{S as R,a4 as Et,gA as yt,an as ve,bk as re,gB as bt,gC as te,cJ as H,B as we,gD as vt,gE as wt,gF as Tt,aA as It,Q as St,af as Te}from"./addresses-is-address-empty.Bn2lNY_L.js";import{i as At,s as kt}from"./checkout-as-guest-amazon-pay.BDkrfUVE.js";import{e as _,c as Ct,b as Rt,d as Nt,f as Lt,g as _t,h as Mt,j as Pt,s as Dt,k as Ot,l as Ut,m as Bt,n as $t,o as jt,p as Ie,R as Ft,q as qt,r as Vt,t as Gt,u as Ht,v as zt,w as Wt,x as Kt,y as Xt}from"./extension-targets-rendering-extension-targets.CtUkCn-H.js";import{a as Qt}from"./hooks-useForceShopPayUrl.BFRInJvm.js";import{e as L}from"./performance-index.mu6MOGR9.js";import{E as Jt,i as Yt,c as Zt}from"./app.DbSrjjlA.js";import{v as en}from"./dist-v4.EwEgHOG0.js";import{T as J,a as tn,b as ae,c as V,d as X,e as nn,A as Y,f as ce,H as sn,M as on,i as rn,g as Q,E as Se,h as an,L as cn,j as dn,k as un,l as ln,m as hn,n as pn}from"./utilities-extension-execution-errors.Bov3aYbn.js";import{a as gn,i as fn,c as mn}from"./AnnouncementRuntimeExtensions.CyqR_T7y.js";import{a as xn}from"./adapter-host.DrRmHuXU.js";import{L as de}from"./extensions-remote-dom.MLww-Mka.js";import{c as En}from"./amazon-pay-useAmazonPayPaymentLine.Ju006AId.js";import"./graphql-PaymentSessionMutation.CAXCwUvV.js";import"./hooks-useShopPayExternalAppContext.DWwMuRnz.js";import"./consent-manager-shared.DROIEFP2.js";import"./Page.jjGbeNkl.js";import"./AddressPresenter.BIgrto4P.js";import"./QRCode.CJw16n0F.js";import"./Pressable.ZFaj0-Rx.js";import"./Checkbox.DQyvbr9E.js";import"./Choice.DSKmQsTS.js";import"./utilities-dates.ChO2GdxN.js";import"./Popover.BScgzCsS.js";import"./PaymentIcon.CIva5Q4J.js";import"./NumberField.C_TDDWmw.js";import"./Switch.jEKUIqPZ.js";import"./EmailField.M5oHXAvJ.js";import"./TextArea.C1mMoZ65.js";import"./Sheet.CvqBdJB1.js";import"./styles-floating-layer.module.BCoSmdvP.js";import"./PhoneField.C0TeiZrn.js";import"./components-RedirectionNotice.module.CsVdFi0g.js";import"./hooks-useSuppressShopPayModalOnLoad.DFOLDSdS.js";import"./hooks-useShowShopPayOptin.Br0M25ky.js";function yn(){const i=Ke(),{i18n:e}=R();return me(()=>i.value?{id:"cart",label:e.translate("general.cart"),route:"",features:[]}:void 0)}function bn(i,e){const t=K(i?.translations[i.defaultLocale]??{}),n=Ae(e),s=K(i?.translations[n]??{}),o=K(i?.translations[e]??{});return wn(new Map([...t,...s,...o]))}function vn(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=Ae(e);return t.has(n)?n:i.defaultLocale}function wn(i){const e={};for(const[t,n]of i)e[t]=n;return e}function Ae(i){return i.split("-")[0]}function Tn(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:Xe(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 In(i){const e=ee(),{currentPage:t,currentDetour:n}=j().value,s=P(t),o=P(n);C(()=>{s.current=t},[t]),C(()=>{o.current=n},[n]),C(()=>{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 Sn(){const{shop:i}=R(),e=Et().buyerIdentity;return me(()=>({isoCode:e.value?.presentmentCurrency??i.currencyCode}))}function An({renderManager:i}){const{client:e}=R(),t=ee(),{currentPage:n,currentDetour:s}=j().value,o=e.unstable_legacyNavigationPerformance,r=P(n),a=P(s),c=P(i);C(()=>{r.current=n},[n]),C(()=>{a.current=s},[s]),C(()=>{c.current=i},[i]),C(()=>
1{if(!o)return;const l=o.on("navigation",()=>{L.setEndOfInitialLoad()});return()=>{l()}},[o]),C(()=>L.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:f,duration:x,timestamp:b,initialLoad:v}=d;t("extensionLifecycle",{duration:x,extension:null,phase:f,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:f,timestamp:x,httpStatus:b,httpMethod:v,errorType:E,destination:y,extension:m,origin:T,requestUrl:S}=d;t("extensionFetchCall",{duration:f,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:S});break}case"extension-metric":{const{mark:f,extension:x,duration:b,timestamp:v,instanceId:E,transferredBundleSize:y,bundleSize:m,initialLoad:T,ttsCompletionReason:S,ttsRenderObserved:g,ttsRequestCount:A}=d;t("extensionLifecycle",{duration:b,instanceId:E,extension:ke(x),phase:f,section:"extension",page:p,timestamp:v,initialPageLoad:!!T,transferredBundleSize:y,bundleSize:m,ttsCompletionReason:S,ttsRenderObserved:g,ttsRequestCount:A});break}}})}),[t])}function kn(){const{client:i}=R();return{isTreatment:i.unstable_getSerialization("experiments")?.find(({clientHandle:n})=>n===Jt)?.variant===yt.Treatment}}const ue=250;function Cn({localExtensions:i=[]}){const{checkout:{extensibility:e}}=R(),{isTreatment:t}=kn(),{extensionSkeletonBatchStateSignal:n,extensionSkeletonBatchReleaseIdSignal:s,extensionSkeletonPendingCountSignal:o}=ve(),r=n.value,a=t?o.value:0,c=P(null),l=e.ui.search().value,u=Qe(),p=[...i,...l].filter(u).length<=1;return C(()=>{if(r!=="collecting"){c.current=null;return}const h=c.current??Date.now();c.current=h;const f=()=>{$e(()=>{s.value+=1,n.value="idle"})};if(t?a===0:p){f();return}const b=t?Math.max(0,ue-(Date.now()-h)):ue,v=setTimeout(f,b);return()=>clearTimeout(v)},[r,t,a,n,s,p]),null}class Rn{#e;constructor(e){this.domain=e.domain,this.action=e.action,this.#e=[e.domain,e.action,en()].join(":"),Object.freeze(this)}get eventId(){return this.#e}}const Nn=3,Ln=200,_n=100,le=100;function Mn(i){return new Pn(i)}class Pn{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 J(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=_(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 J(this.negotiationRateLimiter.reason):null},this.enqueue=async({options:s,extension:o,validateCanNegotiate:r})=>{if(this.queue.length>=_n)throw new tn("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",{..._(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 ae&&s.retryCount<Nn){const r=Ln*2**s.retryCount;this.observability.debug("extensions_negotiator_negotiation_processed","[Extensions::Negotiator] Retrying stale negotiation",{..._(s.extension),retryCount:s.retryCount,delayMs:r}),await je(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:le}),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)},le)})},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(re.SubmittedForCompletion)?new V("The buyer has already submitted the checkout.",{cause:{code:re.SubmittedForCompletion}}):new X(`Negotiation was invalid. Reasons: ${r.reasons.join(", ")}`,{cause:{code:"INVALID_NEGOTIATION"}});case"stale":throw new ae("Negotiation was stale.",{cause:{code:"STALE_NEGOTIATION"}});case"denied":throw new X("A checkpoint was denied during negotiation.",{cause:{code:"DENIED_NEGOTIATION"}});case"throttled":throw new X("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 nn("Unknown negotiation result.",{cause:{code:"UNKNOWN_NEGOTIATION_RESULT"}})})()}},this.proposal=e,this.observability=t,this.negotiationRateLimiter=n}}const Dn="unknownChange";function On({captureEvent:i,journeyCompletedSignal:e,wallets:t,proposal:n,observability:s,extensionPerformance:o,negotiationRateLimiter:r}){const{negotiate:a}=Mn({proposal:n,observability:s,negotiationRateLimiter:r});function c(d,{error:p,changeTypeName:h,startTimestamp:f,extension:x,extensionInstanceId:b,initialLoad:v,eventId:E}){i("extensionInteraction",{interaction:`${h}${d}`,error:p,duration:d==="Start"||f===void 0?void 0:performance.now()-f,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:f,changeIsNoOp:x}){s.leaveErrorBreadcrumb(`Extensions::API::${d}`,{message:p,eventId:f,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:f,extension:x,extensionInstanceId:b,initialLoad:v,changeIsNoOp:E}){const y=f?"failed":"successful",m={..._(x),change:p,result:h,...f&&{error:f},...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:f=!1,allowChangeDuringAcceleratedWallet:x=!1,handlers:b,errorResult:v,extensionInstanceId:E}){const y=Ce(p)?p.type:Dn,m=ye(h),T=o.initialLoad,S=new Rn({domain:"extensibility",action:y}),g=S.eventId;c("Start",{changeTypeName:y,extension:h,extensionInstanceId:E,initialLoad:T,eventId:g});const A=performance.now();try{$n(p,b);const k=p;he({journeyCompletedSignal:e,wallets:t,allowChangeAfterJourneyCompletion:f,allowChangeDuringAcceleratedWallet:x}),jn({negotiationRateLimiter:r,extension:h});const I=b[k.type];let w=!1;const D=await I({change:k,negotiate(N){return a({options:{...N,reason:S},extension:h,validateCanNegotiate:()=>he({journeyCompletedSignal:e,wallets:t,allowChangeAfterJourneyCompletion:f,allowChangeDuringAcceleratedWallet:x})})},markChangeAsNoOp(){w=!0}});return c("Success",{changeTypeName:y,extension:h,extensionInstanceId:E,startTimestamp:A,initialLoad:T,eventId:g}),l({changeTypeName:y,message:`Applied change ${y} successfully`,extension:h,eventId:g,changeIsNoOp:w}),u({changeTypeName:y,change:k,result:D,extension:h,extensionInstanceId:E,initialLoad:T,changeIsNoOp:w}),D}catch(k){const I=Fn(k);qn(I)?c("Success",{error:I,changeTypeName:y,extension:h,startTimestamp:A,extensionInstanceId:E,initialLoad:T,eventId:g}):c("Error",{error:I,changeTypeName:y,extension:h,startTimestamp:A,extensionInstanceId:E,initialLoad:T,eventId:g}),s.error(I,{metadata:{extension:m,change:{type:y}}}),l({changeTypeName:y,message:`Could not apply change ${y}. Error: ${I.message}`,extension:h,eventId:g});const w=v(I);return u({changeTypeName:y,change:p,result:w,error:{name:I.name,message:I.message,cause:I.cause},extension:h,extensionInstanceId:E,initialLoad:T}),w}}}function Ce(i){return Un(i)?!!Bn(i.type):!1}function Un(i){return typeof i=="object"&&i!==null&&"type"in i&&typeof i.type=="string"}function Bn(i){return Je.includes(i)}function $n(i,e){if(!Ce(i)||!Object.keys(e).includes(i.type))throw new Y(`Unknown change type "${i?.type}". Valid change types include: ${Object.keys(e).map(t=>`"${t}"`).join(", ")}.`)}function he({journeyCompletedSignal:i,wallets:e,allowChangeAfterJourneyCompletion:t,allowChangeDuringAcceleratedWallet:n}){if(!t&&i.peek())throw new Y("The buyer journey is completed");if(!n&&e.activeSession.value)throw new Y("The buyer is using an accelerated wallet")}function jn({negotiationRateLimiter:i,extension:e}){if(i.isThrottled(e.id))throw new J(i.reason)}function Fn(i){return i instanceof Error?i:typeof i=="string"?new ce(i):new ce("unknown")}function qn(i){return bt(i.name)||Yt(i)||Zt(i)}function Re(i){const{shop:e,extension:t}=i,{attributes:n}=Ct(i),{billingAddress:s,shippingAddress:o}=Rt(i),{metafields:r}=Nt(i),{appMetafields:a}=Lt(i);return{...jt(i),...$t(i),...Bt(i),...Ut(i),...gn(i),appMetafields:a,attributes:n,billingAddress:s,extension:Ot(i),...Dt(t.apiVersion)?{metafields:r}:{},settings:Pt(i),shippingAddress:o,shop:Mt(e),storage:_t(i),version:t.apiVersion}}const pe=Ie({name:"purchase.address-autocomplete.suggest",api(i){return{signal:void 0,target:{},...Re(i)}}}),ge=Ie({name:"purchase.address-autocomplete.format-suggestion",api(i){return{target:{},...Re(i)}}}),ne={[pe.name]:pe,[ge.name]:ge},Vn={...Ft,...ne};function Ne(i,e,t){const n=r(),s=te(n.extensionInstance.target);return a(n);function o(c){return s in ne?c.value:qt({get current(){return c.value},subscribe:l=>{const u=Fe(()=>{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 Vn[s].api(c,t)}}class se{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=En({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)||qe(e),this.#i.add(e)}unregister(e){this.#i.has(e)&&(oe(e),this.#i.delete(e))}
1emit(e){this.#i.forEach(t=>{try{t(e)}catch(n){throw new H(`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=>{oe(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.#g(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 sn("HostedIframe handshake timed out"))},se.#e);window.addEventListener("message",o),this.#d.push(()=>{clearTimeout(a),window.removeEventListener("message",o),window.removeEventListener("message",r)})}#g(e){try{return new URL(e).origin}catch{return null}}}const fe=100;class Le{constructor({context:e,extension:t,id:n,extensionInstanceCache:s,options:o}){this.#e=G(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=Ve(()=>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 on("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:{...ye(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>0&&(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>=fe&&(this.teardowns.shift(),this.createApiContext.observability.log("extension_teardown_queue_overflow",`[Extensions::Teardown] Teardown queue exceeded ${fe}, 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;fn(s)||rn(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 _e({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:L.initialLoad}),t==="mountSuccess"||t==="mountError"){const p={..._(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 Gn=Object.keys(mn({notifyError(){}}));function Hn(i){return new zn(i)}class zn 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 de(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,Wn(t.extensionPoint.target)&&typeof document<"u"&&(this.hostedIframe=ne
1w se({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 Q(`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",{..._(this.extension),renderCount:this.renderCount,retryAfterSeconds:e.retryAfterSeconds,reason:e.reason})}}return this.mount().catch(e=>{this.notifyError({error:e,isDeactivated:this.deactivated})}),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 Se(String(s)):new H(String(s));this.notifyError({error:o})}),n=e.on("restart",()=>{this.isMounted=!1,this.receiver=new de(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",{..._(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 Q(`Can't mount extension ${this.extension.id} because it has already been destroyed`)):this.mountPromise!=null?this.mountPromise:(this.initializeSandbox(),L.markStarted("api-object",{extension:this.extension,instanceId:this.id,type:"extension"}),this.api=Ne(this,{...this.createApiContext,extension:this.extension,storefrontTokens:this.createApiContext.storefrontTokens},this.options),L.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=we();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=vt(u),p=u===d?u:[u,d];if(this.mountStartTime=Date.now(),this.captureExtensionLifecycleEvent("mountStart",void 0,t),!this.destroyed){let h;if(ft(this.extension.apiVersion))h=n.connection;else{const x=xn(n.connection);h=(...b)=>{o||this.destroyed||!s()||x(...b)}}const f=await this.sandbox?.render(p,h,Gn,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);f?.teardown&&this.addTeardown(f.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 H("DataCloneError occurred: failed to render extension",{cause:u});break;default:d=new an(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_
1instance_usage_error_occurred","Extension usage error occurred: failed to render extension",{..._(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 cn(`Local extension ${this.extension.id} was destroyed before it finished mounting at ${u}`,d):this.sandbox?.isWorkerAvailable()?new dn(`Extension ${this.extension.id} was destroyed before it finished mounting at ${u}`,d):new Q(`Extension ${this.extension.id} was destroyed before it finished mounting at ${u}`,d)}if(!s())throw this.extension.type==="local"?new un(`Local extension ${this.extension.id} was restarted before it finished mounting`):new ln(`Extension ${this.extension.id} was restarted before it finished mounting`);o||(this.isMounted=!0),L.markFinished("execution",{instanceId:this.id,extension:this.extension,type:"extension"}),L.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 hn(`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("mount")}catch(u){throw this.captureExtensionLifecycleEvent("mountError",u,t),u}}captureExtensionLifecycleEvent(e,t,n){_e({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 Wn(i){return i==="purchase.checkout.chat.render"||i==="purchase.thank-you.chat.render"}function Kn(i){return new Xn(i)}class Xn 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=we(),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 pn(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 Se(String(n),{cause:n}):new H(String(n),{cause:n});this.notifyError({error:s})})]}captureExtensionLifecycleEvent(e,t){try{_e({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 Ne(this,{...this.createApiContext,extension:this.extension,storefrontTokens:this.createApiContext.storefrontTokens},this.options)}}function Qn(i){return new Jn(i)}class Jn{constructor(e){this.context=e,this.cache=new Map,this.#e=new Map,this.#t=G([]),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;
1const 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;Gt(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 te(t.extensionPoint.target)in ne?Kn(e):Hn(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 Yn(i,e){const t=[];for(const n of i)switch(te(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 Zn=20,es=6e4,ts="Too many checkout changes. See https://shopify.dev/docs/api/checkout-ui-extensions/latest#apply-changes-update-the-cart-and-checkout for details";function ns(){return new ss({maxRequests:Zn,windowMs:es,reason:ts})}class ss{#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 is{#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 os(){const i=Ze(),e=xe(void 0),t=Z(n=>{if(n){const[s,o]=n;i.detour(s,o)}},[i]);return Ge(()=>{const n=e.value;return He(()=>t(n))}),e}const rs=60*1e3,as=10*1e3;function Qs(i){return B(hs,{children:B(cs,{...i})})}function cs({children:i,renderManager:e}){const{checkout:{extensibility:t},i18n:n,observability:s,shop:o}=R(),r=Qt(),a=j();function c(T,S){const g=vn(S,T),A=bn(S,T);return[g,A]}const l=t.ui.sandboxCache,d=et().workspace,p=Ee(()=>{const T=d?.extensions??[],S=tt(a.value);return T.flatMap((g,A)=>{const k="development"in g?g.development.hidden:!1;return(g.extensionPoints.length?g.extensionPoints.map(w=>typeof w=="string"?{target:w,metafields:[]}:{...w,metafields:w.metafields??[]}):[{target:"Checkout::Dynamic::Render",metafields:g.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";At(g)?(M=new Set(g.approvalScopes),g.capabilities.networkAccess&&M.add(mt.NetworkAccessScope),N=g.assets.main.url,[F,q]=c(n.locale,g.localization),O={...O,...g.capabilities,collectBuyerConsent:{...O.collectBuyerConsent,...g.capabilities.collectBuyerConsent}},U=g.name):N=g.scriptUrl;const $=`${A}${D}`,Me=g.uuid??`gid://shopify/LocalExtension/${$}`,Pe=`gid://shopify/LocalActivatedExtension/${$}`,De=d&&"app"in d?d.app?.title:"local",Oe=d.app?.apiKey??d?.apiKey,Ue=wt(w.target);if("preloads"in w&&typeof w.preloads=="object")try{const z=new URL(N).origin;
1Object.entries(w.preloads).forEach(([W,Be])=>{const ie=Tt(W,Be,z);ie?w.preloads[W]=ie:delete w.preloads?.[W]})}catch(z){s.error(z)}return{type:"local",id:Pe,extensionId:Me,appId:d?.appId??"",appName:De,appApiKey:Oe??"",handle:g.handle,apiVersion:g.apiVersion??xt,extensionPoint:w,scriptUrl:N,extensionLocale:F,metafields:g.metafields,translations:q,placementReference:Ue?r??S:void 0,approvalScopes:M,name:U,capabilities:O,behaviors:G({showInExpressCheckout:!0,alwaysReveal:!0,blockProgress:!0}),extensionSkeletons:null,configuration:G({}),hidden:k,version:g.version??"",metafieldRequests:[]}})}).filter(g=>!g.hidden)},[d,r,n,a.value,s]),h=t.ui.search().value,f=Ht([...h,...p]),x=t.ui.storefrontTokens,b=ls(l,x,f),v=e??b,E=o?.storefrontUrl??"",y=o?.myshopifyDomain??"",m=Z((T,S)=>{const g=p.filter(A=>A.extensionId===T);if(g.length!==0){if(S!==void 0){const[A,k]=c(n.locale,S);g.forEach(I=>{I.extensionLocale=A,I.translations=k})}g.forEach(A=>{l?.getOrCreate({extension:A,storefrontUrl:E,myshopifyDomain:y}).restart()})}},[p,l,n,E,y]);return C(()=>{if(!(!d||!d.extensions.length))return nt(d)?kt(d,m):Tn(d.extensions[0].socketUrl,()=>m(p[0].extensionId))},[p,d,m]),ds(v,p,f),In(l),An({renderManager:v}),B(it.Provider,{value:v,children:B(st.Provider,{value:p,children:[B(Cn,{localExtensions:p}),i]})})}function ds(i,e,t){const{currentPage:n}=j().value,s=Te(),o=be(),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(),f=gt(n,p,o.deactivatedExtensionIds,r,c.type),x=[...d,...e].filter(f);Kt(h,x);const b=await us(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 us(i,e,t,n){const s=Yn(i,e);return Promise.all(s.map(async({extension:o,options:r})=>(await t.get(o,r).initialize({currentStep:n}),o)))}function ls(i,e,t){const n=It(),{checkout:s,consentManager:o,i18n:r,shop:a,source:c,observability:l,url:u,graphql:{coreGraphql:d}}=R(),p=j().value,{completed:h,journeyState:f}=p,{pageBeforeDetour:x}=St(rt),b=yn(),v=Sn(),E=Te(),{addDeactivatedExtension:y}=be(),m=at(),T=ee(),S=ct(),{closeOverlay:g}=dt(),A=s.configuration.layout.isOnePage.value,k=os(),I=xe(Xt),w=zt(),D=ut(),{appMetafieldsSignal:N,currentDiscountCodeAttemptSignal:F,bankIdNumberSignal:q,cartLineChangeLoadingSignal:O}=ve(),M=P();if(We(()=>{try{I.value=Wt(o)}catch(U){l.error(U)}},[l,I,o]),!M.current){const U=new is({maxTokens:10,refillRate:1,reason:"Rate limit exceeded. Extension is mounting/unmounting too rapidly."}),$=ns();M.current=Qn({addDeactivatedExtension:y,captureEvent:T,defaultCacheDuration:S?as:rs,coreGraphql:d,currencySignal:v,locale:r.locale,negotiated:E.current,proposal:n,proposed:n.parts,sandboxCache:i,mountRateLimiter:U,negotiationRateLimiter:$,shop:a,timezone:r.timeZone,webPixels:m,sourceId:c.sourceId,sourceType:c.type,isCheckoutEditor:S,journeyCompletedSignal:h,checkout:s,journeyStateSignal:f,pageBeforeDetourSignal:x,storefrontTokens:e,ui:{overlay:{close:g}},publicCheckoutSessionId:lt(c),isOnePageCheckout:A,stableDetourSignal:k,customerPrivacySignal:I,bankIdNumberSignal:q,cartPageSignal:b,cartInstructionsSignal:w,interceptorRegistrationResolversSignal:t,observability:l,consentManager:o,currentDiscountCodeAttemptSignal:F,cartLineChangeLoadingSignal:O,applyChange:On({captureEvent:T,journeyCompletedSignal:h,wallets:s.wallets,proposal:n,observability:l,extensionPerformance:L,negotiationRateLimiter:$}),announcementEmitter:D,appMetafieldsSignal:N,sandboxAppBridgeUrl:u.sandboxAppBridge()})}return M.current}function hs({children:i}){const[e,t]=ze(new Set),{observability:n,checkout:{extensibility:s}}=R(),o=s.ui.search().value;C(()=>{n.addErrorMetadata("extensions",{active:o.map(({id:c})=>c)})},[n,o]);const r=Z(c=>{t(l=>{const u=new Set([...l,c]);return n.addErrorMetadata("extensions",{deactivated:Array.from(u)}),u})},[n]),a=Ee(()=>({deactivatedExtensionIds:e,addDeactivatedExtension:r}),[e,r]);return B(ot.Provider,{value:a,children:i})}export{Qs 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.