import{d as B,aa as I,g as _,A as U,J as s,j as r,t as n,a8 as d,i as $,B as N,Y as V,H as D,c as i,r as J,a as w}from"./index-DOFLUERq.js";import O from"./SchemaEditorModal-Dx35HFmL.js";import{_ as T}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./_commonjsHelpers-CE1G-McA.js";const j=["title"],z=["title"],A=["title","disabled"],F=["title"],H=B({__name:"local_ai_node_list_actions",props:{context:{},row:{},entity:{},viewMode:{}},emits:["view","edit","delete"],setup(y,{emit:b}){const a=y,u=b,t=i(()=>a.row||a.context?.row),v=i(()=>a.entity||a.context?.entity),x=i(()=>a.viewMode||a.context?.viewMode||"list"),S=i(()=>x.value==="card"?"actions-container card-actions":"actions-container col-actions"),c=I(),l=J(!1),m=i(()=>t.value?.name||""),p=i(()=>t.value?.node_type||""),C=i(()=>{const o=t.value?.node_schema;if(!o)return{};if(typeof o=="string")try{return JSON.parse(o)}catch{return{}}return o}),f=i(()=>!!p.value);function g(){a.context?.openDetail?a.context.openDetail(t.value.name):u("view",t.value)}function E(){a.context?.editRecord?a.context.editRecord(t.value):u("edit",t.value)}function k(){a.context?.deleteRecord?a.context.deleteRecord(t.value.name):u("delete",t.value)}async function R(){if(!f.value){c.warning(n("Please select node type first"));return}if(!t.value?.node_schema)try{const e=(await w.get(`/api/data/${encodeURIComponent(v.value)}/${encodeURIComponent(m.value)}`)).data?.data||{};e.node_schema&&t.value&&(t.value.node_schema=e.node_schema)}catch(o){console.error("获取节点数据失败:",o),c.error(n("Failed to load node data"));return}l.value=!0}async function M(o){try{const e=await w.put(`/api/data/${encodeURIComponent(v.value)}/${encodeURIComponent(m.value)}`,{node_schema:o});if(e.data?.success!==!1)t.value&&(t.value.node_schema=o),c.success(n("Schema saved successfully")),l.value=!1;else throw new Error(e.data?.message||n("Save failed"))}catch(e){throw console.error("保存 Schema 失败:",e),c.error(e?.response?.data?.message||e?.message||n("Save failed, please check permission and server logs")),e}}return(o,e)=>(_(),U("div",{class:D(S.value)},[s("button",{class:"action-btn",onClick:d(g,["stop"]),title:r(n)("View")},[...e[2]||(e[2]=[s("i",{class:"fa fa-eye"},null,-1)])],8,j),s("button",{class:"action-btn",onClick:d(E,["stop"]),title:r(n)("Edit")},[...e[3]||(e[3]=[s("i",{class:"fa fa-edit"},null,-1)])],8,z),s("button",{class:"action-btn schema-btn",onClick:d(R,["stop"]),title:r(n)("Edit Schema"),disabled:!f.value},[...e[4]||(e[4]=[s("i",{class:"fa fa-table"},null,-1)])],8,A),s("button",{class:"action-btn delete-btn",onClick:d(k,["stop"]),title:r(n)("Delete")},[...e[5]||(e[5]=[s("i",{class:"fa fa-trash"},null,-1)])],8,F),(_(),$(V,{to:"body"},[N(O,{visible:l.value,"onUpdate:visible":e[0]||(e[0]=h=>l.value=h),"node-type":p.value,"node-name":m.value,"initial-schema":C.value,"on-save":M,onClose:e[1]||(e[1]=h=>l.value=!1)},null,8,["visible","node-type","node-name","initial-schema"])]))],2))}}),K=T(H,[["__scopeId","data-v-0eaac868"]]);export{K as default};
