import{L as $}from"./tasksController.659c345f.js";import{d as k,e as f,o as y,c as _,w as u,b as p,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.5aecb583.js";import{a as W}from"./asyncComputed.919e81fb.js";import"./linters.fe07d562.js";import{S as A}from"./scripts.ade32b25.js";import{W as B}from"./workspaces.bf51056b.js";import{_ as L,a as N}from"./RunButton.vue_vue_type_script_setup_true_lang.652df288.js";import{R as P}from"./SmartChat.f4c0d1b7.js";import"./gateway.a0446a31.js";import"./popupNotifcation.a70532ef.js";import"./polling.82e59f77.js";import"./string.29356842.js";import"./record.7b9a0c18.js";import"./workspaceStore.d4664f94.js";import"./url.d1aedda8.js";import"./colorHelpers.25ec075c.js";import"./BaseLayout.1b33e1cd.js";import"./SaveButton.ad706c5b.js";import"./UnsavedChangesHandler.a33b5aee.js";import"./ExclamationCircleOutlined.f3294aae.js";import"./NavbarControls.be2d98a6.js";import"./index.07e90e85.js";import"./CloseCircleOutlined.63082e2c.js";import"./index.1ef256d6.js";import"./editor.bbb11be7.js";import"./PhArrowSquareOut.vue.d49c2a29.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.1a4649a6.js";import"./BookOutlined.1b5c2f81.js";import"./PhChats.vue.f2523dcf.js";import"./TasksManager.b7676b86.js";import"./ant-design.062152ca.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.74e20c49.js";import"./index.d80e8dc1.js";import"./Card.343e3a00.js";import"./TabPane.1c765b36.js";import"./CollapsePanel.f5c195cf.js";import"./index.a7ec6bbe.js";import"./index.353f6095.js";import"./index.9e74a977.js";import"./Avatar.dc15e97c.js";import"./validations.e8ce4139.js";import"./uuid.83097e63.js";import"./PhCaretRight.vue.93c17fa0.js";import"./Badge.1d490ce7.js";import"./LoadingOutlined.ff0e335a.js";import"./PhFolder.vue.f81e9f1f.js";import"./PhPencil.vue.03a4e6ee.js";import"./toggleHighContrast.d7e7b688.js";import"./AbstraLogo.vue_vue_type_script_setup_true_lang.01e384ac.js";import"./Logo.d4f441cc.js";import"./PhGear.vue.b605fb00.js";import"./ai.fd9ba83c.js";import"./PhCheckCircle.vue.6a54b6c3.js";import"./PhCopySimple.vue.f6b0c1b1.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},l=new Error().stack;l&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[l]="4eafdc7d-f63e-4f05-aae9-2f63394aab5a",i._sentryDebugIdIdentifier="sentry-dbid-4eafdc7d-f63e-4f05-aae9-2f63394aab5a")}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(()=>[p(r(w),{label:"Name",required:""},{default:u(()=>[p(r(I),{value:e.value.title,"onUpdate:value":s[0]||(s[0]=m=>e.value.title=m)},null,8,["value"])]),_:1}),p(P,{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:l}){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,l("refetch-tasks",e.script.id)}};return(t,o)=>(y(),R("div",z,[p(r(b),{layout:"vertical",style:{overflow:"auto"}},{default:u(()=>[p(r(w),{label:"Trigger task"},{default:u(()=>[p(r(x),{options:d.value,value:s.value,onSelect:o[0]||(o[0]=c=>s.value=c)},null,8,["options","value"])]),_:1})]),_:1}),p(L,{loading:a.value,disabled:t.disabledWarning||m.value,onClick:n,onSave:o[1]||(o[1]=c=>t.script.save())},null,8,["loading","disabled"])]))}}),Ot=k({__name:"ScriptEditor",setup(i){const l=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(l.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(()=>[p(E,{script:r(a).script},null,8,["script"])]),test:u(()=>[p(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{Ot as default};
//# sourceMappingURL=ScriptEditor.e4c3cd56.js.map
