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]=`2a699391-ccec-400b-9492-ff35145948bc`,e._sentryDebugIdIdentifier=`sentry-dbid-2a699391-ccec-400b-9492-ff35145948bc`)}catch{}import"./rolldown-runtime-eb2nym32.js";import{Cp as e,Sp as t,Tp as n,_p as r,cm as i,dm as a,hp as o,ig as s,im as c,lm as l,mm as u,mp as d,om as f,qr as p,wp as m,xp as h,yp as g}from"./entry.client-dr7r6s9a.js";import{i as ee,n as _,r as v,t as y}from"./ActionMetadataError-g7b5a4xs.js";a(),i(),c();var b=t({title:m(),subtitle:m().optional(),icon:m().optional(),tooltip:m().optional(),altText:m().optional()}).passthrough(),x=m(),S=new Set(Object.keys(ee)),C=t({kind:x.refine(e=>!S.has(e),{message:`CommonActionMetadata exclude actions that have their own schema.`}),rank:h(),predicates:d(m()).optional(),display:b}).passthrough(),w=t({productId:m(),skuId:m(),availabilityId:m(),isPreferredSku:o()}).passthrough(),T=b.extend({price:m(),strikethroughPrice:m().nullable()}),E=C.extend({kind:g(v.Buy),data:w,display:T}).strict(),D=t({editions:d(t({productId:m(),productTitle:m(),isCurrentProduct:o()}).passthrough())}).passthrough(),O=C.extend({kind:g(v.EditionsPicker),data:D}).strict(),k=t({}).passthrough().optional(),A=C.extend({kind:g(v.GetReadyToStream),data:k}).strict(),j=t({productId:m(),skuId:m().nullable(),pfn:m().nullable()}).passthrough(),M=C.extend({kind:g(v.Install),data:j}).strict(),N=t({productId:m(),productTitle:m(),xboxTitleId:m().optional()}).passthrough(),P=C.extend({kind:g(v.RequestPermission),data:N}).strict(),F=t({productId:m()}).passthrough(),I=C.extend({kind:g(v.Share),data:F}).strict(),te=t({signInUrl:m().regex(/^\/.*/,`Must be a relative URL starting with /`)}).passthrough(),L=C.extend({kind:g(v.SignIn),data:te}).strict(),R=t({program:m(),entitlementProductId:m().nullable(),xCloudTitleId:m(),contentId:m().nullable()}).passthrough(),z=C.extend({kind:g(v.Stream),data:R}).strict(),B=t({upsellProductId:m(),currentGamePassId:m().nullable()}).passthrough(),V=C.extend({kind:g(v.StreamUpsell),data:B}).strict(),H=t({productId:m(),skuId:m().nullable(),availabilityId:m().nullable()}).passthrough(),U=C.extend({kind:g(v.Upsell),data:H}).strict(),W=t({productId:m(),storePageUrl:m().url()}).passthrough(),G=C.extend({kind:g(v.ViewInStore),data:W}).strict(),K=t({supportedRegionsUrl:m().url()}).passthrough(),q=n([r(`kind`,[E,M,I,L,z,V,U,G,O,A,P,C.extend({kind:g(v.ViewSupportedRegions),data:K}).strict()]),C]),J=t({message:m().min(1),icon:m().min(1).optional(),rank:h()}),Y=t({productActions:d(q),skuActions:e(d(q)),actionMessages:d(J).optional()}),X=n([t({error:t({code:m(),innerCode:m().nullable(),message:m().nullable(),display:t({title:m().nullable(),description:m().nullable()}).nullable()})}),Y]),Z=(e,t)=>{let n=X.parse(t);if(`error`in n)throw new y(e,n.error.code,n.error.innerCode,n.error.message,n.error.display);return n},Q=`https://storepages.xboxservices.com/api/`,ne=6e4,$={ContentType:`Content-Type`,MsApiVersion:`X-MS-API-Version`},re=class{fetch;config;cvProvider;tokenProvider;get baseUrl(){return this.config.baseUrl||Q}constructor(e,t,n,r=globalThis.fetch){this.config=e,this.cvProvider=t,this.tokenProvider=n,this.fetch=u(r,{authenticator:this.tokenProvider?new l(this.tokenProvider,!1):void 0,interceptors:{request:[new f(this.cvProvider)]},timeoutMs:this.config.timeoutMs??ne,responseValidator:()=>!0})}async fetchProductDetailActions(e,t,n){let r=new URL(`details/${e.productId}/actions`,this.baseUrl);r.searchParams.append(`market`,e.market),r.searchParams.append(`language`,e.language),r.searchParams.append(`client`,e.client),e.deviceFamily&&r.searchParams.append(`deviceFamily`,e.deviceFamily),e.platform&&r.searchParams.append(`platform`,e.platform);let i=await this.fetch(r.toString(),{method:`POST`,headers:{[$.MsApiVersion]:`1.0`,[$.ContentType]:`application/json`},body:JSON.stringify({platformCapabilities:t.platformCapabilities||[],enabledFeatures:t.enabledFeatures||[]}),signal:n}),a=await i.json();return Z(i.status,a)}},ie=class{market;locale;service;constructor(e,t,n,r,i={},a=globalThis.fetch){this.market=e,this.locale=t,this.service=new re(i,n,r,a)}async fetchProductDetailActions(e,t,n,r,i,a,o,c){try{return await this.service.fetchProductDetailActions({productId:e,market:this.market,language:this.locale,client:c??p.Edgewater,deviceFamily:t,platform:n},{platformCapabilities:r,enabledFeatures:i},a)}catch(t){let n=s(t),r={};throw _(n)&&(r={status:n.status,code:n.code,innerCode:n.innerCode,message:n.message}),o.error(`fetchProductDetailActions failed for ${e}`,n,r),n}}};export{ie as ProductActionsMetadataServiceAdaptor};