var _____WB$wombat$assign$function_____=function(name){return (globalThis._wb_wombat && globalThis._wb_wombat.local_init && globalThis._wb_wombat.local_init(name))||globalThis[name];};if(!globalThis.__WB_pmw){globalThis.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}var window = _____WB$wombat$assign$function_____("window");
var self = _____WB$wombat$assign$function_____("self");
var document = _____WB$wombat$assign$function_____("document");
var location = _____WB$wombat$assign$function_____("location");
var top = _____WB$wombat$assign$function_____("top");
var parent = _____WB$wombat$assign$function_____("parent");
var frames = _____WB$wombat$assign$function_____("frames");
var opener = _____WB$wombat$assign$function_____("opener");
import{q7 as v,q8 as w,q9 as q,qa as E,lF as D,lG as T,ih as x,ap as R,bH as C,e6 as O,bl as N,a0 as $,dT as A,gA as U,b0 as F,fG as L,al as M,aX as j,iw as G,ob as X,oa as S,a7 as z}from"./app.ZXowmuNl.js";const B={id:"6e80fbaa48c55e585de6accb0c4efcf5389f92340be06a6c32f0e5ce451de978",type:"query",name:"PostPurchaseData",source:"query PostPurchaseData($input:PostPurchaseDataInput!){postPurchaseData(input:$input){...on PostPurchaseDataSuccess{appId inputData isDevShop scriptUrl trackingData __typename}...on PostPurchaseDataFailed{code __typename}__typename}}"},H="https://cdn.shopify.com/shopifycloud/checkout-web/assets/c1.en/sandbox.Za7BtbvS.worker.js",Q=v(H);function W(){return w({baseURL:q(E),isPostPurchase:!0})(()=>{},{allowNetworkAccess:!0})}const J="v1",K="Checkout::PostPurchase";function V({extensionId:o,sourceId:u}){const n=`${J}-${o}-${K}`,s=`${n}-${u}`;return Object.keys(localStorage).forEach(a=>{a!==s&&a.startsWith(n)&&D(a)}),{read(){return T(s)},async write(a){x(s,a)},async delete(){D(s)}}}class Y extends Error{name="PostPurchaseEmptyDataError"}function Z(){const o=R(),u=C(),n=O(),s=N(),{postPurchaseInquiryStatus:r}=$(),a=A(),{developmentOptions:p,developmentMode:d}=U(),i=F(),g=L(),l=M(null),h=j(async()=>{try{r.value="timeout";const{sessionInput:P,queueToken:ee,changesetTokens:ae,checkpointData:te,..._}=await n(),{data:t,error:m}=await u.query(B,{cache:!1,variables:{input:{forShouldRender:{purchaseProposal:_,sessionToken:P.sessionToken,developmentOptions:p}}}});if(m)throw m;if(t?.postPurchaseData.__typename!=="PostPurchaseDataSuccess"){r.value="failed";return}const y=t.postPurchaseData.inputData;if(!y)throw new Y("The post-purchase inputData is empty");const b=JSON.parse(y),I=V({extensionId:t.postPurchaseData.appId,sourceId:s.sourceId}),e=G();f();async function f(){try{if(t?.postPurchaseData.__typename!=="PostPurchaseDataSuccess")return;e.mark("start");const c=Q({createMessenger:W()});l.current=c,await c.load(t.postPurchaseData.scriptUrl),e.mark("loaded");const k=await c.run("Checkout::PostPurchase::ShouldRender",{locale:o,inputData:b,version:"unstable",extensionPoint:"Checkout::PostPurchase::ShouldRender",storage:{initialData:{},update:I.write}});e.mark("completed"),r.value=k.render?"success":"declined",e.marks.start&&e.marks.loaded&&i.histogram({name:"PostPurchase_inquiry_sandbox_duration",value:e.marks.loaded-e.marks.start,attributes:{app:t.postPurchaseData.appId}}),e.marks.completed&&e.marks.loaded&&i.histogram({name:"PostPurchase_inquiry_duration",value:e.marks.completed-e.marks.loaded,attributes:{should_render:k.render,app:t.postPurchaseData.appId}}),X(c,{async reload(){t.postPurchaseData.__typename==="PostPurchaseDataSuccess"&&d&&(S(c),f())}})}catch{r.value="error"}}}catch{r.value="error"}},[p,n,u,o,i,r,s.sourceId,d]);return z(()=>(h(),()=>{S(l.current)}),[h,a.value?.amount,a.value?.currencyCode,g.value?.countryCode]),null}const re=Object.freeze(Object.defineProperty({__proto__:null,default:Z},Symbol.toStringTag,{value:"Module"}));export{re as P,W as a,V as b,Q as c,B as p};