import{L as $}from"./tasksController.64b17003.js";import{d as b,e as f,o as k,c as y,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.f642553c.js";import{a as W}from"./asyncComputed.47ff725c.js";import"./linters.8d7e557c.js";import{S as A}from"./scripts.5b11ab0e.js";import{W as B}from"./workspaces.9711e425.js";import{R as L,_ as N}from"./RuntimeCommonSettings.d17cd037.js";import{_ as P}from"./RunButton.vue_vue_type_script_setup_true_lang.3af505f9.js";import"./gateway.d1732116.js";import"./popupNotifcation.040c54ab.js";import"./polling.3df437e7.js";import"./string.df9f642e.js";import"./record.f177349f.js";import"./workspaceStore.3db35d66.js";import"./url.805125a0.js";import"./colorHelpers.05cd19a2.js";import"./BaseLayout.a01768ad.js";import"./SaveButton.32fabddc.js";import"./UnsavedChangesHandler.f5c0064d.js";import"./ExclamationCircleOutlined.a05b41a9.js";import"./uuid.d4372e3d.js";import"./NavbarControls.37c642c5.js";import"./index.3b613af3.js";import"./CloseCircleOutlined.da000856.js";import"./index.b05aadfa.js";import"./editor.89f74d39.js";import"./PhArrowSquareOut.vue.6608b1dc.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.deb30b56.js";import"./BookOutlined.4710a705.js";import"./PhChats.vue.bc4e172d.js";import"./AbstraLogo.vue_vue_type_script_setup_true_lang.7daa55cc.js";import"./Logo.6ff63c47.js";import"./ant-design.84179dee.js";import"./ai.80d34eab.js";import"./PhCheckCircle.vue.e6c5fe9e.js";import"./PhCopySimple.vue.cc718a89.js";import"./Avatar.b15a9856.js";import"./LoadingOutlined.f1e9ea60.js";import"./Card.fac996a7.js";import"./TabPane.a3c2b7f1.js";import"./PhCaretRight.vue.9fdc76d5.js";import"./Badge.7cb0aad6.js";import"./PhFolder.vue.dff1ba44.js";import"./PhPencil.vue.b96803a2.js";import"./validations.698b8ace.js";import"./toggleHighContrast.4b0d8a9a.js";import"./TasksManager.22cc849c.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.8aef727a.js";import"./index.88402b65.js";import"./CollapsePanel.084dae2f.js";import"./index.21626f9e.js";import"./index.249cb151.js";import"./index.4b8d86be.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]="df196bdb-f773-4ade-ab67-ca2a30fcaceb",i._sentryDebugIdIdentifier="sentry-dbid-df196bdb-f773-4ade-ab67-ca2a30fcaceb")}catch{}})();const E=b({__name:"ScriptSettings",props:{script:{}},setup(i){const e=f(i.script);return(d,s)=>(k(),y(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=b({__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(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?o:[]}),s=f(void 0),c=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)=>(k(),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:o[0]||(o[0]=m=>s.value=m)},null,8,["options","value"])]),_:1})]),_:1}),l(P,{loading:a.value,disabled:t.disabledWarning||c.value,onClick:n,onSave:o[1]||(o[1]=m=>t.script.save())},null,8,["loading","disabled"])]))}}),Mt=b({__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}),c=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 c(t.id),D({workspace:n,script:t})});return(n,t)=>(k(),y(N,{stage:r(a).script,workspace:r(a).workspace,"stage-type":"scripts",onRefetchTasks:t[0]||(t[0]=o=>c(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:c},null,8,["script","disabled-warning","tasks"])]),_:1},8,["stage","workspace"]))}});export{Mt as default};
//# sourceMappingURL=ScriptEditor.a194ad77.js.map
