import{n as e}from"./f025431a.BlsbPO0-.js";import{yt as t,zt as r}from"./630ba094.L_X-5TXi.js";import{a,i,o as n}from"./4509beb0.BguNH--m.js";import{$t as o,FE as s,Fc as l,Fn as c,Gt as u,Jt as d,Kt as h,Ln as p,Lr as y,Pn as g,Qt as m,R as v,Rv as b,SE as S,TE as f,Tn as k,V as P,Xt as w,Yt as E,Zt as C,a as R,bE as A,ca as z,d as T,dh as H,en as x,f as I,g as L,ha as F,i as _,kf as O,n as q,nn as B,o as U,qt as D,r as M,t as V,tc as j,tn as K,u as G,wn as Y,xE as J,y as Q,yE as W,yh as X}from"./6ec9a0fa.rdcQt2v8.js";var Z=e({captureServerBreadcrumb:()=>ie,captureServerFooterPosition:()=>ae,criticalAsyncComponents:()=>re,hydrateApp:()=>N,loadLayoutPlaygroundRegions:()=>ee,renderTerminalError:()=>$});function $({rootElement:e,terminalErrorPageElement:t}){return r=>_(e,t,r)}async function N(e,{bootStartTime:o,bootPhaseTimings:s,stopObservingRemovals:c}){const{client:u,terminalErrorHandler:d}=e,h="shopPay"===e.checkout.identity.current.value,m=e.checkout.thankYouEntrance.progress;m?n(m,{currentUrl:e.router.currentUrl,latestReceipt:e.checkout.latestReceipt}):i()&&a();const v=U({client:u,isShopPayActive:h,isShopPaySdkCheckout:F(e.shopPay),observability:e.observability});await async function(e,{bootStartTime:t,bootPhaseTimings:r}){const{events:a,client:i,router:n}=e;n.prefix instanceof RegExp&&q({pathnamePrefix:n.prefix,allowedOrigins:i.unstable_getSerialization("shop").origins,client:i,isShopPayActive:"shopPay"===e.checkout.identity.current.value}),Object.defineProperty(window,Symbol.for("Shopify.checkout"),{value:{context:e},writable:!0,configurable:!0,enumerable:!1}),await p(e,{loadFrom:i.initialRequest.isServerRendered?"serialized-cache":"network"});const o=new J(e,{bootStartTime:t,bootPhaseTimings:r});o.waitUntil(async function(e){const{checkout:t,router:r}=e,a=re({isOnePage:t.configuration.layout.isOnePage.value,isShopPay:"shopPay"===t.identity.current.value,path:r.currentUrl.value.normalizedPath,trees:t.configuration.layout.trees.value,uiExtensibility:t.extensibility.ui,orderSummary:t.configuration.orderSummary}),i=g(e);i&&a.push(i),await Promise.all([...a.map(e=>e.load()),t.deliveryPredictions.prepare?.(l.load),"mobile-sdk"===X(e)&&e.mobileCheckoutSdk.load()])}(e)),a.dispatchEvent(o),await o.allResolved(),a.dispatchEvent(new S(o))}(e,{bootStartTime:o,bootPhaseTimings:s}),b.preload(),v&&(v.stage="context_ready");const P=performance.now();let w,E;const C=new Promise(e=>{E=e});let z;k({isCheckoutEditor:e.checkout.configuration.branding.shell.configuration.environment.isCheckoutEditor??!1,isDevelopment:!1,isDevPreview:e.environment.isDevPreview,isHydrated:!0,previewBranch:e.environment.previewBranch,sourceType:e.source.type})&&(z={whenHydrated:new Promise(e=>{w=e}),loadRegions:ee});const x=t(T,{terminalErrorHandler:d,children:t(Y,{context:e,layoutPlaygroundRuntime:z,children:t(I,{})})}),_=void 0!==u.unstable_getSerialization("layout")&&void 0===e.checkout.configuration.layout.trees.value,O=u.initialRequest.isServerRendered&&e.router.shouldHydrateServerRenderedRoute()&&!_,B=c(),D=()=>{w?.(),E()};O?function(e,t,a,i,n){const o="shopPay"===a.checkout.identity.current.value,s=ie(t),l=ae(t);G(e,{onHydrated:n,parent:t,observability:a.observability,debugMode:a.environment.debug.preact,deployStage:a.environment.deployStage,userAgent:a.client.userAgent,isKnownDomMutatingAgent:a.client.userAgentDetails.isKnownDomMutatingAgent,serverUserAgent:a.client.unstable_getSerialization("serverUserAgent"),apiClientId:a.client.unstable_getSerialization("apiClientId"),preHydrationRemovals:i,page:()=>j(window.location.href,{isShopPayActive:o,shopPay:a.shopPay}),mismatchContext:()=>{const e=r(()=>{const e=a.checkout.configuration.branding.shell.configuration;return{shellHeaderShowHeader:a.checkout.configuration.visibility.showHeader,shellHeaderLogoVisibility:e.header.logo?.visibility,shellHeaderCartLinkVisibility:e.cartLink.visibility,shellHeaderIsShopOnWeb:H(a.router.currentUrl.value.search),shellHeaderPrefersDarkMode:a.client.prefersDarkMode.value}}),t=r(()=>({cartLinkShopHasStorefront:a.shop.hasStorefront,cartLinkSourceType:a.source.type,cartLinkHasCartReturnUrl:Boolean(a.source.cartReturnUrl)})),i=L.current,n=i&&{breadcrumbIds:i.ids,breadcrumbActiveId:i.activeId,breadcrumbShowCartLink:i.showCartLink,breadcrumbHasCartUrl:i.hasCartUrl},o=r(()=>{const{footer:e}=a.checkout.configuration.branding.shell.configuration;return{serverFooterPosition:l,shellFooterPosition:e.position,shellFooterContentVisibility:e.content?.visibility,shellFooterConfigShowFooter:a.checkout.configuration.showFooter,shellFooterMobileCheckoutSdkEnabled:a.mobileCheckoutSdk.enabled,shellFooterMobileCheckoutSdkVariant:a.mobileCheckoutSdk.variant.value,shellFooterIsEmbed:null!=a.embed,shellFooterIsCheckoutKit:a.embed?.isCheckoutKit()}}),c=a.client.unstable_getSerialization("graphql"),u={browserDetectedCheckoutEditor:y(a.client.unstable_getSerialization("sourceType")),clientAssetsBase:a.client.assets.assetsBase,clientBundleIsBaseline:a.client.assets.isBaselineBrowser,hasSerializedShopPayLoginAnalyticsTraceId:Boolean(a.client.unstable_getSerialization("shopPayLoginAnalyticsTraceId")),hasSerializedShopPayLoginOAuthState:Boolean(a.client.unstable_getSerialization("shopPayLoginOAuthState")),serializedIsCheckoutEditor:a.client.initialRequest.isCheckoutEditor,serverCommitSha:a.environment.commitSha,serverHandling:a.client.unstable_getSerialization("serverHandling"),serverRequestId:a.client.unstable_getSerialization("requestId"),serverServedAt:a.client.unstable_getSerialization("servedAt"),serverRender:a.client.unstable_getSerialization("serverRender"),serializedGraphqlCacheEntryCount:c?Object.keys(c).length:0,workerVersion:a.client.unstable_getSerialization("workerVersion")};return{serverCrumbCount:s?.count,serverActiveCrumbIndex:s?.activeIndex,...e,...o,...t,...n,...u}}})}(x,u.rootElement,e,B,D):(M(x,u.rootElement),D()),v&&(v.stage="rendered"),R({client:e.client,isShopPayActive:h,progress:m,watch:v}),async function(e,{hydrateStartTime:t,settled:r}){const{events:a}=e,i=new W(e,{hydrateStartTime:t,...r?{settled:r}:{}});a.dispatchEvent(i),await i.allResolved(),a.dispatchEvent(new A(i))}(e,{hydrateStartTime:P,...f.current?{settled:C}:{}})}async function ee(e){const{mainRoot:t,primaryAside:r}=s(e),a=[];if(void 0!==r?.children&&a.push(v.load()),void 0!==t&&a.push(x()),(await Promise.all(a)).some(e=>"function"!=typeof e))throw new te("The checkout rendering engine could not load. Reload and try again.")}var te=class extends Error{constructor(...e){super(...e),this.name="LayoutPlaygroundLoadError"}};function re({isOnePage:e,isShopPay:t,path:r,trees:a,uiExtensibility:i,orderSummary:n}){const l=function({isOnePage:e,isShopPay:t,path:r}){switch(r){case"/processing":return[C];case"/throttle":return[u];case"/thank-you":return[h];case"/shoppay_login":return[d]}if(t||e)return[o];switch(r){case"/shipping":return[E,B];case"/payment":return[m,B];case"/review":return[w,B];case"/stock-problems":return[K,E,m,w,D];default:return[K]}}({isOnePage:e,isShopPay:t,path:r});return z({isOnePage:e,isShopPay:t,path:r})&&l.push(Q),void 0!==a&&e&&O(r)&&(l.push(v),V.includes(r)&&void 0!==s(a.checkout).mainRoot&&l.push({load:x})),e&&"beforeDetails"===n?.placement&&"/thank-you"!==r&&l.push(P),i.required.value&&l.push(c,{load:i.ensureEngineLoaded}),l}function ae(e){const t=e.querySelector('footer[data-inspector-id="footer"]');return t?t.parentElement?.querySelector(":scope > main")?"inline":"end":"none"}function ie(e){const t=e.querySelector("nav ol");if(!t)return;const r=Array.from(t.children);return{count:r.length,activeIndex:r.findIndex(e=>"step"===e.getAttribute("aria-current"))}}export{ie as captureServerBreadcrumb,ae as captureServerFooterPosition,re as criticalAsyncComponents,N as hydrateApp,ee as loadLayoutPlaygroundRegions,$ as renderTerminalError,Z as t};