const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/OrganizationForm-C0JKRQA3.js","assets/render-cqdoDfd9.js","assets/ImageUpload-D80dIRPq.js","assets/Button-D-nJohaT.js","assets/Paper-DtiadJnq.js","assets/utils-C0ZHLGh_.js","assets/Alert-BpUkH7Nx.js","assets/IconButton-BkXELyri.js","assets/Box-pvlRBLzs.js","assets/DialogActions-IskUXpPi.js","assets/RequiredTextField-P1YoYBsM.js","assets/TextField-CbQ6hH_9.js","assets/formControlState-ClbFzec2.js","assets/utils-8Bj6112o.js","assets/Select-BbgK42y1.js","assets/Grow-g9iGpiDr.js","assets/isMuiElement-BOXXIqCm.js","assets/isMuiElement-DqyCXM2X.js"])))=>i.map(i=>d[i]);
import{_t as r,lt as s,n as e,t as i,yt as t}from"./render-cqdoDfd9.js";import"./modulepreload-polyfill-DgzdhEGd.js";import{t as o}from"./Grid-BiwBFfYj.js";import{t as a}from"./Box-pvlRBLzs.js";import{t as n}from"./Base-CUv3vwU4.js";import{t as l}from"./Typography-8v555lWC.js";import{t as c}from"./Link-Bo4Kp619.js";import{c as d,t as m}from"./Paper-DtiadJnq.js";import{t as j}from"./Button-D-nJohaT.js";import{t as x}from"./IconButton-BkXELyri.js";import{t as h}from"./Dialog-BdfDhNhZ.js";import{t as p}from"./LinearProgress-jZTkf1Z2.js";import{t as f}from"./TableContainer-FwpzIaZ5.js";import{a as g,i as u,n as b,r as C,t as k}from"./TableCell-DrJgogcq.js";import{t as z}from"./Alert-BpUkH7Nx.js";import{t as y}from"./utils-C0ZHLGh_.js";import{t as _}from"./Delete-BZeRDRIq.js";import{t as v}from"./Edit-Cm0FSuCS.js";import{t as S}from"./preload-helper-w1h2GTnA.js";import{t as T}from"./Add-DhXv5sLw.js";var A=s(),E=d((0,A.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39"}),"Public"),B=t(r(),1),L=(0,B.lazy)(()=>S(()=>import("./OrganizationForm-C0JKRQA3.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])));i({children:(0,A.jsx)(function(){const{localeMessages:r,direction:s,apiBaseUrl:i,platformBaseUrl:t,isPlatformAdmin:d}=e(),[S,I]=(0,B.useState)(!1),[O,R]=(0,B.useState)(null),[w,D]=(0,B.useState)([]),[M,N]=(0,B.useState)([]);(0,B.useEffect)(()=>{fetch(`${i}/organizations/`,{method:"GET",headers:{"Content-Type":"application/json","X-CSRFToken":y("csrftoken")}}).then(r=>r.json()).then(r=>{D(r.organizations)}).catch(r=>{})},[M]);const P=r=>{I(!1),N(s=>[...s,r])},$=r=>{},F=document.getElementsByTagName("html")[0],G=s=>{R((0,A.jsxs)(a,{sx:{p:2},children:[(0,A.jsx)(l,{variant:"h6",children:r.confirm_deletion}),(0,A.jsx)(z,{severity:"warning",variant:"outlined",sx:{mt:1},children:r.are_you_sure_delete_org.replace("ORGANIZATION_NAME",s.name)}),(0,A.jsxs)(a,{sx:{display:"flex",justifyContent:"flex-end",mt:2},children:[(0,A.jsx)(j,{onClick:()=>I(!1),sx:{mr:1},children:r.cancel}),(0,A.jsx)(j,{variant:"contained",color:"error",onClick:()=>{var r;r=s.id,fetch(`${i}/organizations/${r}/`,{method:"DELETE",headers:{"Content-Type":"application/json","X-CSRFToken":y("csrftoken")}}).then(s=>{s.ok&&N(s=>[...s,{deletedOrganizationId:r}])}).catch(r=>{}),I(!1)},children:r.delete})]})]})),I(!0)};return(0,A.jsxs)(n,{breadCrumbList:[{label:r.organizations,href:"#"}],showOrganizationSwitcher:!1,children:[(0,A.jsx)(o,{size:12,py:2,pl:2,children:(0,A.jsxs)(a,{p:2,sx:{border:"1px solid",borderColor:"border.main",backgroundColor:"background.box",borderRadius:2,minHeight:300},children:[d&&(0,A.jsx)(j,{variant:"contained",startIcon:(0,A.jsx)(T,{sx:{marginLeft:"rtl"==s?1:0}}),sx:{marginBottom:2},onClick:()=>{R((0,A.jsx)(B.Suspense,{fallback:(0,A.jsx)(a,{sx:{p:2},children:(0,A.jsx)(p,{})}),children:(0,A.jsx)(L,{successCallback:P,failureCallback:$,cancelCallback:()=>I(!1),createMode:!0})})),I(!0)},children:r.add_organization}),w.length>0&&(0,A.jsx)(f,{component:m,sx:{maxHeight:440,border:"1px solid",borderColor:"grey.300",borderRadius:1},children:(0,A.jsxs)(g,{children:[(0,A.jsx)(u,{children:(0,A.jsxs)(C,{children:[(0,A.jsx)(k,{dir:F.dir,sx:{textAlign:"rtl"===F.dir?"right":"left"},children:r.name}),(0,A.jsx)(k,{sx:{width:"150px"},children:r.actions})]})}),(0,A.jsx)(b,{children:w.map(r=>(0,A.jsxs)(C,{children:[(0,A.jsx)(k,{dir:F.dir,sx:{textAlign:"rtl"===F.dir?"right":"left"},children:(0,A.jsx)(c,{color:"secondary.dark",href:`${t}/organizations/${r.id}/`,children:r.name})}),(0,A.jsxs)(k,{children:[(0,A.jsx)(x,{onClick:()=>{return s=r.public_url,void window.open(s,"_blank");var s},children:(0,A.jsx)(E,{fontSize:"small"})}),d&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(x,{onClick:()=>{R((0,A.jsx)(B.Suspense,{fallback:(0,A.jsx)(a,{sx:{p:2},children:(0,A.jsx)(p,{})}),children:(0,A.jsx)(L,{successCallback:P,failureCallback:$,cancelCallback:()=>I(!1),createMode:!1,initialName:r.name,initialDescription:r.description,initialLogoUrl:r.logo,organizationId:r.id})})),I(!0)},children:(0,A.jsx)(v,{fontSize:"small"})}),(0,A.jsx)(x,{onClick:()=>G(r),children:(0,A.jsx)(_,{fontSize:"small"})})]})]})]},r.id))})]})})]})}),(0,A.jsx)(h,{open:S,onClose:()=>I(!1),fullWidth:!0,maxWidth:"sm",children:O})]})},{})});