import{r as N,fg as C,aA as E,aB as S,bx as V,bd as w,T as F,j as e,f as I,q as j,aH as t,aY as p,an as K,ao as z,v as A,bS as G,bl as W,aJ as m,bz as Y,bA as q,dr as b,Z as H,$ as f,co as J,as as i,fh as M,dt as R,p as U,fi as Z,eE as Q}from"./index-DHiyXWqE.js";const L=U(Z,Q),X=r=>H().shape({projectName:M("consecutiveUnderlines",R.notOneOf(r,"This name already exists").label("Name")),namespace:i().max(63).label("Namespace"),description:f.label("Description"),featureStoreTopic:f,memberEmails:J().of(i().email().optional())}),D=({isLoading:r,onSubmit:T,onDelete:d,isEdit:o,initialData:s,projectsNames:h=[],isProgressingSubmit:n,isSuccessSubmit:u,progressElement:x})=>{const y=N.useMemo(()=>X(h),[h]),{data:O}=C(),{handleSubmit:$,formState:{errors:a},register:c,control:k}=E({mode:"onTouched",defaultValues:{projectName:s==null?void 0:s.projectName,namespace:s==null?void 0:s.namespace,description:s==null?void 0:s.description,membersEmails:[],featureStoreTopic:s==null?void 0:s.featureStoreTopic},resolver:S(y),shouldUnregister:!1}),l=L(a),P=l===0?"":`${l} error${l>1?"s":""}`,_=V(),[g,v]=w({name:["projectName","description"],control:k}),{data:B}=F("kube_skip_namespace_creation");return e.jsxs("form",{onSubmit:$(T),children:[e.jsx(I,{title:o?"Edit a project":"Create a New Project",mb:"100px",children:(n||u)&&x?x:e.jsxs(j,{flexDirection:"column",children:[e.jsxs(j,{children:[e.jsx(t,{label:"Name",readOnly:o,autoFocus:!0,...c("projectName"),placeholder:"project_acme",labelAction:e.jsx(K,{mainText:"Only alphanumeric characters, dash or underscore",position:"right",children:e.jsx(z,{ml:"5px",size:"xs",icon:A.info_block})}),...p("projectName",a)}),e.jsx(t,{labelProps:{ml:"20px",flex:1},label:"Description",...c("description"),placeholder:"project about....",...p("description",a)})]}),O&&e.jsx(t,{label:"Topic name",tooltipInfo:"The default Kafka topic used for data ingestion in the project.",...c("featureStoreTopic"),placeholder:"featurestore_topic"}),B&&e.jsxs(e.Fragment,{children:[e.jsx(G,{legend:"Kubernetes"}),e.jsx(t,{labelProps:{flex:1},label:"Namespace",readOnly:o,...c("namespace"),placeholder:"Kubernetes pre-created namespace",...p("namespace",a)})]}),o&&d&&e.jsx(W,{text:"Danger zone",width:"fit-content",mt:0,children:e.jsx(m,{intent:"alert",disabled:r,onClick:d,children:"Delete the project"})})]})}),e.jsx(Y,{sx:{maxWidth:`var(${q})`},title:b(g||"",24),firstValue:b(v||"",50),mainButton:e.jsx(m,{type:"submit",isLoading:n,disabled:r||u,intent:"primary",children:o?"Edit Project":"Create New Project"}),secondaryButton:e.jsx(m,{type:"button",disabled:r||n,intent:"secondary",onClick:()=>_(-1),children:"Back"}),hasScrollOnScreen:!1,errorsValue:P})]})},se=N.memo(D);export{se as P};
