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]=`83ee18b7-5b71-48a2-829e-c2d6c732dc97`,e._sentryDebugIdIdentifier=`sentry-dbid-83ee18b7-5b71-48a2-829e-c2d6c732dc97`)}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,Ep as o,Fg as s,Ig as c,Ym as l,_r as u,bm as d,dn as f,sh as p,st as m,th as h}from"./entry.client-dr7r6s9a.js";import{t as g}from"./commercePreloadLinks-7ptujqoo.js";import{n as _,t as v}from"./createGetAuthToken-gzsh85ms.js";import{t as y}from"./useFlowId-n9vqrww9.js";import{t as b}from"./purchasePageReadyUtils-n2r38x2a.js";import{t as x}from"./GiftingHost-hgnt8esd.js";var S=s(),C=d(),w=e(c(),1),T=i(),E=(0,w.createContext)(null),D=f(e=>{let t=(0,S.c)(3),n=x.useComponent(),r;return t[0]!==n||t[1]!==e?(r=(0,T.jsx)(n,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},()=>{let{productId:e,skuId:i,availabilityId:s}=n(r.external.commerce.gifting),[c]=t(r.external.commerce.gifting),{getLogger:l}=h(),{adaptor:{native:u}}=p();m();let d=y(),f=(0,w.useContext)(E),g=l(`GiftingPage`);if(!f)throw new o(`HostCommunicationContext`,a.Missing);let{mode:_,getXToken:x,getToken:S,getMsaToken:T,onExit:D,onPageReady:O}=f;if(!e)throw new o(`productId`,a.Missing);let k=c.gifteeType??void 0,A=c.gifteeValue??void 0,j=c.campaignId??void 0,M=c.optionalCampaignId??void 0,N=c.catalogId??void 0,P=c.identityMismatch??!1,F;if(k?.toLowerCase()===`gamertag`){if(!A)throw new o(`gifteeValue`,a.Missing);F={type:`StartFromGamertagDelivery`,preselectedGamertag:A??``}}else F=k?.toLowerCase()===`email`?{type:`StartFromEmailDelivery`}:{type:`PromptForDeliveryMethod`};let I=(0,w.useRef)(null),L=v({mode:_,getXToken:x,getToken:S,getMsaToken:T,isNhpAvailable:async()=>(I.current||=await u.bridge.isSupported()&&await u.user.isAvailable().catch(e=>(g.info(`native.user.isAvailable() threw — treating NHP as unavailable: ${(0,C.toError)(e).message}`),!1)),I.current),logger:g,msaVersion:`MSAv1`}),R=async e=>{g.info(`onExit — status: ${e.status}`),await D(e)},z=b(O);return{productId:e,skuId:i,availabilityId:s,giftingFlowConfiguration:F,campaignId:j,optionalCampaignId:M,allowAsyncPurchase:!0,catalogId:N,giftingLaunchStartTime:0,callerApplicationId:`PCGamingApp`,getAuthToken:L,onExit:R,onPurchasePageReady:z,flowId:d,identityMismatch:P}}),O=l(u(()=>{let e=_(),{isReady:t,error:n}=e,r=D.useComponent();if(n)throw n;return t?(0,T.jsx)(E.Provider,{value:e,children:(0,T.jsx)(w.Suspense,{fallback:null,children:(0,T.jsx)(r,{})})}):null},`GiftingPage`)),k=()=>g;export{O as default,k as links};