import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{O as t,k as n}from"./vendor-markdown-DngssFHR.js";import{Q as r,X as i,at as a,b as o,x as s}from"./vendor-mui-Ckcy4Lfd.js";import{a as c,c as l,g as u,o as d,s as f,t as p,v as m}from"./ui-BLXHSX1T.js";import{r as h}from"./index-JB73_g7R.js";var g=e(n(),1),_=t(),v=[{value:`open`,color:`#1976d2`,label:`Open`},{value:`in_progress`,color:`#f57c00`,label:`In Progress`},{value:`done`,color:`#388e3c`,label:`Done`},{value:`cancelled`,color:`#d32f2f`,label:`Cancelled`}],y=[{value:`critical`,label:`Critical`},{value:`high`,label:`High`},{value:`medium`,label:`Medium`},{value:`low`,label:`Low`}];function b({epic:e,onSubmit:t,onCancel:n,submitLabel:b=`Save`}){let[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(``),[T,E]=(0,g.useState)(`open`),[D,O]=(0,g.useState)(`medium`),[k,A]=(0,g.useState)([]),[j,M]=(0,g.useState)(!1),[N,P]=(0,g.useState)(!1);(0,g.useEffect)(()=>{e&&(S(e.title),w(e.description),E(e.status),O(e.priority),A(e.tags??[]))},[e]);let F=async()=>{if(!x.trim()){P(!0);return}M(!0);try{await t({title:x.trim(),description:C.trim(),status:T,priority:D,tags:k})}finally{M(!1)}};return(0,_.jsxs)(r,{component:`form`,id:`epic-form`,onSubmit:e=>{e.preventDefault(),F()},sx:{display:`flex`,flexDirection:`column`,gap:3},children:[(0,_.jsx)(c,{main:(0,_.jsx)(m,{title:`Details`,children:(0,_.jsxs)(r,{sx:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,_.jsx)(d,{fieldLabel:`Title`,required:!0,autoFocus:!0,fullWidth:!0,value:x,onChange:e=>{S(e.target.value),P(!1)},error:N,helperText:N?`Title is required`:void 0}),(0,_.jsxs)(l,{fullWidth:!0,children:[(0,_.jsx)(f,{children:`Description`}),(0,_.jsx)(p,{value:C,onChange:w,height:250})]})]})}),sidebar:(0,_.jsx)(m,{title:`Properties`,children:(0,_.jsxs)(r,{sx:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,_.jsxs)(l,{children:[(0,_.jsx)(f,{children:`Status`}),(0,_.jsx)(o,{fullWidth:!0,value:T,onChange:e=>E(e.target.value),renderValue:e=>{let t=v.find(t=>t.value===e);return(0,_.jsxs)(r,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,_.jsx)(r,{sx:{width:10,height:10,borderRadius:`50%`,bgcolor:t?.color}}),t?.label]})},sx:{"& .MuiSelect-select":{display:`flex`,alignItems:`center`}},children:v.map(e=>(0,_.jsx)(s,{value:e.value,children:(0,_.jsxs)(r,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,_.jsx)(r,{sx:{width:10,height:10,borderRadius:`50%`,bgcolor:e.color}}),e.label]})},e.value))})]}),(0,_.jsxs)(l,{children:[(0,_.jsx)(f,{children:`Priority`}),(0,_.jsx)(o,{fullWidth:!0,value:D,onChange:e=>O(e.target.value),renderValue:e=>{let t=y.find(t=>t.value===e),n=h[e];return(0,_.jsxs)(r,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,_.jsx)(r,{sx:{width:10,height:10,borderRadius:`50%`,bgcolor:n}}),t?.label]})},sx:{"& .MuiSelect-select":{display:`flex`,alignItems:`center`}},children:y.map(e=>(0,_.jsx)(s,{value:e.value,children:(0,_.jsxs)(r,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,_.jsx)(r,{sx:{width:10,height:10,borderRadius:`50%`,bgcolor:h[e.value]}}),e.label]})},e.value))})]}),(0,_.jsx)(l,{fullWidth:!0,children:(0,_.jsx)(u,{tags:k,editable:!0,onAdd:e=>A(t=>t.includes(e)?t:[...t,e]),onRemove:e=>A(t=>t.filter(t=>t!==e))})})]})})}),(0,_.jsxs)(r,{sx:{display:`flex`,gap:1,justifyContent:`flex-end`},children:[(0,_.jsx)(i,{onClick:n,children:`Cancel`}),(0,_.jsx)(i,{variant:`contained`,onClick:F,disabled:j||!x.trim(),children:j?(0,_.jsx)(a,{size:20}):b})]})]})}export{b as t};