import{l as r,C as o,f,i as g,M as b}from"./index-K2xIZ1TO.js";try{let e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=(new e.Error).stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="c0ac272b-69b6-48d5-a01d-50bd44dd54ce",e._sentryDebugIdIdentifier="sentry-dbid-c0ac272b-69b6-48d5-a01d-50bd44dd54ce")}catch{}async function y(e,s){var t;try{const i=e();if(!i)return r.log("No session stored; continuing without a client"),null;r.log("Using a standalone client");const{user_id:l,device_id:n,access_token:a,passwordlessUser:d}=i,c={baseUrl:o.defaultHomeserverUrl(),accessToken:a,userId:l,deviceId:n,fallbackICEServerAllowed:f,livekitServiceURL:null==(t=o.get().livekit)?void 0:t.livekit_service_url};try{return{widgetApi:null,client:await g(c,!0),passwordlessUser:d}}catch(e){if(e instanceof b&&"M_UNKNOWN_TOKEN"===e.errcode)return r.log("The session from local store is invalid; continuing without a client"),s(),null;throw e}}catch(e){throw s(),e}}export{y as initSPA};