import{d,r as l,am as f,i as g}from"./jwt-decode.esm-BJTSBhUK.js";import"./router-JNJkT0FW.js";import{O as c}from"./organization-DbQPClux.js";import"./tables-COuMqsTr.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},r=new Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="1b1edfe7-b9a3-4d68-9bcc-485cdfff7bc6",e._sentryDebugIdIdentifier="sentry-dbid-1b1edfe7-b9a3-4d68-9bcc-485cdfff7bc6")}catch{}})();const I=d("organizationSwitcher",()=>{const e=l([]),r=l(!1),o=async()=>{r.value=!0;try{const a=await c.list();e.value=a.sort((n,t)=>n.name.localeCompare(t.name))}finally{r.value=!1}};return{organizations:e,loading:r,fetchOrganizations:o,renameOrganization:async(a,n)=>{const t=e.value.find(s=>s.id===a);if(!t)return!1;const i=t.name;t.name=n;try{return await c.rename(a,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(),e.value.length===0)return{name:"onboarding"};const a=localStorage.getItem("lastSelectedOrganizationId"),n=a?e.value.find(i=>i.id===a):null;return n?{name:"organization",params:{organizationId:n.id}}:(a&&localStorage.removeItem("lastSelectedOrganizationId"),{name:"organization",params:{organizationId:e.value[0].id}})},selectOrganization:a=>{localStorage.setItem("lastSelectedOrganizationId",a),window.location.href=`/organizations/${a}`}}});export{I as u};
//# sourceMappingURL=organizationSwitcher-BA40_kEX.js.map
