import{aC as k,aD as F,j as n,L as b,$ as h,b1 as C,p as E,aI as D,f1 as I,he as A,aM as B,ao as M,ap as R,C as S,bG as j,c7 as z,gE as O,b2 as P,aN as W,dh as _,i as J,u as L,bz as q,hf as G,r as Y,ft as H,B as K,c as Q}from"./index-Cc-6WbPt.js";const V=({schema:r,data:d,onSubmit:i})=>{const o=k({defaultValues:d,resolver:F(r)});return n.jsxs(b,{width:"100%",children:[n.jsx(y,{...o,errors:o.formState.errors,...r.describe()}),i&&n.jsx(h,{width:"100%",justifyContent:"flex-end",children:n.jsx(C,{onClick:o.handleSubmit(i),children:"Save"})})]})},y=({type:r,label:d="",fields:i={},name:o="",register:l,control:t,getValues:x,watch:p,errors:u,setValue:f,meta:s,innerType:e})=>{if(s!=null&&s.hide?s.hide.when(x(E(B("."),A,I(s.hide.prop),D("."))(o))):!1)return n.jsx("span",{style:{display:"none"}});const g=s!=null&&s.info?n.jsx(M,{mainText:s.info,children:n.jsx(R,{size:"xs",icon:S.info_block})}):null,a={register:l,control:t,getValues:x,watch:p,errors:u,setValue:f};if(s!=null&&s.customRender)return s.customRender({type:r,label:d,fields:i,name:o,innerType:e,...a});if(s!=null&&s.CustomComponent)return n.jsx(s.CustomComponent,{type:r,label:d,fields:i,name:o,innerType:e,...a});if(r==="array")return n.jsx(U,{type:e.type,label:e.label,meta:e.meta,fields:e.fields??[],name:o,...a});if(r==="object")return n.jsxs(b,{sx:(s==null?void 0:s.wrapperSx)??{},children:[n.jsxs(j,{fontSize:"14px",mb:"8px",flexDirection:"row",children:[n.jsx("span",{children:d}),g]}),n.jsx(h,{width:"100%",gap:"10px",flexWrap:"wrap",sx:(s==null?void 0:s.sx)??{},children:Object.entries(i).map(([c,w])=>n.jsx(y,{name:o?`${o}.${c}`:c,...a,...w},o?`${o}.${c}`:c))})]});if(s!=null&&s.readonly){const c=x(o);return n.jsxs(h,{mb:"10px",mr:"10px",flexDirection:"column",width:"150px",children:[n.jsx(j,{color:"gray",children:d}),n.jsx(z,{mt:"4px",color:c?"black":"gray",fontWeight:c?"bold":"normal",children:c??"not defined"})]})}if(r==="boolean"){const c=x(o);return n.jsx(h,{mb:"10px",children:n.jsx(O,{colorScheme:"green",readOnly:s==null?void 0:s.disabled,isChecked:c,children:n.jsx(j,{color:c?"black":"gray",children:d})})})}return n.jsx(h,{mb:"10px",mr:"10px",sx:(s==null?void 0:s.sx)??{},children:n.jsx(P,{label:d,type:r==="number"?r:s==null?void 0:s.type,disabled:s==null?void 0:s.disabled,readonly:s==null?void 0:s.readonly,tooltipInfo:s==null?void 0:s.info,...l(o),...W(o,u)})})},U=r=>{var o;const{fields:d,append:i}=_({control:r.control,name:r.name});return n.jsxs(b,{width:"100%",children:[d.map((l,t)=>n.jsx(y,{...r,name:`${r.name}.${t}`},(l==null?void 0:l.id)??t)),((o=r.meta)==null?void 0:o.withAddButton)&&n.jsx(J,{type:"button",onClick:()=>{i(d[0])},icon:S.plus})]})},v=({configName:r,jobName:d,value:i,setValue:o,name:l,onUpdateSuccess:t})=>{const{id:x}=L(),p=q(),[u,{isLoading:f}]=G(),s=Y.useCallback(e=>{e.stopPropagation(),u({pId:x,data:{doNotParse:!0,...i,enabled:!i.enabled},jobName:d}).unwrap().then(()=>{t(),o(l,{...i,enabled:!i.enabled}),p.success({duration:3e3,title:"Success",content:`Config ${r} is ${i.enabled?"paused":"resumed"} successfully`})}).catch($=>{p.error({title:"Failure",content:`Failed to ${i.enabled?"pause":"resume"} ${r}`})})},[r,x,d,l,p,t,o,u,i]);return n.jsx(C,{onClick:s,isLoading:f,minWidth:"fit-content",intent:"secondary",sx:{color:i.enabled?"labels.red":"primary"},children:i.enabled?"Disable":"Enable"})},X=(r,d)=>{const i=l=>K("labels.green",l,{stopped:"labels.red","not-installed":"grayShade2"}),o=H`
  {
    8.33% { opacity: 1; }
    50% { opacity: 0.1; }
    58.33% { opacity: 0.1; }
    100% { opacity: 1; }
  }
`;return{bg:"transparent",width:"14px",height:"14px",borderRadius:"50%",flex:"none",backgroundColor:d?"grayShade2":i(r),left:"0px",top:"0.5px",animation:d?`${o} 1.2s infinite`:""}},N=({text:r,variant:d,isLoading:i=!1,sx:o})=>d?n.jsxs(h,{sx:o,justifyContent:"center",children:[n.jsx(b,{sx:X(d,i)}),r&&n.jsx(Q,{ml:"5px",bold:!0,children:r})]}):null;export{v as E,V as F,N as S,y as a};
