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]=`74df28e0-51b4-4dab-b8e0-45f22a2a1ee0`,e._sentryDebugIdIdentifier=`sentry-dbid-74df28e0-51b4-4dab-b8e0-45f22a2a1ee0`)}catch{}import"./rolldown-runtime-nx40z1zs.js";import{Fs as e,Js as t,Lp as n,Qp as r,Xs as i,gs as a,ic as o,qh as s}from"./entry.client-mpghtlrl.js";import{M as c,N as l}from"./workspace-leaf-files-oergw4h0.js";import{a as u,s as d}from"./redux-boot-core-pd6f4ovn.js";import{t as f}from"./dist-gjjoo1y0.js";n();var p=a(),m=f();e();var h=[],g=class extends u{stateKey=l;titleActionType=m.TitleActionType;hasConsumedSignInAction=!1;actions=m.TitleAction;decoratorType=m.TitleDecoratorType;filterType=m.TitleFilterType;titleSelectors=(0,m.promoteTitleSelectors)(e=>d(e,this.stateKey));constructor(e,t,n,r,i,a,o,s,l){super(e,c,l),this.commonSelectors=t,this.xblTokenProvider=n,this.acceptableLanguageProvider=r,this.marketAndLocaleProvider=i,this.cVProvider=a,this.interceptors=o,this.logger=s,this.reduxEnvironment.registerReducer(this.stateKey,m.titleReducer),this.titleService=new m.XblTitleService(this.xblTokenProvider,this.acceptableLanguageProvider,this.marketAndLocaleProvider,this.cVProvider,this.interceptors,this.logger),this.titleStorageService=new m.XblTitleStorageService(this.xblTokenProvider,this.acceptableLanguageProvider,this.marketAndLocaleProvider,this.cVProvider,this.interceptors,this.logger),this.displayCatalogMetadataService=new m.DisplayCatalogMetadataService(this.xblTokenProvider,this.acceptableLanguageProvider,this.cVProvider,this.marketAndLocaleProvider,this.interceptors),this.collectionsService=new m.CollectionsService(this.xblTokenProvider,this.acceptableLanguageProvider,this.cVProvider,i,o),this.titleSagaManager=new m.TitleSagaManager(this.titleService,this.displayCatalogMetadataService,this.collectionsService,this.titleSelectors,this.logger)}destroy(){this.reduxEnvironment.removeReducer(this.stateKey)}*handleActions(){yield t([this.titleSagaManager.watchForActions()])}shouldFetchTitleHistory(){let e=this;return new Promise((t,n)=>e.reduxEnvironment.sagaMiddleware.run(e.name,function*(){try{let n=yield o(e.commonSelectors.getCurrentUser);if(!n?.xuid){t(!0);return}if((0,p.isContent)(yield o(e.titleSelectors.getUserTitleHistory,n.xuid))){t(!1);return}t(!0)}catch(e){n(e)}}))}isTitleHistoryInfoUpToDate(e,t){let n=this;return new Promise((r,i)=>n.reduxEnvironment.sagaMiddleware.run(n.name,function*(){try{r(yield o(n.titleSelectors.isTitleHistoryInfoUpToDate,e,t))}catch(e){i(e)}}))}getUserTitleHistoryInfo(e,t){let n=this;return new Promise((r,i)=>n.reduxEnvironment.sagaMiddleware.run(n.name,function*(){try{let i=yield o(n.titleSelectors.getUserTitleHistoryInfoLCE,e,t);r(n.unwrapLCEContent(i)??null)}catch(e){i(e)}}))}fetchGameSaves(e){let t=this;return new Promise((n,a)=>t.reduxEnvironment.sagaMiddleware.run(t.name,function*(){let c=yield o(t.commonSelectors.getCurrentUser);if(!c?.xuid){let e=`commonSelectors.getCurrentUser returned null. Cannot fetch game saves from title connected storage without a user`;t.logger.error(e),a(Error(e));return}try{n((yield i([t.titleStorageService,t.titleStorageService.getConnectedStorage],c.xuid,e)).blobs)}catch(e){if(e instanceof r&&(`status`in e.response&&e.response.status===404||`statusCode`in e.response&&e.response.statusCode===404))return n(h);let i=s(e);t.logger.error(`titleStorageService.getConnectedStorage failed due to error: ${i.message}`),a(i)}}))}deleteAllGameSaves(e){let t=this;return new Promise((n,r)=>t.reduxEnvironment.sagaMiddleware.run(t.name,function*(){let a=yield o(t.commonSelectors.getCurrentUser);if(!a?.xuid){let e=`commonSelectors.getCurrentUser returned null. Cannot delete title connected storage without a user`;t.logger.error(e),r(Error(e));return}try{yield i([t.titleStorageService,t.titleStorageService.deleteConnectedStorage],a.xuid,e)}catch(e){let n=s(e);t.logger.error(`titleSelectors.deleteAllGameSaves failed due to error: ${n.message}`),r(n);return}n()}))}};export{g as TitlesPlugin};