import{L as $}from"./tasksController.59a3734d.js";import{d as k,e as f,o as y,c as b,w as u,b as l,u as r,bL as I,cz as _,cy as w,f as v,Y as R,aB as x,ea as C,z as D}from"./index.3d66ab3f.js";import{a as W}from"./asyncComputed.3e41b686.js";import"./linters.705b4c8d.js";import{S as A}from"./scripts.2b967385.js";import{W as B}from"./workspaces.2f5f2521.js";import{R as L,_ as N}from"./RuntimeCommonSettings.5929bb97.js";import{_ as P}from"./RunButton.vue_vue_type_script_setup_true_lang.69c055f2.js";import"./gateway.c90c4cc0.js";import"./popupNotifcation.f439583b.js";import"./polling.e86ace50.js";import"./string.4c6457d7.js";import"./record.20acbd16.js";import"./workspaceStore.65715da4.js";import"./url.64c961af.js";import"./colorHelpers.a7cf0bfe.js";import"./BaseLayout.05adf1e1.js";import"./SaveButton.796777f9.js";import"./UnsavedChangesHandler.28b78bc5.js";import"./ExclamationCircleOutlined.1e0a2d84.js";import"./uuid.c0cdde4d.js";import"./NavbarControls.73dcaefb.js";import"./index.2a5e7e41.js";import"./CloseCircleOutlined.3c144717.js";import"./index.6ecc1e6a.js";import"./editor.497a128c.js";import"./PhArrowSquareOut.vue.635a2852.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.945c4045.js";import"./BookOutlined.e97635c4.js";import"./PhChats.vue.7fe9b11a.js";import"./AbstraLogo.vue_vue_type_script_setup_true_lang.9a130d90.js";import"./Logo.eeb531c5.js";import"./ant-design.ad3f7270.js";import"./ai.5fd8da7e.js";import"./PhCheckCircle.vue.948fa80d.js";import"./PhCopySimple.vue.9dc75d10.js";import"./Avatar.3702ea95.js";import"./LoadingOutlined.7160f40d.js";import"./Card.a639eb0c.js";import"./TabPane.6d18ecdb.js";import"./PhCaretRight.vue.1bc9c933.js";import"./Badge.51abc7fa.js";import"./PhFolder.vue.7f6a2c43.js";import"./PhPencil.vue.2048d912.js";import"./validations.41d9b1df.js";import"./toggleHighContrast.0cd37582.js";import"./TasksManager.dfdde525.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.1dcba02c.js";import"./index.fd3ad7a8.js";import"./CollapsePanel.ff44a7db.js";import"./index.7353fe79.js";import"./index.d6f333ee.js";import"./index.56cb97c5.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},p=new Error().stack;p&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[p]="47405cc2-43bf-4491-99a6-7ccc0fb988b6",i._sentryDebugIdIdentifier="sentry-dbid-47405cc2-43bf-4491-99a6-7ccc0fb988b6")}catch{}})();const E=k({__name:"ScriptSettings",props:{script:{}},setup(i){const e=f(i.script);return(d,s)=>(y(),b(r(w),{layout:"vertical",style:{"padding-bottom":"50px"}},{default:u(()=>[l(r(_),{label:"Name",required:""},{default:u(()=>[l(r(I),{value:e.value.title,"onUpdate:value":s[0]||(s[0]=c=>e.value.title=c)},null,8,["value"])]),_:1}),l(L,{runtime:e.value},null,8,["runtime"])]),_:1}))}}),z={style:{width:"100%",display:"flex","flex-direction":"column"}},F=k({__name:"ScriptTester",props:{script:{},disabledWarning:{},tasks:{}},emits:["refetch-tasks"],setup(i,{emit:p}){const e=i,d=v(()=>{var t,a;return(a=(t=e.tasks)==null?void 0:t.map(m=>{const S=m.payload,g=JSON.stringify(S,null,2),h=g.length>80?g.slice(0,80)+"...":g,T=new Date(m.created.at).toLocaleString();return{label:`${h} - ${T}`,value:m.id}}))!=null?a:[]}),s=f(void 0),c=v(()=>s.value?null:{title:"No trigger task selected",message:"Please select the task that will trigger the script"}),o=f(!1),n=async()=>{var t;o.value=!0;try{await e.script.run((t=s.value)!=null?t:null)}finally{o.value=!1,s.value=void 0,p("refetch-tasks",e.script.id)}};return(t,a)=>(y(),R("div",z,[l(r(w),{layout:"vertical",style:{overflow:"auto"}},{default:u(()=>[l(r(_),{label:"Trigger task"},{default:u(()=>[l(r(x),{options:d.value,value:s.value,onSelect:a[0]||(a[0]=m=>s.value=m)},null,8,["options","value"])]),_:1})]),_:1}),l(P,{loading:o.value,disabled:t.disabledWarning||c.value,onClick:n,onSave:a[1]||(a[1]=m=>t.script.save())},null,8,["loading","disabled"])]))}}),Mt=k({__name:"ScriptEditor",setup(i){const p=C(),e=f(null),d=new $,s=v(()=>{var n;return(n=o.value)!=null&&n.script.hasChanges()?{title:"Unsaved changes",message:"Save the form before running the workflow"}:null}),c=async n=>{const t=await d.getStageTasks(n);e.value=t.tasks.filter(a=>a.status==="pending")},{result:o}=W(async()=>{const[n,t]=await Promise.all([B.get(),A.get(p.params.id)]);return c(t.id),D({workspace:n,script:t})});return(n,t)=>(y(),b(N,{stage:r(o).script,workspace:r(o).workspace,"stage-type":"scripts",onRefetchTasks:t[0]||(t[0]=a=>c(r(o).script.id))},{settings:u(()=>[l(E,{script:r(o).script},null,8,["script"])]),test:u(()=>[l(F,{ref:"tester",script:r(o).script,"disabled-warning":s.value,tasks:e.value,onRefetchTasks:c},null,8,["script","disabled-warning","tasks"])]),_:1},8,["stage","workspace"]))}});export{Mt as default};
//# sourceMappingURL=ScriptEditor.1943fc59.js.map
