drawui-react 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var react=require('react'),drawuiCore=require('drawui-core'),jsxRuntime=require('react/jsx-runtime');function D(){let[a,e]=react.useState(drawuiCore.getLanguage());return react.useEffect(()=>drawuiCore.subscribeLanguage(()=>e(drawuiCore.getLanguage())),[]),a}var yt=[{type:"rectangle",icon:jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"0"})},{type:"rounded-rectangle",icon:jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4"})},{type:"circle",icon:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"8"})},{type:"ellipse",icon:jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"6"})},{type:"diamond",icon:jsxRuntime.jsx("path",{d:"M12 3L21 12L12 21L3 12Z"})},{type:"triangle",icon:jsxRuntime.jsx("path",{d:"M12 4L20 19L4 19Z"})},{type:"hexagon",icon:jsxRuntime.jsx("path",{d:"M12 3L20 7.5V16.5L12 21L4 16.5V7.5Z"})},{type:"parallelogram",icon:jsxRuntime.jsx("path",{d:"M7 5L20 5L17 19L4 19Z"})},{type:"trapezoid",icon:jsxRuntime.jsx("path",{d:"M6 5L18 5L21 19L3 19Z"})},{type:"pentagon",icon:jsxRuntime.jsx("path",{d:"M12 3L21 10L17.5 21L6.5 21L3 10Z"})},{type:"octagon",icon:jsxRuntime.jsx("path",{d:"M8 3L16 3L21 8L21 16L16 21L8 21L3 16L3 8Z"})},{type:"star",icon:jsxRuntime.jsx("path",{d:"M12 2L14.5 8.5L21 9L16 13.5L17.5 20L12 16.5L6.5 20L8 13.5L3 9L9.5 8.5Z"})}],Zt=new Set(yt.map(a=>a.type)),Ot=[{type:"arrow",icon:"M5 12h14M12 5l7 7-7 7",labelKey:"toolbar.arrow"},{type:"text",icon:"M4 7V4h16v3M9 20h6M12 4v16",labelKey:"toolbar.text"}],_t=[{type:"pen",icon:"M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3Z",labelKey:"toolbar.pen"},{type:"highlighter",icon:"M14 3l7 7-3 3-7-7 3-3zM9 8L3 14v3h3l6-6",labelKey:"toolbar.highlighter"}],Vt=[{type:"eraser",icon:"M7 21l-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21M22 21H7M5 11l9 9",labelKey:"toolbar.eraser"}],Yt="M18 11V6.5a1.5 1.5 0 0 0-3 0v3.5a1.5 1.5 0 0 0-3 0V3.5a1.5 1.5 0 0 0-3 0v6.5a1.5 1.5 0 0 0-3 0V14a8 8 0 0 0 16 0v-3a1.5 1.5 0 0 0-3 0",Qe=react.memo(function({activeTool:e,onToolChange:t,showGrid:o,onToggleGrid:u,canUndo:p=false,canRedo:h=false,onUndo:i,onRedo:k}){let[m,y]=react.useState(false),s=react.useRef(null);D();let x=()=>{s.current&&(clearTimeout(s.current),s.current=null),y(true);},H=()=>{s.current=window.setTimeout(()=>{y(false);},200);};return jsxRuntime.jsx("div",{className:"drawui-toolbar-container",children:jsxRuntime.jsxs("div",{className:"drawui-toolbar",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="select"?"active":""}`,onClick:()=>t("select"),title:drawuiCore.t("toolbar.select"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"3"})})}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="hand"?"active":""}`,onClick:()=>t("hand"),title:drawuiCore.t("toolbar.hand"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:Yt})})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:x,onMouseLeave:H,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${Zt.has(e)?"active":""}`,onClick:()=>t("rounded-rectangle"),title:"\u5F62\u72B6",children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4",ry:"4"})})}),m&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid",children:yt.map(c=>jsxRuntime.jsx("button",{className:`drawui-toolbar-shape-item ${e===c.type?"active":""}`,onClick:()=>{t(c.type),y(false);},title:drawuiCore.t("tool."+c.type),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:c.icon})},c.type))})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),Ot.map(c=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===c.type?"active":""}`,onClick:()=>t(c.type),title:drawuiCore.t(c.labelKey),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:c.icon})})},c.type)),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),_t.map(c=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===c.type?"active":""}`,onClick:()=>t(c.type),title:drawuiCore.t(c.labelKey),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:c.icon})})},c.type)),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),Vt.map(c=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===c.type?"active":""}`,onClick:()=>t(c.type),title:drawuiCore.t(c.labelKey),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:c.icon})})},c.type)),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="uml-class"?"active":""}`,onClick:()=>t("uml-class"),title:drawuiCore.t("toolbar.uml-class"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsxRuntime.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsxRuntime.jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),jsxRuntime.jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsxRuntime.jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"}),jsxRuntime.jsx("line",{x1:"7",y1:"18",x2:"11",y2:"18"})]})}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="uml-interface"?"active":""}`,onClick:()=>t("uml-interface"),title:drawuiCore.t("toolbar.uml-interface"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsxRuntime.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsxRuntime.jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsxRuntime.jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"})]})}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="mind-map"?"active":""}`,onClick:()=>t("mind-map"),title:drawuiCore.t("toolbar.mind-map"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"5",cy:"12",r:"2.4"}),jsxRuntime.jsx("path",{d:"M7.4 12h3.6"}),jsxRuntime.jsx("path",{d:"M11 12c0-2.6 1.6-4.4 3.4-4.4"}),jsxRuntime.jsx("path",{d:"M11 12c0 2.6 1.6 4.4 3.4 4.4"}),jsxRuntime.jsx("circle",{cx:"17.4",cy:"7.6",r:"1.7"}),jsxRuntime.jsx("circle",{cx:"17.4",cy:"16.4",r:"1.7"}),jsxRuntime.jsx("circle",{cx:"15.6",cy:"12",r:"1.7"})]})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${o?"active":""}`,onClick:u,title:drawuiCore.t("toolbar.grid"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),jsxRuntime.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),jsxRuntime.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"}),jsxRuntime.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"})]})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:"drawui-toolbar-button",onClick:i,disabled:!p,style:p?void 0:{opacity:.4,cursor:"default"},title:drawuiCore.t("toolbar.undo"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 7v6h6"}),jsxRuntime.jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})}),jsxRuntime.jsx("button",{className:"drawui-toolbar-button",onClick:k,disabled:!h,style:h?void 0:{opacity:.4,cursor:"default"},title:drawuiCore.t("toolbar.redo"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M21 7v6h-6"}),jsxRuntime.jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"})]})})]})})});var et=react.memo(function({onZoomIn:e,onZoomOut:t,onReset:o,zoomLevel:u=100}){return D(),jsxRuntime.jsxs("div",{className:"drawui-zoom-control",children:[jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:e,title:drawuiCore.t("zoom.in"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),jsxRuntime.jsxs("div",{className:"drawui-zoom-level",children:[u,"%"]}),jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:t,title:"\u7F29\u5C0F",children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"})})}),jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:o,title:drawuiCore.t("zoom.reset"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),jsxRuntime.jsx("path",{d:"M3 3v5h5"})]})})]})});var gt=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af","#ffffff"],bt=[{key:"stroke",labelKey:"style.stroke",hasTransparent:false},{key:"fill",labelKey:"style.fill",hasTransparent:true},{key:"text",labelKey:"style.text",hasTransparent:false},{key:"highlight",labelKey:"style.highlight",hasTransparent:true}],Xt=[{type:"straight",labelKey:"style.connection.straight",icon:"\u2501"},{type:"polyline",labelKey:"style.connection.polyline",icon:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 8 C 12 8, 12 16, 20 16"})})},{type:"orthogonal",labelKey:"style.connection.orthogonal",icon:"\u2517"},{type:"curve",labelKey:"style.connection.curve",icon:"\u223F"}],jt=[{type:"none",labelKey:"style.arrowhead.none",icon:"\u2501"},{type:"end",labelKey:"style.arrowhead.end",icon:"\u2192"},{type:"start",labelKey:"style.arrowhead.start",icon:"\u2190"},{type:"both",labelKey:"style.arrowhead.both",icon:"\u21C4"},{type:"inheritance",labelKey:"style.arrowhead.inheritance",icon:"\u2501\u2501\u25B7"},{type:"composition",labelKey:"style.arrowhead.composition",icon:"\u25C6\u2501\u2501"},{type:"aggregation",labelKey:"style.arrowhead.aggregation",icon:"\u25C7\u2501\u2501"}],xt=react.memo(function({editor:e,selectedCount:t,hasLineSelection:o,currentConnectionType:u,currentArrowHead:p,currentDashed:h}){if(D(),!e||t===0)return null;let i=(s,x)=>{switch(s){case "stroke":e.updateSelectedShapesStyle({strokeColor:x});break;case "fill":e.updateSelectedShapesStyle({fillColor:x});break;case "text":e.updateSelectedShapesText({textColor:x});break;case "highlight":e.updateSelectedShapesText({highlightColor:x});break}},k=s=>{e.updateConnectionType(s);},m=s=>{e.updateArrowHeadType(s);},y=s=>{e.updateArrowDashed(s);};return jsxRuntime.jsxs("div",{className:"drawui-style-panel",children:[jsxRuntime.jsx("div",{className:"drawui-style-col",children:bt.slice(0,2).map(s=>jsxRuntime.jsxs("div",{className:"drawui-style-group",children:[jsxRuntime.jsx("div",{className:"drawui-style-group-label",children:drawuiCore.t(s.labelKey)}),jsxRuntime.jsxs("div",{className:"drawui-color-row",children:[s.hasTransparent&&jsxRuntime.jsx("button",{className:"drawui-color-swatch drawui-color-swatch-transparent",onClick:()=>i(s.key,"transparent"),title:drawuiCore.t("style.none")}),gt.map(x=>jsxRuntime.jsx("button",{className:"drawui-color-swatch",style:{background:x},onClick:()=>i(s.key,x),title:x},`${s.key}-${x}`))]})]},s.key))}),jsxRuntime.jsx("div",{className:"drawui-style-divider"}),jsxRuntime.jsx("div",{className:"drawui-style-col",children:bt.slice(2).map(s=>jsxRuntime.jsxs("div",{className:"drawui-style-group",children:[jsxRuntime.jsx("div",{className:"drawui-style-group-label",children:drawuiCore.t(s.labelKey)}),jsxRuntime.jsxs("div",{className:"drawui-color-row",children:[s.hasTransparent&&jsxRuntime.jsx("button",{className:"drawui-color-swatch drawui-color-swatch-transparent",onClick:()=>i(s.key,"transparent"),title:drawuiCore.t("style.none")}),gt.map(x=>jsxRuntime.jsx("button",{className:"drawui-color-swatch",style:{background:x},onClick:()=>i(s.key,x),title:x},`${s.key}-${x}`))]})]},s.key))}),o&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-divider"}),jsxRuntime.jsxs("div",{className:"drawui-style-col",children:[jsxRuntime.jsxs("div",{className:"drawui-style-group",children:[jsxRuntime.jsx("div",{className:"drawui-style-group-label",children:drawuiCore.t("style.connection")}),jsxRuntime.jsx("div",{className:"drawui-connection-row",children:Xt.map(s=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${u===s.type?" active":""}`,onClick:()=>k(s.type),title:drawuiCore.t(s.labelKey),children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:s.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(s.labelKey)})]},s.type))})]}),jsxRuntime.jsxs("div",{className:"drawui-style-group",children:[jsxRuntime.jsx("div",{className:"drawui-style-group-label",children:drawuiCore.t("style.arrow")}),jsxRuntime.jsx("div",{className:"drawui-connection-row",children:jt.map(s=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${p===s.type?" active":""}`,onClick:()=>m(s.type),title:drawuiCore.t(s.labelKey),children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:s.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(s.labelKey)})]},s.type))})]}),jsxRuntime.jsxs("div",{className:"drawui-style-group",children:[jsxRuntime.jsx("div",{className:"drawui-style-group-label",children:drawuiCore.t("style.dashed")}),jsxRuntime.jsxs("div",{className:"drawui-connection-row",children:[jsxRuntime.jsxs("button",{className:`drawui-connection-btn${h?"":" active"}`,onClick:()=>y(false),title:drawuiCore.t("style.solid"),children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:"\u2501"}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t("style.solid")})]}),jsxRuntime.jsxs("button",{className:`drawui-connection-btn${h?" active":""}`,onClick:()=>y(true),title:drawuiCore.t("style.dashed"),children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:"\u2504"}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t("style.dashed")})]})]})]})]})]})]})});var ot=14,kt=20,rn=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af"],an=[12,14,16,18,20,24];function St(a,e,t){let o=a,u=t,p=o.charAt(0);if(o.length>1&&(p==="+"||p==="-"||p==="#"||p==="~")&&o.charAt(1)===" "&&(u=p,o=o.slice(2)),o=o.replace(/^\s+|\s+$/g,""),e==="attribute"){let s=o.indexOf(":");return s===-1?{visibility:u,name:o,type:"",params:"",returnType:""}:{visibility:u,name:o.slice(0,s).replace(/^\s+|\s+$/g,""),type:o.slice(s+1).replace(/^\s+|\s+$/g,""),params:"",returnType:""}}let h=o.indexOf("(");if(h===-1){let s=o.lastIndexOf(":");return s===-1?{visibility:u,name:o,type:"",params:"",returnType:""}:{visibility:u,name:o.slice(0,s).replace(/^\s+|\s+$/g,""),type:"",params:"",returnType:o.slice(s+1).replace(/^\s+|\s+$/g,"")}}let i=o.slice(0,h).replace(/^\s+|\s+$/g,""),k=o.indexOf(")",h);if(k===-1)return {visibility:u,name:i,type:"",params:o.slice(h+1).replace(/^\s+|\s+$/g,""),returnType:""};let m=o.slice(h+1,k).replace(/^\s+|\s+$/g,""),y=o.slice(k+1).replace(/^\s+|\s+$/g,"");return y.startsWith(":")&&(y=y.slice(1).replace(/^\s+|\s+$/g,"")),{visibility:u,name:i,type:"",params:m,returnType:y}}function sn(a,e){let t=`${e.visibility} `;return a==="attribute"?`${t}${e.name}: ${e.type??""}`:`${t}${e.name}(${e.params??""}): ${e.returnType??""}`}var Ct=react.memo(function({editor:e,umlClass:t,editing:o}){let[,u]=react.useState(0);D(),react.useEffect(()=>{if(!e)return;let d=e.subscribe(()=>u(S=>S+1));return ()=>{d();}},[e]);let[p,h]=react.useState(null),[i,k]=react.useState(false),m=react.useRef(null),y=react.useRef(null),s=react.useCallback((d,S)=>{m.current&&(clearTimeout(m.current),m.current=null),h({section:d,rowId:S}),k(false);},[]),x=react.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=window.setTimeout(()=>{h(null),k(false);},150);},[]);if(!e||!t||o!==t.id)return null;let H=e.getCamera(),{id:c,x:_,y:z,width:B,height:R,className:ke,methods:n}=t,b=t.type==="uml-interface",l=b?[]:t.attributes,V=B/2,Q=R/2,ee=drawuiCore.UML_HEADER_HEIGHT,F=drawuiCore.UML_LINE_HEIGHT,ye=drawuiCore.UML_PADDING_X,re=drawuiCore.UML_PADDING_Y,te=b?0:l.length>0?l.length*F+re*2:re*2,g=H.zoom,pe=(B-ye*2)*g,Le=4*g,Te=H.pageToScreen({x:_-V+ye,y:z}),Se=H.pageToScreen({x:_,y:z-Q+ee/2}),I=d=>H.pageToScreen({x:_,y:d}).y,he=F*g,le=d=>z+(-Q+ee+re+F/2+d*F),Ne=d=>z+(-Q+ee+te+re+F/2+d*F),Ee=z+(-Q+ee+te),fe=z+Q,Me={background:"#ffffff",borderWidth:1,borderStyle:"solid",borderColor:"transparent",outline:"none",padding:0,fontFamily:"sans-serif",boxSizing:"border-box"},Re=(d,S)=>{let M=l.find(U=>U.id===d);if(!M)return;let T=St(S,"attribute",M.visibility);e.updateUmlClass(c,{attributes:l.map(U=>U.id===d?{...U,...T}:U)});},E=(d,S)=>{let M=n.find($=>$.id===d);if(!M)return;let T=St(S,"method",M.visibility),U=n.map($=>$.id===d?{...$,...T}:$);b?e.updateUmlInterface(c,{methods:U}):e.updateUmlClass(c,{methods:U});},w=(d,S,M)=>{y.current={section:d,from:S},M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",`${d}:${S}`);},ne=d=>{d.preventDefault(),d.dataTransfer.dropEffect="move";},G=(d,S,M)=>{M.preventDefault();let T=y.current;!T||T.section!==d||(d==="attribute"?e.reorderUmlAttribute(c,T.from,S):e.reorderUmlMethod(c,T.from,S),y.current=null);},Y=(d,S,M,T)=>{let U=I(T),$=p?.section===d&&p.rowId===M.id,Ie=(M.fontSize||drawuiCore.UML_FONT_SIZE)*g,He=M.textColor||"#1f2937",f={position:"absolute",left:Te.x-ot*g-Le,top:U-he/2,width:ot*g+Le+pe+kt*g,height:he,display:"flex",alignItems:"center",gap:2,pointerEvents:"none",zIndex:53},W={...Me,width:pe,height:he-2,fontSize:Ie,color:He,textDecoration:M.strikethrough?"line-through":"none",pointerEvents:"auto",...$?{borderColor:"var(--dw-primary)"}:{}},ae={width:ot*g,height:he-2,cursor:"grab",color:"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",fontSize:12*g,lineHeight:1,opacity:$?1:.55,pointerEvents:"auto"},ce={width:kt*g,height:he-6,border:"none",background:"transparent",color:"#9ca3af",cursor:"pointer",borderRadius:3,fontSize:14*g,opacity:$?1:.35,pointerEvents:"auto"};return jsxRuntime.jsxs("div",{style:f,onDragOver:ne,onDrop:C=>G(d,S,C),children:[jsxRuntime.jsx("span",{style:ae,draggable:true,onDragStart:C=>w(d,S,C),title:drawuiCore.t("uml.drag"),children:"\u22EE\u22EE"}),jsxRuntime.jsx("input",{style:W,value:sn(d,M),onChange:C=>d==="attribute"?Re(M.id,C.target.value):E(M.id,C.target.value),onFocus:()=>s(d,M.id),onBlur:x,spellCheck:false}),jsxRuntime.jsx("button",{style:ce,onMouseDown:C=>C.preventDefault(),onClick:()=>{d==="attribute"?e.removeUmlAttribute(c,M.id):e.removeUmlMethod(c,M.id);},title:drawuiCore.t("uml.delete"),children:"\xD7"})]},M.id)},ie=(d,S,M)=>{let T=I(S),U=d==="attribute";return jsxRuntime.jsxs("button",{onMouseDown:$=>$.preventDefault(),onClick:()=>U?e.addUmlAttribute(c):e.addUmlMethod(c),className:"drawui-uml-add-row",style:{position:"absolute",left:Te.x,top:T-9*g,height:18*g,padding:`0 ${6*g}px`,fontSize:11*g,lineHeight:1,border:"1px dashed #cbd5e1",background:"rgba(255,255,255,0.85)",color:"#64748b",borderRadius:3,cursor:"pointer",pointerEvents:"auto",display:"flex",alignItems:"center",gap:3,whiteSpace:"nowrap",zIndex:53},title:M,children:[jsxRuntime.jsx("span",{style:{fontSize:13*g,lineHeight:1},children:"+"}),jsxRuntime.jsx("span",{children:M})]},`add-${d}`)},De=()=>{if(!p||p.section==="className")return null;let d=p.section,S=p.rowId,T=(d==="attribute"?l:n).find(L=>L.id===S);if(!T)return null;let U=224*g,$=30*g,Ie=H.pageToScreen({x:_,y:z}).x,He=H.pageToScreen({x:_,y:z-Q}).y,f=20*g,W=He-$-f,ae=Ie-U/2,ce=W+$,C=T.textColor||"#1f2937",ge=T.fontSize||drawuiCore.UML_FONT_SIZE,K=!!T.strikethrough;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:Ie-.5,top:ce,width:1,height:f,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),jsxRuntime.jsxs("div",{className:"drawui-uml-toolbar",style:{position:"absolute",left:ae,top:W,width:U,height:$,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:6,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",gap:4*g,padding:`0 ${6*g}px`,pointerEvents:"auto",zIndex:60,fontSize:12*g},onMouseDown:L=>L.preventDefault(),children:[jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{onClick:()=>k(L=>!L),className:"drawui-uml-toolbar-btn",title:drawuiCore.t("uml.textColor"),style:{border:"none",background:"transparent",cursor:"pointer",padding:2,display:"flex",alignItems:"center",borderRadius:3},children:[jsxRuntime.jsx("span",{style:{fontWeight:700,color:C,fontSize:13*g,textDecoration:K?"line-through":"none"},children:"A"}),jsxRuntime.jsx("span",{style:{width:10*g,height:2*g,background:C,marginLeft:3,borderRadius:1}})]}),i&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"100%",left:0,marginTop:4,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:4,padding:4,display:"flex",gap:2,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:61},children:[jsxRuntime.jsx("button",{onClick:()=>{e.updateUmlRowStyle(c,d,T.id,{textColor:null}),k(false);},style:{width:14,height:14,border:"1px solid #e5e7eb",background:"transparent",cursor:"pointer",borderRadius:2},title:drawuiCore.t("uml.defaultColor")}),rn.map(L=>jsxRuntime.jsx("button",{onClick:()=>{e.updateUmlRowStyle(c,d,T.id,{textColor:L}),k(false);},style:{width:14,height:14,border:"none",background:L,cursor:"pointer",borderRadius:2},title:L},L))]})]}),jsxRuntime.jsx("select",{value:ge,onChange:L=>e.updateUmlRowStyle(c,d,T.id,{fontSize:Number(L.target.value)}),style:{border:"1px solid #e5e7eb",borderRadius:3,padding:`0 ${2*g}px`,fontSize:12*g,height:20*g,background:"#ffffff"},title:drawuiCore.t("uml.fontSize"),children:an.map(L=>jsxRuntime.jsx("option",{value:L,children:L},L))}),jsxRuntime.jsx("button",{onClick:()=>e.updateUmlRowStyle(c,d,T.id,{strikethrough:!K}),className:"drawui-uml-toolbar-btn",title:drawuiCore.t("uml.strikethrough"),style:{border:"none",background:K?"var(--dw-primary-weak)":"transparent",cursor:"pointer",padding:2,borderRadius:3},children:jsxRuntime.jsx("span",{style:{fontWeight:700,fontSize:13*g,textDecoration:"line-through"},children:"A"})}),jsxRuntime.jsx("button",{onClick:()=>{d==="attribute"?e.removeUmlAttribute(c,T.id):e.removeUmlMethod(c,T.id),h(null);},className:"drawui-uml-toolbar-btn",title:drawuiCore.t("uml.delete"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#ef4444",padding:2,marginLeft:"auto",borderRadius:3},children:jsxRuntime.jsxs("svg",{width:14*g,height:14*g,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("polyline",{points:"3 6 5 6 21 6"}),jsxRuntime.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),jsxRuntime.jsx("path",{d:"M10 11v6"}),jsxRuntime.jsx("path",{d:"M14 11v6"}),jsxRuntime.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]})]})},Ae=H.pageToScreen({x:_-V,y:z}).x,Xe=H.pageToScreen({x:_,y:z-Q}).y,je=B*g,qe=R*g;return jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:Ae+1,top:Xe+1,width:Math.max(0,je-2),height:Math.max(0,qe-2),background:"#ffffff",pointerEvents:"none",zIndex:51}}),jsxRuntime.jsx("input",{style:{...Me,position:"absolute",left:Se.x-pe/2,top:Se.y-ee*g/2+2,width:pe,height:ee*g-4,textAlign:"center",fontWeight:700,fontSize:(t.fontSize||drawuiCore.UML_FONT_SIZE)*g,color:t.textColor||"#1f2937",pointerEvents:"auto",zIndex:52,...p?.section==="className"?{borderColor:"var(--dw-primary)"}:{}},value:ke,onChange:d=>b?e.updateUmlInterface(c,{className:d.target.value}):e.updateUmlClass(c,{className:d.target.value}),onFocus:()=>s("className",""),onBlur:x,spellCheck:false}),!b&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l.map((d,S)=>Y("attribute",S,d,le(S))),ie("attribute",Ee,"\u5C5E\u6027")]}),n.map((d,S)=>Y("method",S,d,Ne(S))),ie("method",fe,drawuiCore.t("uml.method")),De()]})});var Nt=react.memo(function({editor:e,panelOpen:t,onOpenPanel:o}){let[,u]=react.useState(0);D(),react.useEffect(()=>{if(!e)return;let B=e.subscribe(()=>u(R=>R+1));return ()=>{B();}},[e]);let p=react.useRef(false),h=react.useRef(false);if(!e)return null;let i=e.getMindMapEditingShapeId();if(!i||t)return null;let k=e.getMindMapSelectedNode();if(!k||k.shapeId!==i)return null;let m=e.getMindMapNode(i,k.nodeId),y=e.getMindMapNodeScreenRect(i,k.nodeId);if(!m||!y)return null;let s=e.getCamera().getZoom(),x=drawuiCore.MINDMAP_FONT_SIZE*s,H=Math.max(100,y.width+24),c=y.height+8,_={position:"absolute",left:y.x+y.width/2,top:y.y-4,transform:"translateX(-50%)",width:H,height:c,border:"1.5px solid var(--dw-primary, #3b82f6)",borderRadius:6,background:"#ffffff",boxShadow:"0 2px 10px rgba(0,0,0,0.15)",outline:"none",padding:`0 ${(m.icon?24:12)*s}px`,fontFamily:"sans-serif",fontSize:x,color:"#1f2937",boxSizing:"border-box",pointerEvents:"auto",zIndex:55},z={position:"absolute",left:y.x+y.width+12,top:y.y+y.height/2-11,width:22,height:22,border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:"50%",cursor:"pointer",color:"#6b7280",fontSize:13,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 4px rgba(0,0,0,0.12)",pointerEvents:"auto",zIndex:55};return jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsxRuntime.jsx("input",{autoFocus:true,style:_,value:m.text,spellCheck:false,onChange:B=>{let R=!p.current;p.current=true,e.updateMindMapNode(i,k.nodeId,{text:B.target.value},R);},onBlur:()=>{if(h.current){h.current=false;return}e.exitMindMapEdit();},onKeyDown:B=>{B.key==="Enter"?B.target.blur():B.key==="Escape"&&e.exitMindMapEdit();}}),jsxRuntime.jsx("button",{style:z,title:drawuiCore.t("mindmap.more"),onMouseDown:B=>{B.preventDefault(),h.current=true,setTimeout(()=>{h.current=false;},300);},onClick:o,children:"\u22EF"})]})});var Et=[...drawuiCore.MINDMAP_COLORS,"#1f2937","#9ca3af"],Rt=["\u{1F4A1}","\u2B50","\u{1F525}","\u{1F4CC}","\u2705","\u2757","\u26A0\uFE0F","\u{1F3F7}\uFE0F"],wn={position:"absolute",width:232,background:"rgba(255,255,255,0.96)",border:"1px solid #e5e7eb",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.12)",padding:"10px 12px",fontSize:12,color:"#1f2937",zIndex:70,boxSizing:"border-box",fontFamily:"sans-serif"},rt={fontSize:11,color:"#6b7280",marginBottom:4,display:"block"},We={display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},Ze={border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:5,padding:"3px 8px",fontSize:12,color:"#374151",cursor:"pointer",lineHeight:1.5},it={width:"100%",border:"1px solid #e5e7eb",borderRadius:5,padding:"4px 8px",fontSize:12,outline:"none",boxSizing:"border-box",background:"#ffffff",color:"#1f2937"},It=react.memo(function({editor:e,mindMap:t}){let[,o]=react.useState(0);D(),react.useEffect(()=>{if(!e)return;let n=e.subscribe(()=>o(b=>b+1));return ()=>{n();}},[e]);let u=react.useRef(null);if(!e||!t||e.getMindMapEditingShapeId()!==t.id)return null;let p=e.getMindMapSelectedNode();if(!p||p.shapeId!==t.id)return null;let h=n=>{if(n.id===p.nodeId)return n;for(let b of n.children??[]){let l=h(b);if(l)return l}return null},i=h(t.root);if(!i)return null;let k=e.getCamera(),y=drawuiCore.layoutMindMap(t.root).positions.get(i.id);if(!y)return null;let s=k.zoom,x=k.pageToScreen({x:t.x+y.x,y:t.y+y.y}),H=x.x+y.width*s/2+14,c=x.y-80,z=Math.max(8,Math.min(H,(window.innerWidth||1024)-232-8)),B=Math.max(8,Math.min(c,(window.innerHeight||768)-320)),R=n=>{e.updateMindMapNode(t.id,i.id,n);},ke=!!i.id&&i.id!==t.root.id;return jsxRuntime.jsxs("div",{ref:u,style:{...wn,left:z,top:B},onMouseDown:n=>n.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[jsxRuntime.jsx("span",{style:{fontWeight:600,fontSize:12},children:drawuiCore.t("mindmap.nodeText")}),jsxRuntime.jsx("button",{onClick:()=>e.exitMindMapEdit(),title:drawuiCore.t("mindmap.close"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#9ca3af",fontSize:14,lineHeight:1,padding:2},children:"\xD7"})]}),jsxRuntime.jsx("input",{style:{...it,marginBottom:8},value:i.text,onChange:n=>R({text:n.target.value}),spellCheck:false}),jsxRuntime.jsxs("div",{style:{...We,marginBottom:10},children:[jsxRuntime.jsxs("button",{style:Ze,onClick:()=>e.addMindMapChild(t.id,i.id),children:["+ ",drawuiCore.t("mindmap.addChild")]}),ke&&jsxRuntime.jsxs("button",{style:Ze,onClick:()=>e.addMindMapSibling(t.id,i.id),children:["+ ",drawuiCore.t("mindmap.addSibling")]}),!!i.children?.length&&jsxRuntime.jsx("button",{style:Ze,onClick:()=>e.toggleMindMapCollapse(t.id,i.id),children:i.collapsed?drawuiCore.t("mindmap.expand"):drawuiCore.t("mindmap.collapse")}),jsxRuntime.jsx("button",{style:{...Ze,color:"#ef4444",borderColor:"#fecaca",marginLeft:"auto"},onClick:()=>e.deleteMindMapNode(t.id,i.id),children:drawuiCore.t("mindmap.deleteNode")})]}),jsxRuntime.jsx("span",{style:rt,children:drawuiCore.t("mindmap.color")}),jsxRuntime.jsxs("div",{style:{...We,marginBottom:10},children:[jsxRuntime.jsx("button",{title:drawuiCore.t("mindmap.levelColor"),onClick:()=>R({color:void 0}),style:{width:18,height:18,borderRadius:4,border:"1.5px solid #d1d5db",background:"conic-gradient(#ef4444, #f59e0b, #10b981, #3b82f6, #8b5cf6, #ec4899, #ef4444)",cursor:"pointer",flexShrink:0}}),Et.map(n=>jsxRuntime.jsx("button",{title:n,onClick:()=>R({color:n}),style:{width:18,height:18,borderRadius:4,border:i.color===n?"2px solid #111827":"1px solid #d1d5db",background:n,cursor:"pointer",flexShrink:0}},n))]}),jsxRuntime.jsx("span",{style:rt,children:drawuiCore.t("mindmap.icon")}),jsxRuntime.jsxs("div",{style:{...We,marginBottom:10},children:[jsxRuntime.jsx("button",{title:drawuiCore.t("mindmap.noIcon"),onClick:()=>R({icon:void 0}),style:{width:22,height:22,borderRadius:4,border:i.icon?"1px solid #d1d5db":"2px solid #111827",background:"#f9fafb",cursor:"pointer",fontSize:11,color:"#9ca3af",lineHeight:1},children:"\u2205"}),Rt.map(n=>jsxRuntime.jsx("button",{onClick:()=>R({icon:n}),style:{width:22,height:22,borderRadius:4,border:i.icon===n?"2px solid #111827":"1px solid #d1d5db",background:"#f9fafb",cursor:"pointer",fontSize:13,lineHeight:1},children:n},n)),jsxRuntime.jsx("input",{placeholder:"\u270F\uFE0F",defaultValue:i.icon&&!Rt.includes(i.icon)?i.icon:"",onKeyDown:n=>{if(n.key==="Enter"){let b=n.target.value.trim();R({icon:b||void 0});}},onBlur:n=>{let b=n.target.value.trim();b!==i.icon&&R({icon:b||void 0});},style:{...it,width:56,padding:"2px 4px",textAlign:"center"}})]}),jsxRuntime.jsx("span",{style:rt,children:drawuiCore.t("mindmap.note")}),jsxRuntime.jsx("input",{style:{...it,marginBottom:6},value:i.note??"",placeholder:drawuiCore.t("mindmap.notePlaceholder"),onChange:n=>R({note:n.target.value||void 0}),spellCheck:false}),!!i.note&&jsxRuntime.jsxs("div",{style:{...We,marginTop:4},children:[jsxRuntime.jsx("span",{style:{fontSize:11,color:"#6b7280"},children:drawuiCore.t("mindmap.noteColor")}),jsxRuntime.jsx("button",{title:drawuiCore.t("mindmap.noteColorDefault"),onClick:()=>R({noteColor:void 0}),style:{width:16,height:16,borderRadius:3,border:i.noteColor?"1px solid #d1d5db":"2px solid #111827",background:"repeating-conic-gradient(#ef4444 0% 25%, #f59e0b 0% 50%, #10b981 0% 75%, #3b82f6 0% 100%)",cursor:"pointer"}}),Et.map(n=>jsxRuntime.jsx("button",{onClick:()=>R({noteColor:n}),style:{width:16,height:16,borderRadius:3,border:i.noteColor===n?"2px solid #111827":"1px solid #d1d5db",background:n,cursor:"pointer"}},n))]})]})});var st=220,lt=140,Cn="#fafafa";function Ln(a,e){let t=Math.min(a.x,e.x),o=Math.min(a.y,e.y),u=Math.max(a.x+a.width,e.x+e.width),p=Math.max(a.y+a.height,e.y+e.height);return {x:t,y:o,width:u-t,height:p-o}}function Tn(a){return {x:a.x+a.width/2,y:a.y+a.height/2}}function Nn(){return {x:0,y:0,width:0,height:0}}function En(a){let e=1/0,t=1/0,o=-1/0,u=-1/0,p=false;for(let h of a){let i=dt(h);i&&(p=true,i.x<e&&(e=i.x),i.y<t&&(t=i.y),i.x+i.width>o&&(o=i.x+i.width),i.y+i.height>u&&(u=i.y+i.height));}return p?{x:e,y:t,width:o-e,height:u-t}:null}function dt(a){switch(a.type){case "rectangle":case "rounded-rectangle":case "ellipse":case "diamond":case "triangle":case "hexagon":case "text":return {x:a.x-a.width/2,y:a.y-a.height/2,width:a.width,height:a.height};case "circle":return {x:a.x-a.radius,y:a.y-a.radius,width:a.radius*2,height:a.radius*2};case "line":case "arrow":case "draw":{let e=a.points;if(!e||e.length===0)return null;let t=1/0,o=1/0,u=-1/0,p=-1/0;for(let h of e)h.x<t&&(t=h.x),h.y<o&&(o=h.y),h.x>u&&(u=h.x),h.y>p&&(p=h.y);return {x:t,y:o,width:u-t,height:p-o}}default:return null}}function Rn(a){let e=a.getCamera(),t=e.screenToPage({x:0,y:0}),o=e.screenToPage({x:window.innerWidth,y:window.innerHeight});return {x:t.x,y:t.y,width:o.x-t.x,height:o.y-t.y}}function In(a,e,t){if(a.width<=0||a.height<=0)return {x:a.x-e/2,y:a.y-t/2,width:e,height:t};let o=e/t,u=a.width,p=u/o;p<a.height&&(p=a.height,u=p*o);let h=Tn(a);return {x:h.x-u/2,y:h.y-p/2,width:u,height:p}}function ct(a,e,t,o){let u=(a-t.left)/t.width,p=(e-t.top)/t.height;return {x:o.x+u*o.width,y:o.y+p*o.height}}var zt=react.memo(function({editor:e}){let t=react.useRef(null),o=react.useRef(null),[u,p]=react.useState(false),[h,i]=react.useState(100),[k,m]=react.useState(false),[y,s]=react.useState(false);D();let x=react.useRef(null),H=react.useRef(null);react.useLayoutEffect(()=>{let n=t.current,b=o.current;if(!n||!b)return;let l=window.devicePixelRatio||1;n.width=Math.round(st*l),n.height=Math.round(lt*l),n.style.width=`${st}px`,n.style.height=`${lt}px`;},[u]);let c=react.useCallback(()=>{let n=t.current,b=o.current;if(!n||!b||!e)return;let l=n.getContext("2d");if(!l)return;let V=st,Q=lt,ee=n.width,F=n.height,ye=e.getShapes(),re=new Set(e.getSelectedIds()),te=drawuiCore.getTheme(),g=drawuiCore.hexToRgba(te.text,.16),pe=te.primary,Le=drawuiCore.hexToRgba(te.primary,.18),Te=drawuiCore.hexToRgba(te.primary,.85),Se=En(ye),I=Rn(e),he=Se?Ln(Se,I):I.width>0?I:Nn(),le=In(he,V,Q);H.current=le;let Ne=ee/le.width,Ee=F/le.height,fe=V/le.width;l.setTransform(1,0,0,1,0,0),l.fillStyle=Cn,l.fillRect(0,0,ee,F),l.setTransform(Ne,0,0,Ee,-Ne*le.x,-Ee*le.y),l.fillStyle=g;for(let E of ye){let w=dt(E);w&&l.fillRect(w.x,w.y,w.width,w.height);}l.fillStyle=pe;for(let E of ye){if(!re.has(E.id))continue;let w=dt(E);w&&l.fillRect(w.x,w.y,w.width,w.height);}l.fillStyle=Le,l.fillRect(I.x,I.y,I.width,I.height);let Me=1.5/fe;l.strokeStyle=Te,l.lineWidth=Me,l.lineJoin="round";let Re=Math.min(I.width/6,I.height/6,6/fe);if(l.beginPath(),Re*fe<1)l.rect(I.x,I.y,I.width,I.height);else {let E=I.x,w=I.y,ne=I.width,G=I.height,Y=Math.min(Re,ne/2,G/2);l.moveTo(E+Y,w),l.lineTo(E+ne-Y,w),l.quadraticCurveTo(E+ne,w,E+ne,w+Y),l.lineTo(E+ne,w+G-Y),l.quadraticCurveTo(E+ne,w+G,E+ne-Y,w+G),l.lineTo(E+Y,w+G),l.quadraticCurveTo(E,w+G,E,w+G-Y),l.lineTo(E,w+Y),l.quadraticCurveTo(E,w,E+Y,w),l.closePath();}l.stroke(),l.setTransform(1,0,0,1,0,0);},[e]);react.useEffect(()=>{if(!e||u)return;c();let n=e.subscribe(c),b=drawuiCore.subscribeTheme(c),l=()=>c();return window.addEventListener("resize",l),()=>{n(),b(),window.removeEventListener("resize",l);}},[e,u,c]),react.useEffect(()=>{if(!e)return;let n=()=>{let l=e.getCamera().getZoom();i(Math.round(l*100));};n();let b=e.subscribe(n);return ()=>{b();}},[e]);let _=react.useCallback((n,b)=>{if(!e)return;let l=e.getCamera(),V=l.getZoom(),Q=window.innerWidth/2,ee=window.innerHeight/2,F=l;F.x=Q-n*V,F.y=ee-b*V,e.requestRender();},[e]),z=n=>{if(!e||!o.current||n.button!==0)return;let b=o.current.getBoundingClientRect(),l=H.current;if(!l)return;let V=ct(n.clientX,n.clientY,b,l);x.current={pointerId:n.pointerId,rect:{left:b.left,top:b.top,width:b.width,height:b.height},canvasBox:l},n.currentTarget.setPointerCapture(n.pointerId),s(true),_(V.x,V.y);},B=n=>{if(!y||!e||!x.current||!o.current)return;let b=x.current,l=ct(n.clientX,n.clientY,b.rect,b.canvasBox);_(l.x,l.y);},R=n=>{if(y){s(false),x.current=null;try{n.currentTarget.releasePointerCapture(n.pointerId);}catch{}}},ke=n=>{if(!e||!o.current)return;let b=H.current;if(!b)return;let l=o.current.getBoundingClientRect(),V=ct(n.clientX,n.clientY,l,b);_(V.x,V.y);};return jsxRuntime.jsxs("div",{className:`drawui-minimap ${u?"collapsed":""}`,children:[jsxRuntime.jsx("button",{className:"drawui-minimap-toggle",onClick:()=>p(n=>!n),title:u?drawuiCore.t("minimap.expand"):drawuiCore.t("minimap.collapse"),"aria-label":u?drawuiCore.t("minimap.expand"):drawuiCore.t("minimap.collapse"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u?jsxRuntime.jsx("polyline",{points:"9 6 15 12 9 18"}):jsxRuntime.jsx("polyline",{points:"15 6 9 12 15 18"})})}),!u&&jsxRuntime.jsxs("div",{className:"drawui-minimap-panel",children:[jsxRuntime.jsxs("div",{className:"drawui-minimap-header",children:[jsxRuntime.jsx("span",{className:"drawui-minimap-title",children:drawuiCore.t("minimap.title")}),jsxRuntime.jsxs("span",{className:"drawui-minimap-zoom",children:[h,"%"]})]}),jsxRuntime.jsx("div",{ref:o,className:"drawui-minimap-canvas-wrap",style:{cursor:y?"grabbing":k?"pointer":"default"},onPointerEnter:()=>m(true),onPointerLeave:()=>m(false),children:jsxRuntime.jsx("canvas",{ref:t,className:"drawui-minimap-canvas",onPointerDown:z,onPointerMove:B,onPointerUp:R,onPointerCancel:R,onDoubleClick:ke})})]})]})});var J=a=>jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",className:"drawui-gen-shape-glyph",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:a}),zn=[{type:"rectangle",labelKey:"shape.rectangle",glyph:J(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:J(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:J(jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:J(jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:J(jsxRuntime.jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:J(jsxRuntime.jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:J(jsxRuntime.jsx("path",{d:"M12 3 L19.5 7.5 V16.5 L12 21 L4.5 16.5 V7.5 Z"}))},{type:"parallelogram",labelKey:"shape.parallelogram",glyph:J(jsxRuntime.jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:J(jsxRuntime.jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:J(jsxRuntime.jsx("path",{d:"M12 4 L19.5 9.5 L16.5 18.5 H7.5 L4.5 9.5 Z"}))},{type:"octagon",labelKey:"shape.octagon",glyph:J(jsxRuntime.jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:J(jsxRuntime.jsx("path",{d:"M12 3 L14 9.5 L20.5 10 L15.5 14 L17.5 20.5 L12 16.8 L6.5 20.5 L8.5 14 L3.5 10 L10 9.5 Z"}))},{type:"uml-class",labelKey:"shape.uml-class",glyph:J(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsxRuntime.jsx("path",{d:"M3 9 H21"}),jsxRuntime.jsx("path",{d:"M3 15 H21"}),jsxRuntime.jsx("path",{d:"M6 6.5 H10"}),jsxRuntime.jsx("path",{d:"M6 12.5 H12"})]}))},{type:"uml-interface",labelKey:"shape.uml-interface",glyph:J(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsxRuntime.jsx("path",{d:"M3 9 H21"}),jsxRuntime.jsx("path",{d:"M6 6.5 H10"}),jsxRuntime.jsx("path",{d:"M6 12.5 H12"})]}))},{type:"mind-map",labelKey:"shape.mind-map",glyph:J(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("circle",{cx:"5",cy:"12",r:"2"}),jsxRuntime.jsx("path",{d:"M7 12h2.6"}),jsxRuntime.jsx("path",{d:"M9.6 12c0-2 1.2-3.4 2.6-3.4"}),jsxRuntime.jsx("path",{d:"M9.6 12c0 2 1.2 3.4 2.6 3.4"}),jsxRuntime.jsx("circle",{cx:"15.2",cy:"8.6",r:"1.3"}),jsxRuntime.jsx("circle",{cx:"15.2",cy:"15.4",r:"1.3"}),jsxRuntime.jsx("circle",{cx:"13.6",cy:"12",r:"1.3"})]}))}];function Bt({editor:a,x:e,y:t,context:o,existingArrowId:u,defaultShapeType:p,onClose:h}){let i=react.useRef(null);D();let k=m=>{a?.createGeneratedConnection(o,{type:m,existingArrowId:u}),h();};return react.useEffect(()=>{let m=x=>{i.current&&!i.current.contains(x.target)&&h();},y=x=>{x.key==="Escape"&&(x.preventDefault(),h());},s=setTimeout(()=>{window.addEventListener("pointerdown",m,true),window.addEventListener("keydown",y,true);},0);return ()=>{clearTimeout(s),window.removeEventListener("pointerdown",m,true),window.removeEventListener("keydown",y,true);}},[h]),jsxRuntime.jsxs("div",{className:"drawui-gen-menu",ref:i,style:{left:e,top:t},children:[jsxRuntime.jsx("div",{className:"drawui-gen-menu-label",children:drawuiCore.t("menu.title")}),jsxRuntime.jsx("div",{className:"drawui-gen-shape-grid",children:zn.map(m=>jsxRuntime.jsxs("button",{className:`drawui-gen-shape-btn${m.type===p?" drawui-gen-shape-active":""}`,onClick:()=>k(m.type),title:drawuiCore.t(m.labelKey),children:[m.glyph,jsxRuntime.jsx("span",{className:"drawui-gen-shape-label",children:drawuiCore.t(m.labelKey)})]},m.type))}),jsxRuntime.jsx("div",{className:"drawui-gen-menu-hint",children:drawuiCore.t("menu.cancel")})]})}var An={select:"tool.select",hand:"tool.hand",rectangle:"tool.rectangle","rounded-rectangle":"tool.rounded-rectangle",circle:"tool.circle",ellipse:"tool.ellipse",diamond:"tool.diamond",triangle:"tool.triangle",hexagon:"tool.hexagon",parallelogram:"tool.parallelogram",trapezoid:"tool.trapezoid",pentagon:"tool.pentagon",octagon:"tool.octagon",star:"tool.star","uml-class":"tool.uml-class","uml-interface":"tool.uml-interface",line:"tool.line",arrow:"tool.arrow",text:"tool.text",draw:"tool.draw",pen:"tool.pen",highlighter:"tool.highlighter",eraser:"tool.eraser","mind-map":"tool.mind-map"};function Un({initialTool:a="select",className:e="",themeColor:t,language:o="zh-CN",data:u,onChange:p,onReady:h}){let i=react.useRef(null),k=react.useRef(null),m=react.useRef(null),[y,s]=react.useState(null);D();let[x,H]=react.useState(a),[c,_]=react.useState(false),[z,B]=react.useState(0),[R,ke]=react.useState(false),[n,b]=react.useState("straight"),[l,V]=react.useState("end"),[Q,ee]=react.useState(false),[F,ye]=react.useState(100),[re,te]=react.useState(null),[g,pe]=react.useState(null),[Le,Te]=react.useState(false),[Se,I]=react.useState(false),[he,le]=react.useState(null),[Ne,Ee]=react.useState(null),[fe,Me]=react.useState(false),[Re,E]=react.useState(null),[w,ne]=react.useState(null),G=react.useRef(null),Y=react.useRef(0),ie=react.useRef(null),De=react.useRef(p);De.current=p;let Ae=react.useRef(h);Ae.current=h,react.useEffect(()=>{if(!i.current)return;let f=new drawuiCore.Editor(i.current,{theme:t?{primary:t,editBorder:t,selection:{outline:t,handleStroke:t,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(t,.1),shadow:t}}:void 0,language:o,shapes:u,persist:!u});m.current=f,s(f),window.__drawuiEditor=f,Ae.current?.(f),a&&f.setActiveTool(a);let W=f.subscribe(()=>{H(f.getActiveTool());let C=f.getSelectedIds();B(C.length);let K=f.getShapes().filter(de=>C.includes(de.id)&&(de.type==="line"||de.type==="arrow"));if(ke(K.length>0),K.length>0&&K[0].connectionType?b(K[0].connectionType):K.length>0&&b("straight"),K.length>0){let de=K.find(Je=>Je.type==="arrow");de&&(V(de.arrowHead??"end"),ee(de.dashed??false));}ye(Math.round(f.getCamera().getZoom()*100)),Te(f.canUndo()),I(f.canRedo());let L=f.getSelectedUml();le(L),L||E(null);let Ue=f.getSelectedMindMap();Ee(Ue),f.getMindMapEditingShapeId()||Me(false),De.current?.(f.getData());}),ae=f.subscribeNotifications(C=>{pe(C),G.current&&clearTimeout(G.current),G.current=setTimeout(()=>pe(null),2e3);}),ce=f.subscribeUi(C=>{C.kind==="shapeTypeMenu"&&ne({x:C.screenX,y:C.screenY,context:C.context,existingArrowId:C.existingArrowId,defaultShapeType:C.defaultShapeType});});return ()=>{W(),ae(),ce(),G.current&&clearTimeout(G.current),cancelAnimationFrame(Y.current),f.dispose();}},[a]),react.useEffect(()=>{if(!t)return;let f=k.current;f&&(f.style.setProperty("--dw-primary",t),f.style.setProperty("--dw-primary-hover",drawuiCore.shadeColor(t,-0.12)),f.style.setProperty("--dw-primary-weak",drawuiCore.hexToRgba(t,.1)),f.style.setProperty("--dw-primary-contrast","#ffffff"),f.style.setProperty("--dw-shadow-primary",`0 2px 8px ${drawuiCore.hexToRgba(t,.3)}`)),m.current?.setTheme({primary:t,editBorder:t,selection:{outline:t,handleStroke:t,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(t,.1),shadow:t}});},[t]),react.useEffect(()=>{drawuiCore.setLanguage(o),m.current?.setLanguage(o);},[o]);let Xe=react.useCallback(f=>{m.current?.setActiveTool(f);},[]),je=react.useCallback(()=>{m.current?.zoomIn();},[]),qe=react.useCallback(()=>{m.current?.zoomOut();},[]),d=react.useCallback(()=>{m.current?.resetZoom();},[]),S=react.useCallback(()=>{let f=!c;_(f),m.current?.setShowGrid(f);},[c]),M=react.useCallback(()=>{m.current?.undo();},[]),T=react.useCallback(()=>{m.current?.redo();},[]),U=react.useCallback(f=>{let W=m.current,ae=i.current;if(!W||!ae)return;if(W.isPointerDown()){ie.current!==null&&(ie.current=null,te(null));return}let ce=f.clientX,C=f.clientY;cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{let ge=ae.getBoundingClientRect(),K=ce-ge.left,L=C-ge.top,Ue=K+12,de=L+12,Je=W.getSelectedUml()?.id,Pe=W.getUmlRowAtScreenPoint({x:K,y:L});if(Pe&&Pe.shape.id!==Je&&Pe.text){ie.current!==Pe.text&&(ie.current=Pe.text,te({text:Pe.text,x:Ue,y:de}));return}let ze=W.getShapeAtScreenPoint({x:K,y:L});ze&&ze.text?ie.current!==ze.text&&(ie.current=ze.text,te({text:ze.text,x:Ue,y:de})):ie.current!==null&&(ie.current=null,te(null));});},[]),$=react.useCallback(()=>{te(null);},[]),Ie=react.useCallback(f=>{let W=m.current,ae=i.current;if(!W||!ae)return;let ce=ae.getBoundingClientRect(),C=f.clientX-ce.left,ge=f.clientY-ce.top,K=W.getUmlRowAtScreenPoint({x:C,y:ge});if(K){E(K.shape.id);return}let L=W.getMindMapNodeAtScreenPoint({x:C,y:ge});L&&W.beginMindMapEdit(L.shapeId,L.nodeId);},[]),He=react.useCallback(()=>{ne(null);},[]);return jsxRuntime.jsxs("div",{ref:k,className:`drawui-canvas-board ${e}`,children:[jsxRuntime.jsx("canvas",{ref:i,className:"drawui-canvas",onMouseMove:U,onMouseLeave:$,onDoubleClick:Ie}),re&&jsxRuntime.jsx("div",{className:"drawui-tooltip",style:{left:re.x,top:re.y},children:re.text}),jsxRuntime.jsx(Qe,{activeTool:x,onToolChange:Xe,showGrid:c,onToggleGrid:S,canUndo:Le,canRedo:Se,onUndo:M,onRedo:T}),jsxRuntime.jsx(et,{onZoomIn:je,onZoomOut:qe,onReset:d,zoomLevel:F}),jsxRuntime.jsx(xt,{editor:y,selectedCount:z,hasLineSelection:R,currentConnectionType:n,currentArrowHead:l,currentDashed:Q}),jsxRuntime.jsx(Ct,{editor:y,umlClass:he,editing:Re}),jsxRuntime.jsx(Nt,{editor:y,panelOpen:fe,onOpenPanel:()=>Me(true)}),fe&&jsxRuntime.jsx(It,{editor:y,mindMap:Ne}),jsxRuntime.jsx(zt,{editor:y}),w&&jsxRuntime.jsx(Bt,{editor:y,x:w.x,y:w.y,context:w.context,existingArrowId:w.existingArrowId,defaultShapeType:w.defaultShapeType,onClose:He}),jsxRuntime.jsxs("div",{className:"drawui-status-bar",children:[jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:drawuiCore.t(An[x])})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:z===0?drawuiCore.t("status.none"):drawuiCore.t("status.selected",{n:z})})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsxs("span",{children:[F,"%"]})})]}),g&&jsxRuntime.jsxs("div",{className:"drawui-toast",children:[jsxRuntime.jsx("svg",{className:"drawui-toast-icon",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),g]})]})}exports.CanvasBoard=Un;exports.Toolbar=Qe;exports.ZoomControl=et;
1
+ 'use strict';var react=require('react'),drawuiCore=require('drawui-core'),jsxRuntime=require('react/jsx-runtime');function A(){let[s,e]=react.useState(drawuiCore.getLanguage());return react.useEffect(()=>drawuiCore.subscribeLanguage(()=>e(drawuiCore.getLanguage())),[]),s}var bt=[{type:"rectangle",icon:jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"0"})},{type:"rounded-rectangle",icon:jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4"})},{type:"circle",icon:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"8"})},{type:"ellipse",icon:jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"6"})},{type:"diamond",icon:jsxRuntime.jsx("path",{d:"M12 3L21 12L12 21L3 12Z"})},{type:"triangle",icon:jsxRuntime.jsx("path",{d:"M12 4L20 19L4 19Z"})},{type:"hexagon",icon:jsxRuntime.jsx("path",{d:"M12 3L20 7.5V16.5L12 21L4 16.5V7.5Z"})},{type:"parallelogram",icon:jsxRuntime.jsx("path",{d:"M7 5L20 5L17 19L4 19Z"})},{type:"trapezoid",icon:jsxRuntime.jsx("path",{d:"M6 5L18 5L21 19L3 19Z"})},{type:"pentagon",icon:jsxRuntime.jsx("path",{d:"M12 3L21 10L17.5 21L6.5 21L3 10Z"})},{type:"octagon",icon:jsxRuntime.jsx("path",{d:"M8 3L16 3L21 8L21 16L16 21L8 21L3 16L3 8Z"})},{type:"star",icon:jsxRuntime.jsx("path",{d:"M12 2L14.5 8.5L21 9L16 13.5L17.5 20L12 16.5L6.5 20L8 13.5L3 9L9.5 8.5Z"})}],Ot=new Set(bt.map(s=>s.type)),_t=[{type:"arrow",icon:"M5 12h14M12 5l7 7-7 7",labelKey:"toolbar.arrow"},{type:"text",icon:"M4 7V4h16v3M9 20h6M12 4v16",labelKey:"toolbar.text"}],Ft=[{type:"pen",icon:"M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3Z",labelKey:"toolbar.pen"},{type:"highlighter",icon:"M14 3l7 7-3 3-7-7 3-3zM9 8L3 14v3h3l6-6",labelKey:"toolbar.highlighter"}],Vt=[{type:"eraser",icon:"M7 21l-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21M22 21H7M5 11l9 9",labelKey:"toolbar.eraser"}],Yt="M18 11V6.5a1.5 1.5 0 0 0-3 0v3.5a1.5 1.5 0 0 0-3 0V3.5a1.5 1.5 0 0 0-3 0v6.5a1.5 1.5 0 0 0-3 0V14a8 8 0 0 0 16 0v-3a1.5 1.5 0 0 0-3 0",et=react.memo(function({activeTool:e,onToolChange:t,showGrid:r,onToggleGrid:u,canUndo:p=false,canRedo:m=false,onUndo:a,onRedo:S,onExport:h}){let[f,l]=react.useState(false),[b,R]=react.useState(false),x=react.useRef(null),K=react.useRef(null);A();let I=[{format:"png",labelKey:"toolbar.export.png"},{format:"svg",labelKey:"toolbar.export.svg"},{format:"pdf",labelKey:"toolbar.export.pdf"}],z=()=>{x.current&&(clearTimeout(x.current),x.current=null),R(true);},N=()=>{x.current=window.setTimeout(()=>R(false),200);},he=()=>{K.current&&(clearTimeout(K.current),K.current=null),l(true);},n=()=>{K.current=window.setTimeout(()=>{l(false);},200);};return jsxRuntime.jsx("div",{className:"drawui-toolbar-container",children:jsxRuntime.jsxs("div",{className:"drawui-toolbar",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="select"?"active":""}`,onClick:()=>t("select"),title:drawuiCore.t("toolbar.select"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"3"})})}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="hand"?"active":""}`,onClick:()=>t("hand"),title:drawuiCore.t("toolbar.hand"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:Yt})})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:he,onMouseLeave:n,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${Ot.has(e)?"active":""}`,onClick:()=>t("rounded-rectangle"),title:"\u5F62\u72B6",children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4",ry:"4"})})}),f&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid",children:bt.map(i=>jsxRuntime.jsx("button",{className:`drawui-toolbar-shape-item ${e===i.type?"active":""}`,onClick:()=>{t(i.type),l(false);},title:drawuiCore.t("tool."+i.type),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:i.icon})},i.type))})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),_t.map(i=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===i.type?"active":""}`,onClick:()=>t(i.type),title:drawuiCore.t(i.labelKey),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:i.icon})})},i.type)),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),Ft.map(i=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===i.type?"active":""}`,onClick:()=>t(i.type),title:drawuiCore.t(i.labelKey),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:i.icon})})},i.type)),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),Vt.map(i=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===i.type?"active":""}`,onClick:()=>t(i.type),title:drawuiCore.t(i.labelKey),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:i.icon})})},i.type)),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="uml-class"?"active":""}`,onClick:()=>t("uml-class"),title:drawuiCore.t("toolbar.uml-class"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsxRuntime.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsxRuntime.jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),jsxRuntime.jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsxRuntime.jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"}),jsxRuntime.jsx("line",{x1:"7",y1:"18",x2:"11",y2:"18"})]})}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="uml-interface"?"active":""}`,onClick:()=>t("uml-interface"),title:drawuiCore.t("toolbar.uml-interface"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsxRuntime.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsxRuntime.jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsxRuntime.jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"})]})}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="mind-map"?"active":""}`,onClick:()=>t("mind-map"),title:drawuiCore.t("toolbar.mind-map"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"5",cy:"12",r:"2.4"}),jsxRuntime.jsx("path",{d:"M7.4 12h3.6"}),jsxRuntime.jsx("path",{d:"M11 12c0-2.6 1.6-4.4 3.4-4.4"}),jsxRuntime.jsx("path",{d:"M11 12c0 2.6 1.6 4.4 3.4 4.4"}),jsxRuntime.jsx("circle",{cx:"17.4",cy:"7.6",r:"1.7"}),jsxRuntime.jsx("circle",{cx:"17.4",cy:"16.4",r:"1.7"}),jsxRuntime.jsx("circle",{cx:"15.6",cy:"12",r:"1.7"})]})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${r?"active":""}`,onClick:u,title:drawuiCore.t("toolbar.grid"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),jsxRuntime.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),jsxRuntime.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"}),jsxRuntime.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"})]})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:"drawui-toolbar-button",onClick:a,disabled:!p,style:p?void 0:{opacity:.4,cursor:"default"},title:drawuiCore.t("toolbar.undo"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 7v6h6"}),jsxRuntime.jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})}),jsxRuntime.jsx("button",{className:"drawui-toolbar-button",onClick:S,disabled:!m,style:m?void 0:{opacity:.4,cursor:"default"},title:drawuiCore.t("toolbar.redo"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M21 7v6h-6"}),jsxRuntime.jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"})]})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:z,onMouseLeave:N,children:[jsxRuntime.jsx("button",{className:"drawui-toolbar-button",title:drawuiCore.t("toolbar.export"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),jsxRuntime.jsx("polyline",{points:"7 10 12 15 17 10"}),jsxRuntime.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),b&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-export-grid",children:I.map(i=>jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{h?.(i.format),R(false);},title:drawuiCore.t(i.labelKey),children:drawuiCore.t(i.labelKey)},i.format))})]})]})})});var tt=react.memo(function({onZoomIn:e,onZoomOut:t,onReset:r,zoomLevel:u=100}){return A(),jsxRuntime.jsxs("div",{className:"drawui-zoom-control",children:[jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:e,title:drawuiCore.t("zoom.in"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),jsxRuntime.jsxs("div",{className:"drawui-zoom-level",children:[u,"%"]}),jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:t,title:"\u7F29\u5C0F",children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"})})}),jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:r,title:drawuiCore.t("zoom.reset"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),jsxRuntime.jsx("path",{d:"M3 3v5h5"})]})})]})});var wt=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af","#ffffff"],vt=[{key:"stroke",labelKey:"style.stroke",hasTransparent:false},{key:"fill",labelKey:"style.fill",hasTransparent:true},{key:"text",labelKey:"style.text",hasTransparent:false},{key:"highlight",labelKey:"style.highlight",hasTransparent:true}],jt=[{type:"straight",labelKey:"style.connection.straight",icon:"\u2501"},{type:"polyline",labelKey:"style.connection.polyline",icon:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M4 8 C 12 8, 12 16, 20 16"})})},{type:"orthogonal",labelKey:"style.connection.orthogonal",icon:"\u2517"},{type:"curve",labelKey:"style.connection.curve",icon:"\u223F"}],qt=[{type:"none",labelKey:"style.arrowhead.none",icon:"\u2501"},{type:"end",labelKey:"style.arrowhead.end",icon:"\u2192"},{type:"start",labelKey:"style.arrowhead.start",icon:"\u2190"},{type:"both",labelKey:"style.arrowhead.both",icon:"\u21C4"},{type:"inheritance",labelKey:"style.arrowhead.inheritance",icon:"\u2501\u2501\u25B7"},{type:"composition",labelKey:"style.arrowhead.composition",icon:"\u25C6\u2501\u2501"},{type:"aggregation",labelKey:"style.arrowhead.aggregation",icon:"\u25C7\u2501\u2501"}],kt=react.memo(function({editor:e,selectedCount:t,hasLineSelection:r,currentConnectionType:u,currentArrowHead:p,currentDashed:m}){if(A(),!e||t===0)return null;let a=(l,b)=>{switch(l){case "stroke":e.updateSelectedShapesStyle({strokeColor:b});break;case "fill":e.updateSelectedShapesStyle({fillColor:b});break;case "text":e.updateSelectedShapesText({textColor:b});break;case "highlight":e.updateSelectedShapesText({highlightColor:b});break}},S=l=>{e.updateConnectionType(l);},h=l=>{e.updateArrowHeadType(l);},f=l=>{e.updateArrowDashed(l);};return jsxRuntime.jsxs("div",{className:"drawui-style-panel",children:[jsxRuntime.jsx("div",{className:"drawui-style-col",children:vt.slice(0,2).map(l=>jsxRuntime.jsxs("div",{className:"drawui-style-group",children:[jsxRuntime.jsx("div",{className:"drawui-style-group-label",children:drawuiCore.t(l.labelKey)}),jsxRuntime.jsxs("div",{className:"drawui-color-row",children:[l.hasTransparent&&jsxRuntime.jsx("button",{className:"drawui-color-swatch drawui-color-swatch-transparent",onClick:()=>a(l.key,"transparent"),title:drawuiCore.t("style.none")}),wt.map(b=>jsxRuntime.jsx("button",{className:"drawui-color-swatch",style:{background:b},onClick:()=>a(l.key,b),title:b},`${l.key}-${b}`))]})]},l.key))}),jsxRuntime.jsx("div",{className:"drawui-style-divider"}),jsxRuntime.jsx("div",{className:"drawui-style-col",children:vt.slice(2).map(l=>jsxRuntime.jsxs("div",{className:"drawui-style-group",children:[jsxRuntime.jsx("div",{className:"drawui-style-group-label",children:drawuiCore.t(l.labelKey)}),jsxRuntime.jsxs("div",{className:"drawui-color-row",children:[l.hasTransparent&&jsxRuntime.jsx("button",{className:"drawui-color-swatch drawui-color-swatch-transparent",onClick:()=>a(l.key,"transparent"),title:drawuiCore.t("style.none")}),wt.map(b=>jsxRuntime.jsx("button",{className:"drawui-color-swatch",style:{background:b},onClick:()=>a(l.key,b),title:b},`${l.key}-${b}`))]})]},l.key))}),r&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-divider"}),jsxRuntime.jsxs("div",{className:"drawui-style-col",children:[jsxRuntime.jsxs("div",{className:"drawui-style-group",children:[jsxRuntime.jsx("div",{className:"drawui-style-group-label",children:drawuiCore.t("style.connection")}),jsxRuntime.jsx("div",{className:"drawui-connection-row",children:jt.map(l=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${u===l.type?" active":""}`,onClick:()=>S(l.type),title:drawuiCore.t(l.labelKey),children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:l.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(l.labelKey)})]},l.type))})]}),jsxRuntime.jsxs("div",{className:"drawui-style-group",children:[jsxRuntime.jsx("div",{className:"drawui-style-group-label",children:drawuiCore.t("style.arrow")}),jsxRuntime.jsx("div",{className:"drawui-connection-row",children:qt.map(l=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${p===l.type?" active":""}`,onClick:()=>h(l.type),title:drawuiCore.t(l.labelKey),children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:l.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(l.labelKey)})]},l.type))})]}),jsxRuntime.jsxs("div",{className:"drawui-style-group",children:[jsxRuntime.jsx("div",{className:"drawui-style-group-label",children:drawuiCore.t("style.dashed")}),jsxRuntime.jsxs("div",{className:"drawui-connection-row",children:[jsxRuntime.jsxs("button",{className:`drawui-connection-btn${m?"":" active"}`,onClick:()=>f(false),title:drawuiCore.t("style.solid"),children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:"\u2501"}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t("style.solid")})]}),jsxRuntime.jsxs("button",{className:`drawui-connection-btn${m?" active":""}`,onClick:()=>f(true),title:drawuiCore.t("style.dashed"),children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:"\u2504"}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t("style.dashed")})]})]})]})]})]})]})});var rt=14,Ct=20,an=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af"],sn=[12,14,16,18,20,24];function Lt(s,e,t){let r=s,u=t,p=r.charAt(0);if(r.length>1&&(p==="+"||p==="-"||p==="#"||p==="~")&&r.charAt(1)===" "&&(u=p,r=r.slice(2)),r=r.replace(/^\s+|\s+$/g,""),e==="attribute"){let l=r.indexOf(":");return l===-1?{visibility:u,name:r,type:"",params:"",returnType:""}:{visibility:u,name:r.slice(0,l).replace(/^\s+|\s+$/g,""),type:r.slice(l+1).replace(/^\s+|\s+$/g,""),params:"",returnType:""}}let m=r.indexOf("(");if(m===-1){let l=r.lastIndexOf(":");return l===-1?{visibility:u,name:r,type:"",params:"",returnType:""}:{visibility:u,name:r.slice(0,l).replace(/^\s+|\s+$/g,""),type:"",params:"",returnType:r.slice(l+1).replace(/^\s+|\s+$/g,"")}}let a=r.slice(0,m).replace(/^\s+|\s+$/g,""),S=r.indexOf(")",m);if(S===-1)return {visibility:u,name:a,type:"",params:r.slice(m+1).replace(/^\s+|\s+$/g,""),returnType:""};let h=r.slice(m+1,S).replace(/^\s+|\s+$/g,""),f=r.slice(S+1).replace(/^\s+|\s+$/g,"");return f.startsWith(":")&&(f=f.slice(1).replace(/^\s+|\s+$/g,"")),{visibility:u,name:a,type:"",params:h,returnType:f}}function ln(s,e){let t=`${e.visibility} `;return s==="attribute"?`${t}${e.name}: ${e.type??""}`:`${t}${e.name}(${e.params??""}): ${e.returnType??""}`}var Nt=react.memo(function({editor:e,umlClass:t,editing:r}){let[,u]=react.useState(0);A(),react.useEffect(()=>{if(!e)return;let d=e.subscribe(()=>u(M=>M+1));return ()=>{d();}},[e]);let[p,m]=react.useState(null),[a,S]=react.useState(false),h=react.useRef(null),f=react.useRef(null),l=react.useCallback((d,M)=>{h.current&&(clearTimeout(h.current),h.current=null),m({section:d,rowId:M}),S(false);},[]),b=react.useCallback(()=>{h.current&&clearTimeout(h.current),h.current=window.setTimeout(()=>{m(null),S(false);},150);},[]);if(!e||!t||r!==t.id)return null;let R=e.getCamera(),{id:x,x:K,y:I,width:z,height:N,className:he,methods:n}=t,i=t.type==="uml-interface",c=i?[]:t.attributes,_=z/2,ee=N/2,te=drawuiCore.UML_HEADER_HEIGHT,Y=drawuiCore.UML_LINE_HEIGHT,be=drawuiCore.UML_PADDING_X,ie=drawuiCore.UML_PADDING_Y,ne=i?0:c.length>0?c.length*Y+ie*2:ie*2,g=R.zoom,ye=(z-be*2)*g,Le=4*g,Te=R.pageToScreen({x:K-_+be,y:I}),Se=R.pageToScreen({x:K,y:I-ee+te/2}),P=d=>R.pageToScreen({x:K,y:d}).y,fe=Y*g,le=d=>I+(-ee+te+ie+Y/2+d*Y),Ne=d=>I+(-ee+te+ne+ie+Y/2+d*Y),Ee=I+(-ee+te+ne),xe=I+ee,Me={background:"#ffffff",borderWidth:1,borderStyle:"solid",borderColor:"transparent",outline:"none",padding:0,fontFamily:"sans-serif",boxSizing:"border-box"},Re=(d,M)=>{let C=c.find($=>$.id===d);if(!C)return;let L=Lt(M,"attribute",C.visibility);e.updateUmlClass(x,{attributes:c.map($=>$.id===d?{...$,...L}:$)});},E=(d,M)=>{let C=n.find(W=>W.id===d);if(!C)return;let L=Lt(M,"method",C.visibility),$=n.map(W=>W.id===d?{...W,...L}:W);i?e.updateUmlInterface(x,{methods:$}):e.updateUmlClass(x,{methods:$});},w=(d,M,C)=>{f.current={section:d,from:M},C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/plain",`${d}:${M}`);},oe=d=>{d.preventDefault(),d.dataTransfer.dropEffect="move";},G=(d,M,C)=>{C.preventDefault();let L=f.current;!L||L.section!==d||(d==="attribute"?e.reorderUmlAttribute(x,L.from,M):e.reorderUmlMethod(x,L.from,M),f.current=null);},F=(d,M,C,L)=>{let $=P(L),W=p?.section===d&&p.rowId===C.id,Ie=(C.fontSize||drawuiCore.UML_FONT_SIZE)*g,Ke=C.textColor||"#1f2937",Pe={position:"absolute",left:Te.x-rt*g-Le,top:$-fe/2,width:rt*g+Le+ye+Ct*g,height:fe,display:"flex",alignItems:"center",gap:2,pointerEvents:"none",zIndex:53},y={...Me,width:ye,height:fe-2,fontSize:Ie,color:Ke,textDecoration:C.strikethrough?"line-through":"none",pointerEvents:"auto",...W?{borderColor:"var(--dw-primary)"}:{}},V={width:rt*g,height:fe-2,cursor:"grab",color:"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",fontSize:12*g,lineHeight:1,opacity:W?1:.55,pointerEvents:"auto"},se={width:Ct*g,height:fe-6,border:"none",background:"transparent",color:"#9ca3af",cursor:"pointer",borderRadius:3,fontSize:14*g,opacity:W?1:.35,pointerEvents:"auto"};return jsxRuntime.jsxs("div",{style:Pe,onDragOver:oe,onDrop:B=>G(d,M,B),children:[jsxRuntime.jsx("span",{style:V,draggable:true,onDragStart:B=>w(d,M,B),title:drawuiCore.t("uml.drag"),children:"\u22EE\u22EE"}),jsxRuntime.jsx("input",{style:y,value:ln(d,C),onChange:B=>d==="attribute"?Re(C.id,B.target.value):E(C.id,B.target.value),onFocus:()=>l(d,C.id),onBlur:b,spellCheck:false}),jsxRuntime.jsx("button",{style:se,onMouseDown:B=>B.preventDefault(),onClick:()=>{d==="attribute"?e.removeUmlAttribute(x,C.id):e.removeUmlMethod(x,C.id);},title:drawuiCore.t("uml.delete"),children:"\xD7"})]},C.id)},ae=(d,M,C)=>{let L=P(M),$=d==="attribute";return jsxRuntime.jsxs("button",{onMouseDown:W=>W.preventDefault(),onClick:()=>$?e.addUmlAttribute(x):e.addUmlMethod(x),className:"drawui-uml-add-row",style:{position:"absolute",left:Te.x,top:L-9*g,height:18*g,padding:`0 ${6*g}px`,fontSize:11*g,lineHeight:1,border:"1px dashed #cbd5e1",background:"rgba(255,255,255,0.85)",color:"#64748b",borderRadius:3,cursor:"pointer",pointerEvents:"auto",display:"flex",alignItems:"center",gap:3,whiteSpace:"nowrap",zIndex:53},title:C,children:[jsxRuntime.jsx("span",{style:{fontSize:13*g,lineHeight:1},children:"+"}),jsxRuntime.jsx("span",{children:C})]},`add-${d}`)},Ae=()=>{if(!p||p.section==="className")return null;let d=p.section,M=p.rowId,L=(d==="attribute"?c:n).find(k=>k.id===M);if(!L)return null;let $=224*g,W=30*g,Ie=R.pageToScreen({x:K,y:I}).x,Ke=R.pageToScreen({x:K,y:I-ee}).y,Pe=20*g,y=Ke-W-Pe,V=Ie-$/2,se=y+W,B=L.textColor||"#1f2937",D=L.fontSize||drawuiCore.UML_FONT_SIZE,ce=!!L.strikethrough;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:Ie-.5,top:se,width:1,height:Pe,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),jsxRuntime.jsxs("div",{className:"drawui-uml-toolbar",style:{position:"absolute",left:V,top:y,width:$,height:W,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:6,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",gap:4*g,padding:`0 ${6*g}px`,pointerEvents:"auto",zIndex:60,fontSize:12*g},onMouseDown:k=>k.preventDefault(),children:[jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{onClick:()=>S(k=>!k),className:"drawui-uml-toolbar-btn",title:drawuiCore.t("uml.textColor"),style:{border:"none",background:"transparent",cursor:"pointer",padding:2,display:"flex",alignItems:"center",borderRadius:3},children:[jsxRuntime.jsx("span",{style:{fontWeight:700,color:B,fontSize:13*g,textDecoration:ce?"line-through":"none"},children:"A"}),jsxRuntime.jsx("span",{style:{width:10*g,height:2*g,background:B,marginLeft:3,borderRadius:1}})]}),a&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"100%",left:0,marginTop:4,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:4,padding:4,display:"flex",gap:2,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:61},children:[jsxRuntime.jsx("button",{onClick:()=>{e.updateUmlRowStyle(x,d,L.id,{textColor:null}),S(false);},style:{width:14,height:14,border:"1px solid #e5e7eb",background:"transparent",cursor:"pointer",borderRadius:2},title:drawuiCore.t("uml.defaultColor")}),an.map(k=>jsxRuntime.jsx("button",{onClick:()=>{e.updateUmlRowStyle(x,d,L.id,{textColor:k}),S(false);},style:{width:14,height:14,border:"none",background:k,cursor:"pointer",borderRadius:2},title:k},k))]})]}),jsxRuntime.jsx("select",{value:D,onChange:k=>e.updateUmlRowStyle(x,d,L.id,{fontSize:Number(k.target.value)}),style:{border:"1px solid #e5e7eb",borderRadius:3,padding:`0 ${2*g}px`,fontSize:12*g,height:20*g,background:"#ffffff"},title:drawuiCore.t("uml.fontSize"),children:sn.map(k=>jsxRuntime.jsx("option",{value:k,children:k},k))}),jsxRuntime.jsx("button",{onClick:()=>e.updateUmlRowStyle(x,d,L.id,{strikethrough:!ce}),className:"drawui-uml-toolbar-btn",title:drawuiCore.t("uml.strikethrough"),style:{border:"none",background:ce?"var(--dw-primary-weak)":"transparent",cursor:"pointer",padding:2,borderRadius:3},children:jsxRuntime.jsx("span",{style:{fontWeight:700,fontSize:13*g,textDecoration:"line-through"},children:"A"})}),jsxRuntime.jsx("button",{onClick:()=>{d==="attribute"?e.removeUmlAttribute(x,L.id):e.removeUmlMethod(x,L.id),m(null);},className:"drawui-uml-toolbar-btn",title:drawuiCore.t("uml.delete"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#ef4444",padding:2,marginLeft:"auto",borderRadius:3},children:jsxRuntime.jsxs("svg",{width:14*g,height:14*g,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("polyline",{points:"3 6 5 6 21 6"}),jsxRuntime.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),jsxRuntime.jsx("path",{d:"M10 11v6"}),jsxRuntime.jsx("path",{d:"M14 11v6"}),jsxRuntime.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]})]})},Ue=R.pageToScreen({x:K-_,y:I}).x,je=R.pageToScreen({x:K,y:I-ee}).y,qe=z*g,Je=N*g;return jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:Ue+1,top:je+1,width:Math.max(0,qe-2),height:Math.max(0,Je-2),background:"#ffffff",pointerEvents:"none",zIndex:51}}),jsxRuntime.jsx("input",{style:{...Me,position:"absolute",left:Se.x-ye/2,top:Se.y-te*g/2+2,width:ye,height:te*g-4,textAlign:"center",fontWeight:700,fontSize:(t.fontSize||drawuiCore.UML_FONT_SIZE)*g,color:t.textColor||"#1f2937",pointerEvents:"auto",zIndex:52,...p?.section==="className"?{borderColor:"var(--dw-primary)"}:{}},value:he,onChange:d=>i?e.updateUmlInterface(x,{className:d.target.value}):e.updateUmlClass(x,{className:d.target.value}),onFocus:()=>l("className",""),onBlur:b,spellCheck:false}),!i&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[c.map((d,M)=>F("attribute",M,d,le(M))),ae("attribute",Ee,"\u5C5E\u6027")]}),n.map((d,M)=>F("method",M,d,Ne(M))),ae("method",xe,drawuiCore.t("uml.method")),Ae()]})});var It=react.memo(function({editor:e,panelOpen:t,onOpenPanel:r}){let[,u]=react.useState(0);A(),react.useEffect(()=>{if(!e)return;let z=e.subscribe(()=>u(N=>N+1));return ()=>{z();}},[e]);let p=react.useRef(false),m=react.useRef(false);if(!e)return null;let a=e.getMindMapEditingShapeId();if(!a||t)return null;let S=e.getMindMapSelectedNode();if(!S||S.shapeId!==a)return null;let h=e.getMindMapNode(a,S.nodeId),f=e.getMindMapNodeScreenRect(a,S.nodeId);if(!h||!f)return null;let l=e.getCamera().getZoom(),b=drawuiCore.MINDMAP_FONT_SIZE*l,R=Math.max(100,f.width+24),x=f.height+8,K={position:"absolute",left:f.x+f.width/2,top:f.y-4,transform:"translateX(-50%)",width:R,height:x,border:"1.5px solid var(--dw-primary, #3b82f6)",borderRadius:6,background:"#ffffff",boxShadow:"0 2px 10px rgba(0,0,0,0.15)",outline:"none",padding:`0 ${(h.icon?24:12)*l}px`,fontFamily:"sans-serif",fontSize:b,color:"#1f2937",boxSizing:"border-box",pointerEvents:"auto",zIndex:55},I={position:"absolute",left:f.x+f.width+12,top:f.y+f.height/2-11,width:22,height:22,border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:"50%",cursor:"pointer",color:"#6b7280",fontSize:13,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 4px rgba(0,0,0,0.12)",pointerEvents:"auto",zIndex:55};return jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsxRuntime.jsx("input",{autoFocus:true,style:K,value:h.text,spellCheck:false,onChange:z=>{let N=!p.current;p.current=true,e.updateMindMapNode(a,S.nodeId,{text:z.target.value},N);},onBlur:()=>{if(m.current){m.current=false;return}e.exitMindMapEdit();},onKeyDown:z=>{z.key==="Enter"?z.target.blur():z.key==="Escape"&&e.exitMindMapEdit();}}),jsxRuntime.jsx("button",{style:I,title:drawuiCore.t("mindmap.more"),onMouseDown:z=>{z.preventDefault(),m.current=true,setTimeout(()=>{m.current=false;},300);},onClick:r,children:"\u22EF"})]})});var Pt=[...drawuiCore.MINDMAP_COLORS,"#1f2937","#9ca3af"],Ht=["\u{1F4A1}","\u2B50","\u{1F525}","\u{1F4CC}","\u2705","\u2757","\u26A0\uFE0F","\u{1F3F7}\uFE0F"],vn={position:"absolute",width:232,background:"rgba(255,255,255,0.96)",border:"1px solid #e5e7eb",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.12)",padding:"10px 12px",fontSize:12,color:"#1f2937",zIndex:70,boxSizing:"border-box",fontFamily:"sans-serif"},it={fontSize:11,color:"#6b7280",marginBottom:4,display:"block"},Ze={display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},Oe={border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:5,padding:"3px 8px",fontSize:12,color:"#374151",cursor:"pointer",lineHeight:1.5},at={width:"100%",border:"1px solid #e5e7eb",borderRadius:5,padding:"4px 8px",fontSize:12,outline:"none",boxSizing:"border-box",background:"#ffffff",color:"#1f2937"},Kt=react.memo(function({editor:e,mindMap:t}){let[,r]=react.useState(0);A(),react.useEffect(()=>{if(!e)return;let n=e.subscribe(()=>r(i=>i+1));return ()=>{n();}},[e]);let u=react.useRef(null);if(!e||!t||e.getMindMapEditingShapeId()!==t.id)return null;let p=e.getMindMapSelectedNode();if(!p||p.shapeId!==t.id)return null;let m=n=>{if(n.id===p.nodeId)return n;for(let i of n.children??[]){let c=m(i);if(c)return c}return null},a=m(t.root);if(!a)return null;let S=e.getCamera(),f=drawuiCore.layoutMindMap(t.root).positions.get(a.id);if(!f)return null;let l=S.zoom,b=S.pageToScreen({x:t.x+f.x,y:t.y+f.y}),R=b.x+f.width*l/2+14,x=b.y-80,I=Math.max(8,Math.min(R,(window.innerWidth||1024)-232-8)),z=Math.max(8,Math.min(x,(window.innerHeight||768)-320)),N=n=>{e.updateMindMapNode(t.id,a.id,n);},he=!!a.id&&a.id!==t.root.id;return jsxRuntime.jsxs("div",{ref:u,style:{...vn,left:I,top:z},onMouseDown:n=>n.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[jsxRuntime.jsx("span",{style:{fontWeight:600,fontSize:12},children:drawuiCore.t("mindmap.nodeText")}),jsxRuntime.jsx("button",{onClick:()=>e.exitMindMapEdit(),title:drawuiCore.t("mindmap.close"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#9ca3af",fontSize:14,lineHeight:1,padding:2},children:"\xD7"})]}),jsxRuntime.jsx("input",{style:{...at,marginBottom:8},value:a.text,onChange:n=>N({text:n.target.value}),spellCheck:false}),jsxRuntime.jsxs("div",{style:{...Ze,marginBottom:10},children:[jsxRuntime.jsxs("button",{style:Oe,onClick:()=>e.addMindMapChild(t.id,a.id),children:["+ ",drawuiCore.t("mindmap.addChild")]}),he&&jsxRuntime.jsxs("button",{style:Oe,onClick:()=>e.addMindMapSibling(t.id,a.id),children:["+ ",drawuiCore.t("mindmap.addSibling")]}),!!a.children?.length&&jsxRuntime.jsx("button",{style:Oe,onClick:()=>e.toggleMindMapCollapse(t.id,a.id),children:a.collapsed?drawuiCore.t("mindmap.expand"):drawuiCore.t("mindmap.collapse")}),jsxRuntime.jsx("button",{style:{...Oe,color:"#ef4444",borderColor:"#fecaca",marginLeft:"auto"},onClick:()=>e.deleteMindMapNode(t.id,a.id),children:drawuiCore.t("mindmap.deleteNode")})]}),jsxRuntime.jsx("span",{style:it,children:drawuiCore.t("mindmap.color")}),jsxRuntime.jsxs("div",{style:{...Ze,marginBottom:10},children:[jsxRuntime.jsx("button",{title:drawuiCore.t("mindmap.levelColor"),onClick:()=>N({color:void 0}),style:{width:18,height:18,borderRadius:4,border:"1.5px solid #d1d5db",background:"conic-gradient(#ef4444, #f59e0b, #10b981, #3b82f6, #8b5cf6, #ec4899, #ef4444)",cursor:"pointer",flexShrink:0}}),Pt.map(n=>jsxRuntime.jsx("button",{title:n,onClick:()=>N({color:n}),style:{width:18,height:18,borderRadius:4,border:a.color===n?"2px solid #111827":"1px solid #d1d5db",background:n,cursor:"pointer",flexShrink:0}},n))]}),jsxRuntime.jsx("span",{style:it,children:drawuiCore.t("mindmap.icon")}),jsxRuntime.jsxs("div",{style:{...Ze,marginBottom:10},children:[jsxRuntime.jsx("button",{title:drawuiCore.t("mindmap.noIcon"),onClick:()=>N({icon:void 0}),style:{width:22,height:22,borderRadius:4,border:a.icon?"1px solid #d1d5db":"2px solid #111827",background:"#f9fafb",cursor:"pointer",fontSize:11,color:"#9ca3af",lineHeight:1},children:"\u2205"}),Ht.map(n=>jsxRuntime.jsx("button",{onClick:()=>N({icon:n}),style:{width:22,height:22,borderRadius:4,border:a.icon===n?"2px solid #111827":"1px solid #d1d5db",background:"#f9fafb",cursor:"pointer",fontSize:13,lineHeight:1},children:n},n)),jsxRuntime.jsx("input",{placeholder:"\u270F\uFE0F",defaultValue:a.icon&&!Ht.includes(a.icon)?a.icon:"",onKeyDown:n=>{if(n.key==="Enter"){let i=n.target.value.trim();N({icon:i||void 0});}},onBlur:n=>{let i=n.target.value.trim();i!==a.icon&&N({icon:i||void 0});},style:{...at,width:56,padding:"2px 4px",textAlign:"center"}})]}),jsxRuntime.jsx("span",{style:it,children:drawuiCore.t("mindmap.note")}),jsxRuntime.jsx("input",{style:{...at,marginBottom:6},value:a.note??"",placeholder:drawuiCore.t("mindmap.notePlaceholder"),onChange:n=>N({note:n.target.value||void 0}),spellCheck:false}),!!a.note&&jsxRuntime.jsxs("div",{style:{...Ze,marginTop:4},children:[jsxRuntime.jsx("span",{style:{fontSize:11,color:"#6b7280"},children:drawuiCore.t("mindmap.noteColor")}),jsxRuntime.jsx("button",{title:drawuiCore.t("mindmap.noteColorDefault"),onClick:()=>N({noteColor:void 0}),style:{width:16,height:16,borderRadius:3,border:a.noteColor?"1px solid #d1d5db":"2px solid #111827",background:"repeating-conic-gradient(#ef4444 0% 25%, #f59e0b 0% 50%, #10b981 0% 75%, #3b82f6 0% 100%)",cursor:"pointer"}}),Pt.map(n=>jsxRuntime.jsx("button",{onClick:()=>N({noteColor:n}),style:{width:16,height:16,borderRadius:3,border:a.noteColor===n?"2px solid #111827":"1px solid #d1d5db",background:n,cursor:"pointer"}},n))]})]})});var lt=220,ct=140,Ln="#fafafa";function Tn(s,e){let t=Math.min(s.x,e.x),r=Math.min(s.y,e.y),u=Math.max(s.x+s.width,e.x+e.width),p=Math.max(s.y+s.height,e.y+e.height);return {x:t,y:r,width:u-t,height:p-r}}function Nn(s){return {x:s.x+s.width/2,y:s.y+s.height/2}}function En(){return {x:0,y:0,width:0,height:0}}function Rn(s){let e=1/0,t=1/0,r=-1/0,u=-1/0,p=false;for(let m of s){let a=ut(m);a&&(p=true,a.x<e&&(e=a.x),a.y<t&&(t=a.y),a.x+a.width>r&&(r=a.x+a.width),a.y+a.height>u&&(u=a.y+a.height));}return p?{x:e,y:t,width:r-e,height:u-t}:null}function ut(s){switch(s.type){case "rectangle":case "rounded-rectangle":case "ellipse":case "diamond":case "triangle":case "hexagon":case "text":return {x:s.x-s.width/2,y:s.y-s.height/2,width:s.width,height:s.height};case "circle":return {x:s.x-s.radius,y:s.y-s.radius,width:s.radius*2,height:s.radius*2};case "line":case "arrow":case "draw":{let e=s.points;if(!e||e.length===0)return null;let t=1/0,r=1/0,u=-1/0,p=-1/0;for(let m of e)m.x<t&&(t=m.x),m.y<r&&(r=m.y),m.x>u&&(u=m.x),m.y>p&&(p=m.y);return {x:t,y:r,width:u-t,height:p-r}}default:return null}}function In(s){let e=s.getCamera(),t=e.screenToPage({x:0,y:0}),r=e.screenToPage({x:window.innerWidth,y:window.innerHeight});return {x:t.x,y:t.y,width:r.x-t.x,height:r.y-t.y}}function Pn(s,e,t){if(s.width<=0||s.height<=0)return {x:s.x-e/2,y:s.y-t/2,width:e,height:t};let r=e/t,u=s.width,p=u/r;p<s.height&&(p=s.height,u=p*r);let m=Nn(s);return {x:m.x-u/2,y:m.y-p/2,width:u,height:p}}function dt(s,e,t,r){let u=(s-t.left)/t.width,p=(e-t.top)/t.height;return {x:r.x+u*r.width,y:r.y+p*r.height}}var Dt=react.memo(function({editor:e}){let t=react.useRef(null),r=react.useRef(null),[u,p]=react.useState(false),[m,a]=react.useState(100),[S,h]=react.useState(false),[f,l]=react.useState(false);A();let b=react.useRef(null),R=react.useRef(null);react.useLayoutEffect(()=>{let n=t.current,i=r.current;if(!n||!i)return;let c=window.devicePixelRatio||1;n.width=Math.round(lt*c),n.height=Math.round(ct*c),n.style.width=`${lt}px`,n.style.height=`${ct}px`;},[u]);let x=react.useCallback(()=>{let n=t.current,i=r.current;if(!n||!i||!e)return;let c=n.getContext("2d");if(!c)return;let _=lt,ee=ct,te=n.width,Y=n.height,be=e.getShapes(),ie=new Set(e.getSelectedIds()),ne=drawuiCore.getTheme(),g=drawuiCore.hexToRgba(ne.text,.16),ye=ne.primary,Le=drawuiCore.hexToRgba(ne.primary,.18),Te=drawuiCore.hexToRgba(ne.primary,.85),Se=Rn(be),P=In(e),fe=Se?Tn(Se,P):P.width>0?P:En(),le=Pn(fe,_,ee);R.current=le;let Ne=te/le.width,Ee=Y/le.height,xe=_/le.width;c.setTransform(1,0,0,1,0,0),c.fillStyle=Ln,c.fillRect(0,0,te,Y),c.setTransform(Ne,0,0,Ee,-Ne*le.x,-Ee*le.y),c.fillStyle=g;for(let E of be){let w=ut(E);w&&c.fillRect(w.x,w.y,w.width,w.height);}c.fillStyle=ye;for(let E of be){if(!ie.has(E.id))continue;let w=ut(E);w&&c.fillRect(w.x,w.y,w.width,w.height);}c.fillStyle=Le,c.fillRect(P.x,P.y,P.width,P.height);let Me=1.5/xe;c.strokeStyle=Te,c.lineWidth=Me,c.lineJoin="round";let Re=Math.min(P.width/6,P.height/6,6/xe);if(c.beginPath(),Re*xe<1)c.rect(P.x,P.y,P.width,P.height);else {let E=P.x,w=P.y,oe=P.width,G=P.height,F=Math.min(Re,oe/2,G/2);c.moveTo(E+F,w),c.lineTo(E+oe-F,w),c.quadraticCurveTo(E+oe,w,E+oe,w+F),c.lineTo(E+oe,w+G-F),c.quadraticCurveTo(E+oe,w+G,E+oe-F,w+G),c.lineTo(E+F,w+G),c.quadraticCurveTo(E,w+G,E,w+G-F),c.lineTo(E,w+F),c.quadraticCurveTo(E,w,E+F,w),c.closePath();}c.stroke(),c.setTransform(1,0,0,1,0,0);},[e]);react.useEffect(()=>{if(!e||u)return;x();let n=e.subscribe(x),i=drawuiCore.subscribeTheme(x),c=()=>x();return window.addEventListener("resize",c),()=>{n(),i(),window.removeEventListener("resize",c);}},[e,u,x]),react.useEffect(()=>{if(!e)return;let n=()=>{let c=e.getCamera().getZoom();a(Math.round(c*100));};n();let i=e.subscribe(n);return ()=>{i();}},[e]);let K=react.useCallback((n,i)=>{if(!e)return;let c=e.getCamera(),_=c.getZoom(),ee=window.innerWidth/2,te=window.innerHeight/2,Y=c;Y.x=ee-n*_,Y.y=te-i*_,e.requestRender();},[e]),I=n=>{if(!e||!r.current||n.button!==0)return;let i=r.current.getBoundingClientRect(),c=R.current;if(!c)return;let _=dt(n.clientX,n.clientY,i,c);b.current={pointerId:n.pointerId,rect:{left:i.left,top:i.top,width:i.width,height:i.height},canvasBox:c},n.currentTarget.setPointerCapture(n.pointerId),l(true),K(_.x,_.y);},z=n=>{if(!f||!e||!b.current||!r.current)return;let i=b.current,c=dt(n.clientX,n.clientY,i.rect,i.canvasBox);K(c.x,c.y);},N=n=>{if(f){l(false),b.current=null;try{n.currentTarget.releasePointerCapture(n.pointerId);}catch{}}},he=n=>{if(!e||!r.current)return;let i=R.current;if(!i)return;let c=r.current.getBoundingClientRect(),_=dt(n.clientX,n.clientY,c,i);K(_.x,_.y);};return jsxRuntime.jsxs("div",{className:`drawui-minimap ${u?"collapsed":""}`,children:[jsxRuntime.jsx("button",{className:"drawui-minimap-toggle",onClick:()=>p(n=>!n),title:u?drawuiCore.t("minimap.expand"):drawuiCore.t("minimap.collapse"),"aria-label":u?drawuiCore.t("minimap.expand"):drawuiCore.t("minimap.collapse"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u?jsxRuntime.jsx("polyline",{points:"9 6 15 12 9 18"}):jsxRuntime.jsx("polyline",{points:"15 6 9 12 15 18"})})}),!u&&jsxRuntime.jsxs("div",{className:"drawui-minimap-panel",children:[jsxRuntime.jsxs("div",{className:"drawui-minimap-header",children:[jsxRuntime.jsx("span",{className:"drawui-minimap-title",children:drawuiCore.t("minimap.title")}),jsxRuntime.jsxs("span",{className:"drawui-minimap-zoom",children:[m,"%"]})]}),jsxRuntime.jsx("div",{ref:r,className:"drawui-minimap-canvas-wrap",style:{cursor:f?"grabbing":S?"pointer":"default"},onPointerEnter:()=>h(true),onPointerLeave:()=>h(false),children:jsxRuntime.jsx("canvas",{ref:t,className:"drawui-minimap-canvas",onPointerDown:I,onPointerMove:z,onPointerUp:N,onPointerCancel:N,onDoubleClick:he})})]})]})});var Q=s=>jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",className:"drawui-gen-shape-glyph",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:s}),zn=[{type:"rectangle",labelKey:"shape.rectangle",glyph:Q(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:Q(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:Q(jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:Q(jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:Q(jsxRuntime.jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:Q(jsxRuntime.jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:Q(jsxRuntime.jsx("path",{d:"M12 3 L19.5 7.5 V16.5 L12 21 L4.5 16.5 V7.5 Z"}))},{type:"parallelogram",labelKey:"shape.parallelogram",glyph:Q(jsxRuntime.jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:Q(jsxRuntime.jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:Q(jsxRuntime.jsx("path",{d:"M12 4 L19.5 9.5 L16.5 18.5 H7.5 L4.5 9.5 Z"}))},{type:"octagon",labelKey:"shape.octagon",glyph:Q(jsxRuntime.jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:Q(jsxRuntime.jsx("path",{d:"M12 3 L14 9.5 L20.5 10 L15.5 14 L17.5 20.5 L12 16.8 L6.5 20.5 L8.5 14 L3.5 10 L10 9.5 Z"}))},{type:"uml-class",labelKey:"shape.uml-class",glyph:Q(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsxRuntime.jsx("path",{d:"M3 9 H21"}),jsxRuntime.jsx("path",{d:"M3 15 H21"}),jsxRuntime.jsx("path",{d:"M6 6.5 H10"}),jsxRuntime.jsx("path",{d:"M6 12.5 H12"})]}))},{type:"uml-interface",labelKey:"shape.uml-interface",glyph:Q(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsxRuntime.jsx("path",{d:"M3 9 H21"}),jsxRuntime.jsx("path",{d:"M6 6.5 H10"}),jsxRuntime.jsx("path",{d:"M6 12.5 H12"})]}))},{type:"mind-map",labelKey:"shape.mind-map",glyph:Q(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("circle",{cx:"5",cy:"12",r:"2"}),jsxRuntime.jsx("path",{d:"M7 12h2.6"}),jsxRuntime.jsx("path",{d:"M9.6 12c0-2 1.2-3.4 2.6-3.4"}),jsxRuntime.jsx("path",{d:"M9.6 12c0 2 1.2 3.4 2.6 3.4"}),jsxRuntime.jsx("circle",{cx:"15.2",cy:"8.6",r:"1.3"}),jsxRuntime.jsx("circle",{cx:"15.2",cy:"15.4",r:"1.3"}),jsxRuntime.jsx("circle",{cx:"13.6",cy:"12",r:"1.3"})]}))}];function At({editor:s,x:e,y:t,context:r,existingArrowId:u,defaultShapeType:p,onClose:m}){let a=react.useRef(null);A();let S=h=>{s?.createGeneratedConnection(r,{type:h,existingArrowId:u}),m();};return react.useEffect(()=>{let h=b=>{a.current&&!a.current.contains(b.target)&&m();},f=b=>{b.key==="Escape"&&(b.preventDefault(),m());},l=setTimeout(()=>{window.addEventListener("pointerdown",h,true),window.addEventListener("keydown",f,true);},0);return ()=>{clearTimeout(l),window.removeEventListener("pointerdown",h,true),window.removeEventListener("keydown",f,true);}},[m]),jsxRuntime.jsxs("div",{className:"drawui-gen-menu",ref:a,style:{left:e,top:t},children:[jsxRuntime.jsx("div",{className:"drawui-gen-menu-label",children:drawuiCore.t("menu.title")}),jsxRuntime.jsx("div",{className:"drawui-gen-shape-grid",children:zn.map(h=>jsxRuntime.jsxs("button",{className:`drawui-gen-shape-btn${h.type===p?" drawui-gen-shape-active":""}`,onClick:()=>S(h.type),title:drawuiCore.t(h.labelKey),children:[h.glyph,jsxRuntime.jsx("span",{className:"drawui-gen-shape-label",children:drawuiCore.t(h.labelKey)})]},h.type))}),jsxRuntime.jsx("div",{className:"drawui-gen-menu-hint",children:drawuiCore.t("menu.cancel")})]})}var Un={select:"tool.select",hand:"tool.hand",rectangle:"tool.rectangle","rounded-rectangle":"tool.rounded-rectangle",circle:"tool.circle",ellipse:"tool.ellipse",diamond:"tool.diamond",triangle:"tool.triangle",hexagon:"tool.hexagon",parallelogram:"tool.parallelogram",trapezoid:"tool.trapezoid",pentagon:"tool.pentagon",octagon:"tool.octagon",star:"tool.star","uml-class":"tool.uml-class","uml-interface":"tool.uml-interface",line:"tool.line",arrow:"tool.arrow",text:"tool.text",draw:"tool.draw",pen:"tool.pen",highlighter:"tool.highlighter",eraser:"tool.eraser","mind-map":"tool.mind-map"};function $n({initialTool:s="select",className:e="",themeColor:t,language:r="zh-CN",data:u,onChange:p,onReady:m}){let a=react.useRef(null),S=react.useRef(null),h=react.useRef(null),[f,l]=react.useState(null);A();let[b,R]=react.useState(s),[x,K]=react.useState(false),[I,z]=react.useState(0),[N,he]=react.useState(false),[n,i]=react.useState("straight"),[c,_]=react.useState("end"),[ee,te]=react.useState(false),[Y,be]=react.useState(100),[ie,ne]=react.useState(null),[g,ye]=react.useState(null),[Le,Te]=react.useState(false),[Se,P]=react.useState(false),[fe,le]=react.useState(null),[Ne,Ee]=react.useState(null),[xe,Me]=react.useState(false),[Re,E]=react.useState(null),[w,oe]=react.useState(null),G=react.useRef(null),F=react.useRef(0),ae=react.useRef(null),Ae=react.useRef(p);Ae.current=p;let Ue=react.useRef(m);Ue.current=m,react.useEffect(()=>{if(!a.current)return;let y=new drawuiCore.Editor(a.current,{theme:t?{primary:t,editBorder:t,selection:{outline:t,handleStroke:t,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(t,.1),shadow:t}}:void 0,language:r,shapes:u,persist:!u});h.current=y,l(y),window.__drawuiEditor=y,Ue.current?.(y),s&&y.setActiveTool(s);let V=y.subscribe(()=>{R(y.getActiveTool());let D=y.getSelectedIds();z(D.length);let k=y.getShapes().filter(ue=>D.includes(ue.id)&&(ue.type==="line"||ue.type==="arrow"));if(he(k.length>0),k.length>0&&k[0].connectionType?i(k[0].connectionType):k.length>0&&i("straight"),k.length>0){let ue=k.find(Qe=>Qe.type==="arrow");ue&&(_(ue.arrowHead??"end"),te(ue.dashed??false));}be(Math.round(y.getCamera().getZoom()*100)),Te(y.canUndo()),P(y.canRedo());let de=y.getSelectedUml();le(de),de||E(null);let $e=y.getSelectedMindMap();Ee($e),y.getMindMapEditingShapeId()||Me(false),Ae.current?.(y.getData());}),se=y.subscribeNotifications(D=>{ye(D),G.current&&clearTimeout(G.current),G.current=setTimeout(()=>ye(null),2e3);}),B=y.subscribeUi(D=>{D.kind==="shapeTypeMenu"&&oe({x:D.screenX,y:D.screenY,context:D.context,existingArrowId:D.existingArrowId,defaultShapeType:D.defaultShapeType});});return ()=>{V(),se(),B(),G.current&&clearTimeout(G.current),cancelAnimationFrame(F.current),y.dispose();}},[s]),react.useEffect(()=>{if(!t)return;let y=S.current;y&&(y.style.setProperty("--dw-primary",t),y.style.setProperty("--dw-primary-hover",drawuiCore.shadeColor(t,-0.12)),y.style.setProperty("--dw-primary-weak",drawuiCore.hexToRgba(t,.1)),y.style.setProperty("--dw-primary-contrast","#ffffff"),y.style.setProperty("--dw-shadow-primary",`0 2px 8px ${drawuiCore.hexToRgba(t,.3)}`)),h.current?.setTheme({primary:t,editBorder:t,selection:{outline:t,handleStroke:t,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(t,.1),shadow:t}});},[t]),react.useEffect(()=>{drawuiCore.setLanguage(r),h.current?.setLanguage(r);},[r]);let je=react.useCallback(y=>{h.current?.setActiveTool(y);},[]),qe=react.useCallback(()=>{h.current?.zoomIn();},[]),Je=react.useCallback(()=>{h.current?.zoomOut();},[]),d=react.useCallback(()=>{h.current?.resetZoom();},[]),M=react.useCallback(()=>{let y=!x;K(y),h.current?.setShowGrid(y);},[x]),C=react.useCallback(()=>{h.current?.undo();},[]),L=react.useCallback(()=>{h.current?.redo();},[]),$=react.useCallback(y=>{h.current?.downloadImage("drawui",y,{background:"#ffffff"});},[]),W=react.useCallback(y=>{let V=h.current,se=a.current;if(!V||!se)return;if(V.isPointerDown()){ae.current!==null&&(ae.current=null,ne(null));return}let B=y.clientX,D=y.clientY;cancelAnimationFrame(F.current),F.current=requestAnimationFrame(()=>{let ce=se.getBoundingClientRect(),k=B-ce.left,de=D-ce.top,$e=k+12,ue=de+12,Qe=V.getSelectedUml()?.id,He=V.getUmlRowAtScreenPoint({x:k,y:de});if(He&&He.shape.id!==Qe&&He.text){ae.current!==He.text&&(ae.current=He.text,ne({text:He.text,x:$e,y:ue}));return}let ze=V.getShapeAtScreenPoint({x:k,y:de});ze&&ze.text?ae.current!==ze.text&&(ae.current=ze.text,ne({text:ze.text,x:$e,y:ue})):ae.current!==null&&(ae.current=null,ne(null));});},[]),Ie=react.useCallback(()=>{ne(null);},[]),Ke=react.useCallback(y=>{let V=h.current,se=a.current;if(!V||!se)return;let B=se.getBoundingClientRect(),D=y.clientX-B.left,ce=y.clientY-B.top,k=V.getUmlRowAtScreenPoint({x:D,y:ce});if(k){E(k.shape.id);return}let de=V.getMindMapNodeAtScreenPoint({x:D,y:ce});de&&V.beginMindMapEdit(de.shapeId,de.nodeId);},[]),Pe=react.useCallback(()=>{oe(null);},[]);return jsxRuntime.jsxs("div",{ref:S,className:`drawui-canvas-board ${e}`,children:[jsxRuntime.jsx("canvas",{ref:a,className:"drawui-canvas",onMouseMove:W,onMouseLeave:Ie,onDoubleClick:Ke}),ie&&jsxRuntime.jsx("div",{className:"drawui-tooltip",style:{left:ie.x,top:ie.y},children:ie.text}),jsxRuntime.jsx(et,{activeTool:b,onToolChange:je,showGrid:x,onToggleGrid:M,canUndo:Le,canRedo:Se,onUndo:C,onRedo:L,onExport:$}),jsxRuntime.jsx(tt,{onZoomIn:qe,onZoomOut:Je,onReset:d,zoomLevel:Y}),jsxRuntime.jsx(kt,{editor:f,selectedCount:I,hasLineSelection:N,currentConnectionType:n,currentArrowHead:c,currentDashed:ee}),jsxRuntime.jsx(Nt,{editor:f,umlClass:fe,editing:Re}),jsxRuntime.jsx(It,{editor:f,panelOpen:xe,onOpenPanel:()=>Me(true)}),xe&&jsxRuntime.jsx(Kt,{editor:f,mindMap:Ne}),jsxRuntime.jsx(Dt,{editor:f}),w&&jsxRuntime.jsx(At,{editor:f,x:w.x,y:w.y,context:w.context,existingArrowId:w.existingArrowId,defaultShapeType:w.defaultShapeType,onClose:Pe}),jsxRuntime.jsxs("div",{className:"drawui-status-bar",children:[jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:drawuiCore.t(Un[b])})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:I===0?drawuiCore.t("status.none"):drawuiCore.t("status.selected",{n:I})})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsxs("span",{children:[Y,"%"]})})]}),g&&jsxRuntime.jsxs("div",{className:"drawui-toast",children:[jsxRuntime.jsx("svg",{className:"drawui-toast-icon",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),g]})]})}exports.CanvasBoard=$n;exports.Toolbar=et;exports.ZoomControl=tt;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ToolType, Language, Shape, EditorData, Editor } from 'drawui-core';
2
+ import { ToolType, Language, Shape, EditorData, Editor, ExportFormat } from 'drawui-core';
3
3
  export { ToolType } from 'drawui-core';
4
4
 
5
5
  interface CanvasBoardProps {
@@ -27,6 +27,7 @@ interface ToolbarProps {
27
27
  canRedo?: boolean;
28
28
  onUndo?: () => void;
29
29
  onRedo?: () => void;
30
+ onExport?: (format: ExportFormat) => void;
30
31
  }
31
32
  declare const Toolbar: react.NamedExoticComponent<ToolbarProps>;
32
33
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ToolType, Language, Shape, EditorData, Editor } from 'drawui-core';
2
+ import { ToolType, Language, Shape, EditorData, Editor, ExportFormat } from 'drawui-core';
3
3
  export { ToolType } from 'drawui-core';
4
4
 
5
5
  interface CanvasBoardProps {
@@ -27,6 +27,7 @@ interface ToolbarProps {
27
27
  canRedo?: boolean;
28
28
  onUndo?: () => void;
29
29
  onRedo?: () => void;
30
+ onExport?: (format: ExportFormat) => void;
30
31
  }
31
32
  declare const Toolbar: react.NamedExoticComponent<ToolbarProps>;
32
33
 
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import {memo,useState,useRef,useEffect,useCallback,useLayoutEffect}from'react';import {t,UML_FONT_SIZE,MINDMAP_COLORS,layoutMindMap,getTheme,hexToRgba,subscribeTheme,getLanguage,subscribeLanguage,UML_LINE_HEIGHT,UML_PADDING_Y,UML_PADDING_X,UML_HEADER_HEIGHT,MINDMAP_FONT_SIZE,Editor,shadeColor,setLanguage}from'drawui-core';import {jsx,jsxs,Fragment}from'react/jsx-runtime';function D(){let[a,e]=useState(getLanguage());return useEffect(()=>subscribeLanguage(()=>e(getLanguage())),[]),a}var yt=[{type:"rectangle",icon:jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"0"})},{type:"rounded-rectangle",icon:jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4"})},{type:"circle",icon:jsx("circle",{cx:"12",cy:"12",r:"8"})},{type:"ellipse",icon:jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"6"})},{type:"diamond",icon:jsx("path",{d:"M12 3L21 12L12 21L3 12Z"})},{type:"triangle",icon:jsx("path",{d:"M12 4L20 19L4 19Z"})},{type:"hexagon",icon:jsx("path",{d:"M12 3L20 7.5V16.5L12 21L4 16.5V7.5Z"})},{type:"parallelogram",icon:jsx("path",{d:"M7 5L20 5L17 19L4 19Z"})},{type:"trapezoid",icon:jsx("path",{d:"M6 5L18 5L21 19L3 19Z"})},{type:"pentagon",icon:jsx("path",{d:"M12 3L21 10L17.5 21L6.5 21L3 10Z"})},{type:"octagon",icon:jsx("path",{d:"M8 3L16 3L21 8L21 16L16 21L8 21L3 16L3 8Z"})},{type:"star",icon:jsx("path",{d:"M12 2L14.5 8.5L21 9L16 13.5L17.5 20L12 16.5L6.5 20L8 13.5L3 9L9.5 8.5Z"})}],Zt=new Set(yt.map(a=>a.type)),Ot=[{type:"arrow",icon:"M5 12h14M12 5l7 7-7 7",labelKey:"toolbar.arrow"},{type:"text",icon:"M4 7V4h16v3M9 20h6M12 4v16",labelKey:"toolbar.text"}],_t=[{type:"pen",icon:"M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3Z",labelKey:"toolbar.pen"},{type:"highlighter",icon:"M14 3l7 7-3 3-7-7 3-3zM9 8L3 14v3h3l6-6",labelKey:"toolbar.highlighter"}],Vt=[{type:"eraser",icon:"M7 21l-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21M22 21H7M5 11l9 9",labelKey:"toolbar.eraser"}],Yt="M18 11V6.5a1.5 1.5 0 0 0-3 0v3.5a1.5 1.5 0 0 0-3 0V3.5a1.5 1.5 0 0 0-3 0v6.5a1.5 1.5 0 0 0-3 0V14a8 8 0 0 0 16 0v-3a1.5 1.5 0 0 0-3 0",Qe=memo(function({activeTool:e,onToolChange:t$1,showGrid:o,onToggleGrid:u,canUndo:p=false,canRedo:h=false,onUndo:i,onRedo:k}){let[m,y]=useState(false),s=useRef(null);D();let x=()=>{s.current&&(clearTimeout(s.current),s.current=null),y(true);},H=()=>{s.current=window.setTimeout(()=>{y(false);},200);};return jsx("div",{className:"drawui-toolbar-container",children:jsxs("div",{className:"drawui-toolbar",children:[jsx("button",{className:`drawui-toolbar-button ${e==="select"?"active":""}`,onClick:()=>t$1("select"),title:t("toolbar.select"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("circle",{cx:"12",cy:"12",r:"3"})})}),jsx("button",{className:`drawui-toolbar-button ${e==="hand"?"active":""}`,onClick:()=>t$1("hand"),title:t("toolbar.hand"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:Yt})})}),jsx("div",{className:"drawui-toolbar-divider"}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:x,onMouseLeave:H,children:[jsx("button",{className:`drawui-toolbar-button ${Zt.has(e)?"active":""}`,onClick:()=>t$1("rounded-rectangle"),title:"\u5F62\u72B6",children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4",ry:"4"})})}),m&&jsx("div",{className:"drawui-toolbar-shape-grid",children:yt.map(c=>jsx("button",{className:`drawui-toolbar-shape-item ${e===c.type?"active":""}`,onClick:()=>{t$1(c.type),y(false);},title:t("tool."+c.type),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:c.icon})},c.type))})]}),jsx("div",{className:"drawui-toolbar-divider"}),Ot.map(c=>jsx("button",{className:`drawui-toolbar-button ${e===c.type?"active":""}`,onClick:()=>t$1(c.type),title:t(c.labelKey),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:c.icon})})},c.type)),jsx("div",{className:"drawui-toolbar-divider"}),_t.map(c=>jsx("button",{className:`drawui-toolbar-button ${e===c.type?"active":""}`,onClick:()=>t$1(c.type),title:t(c.labelKey),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:c.icon})})},c.type)),jsx("div",{className:"drawui-toolbar-divider"}),Vt.map(c=>jsx("button",{className:`drawui-toolbar-button ${e===c.type?"active":""}`,onClick:()=>t$1(c.type),title:t(c.labelKey),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:c.icon})})},c.type)),jsx("button",{className:`drawui-toolbar-button ${e==="uml-class"?"active":""}`,onClick:()=>t$1("uml-class"),title:t("toolbar.uml-class"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"}),jsx("line",{x1:"7",y1:"18",x2:"11",y2:"18"})]})}),jsx("button",{className:`drawui-toolbar-button ${e==="uml-interface"?"active":""}`,onClick:()=>t$1("uml-interface"),title:t("toolbar.uml-interface"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"})]})}),jsx("button",{className:`drawui-toolbar-button ${e==="mind-map"?"active":""}`,onClick:()=>t$1("mind-map"),title:t("toolbar.mind-map"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"5",cy:"12",r:"2.4"}),jsx("path",{d:"M7.4 12h3.6"}),jsx("path",{d:"M11 12c0-2.6 1.6-4.4 3.4-4.4"}),jsx("path",{d:"M11 12c0 2.6 1.6 4.4 3.4 4.4"}),jsx("circle",{cx:"17.4",cy:"7.6",r:"1.7"}),jsx("circle",{cx:"17.4",cy:"16.4",r:"1.7"}),jsx("circle",{cx:"15.6",cy:"12",r:"1.7"})]})}),jsx("div",{className:"drawui-toolbar-divider"}),jsx("button",{className:`drawui-toolbar-button ${o?"active":""}`,onClick:u,title:t("toolbar.grid"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"}),jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"})]})}),jsx("div",{className:"drawui-toolbar-divider"}),jsx("button",{className:"drawui-toolbar-button",onClick:i,disabled:!p,style:p?void 0:{opacity:.4,cursor:"default"},title:t("toolbar.undo"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 7v6h6"}),jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})}),jsx("button",{className:"drawui-toolbar-button",onClick:k,disabled:!h,style:h?void 0:{opacity:.4,cursor:"default"},title:t("toolbar.redo"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M21 7v6h-6"}),jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"})]})})]})})});var et=memo(function({onZoomIn:e,onZoomOut:t$1,onReset:o,zoomLevel:u=100}){return D(),jsxs("div",{className:"drawui-zoom-control",children:[jsx("button",{className:"drawui-zoom-button",onClick:e,title:t("zoom.in"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),jsxs("div",{className:"drawui-zoom-level",children:[u,"%"]}),jsx("button",{className:"drawui-zoom-button",onClick:t$1,title:"\u7F29\u5C0F",children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"})})}),jsx("button",{className:"drawui-zoom-button",onClick:o,title:t("zoom.reset"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),jsx("path",{d:"M3 3v5h5"})]})})]})});var gt=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af","#ffffff"],bt=[{key:"stroke",labelKey:"style.stroke",hasTransparent:false},{key:"fill",labelKey:"style.fill",hasTransparent:true},{key:"text",labelKey:"style.text",hasTransparent:false},{key:"highlight",labelKey:"style.highlight",hasTransparent:true}],Xt=[{type:"straight",labelKey:"style.connection.straight",icon:"\u2501"},{type:"polyline",labelKey:"style.connection.polyline",icon:jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 8 C 12 8, 12 16, 20 16"})})},{type:"orthogonal",labelKey:"style.connection.orthogonal",icon:"\u2517"},{type:"curve",labelKey:"style.connection.curve",icon:"\u223F"}],jt=[{type:"none",labelKey:"style.arrowhead.none",icon:"\u2501"},{type:"end",labelKey:"style.arrowhead.end",icon:"\u2192"},{type:"start",labelKey:"style.arrowhead.start",icon:"\u2190"},{type:"both",labelKey:"style.arrowhead.both",icon:"\u21C4"},{type:"inheritance",labelKey:"style.arrowhead.inheritance",icon:"\u2501\u2501\u25B7"},{type:"composition",labelKey:"style.arrowhead.composition",icon:"\u25C6\u2501\u2501"},{type:"aggregation",labelKey:"style.arrowhead.aggregation",icon:"\u25C7\u2501\u2501"}],xt=memo(function({editor:e,selectedCount:t$1,hasLineSelection:o,currentConnectionType:u,currentArrowHead:p,currentDashed:h}){if(D(),!e||t$1===0)return null;let i=(s,x)=>{switch(s){case "stroke":e.updateSelectedShapesStyle({strokeColor:x});break;case "fill":e.updateSelectedShapesStyle({fillColor:x});break;case "text":e.updateSelectedShapesText({textColor:x});break;case "highlight":e.updateSelectedShapesText({highlightColor:x});break}},k=s=>{e.updateConnectionType(s);},m=s=>{e.updateArrowHeadType(s);},y=s=>{e.updateArrowDashed(s);};return jsxs("div",{className:"drawui-style-panel",children:[jsx("div",{className:"drawui-style-col",children:bt.slice(0,2).map(s=>jsxs("div",{className:"drawui-style-group",children:[jsx("div",{className:"drawui-style-group-label",children:t(s.labelKey)}),jsxs("div",{className:"drawui-color-row",children:[s.hasTransparent&&jsx("button",{className:"drawui-color-swatch drawui-color-swatch-transparent",onClick:()=>i(s.key,"transparent"),title:t("style.none")}),gt.map(x=>jsx("button",{className:"drawui-color-swatch",style:{background:x},onClick:()=>i(s.key,x),title:x},`${s.key}-${x}`))]})]},s.key))}),jsx("div",{className:"drawui-style-divider"}),jsx("div",{className:"drawui-style-col",children:bt.slice(2).map(s=>jsxs("div",{className:"drawui-style-group",children:[jsx("div",{className:"drawui-style-group-label",children:t(s.labelKey)}),jsxs("div",{className:"drawui-color-row",children:[s.hasTransparent&&jsx("button",{className:"drawui-color-swatch drawui-color-swatch-transparent",onClick:()=>i(s.key,"transparent"),title:t("style.none")}),gt.map(x=>jsx("button",{className:"drawui-color-swatch",style:{background:x},onClick:()=>i(s.key,x),title:x},`${s.key}-${x}`))]})]},s.key))}),o&&jsxs(Fragment,{children:[jsx("div",{className:"drawui-style-divider"}),jsxs("div",{className:"drawui-style-col",children:[jsxs("div",{className:"drawui-style-group",children:[jsx("div",{className:"drawui-style-group-label",children:t("style.connection")}),jsx("div",{className:"drawui-connection-row",children:Xt.map(s=>jsxs("button",{className:`drawui-connection-btn${u===s.type?" active":""}`,onClick:()=>k(s.type),title:t(s.labelKey),children:[jsx("span",{className:"drawui-connection-icon",children:s.icon}),jsx("span",{className:"drawui-connection-label",children:t(s.labelKey)})]},s.type))})]}),jsxs("div",{className:"drawui-style-group",children:[jsx("div",{className:"drawui-style-group-label",children:t("style.arrow")}),jsx("div",{className:"drawui-connection-row",children:jt.map(s=>jsxs("button",{className:`drawui-connection-btn${p===s.type?" active":""}`,onClick:()=>m(s.type),title:t(s.labelKey),children:[jsx("span",{className:"drawui-connection-icon",children:s.icon}),jsx("span",{className:"drawui-connection-label",children:t(s.labelKey)})]},s.type))})]}),jsxs("div",{className:"drawui-style-group",children:[jsx("div",{className:"drawui-style-group-label",children:t("style.dashed")}),jsxs("div",{className:"drawui-connection-row",children:[jsxs("button",{className:`drawui-connection-btn${h?"":" active"}`,onClick:()=>y(false),title:t("style.solid"),children:[jsx("span",{className:"drawui-connection-icon",children:"\u2501"}),jsx("span",{className:"drawui-connection-label",children:t("style.solid")})]}),jsxs("button",{className:`drawui-connection-btn${h?" active":""}`,onClick:()=>y(true),title:t("style.dashed"),children:[jsx("span",{className:"drawui-connection-icon",children:"\u2504"}),jsx("span",{className:"drawui-connection-label",children:t("style.dashed")})]})]})]})]})]})]})});var ot=14,kt=20,rn=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af"],an=[12,14,16,18,20,24];function St(a,e,t){let o=a,u=t,p=o.charAt(0);if(o.length>1&&(p==="+"||p==="-"||p==="#"||p==="~")&&o.charAt(1)===" "&&(u=p,o=o.slice(2)),o=o.replace(/^\s+|\s+$/g,""),e==="attribute"){let s=o.indexOf(":");return s===-1?{visibility:u,name:o,type:"",params:"",returnType:""}:{visibility:u,name:o.slice(0,s).replace(/^\s+|\s+$/g,""),type:o.slice(s+1).replace(/^\s+|\s+$/g,""),params:"",returnType:""}}let h=o.indexOf("(");if(h===-1){let s=o.lastIndexOf(":");return s===-1?{visibility:u,name:o,type:"",params:"",returnType:""}:{visibility:u,name:o.slice(0,s).replace(/^\s+|\s+$/g,""),type:"",params:"",returnType:o.slice(s+1).replace(/^\s+|\s+$/g,"")}}let i=o.slice(0,h).replace(/^\s+|\s+$/g,""),k=o.indexOf(")",h);if(k===-1)return {visibility:u,name:i,type:"",params:o.slice(h+1).replace(/^\s+|\s+$/g,""),returnType:""};let m=o.slice(h+1,k).replace(/^\s+|\s+$/g,""),y=o.slice(k+1).replace(/^\s+|\s+$/g,"");return y.startsWith(":")&&(y=y.slice(1).replace(/^\s+|\s+$/g,"")),{visibility:u,name:i,type:"",params:m,returnType:y}}function sn(a,e){let t=`${e.visibility} `;return a==="attribute"?`${t}${e.name}: ${e.type??""}`:`${t}${e.name}(${e.params??""}): ${e.returnType??""}`}var Ct=memo(function({editor:e,umlClass:t$1,editing:o}){let[,u]=useState(0);D(),useEffect(()=>{if(!e)return;let d=e.subscribe(()=>u(S=>S+1));return ()=>{d();}},[e]);let[p,h]=useState(null),[i,k]=useState(false),m=useRef(null),y=useRef(null),s=useCallback((d,S)=>{m.current&&(clearTimeout(m.current),m.current=null),h({section:d,rowId:S}),k(false);},[]),x=useCallback(()=>{m.current&&clearTimeout(m.current),m.current=window.setTimeout(()=>{h(null),k(false);},150);},[]);if(!e||!t$1||o!==t$1.id)return null;let H=e.getCamera(),{id:c,x:_,y:z,width:B,height:R,className:ke,methods:n}=t$1,b=t$1.type==="uml-interface",l=b?[]:t$1.attributes,V=B/2,Q=R/2,ee=UML_HEADER_HEIGHT,F=UML_LINE_HEIGHT,ye=UML_PADDING_X,re=UML_PADDING_Y,te=b?0:l.length>0?l.length*F+re*2:re*2,g=H.zoom,pe=(B-ye*2)*g,Le=4*g,Te=H.pageToScreen({x:_-V+ye,y:z}),Se=H.pageToScreen({x:_,y:z-Q+ee/2}),I=d=>H.pageToScreen({x:_,y:d}).y,he=F*g,le=d=>z+(-Q+ee+re+F/2+d*F),Ne=d=>z+(-Q+ee+te+re+F/2+d*F),Ee=z+(-Q+ee+te),fe=z+Q,Me={background:"#ffffff",borderWidth:1,borderStyle:"solid",borderColor:"transparent",outline:"none",padding:0,fontFamily:"sans-serif",boxSizing:"border-box"},Re=(d,S)=>{let M=l.find(U=>U.id===d);if(!M)return;let T=St(S,"attribute",M.visibility);e.updateUmlClass(c,{attributes:l.map(U=>U.id===d?{...U,...T}:U)});},E=(d,S)=>{let M=n.find($=>$.id===d);if(!M)return;let T=St(S,"method",M.visibility),U=n.map($=>$.id===d?{...$,...T}:$);b?e.updateUmlInterface(c,{methods:U}):e.updateUmlClass(c,{methods:U});},w=(d,S,M)=>{y.current={section:d,from:S},M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",`${d}:${S}`);},ne=d=>{d.preventDefault(),d.dataTransfer.dropEffect="move";},G=(d,S,M)=>{M.preventDefault();let T=y.current;!T||T.section!==d||(d==="attribute"?e.reorderUmlAttribute(c,T.from,S):e.reorderUmlMethod(c,T.from,S),y.current=null);},Y=(d,S,M,T)=>{let U=I(T),$=p?.section===d&&p.rowId===M.id,Ie=(M.fontSize||UML_FONT_SIZE)*g,He=M.textColor||"#1f2937",f={position:"absolute",left:Te.x-ot*g-Le,top:U-he/2,width:ot*g+Le+pe+kt*g,height:he,display:"flex",alignItems:"center",gap:2,pointerEvents:"none",zIndex:53},W={...Me,width:pe,height:he-2,fontSize:Ie,color:He,textDecoration:M.strikethrough?"line-through":"none",pointerEvents:"auto",...$?{borderColor:"var(--dw-primary)"}:{}},ae={width:ot*g,height:he-2,cursor:"grab",color:"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",fontSize:12*g,lineHeight:1,opacity:$?1:.55,pointerEvents:"auto"},ce={width:kt*g,height:he-6,border:"none",background:"transparent",color:"#9ca3af",cursor:"pointer",borderRadius:3,fontSize:14*g,opacity:$?1:.35,pointerEvents:"auto"};return jsxs("div",{style:f,onDragOver:ne,onDrop:C=>G(d,S,C),children:[jsx("span",{style:ae,draggable:true,onDragStart:C=>w(d,S,C),title:t("uml.drag"),children:"\u22EE\u22EE"}),jsx("input",{style:W,value:sn(d,M),onChange:C=>d==="attribute"?Re(M.id,C.target.value):E(M.id,C.target.value),onFocus:()=>s(d,M.id),onBlur:x,spellCheck:false}),jsx("button",{style:ce,onMouseDown:C=>C.preventDefault(),onClick:()=>{d==="attribute"?e.removeUmlAttribute(c,M.id):e.removeUmlMethod(c,M.id);},title:t("uml.delete"),children:"\xD7"})]},M.id)},ie=(d,S,M)=>{let T=I(S),U=d==="attribute";return jsxs("button",{onMouseDown:$=>$.preventDefault(),onClick:()=>U?e.addUmlAttribute(c):e.addUmlMethod(c),className:"drawui-uml-add-row",style:{position:"absolute",left:Te.x,top:T-9*g,height:18*g,padding:`0 ${6*g}px`,fontSize:11*g,lineHeight:1,border:"1px dashed #cbd5e1",background:"rgba(255,255,255,0.85)",color:"#64748b",borderRadius:3,cursor:"pointer",pointerEvents:"auto",display:"flex",alignItems:"center",gap:3,whiteSpace:"nowrap",zIndex:53},title:M,children:[jsx("span",{style:{fontSize:13*g,lineHeight:1},children:"+"}),jsx("span",{children:M})]},`add-${d}`)},De=()=>{if(!p||p.section==="className")return null;let d=p.section,S=p.rowId,T=(d==="attribute"?l:n).find(L=>L.id===S);if(!T)return null;let U=224*g,$=30*g,Ie=H.pageToScreen({x:_,y:z}).x,He=H.pageToScreen({x:_,y:z-Q}).y,f=20*g,W=He-$-f,ae=Ie-U/2,ce=W+$,C=T.textColor||"#1f2937",ge=T.fontSize||UML_FONT_SIZE,K=!!T.strikethrough;return jsxs(Fragment,{children:[jsx("div",{style:{position:"absolute",left:Ie-.5,top:ce,width:1,height:f,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),jsxs("div",{className:"drawui-uml-toolbar",style:{position:"absolute",left:ae,top:W,width:U,height:$,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:6,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",gap:4*g,padding:`0 ${6*g}px`,pointerEvents:"auto",zIndex:60,fontSize:12*g},onMouseDown:L=>L.preventDefault(),children:[jsxs("div",{style:{position:"relative"},children:[jsxs("button",{onClick:()=>k(L=>!L),className:"drawui-uml-toolbar-btn",title:t("uml.textColor"),style:{border:"none",background:"transparent",cursor:"pointer",padding:2,display:"flex",alignItems:"center",borderRadius:3},children:[jsx("span",{style:{fontWeight:700,color:C,fontSize:13*g,textDecoration:K?"line-through":"none"},children:"A"}),jsx("span",{style:{width:10*g,height:2*g,background:C,marginLeft:3,borderRadius:1}})]}),i&&jsxs("div",{style:{position:"absolute",top:"100%",left:0,marginTop:4,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:4,padding:4,display:"flex",gap:2,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:61},children:[jsx("button",{onClick:()=>{e.updateUmlRowStyle(c,d,T.id,{textColor:null}),k(false);},style:{width:14,height:14,border:"1px solid #e5e7eb",background:"transparent",cursor:"pointer",borderRadius:2},title:t("uml.defaultColor")}),rn.map(L=>jsx("button",{onClick:()=>{e.updateUmlRowStyle(c,d,T.id,{textColor:L}),k(false);},style:{width:14,height:14,border:"none",background:L,cursor:"pointer",borderRadius:2},title:L},L))]})]}),jsx("select",{value:ge,onChange:L=>e.updateUmlRowStyle(c,d,T.id,{fontSize:Number(L.target.value)}),style:{border:"1px solid #e5e7eb",borderRadius:3,padding:`0 ${2*g}px`,fontSize:12*g,height:20*g,background:"#ffffff"},title:t("uml.fontSize"),children:an.map(L=>jsx("option",{value:L,children:L},L))}),jsx("button",{onClick:()=>e.updateUmlRowStyle(c,d,T.id,{strikethrough:!K}),className:"drawui-uml-toolbar-btn",title:t("uml.strikethrough"),style:{border:"none",background:K?"var(--dw-primary-weak)":"transparent",cursor:"pointer",padding:2,borderRadius:3},children:jsx("span",{style:{fontWeight:700,fontSize:13*g,textDecoration:"line-through"},children:"A"})}),jsx("button",{onClick:()=>{d==="attribute"?e.removeUmlAttribute(c,T.id):e.removeUmlMethod(c,T.id),h(null);},className:"drawui-uml-toolbar-btn",title:t("uml.delete"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#ef4444",padding:2,marginLeft:"auto",borderRadius:3},children:jsxs("svg",{width:14*g,height:14*g,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),jsx("path",{d:"M10 11v6"}),jsx("path",{d:"M14 11v6"}),jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]})]})},Ae=H.pageToScreen({x:_-V,y:z}).x,Xe=H.pageToScreen({x:_,y:z-Q}).y,je=B*g,qe=R*g;return jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsx("div",{style:{position:"absolute",left:Ae+1,top:Xe+1,width:Math.max(0,je-2),height:Math.max(0,qe-2),background:"#ffffff",pointerEvents:"none",zIndex:51}}),jsx("input",{style:{...Me,position:"absolute",left:Se.x-pe/2,top:Se.y-ee*g/2+2,width:pe,height:ee*g-4,textAlign:"center",fontWeight:700,fontSize:(t$1.fontSize||UML_FONT_SIZE)*g,color:t$1.textColor||"#1f2937",pointerEvents:"auto",zIndex:52,...p?.section==="className"?{borderColor:"var(--dw-primary)"}:{}},value:ke,onChange:d=>b?e.updateUmlInterface(c,{className:d.target.value}):e.updateUmlClass(c,{className:d.target.value}),onFocus:()=>s("className",""),onBlur:x,spellCheck:false}),!b&&jsxs(Fragment,{children:[l.map((d,S)=>Y("attribute",S,d,le(S))),ie("attribute",Ee,"\u5C5E\u6027")]}),n.map((d,S)=>Y("method",S,d,Ne(S))),ie("method",fe,t("uml.method")),De()]})});var Nt=memo(function({editor:e,panelOpen:t$1,onOpenPanel:o}){let[,u]=useState(0);D(),useEffect(()=>{if(!e)return;let B=e.subscribe(()=>u(R=>R+1));return ()=>{B();}},[e]);let p=useRef(false),h=useRef(false);if(!e)return null;let i=e.getMindMapEditingShapeId();if(!i||t$1)return null;let k=e.getMindMapSelectedNode();if(!k||k.shapeId!==i)return null;let m=e.getMindMapNode(i,k.nodeId),y=e.getMindMapNodeScreenRect(i,k.nodeId);if(!m||!y)return null;let s=e.getCamera().getZoom(),x=MINDMAP_FONT_SIZE*s,H=Math.max(100,y.width+24),c=y.height+8,_={position:"absolute",left:y.x+y.width/2,top:y.y-4,transform:"translateX(-50%)",width:H,height:c,border:"1.5px solid var(--dw-primary, #3b82f6)",borderRadius:6,background:"#ffffff",boxShadow:"0 2px 10px rgba(0,0,0,0.15)",outline:"none",padding:`0 ${(m.icon?24:12)*s}px`,fontFamily:"sans-serif",fontSize:x,color:"#1f2937",boxSizing:"border-box",pointerEvents:"auto",zIndex:55},z={position:"absolute",left:y.x+y.width+12,top:y.y+y.height/2-11,width:22,height:22,border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:"50%",cursor:"pointer",color:"#6b7280",fontSize:13,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 4px rgba(0,0,0,0.12)",pointerEvents:"auto",zIndex:55};return jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsx("input",{autoFocus:true,style:_,value:m.text,spellCheck:false,onChange:B=>{let R=!p.current;p.current=true,e.updateMindMapNode(i,k.nodeId,{text:B.target.value},R);},onBlur:()=>{if(h.current){h.current=false;return}e.exitMindMapEdit();},onKeyDown:B=>{B.key==="Enter"?B.target.blur():B.key==="Escape"&&e.exitMindMapEdit();}}),jsx("button",{style:z,title:t("mindmap.more"),onMouseDown:B=>{B.preventDefault(),h.current=true,setTimeout(()=>{h.current=false;},300);},onClick:o,children:"\u22EF"})]})});var Et=[...MINDMAP_COLORS,"#1f2937","#9ca3af"],Rt=["\u{1F4A1}","\u2B50","\u{1F525}","\u{1F4CC}","\u2705","\u2757","\u26A0\uFE0F","\u{1F3F7}\uFE0F"],wn={position:"absolute",width:232,background:"rgba(255,255,255,0.96)",border:"1px solid #e5e7eb",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.12)",padding:"10px 12px",fontSize:12,color:"#1f2937",zIndex:70,boxSizing:"border-box",fontFamily:"sans-serif"},rt={fontSize:11,color:"#6b7280",marginBottom:4,display:"block"},We={display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},Ze={border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:5,padding:"3px 8px",fontSize:12,color:"#374151",cursor:"pointer",lineHeight:1.5},it={width:"100%",border:"1px solid #e5e7eb",borderRadius:5,padding:"4px 8px",fontSize:12,outline:"none",boxSizing:"border-box",background:"#ffffff",color:"#1f2937"},It=memo(function({editor:e,mindMap:t$1}){let[,o]=useState(0);D(),useEffect(()=>{if(!e)return;let n=e.subscribe(()=>o(b=>b+1));return ()=>{n();}},[e]);let u=useRef(null);if(!e||!t$1||e.getMindMapEditingShapeId()!==t$1.id)return null;let p=e.getMindMapSelectedNode();if(!p||p.shapeId!==t$1.id)return null;let h=n=>{if(n.id===p.nodeId)return n;for(let b of n.children??[]){let l=h(b);if(l)return l}return null},i=h(t$1.root);if(!i)return null;let k=e.getCamera(),y=layoutMindMap(t$1.root).positions.get(i.id);if(!y)return null;let s=k.zoom,x=k.pageToScreen({x:t$1.x+y.x,y:t$1.y+y.y}),H=x.x+y.width*s/2+14,c=x.y-80,z=Math.max(8,Math.min(H,(window.innerWidth||1024)-232-8)),B=Math.max(8,Math.min(c,(window.innerHeight||768)-320)),R=n=>{e.updateMindMapNode(t$1.id,i.id,n);},ke=!!i.id&&i.id!==t$1.root.id;return jsxs("div",{ref:u,style:{...wn,left:z,top:B},onMouseDown:n=>n.stopPropagation(),children:[jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[jsx("span",{style:{fontWeight:600,fontSize:12},children:t("mindmap.nodeText")}),jsx("button",{onClick:()=>e.exitMindMapEdit(),title:t("mindmap.close"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#9ca3af",fontSize:14,lineHeight:1,padding:2},children:"\xD7"})]}),jsx("input",{style:{...it,marginBottom:8},value:i.text,onChange:n=>R({text:n.target.value}),spellCheck:false}),jsxs("div",{style:{...We,marginBottom:10},children:[jsxs("button",{style:Ze,onClick:()=>e.addMindMapChild(t$1.id,i.id),children:["+ ",t("mindmap.addChild")]}),ke&&jsxs("button",{style:Ze,onClick:()=>e.addMindMapSibling(t$1.id,i.id),children:["+ ",t("mindmap.addSibling")]}),!!i.children?.length&&jsx("button",{style:Ze,onClick:()=>e.toggleMindMapCollapse(t$1.id,i.id),children:i.collapsed?t("mindmap.expand"):t("mindmap.collapse")}),jsx("button",{style:{...Ze,color:"#ef4444",borderColor:"#fecaca",marginLeft:"auto"},onClick:()=>e.deleteMindMapNode(t$1.id,i.id),children:t("mindmap.deleteNode")})]}),jsx("span",{style:rt,children:t("mindmap.color")}),jsxs("div",{style:{...We,marginBottom:10},children:[jsx("button",{title:t("mindmap.levelColor"),onClick:()=>R({color:void 0}),style:{width:18,height:18,borderRadius:4,border:"1.5px solid #d1d5db",background:"conic-gradient(#ef4444, #f59e0b, #10b981, #3b82f6, #8b5cf6, #ec4899, #ef4444)",cursor:"pointer",flexShrink:0}}),Et.map(n=>jsx("button",{title:n,onClick:()=>R({color:n}),style:{width:18,height:18,borderRadius:4,border:i.color===n?"2px solid #111827":"1px solid #d1d5db",background:n,cursor:"pointer",flexShrink:0}},n))]}),jsx("span",{style:rt,children:t("mindmap.icon")}),jsxs("div",{style:{...We,marginBottom:10},children:[jsx("button",{title:t("mindmap.noIcon"),onClick:()=>R({icon:void 0}),style:{width:22,height:22,borderRadius:4,border:i.icon?"1px solid #d1d5db":"2px solid #111827",background:"#f9fafb",cursor:"pointer",fontSize:11,color:"#9ca3af",lineHeight:1},children:"\u2205"}),Rt.map(n=>jsx("button",{onClick:()=>R({icon:n}),style:{width:22,height:22,borderRadius:4,border:i.icon===n?"2px solid #111827":"1px solid #d1d5db",background:"#f9fafb",cursor:"pointer",fontSize:13,lineHeight:1},children:n},n)),jsx("input",{placeholder:"\u270F\uFE0F",defaultValue:i.icon&&!Rt.includes(i.icon)?i.icon:"",onKeyDown:n=>{if(n.key==="Enter"){let b=n.target.value.trim();R({icon:b||void 0});}},onBlur:n=>{let b=n.target.value.trim();b!==i.icon&&R({icon:b||void 0});},style:{...it,width:56,padding:"2px 4px",textAlign:"center"}})]}),jsx("span",{style:rt,children:t("mindmap.note")}),jsx("input",{style:{...it,marginBottom:6},value:i.note??"",placeholder:t("mindmap.notePlaceholder"),onChange:n=>R({note:n.target.value||void 0}),spellCheck:false}),!!i.note&&jsxs("div",{style:{...We,marginTop:4},children:[jsx("span",{style:{fontSize:11,color:"#6b7280"},children:t("mindmap.noteColor")}),jsx("button",{title:t("mindmap.noteColorDefault"),onClick:()=>R({noteColor:void 0}),style:{width:16,height:16,borderRadius:3,border:i.noteColor?"1px solid #d1d5db":"2px solid #111827",background:"repeating-conic-gradient(#ef4444 0% 25%, #f59e0b 0% 50%, #10b981 0% 75%, #3b82f6 0% 100%)",cursor:"pointer"}}),Et.map(n=>jsx("button",{onClick:()=>R({noteColor:n}),style:{width:16,height:16,borderRadius:3,border:i.noteColor===n?"2px solid #111827":"1px solid #d1d5db",background:n,cursor:"pointer"}},n))]})]})});var st=220,lt=140,Cn="#fafafa";function Ln(a,e){let t=Math.min(a.x,e.x),o=Math.min(a.y,e.y),u=Math.max(a.x+a.width,e.x+e.width),p=Math.max(a.y+a.height,e.y+e.height);return {x:t,y:o,width:u-t,height:p-o}}function Tn(a){return {x:a.x+a.width/2,y:a.y+a.height/2}}function Nn(){return {x:0,y:0,width:0,height:0}}function En(a){let e=1/0,t=1/0,o=-1/0,u=-1/0,p=false;for(let h of a){let i=dt(h);i&&(p=true,i.x<e&&(e=i.x),i.y<t&&(t=i.y),i.x+i.width>o&&(o=i.x+i.width),i.y+i.height>u&&(u=i.y+i.height));}return p?{x:e,y:t,width:o-e,height:u-t}:null}function dt(a){switch(a.type){case "rectangle":case "rounded-rectangle":case "ellipse":case "diamond":case "triangle":case "hexagon":case "text":return {x:a.x-a.width/2,y:a.y-a.height/2,width:a.width,height:a.height};case "circle":return {x:a.x-a.radius,y:a.y-a.radius,width:a.radius*2,height:a.radius*2};case "line":case "arrow":case "draw":{let e=a.points;if(!e||e.length===0)return null;let t=1/0,o=1/0,u=-1/0,p=-1/0;for(let h of e)h.x<t&&(t=h.x),h.y<o&&(o=h.y),h.x>u&&(u=h.x),h.y>p&&(p=h.y);return {x:t,y:o,width:u-t,height:p-o}}default:return null}}function Rn(a){let e=a.getCamera(),t=e.screenToPage({x:0,y:0}),o=e.screenToPage({x:window.innerWidth,y:window.innerHeight});return {x:t.x,y:t.y,width:o.x-t.x,height:o.y-t.y}}function In(a,e,t){if(a.width<=0||a.height<=0)return {x:a.x-e/2,y:a.y-t/2,width:e,height:t};let o=e/t,u=a.width,p=u/o;p<a.height&&(p=a.height,u=p*o);let h=Tn(a);return {x:h.x-u/2,y:h.y-p/2,width:u,height:p}}function ct(a,e,t,o){let u=(a-t.left)/t.width,p=(e-t.top)/t.height;return {x:o.x+u*o.width,y:o.y+p*o.height}}var zt=memo(function({editor:e}){let t$1=useRef(null),o=useRef(null),[u,p]=useState(false),[h,i]=useState(100),[k,m]=useState(false),[y,s]=useState(false);D();let x=useRef(null),H=useRef(null);useLayoutEffect(()=>{let n=t$1.current,b=o.current;if(!n||!b)return;let l=window.devicePixelRatio||1;n.width=Math.round(st*l),n.height=Math.round(lt*l),n.style.width=`${st}px`,n.style.height=`${lt}px`;},[u]);let c=useCallback(()=>{let n=t$1.current,b=o.current;if(!n||!b||!e)return;let l=n.getContext("2d");if(!l)return;let V=st,Q=lt,ee=n.width,F=n.height,ye=e.getShapes(),re=new Set(e.getSelectedIds()),te=getTheme(),g=hexToRgba(te.text,.16),pe=te.primary,Le=hexToRgba(te.primary,.18),Te=hexToRgba(te.primary,.85),Se=En(ye),I=Rn(e),he=Se?Ln(Se,I):I.width>0?I:Nn(),le=In(he,V,Q);H.current=le;let Ne=ee/le.width,Ee=F/le.height,fe=V/le.width;l.setTransform(1,0,0,1,0,0),l.fillStyle=Cn,l.fillRect(0,0,ee,F),l.setTransform(Ne,0,0,Ee,-Ne*le.x,-Ee*le.y),l.fillStyle=g;for(let E of ye){let w=dt(E);w&&l.fillRect(w.x,w.y,w.width,w.height);}l.fillStyle=pe;for(let E of ye){if(!re.has(E.id))continue;let w=dt(E);w&&l.fillRect(w.x,w.y,w.width,w.height);}l.fillStyle=Le,l.fillRect(I.x,I.y,I.width,I.height);let Me=1.5/fe;l.strokeStyle=Te,l.lineWidth=Me,l.lineJoin="round";let Re=Math.min(I.width/6,I.height/6,6/fe);if(l.beginPath(),Re*fe<1)l.rect(I.x,I.y,I.width,I.height);else {let E=I.x,w=I.y,ne=I.width,G=I.height,Y=Math.min(Re,ne/2,G/2);l.moveTo(E+Y,w),l.lineTo(E+ne-Y,w),l.quadraticCurveTo(E+ne,w,E+ne,w+Y),l.lineTo(E+ne,w+G-Y),l.quadraticCurveTo(E+ne,w+G,E+ne-Y,w+G),l.lineTo(E+Y,w+G),l.quadraticCurveTo(E,w+G,E,w+G-Y),l.lineTo(E,w+Y),l.quadraticCurveTo(E,w,E+Y,w),l.closePath();}l.stroke(),l.setTransform(1,0,0,1,0,0);},[e]);useEffect(()=>{if(!e||u)return;c();let n=e.subscribe(c),b=subscribeTheme(c),l=()=>c();return window.addEventListener("resize",l),()=>{n(),b(),window.removeEventListener("resize",l);}},[e,u,c]),useEffect(()=>{if(!e)return;let n=()=>{let l=e.getCamera().getZoom();i(Math.round(l*100));};n();let b=e.subscribe(n);return ()=>{b();}},[e]);let _=useCallback((n,b)=>{if(!e)return;let l=e.getCamera(),V=l.getZoom(),Q=window.innerWidth/2,ee=window.innerHeight/2,F=l;F.x=Q-n*V,F.y=ee-b*V,e.requestRender();},[e]),z=n=>{if(!e||!o.current||n.button!==0)return;let b=o.current.getBoundingClientRect(),l=H.current;if(!l)return;let V=ct(n.clientX,n.clientY,b,l);x.current={pointerId:n.pointerId,rect:{left:b.left,top:b.top,width:b.width,height:b.height},canvasBox:l},n.currentTarget.setPointerCapture(n.pointerId),s(true),_(V.x,V.y);},B=n=>{if(!y||!e||!x.current||!o.current)return;let b=x.current,l=ct(n.clientX,n.clientY,b.rect,b.canvasBox);_(l.x,l.y);},R=n=>{if(y){s(false),x.current=null;try{n.currentTarget.releasePointerCapture(n.pointerId);}catch{}}},ke=n=>{if(!e||!o.current)return;let b=H.current;if(!b)return;let l=o.current.getBoundingClientRect(),V=ct(n.clientX,n.clientY,l,b);_(V.x,V.y);};return jsxs("div",{className:`drawui-minimap ${u?"collapsed":""}`,children:[jsx("button",{className:"drawui-minimap-toggle",onClick:()=>p(n=>!n),title:u?t("minimap.expand"):t("minimap.collapse"),"aria-label":u?t("minimap.expand"):t("minimap.collapse"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u?jsx("polyline",{points:"9 6 15 12 9 18"}):jsx("polyline",{points:"15 6 9 12 15 18"})})}),!u&&jsxs("div",{className:"drawui-minimap-panel",children:[jsxs("div",{className:"drawui-minimap-header",children:[jsx("span",{className:"drawui-minimap-title",children:t("minimap.title")}),jsxs("span",{className:"drawui-minimap-zoom",children:[h,"%"]})]}),jsx("div",{ref:o,className:"drawui-minimap-canvas-wrap",style:{cursor:y?"grabbing":k?"pointer":"default"},onPointerEnter:()=>m(true),onPointerLeave:()=>m(false),children:jsx("canvas",{ref:t$1,className:"drawui-minimap-canvas",onPointerDown:z,onPointerMove:B,onPointerUp:R,onPointerCancel:R,onDoubleClick:ke})})]})]})});var J=a=>jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",className:"drawui-gen-shape-glyph",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:a}),zn=[{type:"rectangle",labelKey:"shape.rectangle",glyph:J(jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:J(jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:J(jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:J(jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:J(jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:J(jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:J(jsx("path",{d:"M12 3 L19.5 7.5 V16.5 L12 21 L4.5 16.5 V7.5 Z"}))},{type:"parallelogram",labelKey:"shape.parallelogram",glyph:J(jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:J(jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:J(jsx("path",{d:"M12 4 L19.5 9.5 L16.5 18.5 H7.5 L4.5 9.5 Z"}))},{type:"octagon",labelKey:"shape.octagon",glyph:J(jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:J(jsx("path",{d:"M12 3 L14 9.5 L20.5 10 L15.5 14 L17.5 20.5 L12 16.8 L6.5 20.5 L8.5 14 L3.5 10 L10 9.5 Z"}))},{type:"uml-class",labelKey:"shape.uml-class",glyph:J(jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsx("path",{d:"M3 9 H21"}),jsx("path",{d:"M3 15 H21"}),jsx("path",{d:"M6 6.5 H10"}),jsx("path",{d:"M6 12.5 H12"})]}))},{type:"uml-interface",labelKey:"shape.uml-interface",glyph:J(jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsx("path",{d:"M3 9 H21"}),jsx("path",{d:"M6 6.5 H10"}),jsx("path",{d:"M6 12.5 H12"})]}))},{type:"mind-map",labelKey:"shape.mind-map",glyph:J(jsxs(Fragment,{children:[jsx("circle",{cx:"5",cy:"12",r:"2"}),jsx("path",{d:"M7 12h2.6"}),jsx("path",{d:"M9.6 12c0-2 1.2-3.4 2.6-3.4"}),jsx("path",{d:"M9.6 12c0 2 1.2 3.4 2.6 3.4"}),jsx("circle",{cx:"15.2",cy:"8.6",r:"1.3"}),jsx("circle",{cx:"15.2",cy:"15.4",r:"1.3"}),jsx("circle",{cx:"13.6",cy:"12",r:"1.3"})]}))}];function Bt({editor:a,x:e,y:t$1,context:o,existingArrowId:u,defaultShapeType:p,onClose:h}){let i=useRef(null);D();let k=m=>{a?.createGeneratedConnection(o,{type:m,existingArrowId:u}),h();};return useEffect(()=>{let m=x=>{i.current&&!i.current.contains(x.target)&&h();},y=x=>{x.key==="Escape"&&(x.preventDefault(),h());},s=setTimeout(()=>{window.addEventListener("pointerdown",m,true),window.addEventListener("keydown",y,true);},0);return ()=>{clearTimeout(s),window.removeEventListener("pointerdown",m,true),window.removeEventListener("keydown",y,true);}},[h]),jsxs("div",{className:"drawui-gen-menu",ref:i,style:{left:e,top:t$1},children:[jsx("div",{className:"drawui-gen-menu-label",children:t("menu.title")}),jsx("div",{className:"drawui-gen-shape-grid",children:zn.map(m=>jsxs("button",{className:`drawui-gen-shape-btn${m.type===p?" drawui-gen-shape-active":""}`,onClick:()=>k(m.type),title:t(m.labelKey),children:[m.glyph,jsx("span",{className:"drawui-gen-shape-label",children:t(m.labelKey)})]},m.type))}),jsx("div",{className:"drawui-gen-menu-hint",children:t("menu.cancel")})]})}var An={select:"tool.select",hand:"tool.hand",rectangle:"tool.rectangle","rounded-rectangle":"tool.rounded-rectangle",circle:"tool.circle",ellipse:"tool.ellipse",diamond:"tool.diamond",triangle:"tool.triangle",hexagon:"tool.hexagon",parallelogram:"tool.parallelogram",trapezoid:"tool.trapezoid",pentagon:"tool.pentagon",octagon:"tool.octagon",star:"tool.star","uml-class":"tool.uml-class","uml-interface":"tool.uml-interface",line:"tool.line",arrow:"tool.arrow",text:"tool.text",draw:"tool.draw",pen:"tool.pen",highlighter:"tool.highlighter",eraser:"tool.eraser","mind-map":"tool.mind-map"};function Un({initialTool:a="select",className:e="",themeColor:t$1,language:o="zh-CN",data:u,onChange:p,onReady:h}){let i=useRef(null),k=useRef(null),m=useRef(null),[y,s]=useState(null);D();let[x,H]=useState(a),[c,_]=useState(false),[z,B]=useState(0),[R,ke]=useState(false),[n,b]=useState("straight"),[l,V]=useState("end"),[Q,ee]=useState(false),[F,ye]=useState(100),[re,te]=useState(null),[g,pe]=useState(null),[Le,Te]=useState(false),[Se,I]=useState(false),[he,le]=useState(null),[Ne,Ee]=useState(null),[fe,Me]=useState(false),[Re,E]=useState(null),[w,ne]=useState(null),G=useRef(null),Y=useRef(0),ie=useRef(null),De=useRef(p);De.current=p;let Ae=useRef(h);Ae.current=h,useEffect(()=>{if(!i.current)return;let f=new Editor(i.current,{theme:t$1?{primary:t$1,editBorder:t$1,selection:{outline:t$1,handleStroke:t$1,handleFill:"#ffffff",outlineFill:hexToRgba(t$1,.1),shadow:t$1}}:void 0,language:o,shapes:u,persist:!u});m.current=f,s(f),window.__drawuiEditor=f,Ae.current?.(f),a&&f.setActiveTool(a);let W=f.subscribe(()=>{H(f.getActiveTool());let C=f.getSelectedIds();B(C.length);let K=f.getShapes().filter(de=>C.includes(de.id)&&(de.type==="line"||de.type==="arrow"));if(ke(K.length>0),K.length>0&&K[0].connectionType?b(K[0].connectionType):K.length>0&&b("straight"),K.length>0){let de=K.find(Je=>Je.type==="arrow");de&&(V(de.arrowHead??"end"),ee(de.dashed??false));}ye(Math.round(f.getCamera().getZoom()*100)),Te(f.canUndo()),I(f.canRedo());let L=f.getSelectedUml();le(L),L||E(null);let Ue=f.getSelectedMindMap();Ee(Ue),f.getMindMapEditingShapeId()||Me(false),De.current?.(f.getData());}),ae=f.subscribeNotifications(C=>{pe(C),G.current&&clearTimeout(G.current),G.current=setTimeout(()=>pe(null),2e3);}),ce=f.subscribeUi(C=>{C.kind==="shapeTypeMenu"&&ne({x:C.screenX,y:C.screenY,context:C.context,existingArrowId:C.existingArrowId,defaultShapeType:C.defaultShapeType});});return ()=>{W(),ae(),ce(),G.current&&clearTimeout(G.current),cancelAnimationFrame(Y.current),f.dispose();}},[a]),useEffect(()=>{if(!t$1)return;let f=k.current;f&&(f.style.setProperty("--dw-primary",t$1),f.style.setProperty("--dw-primary-hover",shadeColor(t$1,-0.12)),f.style.setProperty("--dw-primary-weak",hexToRgba(t$1,.1)),f.style.setProperty("--dw-primary-contrast","#ffffff"),f.style.setProperty("--dw-shadow-primary",`0 2px 8px ${hexToRgba(t$1,.3)}`)),m.current?.setTheme({primary:t$1,editBorder:t$1,selection:{outline:t$1,handleStroke:t$1,handleFill:"#ffffff",outlineFill:hexToRgba(t$1,.1),shadow:t$1}});},[t$1]),useEffect(()=>{setLanguage(o),m.current?.setLanguage(o);},[o]);let Xe=useCallback(f=>{m.current?.setActiveTool(f);},[]),je=useCallback(()=>{m.current?.zoomIn();},[]),qe=useCallback(()=>{m.current?.zoomOut();},[]),d=useCallback(()=>{m.current?.resetZoom();},[]),S=useCallback(()=>{let f=!c;_(f),m.current?.setShowGrid(f);},[c]),M=useCallback(()=>{m.current?.undo();},[]),T=useCallback(()=>{m.current?.redo();},[]),U=useCallback(f=>{let W=m.current,ae=i.current;if(!W||!ae)return;if(W.isPointerDown()){ie.current!==null&&(ie.current=null,te(null));return}let ce=f.clientX,C=f.clientY;cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{let ge=ae.getBoundingClientRect(),K=ce-ge.left,L=C-ge.top,Ue=K+12,de=L+12,Je=W.getSelectedUml()?.id,Pe=W.getUmlRowAtScreenPoint({x:K,y:L});if(Pe&&Pe.shape.id!==Je&&Pe.text){ie.current!==Pe.text&&(ie.current=Pe.text,te({text:Pe.text,x:Ue,y:de}));return}let ze=W.getShapeAtScreenPoint({x:K,y:L});ze&&ze.text?ie.current!==ze.text&&(ie.current=ze.text,te({text:ze.text,x:Ue,y:de})):ie.current!==null&&(ie.current=null,te(null));});},[]),$=useCallback(()=>{te(null);},[]),Ie=useCallback(f=>{let W=m.current,ae=i.current;if(!W||!ae)return;let ce=ae.getBoundingClientRect(),C=f.clientX-ce.left,ge=f.clientY-ce.top,K=W.getUmlRowAtScreenPoint({x:C,y:ge});if(K){E(K.shape.id);return}let L=W.getMindMapNodeAtScreenPoint({x:C,y:ge});L&&W.beginMindMapEdit(L.shapeId,L.nodeId);},[]),He=useCallback(()=>{ne(null);},[]);return jsxs("div",{ref:k,className:`drawui-canvas-board ${e}`,children:[jsx("canvas",{ref:i,className:"drawui-canvas",onMouseMove:U,onMouseLeave:$,onDoubleClick:Ie}),re&&jsx("div",{className:"drawui-tooltip",style:{left:re.x,top:re.y},children:re.text}),jsx(Qe,{activeTool:x,onToolChange:Xe,showGrid:c,onToggleGrid:S,canUndo:Le,canRedo:Se,onUndo:M,onRedo:T}),jsx(et,{onZoomIn:je,onZoomOut:qe,onReset:d,zoomLevel:F}),jsx(xt,{editor:y,selectedCount:z,hasLineSelection:R,currentConnectionType:n,currentArrowHead:l,currentDashed:Q}),jsx(Ct,{editor:y,umlClass:he,editing:Re}),jsx(Nt,{editor:y,panelOpen:fe,onOpenPanel:()=>Me(true)}),fe&&jsx(It,{editor:y,mindMap:Ne}),jsx(zt,{editor:y}),w&&jsx(Bt,{editor:y,x:w.x,y:w.y,context:w.context,existingArrowId:w.existingArrowId,defaultShapeType:w.defaultShapeType,onClose:He}),jsxs("div",{className:"drawui-status-bar",children:[jsx("div",{className:"drawui-status-item",children:jsx("span",{children:t(An[x])})}),jsx("div",{className:"drawui-status-item",children:jsx("span",{children:z===0?t("status.none"):t("status.selected",{n:z})})}),jsx("div",{className:"drawui-status-item",children:jsxs("span",{children:[F,"%"]})})]}),g&&jsxs("div",{className:"drawui-toast",children:[jsx("svg",{className:"drawui-toast-icon",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),g]})]})}export{Un as CanvasBoard,Qe as Toolbar,et as ZoomControl};
1
+ import {memo,useState,useRef,useEffect,useCallback,useLayoutEffect}from'react';import {t,UML_FONT_SIZE,MINDMAP_COLORS,layoutMindMap,getTheme,hexToRgba,subscribeTheme,getLanguage,subscribeLanguage,UML_LINE_HEIGHT,UML_PADDING_Y,UML_PADDING_X,UML_HEADER_HEIGHT,MINDMAP_FONT_SIZE,Editor,shadeColor,setLanguage}from'drawui-core';import {jsx,jsxs,Fragment}from'react/jsx-runtime';function A(){let[s,e]=useState(getLanguage());return useEffect(()=>subscribeLanguage(()=>e(getLanguage())),[]),s}var bt=[{type:"rectangle",icon:jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"0"})},{type:"rounded-rectangle",icon:jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4"})},{type:"circle",icon:jsx("circle",{cx:"12",cy:"12",r:"8"})},{type:"ellipse",icon:jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"6"})},{type:"diamond",icon:jsx("path",{d:"M12 3L21 12L12 21L3 12Z"})},{type:"triangle",icon:jsx("path",{d:"M12 4L20 19L4 19Z"})},{type:"hexagon",icon:jsx("path",{d:"M12 3L20 7.5V16.5L12 21L4 16.5V7.5Z"})},{type:"parallelogram",icon:jsx("path",{d:"M7 5L20 5L17 19L4 19Z"})},{type:"trapezoid",icon:jsx("path",{d:"M6 5L18 5L21 19L3 19Z"})},{type:"pentagon",icon:jsx("path",{d:"M12 3L21 10L17.5 21L6.5 21L3 10Z"})},{type:"octagon",icon:jsx("path",{d:"M8 3L16 3L21 8L21 16L16 21L8 21L3 16L3 8Z"})},{type:"star",icon:jsx("path",{d:"M12 2L14.5 8.5L21 9L16 13.5L17.5 20L12 16.5L6.5 20L8 13.5L3 9L9.5 8.5Z"})}],Ot=new Set(bt.map(s=>s.type)),_t=[{type:"arrow",icon:"M5 12h14M12 5l7 7-7 7",labelKey:"toolbar.arrow"},{type:"text",icon:"M4 7V4h16v3M9 20h6M12 4v16",labelKey:"toolbar.text"}],Ft=[{type:"pen",icon:"M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3Z",labelKey:"toolbar.pen"},{type:"highlighter",icon:"M14 3l7 7-3 3-7-7 3-3zM9 8L3 14v3h3l6-6",labelKey:"toolbar.highlighter"}],Vt=[{type:"eraser",icon:"M7 21l-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21M22 21H7M5 11l9 9",labelKey:"toolbar.eraser"}],Yt="M18 11V6.5a1.5 1.5 0 0 0-3 0v3.5a1.5 1.5 0 0 0-3 0V3.5a1.5 1.5 0 0 0-3 0v6.5a1.5 1.5 0 0 0-3 0V14a8 8 0 0 0 16 0v-3a1.5 1.5 0 0 0-3 0",et=memo(function({activeTool:e,onToolChange:t$1,showGrid:r,onToggleGrid:u,canUndo:p=false,canRedo:m=false,onUndo:a,onRedo:S,onExport:h}){let[f,l]=useState(false),[b,R]=useState(false),x=useRef(null),K=useRef(null);A();let I=[{format:"png",labelKey:"toolbar.export.png"},{format:"svg",labelKey:"toolbar.export.svg"},{format:"pdf",labelKey:"toolbar.export.pdf"}],z=()=>{x.current&&(clearTimeout(x.current),x.current=null),R(true);},N=()=>{x.current=window.setTimeout(()=>R(false),200);},he=()=>{K.current&&(clearTimeout(K.current),K.current=null),l(true);},n=()=>{K.current=window.setTimeout(()=>{l(false);},200);};return jsx("div",{className:"drawui-toolbar-container",children:jsxs("div",{className:"drawui-toolbar",children:[jsx("button",{className:`drawui-toolbar-button ${e==="select"?"active":""}`,onClick:()=>t$1("select"),title:t("toolbar.select"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("circle",{cx:"12",cy:"12",r:"3"})})}),jsx("button",{className:`drawui-toolbar-button ${e==="hand"?"active":""}`,onClick:()=>t$1("hand"),title:t("toolbar.hand"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:Yt})})}),jsx("div",{className:"drawui-toolbar-divider"}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:he,onMouseLeave:n,children:[jsx("button",{className:`drawui-toolbar-button ${Ot.has(e)?"active":""}`,onClick:()=>t$1("rounded-rectangle"),title:"\u5F62\u72B6",children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4",ry:"4"})})}),f&&jsx("div",{className:"drawui-toolbar-shape-grid",children:bt.map(i=>jsx("button",{className:`drawui-toolbar-shape-item ${e===i.type?"active":""}`,onClick:()=>{t$1(i.type),l(false);},title:t("tool."+i.type),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:i.icon})},i.type))})]}),jsx("div",{className:"drawui-toolbar-divider"}),_t.map(i=>jsx("button",{className:`drawui-toolbar-button ${e===i.type?"active":""}`,onClick:()=>t$1(i.type),title:t(i.labelKey),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:i.icon})})},i.type)),jsx("div",{className:"drawui-toolbar-divider"}),Ft.map(i=>jsx("button",{className:`drawui-toolbar-button ${e===i.type?"active":""}`,onClick:()=>t$1(i.type),title:t(i.labelKey),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:i.icon})})},i.type)),jsx("div",{className:"drawui-toolbar-divider"}),Vt.map(i=>jsx("button",{className:`drawui-toolbar-button ${e===i.type?"active":""}`,onClick:()=>t$1(i.type),title:t(i.labelKey),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:i.icon})})},i.type)),jsx("button",{className:`drawui-toolbar-button ${e==="uml-class"?"active":""}`,onClick:()=>t$1("uml-class"),title:t("toolbar.uml-class"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"}),jsx("line",{x1:"7",y1:"18",x2:"11",y2:"18"})]})}),jsx("button",{className:`drawui-toolbar-button ${e==="uml-interface"?"active":""}`,onClick:()=>t$1("uml-interface"),title:t("toolbar.uml-interface"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"})]})}),jsx("button",{className:`drawui-toolbar-button ${e==="mind-map"?"active":""}`,onClick:()=>t$1("mind-map"),title:t("toolbar.mind-map"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"5",cy:"12",r:"2.4"}),jsx("path",{d:"M7.4 12h3.6"}),jsx("path",{d:"M11 12c0-2.6 1.6-4.4 3.4-4.4"}),jsx("path",{d:"M11 12c0 2.6 1.6 4.4 3.4 4.4"}),jsx("circle",{cx:"17.4",cy:"7.6",r:"1.7"}),jsx("circle",{cx:"17.4",cy:"16.4",r:"1.7"}),jsx("circle",{cx:"15.6",cy:"12",r:"1.7"})]})}),jsx("div",{className:"drawui-toolbar-divider"}),jsx("button",{className:`drawui-toolbar-button ${r?"active":""}`,onClick:u,title:t("toolbar.grid"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"}),jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"})]})}),jsx("div",{className:"drawui-toolbar-divider"}),jsx("button",{className:"drawui-toolbar-button",onClick:a,disabled:!p,style:p?void 0:{opacity:.4,cursor:"default"},title:t("toolbar.undo"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 7v6h6"}),jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})}),jsx("button",{className:"drawui-toolbar-button",onClick:S,disabled:!m,style:m?void 0:{opacity:.4,cursor:"default"},title:t("toolbar.redo"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M21 7v6h-6"}),jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"})]})}),jsx("div",{className:"drawui-toolbar-divider"}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:z,onMouseLeave:N,children:[jsx("button",{className:"drawui-toolbar-button",title:t("toolbar.export"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),jsx("polyline",{points:"7 10 12 15 17 10"}),jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),b&&jsx("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-export-grid",children:I.map(i=>jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{h?.(i.format),R(false);},title:t(i.labelKey),children:t(i.labelKey)},i.format))})]})]})})});var tt=memo(function({onZoomIn:e,onZoomOut:t$1,onReset:r,zoomLevel:u=100}){return A(),jsxs("div",{className:"drawui-zoom-control",children:[jsx("button",{className:"drawui-zoom-button",onClick:e,title:t("zoom.in"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),jsxs("div",{className:"drawui-zoom-level",children:[u,"%"]}),jsx("button",{className:"drawui-zoom-button",onClick:t$1,title:"\u7F29\u5C0F",children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"})})}),jsx("button",{className:"drawui-zoom-button",onClick:r,title:t("zoom.reset"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),jsx("path",{d:"M3 3v5h5"})]})})]})});var wt=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af","#ffffff"],vt=[{key:"stroke",labelKey:"style.stroke",hasTransparent:false},{key:"fill",labelKey:"style.fill",hasTransparent:true},{key:"text",labelKey:"style.text",hasTransparent:false},{key:"highlight",labelKey:"style.highlight",hasTransparent:true}],jt=[{type:"straight",labelKey:"style.connection.straight",icon:"\u2501"},{type:"polyline",labelKey:"style.connection.polyline",icon:jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 8 C 12 8, 12 16, 20 16"})})},{type:"orthogonal",labelKey:"style.connection.orthogonal",icon:"\u2517"},{type:"curve",labelKey:"style.connection.curve",icon:"\u223F"}],qt=[{type:"none",labelKey:"style.arrowhead.none",icon:"\u2501"},{type:"end",labelKey:"style.arrowhead.end",icon:"\u2192"},{type:"start",labelKey:"style.arrowhead.start",icon:"\u2190"},{type:"both",labelKey:"style.arrowhead.both",icon:"\u21C4"},{type:"inheritance",labelKey:"style.arrowhead.inheritance",icon:"\u2501\u2501\u25B7"},{type:"composition",labelKey:"style.arrowhead.composition",icon:"\u25C6\u2501\u2501"},{type:"aggregation",labelKey:"style.arrowhead.aggregation",icon:"\u25C7\u2501\u2501"}],kt=memo(function({editor:e,selectedCount:t$1,hasLineSelection:r,currentConnectionType:u,currentArrowHead:p,currentDashed:m}){if(A(),!e||t$1===0)return null;let a=(l,b)=>{switch(l){case "stroke":e.updateSelectedShapesStyle({strokeColor:b});break;case "fill":e.updateSelectedShapesStyle({fillColor:b});break;case "text":e.updateSelectedShapesText({textColor:b});break;case "highlight":e.updateSelectedShapesText({highlightColor:b});break}},S=l=>{e.updateConnectionType(l);},h=l=>{e.updateArrowHeadType(l);},f=l=>{e.updateArrowDashed(l);};return jsxs("div",{className:"drawui-style-panel",children:[jsx("div",{className:"drawui-style-col",children:vt.slice(0,2).map(l=>jsxs("div",{className:"drawui-style-group",children:[jsx("div",{className:"drawui-style-group-label",children:t(l.labelKey)}),jsxs("div",{className:"drawui-color-row",children:[l.hasTransparent&&jsx("button",{className:"drawui-color-swatch drawui-color-swatch-transparent",onClick:()=>a(l.key,"transparent"),title:t("style.none")}),wt.map(b=>jsx("button",{className:"drawui-color-swatch",style:{background:b},onClick:()=>a(l.key,b),title:b},`${l.key}-${b}`))]})]},l.key))}),jsx("div",{className:"drawui-style-divider"}),jsx("div",{className:"drawui-style-col",children:vt.slice(2).map(l=>jsxs("div",{className:"drawui-style-group",children:[jsx("div",{className:"drawui-style-group-label",children:t(l.labelKey)}),jsxs("div",{className:"drawui-color-row",children:[l.hasTransparent&&jsx("button",{className:"drawui-color-swatch drawui-color-swatch-transparent",onClick:()=>a(l.key,"transparent"),title:t("style.none")}),wt.map(b=>jsx("button",{className:"drawui-color-swatch",style:{background:b},onClick:()=>a(l.key,b),title:b},`${l.key}-${b}`))]})]},l.key))}),r&&jsxs(Fragment,{children:[jsx("div",{className:"drawui-style-divider"}),jsxs("div",{className:"drawui-style-col",children:[jsxs("div",{className:"drawui-style-group",children:[jsx("div",{className:"drawui-style-group-label",children:t("style.connection")}),jsx("div",{className:"drawui-connection-row",children:jt.map(l=>jsxs("button",{className:`drawui-connection-btn${u===l.type?" active":""}`,onClick:()=>S(l.type),title:t(l.labelKey),children:[jsx("span",{className:"drawui-connection-icon",children:l.icon}),jsx("span",{className:"drawui-connection-label",children:t(l.labelKey)})]},l.type))})]}),jsxs("div",{className:"drawui-style-group",children:[jsx("div",{className:"drawui-style-group-label",children:t("style.arrow")}),jsx("div",{className:"drawui-connection-row",children:qt.map(l=>jsxs("button",{className:`drawui-connection-btn${p===l.type?" active":""}`,onClick:()=>h(l.type),title:t(l.labelKey),children:[jsx("span",{className:"drawui-connection-icon",children:l.icon}),jsx("span",{className:"drawui-connection-label",children:t(l.labelKey)})]},l.type))})]}),jsxs("div",{className:"drawui-style-group",children:[jsx("div",{className:"drawui-style-group-label",children:t("style.dashed")}),jsxs("div",{className:"drawui-connection-row",children:[jsxs("button",{className:`drawui-connection-btn${m?"":" active"}`,onClick:()=>f(false),title:t("style.solid"),children:[jsx("span",{className:"drawui-connection-icon",children:"\u2501"}),jsx("span",{className:"drawui-connection-label",children:t("style.solid")})]}),jsxs("button",{className:`drawui-connection-btn${m?" active":""}`,onClick:()=>f(true),title:t("style.dashed"),children:[jsx("span",{className:"drawui-connection-icon",children:"\u2504"}),jsx("span",{className:"drawui-connection-label",children:t("style.dashed")})]})]})]})]})]})]})});var rt=14,Ct=20,an=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af"],sn=[12,14,16,18,20,24];function Lt(s,e,t){let r=s,u=t,p=r.charAt(0);if(r.length>1&&(p==="+"||p==="-"||p==="#"||p==="~")&&r.charAt(1)===" "&&(u=p,r=r.slice(2)),r=r.replace(/^\s+|\s+$/g,""),e==="attribute"){let l=r.indexOf(":");return l===-1?{visibility:u,name:r,type:"",params:"",returnType:""}:{visibility:u,name:r.slice(0,l).replace(/^\s+|\s+$/g,""),type:r.slice(l+1).replace(/^\s+|\s+$/g,""),params:"",returnType:""}}let m=r.indexOf("(");if(m===-1){let l=r.lastIndexOf(":");return l===-1?{visibility:u,name:r,type:"",params:"",returnType:""}:{visibility:u,name:r.slice(0,l).replace(/^\s+|\s+$/g,""),type:"",params:"",returnType:r.slice(l+1).replace(/^\s+|\s+$/g,"")}}let a=r.slice(0,m).replace(/^\s+|\s+$/g,""),S=r.indexOf(")",m);if(S===-1)return {visibility:u,name:a,type:"",params:r.slice(m+1).replace(/^\s+|\s+$/g,""),returnType:""};let h=r.slice(m+1,S).replace(/^\s+|\s+$/g,""),f=r.slice(S+1).replace(/^\s+|\s+$/g,"");return f.startsWith(":")&&(f=f.slice(1).replace(/^\s+|\s+$/g,"")),{visibility:u,name:a,type:"",params:h,returnType:f}}function ln(s,e){let t=`${e.visibility} `;return s==="attribute"?`${t}${e.name}: ${e.type??""}`:`${t}${e.name}(${e.params??""}): ${e.returnType??""}`}var Nt=memo(function({editor:e,umlClass:t$1,editing:r}){let[,u]=useState(0);A(),useEffect(()=>{if(!e)return;let d=e.subscribe(()=>u(M=>M+1));return ()=>{d();}},[e]);let[p,m]=useState(null),[a,S]=useState(false),h=useRef(null),f=useRef(null),l=useCallback((d,M)=>{h.current&&(clearTimeout(h.current),h.current=null),m({section:d,rowId:M}),S(false);},[]),b=useCallback(()=>{h.current&&clearTimeout(h.current),h.current=window.setTimeout(()=>{m(null),S(false);},150);},[]);if(!e||!t$1||r!==t$1.id)return null;let R=e.getCamera(),{id:x,x:K,y:I,width:z,height:N,className:he,methods:n}=t$1,i=t$1.type==="uml-interface",c=i?[]:t$1.attributes,_=z/2,ee=N/2,te=UML_HEADER_HEIGHT,Y=UML_LINE_HEIGHT,be=UML_PADDING_X,ie=UML_PADDING_Y,ne=i?0:c.length>0?c.length*Y+ie*2:ie*2,g=R.zoom,ye=(z-be*2)*g,Le=4*g,Te=R.pageToScreen({x:K-_+be,y:I}),Se=R.pageToScreen({x:K,y:I-ee+te/2}),P=d=>R.pageToScreen({x:K,y:d}).y,fe=Y*g,le=d=>I+(-ee+te+ie+Y/2+d*Y),Ne=d=>I+(-ee+te+ne+ie+Y/2+d*Y),Ee=I+(-ee+te+ne),xe=I+ee,Me={background:"#ffffff",borderWidth:1,borderStyle:"solid",borderColor:"transparent",outline:"none",padding:0,fontFamily:"sans-serif",boxSizing:"border-box"},Re=(d,M)=>{let C=c.find($=>$.id===d);if(!C)return;let L=Lt(M,"attribute",C.visibility);e.updateUmlClass(x,{attributes:c.map($=>$.id===d?{...$,...L}:$)});},E=(d,M)=>{let C=n.find(W=>W.id===d);if(!C)return;let L=Lt(M,"method",C.visibility),$=n.map(W=>W.id===d?{...W,...L}:W);i?e.updateUmlInterface(x,{methods:$}):e.updateUmlClass(x,{methods:$});},w=(d,M,C)=>{f.current={section:d,from:M},C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/plain",`${d}:${M}`);},oe=d=>{d.preventDefault(),d.dataTransfer.dropEffect="move";},G=(d,M,C)=>{C.preventDefault();let L=f.current;!L||L.section!==d||(d==="attribute"?e.reorderUmlAttribute(x,L.from,M):e.reorderUmlMethod(x,L.from,M),f.current=null);},F=(d,M,C,L)=>{let $=P(L),W=p?.section===d&&p.rowId===C.id,Ie=(C.fontSize||UML_FONT_SIZE)*g,Ke=C.textColor||"#1f2937",Pe={position:"absolute",left:Te.x-rt*g-Le,top:$-fe/2,width:rt*g+Le+ye+Ct*g,height:fe,display:"flex",alignItems:"center",gap:2,pointerEvents:"none",zIndex:53},y={...Me,width:ye,height:fe-2,fontSize:Ie,color:Ke,textDecoration:C.strikethrough?"line-through":"none",pointerEvents:"auto",...W?{borderColor:"var(--dw-primary)"}:{}},V={width:rt*g,height:fe-2,cursor:"grab",color:"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",fontSize:12*g,lineHeight:1,opacity:W?1:.55,pointerEvents:"auto"},se={width:Ct*g,height:fe-6,border:"none",background:"transparent",color:"#9ca3af",cursor:"pointer",borderRadius:3,fontSize:14*g,opacity:W?1:.35,pointerEvents:"auto"};return jsxs("div",{style:Pe,onDragOver:oe,onDrop:B=>G(d,M,B),children:[jsx("span",{style:V,draggable:true,onDragStart:B=>w(d,M,B),title:t("uml.drag"),children:"\u22EE\u22EE"}),jsx("input",{style:y,value:ln(d,C),onChange:B=>d==="attribute"?Re(C.id,B.target.value):E(C.id,B.target.value),onFocus:()=>l(d,C.id),onBlur:b,spellCheck:false}),jsx("button",{style:se,onMouseDown:B=>B.preventDefault(),onClick:()=>{d==="attribute"?e.removeUmlAttribute(x,C.id):e.removeUmlMethod(x,C.id);},title:t("uml.delete"),children:"\xD7"})]},C.id)},ae=(d,M,C)=>{let L=P(M),$=d==="attribute";return jsxs("button",{onMouseDown:W=>W.preventDefault(),onClick:()=>$?e.addUmlAttribute(x):e.addUmlMethod(x),className:"drawui-uml-add-row",style:{position:"absolute",left:Te.x,top:L-9*g,height:18*g,padding:`0 ${6*g}px`,fontSize:11*g,lineHeight:1,border:"1px dashed #cbd5e1",background:"rgba(255,255,255,0.85)",color:"#64748b",borderRadius:3,cursor:"pointer",pointerEvents:"auto",display:"flex",alignItems:"center",gap:3,whiteSpace:"nowrap",zIndex:53},title:C,children:[jsx("span",{style:{fontSize:13*g,lineHeight:1},children:"+"}),jsx("span",{children:C})]},`add-${d}`)},Ae=()=>{if(!p||p.section==="className")return null;let d=p.section,M=p.rowId,L=(d==="attribute"?c:n).find(k=>k.id===M);if(!L)return null;let $=224*g,W=30*g,Ie=R.pageToScreen({x:K,y:I}).x,Ke=R.pageToScreen({x:K,y:I-ee}).y,Pe=20*g,y=Ke-W-Pe,V=Ie-$/2,se=y+W,B=L.textColor||"#1f2937",D=L.fontSize||UML_FONT_SIZE,ce=!!L.strikethrough;return jsxs(Fragment,{children:[jsx("div",{style:{position:"absolute",left:Ie-.5,top:se,width:1,height:Pe,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),jsxs("div",{className:"drawui-uml-toolbar",style:{position:"absolute",left:V,top:y,width:$,height:W,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:6,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",gap:4*g,padding:`0 ${6*g}px`,pointerEvents:"auto",zIndex:60,fontSize:12*g},onMouseDown:k=>k.preventDefault(),children:[jsxs("div",{style:{position:"relative"},children:[jsxs("button",{onClick:()=>S(k=>!k),className:"drawui-uml-toolbar-btn",title:t("uml.textColor"),style:{border:"none",background:"transparent",cursor:"pointer",padding:2,display:"flex",alignItems:"center",borderRadius:3},children:[jsx("span",{style:{fontWeight:700,color:B,fontSize:13*g,textDecoration:ce?"line-through":"none"},children:"A"}),jsx("span",{style:{width:10*g,height:2*g,background:B,marginLeft:3,borderRadius:1}})]}),a&&jsxs("div",{style:{position:"absolute",top:"100%",left:0,marginTop:4,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:4,padding:4,display:"flex",gap:2,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:61},children:[jsx("button",{onClick:()=>{e.updateUmlRowStyle(x,d,L.id,{textColor:null}),S(false);},style:{width:14,height:14,border:"1px solid #e5e7eb",background:"transparent",cursor:"pointer",borderRadius:2},title:t("uml.defaultColor")}),an.map(k=>jsx("button",{onClick:()=>{e.updateUmlRowStyle(x,d,L.id,{textColor:k}),S(false);},style:{width:14,height:14,border:"none",background:k,cursor:"pointer",borderRadius:2},title:k},k))]})]}),jsx("select",{value:D,onChange:k=>e.updateUmlRowStyle(x,d,L.id,{fontSize:Number(k.target.value)}),style:{border:"1px solid #e5e7eb",borderRadius:3,padding:`0 ${2*g}px`,fontSize:12*g,height:20*g,background:"#ffffff"},title:t("uml.fontSize"),children:sn.map(k=>jsx("option",{value:k,children:k},k))}),jsx("button",{onClick:()=>e.updateUmlRowStyle(x,d,L.id,{strikethrough:!ce}),className:"drawui-uml-toolbar-btn",title:t("uml.strikethrough"),style:{border:"none",background:ce?"var(--dw-primary-weak)":"transparent",cursor:"pointer",padding:2,borderRadius:3},children:jsx("span",{style:{fontWeight:700,fontSize:13*g,textDecoration:"line-through"},children:"A"})}),jsx("button",{onClick:()=>{d==="attribute"?e.removeUmlAttribute(x,L.id):e.removeUmlMethod(x,L.id),m(null);},className:"drawui-uml-toolbar-btn",title:t("uml.delete"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#ef4444",padding:2,marginLeft:"auto",borderRadius:3},children:jsxs("svg",{width:14*g,height:14*g,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),jsx("path",{d:"M10 11v6"}),jsx("path",{d:"M14 11v6"}),jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]})]})},Ue=R.pageToScreen({x:K-_,y:I}).x,je=R.pageToScreen({x:K,y:I-ee}).y,qe=z*g,Je=N*g;return jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsx("div",{style:{position:"absolute",left:Ue+1,top:je+1,width:Math.max(0,qe-2),height:Math.max(0,Je-2),background:"#ffffff",pointerEvents:"none",zIndex:51}}),jsx("input",{style:{...Me,position:"absolute",left:Se.x-ye/2,top:Se.y-te*g/2+2,width:ye,height:te*g-4,textAlign:"center",fontWeight:700,fontSize:(t$1.fontSize||UML_FONT_SIZE)*g,color:t$1.textColor||"#1f2937",pointerEvents:"auto",zIndex:52,...p?.section==="className"?{borderColor:"var(--dw-primary)"}:{}},value:he,onChange:d=>i?e.updateUmlInterface(x,{className:d.target.value}):e.updateUmlClass(x,{className:d.target.value}),onFocus:()=>l("className",""),onBlur:b,spellCheck:false}),!i&&jsxs(Fragment,{children:[c.map((d,M)=>F("attribute",M,d,le(M))),ae("attribute",Ee,"\u5C5E\u6027")]}),n.map((d,M)=>F("method",M,d,Ne(M))),ae("method",xe,t("uml.method")),Ae()]})});var It=memo(function({editor:e,panelOpen:t$1,onOpenPanel:r}){let[,u]=useState(0);A(),useEffect(()=>{if(!e)return;let z=e.subscribe(()=>u(N=>N+1));return ()=>{z();}},[e]);let p=useRef(false),m=useRef(false);if(!e)return null;let a=e.getMindMapEditingShapeId();if(!a||t$1)return null;let S=e.getMindMapSelectedNode();if(!S||S.shapeId!==a)return null;let h=e.getMindMapNode(a,S.nodeId),f=e.getMindMapNodeScreenRect(a,S.nodeId);if(!h||!f)return null;let l=e.getCamera().getZoom(),b=MINDMAP_FONT_SIZE*l,R=Math.max(100,f.width+24),x=f.height+8,K={position:"absolute",left:f.x+f.width/2,top:f.y-4,transform:"translateX(-50%)",width:R,height:x,border:"1.5px solid var(--dw-primary, #3b82f6)",borderRadius:6,background:"#ffffff",boxShadow:"0 2px 10px rgba(0,0,0,0.15)",outline:"none",padding:`0 ${(h.icon?24:12)*l}px`,fontFamily:"sans-serif",fontSize:b,color:"#1f2937",boxSizing:"border-box",pointerEvents:"auto",zIndex:55},I={position:"absolute",left:f.x+f.width+12,top:f.y+f.height/2-11,width:22,height:22,border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:"50%",cursor:"pointer",color:"#6b7280",fontSize:13,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 4px rgba(0,0,0,0.12)",pointerEvents:"auto",zIndex:55};return jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsx("input",{autoFocus:true,style:K,value:h.text,spellCheck:false,onChange:z=>{let N=!p.current;p.current=true,e.updateMindMapNode(a,S.nodeId,{text:z.target.value},N);},onBlur:()=>{if(m.current){m.current=false;return}e.exitMindMapEdit();},onKeyDown:z=>{z.key==="Enter"?z.target.blur():z.key==="Escape"&&e.exitMindMapEdit();}}),jsx("button",{style:I,title:t("mindmap.more"),onMouseDown:z=>{z.preventDefault(),m.current=true,setTimeout(()=>{m.current=false;},300);},onClick:r,children:"\u22EF"})]})});var Pt=[...MINDMAP_COLORS,"#1f2937","#9ca3af"],Ht=["\u{1F4A1}","\u2B50","\u{1F525}","\u{1F4CC}","\u2705","\u2757","\u26A0\uFE0F","\u{1F3F7}\uFE0F"],vn={position:"absolute",width:232,background:"rgba(255,255,255,0.96)",border:"1px solid #e5e7eb",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.12)",padding:"10px 12px",fontSize:12,color:"#1f2937",zIndex:70,boxSizing:"border-box",fontFamily:"sans-serif"},it={fontSize:11,color:"#6b7280",marginBottom:4,display:"block"},Ze={display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},Oe={border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:5,padding:"3px 8px",fontSize:12,color:"#374151",cursor:"pointer",lineHeight:1.5},at={width:"100%",border:"1px solid #e5e7eb",borderRadius:5,padding:"4px 8px",fontSize:12,outline:"none",boxSizing:"border-box",background:"#ffffff",color:"#1f2937"},Kt=memo(function({editor:e,mindMap:t$1}){let[,r]=useState(0);A(),useEffect(()=>{if(!e)return;let n=e.subscribe(()=>r(i=>i+1));return ()=>{n();}},[e]);let u=useRef(null);if(!e||!t$1||e.getMindMapEditingShapeId()!==t$1.id)return null;let p=e.getMindMapSelectedNode();if(!p||p.shapeId!==t$1.id)return null;let m=n=>{if(n.id===p.nodeId)return n;for(let i of n.children??[]){let c=m(i);if(c)return c}return null},a=m(t$1.root);if(!a)return null;let S=e.getCamera(),f=layoutMindMap(t$1.root).positions.get(a.id);if(!f)return null;let l=S.zoom,b=S.pageToScreen({x:t$1.x+f.x,y:t$1.y+f.y}),R=b.x+f.width*l/2+14,x=b.y-80,I=Math.max(8,Math.min(R,(window.innerWidth||1024)-232-8)),z=Math.max(8,Math.min(x,(window.innerHeight||768)-320)),N=n=>{e.updateMindMapNode(t$1.id,a.id,n);},he=!!a.id&&a.id!==t$1.root.id;return jsxs("div",{ref:u,style:{...vn,left:I,top:z},onMouseDown:n=>n.stopPropagation(),children:[jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[jsx("span",{style:{fontWeight:600,fontSize:12},children:t("mindmap.nodeText")}),jsx("button",{onClick:()=>e.exitMindMapEdit(),title:t("mindmap.close"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#9ca3af",fontSize:14,lineHeight:1,padding:2},children:"\xD7"})]}),jsx("input",{style:{...at,marginBottom:8},value:a.text,onChange:n=>N({text:n.target.value}),spellCheck:false}),jsxs("div",{style:{...Ze,marginBottom:10},children:[jsxs("button",{style:Oe,onClick:()=>e.addMindMapChild(t$1.id,a.id),children:["+ ",t("mindmap.addChild")]}),he&&jsxs("button",{style:Oe,onClick:()=>e.addMindMapSibling(t$1.id,a.id),children:["+ ",t("mindmap.addSibling")]}),!!a.children?.length&&jsx("button",{style:Oe,onClick:()=>e.toggleMindMapCollapse(t$1.id,a.id),children:a.collapsed?t("mindmap.expand"):t("mindmap.collapse")}),jsx("button",{style:{...Oe,color:"#ef4444",borderColor:"#fecaca",marginLeft:"auto"},onClick:()=>e.deleteMindMapNode(t$1.id,a.id),children:t("mindmap.deleteNode")})]}),jsx("span",{style:it,children:t("mindmap.color")}),jsxs("div",{style:{...Ze,marginBottom:10},children:[jsx("button",{title:t("mindmap.levelColor"),onClick:()=>N({color:void 0}),style:{width:18,height:18,borderRadius:4,border:"1.5px solid #d1d5db",background:"conic-gradient(#ef4444, #f59e0b, #10b981, #3b82f6, #8b5cf6, #ec4899, #ef4444)",cursor:"pointer",flexShrink:0}}),Pt.map(n=>jsx("button",{title:n,onClick:()=>N({color:n}),style:{width:18,height:18,borderRadius:4,border:a.color===n?"2px solid #111827":"1px solid #d1d5db",background:n,cursor:"pointer",flexShrink:0}},n))]}),jsx("span",{style:it,children:t("mindmap.icon")}),jsxs("div",{style:{...Ze,marginBottom:10},children:[jsx("button",{title:t("mindmap.noIcon"),onClick:()=>N({icon:void 0}),style:{width:22,height:22,borderRadius:4,border:a.icon?"1px solid #d1d5db":"2px solid #111827",background:"#f9fafb",cursor:"pointer",fontSize:11,color:"#9ca3af",lineHeight:1},children:"\u2205"}),Ht.map(n=>jsx("button",{onClick:()=>N({icon:n}),style:{width:22,height:22,borderRadius:4,border:a.icon===n?"2px solid #111827":"1px solid #d1d5db",background:"#f9fafb",cursor:"pointer",fontSize:13,lineHeight:1},children:n},n)),jsx("input",{placeholder:"\u270F\uFE0F",defaultValue:a.icon&&!Ht.includes(a.icon)?a.icon:"",onKeyDown:n=>{if(n.key==="Enter"){let i=n.target.value.trim();N({icon:i||void 0});}},onBlur:n=>{let i=n.target.value.trim();i!==a.icon&&N({icon:i||void 0});},style:{...at,width:56,padding:"2px 4px",textAlign:"center"}})]}),jsx("span",{style:it,children:t("mindmap.note")}),jsx("input",{style:{...at,marginBottom:6},value:a.note??"",placeholder:t("mindmap.notePlaceholder"),onChange:n=>N({note:n.target.value||void 0}),spellCheck:false}),!!a.note&&jsxs("div",{style:{...Ze,marginTop:4},children:[jsx("span",{style:{fontSize:11,color:"#6b7280"},children:t("mindmap.noteColor")}),jsx("button",{title:t("mindmap.noteColorDefault"),onClick:()=>N({noteColor:void 0}),style:{width:16,height:16,borderRadius:3,border:a.noteColor?"1px solid #d1d5db":"2px solid #111827",background:"repeating-conic-gradient(#ef4444 0% 25%, #f59e0b 0% 50%, #10b981 0% 75%, #3b82f6 0% 100%)",cursor:"pointer"}}),Pt.map(n=>jsx("button",{onClick:()=>N({noteColor:n}),style:{width:16,height:16,borderRadius:3,border:a.noteColor===n?"2px solid #111827":"1px solid #d1d5db",background:n,cursor:"pointer"}},n))]})]})});var lt=220,ct=140,Ln="#fafafa";function Tn(s,e){let t=Math.min(s.x,e.x),r=Math.min(s.y,e.y),u=Math.max(s.x+s.width,e.x+e.width),p=Math.max(s.y+s.height,e.y+e.height);return {x:t,y:r,width:u-t,height:p-r}}function Nn(s){return {x:s.x+s.width/2,y:s.y+s.height/2}}function En(){return {x:0,y:0,width:0,height:0}}function Rn(s){let e=1/0,t=1/0,r=-1/0,u=-1/0,p=false;for(let m of s){let a=ut(m);a&&(p=true,a.x<e&&(e=a.x),a.y<t&&(t=a.y),a.x+a.width>r&&(r=a.x+a.width),a.y+a.height>u&&(u=a.y+a.height));}return p?{x:e,y:t,width:r-e,height:u-t}:null}function ut(s){switch(s.type){case "rectangle":case "rounded-rectangle":case "ellipse":case "diamond":case "triangle":case "hexagon":case "text":return {x:s.x-s.width/2,y:s.y-s.height/2,width:s.width,height:s.height};case "circle":return {x:s.x-s.radius,y:s.y-s.radius,width:s.radius*2,height:s.radius*2};case "line":case "arrow":case "draw":{let e=s.points;if(!e||e.length===0)return null;let t=1/0,r=1/0,u=-1/0,p=-1/0;for(let m of e)m.x<t&&(t=m.x),m.y<r&&(r=m.y),m.x>u&&(u=m.x),m.y>p&&(p=m.y);return {x:t,y:r,width:u-t,height:p-r}}default:return null}}function In(s){let e=s.getCamera(),t=e.screenToPage({x:0,y:0}),r=e.screenToPage({x:window.innerWidth,y:window.innerHeight});return {x:t.x,y:t.y,width:r.x-t.x,height:r.y-t.y}}function Pn(s,e,t){if(s.width<=0||s.height<=0)return {x:s.x-e/2,y:s.y-t/2,width:e,height:t};let r=e/t,u=s.width,p=u/r;p<s.height&&(p=s.height,u=p*r);let m=Nn(s);return {x:m.x-u/2,y:m.y-p/2,width:u,height:p}}function dt(s,e,t,r){let u=(s-t.left)/t.width,p=(e-t.top)/t.height;return {x:r.x+u*r.width,y:r.y+p*r.height}}var Dt=memo(function({editor:e}){let t$1=useRef(null),r=useRef(null),[u,p]=useState(false),[m,a]=useState(100),[S,h]=useState(false),[f,l]=useState(false);A();let b=useRef(null),R=useRef(null);useLayoutEffect(()=>{let n=t$1.current,i=r.current;if(!n||!i)return;let c=window.devicePixelRatio||1;n.width=Math.round(lt*c),n.height=Math.round(ct*c),n.style.width=`${lt}px`,n.style.height=`${ct}px`;},[u]);let x=useCallback(()=>{let n=t$1.current,i=r.current;if(!n||!i||!e)return;let c=n.getContext("2d");if(!c)return;let _=lt,ee=ct,te=n.width,Y=n.height,be=e.getShapes(),ie=new Set(e.getSelectedIds()),ne=getTheme(),g=hexToRgba(ne.text,.16),ye=ne.primary,Le=hexToRgba(ne.primary,.18),Te=hexToRgba(ne.primary,.85),Se=Rn(be),P=In(e),fe=Se?Tn(Se,P):P.width>0?P:En(),le=Pn(fe,_,ee);R.current=le;let Ne=te/le.width,Ee=Y/le.height,xe=_/le.width;c.setTransform(1,0,0,1,0,0),c.fillStyle=Ln,c.fillRect(0,0,te,Y),c.setTransform(Ne,0,0,Ee,-Ne*le.x,-Ee*le.y),c.fillStyle=g;for(let E of be){let w=ut(E);w&&c.fillRect(w.x,w.y,w.width,w.height);}c.fillStyle=ye;for(let E of be){if(!ie.has(E.id))continue;let w=ut(E);w&&c.fillRect(w.x,w.y,w.width,w.height);}c.fillStyle=Le,c.fillRect(P.x,P.y,P.width,P.height);let Me=1.5/xe;c.strokeStyle=Te,c.lineWidth=Me,c.lineJoin="round";let Re=Math.min(P.width/6,P.height/6,6/xe);if(c.beginPath(),Re*xe<1)c.rect(P.x,P.y,P.width,P.height);else {let E=P.x,w=P.y,oe=P.width,G=P.height,F=Math.min(Re,oe/2,G/2);c.moveTo(E+F,w),c.lineTo(E+oe-F,w),c.quadraticCurveTo(E+oe,w,E+oe,w+F),c.lineTo(E+oe,w+G-F),c.quadraticCurveTo(E+oe,w+G,E+oe-F,w+G),c.lineTo(E+F,w+G),c.quadraticCurveTo(E,w+G,E,w+G-F),c.lineTo(E,w+F),c.quadraticCurveTo(E,w,E+F,w),c.closePath();}c.stroke(),c.setTransform(1,0,0,1,0,0);},[e]);useEffect(()=>{if(!e||u)return;x();let n=e.subscribe(x),i=subscribeTheme(x),c=()=>x();return window.addEventListener("resize",c),()=>{n(),i(),window.removeEventListener("resize",c);}},[e,u,x]),useEffect(()=>{if(!e)return;let n=()=>{let c=e.getCamera().getZoom();a(Math.round(c*100));};n();let i=e.subscribe(n);return ()=>{i();}},[e]);let K=useCallback((n,i)=>{if(!e)return;let c=e.getCamera(),_=c.getZoom(),ee=window.innerWidth/2,te=window.innerHeight/2,Y=c;Y.x=ee-n*_,Y.y=te-i*_,e.requestRender();},[e]),I=n=>{if(!e||!r.current||n.button!==0)return;let i=r.current.getBoundingClientRect(),c=R.current;if(!c)return;let _=dt(n.clientX,n.clientY,i,c);b.current={pointerId:n.pointerId,rect:{left:i.left,top:i.top,width:i.width,height:i.height},canvasBox:c},n.currentTarget.setPointerCapture(n.pointerId),l(true),K(_.x,_.y);},z=n=>{if(!f||!e||!b.current||!r.current)return;let i=b.current,c=dt(n.clientX,n.clientY,i.rect,i.canvasBox);K(c.x,c.y);},N=n=>{if(f){l(false),b.current=null;try{n.currentTarget.releasePointerCapture(n.pointerId);}catch{}}},he=n=>{if(!e||!r.current)return;let i=R.current;if(!i)return;let c=r.current.getBoundingClientRect(),_=dt(n.clientX,n.clientY,c,i);K(_.x,_.y);};return jsxs("div",{className:`drawui-minimap ${u?"collapsed":""}`,children:[jsx("button",{className:"drawui-minimap-toggle",onClick:()=>p(n=>!n),title:u?t("minimap.expand"):t("minimap.collapse"),"aria-label":u?t("minimap.expand"):t("minimap.collapse"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u?jsx("polyline",{points:"9 6 15 12 9 18"}):jsx("polyline",{points:"15 6 9 12 15 18"})})}),!u&&jsxs("div",{className:"drawui-minimap-panel",children:[jsxs("div",{className:"drawui-minimap-header",children:[jsx("span",{className:"drawui-minimap-title",children:t("minimap.title")}),jsxs("span",{className:"drawui-minimap-zoom",children:[m,"%"]})]}),jsx("div",{ref:r,className:"drawui-minimap-canvas-wrap",style:{cursor:f?"grabbing":S?"pointer":"default"},onPointerEnter:()=>h(true),onPointerLeave:()=>h(false),children:jsx("canvas",{ref:t$1,className:"drawui-minimap-canvas",onPointerDown:I,onPointerMove:z,onPointerUp:N,onPointerCancel:N,onDoubleClick:he})})]})]})});var Q=s=>jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",className:"drawui-gen-shape-glyph",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:s}),zn=[{type:"rectangle",labelKey:"shape.rectangle",glyph:Q(jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:Q(jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:Q(jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:Q(jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:Q(jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:Q(jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:Q(jsx("path",{d:"M12 3 L19.5 7.5 V16.5 L12 21 L4.5 16.5 V7.5 Z"}))},{type:"parallelogram",labelKey:"shape.parallelogram",glyph:Q(jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:Q(jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:Q(jsx("path",{d:"M12 4 L19.5 9.5 L16.5 18.5 H7.5 L4.5 9.5 Z"}))},{type:"octagon",labelKey:"shape.octagon",glyph:Q(jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:Q(jsx("path",{d:"M12 3 L14 9.5 L20.5 10 L15.5 14 L17.5 20.5 L12 16.8 L6.5 20.5 L8.5 14 L3.5 10 L10 9.5 Z"}))},{type:"uml-class",labelKey:"shape.uml-class",glyph:Q(jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsx("path",{d:"M3 9 H21"}),jsx("path",{d:"M3 15 H21"}),jsx("path",{d:"M6 6.5 H10"}),jsx("path",{d:"M6 12.5 H12"})]}))},{type:"uml-interface",labelKey:"shape.uml-interface",glyph:Q(jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsx("path",{d:"M3 9 H21"}),jsx("path",{d:"M6 6.5 H10"}),jsx("path",{d:"M6 12.5 H12"})]}))},{type:"mind-map",labelKey:"shape.mind-map",glyph:Q(jsxs(Fragment,{children:[jsx("circle",{cx:"5",cy:"12",r:"2"}),jsx("path",{d:"M7 12h2.6"}),jsx("path",{d:"M9.6 12c0-2 1.2-3.4 2.6-3.4"}),jsx("path",{d:"M9.6 12c0 2 1.2 3.4 2.6 3.4"}),jsx("circle",{cx:"15.2",cy:"8.6",r:"1.3"}),jsx("circle",{cx:"15.2",cy:"15.4",r:"1.3"}),jsx("circle",{cx:"13.6",cy:"12",r:"1.3"})]}))}];function At({editor:s,x:e,y:t$1,context:r,existingArrowId:u,defaultShapeType:p,onClose:m}){let a=useRef(null);A();let S=h=>{s?.createGeneratedConnection(r,{type:h,existingArrowId:u}),m();};return useEffect(()=>{let h=b=>{a.current&&!a.current.contains(b.target)&&m();},f=b=>{b.key==="Escape"&&(b.preventDefault(),m());},l=setTimeout(()=>{window.addEventListener("pointerdown",h,true),window.addEventListener("keydown",f,true);},0);return ()=>{clearTimeout(l),window.removeEventListener("pointerdown",h,true),window.removeEventListener("keydown",f,true);}},[m]),jsxs("div",{className:"drawui-gen-menu",ref:a,style:{left:e,top:t$1},children:[jsx("div",{className:"drawui-gen-menu-label",children:t("menu.title")}),jsx("div",{className:"drawui-gen-shape-grid",children:zn.map(h=>jsxs("button",{className:`drawui-gen-shape-btn${h.type===p?" drawui-gen-shape-active":""}`,onClick:()=>S(h.type),title:t(h.labelKey),children:[h.glyph,jsx("span",{className:"drawui-gen-shape-label",children:t(h.labelKey)})]},h.type))}),jsx("div",{className:"drawui-gen-menu-hint",children:t("menu.cancel")})]})}var Un={select:"tool.select",hand:"tool.hand",rectangle:"tool.rectangle","rounded-rectangle":"tool.rounded-rectangle",circle:"tool.circle",ellipse:"tool.ellipse",diamond:"tool.diamond",triangle:"tool.triangle",hexagon:"tool.hexagon",parallelogram:"tool.parallelogram",trapezoid:"tool.trapezoid",pentagon:"tool.pentagon",octagon:"tool.octagon",star:"tool.star","uml-class":"tool.uml-class","uml-interface":"tool.uml-interface",line:"tool.line",arrow:"tool.arrow",text:"tool.text",draw:"tool.draw",pen:"tool.pen",highlighter:"tool.highlighter",eraser:"tool.eraser","mind-map":"tool.mind-map"};function $n({initialTool:s="select",className:e="",themeColor:t$1,language:r="zh-CN",data:u,onChange:p,onReady:m}){let a=useRef(null),S=useRef(null),h=useRef(null),[f,l]=useState(null);A();let[b,R]=useState(s),[x,K]=useState(false),[I,z]=useState(0),[N,he]=useState(false),[n,i]=useState("straight"),[c,_]=useState("end"),[ee,te]=useState(false),[Y,be]=useState(100),[ie,ne]=useState(null),[g,ye]=useState(null),[Le,Te]=useState(false),[Se,P]=useState(false),[fe,le]=useState(null),[Ne,Ee]=useState(null),[xe,Me]=useState(false),[Re,E]=useState(null),[w,oe]=useState(null),G=useRef(null),F=useRef(0),ae=useRef(null),Ae=useRef(p);Ae.current=p;let Ue=useRef(m);Ue.current=m,useEffect(()=>{if(!a.current)return;let y=new Editor(a.current,{theme:t$1?{primary:t$1,editBorder:t$1,selection:{outline:t$1,handleStroke:t$1,handleFill:"#ffffff",outlineFill:hexToRgba(t$1,.1),shadow:t$1}}:void 0,language:r,shapes:u,persist:!u});h.current=y,l(y),window.__drawuiEditor=y,Ue.current?.(y),s&&y.setActiveTool(s);let V=y.subscribe(()=>{R(y.getActiveTool());let D=y.getSelectedIds();z(D.length);let k=y.getShapes().filter(ue=>D.includes(ue.id)&&(ue.type==="line"||ue.type==="arrow"));if(he(k.length>0),k.length>0&&k[0].connectionType?i(k[0].connectionType):k.length>0&&i("straight"),k.length>0){let ue=k.find(Qe=>Qe.type==="arrow");ue&&(_(ue.arrowHead??"end"),te(ue.dashed??false));}be(Math.round(y.getCamera().getZoom()*100)),Te(y.canUndo()),P(y.canRedo());let de=y.getSelectedUml();le(de),de||E(null);let $e=y.getSelectedMindMap();Ee($e),y.getMindMapEditingShapeId()||Me(false),Ae.current?.(y.getData());}),se=y.subscribeNotifications(D=>{ye(D),G.current&&clearTimeout(G.current),G.current=setTimeout(()=>ye(null),2e3);}),B=y.subscribeUi(D=>{D.kind==="shapeTypeMenu"&&oe({x:D.screenX,y:D.screenY,context:D.context,existingArrowId:D.existingArrowId,defaultShapeType:D.defaultShapeType});});return ()=>{V(),se(),B(),G.current&&clearTimeout(G.current),cancelAnimationFrame(F.current),y.dispose();}},[s]),useEffect(()=>{if(!t$1)return;let y=S.current;y&&(y.style.setProperty("--dw-primary",t$1),y.style.setProperty("--dw-primary-hover",shadeColor(t$1,-0.12)),y.style.setProperty("--dw-primary-weak",hexToRgba(t$1,.1)),y.style.setProperty("--dw-primary-contrast","#ffffff"),y.style.setProperty("--dw-shadow-primary",`0 2px 8px ${hexToRgba(t$1,.3)}`)),h.current?.setTheme({primary:t$1,editBorder:t$1,selection:{outline:t$1,handleStroke:t$1,handleFill:"#ffffff",outlineFill:hexToRgba(t$1,.1),shadow:t$1}});},[t$1]),useEffect(()=>{setLanguage(r),h.current?.setLanguage(r);},[r]);let je=useCallback(y=>{h.current?.setActiveTool(y);},[]),qe=useCallback(()=>{h.current?.zoomIn();},[]),Je=useCallback(()=>{h.current?.zoomOut();},[]),d=useCallback(()=>{h.current?.resetZoom();},[]),M=useCallback(()=>{let y=!x;K(y),h.current?.setShowGrid(y);},[x]),C=useCallback(()=>{h.current?.undo();},[]),L=useCallback(()=>{h.current?.redo();},[]),$=useCallback(y=>{h.current?.downloadImage("drawui",y,{background:"#ffffff"});},[]),W=useCallback(y=>{let V=h.current,se=a.current;if(!V||!se)return;if(V.isPointerDown()){ae.current!==null&&(ae.current=null,ne(null));return}let B=y.clientX,D=y.clientY;cancelAnimationFrame(F.current),F.current=requestAnimationFrame(()=>{let ce=se.getBoundingClientRect(),k=B-ce.left,de=D-ce.top,$e=k+12,ue=de+12,Qe=V.getSelectedUml()?.id,He=V.getUmlRowAtScreenPoint({x:k,y:de});if(He&&He.shape.id!==Qe&&He.text){ae.current!==He.text&&(ae.current=He.text,ne({text:He.text,x:$e,y:ue}));return}let ze=V.getShapeAtScreenPoint({x:k,y:de});ze&&ze.text?ae.current!==ze.text&&(ae.current=ze.text,ne({text:ze.text,x:$e,y:ue})):ae.current!==null&&(ae.current=null,ne(null));});},[]),Ie=useCallback(()=>{ne(null);},[]),Ke=useCallback(y=>{let V=h.current,se=a.current;if(!V||!se)return;let B=se.getBoundingClientRect(),D=y.clientX-B.left,ce=y.clientY-B.top,k=V.getUmlRowAtScreenPoint({x:D,y:ce});if(k){E(k.shape.id);return}let de=V.getMindMapNodeAtScreenPoint({x:D,y:ce});de&&V.beginMindMapEdit(de.shapeId,de.nodeId);},[]),Pe=useCallback(()=>{oe(null);},[]);return jsxs("div",{ref:S,className:`drawui-canvas-board ${e}`,children:[jsx("canvas",{ref:a,className:"drawui-canvas",onMouseMove:W,onMouseLeave:Ie,onDoubleClick:Ke}),ie&&jsx("div",{className:"drawui-tooltip",style:{left:ie.x,top:ie.y},children:ie.text}),jsx(et,{activeTool:b,onToolChange:je,showGrid:x,onToggleGrid:M,canUndo:Le,canRedo:Se,onUndo:C,onRedo:L,onExport:$}),jsx(tt,{onZoomIn:qe,onZoomOut:Je,onReset:d,zoomLevel:Y}),jsx(kt,{editor:f,selectedCount:I,hasLineSelection:N,currentConnectionType:n,currentArrowHead:c,currentDashed:ee}),jsx(Nt,{editor:f,umlClass:fe,editing:Re}),jsx(It,{editor:f,panelOpen:xe,onOpenPanel:()=>Me(true)}),xe&&jsx(Kt,{editor:f,mindMap:Ne}),jsx(Dt,{editor:f}),w&&jsx(At,{editor:f,x:w.x,y:w.y,context:w.context,existingArrowId:w.existingArrowId,defaultShapeType:w.defaultShapeType,onClose:Pe}),jsxs("div",{className:"drawui-status-bar",children:[jsx("div",{className:"drawui-status-item",children:jsx("span",{children:t(Un[b])})}),jsx("div",{className:"drawui-status-item",children:jsx("span",{children:I===0?t("status.none"):t("status.selected",{n:I})})}),jsx("div",{className:"drawui-status-item",children:jsxs("span",{children:[Y,"%"]})})]}),g&&jsxs("div",{className:"drawui-toast",children:[jsx("svg",{className:"drawui-toast-icon",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),g]})]})}export{$n as CanvasBoard,et as Toolbar,tt as ZoomControl};
package/dist/styles.css CHANGED
@@ -198,6 +198,18 @@
198
198
  width: 20px;
199
199
  height: 20px;
200
200
  }
201
+ .drawui-toolbar-export-grid {
202
+ grid-template-columns: 1fr;
203
+ min-width: 132px;
204
+ }
205
+ .drawui-toolbar-export-item {
206
+ width: 100%;
207
+ height: 32px;
208
+ padding: 0 12px;
209
+ font-size: 13px;
210
+ white-space: nowrap;
211
+ justify-content: flex-start;
212
+ }
201
213
  .drawui-zoom-control {
202
214
  position: fixed;
203
215
  top: 20px;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "drawui-react",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
- "description": "React wrapper for drawui-core canvas drawing",
5
+ "description": "React wrapper for drawui-core canvas drawing (PNG / SVG / PDF export, UML, mind map)",
6
6
  "license": "MIT",
7
7
  "files": [
8
8
  "dist"
@@ -26,17 +26,11 @@
26
26
  },
27
27
  "./styles.css": "./dist/styles.css"
28
28
  },
29
- "scripts": {
30
- "build": "tsup && lessc src/styles.less dist/styles.css",
31
- "prepublishOnly": "pnpm build",
32
- "typecheck": "tsc --noEmit",
33
- "dev": "tsup --watch"
34
- },
35
29
  "publishConfig": {
36
30
  "access": "public"
37
31
  },
38
32
  "dependencies": {
39
- "drawui-core": "^0.2.0"
33
+ "drawui-core": "0.2.2"
40
34
  },
41
35
  "peerDependencies": {
42
36
  "react": "^18.3.1"
@@ -47,5 +41,10 @@
47
41
  "react": "^18.3.1",
48
42
  "tsup": "^8.4.0",
49
43
  "typescript": "^5.6.3"
44
+ },
45
+ "scripts": {
46
+ "build": "tsup && lessc src/styles.less dist/styles.css",
47
+ "typecheck": "tsc --noEmit",
48
+ "dev": "tsup --watch"
50
49
  }
51
50
  }