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]=`c3d1e7c8-b46d-4bb4-b17d-ff6714cd722e`,e._sentryDebugIdIdentifier=`sentry-dbid-c3d1e7c8-b46d-4bb4-b17d-ff6714cd722e`)}catch{}import"./rolldown-runtime-nx40z1zs.js";import{Ap as e,Dp as t,Ff as n,Gf as r,Hp as i,Lp as a,Mf as o,Np as s,Pp as c,Uf as l,zf as u}from"./entry.client-mpghtlrl.js";a(),s(),t();var d=u({offerId:l(),offerStatus:n([`available`,`unavailable`,`claimed`]),resourceType:n([`store-token`,`external-link`]),resource:l().nullish(),claimedDate:l().nullish()}),f=u({offers:o(r())});function p(e){return{offerId:e.offerId.toUpperCase(),offerStatus:e.offerStatus,resourceType:e.resourceType,resource:e.resource??void 0,claimedDate:e.claimedDate??void 0}}function m(e,t){let n=f.parse(e),r=[];for(let e of n.offers)try{let t=d.parse(e);r.push(p(t))}catch(n){t?.(e,n)}return r}function h(e){return p(d.parse(e))}var g=`https://gamepassperks.xboxservices.com/`,_=3,v=class{get baseUrl(){return this.config.baseUrl??g}constructor(t,n,r,a=globalThis.fetch){this.config=t,this.authenticatedFetch=i(a,{authenticator:new c(r,!0),interceptors:{request:[new e(n)]},timeoutMs:t.timeoutMs,maxRetries:t.maxRetries??_})}async fetchPerkOffers(e,t){let n=new URL(`v2/offers`,this.baseUrl);return m(await(await this.authenticatedFetch(n.toString(),{method:`GET`,headers:{"Content-Type":`application/json`},signal:t?.signal})).json(),e)}async claimPerkOffer(e,t){let n=new URL(`v2/offers/${encodeURIComponent(e)}`,this.baseUrl);return h(await(await this.authenticatedFetch(n.toString(),{method:`POST`,headers:{"Content-Type":`application/json`},signal:t?.signal})).json())}};export{v as GamePassProfileService};