import{d as y,u as h,c as g,o as B,e as _,f as i,g as u,j as a,h as F,w as A,J as S,l as I,X as k,t as s,n as d,s as x,q as N}from"./index-a0da86f0.js";import{u as V,F as C}from"./FlowBuilderContainer-446263f9.js";import{useFlowBuilderStore as D}from"./flowBuilder-c7c3e16b.js";import{_ as q}from"./_plugin-vue_export-helper-c27b6911.js";import"./iconify-56cbf3ff.js";import"./AIAgentFlowBuilder-9839caaa.js";import"./vue-flow-core-379fe11a.js";import"./nodeMetadata-d183494d.js";import"./NodePropertyModal-29321bf4.js";import"./SchemaFormRenderer-4ebe686e.js";import"./nodes-23b691ed.js";import"./NodePalette-48aa6c6e.js";import"./ExecutionResults-29ea2a6e.js";import"./common-fa44b7a0.js";const J={class:"flow-builder-page"},M={key:0,class:"empty-state"},P={class:"empty-content"},R=y({__name:"FlowBuilder",setup(T){const f=I(),p=k(),l=h(),c=V(),t=D(),n=g(()=>t.getAgentId()||p.query.agentId),m=g(()=>n.value||t.hasFlowData());B(async()=>{const o=p.query.agentId;if(o&&!t.getAgentId())try{t.setAgentId(o),await c.fetchAgent(o);const e=c.currentAgent;if(e!=null&&e.agent_flow){let r=e.agent_flow;typeof r=="string"&&(r=JSON.parse(r)),t.setFlowData(r)}}catch(e){console.error("恢复智能体数据失败:",e)}});const w=async o=>{try{n.value?(await c.updateAgent(n.value,{agent_flow:o}),l.success(s("Agent flow saved successfully")),t.deactivateFlowBuilder()):(console.log("保存流程数据:",o),l.success(s("Flow saved successfully")))}catch(e){l.error(s("Save failed")+": "+((e==null?void 0:e.message)||""))}},v=()=>{f.push("/agents")};return(o,e)=>(d(),_("div",J,[m.value?(d(),S(C,{key:1,"initial-value":a(t).getFlowData(),"agent-id":n.value,onSave:w},null,8,["initial-value","agent-id"])):(d(),_("div",M,[i("div",P,[i("h3",null,u(a(s)("Flow Builder")),1),i("p",null,u(a(s)("Please enter from Agents page to open Flow Builder")),1),F(a(N),{type:"primary",onClick:v},{default:A(()=>[x(u(a(s)("View Agents")),1)]),_:1})])]))]))}});const Z=q(R,[["__scopeId","data-v-2089ffe8"]]);export{Z as default};
