import{aC as F,aD as E,j as n,L as a,bw as D,a as t,aJ as g,p as I,aT as A,f5 as B,hs as J,aX as P,ao as R,ap as W,d as S,bG as y,c7 as z,gJ as M,aH as O,aY as _,dh as L,i as q,u as G,bz as H,ht as X,r as Y,fv as K,B as Q,c as U}from"./index-_eM6l4Nf.js";const T=({schema:r,data:i,children:d,onSubmit:o})=>{const l=F({defaultValues:i,resolver:E(r)});return n.jsx(a,{width:"100%",children:n.jsxs(D,{...l,children:[n.jsx(C,{...l,errors:l.formState.errors,...r.describe()}),o&&n.jsx(t,{width:"100%",justifyContent:"flex-end",children:n.jsx(g,{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:f,meta:s,innerType:c})=>{if(s!=null&&s.hide?s.hide.when(h(I(P("."),J,B(s.hide.prop),A("."))(o))):!1)return n.jsx(a,{sx:{display:"none"}});const $=s!=null&&s.info?n.jsx(R,{mainText:s.info,children:n.jsx(W,{size:"xs",icon:S.info_block})}):null,b={register:l,control:e,getValues:h,watch:x,errors:p,setValue:f},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(V,{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}),$]}),n.jsx(t,{width:"100%",gap:"10px",flexWrap:"wrap",sx:(s==null?void 0:s.sx)??{},children:Object.entries(d).map(([j,k])=>n.jsx(C,{name:o?`${o}.${j}`:j,...b,...k},o?`${o}.${j}`:j))})]}):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(z,{mt:"4px",color:u?"black":"gray",fontWeight:u?"bold":"normal",children:u??"not defined"})]}):r==="boolean"?n.jsx(t,{mb:"10px",children:n.jsx(M,{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(O,{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),..._(o,p)})})},V=r=>{var o;const{fields:i,append:d}=L({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(q,{type:"button",onClick:()=>{d(i[0])},icon:S.plus})]})},N=({configName:r,jobName:i,value:d,setValue:o,name:l,onUpdateSuccess:e})=>{const{id:h}=G(),x=H(),[p,{isLoading:f}]=X(),s=Y.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(g,{onClick:s,isLoading:f,minWidth:"fit-content",intent:"secondary",sx:{color:d.enabled?"labels.red":"primary"},children:d.enabled?"Disable":"Enable"})},Z=(r,i)=>{const d=l=>Q("labels.green",l,{stopped:"labels.red","not-installed":"grayShade2"}),o=K`
  {
    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:Z(i,d)}),r&&n.jsx(U,{ml:"5px",bold:!0,children:r})]}):null;export{N as E,T as F,m as S,C as a};
