import{d as h,aa as F,o as A,A as y,J as p,P as d,j as s,t as a,B as S,C as k,an as q,i as x,b as C,c as g,g as m,_ as N,e as P,ay as T}from"./index-DOFLUERq.js";import{u as V,F as b}from"./FlowBuilderContainer-UOYwywsf.js";import{useFlowBuilderStore as D}from"./flowBuilder-q7JE5Odm.js";import{_ as I}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./iconify-p99pbjf9.js";import"./AIAgentFlowBuilder-CGxot1WF.js";import"./vue-flow-core-CsxnVOkM.js";import"./nodeMetadata-BYrn6PHN.js";import"./common-DEIQtiPI.js";import"./NodePropertyModal-mmcKGDvy.js";import"./SchemaFormRenderer-qVPQyEK7.js";import"./nodes-5SvwML7l.js";import"./NodePalette-DCoiMD7j.js";import"./ExecutionResults-Cf6jbq5F.js";const J={class:"flow-builder-page"},M={key:0,class:"empty-state"},R={class:"empty-content"},j=h({__name:"FlowBuilder",setup(E){const _=P(),o=C(),i=F(),c=V(),t=D(),r=g(()=>o.query.id||o.query.name||t.getAgentId()),f=g(()=>{const e=o.query.pagetype;return e?T(e):""}),w=g(()=>r.value||t.hasFlowData());A(async()=>{const e=o.query.id||o.query.name,n=f.value;if(e&&!t.getAgentId())try{await c.fetchAgent(e,n);const l=c.currentAgent;if(l?.agent_flow){let u=l.agent_flow;typeof u=="string"&&(u=JSON.parse(u)),t.activateFlowBuilder(u,e)}}catch(l){console.error("恢复智能体数据失败:",l)}});const v=async e=>{try{r.value?(await c.updateAgent(r.value,{agent_flow:e},f.value),i.success(a("Agent flow saved successfully")),t.deactivateFlowBuilder()):i.success(a("Flow saved successfully"))}catch(n){i.error(a("Save failed")+": "+(n?.message||""))}},B=()=>{_.push("/agents")};return(e,n)=>(m(),y("div",J,[w.value?(m(),x(b,{key:1,"initial-value":s(t).getFlowData(),"agent-id":r.value,onSave:v},null,8,["initial-value","agent-id"])):(m(),y("div",M,[p("div",R,[p("h3",null,d(s(a)("Flow Builder")),1),p("p",null,d(s(a)("Please enter from Agents page to open Flow Builder")),1),S(s(q),{type:"primary",onClick:B},{default:k(()=>[N(d(s(a)("View Agents")),1)]),_:1})])]))]))}}),te=I(j,[["__scopeId","data-v-bffeb9f8"]]);export{te as default};
