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]=`e9c17005-3487-43ef-8eec-0f27ebfd9cc1`,e._sentryDebugIdIdentifier=`sentry-dbid-e9c17005-3487-43ef-8eec-0f27ebfd9cc1`)}catch{}import"./rolldown-runtime-nx40z1zs.js";import{r as e}from"./vendor-misc-dys7qi6h.js";import{Bs as t,Fs as n,Js as r,Xs as i,ac as a,gs as o,ic as s,nc as c,qh as l}from"./entry.client-mpghtlrl.js";import{R as u,z as d}from"./workspace-leaf-files-oergw4h0.js";import{a as f,i as p,s as m}from"./redux-boot-core-pd6f4ovn.js";var h=o(),g=e();n();var _=class extends f{stateKey=d;actions=g.FamilyAction;familyActionType=g.FamilyActionType;familySelectors=(0,g.promoteFamilySelectors)(e=>m(e,this.stateKey));constructor(e,t,n,r,i,a,o){super(e,u,o),this.xblTokenProvider=t,this.acceptableLanguageProvider=n,this.cVProvider=r,this.interceptors=i,this.logger=a,this.reduxEnvironment.registerReducer(this.stateKey,g.familyReducer),this.accountsService=new g.XboxAccountsService(this.xblTokenProvider,this.acceptableLanguageProvider,this.cVProvider,this.interceptors),this.familySagaManager=new g.FamilySagaManager(this.accountsService,this.logger)}destroy(){this.reduxEnvironment.removeReducer(this.stateKey)}*handleActions(){let e=this;yield r([this.familySagaManager.watchForActions(),t(p.UpdateUser,function*(t){try{t?.user?.xuid?yield i([e,e.fetchUserFamilyInfo],t.user.xuid):e.logger.debug(`User is not signed in or has no user family settings`)}catch(t){let n=l(t);e.logger.warn(`Failed to fetch user family settings`,n)}})])}fetchUserFamilyInfo(e){let t=this;return new Promise((n,i)=>t.reduxEnvironment.sagaMiddleware.run(t.name,function*(){if((yield s(t.familySelectors.getCurrentXuid))===e){let e=(0,h.getDataOrPrevious)(yield s(t.familySelectors.getCurrentXuidFamilyInfoStateLCE)),r=(0,h.getDataOrPrevious)(yield s(t.familySelectors.getCurrentIsManagedUserStateLCE));if(e)return n({familyUserData:e,isManagedUser:r})}yield r([c(t.actions.fetchUserFamily.start(e)),a(t=>t.type===g.FamilyActionType.FetchUserFamilyComplete&&t.xuid===e)]);let o=yield s(t.familySelectors.getCurrentXuidFamilyInfoStateLCE);if((0,h.isError)(o)){t.logger.error(`Failed to get user family info in FamilyPlugin`,o.error),i(o.error);return}let l=(0,h.getDataOrPrevious)(o);if(!l){let e=`selectors.getUserFamilyInfo returned undefined but did not have an error.This should never happen and is likely an issue with xbox-family`;t.logger.error(e),i(Error(e));return}let u=yield s(t.familySelectors.getCurrentIsManagedUserStateLCE);if((0,h.isError)(u)){t.logger.error(`Failed to get user isManagedUser in FamilyPlugin`,u.error),i(u.error);return}n({familyUserData:l,isManagedUser:(0,h.getDataOrPrevious)(u)})}))}};export{_ as FamilyPlugin};