drawui-react 0.3.6 → 0.4.0
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/LICENSE +21 -21
- package/README.md +484 -472
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1 -1
- package/dist/styles.css +243 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var react=require('react'),drawuiCore=require('drawui-core'),jsxRuntime=require('react/jsx-runtime');function q(){let[n,e]=react.useState(drawuiCore.getLanguage());return react.useEffect(()=>drawuiCore.subscribeLanguage(()=>e(drawuiCore.getLanguage())),[]),n}var Zt=["#ffeb3b","#22c55e","#3b82f6","#ec4899","#8b5cf6","#f97316"],_t="drawui:highlighterColor";function rt(){if(typeof window>"u")return drawuiCore.DEFAULT_HIGHLIGHTER_COLOR;try{let n=window.localStorage.getItem(_t);return n&&/^#[0-9a-fA-F]{6}$/.test(n)?n.toLowerCase():drawuiCore.DEFAULT_HIGHLIGHTER_COLOR}catch{return drawuiCore.DEFAULT_HIGHLIGHTER_COLOR}}function Gt(n){if(!(typeof window>"u"))try{window.localStorage.setItem(_t,n);}catch{}}var fe=n=>`${n.x.toFixed(1)},${n.y.toFixed(1)}`,Vt=(n,e)=>{let o=e*Math.PI/180;return {x:n.x*Math.cos(o)-n.y*Math.sin(o),y:n.x*Math.sin(o)+n.y*Math.cos(o)}},Ye={x:Math.SQRT1_2,y:-Math.SQRT1_2},kt={x:4.6,y:19.4},Qe={x:19,y:5};function Mt(n,e,o){let r={x:-o.y,y:o.x},u=s=>({x:e.x-o.x*s,y:e.y-o.y*s}),p=(s,i)=>({x:s.x+r.x*i,y:s.y+r.y*i});switch(n){case "end":{let s=u(5.6);return jsxRuntime.jsx("polygon",{points:`${fe(e)} ${fe(p(s,2.7))} ${fe(p(s,-2.7))}`,fill:"currentColor",stroke:"none"})}case "inheritance":case "realization":{let s=u(8.6);return jsxRuntime.jsx("polygon",{points:`${fe(e)} ${fe(p(s,3.5))} ${fe(p(s,-3.5))}`,fill:"none"})}case "aggregation":case "composition":{let s=u(4.3),i=u(8.6);return jsxRuntime.jsx("polygon",{points:`${fe(e)} ${fe(p(s,2.7))} ${fe(i)} ${fe(p(s,-2.7))}`,fill:n==="composition"?"currentColor":"none",stroke:"currentColor"})}case "dependency":{let s=Vt({x:-o.x,y:-o.y},30),i=Vt({x:-o.x,y:-o.y},-30);return jsxRuntime.jsx("path",{d:`M ${fe({x:e.x+s.x*5.8,y:e.y+s.y*5.8})} L ${fe(e)} L ${fe({x:e.x+i.x*5.8,y:e.y+i.y*5.8})}`,fill:"none"})}default:return null}}function Se(n,e){let o=e||n==="dependency"||n==="realization",r=o?{x:Qe.x-Ye.x*8.6,y:Qe.y-Ye.y*8.6}:Qe,u={x:-Ye.x,y:-Ye.y};return jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:kt.x,y1:kt.y,x2:r.x,y2:r.y,strokeDasharray:o?"3 2.6":void 0}),(n==="end"||n==="both")&&Mt("end",Qe,Ye),(n==="start"||n==="both")&&Mt("end",kt,u),n!=="none"&&n!=="start"&&n!=="end"&&n!=="both"?Mt(n,Qe,Ye):null]})}var at=n=>jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:n})}),Co=[{type:"straight",labelKey:"style.connection.straight",icon:at("M3 12h18")},{type:"polyline",labelKey:"style.connection.polyline",icon:at("M4 8 C 12 8, 12 16, 20 16")},{type:"orthogonal",labelKey:"style.connection.orthogonal",icon:at("M5 5v14h14")},{type:"curve",labelKey:"style.connection.curve",icon:at("M3 13 C 6 7, 9 7, 12 12 C 15 17, 18 17, 21 11")}],Yt=[{key:"none",arrowHead:"none",dashed:false,labelKey:"style.arrowhead.none",icon:Se("none",false)},{key:"end",arrowHead:"end",dashed:false,labelKey:"style.arrowhead.end",icon:Se("end",false)},{key:"start",arrowHead:"start",dashed:false,labelKey:"style.arrowhead.start",icon:Se("start",false)},{key:"both",arrowHead:"both",dashed:false,labelKey:"style.arrowhead.both",icon:Se("both",false)},{key:"none-dashed",arrowHead:"none",dashed:true,labelKey:"style.arrowhead.none-dashed",icon:Se("none",true)},{key:"both-dashed",arrowHead:"both",dashed:true,labelKey:"style.arrowhead.both-dashed",icon:Se("both",true)}],Xt=[{key:"inheritance",arrowHead:"inheritance",dashed:false,labelKey:"style.arrowhead.inheritance",icon:Se("inheritance",false)},{key:"composition",arrowHead:"composition",dashed:false,labelKey:"style.arrowhead.composition",icon:Se("composition",false)},{key:"aggregation",arrowHead:"aggregation",dashed:false,labelKey:"style.arrowhead.aggregation",icon:Se("aggregation",false)},{key:"dependency",arrowHead:"dependency",dashed:true,labelKey:"style.arrowhead.dependency",icon:Se("dependency",true)},{key:"realization",arrowHead:"realization",dashed:true,labelKey:"style.arrowhead.realization",icon:Se("realization",true)}],Ft=[...Yt,...Xt];function Lo(n,e){let o=Ft.find(r=>r.arrowHead===n&&r.dashed===e);return o?o.key:Ft.find(r=>r.arrowHead===n)?.key}var st=react.memo(function({connectionType:e,arrowHead:o,dashed:r,onConnectionTypeChange:u,onArrowStyleChange:p,onOptionHover:s,onOptionLeave:i}){q();let M=Lo(o,r),f=c=>jsxRuntime.jsx("div",{className:"drawui-connection-row",children:c.map(b=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${M===b.key?" active":""}`,onClick:()=>p(b),"data-drawui-tip":s?void 0:drawuiCore.t(b.labelKey),onMouseEnter:s?P=>s(b.labelKey,P.currentTarget):void 0,onMouseLeave:s?i:void 0,"aria-label":drawuiCore.t(b.labelKey),type:"button",children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:b.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(b.labelKey)})]},b.key))});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.connection")}),jsxRuntime.jsx("div",{className:"drawui-connection-row",children:Co.map(c=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${e===c.type?" active":""}`,onClick:()=>u(c.type),"data-drawui-tip":s?void 0:drawuiCore.t(c.labelKey),onMouseEnter:s?b=>s(c.labelKey,b.currentTarget):void 0,onMouseLeave:s?i:void 0,"aria-label":drawuiCore.t(c.labelKey),type:"button",children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:c.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(c.labelKey)})]},c.type))}),jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.arrow")}),f(Yt),jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.uml")}),f(Xt)]})});var jt=[{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"})},{type:"cylinder",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"6.5",rx:"6",ry:"2.8"}),jsxRuntime.jsx("path",{d:"M6 6.5v11c0 1.5 2.7 2.8 6 2.8s6-1.3 6-2.8v-11"})]})},{type:"cloud",icon:jsxRuntime.jsx("path",{d:"M7 18.5h9.4a3.4 3.4 0 0 0 .3-6.8 5 5 0 0 0-9.5-1.2A3.9 3.9 0 0 0 7 18.5Z"})},{type:"heart",icon:jsxRuntime.jsx("path",{d:"M12 20.3S4.6 15.7 4.6 10.5A4.1 4.1 0 0 1 12 7.6a4.1 4.1 0 0 1 7.4 2.9c0 5.2-7.4 9.8-7.4 9.8Z"})},{type:"block-arrow-right",icon:jsxRuntime.jsx("path",{d:"M3 9h9V5l9 7-9 7v-4H3Z"})},{type:"block-arrow-left",icon:jsxRuntime.jsx("path",{d:"M21 9h-9V5L3 12l9 7v-4h9Z"})},{type:"block-arrow-up",icon:jsxRuntime.jsx("path",{d:"M9 21v-9H5l7-9 7 9h-4v9Z"})},{type:"block-arrow-down",icon:jsxRuntime.jsx("path",{d:"M9 3v9H5l7 9 7-9h-4V3Z"})},{type:"block-arrow-double",icon:jsxRuntime.jsx("path",{d:"M2 12l4.5-6v3.5h11V6L22 12l-4.5 6v-3.5h-11V18Z"})},{type:"right-triangle",icon:jsxRuntime.jsx("path",{d:"M4 4v16h16Z"})},{type:"cross",icon:jsxRuntime.jsx("path",{d:"M9.5 3h5v6.5H21v5h-6.5V21h-5v-6.5H3v-5h6.5Z"})},{type:"envelope",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14"}),jsxRuntime.jsx("path",{d:"M3 5l18 14M21 5L3 19"})]})},{type:"checkbox",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),jsxRuntime.jsx("path",{d:"M7.8 12.3l2.7 2.7 5.7-6.2"})]})},{type:"speech-rect",icon:jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("path",{d:"M3 5h18v11H8l-3.2 3.2V16H3Z"})})},{type:"speech-round",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"10.5",rx:"9",ry:"6.5"}),jsxRuntime.jsx("path",{d:"M8 16.2 6 21l5-3.4"})]})},{type:"cube",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 3 20 7.5v9L12 21 4 16.5v-9Z"}),jsxRuntime.jsx("path",{d:"M4 7.5 12 12l8-4.5M12 12v9"})]})},{type:"cuboid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 4 21 8.5v7L12 20 3 15.5v-7Z"}),jsxRuntime.jsx("path",{d:"M3 8.5 12 13l9-4.5M12 13v7"})]})},{type:"triangular-pyramid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 3 21.5 16.5 12 21 2.5 16.5Z"}),jsxRuntime.jsx("path",{d:"M12 3v18M2.5 16.5h19"})]})},{type:"quadrangular-pyramid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 3 22.5 17 12 21 1.5 17Z"}),jsxRuntime.jsx("path",{d:"M12 3v18M12 12 1.5 17M12 12l10.5 5"})]})},{type:"sphere",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"9"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"2.5"})]})},{type:"ellipsoid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"10",ry:"6.5"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"10",ry:"1.9"})]})},{type:"pie",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"9",rx:"9",ry:"3.5"}),jsxRuntime.jsx("path",{d:"M3 9v5c0 1.9 4 3.5 9 3.5s9-1.6 9-3.5V9"}),jsxRuntime.jsx("path",{d:"M12 9 5.6 12M12 9l6.4 3"})]})},{type:"hollow-pie",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"9",rx:"9",ry:"3.5"}),jsxRuntime.jsx("path",{d:"M3 9v5c0 1.9 4 3.5 9 3.5s9-1.6 9-3.5V9"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"9",rx:"3.6",ry:"1.5"})]})},{type:"sector",icon:jsxRuntime.jsx("path",{d:"M12 3a9 9 0 1 0 9 9h-9Z"})},{type:"delay",icon:jsxRuntime.jsx("path",{d:"M3 5h12a7 7 0 0 1 0 14H3Z"})},{type:"predefined-process",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14"}),jsxRuntime.jsx("path",{d:"M6.5 5v14M17.5 5v14"})]})},{type:"document",icon:jsxRuntime.jsx("path",{d:"M3 5h18v10.5c-5 3.5-13-3.5-18 0Z"})},{type:"stadium",icon:jsxRuntime.jsx("rect",{x:"3",y:"6.5",width:"18",height:"11",rx:"5.5"})},{type:"chevron",icon:jsxRuntime.jsx("path",{d:"M2 4h9l9 8-9 8H2l8-8Z"})},{type:"brace-left",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M1 1C3.9 1 5.1 2.4 5.1 5.1c0 3.7 1.2 6.9 2.9 6.9-1.7 0-2.9 3.2-2.9 6.9 0 2.7-1.2 4.1-4.1 4.1"}),jsxRuntime.jsx("path",{d:"M12 9.6h10M12 14.4h10"})]})},{type:"brace-right",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M23 1c-2.9 0-4.1 1.4-4.1 4.1 0 3.7-1.2 6.9-2.9 6.9 1.7 0 2.9 3.2 2.9 6.9 0 2.7 1.2 4.1 4.1 4.1"}),jsxRuntime.jsx("path",{d:"M2 9.6h10M2 14.4h10"})]})},{type:"uml-class",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{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"})]})},{type:"uml-interface",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{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"})]})},{type:"class-catalog",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"1.5"}),jsxRuntime.jsx("line",{x1:"6.6",y1:"5",x2:"6.6",y2:"19"}),jsxRuntime.jsx("line",{x1:"17.4",y1:"5",x2:"17.4",y2:"19"})]})}],Eo=[{key:"basic",labelKey:"shapeGroup.basic",items:[{type:"rectangle"},{type:"rounded-rectangle"},{type:"stadium"},{type:"circle"},{type:"ellipse"},{type:"diamond"},{type:"triangle"},{type:"right-triangle"},{type:"hexagon"},{type:"parallelogram"},{type:"trapezoid"},{type:"pentagon"},{type:"octagon"},{type:"star"},{type:"envelope"},{type:"checkbox"}]},{key:"flowchart",labelKey:"shapeGroup.flowchart",items:[{type:"rectangle",labelKey:"flow.process"},{type:"rounded-rectangle",labelKey:"flow.step"},{type:"stadium",labelKey:"flow.startEnd"},{type:"diamond",labelKey:"flow.decision"},{type:"parallelogram",labelKey:"flow.data"},{type:"trapezoid",labelKey:"flow.manual"},{type:"hexagon",labelKey:"flow.preparation"},{type:"cylinder",labelKey:"flow.database"},{type:"delay",labelKey:"flow.delay"},{type:"predefined-process"},{type:"document"},{type:"block-arrow-right"},{type:"block-arrow-left"},{type:"block-arrow-up"},{type:"block-arrow-down"},{type:"block-arrow-double"}]},{key:"uml",labelKey:"shapeGroup.uml",items:[{type:"uml-class"},{type:"uml-interface"},{type:"rounded-rectangle",labelKey:"class.plain"},{type:"class-catalog"}]},{key:"solid",labelKey:"shapeGroup.solid",items:[{type:"cylinder"},{type:"cube"},{type:"cuboid"},{type:"triangular-pyramid"},{type:"quadrangular-pyramid"},{type:"sphere"},{type:"ellipsoid"},{type:"pie"},{type:"hollow-pie"}]},{key:"other",labelKey:"shapeGroup.other",items:[{type:"cloud"},{type:"heart"},{type:"cross"},{type:"sector"},{type:"chevron"},{type:"speech-rect"},{type:"speech-round"},{type:"brace-left"},{type:"brace-right"}]}],Ro=new Map(jt.map(n=>[n.type,n.icon])),Io=new Set(jt.map(n=>n.type)),Ho=[{type:"arrow",icon:"M5 12h14M12 5l7 7-7 7",labelKey:"toolbar.arrow"},{type:"text",icon:"M4 7V4h16v3M9 20h6M12 4v16",labelKey:"toolbar.text"}],Ko="M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3Z",St="M0 -1Q0.24 -0.24 1 0Q0.24 0.24 0 1Q-0.24 0.24 -1 0Q-0.24 -0.24 0 -1Z",Po=[{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"}],Ct=react.memo(function({activeTool:e,onToolChange:o,showGrid:r,onToggleGrid:u,canUndo:p=false,canRedo:s=false,onUndo:i,onRedo:M,onExport:f,onHighlighterColorChange:c,arrowStyle:b,onArrowStyleChange:P}){let[D,v]=react.useState(false),[U,x]=react.useState(false),[A,O]=react.useState(null),[me,a]=react.useState(false),[w,d]=react.useState(false),[j,_]=react.useState(rt),z=react.useRef(null),G=react.useRef(null),te=react.useRef(null),V=react.useRef(null);q();let ue=[{format:"png",labelKey:"toolbar.export.png"},{format:"svg",labelKey:"toolbar.export.svg"},{format:"pdf",labelKey:"toolbar.export.pdf"}],g=()=>{z.current&&(clearTimeout(z.current),z.current=null),a(true);},oe=()=>{z.current=window.setTimeout(()=>a(false),200);},ke=()=>{G.current&&(clearTimeout(G.current),G.current=null),v(true);},ge=()=>{G.current=window.setTimeout(()=>{v(false),$();},200);},he=()=>{te.current&&(clearTimeout(te.current),te.current=null),x(true);},B=()=>{te.current=window.setTimeout(()=>{x(false),$();},200);},re=(h,S)=>{let C=h.closest(".drawui-toolbar");if(!C)return;let k=h.getBoundingClientRect(),W=C.getBoundingClientRect(),F=k.bottom+46>window.innerHeight;O({label:S,x:k.left-W.left+k.width/2,y:F?k.top-W.top-8:k.bottom-W.top+8,above:F});},$=()=>O(null),be=()=>{V.current&&(clearTimeout(V.current),V.current=null),d(true);},Ce=()=>{V.current=window.setTimeout(()=>d(false),200);},we=h=>{_(h),Gt(h),c?.(h),o("highlighter");};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:()=>o("select"),onMouseEnter:h=>re(h.currentTarget,"toolbar.select"),onMouseLeave:$,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:"M6 3 6 19.6 10.3 15.7 13 21.1 15.8 19.8 13.1 14.5 18.6 14 Z"})})}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="hand"?"active":""}`,onClick:()=>o("hand"),onMouseEnter:h=>re(h.currentTarget,"toolbar.hand"),onMouseLeave:$,children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M7.6 12.6V5.6a1.5 1.5 0 0 1 3 0v4.6"}),jsxRuntime.jsx("path",{d:"M10.6 10.2V4.1a1.5 1.5 0 0 1 3 0v6.1"}),jsxRuntime.jsx("path",{d:"M13.6 10.4V5.2a1.5 1.5 0 0 1 3 0v6.6"}),jsxRuntime.jsx("path",{d:"M16.6 11.8V8.1a1.5 1.5 0 0 1 3 0v6.6a6.2 6.2 0 0 1-6.2 6.2h-1.5a6.2 6.2 0 0 1-5-2.5l-3.2-4.4a1.5 1.5 0 0 1 2.3-1.9l2.6 2.5"})]})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:ke,onMouseLeave:ge,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${Io.has(e)?"active":""}`,onClick:()=>{o("rounded-rectangle"),v(false),$();},"data-drawui-tip":D?void 0:drawuiCore.t("toolbar.shapes"),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"})})}),D&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-shape-menu",children:jsxRuntime.jsx("div",{className:"drawui-shape-menu-scroll",children:Eo.map(h=>jsxRuntime.jsxs("div",{className:"drawui-shape-group",children:[jsxRuntime.jsx("div",{className:"drawui-shape-group-title",children:drawuiCore.t(h.labelKey)}),jsxRuntime.jsx("div",{className:"drawui-shape-group-grid",children:h.items.map(S=>{let C=S.labelKey??`tool.${S.type}`;return jsxRuntime.jsx("button",{type:"button",className:`drawui-toolbar-shape-item ${e===S.type?"active":""}`,onClick:()=>{o(S.type),v(false),$();},onMouseEnter:k=>re(k.currentTarget,C),onMouseLeave:$,"aria-label":drawuiCore.t(C),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:Ro.get(S.type)})},`${h.key}-${S.type}`)})})]},h.key))})})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:he,onMouseLeave:B,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="arrow"?"active":""}`,onClick:()=>{o("arrow"),x(false),$();},"data-drawui-tip":U?void 0:drawuiCore.t("toolbar.arrow"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})}),U&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-arrow-menu",onPointerDown:h=>{h.target.closest("button")||(x(false),$());},children:jsxRuntime.jsx(st,{connectionType:b?.connectionType??"straight",arrowHead:b?.arrowHead??"end",dashed:!!b?.dashed,onConnectionTypeChange:h=>{P?.({connectionType:h}),o("arrow"),x(false),$();},onArrowStyleChange:h=>{P?.({arrowHead:h.arrowHead,dashed:h.dashed}),o("arrow"),x(false),$();},onOptionHover:(h,S)=>re(S,h),onOptionLeave:$})})]}),Ho.filter(h=>h.type!=="arrow").map(h=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===h.type?"active":""}`,onClick:()=>o(h.type),"data-drawui-tip":drawuiCore.t(h.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:h.icon})})},h.type)),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="pen"?"active":""}`,onClick:()=>o("pen"),"data-drawui-tip":drawuiCore.t("toolbar.pen"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:Ko})})}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:be,onMouseLeave:Ce,children:[jsxRuntime.jsxs("button",{className:`drawui-toolbar-button ${e==="highlighter"?"active":""}`,onClick:()=>o("highlighter"),onMouseEnter:h=>re(h.currentTarget,"toolbar.highlighter"),onMouseLeave:$,children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M4.6 19.6 12.8 11.4",strokeWidth:"3.6",strokeLinecap:"square"}),jsxRuntime.jsx("path",{d:"M14.6 9.6 16.2 8",strokeWidth:"3.6",strokeLinecap:"square"}),jsxRuntime.jsxs("g",{fill:"currentColor",stroke:"none",children:[jsxRuntime.jsx("path",{d:St,transform:"translate(7.4 5.4) scale(2.4)"}),jsxRuntime.jsx("path",{d:St,transform:"translate(18.4 3.4) scale(2.5)"}),jsxRuntime.jsx("path",{d:St,transform:"translate(21 10.6) scale(2.2)"})]})]}),jsxRuntime.jsx("span",{className:"drawui-toolbar-color-chip",style:{background:j}})]}),w&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-highlighter-grid",children:Zt.map(h=>jsxRuntime.jsx("button",{type:"button","aria-label":h,className:`drawui-highlighter-swatch${j.toLowerCase()===h.toLowerCase()?" active":""}`,style:{background:h},onClick:()=>we(h)},h))})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),Po.map(h=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===h.type?"active":""}`,onClick:()=>o(h.type),"data-drawui-tip":drawuiCore.t(h.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:h.icon})})},h.type)),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="mind-map"?"active":""}`,onClick:()=>o("mind-map"),"data-drawui-tip":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,"data-drawui-tip":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"},"data-drawui-tip":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:M,disabled:!s,style:s?void 0:{opacity:.4,cursor:"default"},"data-drawui-tip":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:g,onMouseLeave:oe,children:[jsxRuntime.jsx("button",{className:"drawui-toolbar-button","data-drawui-tip":me?void 0: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"})]})}),me&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-export-grid",children:ue.map(h=>jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{f?.(h.format),a(false);},"data-drawui-tip":drawuiCore.t(h.labelKey),children:drawuiCore.t(h.labelKey)},h.format))})]}),A&&jsxRuntime.jsx("div",{className:`drawui-shape-tip ${A.above?"is-above":"is-below"}`,style:{left:A.x,top:A.y},children:drawuiCore.t(A.label)})]})})});var Tt=react.memo(function({onZoomIn:e,onZoomOut:o,onReset:r,zoomLevel:u=100}){return q(),jsxRuntime.jsxs("div",{className:"drawui-zoom-control",children:[jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:e,"data-drawui-tip":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:o,"data-drawui-tip":drawuiCore.t("zoom.out"),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,"data-drawui-tip":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 Jt=["#ffffff","#f1f5f9","#e2e8f0","#ede9fe","#dbeafe","#e0e7ff","#dcfce7","#fef9c3","#fee2e2"],eo=["#0f172a","#475569","#94a3b8","#8b5cf6","#3b82f6","#1d4ed8","#16a34a","#eab308","#dc2626"],Do=Jt.filter(n=>n!=="#f1f5f9"),Uo=[...Do,...eo],Wo=[...Jt,...eo],to=15,oo="drawui:customColors";function Zo(){if(typeof window>"u")return [];try{let n=window.localStorage.getItem(oo);if(!n)return [];let e=JSON.parse(n);return Array.isArray(e)?e.filter(o=>typeof o=="string").slice(-to):[]}catch{return []}}function _o(n){if(!(typeof window>"u"))try{window.localStorage.setItem(oo,JSON.stringify(n));}catch{}}var qt=[{key:"fill",labelKey:"style.fill",hasTransparent:true,hasOpacity:true},{key:"stroke",labelKey:"style.stroke",hasTransparent:false,hasOpacity:true},{key:"text",labelKey:"style.text",hasTransparent:false},{key:"highlight",labelKey:"style.highlight",hasTransparent:true,hasOpacity:true}],Qt=(n,e)=>!!n&&!!e&&n.toLowerCase()===e.toLowerCase(),et=10,Be=12,Ae=n=>!n||n==="transparent",no=react.memo(function({editor:e,selectedCount:o,hasLineSelection:r,currentConnectionType:u,currentArrowHead:p,currentDashed:s}){q();let i=!!e?.getEditingShapeId(),[M,f]=react.useState(null),[c,b]=react.useState(null),[,P]=react.useState(0),D=react.useRef(null),v=react.useRef(null),U=react.useRef(null),[x,A]=react.useState({tw:168,th:42,pw:228,ph:160}),[O,me]=react.useState(Zo),a=react.useRef(null),w=react.useCallback(l=>{let L=l.trim().toLowerCase();/^#[0-9a-f]{6}$/.test(L)&&me(xe=>{let y=xe.filter(R=>R!==L);for(y.push(L);y.length>to;)y.shift();return _o(y),y});},[]);if(react.useEffect(()=>{let l=a.current;if(!l)return;let L=()=>{l.value&&w(l.value);};return l.addEventListener("change",L),()=>l.removeEventListener("change",L)},[w,c]),react.useEffect(()=>{if(!e)return;let l=e.subscribe(()=>P(L=>(L+1)%1e6));return ()=>{l();}},[e]),react.useEffect(()=>{b(null);},[o,i]),react.useEffect(()=>{if(!c)return;let l=L=>{D.current&&!D.current.contains(L.target)&&b(null);};return document.addEventListener("pointerdown",l,true),()=>document.removeEventListener("pointerdown",l,true)},[c]),react.useLayoutEffect(()=>{let l=v.current?.offsetWidth??x.tw,L=v.current?.offsetHeight??x.th,xe=U.current?.offsetWidth??x.pw,y=U.current?.offsetHeight??x.ph;A(R=>R.tw===l&&R.th===L&&R.pw===xe&&R.ph===y?R:{tw:l,th:L,pw:xe,ph:y});}),!e||o===0||i)return null;let d=e.getSelectedIds(),_=e.getShapes().filter(l=>d.includes(l.id)),z=_[0],G=z?.id??"",te=z?.style.fillColor,V=z?.style.strokeColor??"#1f2937",ue=z?.textColor??"#1f2937",g=z?.highlightColor,oe={fill:te,stroke:V,text:ue,highlight:g},ke={fill:z?.style.fillOpacity??1,stroke:z?.style.strokeOpacity??1,highlight:z?.highlightOpacity??1},ge=l=>M&&M.key===`${G}:${l}`?M.value:ke[l]??1,he=(l,L)=>{switch(l){case "stroke":e.updateSelectedShapesStyle({strokeColor:L});break;case "fill":e.updateSelectedShapesStyle({fillColor:L});break;case "text":e.updateSelectedShapesText({textColor:L});break;case "highlight":e.updateSelectedShapesText({highlightColor:L});break}},B=(l,L)=>{f({key:`${G}:${l}`,value:L}),l==="highlight"?e.updateSelectedShapesText({highlightOpacity:L}):l==="stroke"?e.updateSelectedShapesStyle({strokeOpacity:L}):e.updateSelectedShapesStyle({fillOpacity:L});},re=l=>e.updateConnectionType(l),$=l=>e.updateArrowStyle({arrowHead:l.arrowHead,dashed:l.dashed}),be=!!r&&_.length>0&&_.every(l=>l.type==="line"||l.type==="arrow"),Ce=_.length>0&&_.every(l=>l.type==="text"),we=be?qt.filter(l=>l.key==="stroke"):qt,h=l=>l.key==="stroke"&&be?"style.line":l.labelKey,S=c&&c!=="more"?we.find(l=>l.key===c):void 0,C=!!c&&(c==="more"||c==="prefix"||!!S),k=e.getCamera(),W=drawuiCore.getContentBounds(_,0),F=k.pageToScreen({x:W.x,y:W.y}),ne=k.pageToScreen({x:W.x+W.width,y:W.y+W.height}),Me=window.innerWidth,Oe=window.innerHeight,ye=ne.y+et,We=F.y-et,Ze=x.th+(C?et+x.ph:0),je=ye+Ze<=Oe-Be,m=We-Ze>=Be,I=je||!m,H=(F.x+ne.x)/2,K=(l,L,xe)=>Math.max(L,Math.min(l,Math.max(L,xe))),Q=K(H-x.tw/2,Be,Me-x.tw-Be),X=I?ye:We-x.th,ze=K(H-x.pw/2,Be,Me-x.pw-Be),_e=C?K(I?X+x.th+et:X-et-x.ph,Be,Oe-x.ph-Be):0;return jsxRuntime.jsxs("div",{className:"drawui-style-floating",ref:D,children:[jsxRuntime.jsxs("div",{className:"drawui-style-toolbar",ref:v,style:{left:Q,top:X},children:[we.map(l=>jsxRuntime.jsxs("button",{className:`drawui-style-tool-btn${c===l.key?" active":""}`,onClick:()=>b(c===l.key?null:l.key),"data-drawui-tip":drawuiCore.t(h(l)),type:"button",children:[l.key==="fill"&&jsxRuntime.jsx("span",{className:`drawui-st-swatch${Ae(te)?" drawui-st-none":""}`,style:Ae(te)?void 0:{background:te}}),l.key==="stroke"&&(be?jsxRuntime.jsx("span",{className:`drawui-st-line${Ae(V)?" drawui-st-line-none":""}`,style:Ae(V)?void 0:{background:V}}):jsxRuntime.jsx("span",{className:`drawui-st-frame${Ae(V)?" drawui-st-frame-none":""}`,style:Ae(V)?void 0:{borderColor:V}})),l.key==="text"&&jsxRuntime.jsx("span",{className:"drawui-st-text",style:{color:ue},children:"A"}),l.key==="highlight"&&jsxRuntime.jsx("span",{className:`drawui-st-hl${Ae(g)?" drawui-st-none":""}`,style:Ae(g)?void 0:{background:g},children:"A"})]},l.key)),r&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${c==="more"?" active":""}`,onClick:()=>b(c==="more"?null:"more"),"data-drawui-tip":drawuiCore.t("style.connection"),type:"button",children:"\u22EF"}),Ce&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${c==="prefix"?" active":""}`,onClick:()=>b(c==="prefix"?null:"prefix"),"data-drawui-tip":drawuiCore.t("style.prefix"),type:"button",children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[jsxRuntime.jsx("circle",{cx:"5",cy:"8",r:"1.7",fill:"currentColor",stroke:"none"}),jsxRuntime.jsx("circle",{cx:"5",cy:"16",r:"1.7",fill:"currentColor",stroke:"none"}),jsxRuntime.jsx("line",{x1:"10.5",y1:"8",x2:"20",y2:"8"}),jsxRuntime.jsx("line",{x1:"10.5",y1:"16",x2:"20",y2:"16"})]})})]}),C&&jsxRuntime.jsx("div",{className:"drawui-style-popover",ref:U,style:{left:ze,top:_e},children:c==="prefix"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.prefix")}),jsxRuntime.jsx("div",{className:"drawui-muted-hint",children:drawuiCore.t("style.prefix.soon")})]}):S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t(h(S))}),jsxRuntime.jsxs("div",{className:"drawui-color-row",children:[S.hasTransparent&&jsxRuntime.jsx("button",{className:`drawui-color-swatch drawui-color-swatch-transparent${Ae(oe[S.key])?" active":""}`,onClick:()=>he(S.key,"transparent"),"aria-label":drawuiCore.t("style.none"),type:"button"}),(S.hasTransparent?Uo:Wo).map(l=>jsxRuntime.jsx("button",{className:`drawui-color-swatch${Qt(l,oe[S.key])?" active":""}`,style:{background:l},onClick:()=>he(S.key,l),"aria-label":l,type:"button"},l)),O.map(l=>jsxRuntime.jsx("button",{className:`drawui-color-swatch drawui-color-custom${Qt(l,oe[S.key])?" active":""}`,style:{background:l},onClick:()=>he(S.key,l),"aria-label":l,type:"button"},`custom-${l}`)),jsxRuntime.jsxs("span",{className:"drawui-color-swatch drawui-color-add","data-drawui-tip":drawuiCore.t("style.addColor"),children:["+",jsxRuntime.jsx("input",{ref:a,type:"color",defaultValue:"#3b82f6",className:"drawui-color-add-input","aria-label":drawuiCore.t("style.addColor")})]})]}),S.hasOpacity&&jsxRuntime.jsxs("div",{className:"drawui-opacity-row",children:[jsxRuntime.jsx("span",{className:"drawui-opacity-label",children:drawuiCore.t("style.opacity")}),jsxRuntime.jsx("input",{type:"range",min:0,max:100,value:Math.round(ge(S.key)*100),onChange:l=>B(S.key,Number(l.target.value)/100),className:"drawui-opacity-slider"}),jsxRuntime.jsxs("span",{className:"drawui-opacity-value",children:[Math.round(ge(S.key)*100),"%"]})]})]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(st,{connectionType:u??"straight",arrowHead:p??"end",dashed:!!s,onConnectionTypeChange:re,onArrowStyleChange:$})})})]})});var It=14,io=20,qo=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af"],Qo=[12,14,16,18,20,24];function so(n,e,o){let r=n,u=o,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 b=r.indexOf(":");return b===-1?{visibility:u,name:r,type:"",params:"",returnType:""}:{visibility:u,name:r.slice(0,b).replace(/^\s+|\s+$/g,""),type:r.slice(b+1).replace(/^\s+|\s+$/g,""),params:"",returnType:""}}let s=r.indexOf("(");if(s===-1){let b=r.lastIndexOf(":");return b===-1?{visibility:u,name:r,type:"",params:"",returnType:""}:{visibility:u,name:r.slice(0,b).replace(/^\s+|\s+$/g,""),type:"",params:"",returnType:r.slice(b+1).replace(/^\s+|\s+$/g,"")}}let i=r.slice(0,s).replace(/^\s+|\s+$/g,""),M=r.indexOf(")",s);if(M===-1)return {visibility:u,name:i,type:"",params:r.slice(s+1).replace(/^\s+|\s+$/g,""),returnType:""};let f=r.slice(s+1,M).replace(/^\s+|\s+$/g,""),c=r.slice(M+1).replace(/^\s+|\s+$/g,"");return c.startsWith(":")&&(c=c.slice(1).replace(/^\s+|\s+$/g,"")),{visibility:u,name:i,type:"",params:f,returnType:c}}function Jo(n,e){let o=`${e.visibility} `;return n==="attribute"?`${o}${e.name}: ${e.type??""}`:`${o}${e.name}(${e.params??""}): ${e.returnType??""}`}var co=react.memo(function({editor:e,umlClass:o,editing:r}){let[,u]=react.useState(0);q(),react.useEffect(()=>{if(!e)return;let m=e.subscribe(()=>u(I=>I+1));return ()=>{m();}},[e]);let[p,s]=react.useState(null),[i,M]=react.useState(false),f=react.useRef(null),c=react.useRef(null),b=react.useCallback((m,I)=>{f.current&&(clearTimeout(f.current),f.current=null),s({section:m,rowId:I}),M(false);},[]),P=react.useCallback(()=>{f.current&&clearTimeout(f.current),f.current=window.setTimeout(()=>{s(null),M(false);},150);},[]);if(!e||!o||r!==o.id)return null;let D=e.getCamera(),{id:v,x:U,y:x,width:A,height:O,className:me,methods:a}=o,w=o.type==="uml-interface",d=w?[]:o.attributes,j=A/2,_=O/2,z=drawuiCore.UML_HEADER_HEIGHT,G=drawuiCore.UML_LINE_HEIGHT,te=drawuiCore.UML_PADDING_X,V=drawuiCore.UML_PADDING_Y,ue=w?0:d.length>0?d.length*G+V*2:V*2,g=D.zoom,oe=(A-te*2)*g,ke=4*g,ge=D.pageToScreen({x:U-j+te,y:x}),he=D.pageToScreen({x:U,y:x-_+z/2}),B=m=>D.pageToScreen({x:U,y:m}).y,re=G*g,$=m=>x+(-_+z+V+G/2+m*G),be=m=>x+(-_+z+ue+V+G/2+m*G),Ce=x+(-_+z+ue),we=x+_,h={background:"#ffffff",borderWidth:1,borderStyle:"solid",borderColor:"transparent",outline:"none",padding:0,fontFamily:"sans-serif",boxSizing:"border-box"},S=(m,I)=>{let H=d.find(Q=>Q.id===m);if(!H)return;let K=so(I,"attribute",H.visibility);e.updateUmlClass(v,{attributes:d.map(Q=>Q.id===m?{...Q,...K}:Q)});},C=(m,I)=>{let H=a.find(X=>X.id===m);if(!H)return;let K=so(I,"method",H.visibility),Q=a.map(X=>X.id===m?{...X,...K}:X);w?e.updateUmlInterface(v,{methods:Q}):e.updateUmlClass(v,{methods:Q});},k=(m,I,H)=>{c.current={section:m,from:I},H.dataTransfer.effectAllowed="move",H.dataTransfer.setData("text/plain",`${m}:${I}`);},W=m=>{m.preventDefault(),m.dataTransfer.dropEffect="move";},F=(m,I,H)=>{H.preventDefault();let K=c.current;!K||K.section!==m||(m==="attribute"?e.reorderUmlAttribute(v,K.from,I):e.reorderUmlMethod(v,K.from,I),c.current=null);},ne=(m,I,H,K)=>{let Q=B(K),X=p?.section===m&&p.rowId===H.id,ze=(H.fontSize||drawuiCore.UML_FONT_SIZE)*g,_e=H.textColor||"#1f2937",l={position:"absolute",left:ge.x-It*g-ke,top:Q-re/2,width:It*g+ke+oe+io*g,height:re,display:"flex",alignItems:"center",gap:2,pointerEvents:"none",zIndex:53},L={...h,width:oe,height:re-2,fontSize:ze,color:_e,textDecoration:H.strikethrough?"line-through":"none",pointerEvents:"auto",...X?{borderColor:"var(--dw-primary)"}:{}},xe={width:It*g,height:re-2,cursor:"grab",color:"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",fontSize:12*g,lineHeight:1,opacity:X?1:.55,pointerEvents:"auto"},y={width:io*g,height:re-6,border:"none",background:"transparent",color:"#9ca3af",cursor:"pointer",borderRadius:3,fontSize:14*g,opacity:X?1:.35,pointerEvents:"auto"};return jsxRuntime.jsxs("div",{style:l,onDragOver:W,onDrop:R=>F(m,I,R),children:[jsxRuntime.jsx("span",{style:xe,draggable:true,onDragStart:R=>k(m,I,R),"data-drawui-tip":drawuiCore.t("uml.drag"),children:"\u22EE\u22EE"}),jsxRuntime.jsx("input",{style:L,value:Jo(m,H),onChange:R=>m==="attribute"?S(H.id,R.target.value):C(H.id,R.target.value),onFocus:()=>b(m,H.id),onBlur:P,spellCheck:false}),jsxRuntime.jsx("button",{style:y,onMouseDown:R=>R.preventDefault(),onClick:()=>{m==="attribute"?e.removeUmlAttribute(v,H.id):e.removeUmlMethod(v,H.id);},"data-drawui-tip":drawuiCore.t("uml.delete"),children:"\xD7"})]},H.id)},Me=(m,I,H)=>{let K=B(I),Q=m==="attribute";return jsxRuntime.jsxs("button",{onMouseDown:X=>X.preventDefault(),onClick:()=>Q?e.addUmlAttribute(v):e.addUmlMethod(v),className:"drawui-uml-add-row",style:{position:"absolute",left:ge.x,top:K-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},"data-drawui-tip":H,children:[jsxRuntime.jsx("span",{style:{fontSize:13*g,lineHeight:1},children:"+"}),jsxRuntime.jsx("span",{children:H})]},`add-${m}`)},Oe=()=>{if(!p||p.section==="className")return null;let m=p.section,I=p.rowId,K=(m==="attribute"?d:a).find(T=>T.id===I);if(!K)return null;let Q=224*g,X=30*g,ze=D.pageToScreen({x:U,y:x}).x,_e=D.pageToScreen({x:U,y:x-_}).y,l=20*g,L=_e-X-l,xe=ze-Q/2,y=L+X,R=K.textColor||"#1f2937",He=K.fontSize||drawuiCore.UML_FONT_SIZE,Le=!!K.strikethrough;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:ze-.5,top:y,width:1,height:l,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),jsxRuntime.jsxs("div",{className:"drawui-uml-toolbar",style:{position:"absolute",left:xe,top:L,width:Q,height:X,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:T=>T.preventDefault(),children:[jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{onClick:()=>M(T=>!T),className:"drawui-uml-toolbar-btn","data-drawui-tip":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:R,fontSize:13*g,textDecoration:Le?"line-through":"none"},children:"A"}),jsxRuntime.jsx("span",{style:{width:10*g,height:2*g,background:R,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(v,m,K.id,{textColor:null}),M(false);},style:{width:14,height:14,border:"1px solid #e5e7eb",background:"transparent",cursor:"pointer",borderRadius:2},"data-drawui-tip":drawuiCore.t("uml.defaultColor")}),qo.map(T=>jsxRuntime.jsx("button",{onClick:()=>{e.updateUmlRowStyle(v,m,K.id,{textColor:T}),M(false);},style:{width:14,height:14,border:"none",background:T,cursor:"pointer",borderRadius:2},"data-drawui-tip":T},T))]})]}),jsxRuntime.jsx("select",{value:He,onChange:T=>e.updateUmlRowStyle(v,m,K.id,{fontSize:Number(T.target.value)}),style:{border:"1px solid #e5e7eb",borderRadius:3,padding:`0 ${2*g}px`,fontSize:12*g,height:20*g,background:"#ffffff"},"data-drawui-tip":drawuiCore.t("uml.fontSize"),children:Qo.map(T=>jsxRuntime.jsx("option",{value:T,children:T},T))}),jsxRuntime.jsx("button",{onClick:()=>e.updateUmlRowStyle(v,m,K.id,{strikethrough:!Le}),className:"drawui-uml-toolbar-btn","data-drawui-tip":drawuiCore.t("uml.strikethrough"),style:{border:"none",background:Le?"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:()=>{m==="attribute"?e.removeUmlAttribute(v,K.id):e.removeUmlMethod(v,K.id),s(null);},className:"drawui-uml-toolbar-btn","data-drawui-tip":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"})]})})]})]})},ye=D.pageToScreen({x:U-j,y:x}).x,We=D.pageToScreen({x:U,y:x-_}).y,Ze=A*g,je=O*g;return jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:ye+1,top:We+1,width:Math.max(0,Ze-2),height:Math.max(0,je-2),background:"#ffffff",pointerEvents:"none",zIndex:51}}),jsxRuntime.jsx("input",{style:{...h,position:"absolute",left:he.x-oe/2,top:he.y-z*g/2+2,width:oe,height:z*g-4,textAlign:"center",fontWeight:700,fontSize:(o.fontSize||drawuiCore.UML_FONT_SIZE)*g,color:o.textColor||"#1f2937",pointerEvents:"auto",zIndex:52,...p?.section==="className"?{borderColor:"var(--dw-primary)"}:{}},value:me,onChange:m=>w?e.updateUmlInterface(v,{className:m.target.value}):e.updateUmlClass(v,{className:m.target.value}),onFocus:()=>b("className",""),onBlur:P,spellCheck:false}),!w&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[d.map((m,I)=>ne("attribute",I,m,$(I))),Me("attribute",Ce,"\u5C5E\u6027")]}),a.map((m,I)=>ne("method",I,m,be(I))),Me("method",we,drawuiCore.t("uml.method")),Oe()]})});var ho=react.memo(function({editor:e,panelOpen:o,onOpenPanel:r}){let[,u]=react.useState(0);q(),react.useEffect(()=>{if(!e)return;let A=e.subscribe(()=>u(O=>O+1));return ()=>{A();}},[e]);let p=react.useRef(false),s=react.useRef(false);if(!e)return null;let i=e.getMindMapEditingShapeId();if(!i||o)return null;let M=e.getMindMapSelectedNode();if(!M||M.shapeId!==i)return null;let f=e.getMindMapNode(i,M.nodeId),c=e.getMindMapNodeScreenRect(i,M.nodeId);if(!f||!c)return null;let b=e.getCamera().getZoom(),P=drawuiCore.MINDMAP_FONT_SIZE*b,D=Math.max(100,c.width+24),v=c.height+8,U={position:"absolute",left:c.x+c.width/2,top:c.y-4,transform:"translateX(-50%)",width:D,height:v,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 ${(f.icon?24:12)*b}px`,fontFamily:"sans-serif",fontSize:P,color:"#1f2937",boxSizing:"border-box",pointerEvents:"auto",zIndex:55},x={position:"absolute",left:c.x+c.width+12,top:c.y+c.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:U,value:f.text,spellCheck:false,onChange:A=>{let O=!p.current;p.current=true,e.updateMindMapNode(i,M.nodeId,{text:A.target.value},O);},onBlur:()=>{if(s.current){s.current=false;return}e.exitMindMapEdit();},onKeyDown:A=>{A.key==="Enter"?A.target.blur():A.key==="Escape"&&e.exitMindMapEdit();}}),jsxRuntime.jsx("button",{style:x,"data-drawui-tip":drawuiCore.t("mindmap.more"),onMouseDown:A=>{A.preventDefault(),s.current=true,setTimeout(()=>{s.current=false;},300);},onClick:r,children:"\u22EF"})]})});var yo=[...drawuiCore.MINDMAP_COLORS,"#1f2937","#9ca3af"],fo=["\u{1F4A1}","\u2B50","\u{1F525}","\u{1F4CC}","\u2705","\u2757","\u26A0\uFE0F","\u{1F3F7}\uFE0F"],hn={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"},Ht={fontSize:11,color:"#6b7280",marginBottom:4,display:"block"},pt={display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},ht={border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:5,padding:"3px 8px",fontSize:12,color:"#374151",cursor:"pointer",lineHeight:1.5},Kt={width:"100%",border:"1px solid #e5e7eb",borderRadius:5,padding:"4px 8px",fontSize:12,outline:"none",boxSizing:"border-box",background:"#ffffff",color:"#1f2937"},mo=react.memo(function({editor:e,mindMap:o}){let[,r]=react.useState(0);q(),react.useEffect(()=>{if(!e)return;let a=e.subscribe(()=>r(w=>w+1));return ()=>{a();}},[e]);let u=react.useRef(null);if(!e||!o||e.getMindMapEditingShapeId()!==o.id)return null;let p=e.getMindMapSelectedNode();if(!p||p.shapeId!==o.id)return null;let s=a=>{if(a.id===p.nodeId)return a;for(let w of a.children??[]){let d=s(w);if(d)return d}return null},i=s(o.root);if(!i)return null;let M=e.getCamera(),c=drawuiCore.layoutMindMap(o.root).positions.get(i.id);if(!c)return null;let b=M.zoom,P=M.pageToScreen({x:o.x+c.x,y:o.y+c.y}),D=P.x+c.width*b/2+14,v=P.y-80,x=Math.max(8,Math.min(D,(window.innerWidth||1024)-232-8)),A=Math.max(8,Math.min(v,(window.innerHeight||768)-320)),O=a=>{e.updateMindMapNode(o.id,i.id,a);},me=!!i.id&&i.id!==o.root.id;return jsxRuntime.jsxs("div",{ref:u,style:{...hn,left:x,top:A},onMouseDown:a=>a.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(),"data-drawui-tip":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:{...Kt,marginBottom:8},value:i.text,onChange:a=>O({text:a.target.value}),spellCheck:false}),jsxRuntime.jsxs("div",{style:{...pt,marginBottom:10},children:[jsxRuntime.jsxs("button",{style:ht,onClick:()=>e.addMindMapChild(o.id,i.id),children:["+ ",drawuiCore.t("mindmap.addChild")]}),me&&jsxRuntime.jsxs("button",{style:ht,onClick:()=>e.addMindMapSibling(o.id,i.id),children:["+ ",drawuiCore.t("mindmap.addSibling")]}),!!i.children?.length&&jsxRuntime.jsx("button",{style:ht,onClick:()=>e.toggleMindMapCollapse(o.id,i.id),children:i.collapsed?drawuiCore.t("mindmap.expand"):drawuiCore.t("mindmap.collapse")}),jsxRuntime.jsx("button",{style:{...ht,color:"#ef4444",borderColor:"#fecaca",marginLeft:"auto"},onClick:()=>e.deleteMindMapNode(o.id,i.id),children:drawuiCore.t("mindmap.deleteNode")})]}),jsxRuntime.jsx("span",{style:Ht,children:drawuiCore.t("mindmap.color")}),jsxRuntime.jsxs("div",{style:{...pt,marginBottom:10},children:[jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.levelColor"),onClick:()=>O({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}}),yo.map(a=>jsxRuntime.jsx("button",{"data-drawui-tip":a,onClick:()=>O({color:a}),style:{width:18,height:18,borderRadius:4,border:i.color===a?"2px solid #111827":"1px solid #d1d5db",background:a,cursor:"pointer",flexShrink:0}},a))]}),jsxRuntime.jsx("span",{style:Ht,children:drawuiCore.t("mindmap.icon")}),jsxRuntime.jsxs("div",{style:{...pt,marginBottom:10},children:[jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.noIcon"),onClick:()=>O({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"}),fo.map(a=>jsxRuntime.jsx("button",{onClick:()=>O({icon:a}),style:{width:22,height:22,borderRadius:4,border:i.icon===a?"2px solid #111827":"1px solid #d1d5db",background:"#f9fafb",cursor:"pointer",fontSize:13,lineHeight:1},children:a},a)),jsxRuntime.jsx("input",{placeholder:"\u270F\uFE0F",defaultValue:i.icon&&!fo.includes(i.icon)?i.icon:"",onKeyDown:a=>{if(a.key==="Enter"){let w=a.target.value.trim();O({icon:w||void 0});}},onBlur:a=>{let w=a.target.value.trim();w!==i.icon&&O({icon:w||void 0});},style:{...Kt,width:56,padding:"2px 4px",textAlign:"center"}})]}),jsxRuntime.jsx("span",{style:Ht,children:drawuiCore.t("mindmap.note")}),jsxRuntime.jsx("input",{style:{...Kt,marginBottom:6},value:i.note??"",placeholder:drawuiCore.t("mindmap.notePlaceholder"),onChange:a=>O({note:a.target.value||void 0}),spellCheck:false}),!!i.note&&jsxRuntime.jsxs("div",{style:{...pt,marginTop:4},children:[jsxRuntime.jsx("span",{style:{fontSize:11,color:"#6b7280"},children:drawuiCore.t("mindmap.noteColor")}),jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.noteColorDefault"),onClick:()=>O({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"}}),yo.map(a=>jsxRuntime.jsx("button",{onClick:()=>O({noteColor:a}),style:{width:16,height:16,borderRadius:3,border:i.noteColor===a?"2px solid #111827":"1px solid #d1d5db",background:a,cursor:"pointer"}},a))]})]})});var At=220,Ot=140,bn="#fafafa";function wn(n,e){let o=Math.min(n.x,e.x),r=Math.min(n.y,e.y),u=Math.max(n.x+n.width,e.x+e.width),p=Math.max(n.y+n.height,e.y+e.height);return {x:o,y:r,width:u-o,height:p-r}}function xn(n){return {x:n.x+n.width/2,y:n.y+n.height/2}}function vn(){return {x:0,y:0,width:0,height:0}}function kn(n){let e=1/0,o=1/0,r=-1/0,u=-1/0,p=false;for(let s of n){let i=Bt(s);i&&(p=true,i.x<e&&(e=i.x),i.y<o&&(o=i.y),i.x+i.width>r&&(r=i.x+i.width),i.y+i.height>u&&(u=i.y+i.height));}return p?{x:e,y:o,width:r-e,height:u-o}:null}function Bt(n){switch(n.type){case "rectangle":case "rounded-rectangle":case "ellipse":case "diamond":case "triangle":case "hexagon":case "parallelogram":case "trapezoid":case "pentagon":case "octagon":case "star":case "cylinder":case "cloud":case "heart":case "block-arrow-right":case "block-arrow-left":case "block-arrow-up":case "block-arrow-down":case "block-arrow-double":case "right-triangle":case "cross":case "speech-rect":case "speech-round":case "cube":case "sector":case "delay":case "predefined-process":case "document":case "stadium":case "class-catalog":case "chevron":case "brace-left":case "brace-right":case "envelope":case "checkbox":case "triangular-pyramid":case "quadrangular-pyramid":case "cuboid":case "sphere":case "ellipsoid":case "pie":case "hollow-pie":case "uml-class":case "uml-interface":case "mind-map":case "text":return {x:n.x-n.width/2,y:n.y-n.height/2,width:n.width,height:n.height};case "circle":return {x:n.x-n.radius,y:n.y-n.radius,width:n.radius*2,height:n.radius*2};case "line":case "arrow":{let e=n.points;if(!e||e.length===0)return null;let o=1/0,r=1/0,u=-1/0,p=-1/0;for(let s of e)s.x<o&&(o=s.x),s.y<r&&(r=s.y),s.x>u&&(u=s.x),s.y>p&&(p=s.y);return {x:o,y:r,width:u-o,height:p-r}}case "draw":{let e=n,o=e.width,r=e.height;if(typeof o=="number"&&typeof r=="number")return {x:e.x-o/2,y:e.y-r/2,width:o,height:r};let u=e.points;if(!u||u.length===0)return null;let p=1/0,s=1/0,i=-1/0,M=-1/0;for(let f of u){let c=f.x+e.x,b=f.y+e.y;c<p&&(p=c),b<s&&(s=b),c>i&&(i=c),b>M&&(M=b);}return {x:p,y:s,width:i-p,height:M-s}}default:return null}}function Mn(n){let e=n.getCamera(),o=e.screenToPage({x:0,y:0}),r=e.screenToPage({x:window.innerWidth,y:window.innerHeight});return {x:o.x,y:o.y,width:r.x-o.x,height:r.y-o.y}}function Sn(n,e,o){if(n.width<=0||n.height<=0)return {x:n.x-e/2,y:n.y-o/2,width:e,height:o};let r=e/o,u=n.width,p=u/r;p<n.height&&(p=n.height,u=p*r);let s=xn(n);return {x:s.x-u/2,y:s.y-p/2,width:u,height:p}}function zt(n,e,o,r){let u=(n-o.left)/o.width,p=(e-o.top)/o.height;return {x:r.x+u*r.width,y:r.y+p*r.height}}var wo=react.memo(function({editor:e}){let o=react.useRef(null),r=react.useRef(null),[u,p]=react.useState(false),[s,i]=react.useState(100),[M,f]=react.useState(false),[c,b]=react.useState(false);q();let P=react.useRef(null),D=react.useRef(null);react.useLayoutEffect(()=>{let a=o.current,w=r.current;if(!a||!w)return;let d=window.devicePixelRatio||1;a.width=Math.round(At*d),a.height=Math.round(Ot*d),a.style.width=`${At}px`,a.style.height=`${Ot}px`;},[u]);let v=react.useCallback(()=>{let a=o.current,w=r.current;if(!a||!w||!e)return;let d=a.getContext("2d");if(!d)return;let j=At,_=Ot,z=a.width,G=a.height,te=e.getShapes(),V=new Set(e.getSelectedIds()),ue=drawuiCore.getTheme(),g=drawuiCore.hexToRgba(ue.text,.16),oe=ue.primary,ke=drawuiCore.hexToRgba(ue.primary,.18),ge=drawuiCore.hexToRgba(ue.primary,.85),he=kn(te),B=Mn(e),re=he?wn(he,B):B.width>0?B:vn(),$=Sn(re,j,_);D.current=$;let be=z/$.width,Ce=G/$.height,we=j/$.width;d.setTransform(1,0,0,1,0,0),d.fillStyle=bn,d.fillRect(0,0,z,G),d.setTransform(be,0,0,Ce,-be*$.x,-Ce*$.y),d.fillStyle=g;for(let C of te){let k=Bt(C);k&&d.fillRect(k.x,k.y,k.width,k.height);}d.fillStyle=oe;for(let C of te){if(!V.has(C.id))continue;let k=Bt(C);k&&d.fillRect(k.x,k.y,k.width,k.height);}d.fillStyle=ke,d.fillRect(B.x,B.y,B.width,B.height);let h=1.5/we;d.strokeStyle=ge,d.lineWidth=h,d.lineJoin="round";let S=Math.min(B.width/6,B.height/6,6/we);if(d.beginPath(),S*we<1)d.rect(B.x,B.y,B.width,B.height);else {let C=B.x,k=B.y,W=B.width,F=B.height,ne=Math.min(S,W/2,F/2);d.moveTo(C+ne,k),d.lineTo(C+W-ne,k),d.quadraticCurveTo(C+W,k,C+W,k+ne),d.lineTo(C+W,k+F-ne),d.quadraticCurveTo(C+W,k+F,C+W-ne,k+F),d.lineTo(C+ne,k+F),d.quadraticCurveTo(C,k+F,C,k+F-ne),d.lineTo(C,k+ne),d.quadraticCurveTo(C,k,C+ne,k),d.closePath();}d.stroke(),d.setTransform(1,0,0,1,0,0);},[e]);react.useEffect(()=>{if(!e||u)return;v();let a=e.subscribe(v),w=drawuiCore.subscribeTheme(v),d=()=>v();return window.addEventListener("resize",d),()=>{a(),w(),window.removeEventListener("resize",d);}},[e,u,v]),react.useEffect(()=>{if(!e)return;let a=()=>{let d=e.getCamera().getZoom();i(Math.round(d*100));};a();let w=e.subscribe(a);return ()=>{w();}},[e]);let U=react.useCallback((a,w)=>{if(!e)return;let d=e.getCamera(),j=d.getZoom(),_=window.innerWidth/2,z=window.innerHeight/2,G=d;G.x=_-a*j,G.y=z-w*j,e.requestRender();},[e]),x=a=>{if(!e||!r.current||a.button!==0)return;let w=r.current.getBoundingClientRect(),d=D.current;if(!d)return;let j=zt(a.clientX,a.clientY,w,d);P.current={pointerId:a.pointerId,rect:{left:w.left,top:w.top,width:w.width,height:w.height},canvasBox:d},a.currentTarget.setPointerCapture(a.pointerId),b(true),U(j.x,j.y);},A=a=>{if(!c||!e||!P.current||!r.current)return;let w=P.current,d=zt(a.clientX,a.clientY,w.rect,w.canvasBox);U(d.x,d.y);},O=a=>{if(c){b(false),P.current=null;try{a.currentTarget.releasePointerCapture(a.pointerId);}catch{}}},me=a=>{if(!e||!r.current)return;let w=D.current;if(!w)return;let d=r.current.getBoundingClientRect(),j=zt(a.clientX,a.clientY,d,w);U(j.x,j.y);};return jsxRuntime.jsxs("div",{className:`drawui-minimap ${u?"collapsed":""}`,children:[jsxRuntime.jsx("button",{className:"drawui-minimap-toggle",onClick:()=>p(a=>!a),"data-drawui-tip":u?drawuiCore.t("minimap.expand"):drawuiCore.t("minimap.collapse"),"data-drawui-tip-pos":"top","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:[s,"%"]})]}),jsxRuntime.jsx("div",{ref:r,className:"drawui-minimap-canvas-wrap",style:{cursor:c?"grabbing":M?"pointer":"default"},onPointerEnter:()=>f(true),onPointerLeave:()=>f(false),children:jsxRuntime.jsx("canvas",{ref:o,className:"drawui-minimap-canvas",onPointerDown:x,onPointerMove:A,onPointerUp:O,onPointerCancel:O,onDoubleClick:me})})]})]})});var de=n=>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:n}),Tn=[{type:"rectangle",labelKey:"shape.rectangle",glyph:de(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:de(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:de(jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:de(jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:de(jsxRuntime.jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:de(jsxRuntime.jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:de(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:de(jsxRuntime.jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:de(jsxRuntime.jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:de(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:de(jsxRuntime.jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:de(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:de(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:de(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:de(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 xo({editor:n,x:e,y:o,context:r,existingArrowId:u,defaultShapeType:p,onClose:s}){let i=react.useRef(null);q();let M=f=>{n?.createGeneratedConnection(r,{type:f,existingArrowId:u}),s();};return react.useEffect(()=>{let f=P=>{i.current&&!i.current.contains(P.target)&&s();},c=P=>{P.key==="Escape"&&(P.preventDefault(),s());},b=setTimeout(()=>{window.addEventListener("pointerdown",f,true),window.addEventListener("keydown",c,true);},0);return ()=>{clearTimeout(b),window.removeEventListener("pointerdown",f,true),window.removeEventListener("keydown",c,true);}},[s]),jsxRuntime.jsxs("div",{className:"drawui-gen-menu",ref:i,style:{left:e,top:o},children:[jsxRuntime.jsx("div",{className:"drawui-gen-menu-label",children:drawuiCore.t("menu.title")}),jsxRuntime.jsx("div",{className:"drawui-gen-shape-grid",children:Tn.map(f=>jsxRuntime.jsxs("button",{className:`drawui-gen-shape-btn${f.type===p?" drawui-gen-shape-active":""}`,onClick:()=>M(f.type),"data-drawui-tip":drawuiCore.t(f.labelKey),children:[f.glyph,jsxRuntime.jsx("span",{className:"drawui-gen-shape-label",children:drawuiCore.t(f.labelKey)})]},f.type))}),jsxRuntime.jsx("div",{className:"drawui-gen-menu-hint",children:drawuiCore.t("menu.cancel")})]})}var In={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",cylinder:"tool.cylinder",cloud:"tool.cloud",heart:"tool.heart","block-arrow-right":"tool.block-arrow-right","block-arrow-left":"tool.block-arrow-left","block-arrow-up":"tool.block-arrow-up","block-arrow-down":"tool.block-arrow-down","block-arrow-double":"tool.block-arrow-double","right-triangle":"tool.right-triangle",cross:"tool.cross","speech-rect":"tool.speech-rect","speech-round":"tool.speech-round",cube:"tool.cube",sector:"tool.sector",delay:"tool.delay","predefined-process":"tool.predefined-process",document:"tool.document",stadium:"tool.stadium","class-catalog":"tool.class-catalog",chevron:"tool.chevron","brace-left":"tool.brace-left","brace-right":"tool.brace-right",envelope:"tool.envelope",checkbox:"tool.checkbox","triangular-pyramid":"tool.triangular-pyramid","quadrangular-pyramid":"tool.quadrangular-pyramid",cuboid:"tool.cuboid",sphere:"tool.sphere",ellipsoid:"tool.ellipsoid",pie:"tool.pie","hollow-pie":"tool.hollow-pie","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 Hn({initialTool:n="select",className:e="",themeColor:o,language:r="zh-CN",data:u,onChange:p,onReady:s}){let i=react.useRef(null),M=react.useRef(null),f=react.useRef(null),[c,b]=react.useState(null);q();let[P,D]=react.useState(n),[v,U]=react.useState(false),[x,A]=react.useState(0),[O,me]=react.useState(false),[a,w]=react.useState("straight"),[d,j]=react.useState("end"),[_,z]=react.useState(false),[G,te]=react.useState(void 0),[V,ue]=react.useState(100),[g,oe]=react.useState(null),[ke,ge]=react.useState(null),[he,B]=react.useState(false),[re,$]=react.useState(false),[be,Ce]=react.useState(null),[we,h]=react.useState(null),[S,C]=react.useState(false),[k,W]=react.useState(null),[F,ne]=react.useState(null),Me=react.useRef(null),Oe=react.useRef(0),ye=react.useRef(null),We=react.useRef(p);We.current=p;let Ze=react.useRef(s);Ze.current=s,react.useEffect(()=>{if(!i.current)return;let y=new drawuiCore.Editor(i.current,{theme:o?{primary:o,editBorder:o,selection:{outline:o,handleStroke:o,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(o,.1),shadow:o}}:void 0,language:r,shapes:u,persist:!u});f.current=y,b(y),window.__drawuiEditor=y,y.setHighlighterColor(rt()),Ze.current?.(y),n&&y.setActiveTool(n);let R=y.subscribe(()=>{D(y.getActiveTool());let T=y.getSelectedIds();A(T.length);let pe=y.getShapes().filter(Ne=>T.includes(Ne.id)&&(Ne.type==="line"||Ne.type==="arrow"));if(me(pe.length>0),pe.length>0&&pe[0].connectionType?w(pe[0].connectionType):pe.length>0&&w("straight"),pe.length>0){let Ne=pe.find(xt=>xt.type==="arrow");Ne&&(j(Ne.arrowHead??"end"),z(Ne.dashed??false));}ue(Math.round(y.getCamera().getZoom()*100)),te(y.getArrowStyle()),B(y.canUndo()),$(y.canRedo());let Te=y.getSelectedUml();Ce(Te),Te||W(null);let nt=y.getSelectedMindMap();h(nt),y.getMindMapEditingShapeId()||C(false),We.current?.(y.getData());}),He=y.subscribeNotifications(T=>{ge(T),Me.current&&clearTimeout(Me.current),Me.current=setTimeout(()=>ge(null),2e3);}),Le=y.subscribeUi(T=>{T.kind==="shapeTypeMenu"&&ne({x:T.screenX,y:T.screenY,context:T.context,existingArrowId:T.existingArrowId,defaultShapeType:T.defaultShapeType});});return ()=>{R(),He(),Le(),Me.current&&clearTimeout(Me.current),cancelAnimationFrame(Oe.current),y.dispose();}},[n]),react.useEffect(()=>{if(!o)return;let y=M.current;y&&(y.style.setProperty("--dw-primary",o),y.style.setProperty("--dw-primary-hover",drawuiCore.shadeColor(o,-0.12)),y.style.setProperty("--dw-primary-weak",drawuiCore.hexToRgba(o,.1)),y.style.setProperty("--dw-primary-contrast","#ffffff"),y.style.setProperty("--dw-shadow-primary",`0 2px 8px ${drawuiCore.hexToRgba(o,.3)}`)),f.current?.setTheme({primary:o,editBorder:o,selection:{outline:o,handleStroke:o,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(o,.1),shadow:o}});},[o]),react.useEffect(()=>{drawuiCore.setLanguage(r),f.current?.setLanguage(r);},[r]);let je=react.useCallback(y=>{f.current?.setActiveTool(y);},[]),m=react.useCallback(()=>{f.current?.zoomIn();},[]),I=react.useCallback(()=>{f.current?.zoomOut();},[]),H=react.useCallback(()=>{f.current?.resetZoom();},[]),K=react.useCallback(()=>{let y=!v;U(y),f.current?.setShowGrid(y);},[v]),Q=react.useCallback(()=>{f.current?.undo();},[]),X=react.useCallback(()=>{f.current?.redo();},[]),ze=react.useCallback(y=>{f.current?.downloadImage("drawui",y,{background:"#ffffff"});},[]),_e=react.useCallback(y=>{let R=f.current,He=i.current;if(!R||!He)return;if(R.isPointerDown()){ye.current!==null&&(ye.current=null,oe(null));return}let Le=y.clientX,T=y.clientY;cancelAnimationFrame(Oe.current),Oe.current=requestAnimationFrame(()=>{let Ve=He.getBoundingClientRect(),pe=Le-Ve.left,Te=T-Ve.top,nt=pe+12,Ne=Te+12,xt=R.getSelectedUml()?.id,Fe=R.getUmlRowAtScreenPoint({x:pe,y:Te});if(Fe&&Fe.shape.id!==xt&&Fe.text){ye.current!==Fe.text&&(ye.current=Fe.text,oe({text:Fe.text,x:nt,y:Ne}));return}let qe=R.getShapeAtScreenPoint({x:pe,y:Te});qe&&qe.text?ye.current!==qe.text&&(ye.current=qe.text,oe({text:qe.text,x:nt,y:Ne})):ye.current!==null&&(ye.current=null,oe(null));});},[]),l=react.useCallback(()=>{oe(null);},[]),L=react.useCallback(y=>{let R=f.current,He=i.current;if(!R||!He)return;let Le=He.getBoundingClientRect(),T=y.clientX-Le.left,Ve=y.clientY-Le.top,pe=R.getUmlRowAtScreenPoint({x:T,y:Ve});if(pe){W(pe.shape.id);return}let Te=R.getMindMapNodeAtScreenPoint({x:T,y:Ve});Te&&R.beginMindMapEdit(Te.shapeId,Te.nodeId);},[]),xe=react.useCallback(()=>{ne(null);},[]);return jsxRuntime.jsxs("div",{ref:M,className:`drawui-canvas-board ${e}`,children:[jsxRuntime.jsx("canvas",{ref:i,className:"drawui-canvas",onMouseMove:_e,onMouseLeave:l,onDoubleClick:L}),g&&jsxRuntime.jsx("div",{className:"drawui-tooltip",style:{left:g.x,top:g.y},children:g.text}),jsxRuntime.jsx(Ct,{activeTool:P,onToolChange:je,showGrid:v,onToggleGrid:K,canUndo:he,canRedo:re,onUndo:Q,onRedo:X,onExport:ze,onHighlighterColorChange:y=>f.current?.setHighlighterColor(y),arrowStyle:G,onArrowStyleChange:y=>f.current?.setArrowStyle(y)}),jsxRuntime.jsx(Tt,{onZoomIn:m,onZoomOut:I,onReset:H,zoomLevel:V}),jsxRuntime.jsx(no,{editor:c,selectedCount:x,hasLineSelection:O,currentConnectionType:a,currentArrowHead:d,currentDashed:_}),jsxRuntime.jsx(co,{editor:c,umlClass:be,editing:k}),jsxRuntime.jsx(ho,{editor:c,panelOpen:S,onOpenPanel:()=>C(true)}),S&&jsxRuntime.jsx(mo,{editor:c,mindMap:we}),jsxRuntime.jsx(wo,{editor:c}),F&&jsxRuntime.jsx(xo,{editor:c,x:F.x,y:F.y,context:F.context,existingArrowId:F.existingArrowId,defaultShapeType:F.defaultShapeType,onClose:xe}),jsxRuntime.jsxs("div",{className:"drawui-status-bar",children:[jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:drawuiCore.t(In[P])})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:x===0?drawuiCore.t("status.none"):drawuiCore.t("status.selected",{n:x})})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsxs("span",{children:[V,"%"]})})]}),ke&&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"})}),ke]})]})}exports.CanvasBoard=Hn;exports.Toolbar=Ct;exports.ZoomControl=Tt;
|
|
1
|
+
'use strict';var react=require('react'),drawuiCore=require('drawui-core'),jsxRuntime=require('react/jsx-runtime');function G(){let[o,e]=react.useState(drawuiCore.getLanguage());return react.useEffect(()=>drawuiCore.subscribeLanguage(()=>e(drawuiCore.getLanguage())),[]),o}var no=["#ffeb3b","#22c55e","#3b82f6","#ec4899","#8b5cf6","#f97316"],ro="drawui:highlighterColor";function ht(){if(typeof window>"u")return drawuiCore.DEFAULT_HIGHLIGHTER_COLOR;try{let o=window.localStorage.getItem(ro);return o&&/^#[0-9a-fA-F]{6}$/.test(o)?o.toLowerCase():drawuiCore.DEFAULT_HIGHLIGHTER_COLOR}catch{return drawuiCore.DEFAULT_HIGHLIGHTER_COLOR}}function ao(o){if(!(typeof window>"u"))try{window.localStorage.setItem(ro,o);}catch{}}var so="drawui:stickyNoteColor";function yt(){if(typeof window>"u")return drawuiCore.STICKY_NOTE_DEFAULT_COLOR;try{let o=window.localStorage.getItem(so);return o&&/^#[0-9a-fA-F]{6}$/.test(o)?o.toLowerCase():drawuiCore.STICKY_NOTE_DEFAULT_COLOR}catch{return drawuiCore.STICKY_NOTE_DEFAULT_COLOR}}function lo(o){if(!(typeof window>"u"))try{window.localStorage.setItem(so,o);}catch{}}function Jo({icon:o,size:e=24,ink:n=drawuiCore.ICON_DEFAULT_INK}){return jsxRuntime.jsxs("svg",{viewBox:`0 0 ${drawuiCore.ICON_GRID} ${drawuiCore.ICON_GRID}`,width:e,height:e,fill:"none","aria-hidden":"true",children:[o.disc&&jsxRuntime.jsx("circle",{cx:drawuiCore.ICON_GRID/2,cy:drawuiCore.ICON_GRID/2,r:drawuiCore.ICON_GRID/2-1,fill:o.disc}),o.layers.map((r,h)=>{let d=r.fill??"ink",s=r.stroke??"ink";return jsxRuntime.jsx("path",{d:r.d,fill:d==="none"?"none":d==="ink"?n:d,...s==="none"?{}:{stroke:s==="ink"?n:s,strokeWidth:r.w??1.8,strokeLinecap:"round",strokeLinejoin:"round"}},h)}),o.label&&jsxRuntime.jsx("text",{x:drawuiCore.ICON_GRID/2,y:drawuiCore.ICON_GRID/2+.5,textAnchor:"middle",dominantBaseline:"central",fontFamily:"sans-serif",fontSize:o.label.size??13,fill:o.label.color,children:o.label.text})]})}var yo="drawui:recentIcons",fo=12;function At(o,e){let n=/^#?([0-9a-f]{6})$/i.exec(o.trim());if(!n)return o;let r=parseInt(n[1],16);return `rgba(${r>>16&255}, ${r>>8&255}, ${r&255}, ${e})`}function Qo(){if(typeof window>"u")return [];try{let o=JSON.parse(window.localStorage.getItem(yo)||"[]");return Array.isArray(o)?o.filter(e=>typeof e=="string").slice(0,fo):[]}catch{return []}}function en(o){if(!(typeof window>"u"))try{window.localStorage.setItem(yo,JSON.stringify(o));}catch{}}var ho=o=>({"--dw-icon-cat":o,"--dw-icon-cat-soft":At(o,.12)}),mo=react.memo(function({onPick:e,onClose:n}){G();let[r,h]=react.useState(""),[d,s]=react.useState(drawuiCore.ICON_CATEGORIES[0].id),[l,S]=react.useState(Qo),f=react.useRef(null),u=react.useRef(null);react.useEffect(()=>{u.current?.focus();},[]),react.useEffect(()=>{let p=L=>{let se=f.current;se&&(se.contains(L.target)||L.target?.closest?.("[data-icon-toggle]")||n());},A=L=>{L.key==="Escape"&&(L.stopPropagation(),n());};return window.addEventListener("pointerdown",p),window.addEventListener("keydown",A),()=>{window.removeEventListener("pointerdown",p),window.removeEventListener("keydown",A);}},[n]);let w=react.useMemo(()=>l.map(p=>drawuiCore.getIcon(p)).filter(p=>!!p),[l]),I=react.useMemo(()=>r.trim()?drawuiCore.searchIcons(r):d==="recent"?w:drawuiCore.iconsByCategory(d),[r,d,w]),z=d==="recent"?drawuiCore.ICON_CATEGORY_INK.status:drawuiCore.ICON_CATEGORY_INK[d]??drawuiCore.ICON_DEFAULT_INK,C=r.trim()?drawuiCore.t("icon.search"):d==="recent"?drawuiCore.t("icon.recent"):drawuiCore.t(drawuiCore.ICON_CATEGORIES.find(p=>p.id===d)?.labelKey??"icon.search"),B=p=>{e(p),S(A=>{let L=[p.id,...A.filter(se=>se!==p.id)].slice(0,fo);return en(L),L});};return jsxRuntime.jsxs("div",{className:"drawui-icon-panel",ref:f,style:{"--dw-icon-accent":z,"--dw-icon-soft":At(z,.08),"--dw-icon-ring":At(z,.22)},children:[jsxRuntime.jsxs("label",{className:"drawui-icon-search",children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[jsxRuntime.jsx("circle",{cx:"10.5",cy:"10.5",r:"6.5"}),jsxRuntime.jsx("path",{d:"M15.4 15.4L20 20"})]}),jsxRuntime.jsx("input",{ref:u,value:r,onChange:p=>h(p.target.value),onKeyDown:p=>{p.key==="Enter"&&I.length>0&&B(I[0]);},placeholder:drawuiCore.t("icon.search"),"aria-label":drawuiCore.t("icon.search")}),jsxRuntime.jsx("span",{className:"drawui-icon-count",children:I.length})]}),!r.trim()&&jsxRuntime.jsxs("div",{className:"drawui-icon-cats",children:[w.length>0&&jsxRuntime.jsxs("button",{type:"button",className:`drawui-icon-cat${d==="recent"?" active":""}`,style:ho(drawuiCore.ICON_CATEGORY_INK.status),onClick:()=>s("recent"),children:[jsxRuntime.jsx("i",{className:"drawui-icon-dot"}),drawuiCore.t("icon.recent")]}),drawuiCore.ICON_CATEGORIES.map(p=>jsxRuntime.jsxs("button",{type:"button",className:`drawui-icon-cat${d===p.id?" active":""}`,style:ho(drawuiCore.ICON_CATEGORY_INK[p.id]??drawuiCore.ICON_DEFAULT_INK),onClick:()=>s(p.id),children:[jsxRuntime.jsx("i",{className:"drawui-icon-dot"}),drawuiCore.t(p.labelKey)]},p.id))]}),jsxRuntime.jsxs("div",{className:"drawui-icon-card",children:[jsxRuntime.jsxs("div",{className:"drawui-icon-card-head",children:[jsxRuntime.jsx("span",{className:"drawui-icon-card-title",children:C}),jsxRuntime.jsx("span",{className:"drawui-icon-card-count",children:I.length})]}),jsxRuntime.jsxs("div",{className:"drawui-icon-grid",children:[I.map(p=>jsxRuntime.jsx("button",{type:"button",className:"drawui-icon-item",title:`${p.zh} / ${p.en}`,"aria-label":`${p.zh} ${p.en}`,onClick:()=>B(p),children:jsxRuntime.jsx(Jo,{icon:p,size:30,ink:drawuiCore.iconInk(p)})},p.id)),I.length===0&&jsxRuntime.jsx("div",{className:"drawui-icon-empty",children:drawuiCore.t("icon.empty")})]})]})]})});var Ce=o=>`${o.x.toFixed(1)},${o.y.toFixed(1)}`,go=(o,e)=>{let n=e*Math.PI/180;return {x:o.x*Math.cos(n)-o.y*Math.sin(n),y:o.x*Math.sin(n)+o.y*Math.cos(n)}},ot={x:Math.SQRT1_2,y:-Math.SQRT1_2},$t={x:4.6,y:19.4},st={x:19,y:5};function Dt(o,e,n){let r={x:-n.y,y:n.x},h=s=>({x:e.x-n.x*s,y:e.y-n.y*s}),d=(s,l)=>({x:s.x+r.x*l,y:s.y+r.y*l});switch(o){case "end":{let s=h(5.6);return jsxRuntime.jsx("polygon",{points:`${Ce(e)} ${Ce(d(s,2.7))} ${Ce(d(s,-2.7))}`,fill:"currentColor",stroke:"none"})}case "inheritance":case "realization":{let s=h(8.6);return jsxRuntime.jsx("polygon",{points:`${Ce(e)} ${Ce(d(s,3.5))} ${Ce(d(s,-3.5))}`,fill:"none"})}case "aggregation":case "composition":{let s=h(4.3),l=h(8.6);return jsxRuntime.jsx("polygon",{points:`${Ce(e)} ${Ce(d(s,2.7))} ${Ce(l)} ${Ce(d(s,-2.7))}`,fill:o==="composition"?"currentColor":"none",stroke:"currentColor"})}case "dependency":{let s=go({x:-n.x,y:-n.y},30),l=go({x:-n.x,y:-n.y},-30);return jsxRuntime.jsx("path",{d:`M ${Ce({x:e.x+s.x*5.8,y:e.y+s.y*5.8})} L ${Ce(e)} L ${Ce({x:e.x+l.x*5.8,y:e.y+l.y*5.8})}`,fill:"none"})}default:return null}}function Ie(o,e){let n=e||o==="dependency"||o==="realization",r=n?{x:st.x-ot.x*8.6,y:st.y-ot.y*8.6}:st,h={x:-ot.x,y:-ot.y};return jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:$t.x,y1:$t.y,x2:r.x,y2:r.y,strokeDasharray:n?"3 2.6":void 0}),(o==="end"||o==="both")&&Dt("end",st,ot),(o==="start"||o==="both")&&Dt("end",$t,h),o!=="none"&&o!=="start"&&o!=="end"&&o!=="both"?Dt(o,st,ot):null]})}var mt=o=>jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:o})}),on=[{type:"straight",labelKey:"style.connection.straight",icon:mt("M3 12h18")},{type:"polyline",labelKey:"style.connection.polyline",icon:mt("M4 8 C 12 8, 12 16, 20 16")},{type:"orthogonal",labelKey:"style.connection.orthogonal",icon:mt("M5 5v14h14")},{type:"curve",labelKey:"style.connection.curve",icon:mt("M3 13 C 6 7, 9 7, 12 12 C 15 17, 18 17, 21 11")}],wo=[{key:"none",arrowHead:"none",dashed:false,labelKey:"style.arrowhead.none",icon:Ie("none",false)},{key:"end",arrowHead:"end",dashed:false,labelKey:"style.arrowhead.end",icon:Ie("end",false)},{key:"start",arrowHead:"start",dashed:false,labelKey:"style.arrowhead.start",icon:Ie("start",false)},{key:"both",arrowHead:"both",dashed:false,labelKey:"style.arrowhead.both",icon:Ie("both",false)},{key:"none-dashed",arrowHead:"none",dashed:true,labelKey:"style.arrowhead.none-dashed",icon:Ie("none",true)},{key:"both-dashed",arrowHead:"both",dashed:true,labelKey:"style.arrowhead.both-dashed",icon:Ie("both",true)}],xo=[{key:"inheritance",arrowHead:"inheritance",dashed:false,labelKey:"style.arrowhead.inheritance",icon:Ie("inheritance",false)},{key:"composition",arrowHead:"composition",dashed:false,labelKey:"style.arrowhead.composition",icon:Ie("composition",false)},{key:"aggregation",arrowHead:"aggregation",dashed:false,labelKey:"style.arrowhead.aggregation",icon:Ie("aggregation",false)},{key:"dependency",arrowHead:"dependency",dashed:true,labelKey:"style.arrowhead.dependency",icon:Ie("dependency",true)},{key:"realization",arrowHead:"realization",dashed:true,labelKey:"style.arrowhead.realization",icon:Ie("realization",true)}],bo=[...wo,...xo];function nn(o,e){let n=bo.find(r=>r.arrowHead===o&&r.dashed===e);return n?n.key:bo.find(r=>r.arrowHead===o)?.key}var bt=react.memo(function({connectionType:e,arrowHead:n,dashed:r,onConnectionTypeChange:h,onArrowStyleChange:d,onOptionHover:s,onOptionLeave:l}){G();let S=nn(n,r),f=u=>jsxRuntime.jsx("div",{className:"drawui-connection-row",children:u.map(w=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${S===w.key?" active":""}`,onClick:()=>d(w),"data-drawui-tip":s?void 0:drawuiCore.t(w.labelKey),onMouseEnter:s?I=>s(w.labelKey,I.currentTarget):void 0,onMouseLeave:s?l:void 0,"aria-label":drawuiCore.t(w.labelKey),type:"button",children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:w.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(w.labelKey)})]},w.key))});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.connection")}),jsxRuntime.jsx("div",{className:"drawui-connection-row",children:on.map(u=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${e===u.type?" active":""}`,onClick:()=>h(u.type),"data-drawui-tip":s?void 0:drawuiCore.t(u.labelKey),onMouseEnter:s?w=>s(u.labelKey,w.currentTarget):void 0,onMouseLeave:s?l:void 0,"aria-label":drawuiCore.t(u.labelKey),type:"button",children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:u.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(u.labelKey)})]},u.type))}),jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.arrow")}),f(wo),jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.uml")}),f(xo)]})});var vo=[{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"})},{type:"cylinder",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"6.5",rx:"6",ry:"2.8"}),jsxRuntime.jsx("path",{d:"M6 6.5v11c0 1.5 2.7 2.8 6 2.8s6-1.3 6-2.8v-11"})]})},{type:"cloud",icon:jsxRuntime.jsx("path",{d:"M7 18.5h9.4a3.4 3.4 0 0 0 .3-6.8 5 5 0 0 0-9.5-1.2A3.9 3.9 0 0 0 7 18.5Z"})},{type:"heart",icon:jsxRuntime.jsx("path",{d:"M12 20.3S4.6 15.7 4.6 10.5A4.1 4.1 0 0 1 12 7.6a4.1 4.1 0 0 1 7.4 2.9c0 5.2-7.4 9.8-7.4 9.8Z"})},{type:"block-arrow-right",icon:jsxRuntime.jsx("path",{d:"M3 9h9V5l9 7-9 7v-4H3Z"})},{type:"block-arrow-left",icon:jsxRuntime.jsx("path",{d:"M21 9h-9V5L3 12l9 7v-4h9Z"})},{type:"block-arrow-up",icon:jsxRuntime.jsx("path",{d:"M9 21v-9H5l7-9 7 9h-4v9Z"})},{type:"block-arrow-down",icon:jsxRuntime.jsx("path",{d:"M9 3v9H5l7 9 7-9h-4V3Z"})},{type:"block-arrow-double",icon:jsxRuntime.jsx("path",{d:"M2 12l4.5-6v3.5h11V6L22 12l-4.5 6v-3.5h-11V18Z"})},{type:"right-triangle",icon:jsxRuntime.jsx("path",{d:"M4 4v16h16Z"})},{type:"cross",icon:jsxRuntime.jsx("path",{d:"M9.5 3h5v6.5H21v5h-6.5V21h-5v-6.5H3v-5h6.5Z"})},{type:"envelope",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14"}),jsxRuntime.jsx("path",{d:"M3 5l18 14M21 5L3 19"})]})},{type:"checkbox",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),jsxRuntime.jsx("path",{d:"M7.8 12.3l2.7 2.7 5.7-6.2"})]})},{type:"speech-rect",icon:jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("path",{d:"M3 5h18v11H8l-3.2 3.2V16H3Z"})})},{type:"speech-round",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"10.5",rx:"9",ry:"6.5"}),jsxRuntime.jsx("path",{d:"M8 16.2 6 21l5-3.4"})]})},{type:"cube",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 3 20 7.5v9L12 21 4 16.5v-9Z"}),jsxRuntime.jsx("path",{d:"M4 7.5 12 12l8-4.5M12 12v9"})]})},{type:"cuboid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 4 21 8.5v7L12 20 3 15.5v-7Z"}),jsxRuntime.jsx("path",{d:"M3 8.5 12 13l9-4.5M12 13v7"})]})},{type:"triangular-pyramid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 3 21.5 16.5 12 21 2.5 16.5Z"}),jsxRuntime.jsx("path",{d:"M12 3v18M2.5 16.5h19"})]})},{type:"quadrangular-pyramid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 3 22.5 17 12 21 1.5 17Z"}),jsxRuntime.jsx("path",{d:"M12 3v18M12 12 1.5 17M12 12l10.5 5"})]})},{type:"sphere",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"9"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"2.5"})]})},{type:"ellipsoid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"10",ry:"6.5"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"10",ry:"1.9"})]})},{type:"pie",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"9",rx:"9",ry:"3.5"}),jsxRuntime.jsx("path",{d:"M3 9v5c0 1.9 4 3.5 9 3.5s9-1.6 9-3.5V9"}),jsxRuntime.jsx("path",{d:"M12 9 5.6 12M12 9l6.4 3"})]})},{type:"hollow-pie",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"9",rx:"9",ry:"3.5"}),jsxRuntime.jsx("path",{d:"M3 9v5c0 1.9 4 3.5 9 3.5s9-1.6 9-3.5V9"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"9",rx:"3.6",ry:"1.5"})]})},{type:"sector",icon:jsxRuntime.jsx("path",{d:"M12 3a9 9 0 1 0 9 9h-9Z"})},{type:"delay",icon:jsxRuntime.jsx("path",{d:"M3 5h12a7 7 0 0 1 0 14H3Z"})},{type:"predefined-process",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14"}),jsxRuntime.jsx("path",{d:"M6.5 5v14M17.5 5v14"})]})},{type:"document",icon:jsxRuntime.jsx("path",{d:"M3 5h18v10.5c-5 3.5-13-3.5-18 0Z"})},{type:"stadium",icon:jsxRuntime.jsx("rect",{x:"3",y:"6.5",width:"18",height:"11",rx:"5.5"})},{type:"chevron",icon:jsxRuntime.jsx("path",{d:"M2 4h9l9 8-9 8H2l8-8Z"})},{type:"brace-left",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M1 1C3.9 1 5.1 2.4 5.1 5.1c0 3.7 1.2 6.9 2.9 6.9-1.7 0-2.9 3.2-2.9 6.9 0 2.7-1.2 4.1-4.1 4.1"}),jsxRuntime.jsx("path",{d:"M12 9.6h10M12 14.4h10"})]})},{type:"brace-right",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M23 1c-2.9 0-4.1 1.4-4.1 4.1 0 3.7-1.2 6.9-2.9 6.9 1.7 0 2.9 3.2 2.9 6.9 0 2.7 1.2 4.1 4.1 4.1"}),jsxRuntime.jsx("path",{d:"M2 9.6h10M2 14.4h10"})]})},{type:"uml-class",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{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"})]})},{type:"uml-interface",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{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"})]})},{type:"class-catalog",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"1.5"}),jsxRuntime.jsx("line",{x1:"6.6",y1:"5",x2:"6.6",y2:"19"}),jsxRuntime.jsx("line",{x1:"17.4",y1:"5",x2:"17.4",y2:"19"})]})}],sn=[{key:"basic",labelKey:"shapeGroup.basic",items:[{type:"rectangle"},{type:"rounded-rectangle"},{type:"stadium"},{type:"circle"},{type:"ellipse"},{type:"diamond"},{type:"triangle"},{type:"right-triangle"},{type:"hexagon"},{type:"parallelogram"},{type:"trapezoid"},{type:"pentagon"},{type:"octagon"},{type:"star"},{type:"envelope"},{type:"checkbox"}]},{key:"flowchart",labelKey:"shapeGroup.flowchart",items:[{type:"rectangle",labelKey:"flow.process"},{type:"rounded-rectangle",labelKey:"flow.step"},{type:"stadium",labelKey:"flow.startEnd"},{type:"diamond",labelKey:"flow.decision"},{type:"parallelogram",labelKey:"flow.data"},{type:"trapezoid",labelKey:"flow.manual"},{type:"hexagon",labelKey:"flow.preparation"},{type:"cylinder",labelKey:"flow.database"},{type:"delay",labelKey:"flow.delay"},{type:"predefined-process"},{type:"document"},{type:"block-arrow-right"},{type:"block-arrow-left"},{type:"block-arrow-up"},{type:"block-arrow-down"},{type:"block-arrow-double"}]},{key:"uml",labelKey:"shapeGroup.uml",items:[{type:"uml-class"},{type:"uml-interface"},{type:"rounded-rectangle",labelKey:"class.plain"},{type:"class-catalog"}]},{key:"solid",labelKey:"shapeGroup.solid",items:[{type:"cylinder"},{type:"cube"},{type:"cuboid"},{type:"triangular-pyramid"},{type:"quadrangular-pyramid"},{type:"sphere"},{type:"ellipsoid"},{type:"pie"},{type:"hollow-pie"}]},{key:"other",labelKey:"shapeGroup.other",items:[{type:"cloud"},{type:"heart"},{type:"cross"},{type:"sector"},{type:"chevron"},{type:"speech-rect"},{type:"speech-round"},{type:"brace-left"},{type:"brace-right"}]}],ln=new Map(vo.map(o=>[o.type,o.icon])),cn=new Set(vo.map(o=>o.type)),dn=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsxRuntime.jsx("path",{d:"M20 15h-5v5"})]}),un=[{type:"arrow",icon:"M5 12h14M12 5l7 7-7 7",labelKey:"toolbar.arrow"},{type:"text",icon:"M4 7V4h16v3M9 20h6M12 4v16",labelKey:"toolbar.text"}],pn="M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3Z",zt="M0 -1Q0.24 -0.24 1 0Q0.24 0.24 0 1Q-0.24 0.24 -1 0Q-0.24 -0.24 0 -1Z",hn=[{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"}],Bt=react.memo(function({activeTool:e,onToolChange:n,showGrid:r,onToggleGrid:h,canUndo:d=false,canRedo:s=false,onUndo:l,onRedo:S,onExport:f,onExportData:u,onImportData:w,onHighlighterColorChange:I,onStickyNoteColorChange:z,onInsertIcon:C,arrowStyle:B,onArrowStyleChange:p}){let[A,L]=react.useState(false),[se,i]=react.useState(false),[x,y]=react.useState(null),[j,O]=react.useState(false),[_,X]=react.useState(false),[de,Q]=react.useState(ht),[fe,b]=react.useState(false),[ee,Le]=react.useState(yt),[re,Me]=react.useState(false),P=react.useRef(null),ue=react.useRef(null),le=react.useRef(null),Se=react.useRef(null),me=react.useRef(null);G();let Ne=[{format:"png",labelKey:"toolbar.export.png"},{format:"svg",labelKey:"toolbar.export.svg"},{format:"pdf",labelKey:"toolbar.export.pdf"}],Re=()=>{P.current&&(clearTimeout(P.current),P.current=null),O(true);},Te=()=>{P.current=window.setTimeout(()=>O(false),200);},$=react.useRef(null),v=()=>{O(false),U(),$.current?.click();},ae=a=>{let N=a.target.files?.[0];N&&w?.(N),a.target.value="";},Y=()=>{ue.current&&(clearTimeout(ue.current),ue.current=null),L(true);},q=()=>{ue.current=window.setTimeout(()=>{L(false),U();},200);},W=()=>{le.current&&(clearTimeout(le.current),le.current=null),i(true);},He=()=>{le.current=window.setTimeout(()=>{i(false),U();},200);},te=(a,N)=>{let pe=a.closest(".drawui-toolbar");if(!pe)return;let ge=a.getBoundingClientRect(),we=pe.getBoundingClientRect(),Ee=ge.bottom+46>window.innerHeight;y({label:N,x:ge.left-we.left+ge.width/2,y:Ee?ge.top-we.top-8:ge.bottom-we.top+8,above:Ee});},U=()=>y(null),ze=()=>{Se.current&&(clearTimeout(Se.current),Se.current=null),X(true);},Ze=()=>{Se.current=window.setTimeout(()=>X(false),200);},g=a=>{Q(a),ao(a),I?.(a),n("highlighter");},R=()=>{me.current&&(clearTimeout(me.current),me.current=null),b(true);},H=()=>{me.current=window.setTimeout(()=>b(false),200);},D=a=>{Le(a),lo(a),z?.(a),n("sticky-note"),b(false);};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:()=>n("select"),onMouseEnter:a=>te(a.currentTarget,"toolbar.select"),onMouseLeave:U,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:"M6 3 6 19.6 10.3 15.7 13 21.1 15.8 19.8 13.1 14.5 18.6 14 Z"})})}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="hand"?"active":""}`,onClick:()=>n("hand"),onMouseEnter:a=>te(a.currentTarget,"toolbar.hand"),onMouseLeave:U,children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M7.6 12.6V5.6a1.5 1.5 0 0 1 3 0v4.6"}),jsxRuntime.jsx("path",{d:"M10.6 10.2V4.1a1.5 1.5 0 0 1 3 0v6.1"}),jsxRuntime.jsx("path",{d:"M13.6 10.4V5.2a1.5 1.5 0 0 1 3 0v6.6"}),jsxRuntime.jsx("path",{d:"M16.6 11.8V8.1a1.5 1.5 0 0 1 3 0v6.6a6.2 6.2 0 0 1-6.2 6.2h-1.5a6.2 6.2 0 0 1-5-2.5l-3.2-4.4a1.5 1.5 0 0 1 2.3-1.9l2.6 2.5"})]})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:Y,onMouseLeave:q,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${cn.has(e)?"active":""}`,onClick:()=>{n("rounded-rectangle"),L(false),U();},"data-drawui-tip":A?void 0:drawuiCore.t("toolbar.shapes"),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"})})}),A&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-shape-menu",children:jsxRuntime.jsx("div",{className:"drawui-shape-menu-scroll",children:sn.map(a=>jsxRuntime.jsxs("div",{className:"drawui-shape-group",children:[jsxRuntime.jsx("div",{className:"drawui-shape-group-title",children:drawuiCore.t(a.labelKey)}),jsxRuntime.jsx("div",{className:"drawui-shape-group-grid",children:a.items.map(N=>{let pe=N.labelKey??`tool.${N.type}`;return jsxRuntime.jsx("button",{type:"button",className:`drawui-toolbar-shape-item ${e===N.type?"active":""}`,onClick:()=>{n(N.type),L(false),U();},onMouseEnter:ge=>te(ge.currentTarget,pe),onMouseLeave:U,"aria-label":drawuiCore.t(pe),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:ln.get(N.type)})},`${a.key}-${N.type}`)})})]},a.key))})})]}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:R,onMouseLeave:H,children:[jsxRuntime.jsxs("button",{className:`drawui-toolbar-button ${e==="sticky-note"?"active":""}`,onClick:()=>{n("sticky-note"),b(false),U();},"data-drawui-tip":fe?void 0:drawuiCore.t("tool.sticky-note"),children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:dn}),jsxRuntime.jsx("span",{className:"drawui-toolbar-color-chip",style:{background:ee}})]}),fe&&jsxRuntime.jsxs("div",{className:"drawui-toolbar-shape-grid drawui-sticky-panel",children:[jsxRuntime.jsxs("div",{className:"drawui-sticky-panel-head",children:[jsxRuntime.jsx("span",{className:"drawui-sticky-panel-title",children:drawuiCore.t("tool.sticky-note")}),jsxRuntime.jsx("span",{className:"drawui-sticky-panel-key",children:"N"})]}),jsxRuntime.jsx("div",{className:"drawui-sticky-panel-grid",children:drawuiCore.STICKY_NOTE_COLORS.map(a=>jsxRuntime.jsx("button",{type:"button","aria-label":a,className:`drawui-sticky-swatch${ee.toLowerCase()===a.toLowerCase()?" active":""}`,style:{background:a},onClick:()=>D(a)},a))})]})]}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${re?"active":""}`,"data-icon-toggle":"","data-drawui-tip":re?void 0:drawuiCore.t("toolbar.icon"),onClick:()=>{Me(a=>!a),U();},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:"12",cy:"12",r:"9"}),jsxRuntime.jsx("path",{d:"M8.5 10.2h0.01"}),jsxRuntime.jsx("path",{d:"M15.5 10.2h0.01"}),jsxRuntime.jsx("path",{d:"M8.8 14.2c0.9 1 2 1.5 3.2 1.5s2.3 -0.5 3.2 -1.5"})]})}),re&&jsxRuntime.jsx(mo,{onPick:a=>C?.(a.id),onClose:()=>Me(false)})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:W,onMouseLeave:He,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="arrow"?"active":""}`,onClick:()=>{n("arrow"),i(false),U();},"data-drawui-tip":se?void 0:drawuiCore.t("toolbar.arrow"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})}),se&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-arrow-menu",onPointerDown:a=>{a.target.closest("button")||(i(false),U());},children:jsxRuntime.jsx(bt,{connectionType:B?.connectionType??"straight",arrowHead:B?.arrowHead??"end",dashed:!!B?.dashed,onConnectionTypeChange:a=>{p?.({connectionType:a}),n("arrow"),i(false),U();},onArrowStyleChange:a=>{p?.({arrowHead:a.arrowHead,dashed:a.dashed}),n("arrow"),i(false),U();},onOptionHover:(a,N)=>te(N,a),onOptionLeave:U})})]}),un.filter(a=>a.type!=="arrow").map(a=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===a.type?"active":""}`,onClick:()=>n(a.type),"data-drawui-tip":drawuiCore.t(a.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:a.icon})})},a.type)),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="pen"?"active":""}`,onClick:()=>n("pen"),"data-drawui-tip":drawuiCore.t("toolbar.pen"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:pn})})}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:ze,onMouseLeave:Ze,children:[jsxRuntime.jsxs("button",{className:`drawui-toolbar-button ${e==="highlighter"?"active":""}`,onClick:()=>n("highlighter"),onMouseEnter:a=>te(a.currentTarget,"toolbar.highlighter"),onMouseLeave:U,children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M4.6 19.6 12.8 11.4",strokeWidth:"3.6",strokeLinecap:"square"}),jsxRuntime.jsx("path",{d:"M14.6 9.6 16.2 8",strokeWidth:"3.6",strokeLinecap:"square"}),jsxRuntime.jsxs("g",{fill:"currentColor",stroke:"none",children:[jsxRuntime.jsx("path",{d:zt,transform:"translate(7.4 5.4) scale(2.4)"}),jsxRuntime.jsx("path",{d:zt,transform:"translate(18.4 3.4) scale(2.5)"}),jsxRuntime.jsx("path",{d:zt,transform:"translate(21 10.6) scale(2.2)"})]})]}),jsxRuntime.jsx("span",{className:"drawui-toolbar-color-chip",style:{background:de}})]}),_&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-highlighter-grid",children:no.map(a=>jsxRuntime.jsx("button",{type:"button","aria-label":a,className:`drawui-highlighter-swatch${de.toLowerCase()===a.toLowerCase()?" active":""}`,style:{background:a},onClick:()=>g(a)},a))})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),hn.map(a=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===a.type?"active":""}`,onClick:()=>n(a.type),"data-drawui-tip":drawuiCore.t(a.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:a.icon})})},a.type)),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="mind-map"?"active":""}`,onClick:()=>n("mind-map"),"data-drawui-tip":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:h,"data-drawui-tip":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:l,disabled:!d,style:d?void 0:{opacity:.4,cursor:"default"},"data-drawui-tip":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:!s,style:s?void 0:{opacity:.4,cursor:"default"},"data-drawui-tip":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:Re,onMouseLeave:Te,children:[jsxRuntime.jsx("button",{className:"drawui-toolbar-button","data-drawui-tip":j?void 0: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"})]})}),j&&jsxRuntime.jsxs("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-export-grid",children:[Ne.map(a=>jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{f?.(a.format),O(false);},"data-drawui-tip":drawuiCore.t(a.labelKey),children:drawuiCore.t(a.labelKey)},a.format)),jsxRuntime.jsx("div",{className:"drawui-toolbar-export-divider"}),jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{u?.(),O(false);},"data-drawui-tip":drawuiCore.t("toolbar.export.data"),children:drawuiCore.t("toolbar.export.data")}),jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:v,"data-drawui-tip":drawuiCore.t("toolbar.import.data"),children:drawuiCore.t("toolbar.import.data")})]})]}),jsxRuntime.jsx("input",{ref:$,type:"file",accept:".json,application/json",style:{display:"none"},onChange:ae}),x&&jsxRuntime.jsx("div",{className:`drawui-shape-tip ${x.above?"is-above":"is-below"}`,style:{left:x.x,top:x.y},children:drawuiCore.t(x.label)})]})})});var Ut=react.memo(function({onZoomIn:e,onZoomOut:n,onReset:r,zoomLevel:h=100}){return G(),jsxRuntime.jsxs("div",{className:"drawui-zoom-control",children:[jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:e,"data-drawui-tip":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:[h,"%"]}),jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:n,"data-drawui-tip":drawuiCore.t("zoom.out"),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,"data-drawui-tip":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 Mo=["#ffffff","#f1f5f9","#e2e8f0","#ede9fe","#dbeafe","#e0e7ff","#dcfce7","#fef9c3","#fee2e2"],So=["#0f172a","#475569","#94a3b8","#8b5cf6","#3b82f6","#1d4ed8","#16a34a","#eab308","#dc2626"],xn=Mo.filter(o=>o!=="#f1f5f9"),vn=[...xn,...So],kn=[...Mo,...So],Co=15,Lo="drawui:customColors";function Mn(){if(typeof window>"u")return [];try{let o=window.localStorage.getItem(Lo);if(!o)return [];let e=JSON.parse(o);return Array.isArray(e)?e.filter(n=>typeof n=="string").slice(-Co):[]}catch{return []}}function Sn(o){if(!(typeof window>"u"))try{window.localStorage.setItem(Lo,JSON.stringify(o));}catch{}}var Wt=[{key:"fill",labelKey:"style.fill",hasTransparent:true,hasOpacity:true},{key:"stroke",labelKey:"style.stroke",hasTransparent:false,hasOpacity:true},{key:"text",labelKey:"style.text",hasTransparent:false},{key:"highlight",labelKey:"style.highlight",hasTransparent:true,hasOpacity:true}],ko=(o,e)=>!!o&&!!e&&o.toLowerCase()===e.toLowerCase(),ct=10,Fe=12,We=o=>!o||o==="transparent",To=react.memo(function({editor:e,selectedCount:n,hasLineSelection:r,currentConnectionType:h,currentArrowHead:d,currentDashed:s}){G();let l=!!e?.getEditingShapeId(),[S,f]=react.useState(null),[u,w]=react.useState(null),[,I]=react.useState(0),z=react.useRef(null),C=react.useRef(null),B=react.useRef(null),[p,A]=react.useState({tw:168,th:42,pw:228,ph:160}),[L,se]=react.useState(Mn),i=react.useRef(null),x=react.useCallback(c=>{let M=c.trim().toLowerCase();/^#[0-9a-f]{6}$/.test(M)&&se(m=>{let K=m.filter(E=>E!==M);for(K.push(M);K.length>Co;)K.shift();return Sn(K),K});},[]);if(react.useEffect(()=>{let c=i.current;if(!c)return;let M=()=>{c.value&&x(c.value);};return c.addEventListener("change",M),()=>c.removeEventListener("change",M)},[x,u]),react.useEffect(()=>{if(!e)return;let c=e.subscribe(()=>I(M=>(M+1)%1e6));return ()=>{c();}},[e]),react.useEffect(()=>{w(null);},[n,l]),react.useEffect(()=>{if(!u)return;let c=M=>{z.current&&!z.current.contains(M.target)&&w(null);};return document.addEventListener("pointerdown",c,true),()=>document.removeEventListener("pointerdown",c,true)},[u]),react.useLayoutEffect(()=>{let c=C.current?.offsetWidth??p.tw,M=C.current?.offsetHeight??p.th,m=B.current?.offsetWidth??p.pw,K=B.current?.offsetHeight??p.ph;A(E=>E.tw===c&&E.th===M&&E.pw===m&&E.ph===K?E:{tw:c,th:M,pw:m,ph:K});}),!e||n===0||l)return null;let y=e.getSelectedIds(),O=e.getShapes().filter(c=>y.includes(c.id)),_=O[0],X=_?.id??"",de=_?.style.fillColor,Q=_?.style.strokeColor??"#1f2937",fe=_?.textColor??"#1f2937",b=_?.highlightColor,ee={fill:de,stroke:Q,text:fe,highlight:b},Le=O.length>0&&O.every(c=>c.type==="sticky-note"),re={fill:_?.style.fillOpacity??1,stroke:_?.style.strokeOpacity??1,highlight:_?.highlightOpacity??1},Me=c=>S&&S.key===`${X}:${c}`?S.value:re[c]??1,P=(c,M)=>{switch(c){case "stroke":e.updateSelectedShapesStyle({strokeColor:M});break;case "fill":e.updateSelectedShapesStyle({fillColor:M});break;case "text":e.updateSelectedShapesText({textColor:M});break;case "highlight":e.updateSelectedShapesText({highlightColor:M});break}},ue=(c,M)=>{f({key:`${X}:${c}`,value:M}),c==="highlight"?e.updateSelectedShapesText({highlightOpacity:M}):c==="stroke"?e.updateSelectedShapesStyle({strokeOpacity:M}):e.updateSelectedShapesStyle({fillOpacity:M});},le=c=>e.updateConnectionType(c),Se=c=>e.updateArrowStyle({arrowHead:c.arrowHead,dashed:c.dashed}),me=!!r&&O.length>0&&O.every(c=>c.type==="line"||c.type==="arrow"),Ne=O.length>0&&O.every(c=>c.type==="text"),Re=O.length>0&&O.every(c=>c.type==="sticky-note"||c.type==="icon"),Te=me?Wt.filter(c=>c.key==="stroke"):Re?Wt.filter(c=>c.key!=="stroke"):Wt,$=c=>c.key==="stroke"&&me?"style.line":c.labelKey,v=u&&u!=="more"?Te.find(c=>c.key===u):void 0,ae=!!u&&(u==="more"||u==="prefix"||!!v),Y=Le&&v?.key==="fill",q=e.getCamera(),W=drawuiCore.getContentBounds(O,0),He=q.pageToScreen({x:W.x,y:W.y}),te=q.pageToScreen({x:W.x+W.width,y:W.y+W.height}),U=window.innerWidth,ze=window.innerHeight,Ze=te.y+ct,g=He.y-ct,R=p.th+(ae?ct+p.ph:0),H=Ze+R<=ze-Fe,D=g-R>=Fe,a=H||!D,N=(He.x+te.x)/2,pe=(c,M,m)=>Math.max(M,Math.min(c,Math.max(M,m))),ge=pe(N-p.tw/2,Fe,U-p.tw-Fe),we=a?Ze:g-p.th,Ee=pe(N-p.pw/2,Fe,U-p.pw-Fe),Xe=ae?pe(a?we+p.th+ct:we-ct-p.ph,Fe,ze-p.ph-Fe):0;return jsxRuntime.jsxs("div",{className:"drawui-style-floating",ref:z,children:[jsxRuntime.jsxs("div",{className:"drawui-style-toolbar",ref:C,style:{left:ge,top:we},children:[Te.map(c=>jsxRuntime.jsxs("button",{className:`drawui-style-tool-btn${u===c.key?" active":""}`,onClick:()=>w(u===c.key?null:c.key),"data-drawui-tip":drawuiCore.t($(c)),type:"button",children:[c.key==="fill"&&jsxRuntime.jsx("span",{className:`drawui-st-swatch${We(de)?" drawui-st-none":""}`,style:We(de)?void 0:{background:de}}),c.key==="stroke"&&(me?jsxRuntime.jsx("span",{className:`drawui-st-line${We(Q)?" drawui-st-line-none":""}`,style:We(Q)?void 0:{background:Q}}):jsxRuntime.jsx("span",{className:`drawui-st-frame${We(Q)?" drawui-st-frame-none":""}`,style:We(Q)?void 0:{borderColor:Q}})),c.key==="text"&&jsxRuntime.jsx("span",{className:"drawui-st-text",style:{color:fe},children:"A"}),c.key==="highlight"&&jsxRuntime.jsx("span",{className:`drawui-st-hl${We(b)?" drawui-st-none":""}`,style:We(b)?void 0:{background:b},children:"A"})]},c.key)),r&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${u==="more"?" active":""}`,onClick:()=>w(u==="more"?null:"more"),"data-drawui-tip":drawuiCore.t("style.connection"),type:"button",children:"\u22EF"}),Ne&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${u==="prefix"?" active":""}`,onClick:()=>w(u==="prefix"?null:"prefix"),"data-drawui-tip":drawuiCore.t("style.prefix"),type:"button",children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[jsxRuntime.jsx("circle",{cx:"5",cy:"8",r:"1.7",fill:"currentColor",stroke:"none"}),jsxRuntime.jsx("circle",{cx:"5",cy:"16",r:"1.7",fill:"currentColor",stroke:"none"}),jsxRuntime.jsx("line",{x1:"10.5",y1:"8",x2:"20",y2:"8"}),jsxRuntime.jsx("line",{x1:"10.5",y1:"16",x2:"20",y2:"16"})]})})]}),ae&&jsxRuntime.jsx("div",{className:"drawui-style-popover",ref:B,style:{left:Ee,top:Xe},children:u==="prefix"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.prefix")}),jsxRuntime.jsx("div",{className:"drawui-muted-hint",children:drawuiCore.t("style.prefix.soon")})]}):v?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t($(v))}),jsxRuntime.jsxs("div",{className:"drawui-color-row",children:[v.hasTransparent&&!Y&&jsxRuntime.jsx("button",{className:`drawui-color-swatch drawui-color-swatch-transparent${We(ee[v.key])?" active":""}`,onClick:()=>P(v.key,"transparent"),"aria-label":drawuiCore.t("style.none"),type:"button"}),(Y?drawuiCore.STICKY_NOTE_COLORS:v.hasTransparent?vn:kn).map(c=>jsxRuntime.jsx("button",{className:`drawui-color-swatch${ko(c,ee[v.key])?" active":""}`,style:{background:c},onClick:()=>P(v.key,c),"aria-label":c,type:"button"},c)),L.map(c=>jsxRuntime.jsx("button",{className:`drawui-color-swatch drawui-color-custom${ko(c,ee[v.key])?" active":""}`,style:{background:c},onClick:()=>P(v.key,c),"aria-label":c,type:"button"},`custom-${c}`)),jsxRuntime.jsxs("span",{className:"drawui-color-swatch drawui-color-add","data-drawui-tip":drawuiCore.t("style.addColor"),children:["+",jsxRuntime.jsx("input",{ref:i,type:"color",defaultValue:"#3b82f6",className:"drawui-color-add-input","aria-label":drawuiCore.t("style.addColor")})]})]}),v.hasOpacity&&jsxRuntime.jsxs("div",{className:"drawui-opacity-row",children:[jsxRuntime.jsx("span",{className:"drawui-opacity-label",children:drawuiCore.t("style.opacity")}),jsxRuntime.jsx("input",{type:"range",min:0,max:100,value:Math.round(Me(v.key)*100),onChange:c=>ue(v.key,Number(c.target.value)/100),className:"drawui-opacity-slider"}),jsxRuntime.jsxs("span",{className:"drawui-opacity-value",children:[Math.round(Me(v.key)*100),"%"]})]})]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(bt,{connectionType:h??"straight",arrowHead:d??"end",dashed:!!s,onConnectionTypeChange:le,onArrowStyleChange:Se})})})]})});var Vt=14,Io=20,Rn=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af"],Hn=[12,14,16,18,20,24];function Ro(o,e,n){let r=o,h=n,d=r.charAt(0);if(r.length>1&&(d==="+"||d==="-"||d==="#"||d==="~")&&r.charAt(1)===" "&&(h=d,r=r.slice(2)),r=r.replace(/^\s+|\s+$/g,""),e==="attribute"){let w=r.indexOf(":");return w===-1?{visibility:h,name:r,type:"",params:"",returnType:""}:{visibility:h,name:r.slice(0,w).replace(/^\s+|\s+$/g,""),type:r.slice(w+1).replace(/^\s+|\s+$/g,""),params:"",returnType:""}}let s=r.indexOf("(");if(s===-1){let w=r.lastIndexOf(":");return w===-1?{visibility:h,name:r,type:"",params:"",returnType:""}:{visibility:h,name:r.slice(0,w).replace(/^\s+|\s+$/g,""),type:"",params:"",returnType:r.slice(w+1).replace(/^\s+|\s+$/g,"")}}let l=r.slice(0,s).replace(/^\s+|\s+$/g,""),S=r.indexOf(")",s);if(S===-1)return {visibility:h,name:l,type:"",params:r.slice(s+1).replace(/^\s+|\s+$/g,""),returnType:""};let f=r.slice(s+1,S).replace(/^\s+|\s+$/g,""),u=r.slice(S+1).replace(/^\s+|\s+$/g,"");return u.startsWith(":")&&(u=u.slice(1).replace(/^\s+|\s+$/g,"")),{visibility:h,name:l,type:"",params:f,returnType:u}}function Pn(o,e){let n=`${e.visibility} `;return o==="attribute"?`${n}${e.name}: ${e.type??""}`:`${n}${e.name}(${e.params??""}): ${e.returnType??""}`}var Po=react.memo(function({editor:e,umlClass:n,editing:r}){let[,h]=react.useState(0);G(),react.useEffect(()=>{if(!e)return;let g=e.subscribe(()=>h(R=>R+1));return ()=>{g();}},[e]);let[d,s]=react.useState(null),[l,S]=react.useState(false),f=react.useRef(null),u=react.useRef(null),w=react.useCallback((g,R)=>{f.current&&(clearTimeout(f.current),f.current=null),s({section:g,rowId:R}),S(false);},[]),I=react.useCallback(()=>{f.current&&clearTimeout(f.current),f.current=window.setTimeout(()=>{s(null),S(false);},150);},[]);if(!e||!n||r!==n.id)return null;let z=e.getCamera(),{id:C,x:B,y:p,width:A,height:L,className:se,methods:i}=n,x=n.type==="uml-interface",y=x?[]:n.attributes,j=A/2,O=L/2,_=drawuiCore.UML_HEADER_HEIGHT,X=drawuiCore.UML_LINE_HEIGHT,de=drawuiCore.UML_PADDING_X,Q=drawuiCore.UML_PADDING_Y,fe=x?0:y.length>0?y.length*X+Q*2:Q*2,b=z.zoom,ee=(A-de*2)*b,Le=4*b,re=z.pageToScreen({x:B-j+de,y:p}),Me=z.pageToScreen({x:B,y:p-O+_/2}),P=g=>z.pageToScreen({x:B,y:g}).y,ue=X*b,le=g=>p+(-O+_+Q+X/2+g*X),Se=g=>p+(-O+_+fe+Q+X/2+g*X),me=p+(-O+_+fe),Ne=p+O,Re={background:"#ffffff",borderWidth:1,borderStyle:"solid",borderColor:"transparent",outline:"none",padding:0,fontFamily:"sans-serif",boxSizing:"border-box"},Te=(g,R)=>{let H=y.find(a=>a.id===g);if(!H)return;let D=Ro(R,"attribute",H.visibility);e.updateUmlClass(C,{attributes:y.map(a=>a.id===g?{...a,...D}:a)});},$=(g,R)=>{let H=i.find(N=>N.id===g);if(!H)return;let D=Ro(R,"method",H.visibility),a=i.map(N=>N.id===g?{...N,...D}:N);x?e.updateUmlInterface(C,{methods:a}):e.updateUmlClass(C,{methods:a});},v=(g,R,H)=>{u.current={section:g,from:R},H.dataTransfer.effectAllowed="move",H.dataTransfer.setData("text/plain",`${g}:${R}`);},ae=g=>{g.preventDefault(),g.dataTransfer.dropEffect="move";},Y=(g,R,H)=>{H.preventDefault();let D=u.current;!D||D.section!==g||(g==="attribute"?e.reorderUmlAttribute(C,D.from,R):e.reorderUmlMethod(C,D.from,R),u.current=null);},q=(g,R,H,D)=>{let a=P(D),N=d?.section===g&&d.rowId===H.id,pe=(H.fontSize||drawuiCore.UML_FONT_SIZE)*b,ge=H.textColor||"#1f2937",we={position:"absolute",left:re.x-Vt*b-Le,top:a-ue/2,width:Vt*b+Le+ee+Io*b,height:ue,display:"flex",alignItems:"center",gap:2,pointerEvents:"none",zIndex:53},Ee={...Re,width:ee,height:ue-2,fontSize:pe,color:ge,textDecoration:H.strikethrough?"line-through":"none",pointerEvents:"auto",...N?{borderColor:"var(--dw-primary)"}:{}},Xe={width:Vt*b,height:ue-2,cursor:"grab",color:"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",fontSize:12*b,lineHeight:1,opacity:N?1:.55,pointerEvents:"auto"},c={width:Io*b,height:ue-6,border:"none",background:"transparent",color:"#9ca3af",cursor:"pointer",borderRadius:3,fontSize:14*b,opacity:N?1:.35,pointerEvents:"auto"};return jsxRuntime.jsxs("div",{style:we,onDragOver:ae,onDrop:M=>Y(g,R,M),children:[jsxRuntime.jsx("span",{style:Xe,draggable:true,onDragStart:M=>v(g,R,M),"data-drawui-tip":drawuiCore.t("uml.drag"),children:"\u22EE\u22EE"}),jsxRuntime.jsx("input",{style:Ee,value:Pn(g,H),onChange:M=>g==="attribute"?Te(H.id,M.target.value):$(H.id,M.target.value),onFocus:()=>w(g,H.id),onBlur:I,spellCheck:false}),jsxRuntime.jsx("button",{style:c,onMouseDown:M=>M.preventDefault(),onClick:()=>{g==="attribute"?e.removeUmlAttribute(C,H.id):e.removeUmlMethod(C,H.id);},"data-drawui-tip":drawuiCore.t("uml.delete"),children:"\xD7"})]},H.id)},W=(g,R,H)=>{let D=P(R),a=g==="attribute";return jsxRuntime.jsxs("button",{onMouseDown:N=>N.preventDefault(),onClick:()=>a?e.addUmlAttribute(C):e.addUmlMethod(C),className:"drawui-uml-add-row",style:{position:"absolute",left:re.x,top:D-9*b,height:18*b,padding:`0 ${6*b}px`,fontSize:11*b,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},"data-drawui-tip":H,children:[jsxRuntime.jsx("span",{style:{fontSize:13*b,lineHeight:1},children:"+"}),jsxRuntime.jsx("span",{children:H})]},`add-${g}`)},He=()=>{if(!d||d.section==="className")return null;let g=d.section,R=d.rowId,D=(g==="attribute"?y:i).find(E=>E.id===R);if(!D)return null;let a=224*b,N=30*b,pe=z.pageToScreen({x:B,y:p}).x,ge=z.pageToScreen({x:B,y:p-O}).y,we=20*b,Ee=ge-N-we,Xe=pe-a/2,c=Ee+N,M=D.textColor||"#1f2937",m=D.fontSize||drawuiCore.UML_FONT_SIZE,K=!!D.strikethrough;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:pe-.5,top:c,width:1,height:we,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),jsxRuntime.jsxs("div",{className:"drawui-uml-toolbar",style:{position:"absolute",left:Xe,top:Ee,width:a,height:N,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:6,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",gap:4*b,padding:`0 ${6*b}px`,pointerEvents:"auto",zIndex:60,fontSize:12*b},onMouseDown:E=>E.preventDefault(),children:[jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{onClick:()=>S(E=>!E),className:"drawui-uml-toolbar-btn","data-drawui-tip":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:M,fontSize:13*b,textDecoration:K?"line-through":"none"},children:"A"}),jsxRuntime.jsx("span",{style:{width:10*b,height:2*b,background:M,marginLeft:3,borderRadius:1}})]}),l&&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,g,D.id,{textColor:null}),S(false);},style:{width:14,height:14,border:"1px solid #e5e7eb",background:"transparent",cursor:"pointer",borderRadius:2},"data-drawui-tip":drawuiCore.t("uml.defaultColor")}),Rn.map(E=>jsxRuntime.jsx("button",{onClick:()=>{e.updateUmlRowStyle(C,g,D.id,{textColor:E}),S(false);},style:{width:14,height:14,border:"none",background:E,cursor:"pointer",borderRadius:2},"data-drawui-tip":E},E))]})]}),jsxRuntime.jsx("select",{value:m,onChange:E=>e.updateUmlRowStyle(C,g,D.id,{fontSize:Number(E.target.value)}),style:{border:"1px solid #e5e7eb",borderRadius:3,padding:`0 ${2*b}px`,fontSize:12*b,height:20*b,background:"#ffffff"},"data-drawui-tip":drawuiCore.t("uml.fontSize"),children:Hn.map(E=>jsxRuntime.jsx("option",{value:E,children:E},E))}),jsxRuntime.jsx("button",{onClick:()=>e.updateUmlRowStyle(C,g,D.id,{strikethrough:!K}),className:"drawui-uml-toolbar-btn","data-drawui-tip":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*b,textDecoration:"line-through"},children:"A"})}),jsxRuntime.jsx("button",{onClick:()=>{g==="attribute"?e.removeUmlAttribute(C,D.id):e.removeUmlMethod(C,D.id),s(null);},className:"drawui-uml-toolbar-btn","data-drawui-tip":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*b,height:14*b,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"})]})})]})]})},te=z.pageToScreen({x:B-j,y:p}).x,U=z.pageToScreen({x:B,y:p-O}).y,ze=A*b,Ze=L*b;return jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:te+1,top:U+1,width:Math.max(0,ze-2),height:Math.max(0,Ze-2),background:"#ffffff",pointerEvents:"none",zIndex:51}}),jsxRuntime.jsx("input",{style:{...Re,position:"absolute",left:Me.x-ee/2,top:Me.y-_*b/2+2,width:ee,height:_*b-4,textAlign:"center",fontWeight:700,fontSize:(n.fontSize||drawuiCore.UML_FONT_SIZE)*b,color:n.textColor||"#1f2937",pointerEvents:"auto",zIndex:52,...d?.section==="className"?{borderColor:"var(--dw-primary)"}:{}},value:se,onChange:g=>x?e.updateUmlInterface(C,{className:g.target.value}):e.updateUmlClass(C,{className:g.target.value}),onFocus:()=>w("className",""),onBlur:I,spellCheck:false}),!x&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[y.map((g,R)=>q("attribute",R,g,le(R))),W("attribute",me,"\u5C5E\u6027")]}),i.map((g,R)=>q("method",R,g,Se(R))),W("method",Ne,drawuiCore.t("uml.method")),He()]})});var Ao=react.memo(function({editor:e,panelOpen:n,onOpenPanel:r}){let[,h]=react.useState(0);G(),react.useEffect(()=>{if(!e)return;let A=e.subscribe(()=>h(L=>L+1));return ()=>{A();}},[e]);let d=react.useRef(false),s=react.useRef(false);if(!e)return null;let l=e.getMindMapEditingShapeId();if(!l||n)return null;let S=e.getMindMapSelectedNode();if(!S||S.shapeId!==l)return null;let f=e.getMindMapNode(l,S.nodeId),u=e.getMindMapNodeScreenRect(l,S.nodeId);if(!f||!u)return null;let w=e.getCamera().getZoom(),I=drawuiCore.MINDMAP_FONT_SIZE*w,z=Math.max(100,u.width+24),C=u.height+8,B={position:"absolute",left:u.x+u.width/2,top:u.y-4,transform:"translateX(-50%)",width:z,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 ${(f.icon?24:12)*w}px`,fontFamily:"sans-serif",fontSize:I,color:"#1f2937",boxSizing:"border-box",pointerEvents:"auto",zIndex:55},p={position:"absolute",left:u.x+u.width+12,top:u.y+u.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:B,value:f.text,spellCheck:false,onChange:A=>{let L=!d.current;d.current=true,e.updateMindMapNode(l,S.nodeId,{text:A.target.value},L);},onBlur:()=>{if(s.current){s.current=false;return}e.exitMindMapEdit();},onKeyDown:A=>{A.key==="Enter"?A.target.blur():A.key==="Escape"&&e.exitMindMapEdit();}}),jsxRuntime.jsx("button",{style:p,"data-drawui-tip":drawuiCore.t("mindmap.more"),onMouseDown:A=>{A.preventDefault(),s.current=true,setTimeout(()=>{s.current=false;},300);},onClick:r,children:"\u22EF"})]})});var $o=[...drawuiCore.MINDMAP_COLORS,"#1f2937","#9ca3af"],Do=["\u{1F4A1}","\u2B50","\u{1F525}","\u{1F4CC}","\u2705","\u2757","\u26A0\uFE0F","\u{1F3F7}\uFE0F"],Fn={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"},Yt={fontSize:11,color:"#6b7280",marginBottom:4,display:"block"},kt={display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},Mt={border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:5,padding:"3px 8px",fontSize:12,color:"#374151",cursor:"pointer",lineHeight:1.5},jt={width:"100%",border:"1px solid #e5e7eb",borderRadius:5,padding:"4px 8px",fontSize:12,outline:"none",boxSizing:"border-box",background:"#ffffff",color:"#1f2937"},zo=react.memo(function({editor:e,mindMap:n}){let[,r]=react.useState(0);G(),react.useEffect(()=>{if(!e)return;let i=e.subscribe(()=>r(x=>x+1));return ()=>{i();}},[e]);let h=react.useRef(null);if(!e||!n||e.getMindMapEditingShapeId()!==n.id)return null;let d=e.getMindMapSelectedNode();if(!d||d.shapeId!==n.id)return null;let s=i=>{if(i.id===d.nodeId)return i;for(let x of i.children??[]){let y=s(x);if(y)return y}return null},l=s(n.root);if(!l)return null;let S=e.getCamera(),u=drawuiCore.layoutMindMap(n.root).positions.get(l.id);if(!u)return null;let w=S.zoom,I=S.pageToScreen({x:n.x+u.x,y:n.y+u.y}),z=I.x+u.width*w/2+14,C=I.y-80,p=Math.max(8,Math.min(z,(window.innerWidth||1024)-232-8)),A=Math.max(8,Math.min(C,(window.innerHeight||768)-320)),L=i=>{e.updateMindMapNode(n.id,l.id,i);},se=!!l.id&&l.id!==n.root.id;return jsxRuntime.jsxs("div",{ref:h,style:{...Fn,left:p,top:A},onMouseDown:i=>i.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(),"data-drawui-tip":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:{...jt,marginBottom:8},value:l.text,onChange:i=>L({text:i.target.value}),spellCheck:false}),jsxRuntime.jsxs("div",{style:{...kt,marginBottom:10},children:[jsxRuntime.jsxs("button",{style:Mt,onClick:()=>e.addMindMapChild(n.id,l.id),children:["+ ",drawuiCore.t("mindmap.addChild")]}),se&&jsxRuntime.jsxs("button",{style:Mt,onClick:()=>e.addMindMapSibling(n.id,l.id),children:["+ ",drawuiCore.t("mindmap.addSibling")]}),!!l.children?.length&&jsxRuntime.jsx("button",{style:Mt,onClick:()=>e.toggleMindMapCollapse(n.id,l.id),children:l.collapsed?drawuiCore.t("mindmap.expand"):drawuiCore.t("mindmap.collapse")}),jsxRuntime.jsx("button",{style:{...Mt,color:"#ef4444",borderColor:"#fecaca",marginLeft:"auto"},onClick:()=>e.deleteMindMapNode(n.id,l.id),children:drawuiCore.t("mindmap.deleteNode")})]}),jsxRuntime.jsx("span",{style:Yt,children:drawuiCore.t("mindmap.color")}),jsxRuntime.jsxs("div",{style:{...kt,marginBottom:10},children:[jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.levelColor"),onClick:()=>L({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}}),$o.map(i=>jsxRuntime.jsx("button",{"data-drawui-tip":i,onClick:()=>L({color:i}),style:{width:18,height:18,borderRadius:4,border:l.color===i?"2px solid #111827":"1px solid #d1d5db",background:i,cursor:"pointer",flexShrink:0}},i))]}),jsxRuntime.jsx("span",{style:Yt,children:drawuiCore.t("mindmap.icon")}),jsxRuntime.jsxs("div",{style:{...kt,marginBottom:10},children:[jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.noIcon"),onClick:()=>L({icon:void 0}),style:{width:22,height:22,borderRadius:4,border:l.icon?"1px solid #d1d5db":"2px solid #111827",background:"#f9fafb",cursor:"pointer",fontSize:11,color:"#9ca3af",lineHeight:1},children:"\u2205"}),Do.map(i=>jsxRuntime.jsx("button",{onClick:()=>L({icon:i}),style:{width:22,height:22,borderRadius:4,border:l.icon===i?"2px solid #111827":"1px solid #d1d5db",background:"#f9fafb",cursor:"pointer",fontSize:13,lineHeight:1},children:i},i)),jsxRuntime.jsx("input",{placeholder:"\u270F\uFE0F",defaultValue:l.icon&&!Do.includes(l.icon)?l.icon:"",onKeyDown:i=>{if(i.key==="Enter"){let x=i.target.value.trim();L({icon:x||void 0});}},onBlur:i=>{let x=i.target.value.trim();x!==l.icon&&L({icon:x||void 0});},style:{...jt,width:56,padding:"2px 4px",textAlign:"center"}})]}),jsxRuntime.jsx("span",{style:Yt,children:drawuiCore.t("mindmap.note")}),jsxRuntime.jsx("input",{style:{...jt,marginBottom:6},value:l.note??"",placeholder:drawuiCore.t("mindmap.notePlaceholder"),onChange:i=>L({note:i.target.value||void 0}),spellCheck:false}),!!l.note&&jsxRuntime.jsxs("div",{style:{...kt,marginTop:4},children:[jsxRuntime.jsx("span",{style:{fontSize:11,color:"#6b7280"},children:drawuiCore.t("mindmap.noteColor")}),jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.noteColorDefault"),onClick:()=>L({noteColor:void 0}),style:{width:16,height:16,borderRadius:3,border:l.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"}}),$o.map(i=>jsxRuntime.jsx("button",{onClick:()=>L({noteColor:i}),style:{width:16,height:16,borderRadius:3,border:l.noteColor===i?"2px solid #111827":"1px solid #d1d5db",background:i,cursor:"pointer"}},i))]})]})});var qt=220,Jt=140,qn="#fafafa";function Jn(o,e){let n=Math.min(o.x,e.x),r=Math.min(o.y,e.y),h=Math.max(o.x+o.width,e.x+e.width),d=Math.max(o.y+o.height,e.y+e.height);return {x:n,y:r,width:h-n,height:d-r}}function Qn(o){return {x:o.x+o.width/2,y:o.y+o.height/2}}function er(){return {x:0,y:0,width:0,height:0}}function tr(o){let e=1/0,n=1/0,r=-1/0,h=-1/0,d=false;for(let s of o){let l=eo(s);l&&(d=true,l.x<e&&(e=l.x),l.y<n&&(n=l.y),l.x+l.width>r&&(r=l.x+l.width),l.y+l.height>h&&(h=l.y+l.height));}return d?{x:e,y:n,width:r-e,height:h-n}:null}function eo(o){switch(o.type){case "rectangle":case "sticky-note":case "icon":case "rounded-rectangle":case "ellipse":case "diamond":case "triangle":case "hexagon":case "parallelogram":case "trapezoid":case "pentagon":case "octagon":case "star":case "cylinder":case "cloud":case "heart":case "block-arrow-right":case "block-arrow-left":case "block-arrow-up":case "block-arrow-down":case "block-arrow-double":case "right-triangle":case "cross":case "speech-rect":case "speech-round":case "cube":case "sector":case "delay":case "predefined-process":case "document":case "stadium":case "class-catalog":case "chevron":case "brace-left":case "brace-right":case "envelope":case "checkbox":case "triangular-pyramid":case "quadrangular-pyramid":case "cuboid":case "sphere":case "ellipsoid":case "pie":case "hollow-pie":case "uml-class":case "uml-interface":case "mind-map":case "text":return {x:o.x-o.width/2,y:o.y-o.height/2,width:o.width,height:o.height};case "circle":return {x:o.x-o.radius,y:o.y-o.radius,width:o.radius*2,height:o.radius*2};case "line":case "arrow":{let e=o.points;if(!e||e.length===0)return null;let n=1/0,r=1/0,h=-1/0,d=-1/0;for(let s of e)s.x<n&&(n=s.x),s.y<r&&(r=s.y),s.x>h&&(h=s.x),s.y>d&&(d=s.y);return {x:n,y:r,width:h-n,height:d-r}}case "draw":{let e=o,n=e.width,r=e.height;if(typeof n=="number"&&typeof r=="number")return {x:e.x-n/2,y:e.y-r/2,width:n,height:r};let h=e.points;if(!h||h.length===0)return null;let d=1/0,s=1/0,l=-1/0,S=-1/0;for(let f of h){let u=f.x+e.x,w=f.y+e.y;u<d&&(d=u),w<s&&(s=w),u>l&&(l=u),w>S&&(S=w);}return {x:d,y:s,width:l-d,height:S-s}}default:return null}}function or(o){let e=o.getCamera(),n=e.screenToPage({x:0,y:0}),r=e.screenToPage({x:window.innerWidth,y:window.innerHeight});return {x:n.x,y:n.y,width:r.x-n.x,height:r.y-n.y}}function nr(o,e,n){if(o.width<=0||o.height<=0)return {x:o.x-e/2,y:o.y-n/2,width:e,height:n};let r=e/n,h=o.width,d=h/r;d<o.height&&(d=o.height,h=d*r);let s=Qn(o);return {x:s.x-h/2,y:s.y-d/2,width:h,height:d}}function Qt(o,e,n,r){let h=(o-n.left)/n.width,d=(e-n.top)/n.height;return {x:r.x+h*r.width,y:r.y+d*r.height}}var Uo=react.memo(function({editor:e}){let n=react.useRef(null),r=react.useRef(null),[h,d]=react.useState(false),[s,l]=react.useState(100),[S,f]=react.useState(false),[u,w]=react.useState(false);G();let I=react.useRef(null),z=react.useRef(null);react.useLayoutEffect(()=>{let i=n.current,x=r.current;if(!i||!x)return;let y=window.devicePixelRatio||1;i.width=Math.round(qt*y),i.height=Math.round(Jt*y),i.style.width=`${qt}px`,i.style.height=`${Jt}px`;},[h]);let C=react.useCallback(()=>{let i=n.current,x=r.current;if(!i||!x||!e)return;let y=i.getContext("2d");if(!y)return;let j=qt,O=Jt,_=i.width,X=i.height,de=e.getShapes(),Q=new Set(e.getSelectedIds()),fe=drawuiCore.getTheme(),b=drawuiCore.hexToRgba(fe.text,.16),ee=fe.primary,Le=drawuiCore.hexToRgba(fe.primary,.18),re=drawuiCore.hexToRgba(fe.primary,.85),Me=tr(de),P=or(e),ue=Me?Jn(Me,P):P.width>0?P:er(),le=nr(ue,j,O);z.current=le;let Se=_/le.width,me=X/le.height,Ne=j/le.width;y.setTransform(1,0,0,1,0,0),y.fillStyle=qn,y.fillRect(0,0,_,X),y.setTransform(Se,0,0,me,-Se*le.x,-me*le.y),y.fillStyle=b;for(let $ of de){let v=eo($);v&&y.fillRect(v.x,v.y,v.width,v.height);}y.fillStyle=ee;for(let $ of de){if(!Q.has($.id))continue;let v=eo($);v&&y.fillRect(v.x,v.y,v.width,v.height);}y.fillStyle=Le,y.fillRect(P.x,P.y,P.width,P.height);let Re=1.5/Ne;y.strokeStyle=re,y.lineWidth=Re,y.lineJoin="round";let Te=Math.min(P.width/6,P.height/6,6/Ne);if(y.beginPath(),Te*Ne<1)y.rect(P.x,P.y,P.width,P.height);else {let $=P.x,v=P.y,ae=P.width,Y=P.height,q=Math.min(Te,ae/2,Y/2);y.moveTo($+q,v),y.lineTo($+ae-q,v),y.quadraticCurveTo($+ae,v,$+ae,v+q),y.lineTo($+ae,v+Y-q),y.quadraticCurveTo($+ae,v+Y,$+ae-q,v+Y),y.lineTo($+q,v+Y),y.quadraticCurveTo($,v+Y,$,v+Y-q),y.lineTo($,v+q),y.quadraticCurveTo($,v,$+q,v),y.closePath();}y.stroke(),y.setTransform(1,0,0,1,0,0);},[e]);react.useEffect(()=>{if(!e||h)return;C();let i=e.subscribe(C),x=drawuiCore.subscribeTheme(C),y=()=>C();return window.addEventListener("resize",y),()=>{i(),x(),window.removeEventListener("resize",y);}},[e,h,C]),react.useEffect(()=>{if(!e)return;let i=()=>{let y=e.getCamera().getZoom();l(Math.round(y*100));};i();let x=e.subscribe(i);return ()=>{x();}},[e]);let B=react.useCallback((i,x)=>{if(!e)return;let y=e.getCamera(),j=y.getZoom(),O=window.innerWidth/2,_=window.innerHeight/2,X=y;X.x=O-i*j,X.y=_-x*j,e.requestRender();},[e]),p=i=>{if(!e||!r.current||i.button!==0)return;let x=r.current.getBoundingClientRect(),y=z.current;if(!y)return;let j=Qt(i.clientX,i.clientY,x,y);I.current={pointerId:i.pointerId,rect:{left:x.left,top:x.top,width:x.width,height:x.height},canvasBox:y},i.currentTarget.setPointerCapture(i.pointerId),w(true),B(j.x,j.y);},A=i=>{if(!u||!e||!I.current||!r.current)return;let x=I.current,y=Qt(i.clientX,i.clientY,x.rect,x.canvasBox);B(y.x,y.y);},L=i=>{if(u){w(false),I.current=null;try{i.currentTarget.releasePointerCapture(i.pointerId);}catch{}}},se=i=>{if(!e||!r.current)return;let x=z.current;if(!x)return;let y=r.current.getBoundingClientRect(),j=Qt(i.clientX,i.clientY,y,x);B(j.x,j.y);};return jsxRuntime.jsxs("div",{className:`drawui-minimap ${h?"collapsed":""}`,children:[jsxRuntime.jsx("button",{className:"drawui-minimap-toggle",onClick:()=>d(i=>!i),"data-drawui-tip":h?drawuiCore.t("minimap.expand"):drawuiCore.t("minimap.collapse"),"data-drawui-tip-pos":"top","aria-label":h?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:h?jsxRuntime.jsx("polyline",{points:"9 6 15 12 9 18"}):jsxRuntime.jsx("polyline",{points:"15 6 9 12 15 18"})})}),!h&&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:[s,"%"]})]}),jsxRuntime.jsx("div",{ref:r,className:"drawui-minimap-canvas-wrap",style:{cursor:u?"grabbing":S?"pointer":"default"},onPointerEnter:()=>f(true),onPointerLeave:()=>f(false),children:jsxRuntime.jsx("canvas",{ref:n,className:"drawui-minimap-canvas",onPointerDown:p,onPointerMove:A,onPointerUp:L,onPointerCancel:L,onDoubleClick:se})})]})]})});var ye=o=>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:o}),ir=[{type:"rectangle",labelKey:"shape.rectangle",glyph:ye(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:ye(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:ye(jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:ye(jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:ye(jsxRuntime.jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:ye(jsxRuntime.jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:ye(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:ye(jsxRuntime.jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:ye(jsxRuntime.jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:ye(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:ye(jsxRuntime.jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:ye(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:"sticky-note",labelKey:"shape.sticky-note",glyph:ye(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsxRuntime.jsx("path",{d:"M20 15h-5v5"})]}))},{type:"uml-class",labelKey:"shape.uml-class",glyph:ye(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:ye(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:ye(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 Wo({editor:o,x:e,y:n,context:r,existingArrowId:h,defaultShapeType:d,onClose:s}){let l=react.useRef(null);G();let S=f=>{o?.createGeneratedConnection(r,{type:f,existingArrowId:h}),s();};return react.useEffect(()=>{let f=I=>{l.current&&!l.current.contains(I.target)&&s();},u=I=>{I.key==="Escape"&&(I.preventDefault(),s());},w=setTimeout(()=>{window.addEventListener("pointerdown",f,true),window.addEventListener("keydown",u,true);},0);return ()=>{clearTimeout(w),window.removeEventListener("pointerdown",f,true),window.removeEventListener("keydown",u,true);}},[s]),jsxRuntime.jsxs("div",{className:"drawui-gen-menu",ref:l,style:{left:e,top:n},children:[jsxRuntime.jsx("div",{className:"drawui-gen-menu-label",children:drawuiCore.t("menu.title")}),jsxRuntime.jsx("div",{className:"drawui-gen-shape-grid",children:ir.map(f=>jsxRuntime.jsxs("button",{className:`drawui-gen-shape-btn${f.type===d?" drawui-gen-shape-active":""}`,onClick:()=>S(f.type),"data-drawui-tip":drawuiCore.t(f.labelKey),children:[f.glyph,jsxRuntime.jsx("span",{className:"drawui-gen-shape-label",children:drawuiCore.t(f.labelKey)})]},f.type))}),jsxRuntime.jsx("div",{className:"drawui-gen-menu-hint",children:drawuiCore.t("menu.cancel")})]})}var dr={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",cylinder:"tool.cylinder",cloud:"tool.cloud",heart:"tool.heart","block-arrow-right":"tool.block-arrow-right","block-arrow-left":"tool.block-arrow-left","block-arrow-up":"tool.block-arrow-up","block-arrow-down":"tool.block-arrow-down","block-arrow-double":"tool.block-arrow-double","right-triangle":"tool.right-triangle",cross:"tool.cross","speech-rect":"tool.speech-rect","speech-round":"tool.speech-round",cube:"tool.cube",sector:"tool.sector",delay:"tool.delay","predefined-process":"tool.predefined-process",document:"tool.document",stadium:"tool.stadium","class-catalog":"tool.class-catalog",chevron:"tool.chevron","brace-left":"tool.brace-left","brace-right":"tool.brace-right",envelope:"tool.envelope",checkbox:"tool.checkbox","sticky-note":"tool.sticky-note",icon:"toolbar.icon","triangular-pyramid":"tool.triangular-pyramid","quadrangular-pyramid":"tool.quadrangular-pyramid",cuboid:"tool.cuboid",sphere:"tool.sphere",ellipsoid:"tool.ellipsoid",pie:"tool.pie","hollow-pie":"tool.hollow-pie","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 ur({initialTool:o="select",className:e="",themeColor:n,language:r="zh-CN",data:h,onChange:d,onReady:s}){let l=react.useRef(null),S=react.useRef(null),f=react.useRef(null),[u,w]=react.useState(null);G();let[I,z]=react.useState(o),[C,B]=react.useState(false),[p,A]=react.useState(0),[L,se]=react.useState(false),[i,x]=react.useState("straight"),[y,j]=react.useState("end"),[O,_]=react.useState(false),[X,de]=react.useState(void 0),[Q,fe]=react.useState(100),[b,ee]=react.useState(null),[Le,re]=react.useState(null),[Me,P]=react.useState(false),[ue,le]=react.useState(false),[Se,me]=react.useState(null),[Ne,Re]=react.useState(null),[Te,$]=react.useState(false),[v,ae]=react.useState(null),[Y,q]=react.useState(null),W=react.useRef(null),He=react.useRef(0),te=react.useRef(null),U=react.useRef(d);U.current=d;let ze=react.useRef(s);ze.current=s,react.useEffect(()=>{if(!l.current)return;let m=new drawuiCore.Editor(l.current,{theme:n?{primary:n,editBorder:n,selection:{outline:n,handleStroke:n,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(n,.1),shadow:n}}:void 0,language:r,shapes:h,persist:!h});f.current=m,w(m),window.__drawuiEditor=m,m.setHighlighterColor(ht()),m.setStickyNoteColor(yt()),ze.current?.(m),o&&m.setActiveTool(o);let K=m.subscribe(()=>{z(m.getActiveTool());let ie=m.getSelectedIds();A(ie.length);let xe=m.getShapes().filter(Ke=>ie.includes(Ke.id)&&(Ke.type==="line"||Ke.type==="arrow"));if(se(xe.length>0),xe.length>0&&xe[0].connectionType?x(xe[0].connectionType):xe.length>0&&x("straight"),xe.length>0){let Ke=xe.find(It=>It.type==="arrow");Ke&&(j(Ke.arrowHead??"end"),_(Ke.dashed??false));}fe(Math.round(m.getCamera().getZoom()*100)),de(m.getArrowStyle()),P(m.canUndo()),le(m.canRedo());let Pe=m.getSelectedUml();me(Pe),Pe||ae(null);let pt=m.getSelectedMindMap();Re(pt),m.getMindMapEditingShapeId()||$(false),U.current?.(m.getData());}),E=m.subscribeNotifications(ie=>{re({type:"success",text:ie}),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>re(null),3500);}),qe=m.subscribeUi(ie=>{ie.kind==="shapeTypeMenu"&&q({x:ie.screenX,y:ie.screenY,context:ie.context,existingArrowId:ie.existingArrowId,defaultShapeType:ie.defaultShapeType});});return ()=>{K(),E(),qe(),W.current&&clearTimeout(W.current),cancelAnimationFrame(He.current),m.dispose();}},[o]),react.useEffect(()=>{if(!n)return;let m=S.current;m&&(m.style.setProperty("--dw-primary",n),m.style.setProperty("--dw-primary-hover",drawuiCore.shadeColor(n,-0.12)),m.style.setProperty("--dw-primary-weak",drawuiCore.hexToRgba(n,.1)),m.style.setProperty("--dw-primary-contrast","#ffffff"),m.style.setProperty("--dw-shadow-primary",`0 2px 8px ${drawuiCore.hexToRgba(n,.3)}`)),f.current?.setTheme({primary:n,editBorder:n,selection:{outline:n,handleStroke:n,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(n,.1),shadow:n}});},[n]),react.useEffect(()=>{drawuiCore.setLanguage(r),f.current?.setLanguage(r);},[r]);let Ze=react.useCallback(m=>{f.current?.setActiveTool(m);},[]),g=react.useCallback(()=>{f.current?.zoomIn();},[]),R=react.useCallback(()=>{f.current?.zoomOut();},[]),H=react.useCallback(()=>{f.current?.resetZoom();},[]),D=react.useCallback(()=>{let m=!C;B(m),f.current?.setShowGrid(m);},[C]),a=react.useCallback(()=>{f.current?.undo();},[]),N=react.useCallback(()=>{f.current?.redo();},[]),pe=react.useCallback(m=>{f.current?.downloadImage("drawui",m,{background:"#ffffff"});},[]),ge=react.useCallback(()=>{f.current?.downloadJSON("drawui-data");},[]),we=react.useCallback(m=>{let K=new FileReader;K.onload=()=>{let E=typeof K.result=="string"?K.result:"";if(f.current?.importJSON(E)??false){let ie=f.current?.getShapes().length??0;re({type:"success",text:drawuiCore.t("import.success",{n:ie})});}else re({type:"error",text:drawuiCore.t("import.fail")});W.current&&clearTimeout(W.current),W.current=setTimeout(()=>re(null),3500);},K.onerror=()=>{re({type:"error",text:drawuiCore.t("import.fail")}),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>re(null),3500);},K.readAsText(m,"utf-8");},[]),Ee=react.useCallback(m=>{let K=f.current,E=l.current;if(!K||!E)return;if(K.isPointerDown()){te.current!==null&&(te.current=null,ee(null));return}let qe=m.clientX,ie=m.clientY;cancelAnimationFrame(He.current),He.current=requestAnimationFrame(()=>{let et=E.getBoundingClientRect(),xe=qe-et.left,Pe=ie-et.top,pt=xe+12,Ke=Pe+12,It=K.getSelectedUml()?.id,tt=K.getUmlRowAtScreenPoint({x:xe,y:Pe});if(tt&&tt.shape.id!==It&&tt.text){te.current!==tt.text&&(te.current=tt.text,ee({text:tt.text,x:pt,y:Ke}));return}let it=K.getShapeAtScreenPoint({x:xe,y:Pe});it&&it.text?te.current!==it.text&&(te.current=it.text,ee({text:it.text,x:pt,y:Ke})):te.current!==null&&(te.current=null,ee(null));});},[]),Xe=react.useCallback(()=>{ee(null);},[]),c=react.useCallback(m=>{let K=f.current,E=l.current;if(!K||!E)return;let qe=E.getBoundingClientRect(),ie=m.clientX-qe.left,et=m.clientY-qe.top,xe=K.getUmlRowAtScreenPoint({x:ie,y:et});if(xe){ae(xe.shape.id);return}let Pe=K.getMindMapNodeAtScreenPoint({x:ie,y:et});Pe&&K.beginMindMapEdit(Pe.shapeId,Pe.nodeId);},[]),M=react.useCallback(()=>{q(null);},[]);return jsxRuntime.jsxs("div",{ref:S,className:`drawui-canvas-board ${e}`,children:[jsxRuntime.jsx("canvas",{ref:l,className:"drawui-canvas",onMouseMove:Ee,onMouseLeave:Xe,onDoubleClick:c}),b&&jsxRuntime.jsx("div",{className:"drawui-tooltip",style:{left:b.x,top:b.y},children:b.text}),jsxRuntime.jsx(Bt,{activeTool:I,onToolChange:Ze,showGrid:C,onToggleGrid:D,canUndo:Me,canRedo:ue,onUndo:a,onRedo:N,onExport:pe,onExportData:ge,onImportData:we,onHighlighterColorChange:m=>f.current?.setHighlighterColor(m),onStickyNoteColorChange:m=>f.current?.setStickyNoteColor(m),onInsertIcon:m=>f.current?.insertIcon(m),arrowStyle:X,onArrowStyleChange:m=>f.current?.setArrowStyle(m)}),jsxRuntime.jsx(Ut,{onZoomIn:g,onZoomOut:R,onReset:H,zoomLevel:Q}),jsxRuntime.jsx(To,{editor:u,selectedCount:p,hasLineSelection:L,currentConnectionType:i,currentArrowHead:y,currentDashed:O}),jsxRuntime.jsx(Po,{editor:u,umlClass:Se,editing:v}),jsxRuntime.jsx(Ao,{editor:u,panelOpen:Te,onOpenPanel:()=>$(true)}),Te&&jsxRuntime.jsx(zo,{editor:u,mindMap:Ne}),jsxRuntime.jsx(Uo,{editor:u}),Y&&jsxRuntime.jsx(Wo,{editor:u,x:Y.x,y:Y.y,context:Y.context,existingArrowId:Y.existingArrowId,defaultShapeType:Y.defaultShapeType,onClose:M}),jsxRuntime.jsxs("div",{className:"drawui-status-bar",children:[jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:drawuiCore.t(dr[I])})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:p===0?drawuiCore.t("status.none"):drawuiCore.t("status.selected",{n:p})})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsxs("span",{children:[Q,"%"]})})]}),Le&&jsxRuntime.jsxs("div",{className:"drawui-toast",children:[Le.type==="success"?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"})}):jsxRuntime.jsxs("svg",{className:"drawui-toast-icon drawui-toast-icon-error",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),Le.text]})]})}exports.CanvasBoard=ur;exports.Toolbar=Bt;exports.ZoomControl=Ut;
|
package/dist/index.d.cts
CHANGED
|
@@ -28,8 +28,16 @@ interface ToolbarProps {
|
|
|
28
28
|
onUndo?: () => void;
|
|
29
29
|
onRedo?: () => void;
|
|
30
30
|
onExport?: (format: ExportFormat) => void;
|
|
31
|
+
/** 导出完整数据(下载 .json 文件) */
|
|
32
|
+
onExportData?: () => void;
|
|
33
|
+
/** 导入完整数据(用户选择 .json 文件后回调) */
|
|
34
|
+
onImportData?: (file: File) => void;
|
|
31
35
|
/** 荧光笔选色后回调(宿主据此同步给 editor) */
|
|
32
36
|
onHighlighterColorChange?: (color: string) => void;
|
|
37
|
+
/** 便签纸面色选好后回调(宿主据此同步给 editor,新建便签就用这个色) */
|
|
38
|
+
onStickyNoteColorChange?: (color: string) => void;
|
|
39
|
+
/** 从图标库面板选了一个图标:宿主负责插入画布 */
|
|
40
|
+
onInsertIcon?: (iconId: string) => void;
|
|
33
41
|
/** 新建箭头的默认样式(工具栏「箭头」下拉里展示/修改) */
|
|
34
42
|
arrowStyle?: ArrowStyle;
|
|
35
43
|
onArrowStyleChange?: (updates: Partial<ArrowStyle>) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -28,8 +28,16 @@ interface ToolbarProps {
|
|
|
28
28
|
onUndo?: () => void;
|
|
29
29
|
onRedo?: () => void;
|
|
30
30
|
onExport?: (format: ExportFormat) => void;
|
|
31
|
+
/** 导出完整数据(下载 .json 文件) */
|
|
32
|
+
onExportData?: () => void;
|
|
33
|
+
/** 导入完整数据(用户选择 .json 文件后回调) */
|
|
34
|
+
onImportData?: (file: File) => void;
|
|
31
35
|
/** 荧光笔选色后回调(宿主据此同步给 editor) */
|
|
32
36
|
onHighlighterColorChange?: (color: string) => void;
|
|
37
|
+
/** 便签纸面色选好后回调(宿主据此同步给 editor,新建便签就用这个色) */
|
|
38
|
+
onStickyNoteColorChange?: (color: string) => void;
|
|
39
|
+
/** 从图标库面板选了一个图标:宿主负责插入画布 */
|
|
40
|
+
onInsertIcon?: (iconId: string) => void;
|
|
33
41
|
/** 新建箭头的默认样式(工具栏「箭头」下拉里展示/修改) */
|
|
34
42
|
arrowStyle?: ArrowStyle;
|
|
35
43
|
onArrowStyleChange?: (updates: Partial<ArrowStyle>) => void;
|