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]=`be6b083a-a535-44f3-b936-d3813bf844cf`,e._sentryDebugIdIdentifier=`sentry-dbid-be6b083a-a535-44f3-b936-d3813bf844cf`)}catch{}import"./rolldown-runtime-nx40z1zs.js";import{Hp as e,Lp as t,Mf as n,Nf as r,Np as i,Pp as a,Rf as o,Uf as s,zf as c}from"./entry.client-mpghtlrl.js";t(),i();var l=c({deviceType:s(),gameplayType:s(),lastTimePlayed:s()}),u=c({currentAchievements:o(),totalAchievements:o(),currentGamerscore:o(),totalGamerscore:o(),progressPercentage:o(),sourceVersion:o()}),d=c({titles:n(c({titleId:s(),name:s().optional().nullable(),isStreamable:r().optional().nullable(),productId:s().optional().nullable(),titleRecord:l.optional().nullable(),achievement:u.optional().nullable()}).passthrough())});function f(e){return d.parse(e).titles}var p=[`Achievement`,`ProductId`],m=[`IsGame`],h=class{authenticatedFetchMap=new WeakMap;get baseUrl(){return this.config.baseUrl??`https://titlehub.xboxlive.com`}constructor(e={},t=globalThis.fetch){this.config=e,this.unenhancedFetch=t}async getUserTitleRecords(e,t){let{xuid:n,tokenProvider:r,decorators:i=p,filters:a=m,maxItems:o,supportedPlatform:s,xCloudOfferings:c}=e,l=this.baseUrl.endsWith(`/`)?this.baseUrl:`${this.baseUrl}/`,u=`users/xuid(${n})/titles/titleRecord${i.length>0?`/decoration/${i.join(`,`)}`:``}`,d=new URL(u,l);a.length>0&&d.searchParams.set(`filterTo`,a.join(`,`)),o!=null&&d.searchParams.set(`maxItems`,o.toString()),s&&d.searchParams.set(`supportedPlatform`,s),c&&d.searchParams.set(`xCloudOfferings`,c);let h=await this.composeAuthenticatedFetch(r)(d.toString(),{method:`GET`,headers:{"x-xbl-contract-version":`2`,Accept:`application/json`},signal:t?.signal});if(!h.ok){let e=``;try{e=await h.text()}catch{}throw Error(`TitleHub getUserTitleRecords failed: ${h.status} ${h.statusText}${e?` — ${e}`:``}`)}return f(await h.json())}composeAuthenticatedFetch(t){let n=this.authenticatedFetchMap.get(t);if(n)return n;let r=e(this.unenhancedFetch,{authenticator:new a(t,!1),timeoutMs:this.config.timeoutMs});return this.authenticatedFetchMap.set(t,r),r}};export{h as TitleRecordsService};