import{d,r as l,aj as f,i as g}from"./jwt-decode.esm-Dzy-9m8i.js";import"./router-DFKMVA7Q.js";import{O as c}from"./organization-ZhAJhUgH.js";import"./tables-B--iEE7v.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},r=new Error().stack;r&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[r]="11fb8aa2-cc91-4784-b6a1-fc73975f8a73",a._sentryDebugIdIdentifier="sentry-dbid-11fb8aa2-cc91-4784-b6a1-fc73975f8a73")}catch{}})();const I=d("organizationSwitcher",()=>{const a=l([]),r=l(!1),o=async()=>{r.value=!0;try{const e=await c.list();a.value=e.sort((n,t)=>n.name.localeCompare(t.name))}finally{r.value=!1}};return{organizations:a,loading:r,fetchOrganizations:o,renameOrganization:async(e,n)=>{const t=a.value.find(s=>s.id===e);if(!t)return!1;const i=t.name;t.name=n;try{return await c.rename(e,n),!0}catch(s){return t.name=i,f.error(g.translate("i18n_breadcrumb_rename_error")),console.error("Failed to rename organization",s),!1}},selectDefaultOrganization:async()=>{if(await o(),a.value.length===0)return{name:"onboarding"};const e=localStorage.getItem("lastSelectedOrganizationId"),n=e?a.value.find(i=>i.id===e):null;return n?{name:"organization",params:{organizationId:n.id}}:(e&&localStorage.removeItem("lastSelectedOrganizationId"),{name:"organization",params:{organizationId:a.value[0].id}})},selectOrganization:e=>{localStorage.setItem("lastSelectedOrganizationId",e),window.location.href=`/organizations/${e}`}}});export{I as u};
//# sourceMappingURL=organizationSwitcher-Dx4c2c2j.js.map
