PageSourceSearch

https://www.vissla.com/cdn/shopifycloud/checkout-web/assets/c1/33682ee7.A5QlWHEa.js

js vissla.com collected 2026-10-02 16:25:14 UTC 44,204 bytes, 1 lines download raw bytes

1import{t as e,ac as t,l as n,m as i,n as s,V as o,j as r,r as a,a4 as c,y as d,G as h,q as l,s as u,C as p,f as g,u as m,T as x,x as f,_ as y}from"./2c1ab0fe.GMbxnz74.js";import{f1 as b,g6 as v,bT as w,e as I,e1 as E,g7 as C,g8 as k,i as S,be as T,bh as L,g9 as A,ga as P,gb as M,gc as R,gd as N,e0 as _,f4 as D,cz as j,ax as O,ge as $,gf as B,bg as q,gg as U,gh as z}from"./164ad2e3.BmqNdq2P.js";import{i as F,A as V,D as K}from"./60a453ce.fEeMtJEq.js";import{S as H,T as G,aZ as W,bp as Q,gE as J,gF as Y,b8 as Z,E as X,gG as ee,gH as te,gI as ne,aw as ie,aS as se,aa as oe}from"./4c290a1e.2OXqqQwu.js";import{i as re,s as ae}from"./55098bf1.8h6_nu_5.js";import{e as ce,c as de,b as he,d as le,f as ue,g as pe,h as ge,j as me,s as xe,k as fe,l as ye,m as be,n as ve,o as we,p as Ie,R as Ee,q as Ce,r as ke,t as Se,u as Te,v as Le,w as Ae,x as Pe,y as Me}from"./c610ba76.CVEIqZFh.js";import{a as Re}from"./2fdb3dd3.DcIdY-nh.js";import{e as Ne}from"./9c384ce8.CFjjgE6K.js";import{v as _e}from"./2210eadb.DF0gIp_2.js";import{i as De,c as je}from"./app.iZwEIta_.js";import{T as Oe,a as $e,b as Be,c as qe,d as Ue,e as ze,A as Fe,f as Ve,H as Ke,M as He,i as Ge,g as We,E as Qe,h as Je,L as Ye,j as Ze,k as Xe,l as et,m as tt,n as nt}from"./66338e00.CZg7rFan.js";import{a as it,i as st,c as ot}from"./28ac86c0.B3L04Tlv.js";import{L as rt,a as at}from"./27f09e31.BCPS7kNH.js";import{c as ct}from"./ac5a19ff.DlwW5UC8.js";import"./9f047e05.Bp-gLL-x.js";import"./0a7dffce.BIRsKacx.js";import"./5fda1420.C7SyMXTh.js";import"./21cc90a2.BYvnDDaS.js";import"./bb728e1c.D-ELh9cQ.js";import"./413b21e2.BR4Ns-ic.js";import"./53bbdad9.Z4N3tZKQ.js";import"./3e6029dd.DwFWUGoq.js";import"./30074413.D9CsKy_H.js";import"./efa0389a.BaeWUwuC.js";import"./9f57d2aa.DGYsgK89.js";import"./8574876b.DlqSeZRL.js";import"./064f6ac1.DqrP83xw.js";import"./598fef4e.DTBD4kzt.js";import"./33d2e4fc.D4zfSoBl.js";import"./39921a74.CFM70_Q1.js";import"./137622f3.BmZtJbLW.js";import"./54bf0ebb.ieqDwZM0.js";import"./1ed8f5e3.DkmKdCgD.js";import"./47b970b2.B-hNfQZG.js";import"./29034f35.B7Z7JU9E.js";import"./0727407f.C7yJLDwL.js";function dt(e){return e.split("-")[0]}function ht(e){let t,n;return"local"!==e.type&&(t="targetPublicIdentifier"in e?e.targetPublicIdentifier:void 0,n=e.publicIdentifier),{extensionId:v(e),extensionPoint:{target:e.extensionPoint.target,metafields:e.extensionPoint.metafields},placementReference:e.placementReference,type:e.type,appId:e.appId,appApiKey:e.appApiKey??null,apiVersion:e.apiVersion,version:e.version,registrationId:e&&"registrationId"in e?e.registrationId:"",targetPublicIdentifier:t,publicIdentifier:n}}function lt(){const{extensionSkeletonBatchStateSignal:e,extensionSkeletonBatchReleaseIdSignal:t,extensionSkeletonPendingCountSignal:o}=W(),r=e.value,a=o.value,c=n(null);return i(()=>{if("collecting"!==r)return void(c.current=null);const n=c.current??Date.now();c.current=n;const i=()=>{s(()=>{t.value+=1,e.value="idle"})};if(0===a)return void i();const o=setTimeout(i,Math.max(0,250-(Date.now()-n)));return()=>clearTimeout(o)},[r,a,e,t]),null}class ut{#e;constructor(e){this.domain=e.domain,this.action=e.action,this.#e=[e.domain,e.action,_e()].join(":"),Object.freeze(this)}get eventId(){return this.#e}}class pt{constructor({proposal:e,observability:t,negotiationRateLimiter:n}){this.queue=[],this.isProcessingQueue=!1,this.debounceTimer=null,this.debouncedNegotiations=[],this.negotiate=async({options:e,extension:t,validateCanNegotiate:n})=>(this.throwIfThrottled(t),e.customizeNegotiation?this.enqueue({options:e,extension:t,validateCanNegotiate:n}):this.debounceNegotiation({options:e,extension:t,validateCanNegotiate:n})),this.throwIfThrottled=e=>{if(this.negotiationRateLimiter.isThrottled(e.id))throw new Oe(this.negotiationRateLimiter.reason)},this.recordAndCheckThrottle=(e,t)=>{const{isThrottled:n,isFirstThrottled:i}=this.negotiationRateLimiter.record(e.id,t);if(i){if("local"!==e.type){const t=ce(e),n=!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:t.isHighValueExtension,extension:t,eventIds:this.negotiationRateLimiter.eventIds(e.id)},{exportImmediately:n}),this.observability.counter({name:"extension_sliding_window_throttle_exceeded",value:1,attributes:{enforced:!0,isHighValueExtension:t.isHighValueExtension},exportImmediately:n})}const t=e.appName?`${e.appName} (${e.name})`:e.name;console.warn(`Checkout UI extension ${t} has exceeded the maximum number of allowed API requests and has been blocked for this session.`)}return n?new Oe(this.negotiationRateLimiter.reason):null},this.enqueue=async({options:e,extension:t,validateCanNegotiate:n})=>{if(this.queue.length>=100)throw new $e("There are too many negotiations waiting to be processed. Please wait and try again.");return new Promise((i,s)=>{this.queue.push({options:e,extension:t,resolve:i,reject:s,retryCount:0,validateCanNegotiate:n}),this.processQueue()})},this.processQueue=async()=>
1{if(!this.isProcessingQueue){for(this.isProcessingQueue=!0;this.queue.length>0;){const t=this.queue.shift();try{this.observability.debug("extensions_negotiator_negotiation_processed","[Extensions::Negotiator] Performing queued negotiation",{...ce(t.extension),queueLength:this.queue.length});const e=await this.executeSingleNegotiation({options:t.options,extension:t.extension,validateCanNegotiate:t.validateCanNegotiate});t.resolve(e)}catch(e){if(e instanceof Be&&t.retryCount<3){const e=200*2**t.retryCount;this.observability.debug("extensions_negotiator_negotiation_processed","[Extensions::Negotiator] Retrying stale negotiation",{...ce(t.extension),retryCount:t.retryCount,delayMs:e}),await o(e),t.retryCount++,this.queue.unshift(t)}else t.reject(e)}}this.isProcessingQueue=!1}},this.debounceNegotiation=({options:e,extension:t,validateCanNegotiate:n})=>{if(null!==this.debounceTimer){const i=this.debouncedNegotiations.length+1;return this.observability.debug("extension_negotiation_debounced",`[Extensions::Negotiator] Debounce: collapsing call ${i} into open window`,{callNumber:i,newOptions:e}),this.observability.log("extension_negotiation_debounced","[Extensions::Negotiator] Extension negotiation debounced — collapsing into pending window",{callNumber:i}),new Promise((i,s)=>{this.debouncedNegotiations.push({resolve:i,reject:s,extension:t,options:e,validateCanNegotiate:n})})}return this.observability.debug("extension_negotiation_debounced","[Extensions::Negotiator] Debounce: opening window",{options:e,delayMs:100}),new Promise((i,s)=>{this.debouncedNegotiations.push({resolve:i,reject:s,extension:t,options:e,validateCanNegotiate:n}),this.debounceTimer=setTimeout(async()=>{const e=[...this.debouncedNegotiations];this.debouncedNegotiations=[],this.debounceTimer=null,await this.executeDebouncedNegotiations(e)},100)})},this.executeDebouncedNegotiations=async e=>{this.observability.debug("extension_negotiation_debounced",`[Extensions::Negotiator] Debounce: firing for ${e.length} collapsed call(s)`),this.observability.histogram({name:"extension_negotiation_debounce_window_size",value:e.length});const t=this.rejectInvalidNegotiations(e),n=this.rejectThrottledExtensions(t);await Promise.all(n.map(async e=>{try{const t=await this.executeNegotiation({options:e.options});e.resolve(t)}catch(t){e.reject(t)}}))},this.rejectInvalidNegotiations=e=>{const t=[];for(const i of e)try{i.validateCanNegotiate(),t.push(i)}catch(n){i.reject(n)}return t},this.rejectThrottledExtensions=e=>{const t=new Map,n=[];for(const i of e){t.has(i.extension.id)||t.set(i.extension.id,this.recordAndCheckThrottle(i.extension,i.options.reason?.eventId));const e=t.get(i.extension.id);e?i.reject(e):n.push(i)}return n},this.executeSingleNegotiation=({options:e,extension:t,validateCanNegotiate:n})=>{n();const i=this.recordAndCheckThrottle(t,e.reason?.eventId);if(null!==i)throw i;return this.executeNegotiation({options:e})},this.executeNegotiation=async({options:e})=>{const{runListenersOnError:t=!0}=e,n=await this.proposal.negotiate({...e,negotiationStage:"negotiation"});switch(n.status){case"success":{const e={type:n.status,errors:n.errors,violations:n.violations,negotiationStage:"negotiation"};return this.proposal.recordProgression(e),await this.proposal.runListeners(e),n}case"error":{const e={type:n.status,errors:n.errors,violations:n.violations,negotiationStage:"negotiation"};return t&&(this.proposal.recordProgression(e),await this.proposal.runListeners(e)),n}case"invalid":if(n.reasons.includes(Q.SubmittedForCompletion))throw new qe("The buyer has already submitted the checkout.",{cause:{code:Q.SubmittedForCompletion}});throw new Ue(`Negotiation was invalid. Reasons: ${n.reasons.join(", ")}`,{cause:{code:"INVALID_NEGOTIATION"}});case"stale":throw new Be("Negotiation was stale.",{cause:{code:"STALE_NEGOTIATION"}});case"denied":throw new Ue("A checkpoint was denied during negotiation.",{cause:{code:"DENIED_NEGOTIATION"}});case"throttled":throw new Ue("The negotiation was throttled.",{cause:{code:"THROTTLED_NEGOTIATION"}});case"tooManyRequests":throw new qe("The negotiation was halted due to too many requests.",{cause:{code:"TOO_MANY_REQUESTS_IN_NEGOTIATION"}});case"alreadyCompleted":throw new qe("Negotiation was already completed.",{cause:{code:"ALREADY_COMPLETED_NEGOTIATION"}});case"fetch_failed":throw new qe("The negotiation fetch failed.",{cause:{code:"NEGOTIATION_FETCH_FAILED"}});default:return(()=>{throw new ze("Unknown negotiation result.",{cause:{code:"UNKNOWN_NEGOTIATION_RESULT"}})})()}},this.proposal=e,this.observability=t,this.negotiationRateLimiter=n}}function gt({captureEvent:e,journeyCompletedSignal:t,wallets:n,proposal:i,observability:s,extensionPerformance:o,negotiationRateLimiter:r}){const{negotiate:a}=new pt({proposal:i,observability:s,negotiationRateLimiter:r});function c(t,{error:n,changeTypeName:i,startTimestamp:s,extension:o,extensionInstanceId:a,initialLoad:c,eventId:d}){e("extensionInteraction",{interaction:`${i}${t}`,error:n,duration:"Start"===t||void 0===s?void 0:performance.now()-s,extension:o,section:"extension",extensionInstanceId:a??"",timestamp:new Date,initialLoad:c,eventId:d,throttleCounter:r.count(o.id)})}function d({changeTypeName:e,message:t,extension:n,eventId:i,changeIsNoOp:o}){s.leaveErrorBreadcrumb(`Extensions::API::${e}`,{message:t,eventId:i,throttleCounter:r.count(n.id),extension:{appId:n.appId,id:n.id,registrationId:"local"===n.type?void 0:n.registrationId},...void 0!==o&&{changeIsNoOp:o}})}function h({changeTypeName:e,change:t,result:n,error:i,extension:o,extensionInstanceId:r,initialLoad:a,changeIsNoOp:c}){const d=i?"failed":"successful",h={...ce(o),change:t,result:n,...i&&{error:i},...void 0!==c&&{changeIsNoOp:c},extensionInstanceId:r,initialLoad:a};s.debug("extenstions_change_applied",`[Extensions::ApplyChange::${e}] ${d}`,h)}return async function({unknownChange:e,extension:i,allowChangeAfterJourneyCompletion:l=!1,allowChangeDuringAcceleratedWallet:u=!1,handlers:p,errorResult:g,extensionInstanceId:m}){const x=mt(e)?e.type:"unknownChange",f=E(i),y=o.initialLoad,b=new ut({domain:"extensibility",action:x}),v=b.eventId;c("Start",{changeTypeName:x,extension:i,extensionInstanceId:m,initialLoad:y,eventId:v});const w=performance.now();try{!function(e,t){if(!mt(e)||!Object.keys(t).includes(e.type))throw new Fe(`Unknown change type "${e?.type}". Valid change types include: ${Object.keys(t).map(e=>`"${e}"`).join(", ")}.`)}(e,p);const s=e;xt({journeyCompletedSignal:t,wallets:n,allowChangeAfterJourneyCompletion:l,allowChangeDuringAcceleratedWallet:u}),function({negotiationRateLimiter:e,extension:t}){if(e.isThrottled(t.id))throw new Oe(e.reason)}({negotiationRateLimiter:r,extension:i});const o=p[s.type];let g=!1;const f=await o({change:s,negotiate:e=>a({options:{...e,reason:b},extension:i,validateCanNegotiate:()=>xt({journeyCompletedSignal:t,wallets:n,allowChangeAfterJourneyCompletion:l,allowChangeDuringAcceleratedWallet:u})}),markChangeAsNoOp(){g=!0}});return c("Success",{changeTypeName:x,extension:i,extensionInstanceId:m,startTimestamp:w,initialLoad:y,eventId:v}),d({changeTypeName:x,message:`Applied change ${x} successfully`,extension:i,eventId:v,changeIsNoOp:g}),h({changeTypeName:x,change:s,result:f,extension:i,extensionInstanceId:m,initialLoad:y,changeIsNoOp:g}),f}catch(C){const t=function(e){return e instanceof Error?e:new Ve("string"==typeof e?e:"unknown")}(C);J((I=t).name)||De(I)||je(I)?c("Success",{error:t,changeTypeName:x,extension:i,startTimestamp:w,extensionInstanceId:m,initialLoad:y,eventId:v}):c("Error",{error:t,changeTypeName:x,extension:i,startTimestamp:w,extensionInstanceId:m,initialLoad:y,eventId:v}),s.error(t,{metadata:{extension:f,change:{type:x}}}),d({changeTypeName:x,message:`Could not apply change ${x}. Error: ${t.message}`,extension:i,eventId:v});const n=g(t);return h({changeTypeName:x,change:e,result:n,error:{name:t.name,message:t.message,cause:t.cause},extension:i,extensionInstanceId:m,initialLoad:y}),n}var I}}function mt(e){return!!function(e){return"object"==typeof e&&null!==e&&"type"in e&&"string"==typeof e.type}(e)&&(t=e.type,!!C.includes(t));var t}function xt({journeyCompletedSignal:e,wallets:t,allowChangeAfterJourneyCompletion:n,allowChangeDuringAcceleratedWallet:i}){if(!n&&e.peek())throw new Fe("The buyer journey is completed");if(!i&&Boolean(t.activeSession.value))throw new Fe("The buyer is using an accelerated wallet")}function ft(e){const{shop:t,extension:n}=e,{attributes:i}=de(e),{billingAddress:s,shippingAddress:o}=he(e),{metafields:r}
1=le(e),{appMetafields:a}=ue(e);return{...we(e),...ve(e),...be(e),...ye(e),...it(e),appMetafields:a,attributes:i,billingAddress:s,extension:fe(e),...xe(n.apiVersion)?{metafields:r}:{},settings:me(e),shippingAddress:o,shop:ge(t),storage:pe(e),version:n.apiVersion}}const yt=Ie({name:"purchase.address-autocomplete.suggest",api:e=>({signal:void 0,target:{},...ft(e)})}),bt=Ie({name:"purchase.address-autocomplete.format-suggestion",api:e=>({target:{},...ft(e)})}),vt={[yt.name]:yt,[bt.name]:bt},wt={...Ee,...vt};function It(e,t,n){const i={extensionInstance:e,createSubscribableFromSignal:function(t){return s in vt?t.value:Ce({get current(){return t.value},subscribe:n=>{const i=r(()=>{n(t.value)}),s=e.on("restart",()=>{a()}),o=e.on("destroy",()=>{a()}),a=()=>{i(),s(),o()};return a}})},...t},s=Y(i.extensionInstance.target);return o=i,wt[s].api(o,n);var o}class Et{static#t=3e4;#n;#i;#s;#o=null;#r;#a=()=>{};#c=()=>{};#d=[];#h=!1;#l=new Set;constructor(e){this.#i=new MessageChannel,this.#s=this.#i.port2,this.#r=new Promise((e,t)=>{this.#a=e,this.#c=t}),this.#n=ct({id:e.id,url:e.sandboxUrl,privileges:["allow-scripts","allow-same-origin"],name:e.name}),this.#u(e.sandboxUrl)}get rpcPort(){return this.#s}get portReady(){return this.#r}register(e){this.#l.has(e)||a(e),this.#l.add(e)}unregister(e){this.#l.has(e)&&(c(e),this.#l.delete(e))}emit(e){this.#l.forEach(t=>{try{t(e)}catch(n){throw new Z(`HostedIframe relay listener threw: ${n}`)}})}onMessage(e){let t=!1;return this.#o?this.#o.addEventListener("message",e):this.#r.then(n=>{t||n.addEventListener("message",e)}).catch(()=>{}),()=>{t=!0,this.#o?.removeEventListener("message",e)}}postMessage(e){this.#o?.postMessage(e)}destroy(){this.#h||(this.#h=!0,this.#d.forEach(e=>e()),this.#o?.close(),this.#l.forEach(e=>{c(e)}),this.#l.clear(),this.#n.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()}}#p(e){return e.source===this.#n.contentWindow}#g(e,t){return"object"==typeof e.data&&null!==e.data&&e.data.eventName===t}#u(e){const t=this.#m(e);if(!t)return;const n=this.#i.port1;let i=!1;const s=e=>{if(this.#g(e,"app-bridge-checkout::handshake")&&e.origin===t&&this.#p(e)){try{e.source?.postMessage({eventName:"checkout-web::rpc-host-port"},{targetOrigin:t,transfer:[n]}),i=!0}catch(r){if(r instanceof Error&&r.message.includes("already neutered"))return;throw r}window.removeEventListener("message",s),i&&window.addEventListener("message",o)}},o=e=>{this.#g(e,"app-bridge-checkout::port-transfer")&&e.origin===t&&this.#p(e)&&e.ports&&1===e.ports.length&&(e.source?.postMessage({eventName:"checkout-web::port-received"},{targetOrigin:t}),this.#o=e.ports[0],this.#o.start(),this.#a(this.#o),clearTimeout(r),window.removeEventListener("message",o))},r=setTimeout(()=>{window.removeEventListener("message",s),window.removeEventListener("message",o),this.#c(new Ke("HostedIframe handshake timed out"))},Et.#t);window.addEventListener("message",s),this.#d.push(()=>{clearTimeout(r),window.removeEventListener("message",s),window.removeEventListener("message",o)})}#m(e){try{return new URL(e).origin}catch{return null}}}class Ct{constructor({context:e,extension:t,id:n,extensionInstanceCache:i,options:s}){this.#x=d(new Set),this.teardowns=[],this.sandboxListenerCleanups=[],this.id=n,this.target=t.extensionPoint.target,this.extension=t,this.options=s,this.extensionInstanceCache=i;const o={...e},{addDeactivatedExtension:r,defaultCacheDuration:a,sandboxCache:c,...l}=o;this.sandboxCache=c,this.createApiContext=l,this.eventMap=new Map,this.blocking=h(()=>this.#x.value.size>0)}#x;markBlocking(e){if(this.isDestroyed)return;const t=this.#x.value;if(!t.has(e)){const n=new Set(t);n.add(e),this.#x.value=n}this.emit("block")}markNotBlocking(e){if(this.isDestroyed)return;const t=this.#x.value;if(!t.has(e))return;const n=new Set(t);n.delete(e),this.#x.value=n,0===n.size&&this.emit("unblock")}on(e,t){let n=this.eventMap.get(e);return null==n&&(n=new Set,this.eventMap.set(e,n)),n.add(t),()=>{n.delete(t)}}emit(e){const t=this.eventMap.get(e);if(null!=t)for(const n of t)n()}initializeSandbox(){if(!this.sandboxCache)throw new He("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:{...E(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.#x.value.size>
10&&(this.#x.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>=100&&(this.teardowns.shift(),this.createApiContext.observability.log("extension_teardown_queue_overflow","[Extensions::Teardown] Teardown queue exceeded 100, 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(e=>{try{return e()}catch(t){return Promise.reject(t)}})).then(e=>{for(const t of e){if("rejected"!==t.status)continue;const e=t.reason;st(e)||Ge(e)||this.createApiContext.observability.log("extension_teardown_error","[Extensions::Teardown] Teardown failed",{errorClass:e instanceof Error?e.constructor.name:typeof e,errorMessage:String(e),errorStack:e instanceof Error?e.stack??"":""})}})}}function kt({createApiContext:e,extension:t,phase:n,instanceId:i,mountId:s,mountStartTime:o,page:r="",error:a}){const{captureEvent:c,observability:d}=e,h="mountStart"===n||null==o?void 0:Date.now()-o,l=a instanceof Error?a:void 0;if(c("extensionLifecycle",{duration:h,extension:t,phase:n,section:"extension",page:r,timestamp:new Date,instanceId:i,...s&&{mountId:s},...l&&{error:l},initialPageLoad:Ne.initialLoad}),"mountSuccess"===n||"mountError"===n){const e={...ce(t),duration:h,...s&&{mountId:s},...l&&{error:{...l,message:l?.message??String(l)}}};"persisted"!==t.type&&"global"!==t.type||d.log("extensions_lifecycle_event_phase_captured",`[Extensions::Lifecycle] ${n}`,e),d.debug("extensions_lifecycle_event_phase_captured",`[Extensions::Lifecycle] ${n}`,e)}}const St=Object.keys(ot({notifyError(){}}));class Tt extends Ct{constructor({context:e,extension:t,id:n,options:i,extensionInstanceCache:s}){super({context:e,extension:t,id:n,options:i,extensionInstanceCache:s});const{addDeactivatedExtension:o,defaultCacheDuration:r,sandboxCache:a,mountRateLimiter:c,announcementEmitter:
1d}=e;var h;this.receiver=new rt(t),this.addDeactivatedExtension=e=>{this.deactivated=!0,o(e)},this.deactivated=!1,this.defaultCacheDuration=r,this.mountRateLimiter=c,this.sandboxCache=a,this.announcementEmitter=d,this.isMounted=!1,this.destroyed=!1,this.renderCount=0,"purchase.checkout.chat.render"!==(h=t.extensionPoint.target)&&"purchase.thank-you.chat.render"!==h||"undefined"==typeof document||(this.hostedIframe=new Et({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 We(`Can't render extension ${this.extension.id} because it has already been destroyed`);if(this.destroyTimeout&&clearTimeout(this.destroyTimeout),this.renderCount+=1,"local"!==this.extension.type){const e=this.mountRateLimiter.checkRate(this.id);if(!e.allowed){const t=null!=this.extension.registrationId&&k.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",{...ce(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),"checkout_profile_change"===e.reason&&this.captureExtensionLifecycleEvent("checkoutProfileChangeDestroy"))}installSandboxListeners(e){return[e.on("error",e=>{if(this.destroyed)return;const t="ExtensionSandboxError"===e.name?new Qe(String(e)):new Z(String(e));this.notifyError({error:t})}),e.on("restart",()=>{this.isMounted=!1,this.receiver=new rt(this.extension),this.mountPromise=this.renderAndMountExtension(this.api),this.emit("restart")})]}destroyWithCache(e){this.renderCount>0&&(this.renderCount-=1);const t=e.cache??this.defaultCacheDuration,n=Date.now(),i=Math.max(this.cacheUntil??n,n+t);if(this.cacheUntil=i,this.emit("remove"),this.createApiContext.observability.debug("extensions_lifecycle_event_phase_captured","[Extensions::Lifecycle] Remove event emitted",{...ce(this.extension),isDestroyed:this.destroyed,rendered:this.rendered,extensionInstanceId:this.id,extensionDestroyedReason:e.reason}),this.destroyTimeout||this.destroyed)return;if(this.renderCount>0)return;const s=Math.max(0,this.cacheUntil-n);s<=0?this.destroy(e):this.destroyTimeout=setTimeout(()=>{this.destroy(e)},s)}async mount(e){return this.destroyed?Promise.reject(new We(`Can't mount extension ${this.extension.id} because it has already been destroyed`)):(null!=this.mountPromise||(this.initializeSandbox(),Ne.markStarted("api-object",{extension:this.extension,instanceId:this.id,type:"extension"}),this.api=It(this,{...this.createApiContext,extension:this.extension,storefrontTokens:this.createApiContext.storefrontTokens},this.options),Ne.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=X();this.deactivated=!1;const n=this.receiver,i=()=>this.receiver===n;let s,o=!1;const r=(async()=>{try{const s=this.extension.extensionPoint.target,r=ee(s),a=s===r?s:[s,r];if(this.mountStartTime=Date.now(),this.captureExtensionLifecycleEvent("mountStart",void 0,t),!this.destroyed){let t;if(F(this.extension.apiVersion))t=n.connection;else{const e=at(n.connection);t=(...t)=>{o||this.destroyed||!i()||e(...t)}}const s=await(this.sandbox?.render(a,t,St,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));s?.teardown&&this.addTeardown(s.teardown)}}catch(r){if(!this.destroyed||!r?.message?.includes("terminated web worker")){let e;switch(this.addDeactivatedExtension(this.extension.id),r?.name){case"ExtensionUsageError":case"ExtensionAssetFetchError":case"ExtensionSandboxAssetFetchError":e=r;break;case"DataCloneError":e=new Z("DataCloneError occurred: failed to render extension",{cause:r});break;default:e=new Je(String(r),{cause:r,groupingHash:`ExtensionRenderError::${r.name??"Unknown"}`})}throw"ExtensionUsageError"!==e.name||"persisted"!==this.extension.type&&"global"!==this.extension.type||this.createApiContext.observability.log("render_extension_
1instance_usage_error_occurred","Extension usage error occurred: failed to render extension",{...ce(this.extension),errorMessage:r.message}),e}s=r}if(this.destroyed){const e=`${this.extension.extensionPoint.target}:${this.extension.placementReference}`,t=s?{cause:s}:void 0;if("local"===this.extension.type)throw new Ye(`Local extension ${this.extension.id} was destroyed before it finished mounting at ${e}`,t);if(this.sandbox?.isWorkerAvailable())throw new Ze(`Extension ${this.extension.id} was destroyed before it finished mounting at ${e}`,t);throw new We(`Extension ${this.extension.id} was destroyed before it finished mounting at ${e}`,t)}if(!i()){if("local"===this.extension.type)throw new Xe(`Local extension ${this.extension.id} was restarted before it finished mounting`);throw new et(`Extension ${this.extension.id} was restarted before it finished mounting`)}o||(this.isMounted=!0),Ne.markFinished("execution",{instanceId:this.id,extension:this.extension,type:"extension"}),Ne.markStarted("wait-time-after-execution",{instanceId:this.id,extension:this.extension,type:"extension"})})(),a=this.getExtensionMountTimeout(this.extension),c=new Promise((e,t)=>setTimeout(()=>{if(0===a)return;if(this.destroyed||this.isMounted||!i())return void e();o=!0,this.addDeactivatedExtension(this.extension.id);const n=new tt(`Extension ${this.extension.id} timed out while mounting`);t(n)},a));try{await Promise.race([r,c]),!this.destroyed&&i()&&this.captureExtensionLifecycleEvent("mountSuccess",void 0,t),this.emit("mount")}catch(d){throw this.captureExtensionLifecycleEvent("mountError",d,t),d}}captureExtensionLifecycleEvent(e,t,n){kt({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:i,appId:s,apiVersion:o}=this.extension;this.createApiContext.observability.leaveErrorBreadcrumb("Extensions:mountExtension",{id:e,extensionId:t,extensionPoint:n,placementReference:i,appId:s,apiVersion:o,currentStep:this.stepOnMount??""})}getExtensionMountTimeout(e){if(this.createApiContext.shop.extendedExtensionTimeout)return 0;const t=e.capabilities?.blockProgress;return t?3e4:0}}class Lt extends Ct{constructor({context:e,extension:t,extensionInstanceCache:n,id:i,options:s}){super({context:e,id:i,extension:t,extensionInstanceCache:n,options:s}),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=X(),this.mountStartTime=Date.now(),this.captureExtensionLifecycleEvent("mountStart"));try{const{output:n,teardown:i}=await this.sandbox.run(t,{...this.createStaticApi(),...e},this.id,this.extension.id,void 0);return this.addTeardown(i),this.hasMounted||this.destroyed||(this.hasMounted=!0,this.captureExtensionLifecycleEvent("mountSuccess")),n}catch(i){if(this.destroyed&&i?.message?.includes("terminated web worker"))return;const e="ExtensionUsageError"===i?.name||"ExtensionAssetFetchError"===i?.name?i:new nt(String(i));!n||this.hasMounted||this.destroyed||this.captureExtensionLifecycleEvent("mountError",e),this.notifyError({error:e})}}destroy(e){this.destroyed=!0,this.performCleanup(e)}installSandboxListeners(e){return[e.on("error",e=>{if(this.destroyed)return;const t="ExtensionSandboxError"===e.name?new Qe(String(e),{cause:e}):new Z(String(e),{cause:e});this.notifyError({error:t})})]}captureExtensionLifecycleEvent(e,t){try{kt({createApiContext:this.createApiContext,extension:this.extension,phase:e,instanceId:this.id,mountId:"mountStart"===e||"mountSuccess"===e||"mountError"===e?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 It(this,{...this.createApiContext,extension:this.extension,storefrontTokens:this.createApiContext.storefrontTokens},this.options)}}class At{constructor(e){this.context=e,this.cache=new Map,this.#f=new Map,this.#y=d([]),this.context.checkout.extensibility.ui.unstable_registerExtensionsManager(this),this.blockingExtensions=this.#y}#f;#y;get(e,t){const n=this.createFullIdentifier({id:e.id,target:e.extensionPoint.target,options:t}),i=this.cache.get(n);if(i)return i;
1const s=this.context.interceptorRegistrationResolversSignal.peek(),o=ke(s,e.id),r=this.createExtensionInstance({context:this.context,extension:e,id:n,options:t,extensionInstanceCache:this.cache});return r.on("block",()=>{this.#f.set(r.id,e),this.#b()}),r.on("unblock",()=>{this.#f.delete(r.id),this.#b()}),r.on("destroy",()=>{this.#f.delete(r.id),this.#b();for(const t of this.cache.values())if(t.extension.id===e.id)return;Se(s,e.id,o)}),this.cache.set(n,r),r}findAll(e){const t=this.createFullIdentifier(e),n=this.cache.get(t);return n?[n]:Array.from(this.cache.values()).filter(e=>e.id.startsWith(t))}#b(){const e=new Map;for(const t of this.#f.values())e.has(t.id)||e.set(t.id,t);this.#y.value=[...e.values()]}createExtensionInstance(e){const{extension:t}=e;return Y(t.extensionPoint.target)in vt?function(e){return new Lt(e)}(e):function(e){return new Tt(e)}(e)}createFullIdentifier({id:e,target:t,options:n}){const i=`${e}:${t}`;if(null==n)return i;const s=Object.keys(n);if(0===s.length)return i;let o="";for(const r of s.sort((e,t)=>e.localeCompare(t)))o.length>0&&(o+="&"),o+=`${r}=${JSON.stringify(n[r])}`;return`${i}?${o}`}}class Pt{#v=new Map;#w=new Set;constructor(e){this.maxRequests=e.maxRequests,this.windowMs=e.windowMs,this.reason=e.reason}isThrottled(e){return this.#w.has(e)}record(e,t){if(this.#w.has(e))return{isThrottled:!0,isFirstThrottled:!1};const n=Date.now();let i=this.#v.get(e);i||(i=[],this.#v.set(e,i));const s=n-this.windowMs,o=i.filter(e=>e.timestamp>s);return this.#v.set(e,o),o.length>=this.maxRequests?(this.#w.add(e),{isThrottled:!0,isFirstThrottled:!0}):(o.push({timestamp:n,eventId:t}),{isThrottled:!1,isFirstThrottled:!1})}eventIds(e){return this.#I(e).map(e=>e.eventId).filter(e=>null!=e)}count(e){return this.#I(e).length}#I(e){const t=this.#v.get(e)??[];if(this.#w.has(e))return t;const n=Date.now()-this.windowMs;return t.filter(e=>e.timestamp>n)}}class Mt{#E=new Map;#C;constructor(e){this.#C=e}checkRate(e){const t=Date.now();let n=this.#E.get(e);n||(n={tokens:this.#C.maxTokens,lastCheck:t},this.#E.set(e,n));const i=(t-n.lastCheck)/1e3*this.#C.refillRate;if(n.tokens=Math.min(this.#C.maxTokens,n.tokens+i),n.lastCheck=t,n.tokens<1){const e=(1-n.tokens)/this.#C.refillRate;return{allowed:!1,reason:this.#C.reason,retryAfterSeconds:Math.ceil(e)}}return n.tokens-=1,{allowed:!0,tokensRemaining:Math.floor(n.tokens)}}}class Rt{#k=new Map;get(e){return this.#k.get(e)}record(e,t){this.#k.set(e,t)}}function Nt(e){return m(Dt,{children:m(_t,{...e})})}function _t({children:s,renderManager:o}){const{checkout:{extensibility:r},i18n:a,observability:c,shop:h}=H(),f=Re(),v=I();function E(e,n){const i=function(e,t){if(!e)return t;const n=new Set(Object.keys(e.translations));if(0===n.size)return t;if(n.has(t))return t;const i=dt(t);return n.has(i)?i:e.defaultLocale}(n,e),s=function(e,n){const i=t(e?.translations[e.defaultLocale]??{}),s=dt(n),o=t(e?.translations[s]??{}),r=t(e?.translations[n]??{});return function(e){const t={};for(const[n,i]of e)t[n]=i;return t}(new Map([...i,...o,...r]))}(n,e);return[i,s]}const C=r.ui.sandboxCache,k=T().workspace,R=x(()=>{const e=k?.extensions??[],t=L(v.value);return e.flatMap((e,n)=>{const i="development"in e&&e.development.hidden;return(e.extensionPoints.length?e.extensionPoints.map(e=>"string"==typeof e?{target:e,metafields:[]}:{...e,metafields:e.metafields??[]}):[{target:"Checkout::Dynamic::Render",metafields:e.metafields??[]}]).map((s,o)=>{let r,h=a.locale,l={},u={apiAccess:!1,networkAccess:!1,blockProgress:!1,collectBuyerConsent:{smsMarketing:!1,customerPrivacy:!1}},p=new Set,g="local";re(e)?(p=new Set(e.approvalScopes),e.capabilities.networkAccess&&p.add(V.NetworkAccessScope),r=e.assets.main.url,[h,l]=E(a.locale,e.localization),u={...u,...e.capabilities,collectBuyerConsent:{...u.collectBuyerConsent,...e.capabilities.collectBuyerConsent}},g=e.name):r=e.scriptUrl;const m=`${n}${o}`,x=e.uuid??`gid://shopify/LocalExtension/${m}`,y=`gid://shopify/LocalActivatedExtension/${m}`,b=k&&"app"in k?k.app?.title:"local",v=k.app?.apiKey??k?.apiKey,w=te(s.target);if("preloads"in s&&"object"==typeof s.preloads)try{const e=new URL(r).origin;
1Object.entries(s.preloads).forEach(([t,n])=>{const i=ne(t,n,e);i?s.preloads[t]=i:delete s.preloads?.[t]})}catch(I){c.error(I)}return{type:"local",id:y,extensionId:x,appId:k?.appId??"",appName:b,appApiKey:v??"",handle:e.handle,apiVersion:e.apiVersion??K,extensionPoint:s,scriptUrl:r,extensionLocale:h,metafields:e.metafields,translations:l,placementReference:w?f??t:void 0,approvalScopes:p,name:g,capabilities:u,behaviors:d({showInExpressCheckout:!0,alwaysReveal:!0,blockProgress:!0}),extensionSkeletons:null,configuration:d({}),hidden:i,version:e.version??"",metafieldRequests:[]}})}).filter(e=>!e.hidden)},[k,f,a,v.value,c]),F=r.ui.search().value,Q=Te([...F,...R]),J=r.ui.storefrontTokens,Z=function(t,i,s){const o=ie(),{checkout:r,consentManager:a,i18n:c,shop:d,source:h,observability:m,url:x,graphql:{coreGraphql:f}}=H(),v=I().value,{completed:E,journeyState:C}=v,{pageBeforeDetour:k}=se(N),T=function(){const t=b(),{i18n:n}=H();return e(()=>t.value?{id:"cart",label:n.translate("general.cart"),route:"",features:[]}:void 0)}(),L=function(){const{shop:t}=H(),n=G().buyerIdentity;return e(()=>({isoCode:n.value?.presentmentCurrency??t.currencyCode}))}(),A=oe(),{addDeactivatedExtension:P}=_(),M=D(),R=w(),q=j(),{closeOverlay:U}=O(),z=r.configuration.layout.isOnePage.value,F=function(){const e=S(),t=l(void 0),n=u(t=>{if(t){const[n,i]=t;e.detour(n,i)}},[e]);return p(()=>{const e=t.value;return g(()=>n(e))}),t}(),V=l(Me),K=Le(),Q=$(),{appMetafieldsSignal:J,currentDiscountCodeAttemptSignal:Y,bankIdNumberSignal:Z,cartLineChangeLoadingSignal:X}=W(),ee=n();if(y(()=>{try{V.value=Ae(a)}catch(e){m.error(e)}},[m,V,a]),!ee.current){const e=new Mt({maxTokens:10,refillRate:1,reason:"Rate limit exceeded. Extension is mounting/unmounting too rapidly."}),n=new Pt({maxRequests:20,windowMs:6e4,reason:"Too many checkout changes. See https://shopify.dev/docs/api/checkout-ui-extensions/latest#apply-changes-update-the-cart-and-checkout for details"}),l=new Rt;ee.current=(te={addDeactivatedExtension:P,captureEvent:R,defaultCacheDuration:q?1e4:6e4,coreGraphql:f,currencySignal:L,locale:c.locale,negotiated:A.current,deliveryMethodsAddressErrors:A.context.deliveryMethodsAddressErrors,proposal:o,proposed:o.parts,sandboxCache:t,mountRateLimiter:e,negotiationRateLimiter:n,refusedMerchandise:l,shop:d,timezone:c.timeZone,webPixels:M,sourceId:h.sourceId,sourceType:h.type,isCheckoutEditor:q,journeyCompletedSignal:E,checkout:r,journeyStateSignal:C,pageBeforeDetourSignal:k,storefrontTokens:i,ui:{overlay:{close:U}},publicCheckoutSessionId:B(h),isOnePageCheckout:z,stableDetourSignal:F,customerPrivacySignal:V,bankIdNumberSignal:Z,cartPageSignal:T,cartInstructionsSignal:K,interceptorRegistrationResolversSignal:s,observability:m,consentManager:a,currentDiscountCodeAttemptSignal:Y,cartLineChangeLoadingSignal:X,applyChange:gt({captureEvent:R,journeyCompletedSignal:E,wallets:r.wallets,proposal:o,observability:m,extensionPerformance:Ne,negotiationRateLimiter:n}),announcementEmitter:Q,appMetafieldsSignal:J,sandboxAppBridgeUrl:x.sandboxAppBridge()},new At(te))}var te;return ee.current}(C,J,Q),X=o??Z,ee=h?.storefrontUrl??"",ce=h?.myshopifyDomain??"",de=u((e,t)=>{const n=R.filter(t=>t.extensionId===e);if(0!==n.length){if(void 0!==t){const[e,i]=E(a.locale,t);n.forEach(t=>{t.extensionLocale=e,t.translations=i})}n.forEach(e=>{C?.getOrCreate({extension:e,storefrontUrl:ee,myshopifyDomain:ce}).restart()})}},[R,C,a,ee,ce]);return i(()=>{if(k&&k.extensions.length)return A(k)?ae(k,de):function(e,t){let n=!0;const i=new WebSocket(e),s=({data:i})=>{try{const{type:e}=JSON.parse(i);if("ok"===e||"warnings"===e){if(n)return void(n=!1);t()}}catch(s){console.log(`error parsing update message from ${e} : ${s}`)}};return i.addEventListener("message",s),()=>{i.removeEventListener("message",s),i.close()}}(k.extensions[0].socketUrl,()=>de(R[0].extensionId))},[R,k,de]),function(e,t,n){const{currentPage:i}=I().value,s=oe(),o=_(),r=q(),{observability:a,source:c,checkout:{extensibility:d}}=H();U(async()=>{const h=d.ui.search().peek(),l=s.current.peek(),u=n.peek(),p=z(i,l,o.deactivatedExtensionIds,r,c.type),g=[...h,...t].filter(p);Pe(u,g);const m=await function(e,t,n,i){const s=function(e,t){const n=[];for(const i of e)switch(Y(i.extensionPoint.target)){case"Checkout::ThankYou::CartLineDetails::RenderAfter":case"Checkout::CartLineDetails::RenderLineComponents":case"Checkout::CartLineDetails::RenderAfter":{const e=t.merchandiseLines?.lines?.filter(e=>e.variantId)?.flatMap(e=>e.lineAllocations)?.reduce((e,t)=>
1t.stableId?[...e,{extension:i,options:{stableId:t.stableId}}]:e,[])??[];n.push(...e);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(i.apiVersion)&&n.push({extension:i});break;default:n.push({extension:i})}return n}(e,t);return Promise.all(s.map(async({extension:e,options:t})=>{const s=n.get(e,t);return await s.initialize({currentStep:i}),e}))}(g,l,e,i?.id??"");a.leaveErrorBreadcrumb("[Extensions] Finished blocking extensions check",{awaitableCount:m.length});const x=m.map(e=>u.get(e.id)?.promise||Promise.resolve());await Promise.race([new Promise((e,t)=>setTimeout(e,1e3)),Promise.all(x)])})}(X,R,Q),function(e){const t=w(),{currentPage:s,currentDetour:o}=I().value,r=n(s),a=n(o);i(()=>{r.current=s},[s]),i(()=>{a.current=o},[o]),i(()=>{if(e)return e.on("apiRead",e=>{const n=a.current?.type??r.current?.id??"";for(const i of e.apiPropertyNames)t("extensionLifecycle",{apiPropertyName:i,extension:ht(e.extension),initialPageLoad:e.initialLoad,page:n,phase:"apiRead",section:"extension",timestamp:e.timestamp})})},[t,e])}(C),function({renderManager:e}){const{client:t}=H(),s=w(),{currentPage:o,currentDetour:r}=I().value,a=t.unstable_legacyNavigationPerformance,c=n(o),d=n(r),h=n(e);i(()=>{c.current=o},[o]),i(()=>{d.current=r},[r]),i(()=>{h.current=e},[e]),i(()=>{if(!a)return;const e=a.on("navigation",()=>{Ne.setEndOfInitialLoad()});return()=>{e()}},[a]),i(()=>Ne.subscribe(e=>{e.forEach(e=>{const t=d.current?.type??c.current?.id??"";switch(e.type){case"iframe-loader-metric":case"sandbox-fetch-metric":{const{mark:n,duration:i,timestamp:o,initialLoad:r}=e;s("extensionLifecycle",{duration:i,extension:null,phase:n,section:"extension",page:t,timestamp:o,initialPageLoad:Boolean(r),transferredBundleSize:"sandbox-fetch-metric"===e.type?e.transferredBundleSize:void 0,bundleSize:"sandbox-fetch-metric"===e.type?e.bundleSize:void 0});break}case"extension-fetch-call-metric":{const{duration:t,timestamp:n,httpStatus:i,httpMethod:o,errorType:r,destination:a,extension:c,origin:d,requestUrl:h}=e;s("extensionFetchCall",{duration:t,destination:a,httpStatus:i,httpMethod:o,errorType:r,timestamp:n,extension:{extensionId:c.extensionId,extensionPoint:{target:c.extensionPoint.target,metafields:c.extensionPoint.metafields},placementReference:c.placementReference,type:c.type,appId:c.appId,appApiKey:c.appApiKey??null,apiVersion:c.apiVersion,version:c.version,registrationId:"registrationId"in c?c.registrationId:void 0,publicIdentifier:"publicIdentifier"in c?c.publicIdentifier:void 0,targetPublicIdentifier:"targetPublicIdentifier"in c?c.targetPublicIdentifier:void 0},section:"extension",origin:d,requestUrl:h});break}case"extension-metric":{const{mark:n,extension:i,duration:o,timestamp:r,instanceId:a,transferredBundleSize:c,bundleSize:d,initialLoad:h,ttsCompletionReason:l,ttsRenderObserved:u,ttsRequestCount:p}=e;s("extensionLifecycle",{duration:o,instanceId:a,extension:ht(i),phase:n,section:"extension",page:t,timestamp:r,initialPageLoad:Boolean(h),transferredBundleSize:c,bundleSize:d,ttsCompletionReason:l,ttsRenderObserved:u,ttsRequestCount:p});break}}})}),[s])}({renderManager:X}),m(M.Provider,{value:X,children:m(P.Provider,{value:R,children:[m(lt,{}),s]})})}function Dt({children:e}){const[t,n]=f(new Set),{observability:s,checkout:{extensibility:o}}=H(),r=o.ui.search().value;i(()=>{s.addErrorMetadata("extensions",{active:r.map(({id:e})=>e)})},[s,r]);const a=u(e=>{n(t=>{const n=new Set([...t,e]);return s.addErrorMetadata("extensions",{deactivated:Array.from(n)}),n})},[s]),c=x(()=>({deactivatedExtensionIds:t,addDeactivatedExtension:a}),[t,a]);return m(R.Provider,{value:c,children:e})}export{Nt 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.