const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/flowBuilder-q7JE5Odm.js","assets/index-DOFLUERq.js","assets/index-Cl-AM8AM.css"])))=>i.map(i=>d[i]);
import{d as g,aa as p,g as y,A as b,J as a,a8 as l,H as u,c as v,r as B,a as C,aI as E,a0 as F}from"./index-DOFLUERq.js";import{api as S}from"./common-DEIQtiPI.js";import{_}from"./_plugin-vue_export-helper-DlAUqK2U.js";const k=["title"],I=["title"],M=["title","disabled"],R=["title"],$=["title"],D=g({__name:"ai_agent_list_actions",props:{context:{}},setup(n){const e=n,f=v(()=>(e.context.viewMode||"list")==="card"?"actions-container card-actions":"actions-container col-actions"),r=p(),c=B(!1);async function x(){try{c.value=!0;const o=e.context.row.name;if(!o){r.error(e.context.t("Agent name is required"));return}const t=await S.call("jingrow.ai.pagetype.ai_agent.ai_agent.execute_agent_by_name",{agent_name:o}),i=t?.message||t;i?.success?r.success(e.context.t("Submitted successfully")):r.error(i?.error||e.context.t("Execution failed"))}catch(o){r.error(o?.message||e.context.t("Execution failed"))}finally{c.value=!1}}async function w(){try{const o=e.context.row.name;let t={};if(e.context.row.agent_flow!==void 0&&e.context.row.agent_flow!==null){const s=e.context.row.agent_flow;if(t=s,typeof s=="string")try{t=JSON.parse(s)}catch{t={}}}else try{const d=((await C.get(`/api/data/${encodeURIComponent(e.context.entity)}/${encodeURIComponent(o)}`)).data?.data||{}).agent_flow??{};if(t=d,typeof d=="string")try{t=JSON.parse(d)}catch{t={}}}catch(s){console.error("获取智能体数据失败:",s),r.error(e.context.t("Failed to load agent data"));return}const i=E(e.context.entity),{useFlowBuilderStore:m}=await F(async()=>{const{useFlowBuilderStore:s}=await import("./flowBuilder-q7JE5Odm.js");return{useFlowBuilderStore:s}},__vite__mapDeps([0,1,2]));m().activateFlowBuilder(t,o),e.context.router.push({name:"FlowBuilder",query:{pagetype:i,id:o}})}catch(o){console.error("打开流程编排失败:",o),r.error(o?.message||e.context.t("Failed to open flow builder"))}}return(o,t)=>(y(),b("div",{class:u(f.value)},[a("button",{class:"action-btn",onClick:t[0]||(t[0]=l(i=>n.context.openDetail(n.context.row.name),["stop"])),title:n.context.t("View")},[...t[3]||(t[3]=[a("i",{class:"fa fa-eye"},null,-1)])],8,k),a("button",{class:"action-btn",onClick:t[1]||(t[1]=l(i=>n.context.editRecord(n.context.row),["stop"])),title:n.context.t("Edit")},[...t[4]||(t[4]=[a("i",{class:"fa fa-edit"},null,-1)])],8,I),a("button",{class:"action-btn execute-btn",onClick:l(x,["stop"]),title:n.context.t("Execute"),disabled:c.value},[a("i",{class:u(c.value?"fa fa-spinner fa-spin":"fa fa-play")},null,2)],8,M),a("button",{class:"action-btn flow-builder-btn",onClick:l(w,["stop"]),title:n.context.t("Flow Builder")},[...t[5]||(t[5]=[a("i",{class:"fa fa-sitemap"},null,-1)])],8,R),a("button",{class:"action-btn delete-btn",onClick:t[2]||(t[2]=l(i=>n.context.deleteRecord(n.context.row.name),["stop"])),title:n.context.t("Delete")},[...t[6]||(t[6]=[a("i",{class:"fa fa-trash"},null,-1)])],8,$)],2))}}),V=_(D,[["__scopeId","data-v-1aa3dda6"]]);export{V as default};
