import{u as I}from"./useMindMap-DgbPq3QC.js";import{d as J,o as S,w as v,g as _,A as C,J as o,P as g,K as R,L as j,H as A,j as l,r as h,c as E}from"./index-DOFLUERq.js";import{_ as H}from"./_plugin-vue_export-helper-DlAUqK2U.js";const K={class:"toolbar"},P={class:"toolbar-left"},Z={class:"layout-label"},$={class:"toolbar-center"},q={class:"layout-switcher"},G=["onClick"],Q={class:"toolbar-right"},U={class:"canvas-wrapper"},W=J({__name:"MindMapCanvas",props:{modelValue:{},layoutType:{},readonly:{type:Boolean}},emits:["update:modelValue","nodeClick","nodeDoubleClick","layoutChange"],setup(V,{expose:w,emit:L}){const n=V,i=L,M=h(),d=h(),{layoutType:r,interaction:c,initCanvas:N,applyLayout:u,addNode:T,removeNode:D,updateNodeLabel:x,toggleCollapse:F,exportData:f,importData:p,fitView:s,zoomIn:m,zoomOut:y,resetZoom:b}=I({layoutType:n.layoutType}),k=[{label:"思维导图",key:"radial-mindmap"},{label:"逻辑树",key:"logic-tree"},{label:"鱼骨图",key:"fishbone"},{label:"树形图",key:"tree"},{label:"组织结构图",key:"org-chart"},{label:"横向时间轴",key:"timeline-horizontal"},{label:"纵向时间轴",key:"timeline-vertical"},{label:"力导向图",key:"force-directed"}],O=E(()=>k.find(e=>e.key===r.value)?.label||"思维导图");S(()=>{if(d.value){const t=N(d.value);if(n.modelValue)try{const e=typeof n.modelValue=="string"?JSON.parse(n.modelValue):n.modelValue;p(e)}catch(e){console.error("Failed to load mindmap data:",e)}else t&&setTimeout(()=>s(),100);c.value&&(c.value.on("node:click",e=>{i("nodeClick",e.nodeId)}),c.value.on("node:dblclick",e=>{i("nodeDoubleClick",e.nodeId)})),setTimeout(()=>s(),100)}}),v(()=>n.modelValue,t=>{if(t)try{const e=typeof t=="string"?JSON.parse(t):t;p(e)}catch(e){console.error("Failed to load mindmap data:",e)}},{deep:!0}),v(()=>n.layoutType,t=>{t&&t!==r.value&&u(t)});function z(){const t=f();i("update:modelValue",JSON.stringify(t))}function B(t){u(t),i("layoutChange",t),z()}return w({applyLayout:u,addNode:T,removeNode:D,updateNodeLabel:x,toggleCollapse:F,exportData:f,importData:p,fitView:s,zoomIn:m,zoomOut:y,resetZoom:b}),(t,e)=>(_(),C("div",{class:"mind-map-container",ref_key:"canvasContainer",ref:M},[o("div",K,[o("div",P,[o("span",Z,g(O.value),1)]),o("div",$,[o("div",q,[(_(),C(R,null,j(k,a=>o("button",{key:a.key,class:A(["layout-btn",{active:l(r)===a.key}]),onClick:X=>B(a.key)},g(a.label),11,G)),64))])]),o("div",Q,[o("button",{class:"tool-btn",onClick:e[0]||(e[0]=(...a)=>l(m)&&l(m)(...a)),title:"放大"},"+"),o("button",{class:"tool-btn",onClick:e[1]||(e[1]=(...a)=>l(y)&&l(y)(...a)),title:"缩小"},"-"),o("button",{class:"tool-btn",onClick:e[2]||(e[2]=(...a)=>l(s)&&l(s)(...a)),title:"适应"},"Fit"),o("button",{class:"tool-btn",onClick:e[3]||(e[3]=(...a)=>l(b)&&l(b)(...a)),title:"重置"},"Reset")])]),o("div",U,[o("canvas",{ref_key:"canvasRef",ref:d,class:"mind-map-canvas"},null,512)])],512))}}),oe=H(W,[["__scopeId","data-v-6f5e63bd"]]);export{oe as default};
