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]=`a2c06ec9-9879-42bd-86cb-fadb730a8d04`,e._sentryDebugIdIdentifier=`sentry-dbid-a2c06ec9-9879-42bd-86cb-fadb730a8d04`)}catch{}import{o as e}from"./rolldown-runtime-eb2nym32.js";import{R as t}from"./vendor-misc-hfpbxrii.js";import{$d as n,Ag as r,Fg as i,Ig as a,Ym as o,_r as s,dn as c,mh as l,ng as u,np as d,sh as f,st as p,th as m}from"./entry.client-dr7r6s9a.js";import{t as h}from"./commercePreloadLinks-7ptujqoo.js";import{n as g,t as _}from"./createGetAuthToken-gzsh85ms.js";import{t as v}from"./useFlowId-n9vqrww9.js";import{t as y}from"./OffersAndCreditsHost-jfnu7rfh.js";var b=i(),x=d(),S=e(a(),1),C=r(),w=(0,S.createContext)(null),T=c(e=>{let t=(0,b.c)(3),n=y.useComponent(),r;return t[0]!==n||t[1]!==e?(r=(0,C.jsx)(n,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},()=>{let[e]=t(n.external.commerce.offersAndCredits),{getLogger:r}=m(),{adaptor:{native:i}}=f();p();let a=v(),o=(0,S.useContext)(w),s=r(`OffersAndCreditsPage`);if(!o)throw Error(`HostCommunicationContext is required but was not provided`);let{mode:c,getXToken:d,getToken:h,getMsaToken:g}=o;return{getAuthToken:_({mode:c,getXToken:d,getToken:h,getMsaToken:g,isNhpAvailable:()=>i.bridge.isSupported(),logger:s,msaVersion:`MSAv1`}),onOfferRedeemed:async e=>{if(await i.bridge.isSupported()){if(!await i.legacyInterop.isAvailable())throw new u(`native.legacyInterop`);let t=D(e.status);await i.legacyInterop.mutations.reportPurchaseResultV2.isAvailable()&&await i.legacyInterop.mutations.reportPurchaseResultV2.execute({status:t,resultJson:JSON.stringify(e)}),await i.legacyInterop.mutations.reportPurchaseResult.execute({status:t})}},onClose:async()=>{await i.bridge.isSupported()&&await i.legacyInterop.mutations.exitWebExperience.execute({route:x.LegacyInteropValues.ExitWebExperienceRoute.PreviousPage})},flowId:a,sourceClientName:l[e.clientName]}}),E=s(()=>{let e=g({resultReporting:`onExit`}),{isReady:t,error:n}=e,r=T.useComponent();if(n)throw n;return t?(0,C.jsx)(w.Provider,{value:e,children:(0,C.jsx)(S.Suspense,{children:(0,C.jsx)(r,{})})}):null},`OffersAndCreditsPage`),D=e=>{switch(e){case`Succeeded`:return x.LegacyInteropValues.PurchaseResultStatus.Succeeded;case`Canceled`:return x.LegacyInteropValues.PurchaseResultStatus.Canceled;default:return x.LegacyInteropValues.PurchaseResultStatus.Error}},O=o(E),k=()=>h;export{O as default,k as links};