import{L as $}from"./tasksController.c0cc912e.js";import{d as k,e as f,o as y,c as _,w as u,b as l,u as r,bL as I,cz as w,cy as b,f as v,Y as R,aB as x,ea as C,z as D}from"./index.c4f9f025.js";import{a as W}from"./asyncComputed.bfad5b5f.js";import"./linters.cd09d15a.js";import{S as A}from"./scripts.5a5dc9ce.js";import{W as B}from"./workspaces.8642e7e0.js";import{R as L,_ as N}from"./RuntimeCommonSettings.2f268075.js";import{_ as P}from"./RunButton.vue_vue_type_script_setup_true_lang.61f39b48.js";import"./gateway.408bdde1.js";import"./popupNotifcation.ebc30b56.js";import"./polling.19d6afa8.js";import"./string.45b9e9dc.js";import"./record.8b302d80.js";import"./workspaceStore.66fb9534.js";import"./url.b319ee4d.js";import"./colorHelpers.4725e4d8.js";import"./BaseLayout.902b23e4.js";import"./SaveButton.e6b204c5.js";import"./UnsavedChangesHandler.b2721048.js";import"./ExclamationCircleOutlined.d86a7477.js";import"./uuid.9767511d.js";import"./NavbarControls.039f7c77.js";import"./index.c251cf6d.js";import"./CloseCircleOutlined.4fbdc40d.js";import"./index.8a59a397.js";import"./editor.4c7a74a9.js";import"./PhArrowSquareOut.vue.4197b0db.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.00c3f4e2.js";import"./BookOutlined.ec23cf35.js";import"./PhChats.vue.2f9c30e2.js";import"./AbstraLogo.vue_vue_type_script_setup_true_lang.b545f514.js";import"./Logo.88222daa.js";import"./ant-design.b662a793.js";import"./ai.ee3576b4.js";import"./PhCheckCircle.vue.72f78588.js";import"./PhCopySimple.vue.c7cb64bd.js";import"./Avatar.9bb6d17c.js";import"./LoadingOutlined.7c61f089.js";import"./Card.b2dea59d.js";import"./TabPane.4690ebe8.js";import"./PhCaretRight.vue.588cb449.js";import"./Badge.f662d019.js";import"./SourceCode.22c16c27.js";import"./validations.9166be01.js";import"./PhFolder.vue.ef04e782.js";import"./toggleHighContrast.63e5940d.js";import"./TasksManager.f4df988f.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.54c4b6d6.js";import"./index.a6857b13.js";import"./CollapsePanel.3b1ab867.js";import"./index.64837d8a.js";import"./index.204ccab6.js";import"./index.fc2acfdf.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]="39638e7a-0d9a-4573-a223-3d86028850c9",i._sentryDebugIdIdentifier="sentry-dbid-39638e7a-0d9a-4573-a223-3d86028850c9")}catch{}})();const E=k({__name:"ScriptSettings",props:{script:{}},setup(i){const e=f(i.script);return(d,s)=>(y(),_(r(b),{layout:"vertical",style:{"padding-bottom":"50px"}},{default:u(()=>[l(r(w),{label:"Name",required:""},{default:u(()=>[l(r(I),{value:e.value.title,"onUpdate:value":s[0]||(s[0]=m=>e.value.title=m)},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,o;return(o=(t=e.tasks)==null?void 0:t.map(c=>{const S=c.payload,g=JSON.stringify(S,null,2),h=g.length>80?g.slice(0,80)+"...":g,T=new Date(c.created.at).toLocaleString();return{label:`${h} - ${T}`,value:c.id}}))!=null?o:[]}),s=f(void 0),m=v(()=>s.value?null:{title:"No trigger task selected",message:"Please select the task that will trigger the script"}),a=f(!1),n=async()=>{var t;a.value=!0;try{await e.script.run((t=s.value)!=null?t:null)}finally{a.value=!1,s.value=void 0,p("refetch-tasks",e.script.id)}};return(t,o)=>(y(),R("div",z,[l(r(b),{layout:"vertical",style:{overflow:"auto"}},{default:u(()=>[l(r(w),{label:"Trigger task"},{default:u(()=>[l(r(x),{options:d.value,value:s.value,onSelect:o[0]||(o[0]=c=>s.value=c)},null,8,["options","value"])]),_:1})]),_:1}),l(P,{loading:a.value,disabled:t.disabledWarning||m.value,onClick:n,onSave:o[1]||(o[1]=c=>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=a.value)!=null&&n.script.hasChanges()?{title:"Unsaved changes",message:"Save the form before running the workflow"}:null}),m=async n=>{const t=await d.getStageTasks(n);e.value=t.tasks.filter(o=>o.status==="pending")},{result:a}=W(async()=>{const[n,t]=await Promise.all([B.get(),A.get(p.params.id)]);return m(t.id),D({workspace:n,script:t})});return(n,t)=>(y(),_(N,{stage:r(a).script,workspace:r(a).workspace,"stage-type":"scripts",onRefetchTasks:t[0]||(t[0]=o=>m(r(a).script.id))},{settings:u(()=>[l(E,{script:r(a).script},null,8,["script"])]),test:u(()=>[l(F,{ref:"tester",script:r(a).script,"disabled-warning":s.value,tasks:e.value,onRefetchTasks:m},null,8,["script","disabled-warning","tasks"])]),_:1},8,["stage","workspace"]))}});export{Mt as default};
//# sourceMappingURL=ScriptEditor.a580f54e.js.map
