import{r as N,j as e}from"./vendor-react-wBh_31cN.js";import{u as w,b as z}from"./index.esm-CAGtek53.js";import{dh as B,X as I,G as n,ar as V,aU as i,bn as _,as as f,di as E,bo as K,h as P,cm as S}from"./index-BKr2rJhV.js";import{o as G}from"./yup-XkUC3UEH.js";import{g as p}from"./getInputValidation-CUi6Oel7.js";import{I as t}from"./input-H6_qmzms.js";import{C as U,a as q,b as Y,c as A}from"./card-DISTA6Ay.js";import{F as H}from"./form-footer-CprMCGDT.js";import{T as L}from"./tooltip-Da8-EbK8.js";import{L as M}from"./label-Dnebucx5.js";import{c as b}from"./utils-DSqkOIhq.js";import{u as Q}from"./vendor-router-D1GqFWiT.js";import{O as R}from"./vendor-icons-BUUmD6ht.js";import{l as W}from"./length-DTSUQW_a.js";const X=P(S,W),J=r=>V().shape({projectName:E("consecutiveUnderlines",K.notOneOf(r,"This name already exists").label("Name")),namespace:f().max(63).label("Namespace"),description:i.label("Description"),featureStoreTopic:i,memberEmails:_().of(f().email().optional())}),Z=({isLoading:r,onSubmit:g,onDelete:d,isEdit:o,initialData:s,projectsNames:x=[],isProgressingSubmit:m,isSuccessSubmit:h,progressElement:j})=>{const v=N.useMemo(()=>J(x),[x]),{data:y}=B(),{handleSubmit:T,formState:{errors:a},register:c,control:C}=w({mode:"onTouched",defaultValues:{projectName:s==null?void 0:s.projectName,namespace:s==null?void 0:s.namespace,description:s==null?void 0:s.description,memberEmails:[],featureStoreTopic:s==null?void 0:s.featureStoreTopic},resolver:G(v),shouldUnregister:!1}),l=X(a),u=l===0?"":`${l} error${l>1?"s":""}`,O=Q(),[F,k]=z({name:["projectName","description"],control:C}),{data:$}=I("kube_skip_namespace_creation");return e.jsxs("form",{onSubmit:T(g),className:"flex flex-col gap-5",children:[e.jsxs(U,{children:[e.jsx(q,{children:e.jsx(Y,{children:o?"Edit a project":"Create a New Project"})}),e.jsx(A,{children:(m||h)&&j?j:e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(t,{label:"Name",readOnly:o,autoFocus:!0,...c("projectName"),placeholder:"project_acme",labelAction:e.jsx(L,{content:"Only alphanumeric characters, dash or underscore",side:"right",children:e.jsx(R,{className:"size-3.5 text-quartz-gray"})}),...p("projectName",a)}),e.jsx(t,{label:"Description",...c("description"),placeholder:"project about....",...p("description",a)})]}),y&&e.jsx(t,{label:"Topic name",...c("featureStoreTopic"),placeholder:"featurestore_topic"}),$&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Kubernetes"}),e.jsx(t,{label:"Namespace",readOnly:o,...c("namespace"),placeholder:"Kubernetes pre-created namespace",...p("namespace",a)})]}),o&&d&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:"Danger zone"}),e.jsx(n,{variant:"destructive",disabled:r,onClick:d,children:"Delete the project"})]})]})})]}),e.jsxs(H,{className:"justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-bold",children:b(F||"",24)}),e.jsx("span",{className:"text-xs text-quartz-gray",children:b(k||"",50)}),u&&e.jsx("span",{className:"text-xs text-destructive",children:u})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(n,{type:"button",disabled:r||m,variant:"secondary",onClick:()=>O(-1),children:"Back"}),e.jsx(n,{type:"submit",loading:m,disabled:r||h,children:o?"Edit Project":"Create New Project"})]})]})]})},he=N.memo(Z);export{he as P};
