import{L as $}from"./tasksController.11e798f4.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.00900164.js";import{a as W}from"./asyncComputed.61a4e861.js";import"./linters.4ffd16b2.js";import{S as A}from"./scripts.d54186dc.js";import{W as B}from"./workspaces.882dbbfd.js";import{R as L,_ as N}from"./RuntimeCommonSettings.893a314c.js";import{_ as P}from"./RunButton.vue_vue_type_script_setup_true_lang.62fc6a52.js";import"./gateway.61e97762.js";import"./popupNotifcation.105ba4a6.js";import"./polling.4c55b326.js";import"./string.a628f102.js";import"./record.9a19fe6f.js";import"./workspaceStore.5ccc82e1.js";import"./url.81ce8e9e.js";import"./colorHelpers.2d30f02e.js";import"./BaseLayout.f23f3ab1.js";import"./SaveButton.66a17872.js";import"./UnsavedChangesHandler.ad175023.js";import"./ExclamationCircleOutlined.fde09017.js";import"./uuid.93ac9996.js";import"./NavbarControls.c596c357.js";import"./index.cdbf7d0b.js";import"./CloseCircleOutlined.2b1a6d48.js";import"./index.c337cd49.js";import"./editor.3bed9b7d.js";import"./PhArrowSquareOut.vue.c422f708.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.59fb8def.js";import"./BookOutlined.d78d7289.js";import"./PhChats.vue.38555357.js";import"./AbstraLogo.vue_vue_type_script_setup_true_lang.3d3f11b4.js";import"./Logo.bfd3f9e6.js";import"./ant-design.a6952f3b.js";import"./ai.a09bd437.js";import"./PhCheckCircle.vue.cb8c1c48.js";import"./PhCopySimple.vue.11e9fe5f.js";import"./Avatar.8b92ae0e.js";import"./LoadingOutlined.30286f42.js";import"./Card.e994fc5d.js";import"./TabPane.cc923c64.js";import"./PhCaretRight.vue.8a2a9cdb.js";import"./Badge.424cfeb2.js";import"./SourceCode.2a0f7050.js";import"./validations.de4cc741.js";import"./PhFolder.vue.ec78cc62.js";import"./toggleHighContrast.ad9677f7.js";import"./TasksManager.69d4340e.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.e5a09f6e.js";import"./index.041d55b4.js";import"./CollapsePanel.c09bd5d3.js";import"./index.54838c68.js";import"./index.dec4e8c2.js";import"./index.7e967143.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]="452732cf-c4c9-4c12-9ed9-3eb6960721ad",i._sentryDebugIdIdentifier="sentry-dbid-452732cf-c4c9-4c12-9ed9-3eb6960721ad")}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]=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(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: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(),_(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.4fdd3921.js.map
