import{L as $}from"./tasksController.4435e53d.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 b,cy as w,f as v,Y as R,aB as x,ea as C,z as D}from"./index.abaf3ad4.js";import{a as W}from"./asyncComputed.84aa5ffe.js";import"./linters.0fabbf73.js";import{S as A}from"./scripts.24ea2b00.js";import{W as B}from"./workspaces.16081016.js";import{R as L,_ as N}from"./RuntimeCommonSettings.2b92c15c.js";import{_ as P}from"./RunButton.vue_vue_type_script_setup_true_lang.cb734055.js";import"./gateway.21d52798.js";import"./popupNotifcation.4879d617.js";import"./polling.1abfd793.js";import"./string.7a9e8232.js";import"./record.fee51533.js";import"./workspaceStore.a9cf83e9.js";import"./url.8ee60884.js";import"./colorHelpers.5d53a4e5.js";import"./BaseLayout.7ffcbde7.js";import"./SaveButton.03d64e2b.js";import"./UnsavedChangesHandler.85819ddf.js";import"./ExclamationCircleOutlined.193ac538.js";import"./uuid.ecc0e70e.js";import"./NavbarControls.ad7a483c.js";import"./index.877779f4.js";import"./CloseCircleOutlined.ae6ff195.js";import"./index.7379e16a.js";import"./editor.b47b3988.js";import"./PhArrowSquareOut.vue.1ec19773.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.a65e24ff.js";import"./BookOutlined.2ea62891.js";import"./PhChats.vue.14138a41.js";import"./AbstraLogo.vue_vue_type_script_setup_true_lang.01b40a66.js";import"./Logo.25cc61a3.js";import"./ant-design.adc06afb.js";import"./ai.58014c64.js";import"./PhCheckCircle.vue.c916b86b.js";import"./PhCopySimple.vue.16143f73.js";import"./Avatar.26fee0bf.js";import"./LoadingOutlined.eb13bd9d.js";import"./Card.3feb8148.js";import"./TabPane.fc901a4e.js";import"./PhCaretRight.vue.a2e2b887.js";import"./Badge.05c5a8ba.js";import"./PhFolder.vue.0b355341.js";import"./PhPencil.vue.10b5ae03.js";import"./validations.05f9887e.js";import"./toggleHighContrast.e137e951.js";import"./TasksManager.4044d8a1.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.52a189d1.js";import"./index.2fcbba35.js";import"./CollapsePanel.7bdb061c.js";import"./index.a6a4f2c0.js";import"./index.5484d772.js";import"./index.d045fd91.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]="af5d78a6-db2f-4d38-990c-9861a8e38bf5",i._sentryDebugIdIdentifier="sentry-dbid-af5d78a6-db2f-4d38-990c-9861a8e38bf5")}catch{}})();const E=k({__name:"ScriptSettings",props:{script:{}},setup(i){const e=f(i.script);return(d,s)=>(y(),_(r(w),{layout:"vertical",style:{"padding-bottom":"50px"}},{default:u(()=>[l(r(b),{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(w),{layout:"vertical",style:{overflow:"auto"}},{default:u(()=>[l(r(b),{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.e116eaf6.js.map
