PageSourceSearch

https://homdum.com/cdn/shopifycloud/checkout-web/assets/c1/CheckoutEditorBridge.D1fiZwl6.js

js homdum.com collected 2026-09-26 13:35:56 UTC 52,323 bytes, 1 lines download raw bytes

1import{R as we,a4 as ze,A as Ge,h as S,o as Re,j as Ue,u as _,S as ce,k as J,q as O,y as P,m as j,T as z,a8 as We,ad as He}from"./esnext-vendor.B9Da21W6.js";import{a as Ve}from"./adapter-host.DrRmHuXU.js";import{aW as Ke,bB as $e,S as D,af as qe,bo as je,gG as Ye,Q as ke,gH as Je,an as Xe,gI as Qe}from"./addresses-is-address-empty.Bn2lNY_L.js";import{L as Ze,g as et,h as tt,f as nt}from"./extensions-remote-dom.MLww-Mka.js";import{n as X,f as it,a2 as ae,a3 as A,g6 as Ie,dG as ot,g7 as Me,g8 as rt,eY as st}from"./hydrate.DZ4YTm7p.js";import{receiptForUI as ct}from"./receipt-mappers.BRsl752N.js";import{u as at,d as lt}from"./app.DbSrjjlA.js";import"./utilities-extension-execution-errors.Bov3aYbn.js";import"./graphql-PaymentSessionMutation.CAXCwUvV.js";import"./hooks-useShopPayExternalAppContext.DWwMuRnz.js";import"./hooks-useReplaceShopPayInHistory.DPpLejwu.js";import"./shared-receipt-eager-mappers.BEm77m4Q.js";import"./shared-receipt-merchandise-lines.DEXSlNem.js";function Ce(e){we(e);let t=e.initial,n=!0,i=!1;const o=new Set,r=Promise.resolve(e.subscribe(s)).then(c=>(i||s(c[1]),c));return{get current(){return t},subscribe(c){return o.add(c),()=>{o.delete(c)}},async destroy(){n=!1,o.clear();const[c]=await r;c(),ze(e)}};function s(c){if(i=!0,!(!n||t===c)){t=c;for(const a of o)a(t)}}}var T=class{static intersect(e,t){const n=Math.max(e.left,t.left),i=Math.min(e.right,t.right),o=Math.max(e.top,t.top),r=Math.min(e.bottom,t.bottom),s=Math.max(0,i-n),c=Math.max(0,r-o);return new DOMRect(n,o,s,c)}static clip(e,t){const n={...e.toJSON(),top:e.top+t.top,left:e.left+t.left,bottom:e.bottom-t.bottom,right:e.right-t.right};return n.width=n.right-n.left,n.height=n.bottom-n.top,new DOMRect(n.left,n.top,n.width,n.height)}static clipOffsets(e,t){return{top:t.top-e.top,left:t.left-e.left,bottom:e.bottom-t.bottom,right:e.right-t.right}}static equals(e,t){return e==null||t==null?e===t:e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}static sizeEqual(e,t){return Math.round(e.width)===Math.round(t.width)&&Math.round(e.height)===Math.round(t.height)}},H=-1,de=1-H*2;function dt(e,t){const n=Math.max(e.width,de),i=Math.max(e.height,de),o=e.top-t.top-H,r=e.left-t.left-H,s=t.right-e.left-n-H,c=t.bottom-e.top-i-H;return`${-Math.round(o)}px ${-Math.round(s)}px ${-Math.round(c)}px ${-Math.round(r)}px`}var Oe=[...Array.from({length:1e3},(e,t)=>t/1e3),1],ut=class{constructor(e,t,n){this.#n=t,this.#t=n,this.#i=n.clientRect,this.#o(e)}#n;#e=void 0;#t;#i;#r=void 0;get visibleRect(){const e=this.#t.clip;return e?T.clip(this.#i,e):this.#i}get isIntersecting(){const{width:e,height:t}=this.visibleRect;return e>0&&t>0}#o(e){const{root:t,rootBounds:n}=this.#t,{visibleRect:i}=this;this.#e?.disconnect(),this.#e=new IntersectionObserver(this.#s,{root:t,rootMargin:dt(i,n),threshold:Oe}),this.#e.observe(e)}#s=e=>{if(!this.#e)return;const t=e[e.length-1];if(t){const{intersectionRatio:n,boundingClientRect:i}=t,o=this.#i;this.#i=i;const r=this.#r,s=!T.equals(i,o);if(n!==this.#r||s){const c=this.#t.rootBounds,a=T.intersect(i,c),d=a.width>0&&a.height>0;if(!d)return;this.#r=n,(r!=null||s)&&(this.#n(new ht(t.target,i,t.intersectionRect,d,c),this),this.#o(t.target))}}};disconnect(){this.#e?.disconnect()}},ht=class{constructor(e,t,n,i,o){this.target=e,this.boundingClientRect=t,this.intersectionRect=n,this.isIntersecting=i,this.rootBounds=o}},ft=class{constructor(e,t){const n=pt(e);if(gt(n)){const i=n.ownerDocument??document;this.rootBounds=n.getBoundingClientRect(),this.#n=new ResizeObserver(o=>{for(const r of o){const[{inlineSize:s,blockSize:c}]=r.borderBoxSize;if(T.sizeEqual(this.rootBounds,{width:s,height:c}))continue;const a=r.target.getBoundingClientRect();this.rootBounds=a,t(a,this)}}),this.#n.observe(n),i.addEventListener("scroll",o=>{o.target&&o.target!==n&&Te(o.target)&&o.target.contains(n)&&(this.rootBounds=n.getBoundingClientRect(),t(this.rootBounds,this))},{capture:!0,passive:!0,signal:this.#e.signal})}else{const i=n.visualViewport??n;this.rootBounds=ue(n);const o=()=>{const r=ue(n);T.equals(this.rootBounds,r)||(this.rootBounds=r,t(r,this))};i.addEventListener("resize",o,{signal:this.#e.signal})}}#n;#e=new AbortController;rootBounds;disconnect(){this.#n?.disconnect(),this.#e.abort()}};
1function ue(e){const t=e.visualViewport?.width??e.innerWidth,n=e.visualViewport?.height??e.innerHeight;return new DOMRect(0,0,t,n)}function Te(e){return"nodeType"in e}function gt(e){return Te(e)&&e.nodeType===Node.ELEMENT_NODE}function mt(e){return e.nodeType===Node.DOCUMENT_NODE}function pt(e){return!e||mt(e)?e?.defaultView??window:e}var yt=class{constructor(e,t){this.#t=t,this.#n=n=>{const i=[];for(const o of n){const r=this.intersections.get(o.target);this.intersections.set(o.target,o),(r?.isIntersecting!==o.isIntersecting||!T.equals(r?.intersectionRect,o.intersectionRect))&&i.push(o)}i.length>0&&e(i,this)}}#n;#e=new Map;#t;intersections=new WeakMap;observe(e){const t=e.ownerDocument;if(!t)return;let n=this.#e.get(t);n||(n=new IntersectionObserver(this.#n,{...this.#t,threshold:Oe}),this.#e.set(t,n)),n.observe(e)}unobserve(e){const t=e.ownerDocument;if(!t)return;const n=this.#e.get(t);n&&(n.unobserve(e),this.intersections.delete(e))}disconnect(){for(const e of this.#e.values())e.disconnect();this.#e.clear()}},bt=class{constructor(e,t){this.#n=e,this.#e=t,this.#o=new ft(t?.root,this.#l),this.#s=new yt(this.#d,t),this.#i=new ResizeObserver(this.#h)}#n;#e;#t=new Map;#i;#r=new WeakMap;#o;#s;observe(e){this.#s.observe(e)}unobserve(e){e?(this.#t.get(e)?.disconnect(),this.#s.unobserve(e),this.#r.delete(e)):this.disconnect()}disconnect(){for(const e of this.#t.values())e.disconnect();this.#t.clear(),this.#i.disconnect(),this.#o.disconnect(),this.#s.disconnect()}#c(e){const t=[];for(const n of e){const{target:i}=n,o=this.#r.get(i);Et(n,o)||(this.#r.set(i,n),t.push(n))}t.length>0&&this.#n(t)}#l=e=>{const t=[];for(const[n]of this.#t){const i=n.getBoundingClientRect(),o=this.#a(n,i);t.push(new K(n,i,o.visibleRect,o.isIntersecting,e))}this.#c(t)};#a(e,t){const n=this.#s;this.#t.get(e)?.disconnect();const i=new ut(e,this.#u,{clientRect:t,root:this.#e?.root,rootBounds:this.#o.rootBounds,get clip(){const o=n.intersections.get(e);if(!o)return;const{intersectionRect:r,boundingClientRect:s}=o;return T.clipOffsets(s,r)}});return this.#t.set(e,i),i}#d=e=>{const t=[];for(const n of e){const{target:i,isIntersecting:o,boundingClientRect:r}=n;o?(this.#a(i,r),this.#i.observe(i)):(this.#t.get(i)?.disconnect(),this.#t.delete(i),this.#i.unobserve(i));const s=this.#t.get(i);t.push(new K(i,r,s?.visibleRect??n.intersectionRect,o,this.#o.rootBounds))}this.#c(t)};#u=(e,t)=>{this.#c([new K(e.target,e.boundingClientRect,t.visibleRect,e.isIntersecting,this.#o.rootBounds)])};#h=e=>{const t=[];for(const n of e){const{target:i,borderBoxSize:o}=n,r=this.#r.get(i);if(r){const[{inlineSize:a,blockSize:d}]=o;if(T.sizeEqual(r.boundingClientRect,{width:a,height:d}))continue}const s=i.getBoundingClientRect(),c=this.#a(i,s);t.push(new K(i,s,c.visibleRect,this.#s.intersections.get(i)?.isIntersecting??!1,this.#o.rootBounds))}this.#c(t)}},K=class{constructor(e,t,n,i,o){this.target=e,this.boundingClientRect=t,this.intersectionRect=n,this.isIntersecting=i,this.rootBounds=o}};function Et(e,t){return t==null?!1:e.target===t.target&&e.isIntersecting===t.isIntersecting&&T.equals(e.boundingClientRect,t.boundingClientRect)&&T.equals(e.intersectionRect,t.intersectionRect)}const V="data-inspector-id",vt="data-inspector-box",St=new Set(["header","orderSummary","footer"]);function Z(e){for(const t of e.composedPath())if(t instanceof HTMLElement){if(t.hasAttribute("data-inspector-managed"))return{element:null,managed:!0};if(t.hasAttribute(V))return{element:t,managed:!1}}return{element:null,managed:!1}}function Y(e){return e.width>0&&e.height>0}function ee(e){if(!e)return null;for(const t of document.querySelectorAll(`[${V}="${e}"]`))if(Y(t.getBoundingClientRect()))return t;return null}function wt(e){return{top:e.top,left:e.left,width:e.width,height:e.height}}function Rt(e,t){const n=wt(t);if(e.getAttribute(vt)!=="content")return n;const i=getComputedStyle(e),o=parseFloat(i.paddingTop)||0,r=parseFloat(i.paddingRight)||0,s=parseFloat(i.paddingBottom)||0,c=parseFloat(i.paddingLeft)||0;return{top:n.top+o,left:n.left+c,width:Math.max(0,n.width-c-r),height:Math.max(0,n.height-o-s)}}function kt(e){e.scrollIntoView?.({behavior:"smooth",block:"center",inline:"nearest"})}function It({inspectorTarget:e,selectedBlock:t,selectedExtension:n}){const i=Ge(null);return S(()=>{let o=null,r=0;function s(u,h){e.rect.value=Rt(u,h),e.viewport.value={width:innerWidth,height:innerHeight}}function c(){if(!o?.isConnected){y();return}const u=o.getBoundingClientRect();if(!Y(u)){y();return}s(o,u)}function a(){cancelAnimationFrame(r),r=requestAnimationFrame(c)}const d=new bt(u=>{for(const h of u)if(h.target===o){if(!h.target.isConnected||!Y(h.boundingClientRect)){y();return}s(h.target,h.boundingClientRect)}}),g=new MutationObserver(()=>{(!o?.isConnected||!Y(o.getBoundingClientRect()))&&y()});g.observe(document.body,{childList:!0,subtree:!0});function l(u){o&&o!==u&&d.unobserve(o),o=u,d.observe(u),s(u,u.getBoundingClientRect())}function p(){o&&d.unobserve(o),o=null,e.rect.value=null}function y({scroll:u=!1,preserveObserved:h=!1}={}){const k=ee(n.value)??ee(t.value);k?(u&&kt(k),h||l(k)):h||p()}function f(u){const{element:h,managed:k}=Z(u);k||!h||h===i.current||(i.current=h,e.hovered.value=h.getAttribute(V)??"",l(h))}function b(u){const{element:h}=Z(u);if(!h||h!==i.current)return;const k=u.relatedTarget;k instanceof Node&&h.contains(k)||k instanceof HTMLElement&&k.closest(`[${V}]`)||(i.current=null,e.hovered.value=void 0,y())}let E=!1;function v(u){const{element:h,managed:k}=Z(u);if(k)return;if(!h){i.current=null,e.hovered.value=void 0,E=!0;try{t.value=null,n.value=void 0}finally{E=!1}y();return}const R=h.getAttribute(V)??"";E=!0;try{St.has(R)?(t.value=R,n.value=void 0):(n.value=R,t.value=void 0)}finally{E=!1}l(h)}let m=!1;const G=u=>{if(!m)return;if(!u){i.current=null,y();return}const h=ee(u);i.current=h,h?l(h):p()};let N=!1;const U=()=>{N&&y({scroll:!E,preserveObserved:!!i.current})},Q=e.hovered.subscribe(G),w=t.subscribe(U),M=n.subscribe(U);return y(),m=!0,N=!0,G(e.hovered.value),document.addEventListener("mouseover",f,!0),document.addEventListener("mouseout",b,!0),document.addEventListener("click",v,!0),document.addEventListener("scroll",a,!0),window.addEventListener("resize",a),window.visualVie
1wport?.addEventListener("scroll",a),window.visualViewport?.addEventListener("resize",a),()=>{cancelAnimationFrame(r),document.removeEventListener("mouseover",f,!0),document.removeEventListener("mouseout",b,!0),document.removeEventListener("click",v,!0),document.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a),window.visualViewport?.removeEventListener("scroll",a),window.visualViewport?.removeEventListener("resize",a),Q(),w(),M(),d.disconnect(),g.disconnect()}},[e,t,n]),null}const Mt={id:"605cb290c423e2035b0d3038d56ed6c5a828a81829a22e6422a54a1974fc7b81",type:"query",name:"SimulatedReceipt",source:""},Ct=Ke(({checkout:e,graphql:{coreGraphql:t}},{journey:n})=>{const i=Re(()=>n.value.currentDetour?.type==="thankYou"),o=t.query(Mt,{skip:()=>!i.value});return Ue(()=>{const r=o.data.value?.simulatedReceipt;!o.loading.value&&r&&i.value&&e.unstable_overwriteLatestReceipt(ct(r))}),{error:o.error,loading:o.loading}});function Ot(){const e=X();return $e(Ct,{journey:e}),null}function Tt(){return _(ce,{children:_(Ot,{})})}function Bt(){const{checkout:e,client:t}=D(),n=t.unstable_legacyNavigationPerformance?.initialLoading.value??!1,i=e.latestReceipt.value,{currentDetour:o}=X().value,[r,s]=J(!0),[c,a]=J(!!i);return S(()=>{n||s(!1)},[n]),S(()=>{i&&a(!0)},[i]),S(()=>{o?.type==="thankYou"&&s(!c)},[o?.type,c]),r}function _t(){const e=qe(),[t,n]=J({}),{checkout:i,router:o}=D(),{currentDetour:r,plan:{greenPath:s,detours:c}}=X().value,{detour:a}=it(),d=O(()=>{const p=e.current.value;n(p)},[e]),g=O(()=>{e.current.value=t,i.unstable_overwriteLatestReceipt(void 0)},[i,t,e]);return S(()=>{d()},[d]),{navigate:O(p=>{const y=!!r?.type,f=r?.type!==p,b=c.find(({type:v})=>v===p)?.type;if(y&&f?g():b&&d(),b){a(b);return}const E=s?.find(({id:v})=>v===p)?.route??"/information";o.navigate(E)},[r?.type,a,c,s,o,d,g])}}const Pt="editor_bridge",xt="mixed_signals",x="mixed_signals_v1",Dt="shopify:checkout-editor:mixed-signals:ready",At="shopify:checkout-editor:mixed-signals:port",Nt="shopify:checkout-editor:mixed-signals:initialized",Lt="shopify:checkout-editor:mixed-signals:error",Ft=["shell.shopify.com","*.preview.shell.shopify.com","admin.shopify.com","*.preview.admin.shopify.com",...Array.from({length:10},(e,t)=>`shell-staging-${t+1}.shopify.com`),...Array.from({length:10},(e,t)=>`*.preview.shell-staging-${t+1}.shopify.com`)],zt="shell.shop.dev",Gt=[...Ft,zt];function Ut(e,t){if(!t.startsWith("*."))return e===t;const n=t.slice(1);return e.length>n.length&&e.endsWith(n)}function Wt(e){try{const t=new URL(e);return t.protocol==="https:"&&t.origin===e&&t.port===""&&Gt.some(n=>Ut(t.hostname,n))}catch{return!1}}function Ht(e){if(e===xt||e===x)return e}function Be(e){return Ht(e.get(Pt))}function Vt(e){return e===x}function Kt(){return{type:Dt,protocol:x}}function $t(){return{type:Nt,protocol:x}}function qt(){return{type:Lt,protocol:x}}function jt(e,t){return typeof e!="object"||e===null||!("type"in e)||e.type!==At?!1:Vt(t)?"protocol"in e&&e.protocol===x:!("protocol"in e)||e.protocol===x}const te="@R",Yt="@S",he="@W",Jt="@U",_e="@M";function fe(e){if(e==="")return;const t=Number(e);return Number.isInteger(t)?t:void 0}function Xt(e){if(e.length<2)return null;const t=e[0];if(t==="R"||t==="E"){const c=e.indexOf(":");if(c===-1)return null;const a=fe(e.slice(1,c));return a===void 0?null:{type:t==="R"?"result":"error",id:a,payload:e.slice(c+1)}}if(t!=="M"&&t!=="N")return null;const n=e.indexOf(":",1);if(n===-1)return null;const i=e.indexOf(":",n+1);if(i===-1)return null;const o=e.slice(1,n),r=e.slice(n+1,i),s=e.slice(i+1);if(!r)return null;if(t==="M"){const c=fe(o);return c===void 0?null:{type:"call",id:c,method:r,payload:s}}return o!==""?null:{type:"notification",method:r,payload:s}}function $(e,t){return JSON.parse(e?`[${e}]`:"[]",t)}function Qt(e,t){return JSON.parse(e,t)}function Pe(e=[]){return JSON.stringify(e).slice(1,-1)}function Zt(e,t,n=[]){return`M${e}:${t}:${Pe(n)}`}function en(e,t=[]){return`N:${e}:${Pe(t)}`}function tn(e,t){return`R${e}:${JSON.stringify(t)}`}function ne(e,t){return`E${e}:${JSON.stringify(t)}`}const se=Symbol("mixed-signals.refreshModel"),xe=Symbol("mixed-signals.getModelSignals"),nn=new Set(["then","catch","finally","toJSON","toString","valueOf","inspect","constructor","prototype","__proto__"]);function ge(e){if(e["@wireId"]!==void 0)return String(e["@wireId"]);const t=e["@M"];if(typeof t=="string"){const n=t.lastIndexOf("#");return n===-1?t:t.slice(n+1)}return""}function me(e){return e!==""&&!nn.has(e)}function q(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function pe(e,t){let n=e.methods.get(t);return n||(n=(...i)=>e.ctx.rpc.call(`${e.wireId}#${t}`,i),Object.defineProperty(n,"name",{value:t,configurable:!0}),e.methods.set(t,n)),n}function on(e,t,n={}){const i=ge(t),o={},r={ctx:e,wireId:i,fallbackId:P(i),signalSources:new Map,methods:new Map};q(o,"id",r.fallbackId);const s=(a,d)=>{const g=r.signalSources.get(a);if(g)g.value=e.rpc.syncSignalIdentity(g.peek(),d);else{const l=P(d);r.signalSources.set(a,l),q(o,a,Re(()=>l.value.value))}},c=a=>{const d=ge(a);r.wireId!==d&&(r.wireId=d,r.signalSources.has("id")||(r.fallbackId.value=d));const g=n.signalProps?n.signalProps.map(l=>[l,a[l]]):Object.entries(a);for(const[l,p]of g)p instanceof j?s(l,p):p?.[se]&&q(o,l,p)};c(t);for(const a of n.methods??[])me(a)&&!Object.hasOwn(o,a)&&q(o,a,pe(r,a));return new Proxy(o,{get(a,d,g){if(d===se)return c;if(d===xe)return()=>Array.from(r.signalSources.values(),l=>l.peek());if(d===Symbol.toStringTag)return n.typeName??"ReflectedModel";if(typeof d=="symbol"||Reflect.has(a,d))return Reflect.get(a,d,g);if(me(d))return pe(r,d)}})}const rn=10;function ie(e){const t=new Set;for(const n of e)n!==void 0&&t.add(n);return Array.from(t)}function ye(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}var sn=class{constructor(e){this.value=e}deref(){return this.value}};const De=typeof WeakRef<"u";function oe(e){return De?new WeakRef(e):new sn(e)}var cn=class I{signals=new Map;signalIds=new WeakMap;signalFinalizerTokens=new WeakMap;signalFinalizer;activeSignals=new Set;models=new Map;modelFinalizerTokens=new WeakMap;modelFinalizer;modelSignals=new Map;refreshedRootModelMarkers=new Set;staleModelMarkers=new Set;refreshingModelMarkers=new Set;modelRefreshGeneration=0;collectingRootModels=!1;modelRegistry=new Map;rpc;ctx;static queuedWatchFlushes=new Set;static watchFlushTimer=null;watchedSignals=new Set;watchBatch=new Set;unwatchBatch=new Set;constructor(t,n){this.rpc=t,this.ctx=n&&n.rpc===t?n:{rpc:t},De&&typeof FinalizationRegistry<"u"&&(this.signalFinalizer=new FinalizationRegistry(i=>{this.signals.get(i)?.deref()||this.signals.delete(i)}),this.modelFinalizer=new FinalizationRegistry(i=>{this.models.get(i)?.deref()||this.forgetModel(i)}))}reset(){this.clearPendingWatchTraffic(),this.signals.clear(),this.signalIds=new WeakMap,this.activeSignals.clear(),this.models.clear(),this.modelSignals.clear(),this.refreshedRootModelMarkers.clear(),this.staleModelMarkers.clear(),this.refreshingModelMarkers.clear(),this.modelRefreshGeneration++,this.collectingRootModels=!1,this.watchedSignals.clear()}prepareReconnect(){this.clearPendingWatchTraffic(),this.watchedSignals.clear(),this.refreshingModelMarkers.clear(),this.modelRefreshGeneration++}prepareProcessChange(){this.prepareReconnect(),this.signals.clear(),this.signalIds=new WeakMap,this.sweepCollectedEntries(),this.staleModelMarkers=new Set(this.models.keys())}replayActiveSignals(t){return this.clearPendingWatchTraffic(),this.sendActiveSignalWatches(t)}sendActiveSignalWatches(t){const n=t?new Set(t):void 0,i=Array.from(this.activeSignals).filter(r=>{const s=this.signalIds.get(r);return s!==void 0&&!n?.has(s)}),o=ie(i.map(r=>this.signalIds.get(r)));if(o.length>0){for(const r of i)this.watchedSignals.add(r);this.rpc.notify(he,o)}return o}registerModel(t,n){n&&this.modelRegistry.set(t,n)}beginRootSnapshot(){this.refreshedRootModelMarkers=new Set,this.collectingRootModels=!0}endRootSnapshot(){this.collectingRootModels=!1}getActiveHeldModelMarkers(){return this.sweepCollectedEntries(),Array.from(this.models.keys()).filter(t=>!this.refreshedRootModelMarkers.has(t)&&!this.refreshingModelMarkers.has(t)&&this.isModelMarkerActive(t))}beginModelRefresh(t){const n=this.modelRefreshGeneration;for(const i of t)this.refreshingModelMarkers.add(i);return n}
1finishModelRefresh(t,n){if(n!==this.modelRefreshGeneration)return!1;for(const i of t)this.refreshingModelMarkers.delete(i);return!0}clearPendingWatchTraffic(){I.queuedWatchFlushes.delete(this),I.queuedWatchFlushes.size===0&&I.watchFlushTimer&&(clearTimeout(I.watchFlushTimer),I.watchFlushTimer=null),this.watchBatch.clear(),this.unwatchBatch.clear()}getSignalById(t){const n=this.signals.get(t);if(!n)return;const i=n.deref();if(!i){this.signals.delete(t);return}return i}rememberSignal(t,n){const i=this.signalIds.get(n);i!==void 0&&i!==t&&this.getSignalById(i)===n&&this.signals.delete(i),this.signals.set(t,oe(n)),this.signalIds.set(n,t),this.registerSignalFinalizer(t,n)}registerSignalFinalizer(t,n){if(!this.signalFinalizer)return;const i=this.signalFinalizerTokens.get(n);i&&this.signalFinalizer.unregister(i);const o={};this.signalFinalizerTokens.set(n,o),this.signalFinalizer.register(n,t,o)}getModel(t){const n=this.models.get(t);if(!n)return;const i=n.deref();if(!i){this.forgetModel(t);return}return i}rememberModel(t,n){this.models.set(t,oe(n)),this.registerModelFinalizer(t,n)}registerModelFinalizer(t,n){if(!this.modelFinalizer||n===null||typeof n!="object"&&typeof n!="function")return;const i=this.modelFinalizerTokens.get(n);i&&this.modelFinalizer.unregister(i);const o={};this.modelFinalizerTokens.set(n,o),this.modelFinalizer.register(n,t,o)}forgetModel(t){this.models.delete(t),this.modelSignals.delete(t),this.refreshedRootModelMarkers.delete(t),this.staleModelMarkers.delete(t),this.refreshingModelMarkers.delete(t)}liveModelSignals(t){const n=this.modelSignals.get(t);if(!n)return[];const i=[];for(const o of n){const r=o.deref();r?i.push(r):n.delete(o)}return i}sweepCollectedEntries(){for(const t of this.signals.keys())this.getSignalById(t);for(const t of this.models.keys())this.getModel(t);for(const t of this.modelSignals.keys())this.models.has(t)?this.liveModelSignals(t):this.modelSignals.delete(t)}static queueGlobalWatchFlush(){I.watchFlushTimer||(I.watchFlushTimer=setTimeout(()=>{I.watchFlushTimer=null,I.flushQueuedWatches()},rn))}static flushQueuedWatches(){const t=Array.from(I.queuedWatchFlushes);I.queuedWatchFlushes.clear();for(const n of t)n.flushWatches()}queueWatchFlush(){I.queuedWatchFlushes.add(this),I.queueGlobalWatchFlush()}scheduleWatch(t){this.unwatchBatch.delete(t),this.watchedSignals.has(t)||(this.watchBatch.add(t),this.queueWatchFlush())}scheduleUnwatch(t){this.watchBatch.delete(t),this.watchedSignals.has(t)&&(this.unwatchBatch.add(t),this.queueWatchFlush())}flushWatches(){const t=Array.from(this.watchBatch).filter(r=>this.activeSignals.has(r)&&!this.watchedSignals.has(r)&&this.signalIds.get(r)!==void 0),n=Array.from(this.unwatchBatch).filter(r=>!this.activeSignals.has(r)&&this.watchedSignals.has(r)&&this.signalIds.get(r)!==void 0);this.watchBatch.clear(),this.unwatchBatch.clear();const i=ie(t.map(r=>this.signalIds.get(r)));if(i.length>0){for(const r of t)this.watchedSignals.add(r);this.rpc.notify(he,i)}const o=ie(n.map(r=>this.signalIds.get(r)));if(o.length>0){for(const r of n)this.watchedSignals.delete(r);this.rpc.notify(Jt,o)}}getOrCreateSignal(t,n){const i=this.getSignalById(t);if(i)return i;let o;return o=P(n,{watched:()=>{this.activeSignals.add(o),this.refreshStaleModelsForSignal(o),this.scheduleWatch(o)},unwatched:()=>{this.activeSignals.delete(o),this.scheduleUnwatch(o)}}),this.rememberSignal(t,o),o}syncSignalSnapshot(t,n){const i=this.getOrCreateSignal(t,n);return i.value=n,i}reconcileRoot(t,n){if(ye(t)&&ye(n)){for(const i of Object.keys(t))i in n||delete t[i];for(const[i,o]of Object.entries(n))t[i]=this.reconcileIdentifiedValue(t[i],o);return t}return this.reconcileIdentifiedValue(t,n)}syncSignalIdentity(t,n){return this.rebindSignal(t,n,!0)}reconcileIdentifiedValue(t,n){return t===n?t:t instanceof j&&n instanceof j?this.rebindSignal(t,n):n}isModelMarkerActive(t){for(const n of this.liveModelSignals(t))if(this.activeSignals.has(n))return!0;return!1}collectModelSignals(t){const n=new Set;for(const i of Object.values(t))i instanceof j&&n.add(i);return n}rememberModelSignals(t,n,i,o=!0){const r=n[xe]?.();r?this.modelSignals.set(t,this.createSignalRefs(r)):o&&this.modelSignals.set(t,this.createSignalRefs(this.collectModelSignals(i)))}createSignalRefs(t){return new Set(Array.from(t,n=>oe(n)))}modelHasLiveSignal(t,n){const i=this.modelSignals.get(t);if(!i)return!1;let o=!1;for(const r of i){const s=r.deref();s?s===n&&(o=!0):i.delete(r)}return o}refreshStaleModelsForSignal(t){const n=[];for(const o of this.staleModelMarkers)!this.refreshingModelMarkers.has(o)&&this.getModel(o)&&this.modelHasLiveSignal(o,t)&&n.push(o);if(n.length===0)return;const i=this.beginModelRefresh(n);this.rpc.call(_e,n).catch(()=>{}).finally(()=>{this.finishModelRefresh(n,i)&&this.sendActiveSignalWatches()})}markModelFresh(t){this.staleModelMarkers.delete(t)}rebindSignal(t,n,i=!1){const o=this.signalIds.get(n);if(o!==void 0){const r=this.getSignalById(o);if(i&&r&&r!==t)return this.transferSignalState(t,r),this.transferSignalState(n,r),t.value=r.peek(),r;this.rememberSignal(o,t)}return this.transferSignalState(n,t),t.value=n.peek(),t}transferSignalState(t,n){t!==n&&(this.activeSignals.has(t)&&(this.activeSignals.delete(t),this.activeSignals.add(n)),this.watchedSignals.has(t)&&(this.watchedSignals.delete(t),this.watchedSignals.add(n)),this.watchBatch.delete(t)&&this.watchBatch.add(n),this.unwatchBatch.delete(t)&&this.unwatchBatch.add(n))}createModelFacade(t){const n=t["@M"];if(!n)throw new Error("Model missing @M field");const i=n.lastIndexOf("#"),o=i!==-1?n.slice(0,i):n,r=i!==-1?n.slice(i+1):void 0,s={...t,"@wireId":r},c=Object.keys(t).some(l=>l!=="@M");this.collectingRootModels&&c&&this.refreshedRootModelMarkers.add(n);const a=this.getModel(n);if(a)return a[se]?.(s),this.rememberModelSignals(n,a,s,c),c&&this.markModelFresh(n),a;const d=this.modelRegistry.get(o),g=d?new d(this.ctx,s):on(this.ctx,s,{t
1ypeName:o});return this.rememberModel(n,g),this.rememberModelSignals(n,g,s,c),c&&this.markModelFresh(n),g}handleUpdate(t,n,i){const o=this.getSignalById(t);if(!o)return;if(!i){o.value=n;return}const r=o.value;switch(i){case"append":Array.isArray(r)?o.value=[...r,...n]:typeof r=="string"&&(o.value=r+n);break;case"merge":r&&typeof r=="object"&&(o.value={...r,...n});break;case"splice":if(Array.isArray(r)){const{start:s,deleteCount:c,items:a}=n,d=[...r];d.splice(s,c,...a),o.value=d}break;default:o.value=n}}};function an(e,t){return t.split(".").reduce((n,i)=>n?.[i],e)}function be(e){return!!e&&typeof e=="object"&&typeof e.connectionId=="string"&&typeof e.processId=="string"&&typeof e.resumed=="boolean"}var ln=class{transport;transportGeneration=0;nextId=1;pending=new Map;notificationListeners=new Set;localRoot;reflection;transportReady;disconnectPromise;_rejectDisconnect;closed=!1;disconnectError;reconnectable=!1;readyResolved=!1;replaySubscriptionsOnRoot=!1;root=void 0;connectionId;connectionInfo;ready;_resolveReady;_rejectReady;constructor(e,t){this.transport=e,this.transportReady=e.ready,this.reconnectable=!!e.onOpen,this.resetDisconnectPromise(),this.ready=this.createReadyPromise(),this.reflection=new cn(this,t),this.wireTransport(e,this.transportGeneration)}reconnect(e){const t=new Error("Transport reconnected");for(const{reject:n}of this.pending.values())n(t);this.pending.clear(),this._rejectDisconnect(t),this.transportGeneration++,this.transport=e,this.transportReady=e.ready,this.reconnectable=!!e.onOpen,this.closed=!1,this.disconnectError=void 0,this.resetDisconnectPromise(),this.reflection.prepareReconnect(),this.replaySubscriptionsOnRoot=this.root!==void 0,this.ready=this.createReadyPromise(),this.wireTransport(e,this.transportGeneration)}createReadyPromise(){return this.readyResolved=!1,new Promise((e,t)=>{this._resolveReady=e,this._rejectReady=t})}resetDisconnectPromise(){this.disconnectPromise=new Promise((e,t)=>{this._rejectDisconnect=t}),this.disconnectPromise.catch(()=>{})}wireTransport(e,t){e.ready?.then(()=>this.handleOpen(t),n=>this.handleDisconnect(t,n)),e.onOpen?.(()=>this.handleOpen(t)),e.onClose?.(n=>this.handleDisconnect(t,n)),e.onMessage(n=>{if(t!==this.transportGeneration||e!==this.transport)return;const i=Xt(n.toString());if(!i)return;const o=(s,c)=>{if(typeof c=="object"&&c){if("@S"in c)return Object.hasOwn(c,"v")?this.reflection.syncSignalSnapshot(c["@S"],c.v):this.reflection.getOrCreateSignal(c["@S"],void 0);if("@M"in c)return this.reflection.createModelFacade(c)}return c};if(i.type==="result"||i.type==="error"){const s=Qt(i.payload,o),c=this.pending.get(i.id);if(!c)return;if(this.pending.delete(i.id),i.type==="result"){c.resolve(s);return}const{message:a,...d}=s??{};c.reject(Object.assign(new Error(a),d));return}if(i.type==="call"){this.handleCall(t,e,i.id,i.method,i.payload,o);return}if(i.method===te){const s=$(i.payload);this.prepareForRootSnapshot(s)}let r;if(i.method===te){this.reflection.beginRootSnapshot();try{r=$(i.payload,o)}finally{this.reflection.endRootSnapshot()}}else r=$(i.payload,o);this.handleNotification(t,i.method,r)})}prepareForRootSnapshot(e){const[,t]=e,n=be(t)?t:void 0;this.root!==void 0&&(!n||!this.connectionInfo||n.processId!==this.connectionInfo.processId)&&this.reflection.prepareProcessChange()}registerModel(e,t){this.reflection.registerModel(e,t)}syncSignalIdentity(e,t){return this.reflection.syncSignalIdentity(e,t)}expose(e){this.localRoot=e}sendOnTransport(e,t,n){e!==this.transportGeneration||t!==this.transport||this.closed||t.send(n)}handleCall(e,t,n,i,o,r){const s=i.split("."),c=s.pop(),a=s.length>0?an(this.localRoot,s.join(".")):this.localRoot,d=a?.[c];if(typeof d!="function"){this.sendOnTransport(e,t,ne(n,{code:-1,message:`Method not found: ${i}`}));return}let g;try{g=$(o,r)}catch(l){this.sendOnTransport(e,t,ne(n,{code:-1,message:l?.message??String(l)}));return}Promise.resolve().then(()=>d.apply(a,g)).then(l=>this.sendOnTransport(e,t,tn(n,l)),l=>this.sendOnTransport(e,t,ne(n,{code:-1,message:l?.message??String(l)})))}async call(e,t){if(this.closed)throw this.getDisconnectError();const n=this.transportGeneration,i=this.transport,o=this.transportReady;if(o&&await Promise.race([o,this.disconnectPromise]),n!==this.transportGeneration||i!==this.transport)throw new Error("Transport reconnected");if(this.closed)throw this.getDisconnectError();return new Promise((r,s)=>{this.sendCall(n,i,e,t,r,s)})}notify(e,t){const n=en(e,t),i=this.transportGeneration,o=this.transport,r=this.transportReady,s=()=>this.sendOnTransport(i,o,n);r?r.then(s,()=>{}):s()}sendCall(e,t,n,i,o,r){if(this.closed||e!==this.transportGeneration||t!==this.transport){r(this.closed?this.getDisconnectError():new Error("Transport reconnected"));return}const s=this.nextId++;this.pending.set(s,{resolve:o,reject:r}),t.send(Zt(s,n,i||[]))}handleOpen(e){if(e!==this.transportGeneration)return;const t=this.closed;this.closed=!1,this.disconnectError=void 0,this.transportReady=void 0,t&&this.resetDisconnectPromise()}handleDisconnect(e,t){if(!(e!==this.transportGeneration||this.closed)){this.closed=!0,this.disconnectError=t instanceof Error?t:new Error("Transport disconnected"),this.readyResolved&&(this.replaySubscriptionsOnRoot=!0),this._rejectDisconnect(this.disconnectError),!this.readyResolved&&!this.reconnectable&&this._rejectReady(this.disconnectError);for(const{reject:n}of this.pending.values())n(this.disconnectError);this.pending.clear()}}getDisconnectError(){return this.disconnectError??new Error("Transport disconnected")}onNotification(e){return this.notificationListeners.add(e),()=>{this.notificationListeners.delete(e)}}async refreshHeldModelsAndReplay(e){const t=this.reflection.getActiveHeldModelMarkers();if(t.length===0){this.reflection.replayActiveSignals();return}const n=this.reflection.beginModelRefresh(t),i=this.call(_e,t),o=this.reflection.replayActiveSignals();try{await i}catch{}
1finally{this.reflection.finishModelRefresh(t,n),e===this.transportGeneration&&this.reflection.replayActiveSignals(o)}}handleNotification(e,t,n){if(t===te){const[i,o]=n,r=this.root!==void 0;be(o)?(this.connectionInfo=o,this.connectionId=o.connectionId):(this.connectionInfo=void 0,this.connectionId=void 0),this.root=r?this.reflection.reconcileRoot(this.root,i):i,this.readyResolved||(this.readyResolved=!0,this._resolveReady()),this.replaySubscriptionsOnRoot&&(this.replaySubscriptionsOnRoot=!1,this.refreshHeldModelsAndReplay(e))}else if(t===Yt){const[i,o,r]=n;this.reflection.handleUpdate(i,o,r)}else for(const i of this.notificationListeners)i(t,n)}};function dn(e){return new ln(e,{})}const Ee=1e4;let un=class extends Error{constructor(){super(...arguments),this.name="CheckoutEditorBridgeTimeoutError"}};function hn(e){let t=i=>{};const n=new Promise((i,o)=>{function r(){window.clearTimeout(s),window.removeEventListener("message",c)}t=a=>{r(),o(a)};const s=window.setTimeout(()=>{r(),o(new un(`Checkout editor bridge timed out after ${Ee}ms`))},Ee);function c(a){const[d]=a.ports;if(d){if(a.source!==window.parent||!Wt(a.origin)){d.close();return}if(!jt(a.data,e)){d.close();return}r(),i({parentOrigin:a.origin,port:d})}}window.addEventListener("message",c),window.parent.postMessage(Kt(),"*")});return{cancel:t,connection:n}}function fn(e){window.parent.postMessage($t(),e)}function gn(e){window.parent.postMessage(qt(),e)}const L=1e4;class mn extends Error{constructor(){super(...arguments),this.name="CheckoutEditorBridgeTimeoutError"}}class pn extends Error{constructor(){super(...arguments),this.name="MixedSignalsCheckoutEditorBridgeNotEnabledError"}}
1class yn extends Error{constructor(){super(...arguments),this.name="MixedSignalsCheckoutEditorBridgeClosedError"}}class bn extends Error{constructor(){super(...arguments),this.name="UnknownMixedSignalsCheckoutEditorBridgeError"}}function En(e){return{send(t){e.postMessage(t)},onMessage(t){e.addEventListener("message",n=>t(n.data)),e.start()},ready:Promise.resolve()}}function B(e){return{initial:e.peek(),subscribe(n){let i=!1;return[e.subscribe(r=>{if(!i){i=!0;return}n(r)}),e.peek()]}}}function W(){}function re(e,t,n){return new Promise((i,o)=>{const r=window.setTimeout(()=>{o(new mn(n))},t);e.then(s=>{window.clearTimeout(r),i(s)}).catch(s=>{window.clearTimeout(r),o(s)})})}function vn(e){return{enabled:B(e.enabled),hover:{hoveredExtension:B(e.hover.hoveredExtension),setHoveredExtension:W},select:{selectedBlock:B(e.select.selectedBlock),setSelectedBlock:W,selectedExtension:B(e.select.selectedExtension),setSelectedExtension:W},actions:{canMoveDown:B(e.actions.canMoveDown),canMoveUp:B(e.actions.canMoveUp),lastDirection:B(e.actions.lastDirection),moveExtension:W,removeExtension:W}}}function Sn(e){return{checkoutProfile:{addressAutocompleteEnabled:B(e.checkoutProfile.addressAutocompleteEnabled),hasOverrides:B(e.checkoutProfile.hasOverrides)},activeInspector:vn(e.activeInspector)}}function wn(){return Be(new URLSearchParams(window.location.search))!=null}function Rn(){let e,t,n,i,o,r,s;const c=Be(new URLSearchParams(window.location.search));function a(){r&&s?.(r),s=void 0,n?.close(),n=void 0,t=void 0}function d(f){return r??=f instanceof Error?f:new bn("Unknown Mixed Signals checkout editor bridge error"),a(),r}function g(){if(!c)return Promise.reject(new pn("Mixed Signals checkout editor bridge is not enabled"));if(r)return Promise.reject(r);if(i)return i;const f=hn(c);return s=f.cancel,i=f.connection.then(async b=>{s=void 0;const{port:E}=b;if(r)throw E.close(),r;o=b.parentOrigin,n=E;const v=dn(En(E));return t=v,e&&v.expose(e),await re(v.ready,L,`Checkout editor bridge did not become ready after ${L}ms`),v}).catch(b=>{throw d(b)}),i}async function l(f,b=[]){try{const E=await g();return await re(E.call(f,b),L,`Checkout editor bridge ${f} timed out after ${L}ms`)}catch(E){throw d(E)}}async function p(){const f=await g();try{const b=await re(f.call("initialize",[]),L,`Checkout editor bridge initialize timed out after ${L}ms`);return Sn(b)}catch(b){throw d(b)}}return{call:{initialize:async f=>p(),navigate:f=>l("navigate",[f]),setLoading:f=>l("setLoading",[f]),updateSections:f=>l("updateSections",[f]),userInteractionEvent:f=>l("userInteractionEvent",[f]),setShopPay:f=>l("setShopPay",[f]),redirectTo:f=>l("redirectTo",[f])},expose(f){e=f,t?.expose(f)},close(){r??=new yn("Checkout editor bridge endpoint is closed"),a()},notifyError(){o&&gn(o)},notifyInitialized(){o&&fn(o)}}}const ve={"customizations.header.banner.image":"header.banner.image","customizations.header.logo.image":"header.logo.image","customizations.main.backgroundImage.image":"main.backgroundImage","customizations.orderSummary.backgroundImage.image":"orderSummary.backgroundImage","components.header.logo.image":"header.logo.image","surfaces.checkout.components.header.backgroundImage.image":"header.banner.image","surfaces.checkout.components.main.backgroundImage.image":"main.backgroundImage","surfaces.checkout.components.orderSummary.backgroundImage.image":"orderSummary.backgroundImage"},kn={"customizations.header.logo.maxWidth":{section:"logo",key:"maxWidth"},"components.header.logo.maxWidth":{section:"logo",key:"maxWidth"}},In={"customizations.header.position":{key:"position",section:"header"},"customizations.header.alignment":{key:"alignment",section:"header"},"surfaces.checkout.components.header.position":{key:"position",section:"header"},"surfaces.checkout.components.header.alignment":{key:"alignment",section:"header"}},Mn={"customizations.footer.position":{key:"position",section:"footer"},"customizations.footer.alignment":{key:"alignment",section:"footer"},"surfaces.checkout.components.footer.position":{key:"position",section:"footer"},"surfaces.checkout.components.footer.alignment":{key:"alignment",section:"footer"}},le={COLOR1:"base",COLOR2:"base",TRANSPARENT:"transparent"},Cn={"designSystem.typography.primary.name":"typographyPrimary","de
1signSystem.typography.secondary.name":"typographySecondary","designTokens.typography.primary.name":"typographyPrimary","designTokens.typography.secondary.name":"typographySecondary"};function On(){const e=ae();return O((t,n)=>{e.set(t,{...e.configuration[t],...n})},[e])}const Tn=["scheme1","scheme2","scheme3","scheme4","scheme5","scheme6","scheme7","scheme8"],Bn=Tn.flatMap(e=>[`designTokens.colors.schemes.${e}.base.background`,`designTokens.colors.schemes.${e}.base.accent`,`designTokens.colors.schemes.${e}.base.text`,`designTokens.colors.schemes.${e}.primaryButton.background`,`designTokens.colors.schemes.${e}.secondaryButton.text`,`designTokens.colors.schemes.${e}.control.accent`]),_n=["designSystem.colors.global.accent","designSystem.colors.global.brand","designSystem.colors.global.critical","designSystem.colors.global.control","designSystem.colors.schemes.scheme1.base.background","designSystem.colors.schemes.scheme2.base.background","designTokens.colors.global.accent","designTokens.colors.global.brand","designTokens.colors.global.critical","designTokens.colors.global.control",...Bn],Pn=["designSystem.typography.secondary.name","designSystem.typography.primary.name","designTokens.typography.secondary.name","designTokens.typography.primary.name"],xn=["customizations.header.banner.image","customizations.header.logo.image","customizations.main.backgroundImage.image","customizations.orderSummary.backgroundImage.image","components.header.logo.image","surfaces.checkout.components.header.backgroundImage.image","surfaces.checkout.components.main.backgroundImage.image","surfaces.checkout.components.orderSummary.backgroundImage.image"],Dn=["customizations.header.logo.maxWidth","components.header.logo.maxWidth"],An=["customizations.header.position","customizations.header.alignment","surfaces.checkout.components.header.position","surfaces.checkout.components.header.alignment"],Nn=["customizations.footer.position","customizations.footer.alignment","surfaces.checkout.components.footer.position","surfaces.checkout.components.footer.alignment"],Ln=["customizations.orderSummary.defaultState","surfaces.checkout.components.orderSummary.defaultState"],Fn=["customizations.control.color","components.control.color"],zn=["customizations.header.logo.visibility","customizations.cartLink.visibility","customizations.buyerJourney.visibility","customizations.footer.content.visibility","surfaces.checkout.components.header.logo.visibility","surfaces.checkout.components.cartLink.visibility","surfaces.checkout.components.buyerJourney.visibility","surfaces.checkout.components.footer.content.visibility"],Gn=["surfaces.checkout.components.header.colorScheme","surfaces.checkout.components.footer.colorScheme","surfaces.checkout.components.main.colorScheme","surfaces.checkout.components.orderSummary.colorScheme"],Un=["HIDDEN","VISIBLE"];function Wn(e){return _n.includes(e)}function Hn(e){return xn.includes(e)}function Vn(e){return Dn.includes(e)}function Kn(e){return An.includes(e)}function $n(e){return Nn.includes(e)}function qn(e){return Fn.includes(e)}function jn(e){return Pn.includes(e)}function Yn(e){return zn.includes(e)}function Jn(e){return Un.includes(e)}function Xn(e){return Ln.includes(e)}function Qn(e){return Gn.includes(e)}const Zn=/^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,ei=e=>e?je(e):void 0,ti=e=>e==="INLINE_SECONDARY"?"inlineSecondary":e.toLowerCase(),ni=e=>e in le,ii=e=>{const t=typeof e=="string"?e.toUpperCase():String(e);return ni(t)?le[t]:"base"},oi=e=>{if(typeof e!="string"||e==="")return!1;const t=e.toUpperCase();return t!=="DEFAULT"&&!(t in le)&&Zn.test(e)},ri=(e,t)=>e.reverse().reduce((n,i)=>({[i]:n}),t),si=(e,t,n,i)=>{if(t){const o=ti(t);n==="alignment"?(e.set(i,{...e.configuration[i],alignment:o}),i==="header"&&e.set("buyerJourney",{...e.configuration.buyerJourney,alignment:e.configuration.header.position==="inline"?o:"start"})):n==="position"&&(e.set(i,{...e.configuration[i],position:o}),i==="header"&&e.set("buyerJourney",{...e.configuration.buyerJourney,alignment:o==="inline"?e.configuration.header.alignment:"start"}))}else e.set(i,{...e.configuration[i],[n]:void 0})},ci=()=>{const e=A();return O((t,n)=>{const{url:i}=t??{},[o]=ve[n].split("."),r=at(e.configuration,ve[n],i);n==="customizations.main.backgroundImage.image"?e.set("main",{...e.configuration.main,backgroundImage:r.main?.backgroundImage}):e.set(o,r[o])},[e])},ai=()=>{const e=A();return O((t,n)=>{switch(n){case"surfaces.checkout.components.footer.colorScheme":e.set("footer",{...e.configuration.footer,colorScheme:t});break;case"surfaces.checkout.components.header.colorScheme":e.set("header",{...e.configuration.header,colorScheme:t});break;case"surfaces.checkout.components.main.colorScheme":e.set("main",{...e.configuration.main,colorScheme:t});break;case"surfaces.checkout.components.orderSummary.colorScheme":e.set("orderSummary",{...e.configuration.orderSummary,colorScheme:t});break}},[e])},li=()=>{const e=A();return O((t,n,i)=>{si(e,t,n,i)},[e])},di=()=>{const e=ae();return O((t,n)=>{const[i,o,...r]=n.split("."),s=ri(r,ei(t));e.preview(lt({...e?.configuration?.colors},s))},[e])},ui=()=>{const e=A();return O((t,n)=>{const i={...e.configuration.header},o=i[n]?.image;t&&o?i[n]={...i[n],image:o,maxWidth:t}:o?i[n]={...i[n],image:o,maxWidth:void 0}:i[n]={...i[n],image:"",maxWidth:void 0},e.set("header",i)},[e])};function hi(){const e=A();return O((t,n)=>{const i=t.toLowerCase(),o=n.startsWith("surfaces")?n.split(".")[3]:n.split(".")[1];let r={};switch(o){case"cartLink":case"buyerJourney":r={visibility:i};break;case"header":r={logo:{...e.configuration.header.logo,visibility:i}};break;case"footer":r={content:{...e.configuration.footer.content,visibility:i}};break}e.set(o,{...e.configuration[o],...r})},[e])}function fi(){const{shop:e}=D(),t=A(),n=e.hasFlagEnabled(Ye);return O(i=>{const o=!!t.configuration.environment?.isOnePageCheckout;t.set("reductions",{...t.configuration.reductions,position:o&&n&&i==="EXPANDED"?"base":"inside_order_summary"}),t.set("orderSummary",{...t.configuration.orderSummary,defaultState:o?void 0:i})},[t,n])}const gi=({id:e,value:t})=>{const n=ae(),i=ci(),o=li(),r=di(),s=ui(),c=On(),a=hi(),d=fi(),g=ai(),l=A();S(()=>
1{if(Wn(e))r(t,e);else if(Hn(e))i(t,e);else if(Vn(e)){const{section:p}=kn[e];s(t,p)}else if(Kn(e)){const{key:p,section:y}=In[e];o(t,p,y)}else if($n(e)&&t){const{key:p,section:y}=Mn[e];o(t,p,y)}else if(qn(e)){const p=ii(t);p==="transparent"?r("#00000000","designTokens.colors.global.control"):oi(t)?r(t,"designTokens.colors.global.control"):p==="base"&&r("#FFFFFF","designTokens.colors.global.control")}else if(jn(e)){const p=Cn[e],y=t,f=y?.bolderVariant?y.bolderVariant:y?.defaultVariant;c(p,{fonts:y?.name??void 0,sourceBase:y?.defaultVariant?.sources||void 0,weightBase:y?.defaultVariant?.variation?.weight?.toString()??void 0,sourceBold:f?.sources||void 0,weightBold:f?.variation?.weight?.toString()??void 0})}else Yn(e)&&Jn(t)?a(t,e):Xn(e)?d(t):Qn(e)&&g(t,e)},[e,t,r,i,s,o,c,n,l,a,d,g])};function mi(e){return gi(e),null}function pi({children:e,hydrated:t,onBrandingLoaded:n}){return z(()=>{t&&n()},[t,n]),_(ce,{children:e})}function yi(){return ke(Ie)}function bi({index:e,children:t,...n}){const i=yi(),o=D().checkout.extensibility.ui,r=ot(),s=o.search().value.find(c=>c.type==="persisted"&&c.publicIdentifier===n.activatedExtensionId&&c.extensionPoint.target===i.extensionPoint&&c.placementReference===i.placementReference);return S(()=>{if(s)return;const c=Je({extension:n,extensionPoint:i.extensionPoint}),a=r.findAll({id:n.targetPublicIdentifier,target:i.extensionPoint})[0];return a?o.add({...a.extension,placementReference:i.placementReference}):o.add({id:n.targetPublicIdentifier,publicIdentifier:n.publicIdentifier,targetPublicIdentifier:n.targetPublicIdentifier,extensionId:n.id,registrationId:n.id,extensionPoint:{target:i.extensionPoint,metafields:[],preloads:c},placementReference:i.placementReference,scriptUrl:n.scriptUrl,appId:n.app.id,appApiKey:null,apiVersion:n.apiVersion,version:n.version,translations:JSON.parse(n.translations),approvalScopes:new Set(n.approvalScopes.map(({handle:d})=>d)),capabilities:n.capabilities,extensionLocale:n.extensionLocale,name:n.name,type:"persisted",behaviors:P({alwaysReveal:!1,blockProgress:!1,showInExpressCheckout:!0}),configuration:P({}),position:P(e)}),()=>{o.remove([n.targetPublicIdentifier],{keepAlive:!0,reason:"checkout_editor"})}},[i.extensionPoint,i.placementReference]),S(()=>{!s||s.position.value===e||(s.position.value=e)},[e,o,n.activatedExtensionId,s]),_(Me.Provider,{value:n,children:s&&t})}function Ae(){return ke(Me)}function Ei({...e}){const t=D().checkout.extensibility.ui,{activatedExtensionId:n}=Ae();return S(()=>{const i=t.search().peek().find(s=>s.type==="persisted"&&s.publicIdentifier===n);if(!i)return;const o=i.behaviors.value;(o.alwaysReveal!==e.alwaysReveal||o.blockProgress!==e.blockProgress||i.behaviors.value.showInExpressCheckout!==e.showInExpressCheckout)&&(i.behaviors.value=e)},[e,n,t]),null}function vi({...e}){const t=D().checkout.extensibility.ui,{activatedExtensionId:n}=Ae();return S(()=>{const i=t.search().peek().find(o=>o.type==="persisted"&&o.publicIdentifier===n);i&&(i.configuration.value=e)},[n,e,t]),null}function Si({children:e,extensionPoint:t,placementReference:n}){const i=z(()=>({extensionPoint:t,placementReference:n}),[t,n]);return _(Ie.Provider,{value:i,children:e})}const wi={BrandingSettings:pi,BrandingSetting:mi,Extension:bi,ExtensionPoint:Si,ExtensionBehaviors:Ei,ExtensionConfiguration:vi},Ri=new Set(["RemoteFunctionRevokedError","RemoteFunctionReleasedError"]);function ki(e){return e instanceof Error&&Ri.has(e.name)}function C(e,t,n){const i=Ce(e),o=P(i.current);return i.subscribe(r=>{o.value=r}),t&&o.subscribe(r=>{if(o.peek()!==i.current){n?.(r);try{t(r)}catch(s){if(!ki(s))throw s}}}),o}function Ii(e){return e.type==="click"}function Mi(e){return e.type==="keydown"}function Ci(e,t){return n=>{n.isTrusted&&(Ii(n)&&(t.leaveErrorBreadcrumb("CheckoutEditorBridge: Click event"),e({type:"click",event:{cancelable:n.cancelable,bubbles:n.bubbles}})),Mi(n)&&((n.key==="s"||n.key==="y")&&(n.metaKey||n.ctrlKey)&&n.preventDefault(),t.leaveErrorBreadcrumb("CheckoutEditorBridge: Keydown event"),e({type:"keydown",event:{altKey:n.altKey,charCode:n.charCode,code:n.code,ctrlKey:n.ctrlKey,isComposing:n.isComposing,key:n.key,keyCode:n.keyCode,shiftKey:n.shiftKey,metaKey:n.metaKey,cancelable:n.cancelable,bubbles:n.bubbles,defaultPrevented:n.defaultPrevented}}
1)))}}const Ne=typeof window<"u"&&wn();class Oi extends Error{constructor(){super(...arguments),this.name="UnknownCheckoutEditorBridgeError"}}function Le(e,t,n){const i=t instanceof Error?t:new Oi("Unknown checkout editor bridge error");n.leaveErrorBreadcrumb(`CheckoutEditorBridge: ${e} call failed`,{error:i.message}),n.error(i,{severity:"warning",metadata:{checkoutEditorBridge:{method:e}}}),i.message==="You attempted to call a function on a terminated web worker."&&n.counter({name:"editor_bridge_called_terminated_worker",value:1,attributes:{terminatedFunctionName:e}})}function F(e,t,n){return Promise.resolve(t).catch(i=>{Le(e,i,n)})}function Fe(){return We(He(),{callable:["initialize","navigate","setLoading","updateSections","userInteractionEvent","setShopPay","redirectTo"]})}const Se=typeof window>"u"||Ne?void 0:Fe();function Vi({setContext:e}){const{currentPage:t,currentDetour:n}=X().value,{navigate:i}=_t(),o=Bt(),{allRenderedSections:r,editorSetShopPaySignal:s}=Xe(),c=r.value,[a,d]=J(!1),{router:g,observability:l,shop:p,checkout:{configuration:y}}=D(),f=g.currentUrl.value,b=rt(),E=st(),v=Ne&&p.hasFlagEnabled(Qe),m=z(()=>{if(!(typeof window>"u"))return v?Rn():Se??Fe()},[v]),G=!v&&Se==null,N=z(()=>new Ze,[]),U=z(()=>Ve(N.connection),[N]);S(()=>{let w;async function M(){if(!m)return;l.leaveErrorBreadcrumb("CheckoutEditorBridge: Initializing");const u=await m.call.initialize(U);if(l.leaveErrorBreadcrumb(`CheckoutEditorBridge: Initialization complete - context ${u?"present":"missing"}`),v||we(u),u?.checkoutProfile.addressAutocompleteEnabled&&(w=Ti(u.checkoutProfile.addressAutocompleteEnabled,h=>{y.update({addressSettings:{autocompleteEnabled:h}})})),u){const h=u.activeInspector.inspectorTarget,k={...u,activeInspector:{enabled:C(u.activeInspector.enabled),selectedBlock:C(u.activeInspector.select.selectedBlock,u.activeInspector.select.setSelectedBlock,R=>{l.leaveErrorBreadcrumb("CheckoutEditorBridge: setSelectedBlock called",{value:R})}),hoveredExtension:C(u.activeInspector.hover.hoveredExtension,u.activeInspector.hover.setHoveredExtension,R=>{l.leaveErrorBreadcrumb("CheckoutEditorBridge: setHoveredExtension called",{value:R})}),selectedExtension:C(u.activeInspector.select.selectedExtension,u.activeInspector.select.setSelectedExtension,R=>{l.leaveErrorBreadcrumb("CheckoutEditorBridge: setSelectedExtension called",{value:R})}),inspectorTarget:h?{hovered:C(h.hovered,h.setHovered),rect:C(h.rect,h.setRect),viewport:C(h.viewport,h.setViewport)}:void 0,actions:{canMoveUp:C(u.activeInspector.actions.canMoveUp),canMoveDown:C(u.activeInspector.actions.canMoveDown),lastDirection:C(u.activeInspector.actions.lastDirection),moveExtension:(...R)=>(l.leaveErrorBreadcrumb("CheckoutEditorBridge: moveExtension called",{args:JSON.stringify(R)}),u.activeInspector.actions.moveExtension(...R)),removeExtension:(...R)=>(l.leaveErrorBreadcrumb("CheckoutEditorBridge: removeExtension called",{args:JSON.stringify(R)}),u.activeInspector.actions.removeExtension(...R))}},checkoutProfile:{addressAutocompleteEnabled:u.checkoutProfile.addressAutocompleteEnabled,hasOverrides:C(u.checkoutProfile.hasOverrides)}};e(k)}s.value={setShopPay:h=>{l.leaveErrorBreadcrumb("CheckoutEditorBridge: setshopPay called",{value:h}),F("setShopPay",m.call.setShopPay(h),l)}},d(!0),v&&m.notifyInitialized?.()}return v?M().catch(u=>{Le("initialize",u,l),m?.notifyError?.()}):M(),()=>{w?.()}},[U,e,s,l,y,v,m]),S(()=>{if(!a||!m)return;const{searchParams:w}=f,M=w.get("ce_redirect");M&&b.includes(M)&&(l.leaveErrorBreadcrumb("CheckoutEditorBridge: redirectTo called",{redirectTo:M}),F("redirectTo",m.call.redirectTo(M),l),g.navigate(u=>{const h=new URL(u.href);return h.searchParams.delete("ce_redirect"),h},{replace:!0}))},[f,a,l,b,g,m]),S(()=>{m&&(l.leaveErrorBreadcrumb("CheckoutEditorBridge: Navigate exposed"),m.expose({navigateToStep:i}))},[i,l,t,m]),S(()=>{const w=n?.type??t?.id;!w||!a||!m||(l.leaveErrorBreadcrumb(`CheckoutEditorBridge: navigate called with checkout:${w}`),F("navigate",m.call.navigate(`checkout:${w}`),l))},[t,n,a,l,m]),S(()=>{!a||!m||(l.leaveErrorBreadcrumb(`CheckoutEditorBridge: setLoading c
1alled with ${o}`),F("setLoading",m.call.setLoading(o),l))},[o,a,l,m]),S(()=>{!a||!m||!c||(l.leaveErrorBreadcrumb("CheckoutEditorBridge: updateSections called with the following sections",{sections:JSON.stringify(c)}),F("updateSections",m.call.updateSections(c),l))},[a,c,l,m]),S(()=>{if(!a||!m)return;const w=Ci(M=>F("userInteractionEvent",m.call.userInteractionEvent(M),l),l);return window.addEventListener("click",w),window.addEventListener("keydown",w),()=>{window.removeEventListener("click",w),window.removeEventListener("keydown",w)}},[a,l,m]);const Q=z(()=>new Map([...Object.entries(wi).map(([w,M])=>[w,tt(M)]),["remote-fragment",et]]),[]);return S(()=>()=>{l.leaveErrorBreadcrumb("CheckoutEditorBridge: Unmounting"),m?.close?.(),G&&m?.terminate?.()},[l,m,G]),_(ce,{children:[_(Tt,{}),_(nt,{receiver:N,components:Q}),a&&E?.activeInspector.inspectorTarget?_(It,{inspectorTarget:E.activeInspector.inspectorTarget,selectedBlock:E.activeInspector.selectedBlock,selectedExtension:E.activeInspector.selectedExtension}):null]})}function Ti(e,t){return t(e.initial),Ce(e).subscribe(t)}export{Vi 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.