import{N as k}from"./Navbar.81a8055b.js";import{B as I}from"./BaseLayout.3e9c5fb5.js";import{C as N}from"./ContentLayout.8304a010.js";import{C as _}from"./CrudView.65cddc3d.js";import{a as O}from"./asyncComputed.0b92728b.js";import{F as x}from"./PhArrowSquareOut.vue.649cb0fe.js";import{G as M}from"./PhPencil.vue.6b2a4ecd.js";import{d as R,e4 as h,r as B,c as D,a4 as F,f as o,b as i,u as s,aQ as V,o as f,a as $,cw as j,bI as A,cv as E,h as G,M as L}from"./jwt-decode.esm.f368ea6d.js";import"./router.e92d73ff.js";import{a as m}from"./organization.de45eba6.js";import"./tables.24d02615.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.711a6f48.js";import"./constants.15500ccf.js";import"./PhChats.vue.e80484e6.js";import"./PhSignOut.vue.c2ddd6ef.js";import"./index.6e6b7d7e.js";import"./index.6354eb1c.js";import"./omniChatStore.aba94cbe.js";import"./record.7a582e5f.js";import"./PhSparkle.vue.553f9de1.js";import"./index.64d49170.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.4c12a84b.js";import"./url.036cb91d.js";import"./PhDotsThreeVertical.vue.2c005e69.js";import"./string.cd622100.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},l=new Error().stack;l&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[l]="ac2228db-9b5f-467e-8c8c-6bb5675dbcf7",r._sentryDebugIdIdentifier="sentry-dbid-ac2228db-9b5f-467e-8c8c-6bb5675dbcf7")}catch{}})();const dt=R({__name:"Organizations",setup(r){const l=[{label:"My organizations",path:"/organizations"}],u=[{key:"name",label:"Organization Name"}],g=h(),{loading:b,result:y,refetch:v}=O(()=>m.list()),c=({key:e})=>{g.push({name:"organization",params:{organizationId:e}})},n=B({state:"idle"});function z(e){n.value={state:"renaming",organizationId:e.id,newName:e.name}}async function d(e){if(n.value.state==="renaming"&&e){const{organizationId:t,newName:a}=n.value;await m.rename(t,a),v()}n.value={state:"idle"}}const w=async e=>{const t=await m.create(e.name);c({key:t.id})},C=D(()=>{var e,t;return{columns:[{title:"Organization Name",align:"left"},{title:"Path"},{title:"",align:"right"}],rows:(t=(e=y.value)==null?void 0:e.map(a=>{var p;return{key:a.id,cells:[{type:"link",text:a.name,to:`/organizations/${encodeURIComponent(a.id)}`},{type:"text",text:(p=a.id)!=null?p:null},{type:"actions",actions:[{icon:x,label:"Go to projects",onClick:c},{icon:M,label:"Rename",onClick:()=>z(a)}]}]}}))!=null?t:[]}});return(e,t)=>(f(),F(V,null,[o(I,null,{navbar:i(()=>[o(k,{breadcrumb:l})]),content:i(()=>[o(N,null,{default:i(()=>[o(_,{"entity-name":"organization",loading:s(b),title:"My organizations",description:"An organization is your company\u2019s account. Manage editors, projects and billing.","create-button-text":"Create Organization","empty-title":"No organizations here yet",table:C.value,fields:u,create:w},null,8,["loading","table"])]),_:1})]),_:1}),o(s(L),{open:n.value.state==="renaming",title:"Rename organization",onCancel:t[1]||(t[1]=a=>d(!1)),onOk:t[2]||(t[2]=a=>d(!0))},{default:i(()=>[n.value.state==="renaming"?(f(),$(s(E),{key:0,layout:"vertical"},{default:i(()=>[o(s(j),{label:"New name"},{default:i(()=>[o(s(A),{value:n.value.newName,"onUpdate:value":t[0]||(t[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):G("",!0)]),_:1},8,["open"])],64))}});export{dt as default};
//# sourceMappingURL=Organizations.03bcc26f.js.map
