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