try{let e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`503f394a-f9aa-4cdc-96dd-4825c1b7774d`,e._sentryDebugIdIdentifier=`sentry-dbid-503f394a-f9aa-4cdc-96dd-4825c1b7774d`)}catch{}import{o as e}from"./rolldown-runtime-eb2nym32.js";import{R as t,z as n}from"./vendor-misc-hfpbxrii.js";import{$d as r,Ag as i,Dp as a,Dr as o,Ep as s,Fg as c,Ig as l,U as u,_r as d,dn as f,go as p,sh as m,st as h,th as g}from"./entry.client-dr7r6s9a.js";import{t as _}from"./XenonSpinner-hionx0on.js";import{n as v,t as y}from"./createGetAuthToken-gzsh85ms.js";import{t as b}from"./PurchaseHost-neaf6sjk.js";import{t as x}from"./useFlowId-n9vqrww9.js";import{t as S}from"./purchasePageReadyUtils-n2r38x2a.js";import{n as C,r as w,t as T}from"./parseSearchParams-lzmzldiy.js";var E=e(l(),1),D=c(),O=i(),k=e=>{let t=(0,D.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=u(`h-full w-full`,`sm-25:(h-[640px] w-[592px] rounded-2xl border border-solid border-action-noninteractive-border-rest bg-container-backgrounds-elevation-background-level-4 bg-cover shadow-xl)`,`md-20:w-[634px]`,`lg-10:(h-[720px] w-[1280px])`,`lg-20:(h-[810px] w-[1440px])`,`density-high:lg-20:h-[720px] density-high:lg-20:w-[1280px]`,`density-low:xl-10:h-[1080px] density-low:xl-10:w-[1920px]`,`select-none overflow-hidden`),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,O.jsx)(`div`,{className:`twscope flex h-screen items-center justify-center`,children:(0,O.jsx)(`div`,{className:r,children:(0,O.jsx)(`div`,{className:`h-full w-full overflow-hidden bg-gradient-to-t from-container-backgrounds-elevation-background-level-4 to-container-backgrounds-overlay-smoke-thin backdrop-blur-3xl`,children:n})})}),t[1]=n,t[2]=i),i},A=()=>{let e=(0,D.c)(1);o(!0);let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,O.jsx)(k,{children:(0,O.jsx)(_,{disableAnimation:!0})}),e[0]=t):t=e[0],t},j=`https://purchasecore.xboxservices.com`,M=(0,E.createContext)(null),N=f(e=>{let t=(0,D.c)(3),n=b.useComponent(),r;return t[0]!==n||t[1]!==e?(r=(0,O.jsx)(n,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},()=>{let{productId:e,skuId:i,availabilityId:o}=n(r.external.commerce.purchase),[c]=t(r.external.commerce.purchase),{getLogger:l}=g(),{adaptor:{native:u}}=m();h();let d=x(),f=(0,E.useContext)(M),_=l(`PurchasePage`);if(!f)throw new s(`HostCommunicationContext`,a.Missing);let{mode:v,getXToken:b,getToken:D,getMsaToken:O,onExit:k,onResult:A,onPageReady:N}=f;if(!e)throw new s(`productId`,a.Missing);let P=c.campaignId??void 0,F=c.optionalCampaignId??void 0,I=c.catalogId??void 0,L=w(c.clientName),R=T(c.callerApplicationId)??p.PCGamingApp,z=C(c.purchaseSource),B=c.identityMismatch??!1,V=(0,E.useRef)(null),H=y({mode:v,getXToken:b,getToken:D,getMsaToken:O,isNhpAvailable:async()=>(V.current===null&&(V.current=await u.bridge.isSupported()&&await u.user.isAvailable().catch(e=>(_.info(`native.user.isAvailable() threw — treating NHP as unavailable: ${e instanceof Error?e.message:String(e)}`),!1))),V.current),logger:_,msaVersion:`MSAv1`}),U=async()=>{let e=await b(j).catch(()=>null);return e?{"X-MS-Authorization-Social":e.token}:void 0},W=async e=>{await A(e)},G=async e=>{_.info(`onExit — status: ${e.status}`),await k(e)},K=S(N);return{productId:e,skuId:i,availabilityId:o,campaignId:P,optionalCampaignId:F,includeOrderDocument:!1,allowAsyncPurchase:!0,catalogId:I,callerApplicationId:R,purchaseLaunchStartTime:performance.now(),preload:c.preload===!0,sourceClientName:L,purchaseSource:z,getAuthToken:H,getExtraHeaders:U,onExit:G,onResult:W,onPurchasePageReady:K,flowId:d,identityMismatch:B}}),P=d(()=>{let e=v({resultReporting:`onResult`}),{isReady:t,error:n}=e,r=N.useComponent();if(n)throw n;return t?(0,O.jsx)(M.Provider,{value:e,children:(0,O.jsx)(E.Suspense,{fallback:(0,O.jsx)(A,{}),children:(0,O.jsx)(r,{})})}):(0,O.jsx)(A,{})},`PurchasePage`);export{P as t};