import{vt as e}from"./mui-BgU4WrXF.js";import{l as t,u as n}from"./IconButton-oialqkv3.js";import{t as r}from"./Container-fY8-hTkD.js";import{t as i}from"./Skeleton-DLSq3aej.js";import{i as a,n as o,r as s}from"./ExpandMore-D0ycvrdR.js";import{t as c}from"./Typography-7EcQ2i3p.js";import{n as l}from"./MenuItem-BNgF7Xqv.js";import{t as u}from"./TextField-DctlzLY-.js";import{Ut as d,ct as f,pt as p,st as m,w as h}from"./index-bel1r0Sr.js";import{t as g}from"./useSettingsStyles-Bugi6oTj.js";var _=e(),v=({children:e,endpoint:v,item:y,setItem:b,defaultItem:x,validate:S,onItemSaved:C,menu:w,breadcrumbs:T})=>{let E=t(),{classes:D}=g(),O=p(),{id:k}=n();m(async({signal:e})=>{y||b(k?await(await h(`/api/${v}/${k}`,{signal:e})).json():x||{})},[k,y,x,v,b]);let A=f(async()=>{let e=`/api/${v}`;k&&(e+=`/${k}`);let t=await h(e,{method:k?`PUT`:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(y)});C&&C(await t.json()),E(-1)});return(0,_.jsx)(l,{menu:w,breadcrumbs:T,children:(0,_.jsxs)(r,{maxWidth:`xs`,className:D.container,children:[y?e:(0,_.jsxs)(a,{defaultExpanded:!0,children:[(0,_.jsx)(o,{children:(0,_.jsx)(c,{variant:`subtitle1`,children:(0,_.jsx)(i,{width:`10em`})})}),(0,_.jsx)(s,{children:[...[,,,]].map((e,t)=>(0,_.jsx)(i,{width:`100%`,children:(0,_.jsx)(u,{})},-t))})]}),(0,_.jsxs)(`div`,{className:D.buttons,children:[(0,_.jsx)(d,{color:`primary`,variant:`outlined`,onClick:()=>E(-1),disabled:!y,children:O(`sharedCancel`)}),(0,_.jsx)(d,{color:`primary`,variant:`contained`,onClick:A,disabled:!y||!S(),children:O(`sharedSave`)})]})]})})};export{v as t};