import{r as o,j as e}from"./vendor-tanstack-BpuysabX.js";import{u as O,a as k}from"./schema-form-input-string-format-datetime-CtefOb8F.js";import{SchemaForm as w}from"./schema-form-DjXuBlAn.js";import{aD as C,aE as V,aF as p,aG as f,C as i,o as d,bI as u,i as F,L as T}from"./index-CREafGO4.js";function D({baseJobTemplate:n,onBaseJobTemplateChange:l}){const[x,h]=o.useState(()=>JSON.stringify(n||{},null,2)),[c,m]=o.useState(null),s=o.useMemo(()=>n?.variables,[n?.variables]),b=o.useMemo(()=>s?.properties&&Object.keys(s.properties).length>0,[s?.properties]),v=o.useMemo(()=>{if(!s?.properties)return{};const a={};return Object.entries(s.properties).forEach(([r,t])=>{t&&typeof t=="object"&&"default"in t&&(a[r]=t.default)}),a},[s?.properties]),[S,j]=O(v),[N]=k([]),g=o.useCallback(a=>{if(j(a),!s?.properties)return;const r={...n,variables:{...s,properties:Object.fromEntries(Object.entries(s.properties).map(([t,E])=>[t,{...E,default:a[t]}]))}};l(r),h(JSON.stringify(r,null,2))},[n,s,l,j]),y=o.useCallback(a=>{h(a),m(null);try{const r=JSON.parse(a);l(r)}catch(r){m(r instanceof Error?r.message:"Invalid JSON")}},[l]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-2xl font-semibold tracking-tight",children:"Base Job Template"}),e.jsxs(C,{defaultValue:"defaults",className:"w-full",children:[e.jsxs(V,{children:[e.jsx(p,{value:"defaults",children:"Defaults"}),e.jsx(p,{value:"advanced",children:"Advanced"})]}),e.jsx(f,{value:"defaults",className:"space-y-4",children:b?e.jsxs(e.Fragment,{children:[e.jsx(i,{children:e.jsx(d,{children:e.jsx(u,{children:"The fields below control the default values for the base job template. These values can be overridden by deployments."})})}),s&&e.jsx(w,{schema:s,kinds:["json"],values:S,onValuesChange:g,errors:N})]}):e.jsx(i,{children:e.jsx(d,{children:e.jsxs(u,{children:["This work pool's base job template does not have any customizations. To add customizations, edit the base job template directly with the ",e.jsx("strong",{children:"Advanced"})," tab."]})})})}),e.jsxs(f,{value:"advanced",className:"space-y-4",children:[e.jsx(i,{children:e.jsx(d,{children:e.jsxs(u,{children:["This is the JSON representation of the base job template. A work pool's job template controls infrastructure configuration for all flow runs in the work pool, and specifies the configuration that can be overridden by deployments.",e.jsx("br",{}),e.jsx("br",{}),"For more information on the structure of a work pool's base job template, check out the docs."]})})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{children:"Base Job Template JSON"}),e.jsx(T,{value:x,onChange:y,className:c?"border-destructive":""}),c&&e.jsx("p",{className:"text-sm text-destructive",children:c})]})]})]})]})}export{D as B};
//# sourceMappingURL=base-job-template-form-section-BPISCkag.js.map
