const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/OrganizationForm-BgRpNZwN.js","assets/render-C1-Vvny8.js","assets/ImageUpload-DyQPtHbL.js","assets/Button-DTVoBv0Y.js","assets/Paper-CNxaRlIm.js","assets/utils-CF94S7_6.js","assets/Alert-C8jEdKQG.js","assets/IconButton-DuqO9anE.js","assets/Box-BbbSuncO.js","assets/DialogActions-CSfNi6Fl.js","assets/RequiredTextField-BD22n93B.js","assets/TextField-CTe-SAnO.js","assets/formControlState-C86DeWc0.js","assets/utils-DRjCtyoU.js","assets/Select-DMnB-FxS.js","assets/Grow-CU7wvVf-.js","assets/isMuiElement-BP9xBIVK.js","assets/isMuiElement-Dar41GHE.js"])))=>i.map(i=>d[i]);
import{_t as r,lt as s,n as e,t as i,yt as t}from"./render-C1-Vvny8.js";import"./modulepreload-polyfill-BSERo6Ae.js";import{t as o}from"./Grid-D9hUDpXa.js";import{t as a}from"./Box-BbbSuncO.js";import{t as n}from"./Base-CZ-AF-9U.js";import{t as l}from"./Typography-CZowogrb.js";import{t as c}from"./Link-CPZlpzkB.js";import{c as d,t as m}from"./Paper-CNxaRlIm.js";import{t as j}from"./Button-DTVoBv0Y.js";import{t as x}from"./IconButton-DuqO9anE.js";import{t as h}from"./Dialog-q61FLv9_.js";import{t as p}from"./LinearProgress-DUnIJMrN.js";import{t as f}from"./TableContainer-CVhPwe5E.js";import{a as g,i as u,n as b,r as C,t as k}from"./TableCell-Df7cTnCH.js";import{t as z}from"./Alert-C8jEdKQG.js";import{t as y}from"./utils-CF94S7_6.js";import{t as _}from"./Delete-B5t7gZgU.js";import{t as v}from"./Edit-BkK4o9Vu.js";import{t as S}from"./preload-helper-Cwct_fkR.js";import{t as T}from"./Add-CQr9Olgv.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-BgRpNZwN.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,w]=(0,B.useState)(!1),[I,O]=(0,B.useState)(null),[M,N]=(0,B.useState)([]),[P,R]=(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=>{N(r.organizations)}).catch(r=>{})},[P]);const D=r=>{w(!1),R(s=>[...s,r])},$=r=>{},F=document.getElementsByTagName("html")[0],G=s=>{O((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:()=>w(!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&&R(s=>[...s,{deletedOrganizationId:r}])}).catch(r=>{}),w(!1)},children:r.delete})]})]})),w(!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:()=>{O((0,A.jsx)(B.Suspense,{fallback:(0,A.jsx)(a,{sx:{p:2},children:(0,A.jsx)(p,{})}),children:(0,A.jsx)(L,{successCallback:D,failureCallback:$,cancelCallback:()=>w(!1),createMode:!0})})),w(!0)},children:r.add_organization}),M.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:M.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:()=>{O((0,A.jsx)(B.Suspense,{fallback:(0,A.jsx)(a,{sx:{p:2},children:(0,A.jsx)(p,{})}),children:(0,A.jsx)(L,{successCallback:D,failureCallback:$,cancelCallback:()=>w(!1),createMode:!1,initialName:r.name,initialDescription:r.description,initialLogoUrl:r.logo,organizationId:r.id})})),w(!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:()=>w(!1),fullWidth:!0,maxWidth:"sm",children:I})]})},{})});