import{aA as k,aB as E,j as n,F as a,bF as A,q as t,aJ as F,p as B,aT as I,f2 as P,ip as R,aX as D,an as M,ao as q,v as g,bl as y,ck as O,bR as W,aH as z,aY as J,du as Y,n as _,u as H,bI as U,iq as X,r as Z,fB as G,E as K,c as L}from"./index-Cox3ZWL0.js";const T=({schema:r,data:i,children:d,onSubmit:o})=>{const l=k({defaultValues:i,resolver:E(r)});return n.jsx(a,{width:"100%",children:n.jsxs(A,{...l,children:[n.jsx(C,{...l,errors:l.formState.errors,...r.describe()}),o&&n.jsx(t,{width:"100%",justifyContent:"flex-end",children:n.jsx(F,{onClick:l.handleSubmit(o),children:"Save"})}),d]})})},C=({type:r,label:i="",fields:d={},name:o="",register:l,control:e,getValues:h,watch:x,errors:p,setValue:j,meta:s,innerType:c})=>{if(s!=null&&s.hide?s.hide.when(h(B(D("."),R,P(s.hide.prop),I("."))(o))):!1)return n.jsx(a,{sx:{display:"none"}});const S=s!=null&&s.info?n.jsx(M,{mainText:s.info,children:n.jsx(q,{size:"xs",icon:g.info_block})}):null,b={register:l,control:e,getValues:h,watch:x,errors:p,setValue:j},u=x(o);return s!=null&&s.customRender?s.customRender({type:r,label:i,fields:d,name:o,innerType:c,...b}):s!=null&&s.CustomComponent?n.jsx(s.CustomComponent,{type:r,label:i,fields:d,name:o,innerType:c,...b}):r==="array"?n.jsx(Q,{type:c.type,label:c.label,meta:c.meta,fields:c.fields??[],name:o,...b}):r==="object"?n.jsxs(a,{sx:(s==null?void 0:s.wrapperSx)??{},children:[i&&n.jsxs(y,{fontSize:"14px",mb:"8px",flexDirection:"row",children:[n.jsx("span",{children:i}),S]}),n.jsx(t,{width:"100%",gap:"10px",flexWrap:"wrap",sx:(s==null?void 0:s.sx)??{},children:Object.entries(d).map(([f,$])=>n.jsx(C,{name:o?`${o}.${f}`:f,...b,...$},o?`${o}.${f}`:f))})]}):s!=null&&s.readonly?n.jsxs(t,{mb:"10px",mr:"10px",flexDirection:"column",width:"150px",children:[n.jsx(y,{color:"gray",children:i}),n.jsx(O,{mt:"4px",color:u?"black":"gray",fontWeight:u?"bold":"normal",children:u??"not defined"})]}):r==="boolean"?n.jsx(t,{mb:"10px",children:n.jsx(W,{colorScheme:"green",readOnly:s==null?void 0:s.disabled,isChecked:u,...l(o),children:n.jsx(y,{color:u?"black":"gray",children:i})})}):n.jsx(t,{mb:"10px",mr:"10px",sx:(s==null?void 0:s.sx)??{},children:n.jsx(z,{label:i,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),...J(o,p)})})},Q=r=>{var o;const{fields:i,append:d}=Y({control:r.control,name:r.name});return n.jsxs(a,{width:"100%",children:[i.map((l,e)=>n.jsx(C,{...r,name:`${r.name}.${e}`},(l==null?void 0:l.id)??e)),((o=r.meta)==null?void 0:o.withAddButton)&&n.jsx(_,{type:"button",onClick:()=>{d(i[0])},icon:g.plus})]})},N=({configName:r,jobName:i,value:d,setValue:o,name:l,onUpdateSuccess:e})=>{const{id:h}=H(),x=U(),[p,{isLoading:j}]=X(),s=Z.useCallback(c=>{c.stopPropagation(),p({pId:h,data:{doNotParse:!0,...d,enabled:!d.enabled},jobName:i}).unwrap().then(()=>{e(),o(l,{...d,enabled:!d.enabled}),x.success({duration:3e3,title:"Success",content:`Config ${r} is ${d.enabled?"paused":"resumed"} successfully`})}).catch(w=>{x.error({title:"Failure",content:`Failed to ${d.enabled?"pause":"resume"} ${r}`})})},[r,h,i,l,x,e,o,p,d]);return n.jsx(F,{onClick:s,isLoading:j,minWidth:"fit-content",intent:"secondary",sx:{color:d.enabled?"labels.red":"primary"},children:d.enabled?"Disable":"Enable"})},V=(r,i)=>{const d=l=>K("labels.green",l,{stopped:"labels.red","not-installed":"grayShade2"}),o=G`
  {
    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:i?"grayShade2":d(r),left:"0px",top:"0.5px",animation:i?`${o} 1.2s infinite`:""}},m=({text:r,variant:i,isLoading:d=!1,sx:o})=>i?n.jsxs(t,{sx:o,justifyContent:"center",children:[n.jsx(a,{sx:V(i,d)}),r&&n.jsx(L,{ml:"5px",bold:!0,children:r})]}):null;export{N as E,T as F,m as S,C as a};
