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-Cg7WCESf.js";import{g as x,r as f,aq as J}from"./index-dNe6i2rS.js";import{u as y}from"./useTitle-DQo_L6Ox.js";import{a as v,b as w}from"./index-DSiF_QgS.js";import{a as S}from"./index-dHd2aGu6.js";import{A as C}from"./AgentJobForm-IlwDt_CS.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-DlAh4Ixf.js";import"./utils-C3tzOLw4.js";import"./lensPath-D2xKReso.js";import"./mergeRight-D1nsCm60.js";import"./time-utils-CQYZ5msB.js";import"./addDays-Cdit4yPz.js";import"./always-oSAuSdys.js";import"./init-Dq_gEBi9.js";import"./concat-CTXo1gGM.js";import"./formatDistance-B6o-SXVU.js";import"./join-oazOKFfj.js";import"./includes-ucXR_9jq.js";import"./add-SI0q72Q7.js";import"./index.esm-CAGtek53.js";import"./yup-XkUC3UEH.js";import"./alertUtil-rW93jnda.js";import"./alertManagerConfUtil-D4yp8Ca8.js";import"./project-eQY1xQe-.js";import"./fileExplorer-DEDqs5DH.js";import"./useDownload-TmtSNiQ3.js";import"./useNotifier-BGMn6HaH.js";import"./notifications-5miqOdlG.js";import"./toast-wiGcevcF.js";import"./useCurrentProject-CTMLbmkf.js";import"./useProject-BbrP3CX5.js";import"./index-DURBtSjL.js";import"./getPathAndFileName-BId4RGny.js";import"./input-DFI7JniT.js";import"./label-gPWmc6ow.js";import"./textarea-BJVuSob1.js";import"./combobox-QqI9aNup.js";import"./input-group-gxy3DSmS.js";import"./vendor-recharts-DmJlpLaF.js";import"./radio-group-CjbLFQxV.js";import"./getInputValidation-B3ahFDSx.js";import"./form-HTA58iI5.js";import"./converge-D7u3m7i4.js";import"./zipObj-C8Moen4w.js";import"./pythonUtils-DP4NidfK.js";import"./badge-UCnweWGd.js";import"./selectors-DK1_X0Cd.js";import"./index-DLI8oDiK.js";import"./index-DnLCKZiK.js";import"./uniq--Ej6WwWR.js";import"./uniqBy-6oWnYXMs.js";import"./useIsJupyterDisabled-BBwxBxqL.js";import"./useHotkeysShortcut-CVWmK5fW.js";import"./index-_Tes9c9v.js";import"./any-BVxDk2A0.js";import"./AlertForm-RAL_VVxo.js";import"./useAlertProjectConfig-DHF-bkkD.js";import"./callout-BFSXVeMz.js";import"./card-BeQtvmcJ.js";import"./icon-button-BZeFL7T7.js";import"./separator-CxqNNMXg.js";import"./CronExpression-B_Y2jRUi.js";import"./index--vO3kPD9.js";import"./slicedToArray-BHGdh4W7.js";import"./vendor-markdown-DYw41Xyj.js";import"./checkbox-BlA4MwH9.js";import"./tooltip-DFFgUYh6.js";import"./HumanizedCronExpression-BsPK2pda.js";import"./not-C0YaysLC.js";import"./CronDetails-DOXCedRS.js";import"./date-picker-K4pHuu1h.js";import"./popover-BzVbz_d3.js";import"./value-7N0Keti9.js";import"./JobsStickySummary-61Sh8wOK.js";import"./dumbPluralize-CcxDsNiu.js";import"./ButtonWithRole-ruQLmPtQ.js";import"./useProjectRole-DpUIGfh9.js";import"./form-footer-Drg8-unW.js";import"./EnvVarsField-Dpnn8U9X.js";import"./ArrayField-DnSSsYNA.js";import"./InjectedEnvVarsPreview-CPNXA8Je.js";import"./EnvVarsService-4OFfVS_Z.js";import"./useProjectId-DeuaOE3U.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};
