import{r as d,j as e}from"./vendor-react-wBh_31cN.js";import{j as A}from"./vendor-redux-CJZrIb6x.js";import{J as h}from"./JobsService-DBth4d1H.js";import{g as x,r as f,aq as J}from"./index-BKr2rJhV.js";import{u as y}from"./useTitle-DQo_L6Ox.js";import{a as v,b as w}from"./index-LWIqX2n6.js";import{a as S}from"./index-DdhqPQ_t.js";import{A as C}from"./AgentJobForm-D3vp09Ud.js";import{u as I,c as N}from"./vendor-router-D1GqFWiT.js";import"./vendor-utils-OeoE2qq_.js";import"./vendor-icons-BUUmD6ht.js";import"./vendor-radix-BRyWS4bQ.js";import"./vendor-grid-CeFlDWv4.js";import"./index-CHdS1Zyb.js";import"./utils-C3tzOLw4.js";import"./lensPath-CdufhmA3.js";import"./mergeRight-Cv2eiGXV.js";import"./time-utils-tK1noPML.js";import"./addDays-DjM7nKyN.js";import"./always-CtAmwIxm.js";import"./init-BDcDHUTz.js";import"./concat-AxOj0lUI.js";import"./formatDistance-qDinyJzC.js";import"./join-DatdAzSt.js";import"./includes-D04d5Ytc.js";import"./add-DCChD-X4.js";import"./index.esm-CAGtek53.js";import"./yup-XkUC3UEH.js";import"./alertUtil-MS8PGQKV.js";import"./alertManagerConfUtil-D4yp8Ca8.js";import"./project-eQY1xQe-.js";import"./fileExplorer-BRS7UOt9.js";import"./useDownload-YBz540B0.js";import"./useNotifier-BCEAoFCf.js";import"./notifications-x-pTFTQl.js";import"./toast-3g7Fh-a0.js";import"./useCurrentProject-C6qZaZgv.js";import"./useProject-FSnHbCQX.js";import"./index-BeaoFlb1.js";import"./getPathAndFileName-BId4RGny.js";import"./input-H6_qmzms.js";import"./label-Dnebucx5.js";import"./textarea-Co48BFy3.js";import"./combobox-CcK1PxyF.js";import"./input-group-Z3Qmt3PL.js";import"./vendor-recharts-DmJlpLaF.js";import"./radio-group-D7-g0sv3.js";import"./getInputValidation-CUi6Oel7.js";import"./form-BGlJWZp2.js";import"./converge-BDz-h6lA.js";import"./zipObj-BpJhvpTB.js";import"./pythonUtils-Ci3XE0w8.js";import"./badge-nyizWwTN.js";import"./selectors-CMD4o3wq.js";import"./index-DkvW68Om.js";import"./index-DJIjy7qt.js";import"./uniq-Cy5NeM3Y.js";import"./uniqBy-qYjau2JN.js";import"./useIsJupyterDisabled-W-gx_pSy.js";import"./useHotkeysShortcut-BupQRiR8.js";import"./index-B5BaAmTQ.js";import"./any-Db6pVWyk.js";import"./AlertForm-DTCsNJT8.js";import"./useAlertProjectConfig-BiyOl1hl.js";import"./callout-Dd8FkTQe.js";import"./card-DISTA6Ay.js";import"./icon-button-FETOk6q1.js";import"./separator-2OqrG5Vy.js";import"./CronExpression-D3O-UlpN.js";import"./index--vO3kPD9.js";import"./slicedToArray-BHGdh4W7.js";import"./vendor-markdown-DYw41Xyj.js";import"./checkbox-DbZXziG0.js";import"./tooltip-Da8-EbK8.js";import"./HumanizedCronExpression-D34G4jQt.js";import"./not-CZjOXJzQ.js";import"./CronDetails-DuLrEPPy.js";import"./date-picker-DuYl6sUN.js";import"./popover-DNRIgB96.js";import"./value-76ihWpF6.js";import"./JobsStickySummary-BdQ0UjxJ.js";import"./dumbPluralize-CcxDsNiu.js";import"./ButtonWithRole-BINnbeGr.js";import"./useProjectRole-UlQXu1Cp.js";import"./form-footer-CprMCGDT.js";import"./EnvVarsField-DuIE3Krh.js";import"./ArrayField-DU-w4GBF.js";import"./InjectedEnvVarsPreview-DGEjLZXG.js";import"./EnvVarsService-BrhQRBBu.js";import"./useProjectId-Ck57b-tn.js";const uo=()=>{const a=I(),i=A(),{id:t}=N(),[b,m]=d.useState(!1),{data:s,isLoading:n}=v({projectId:+t}),[c]=w(),[u]=S();y("Create Agent Task");const g=d.useCallback(async(p,r,l)=>{m(!0);try{try{await h.getOneByName(+t,p.appName),m(!1);return}catch{}const{name:o}=await c({pId:t,data:p,name:p.appName}).unwrap();if(o&&r.length>0)try{if(r.length>1){const j={items:r};await i.jobAlert.createBulk({projectId:+t,jobName:o,jobAlert:j,bulk:!0})}else await i.jobAlert.create({projectId:+t,jobName:o,jobAlert:r[0]})}catch{}if(o&&l)try{await u({pId:t,jobName:o,data:l}).unwrap()}catch{}o&&a(x(f.project.agentJobs.overview,f.project.value,{id:t,jobName:o}))}finally{m(!1)}},[t,c,u,i.jobAlert,a]);return n||!s?e.jsx(J,{}):e.jsx("div",{className:"flex flex-col",children:e.jsx(C,{initialData:s,onSubmit:g,isSubmitting:b,isLoading:n,saveButtonText:"Create agent task"})})};export{uo as default};
