drawui-react 0.5.2 → 0.6.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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var react=require('react'),drawuiCore=require('drawui-core'),jsxRuntime=require('react/jsx-runtime');function V(){let[t,e]=react.useState(drawuiCore.getLanguage());return react.useEffect(()=>drawuiCore.subscribeLanguage(()=>e(drawuiCore.getLanguage())),[]),t}var Mn=["#ffeb3b","#22c55e","#3b82f6","#ec4899","#8b5cf6","#f97316"],Tn="drawui:highlighterColor";function Et(){if(typeof window>"u")return drawuiCore.DEFAULT_HIGHLIGHTER_COLOR;try{let t=window.localStorage.getItem(Tn);return t&&/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():drawuiCore.DEFAULT_HIGHLIGHTER_COLOR}catch{return drawuiCore.DEFAULT_HIGHLIGHTER_COLOR}}function Ln(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Tn,t);}catch{}}var En="drawui:stickyNoteColor";function It(){if(typeof window>"u")return drawuiCore.STICKY_NOTE_DEFAULT_COLOR;try{let t=window.localStorage.getItem(En);return t&&/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():drawuiCore.STICKY_NOTE_DEFAULT_COLOR}catch{return drawuiCore.STICKY_NOTE_DEFAULT_COLOR}}function In(t){if(!(typeof window>"u"))try{window.localStorage.setItem(En,t);}catch{}}function Ho({icon:t,size:e=24,ink:o=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:[t.disc&&jsxRuntime.jsx("circle",{cx:drawuiCore.ICON_GRID/2,cy:drawuiCore.ICON_GRID/2,r:drawuiCore.ICON_GRID/2-1,fill:t.disc}),t.layers.map((i,d)=>{let s=i.fill??"ink",l=i.stroke??"ink";return jsxRuntime.jsx("path",{d:i.d,fill:s==="none"?"none":s==="ink"?o:s,...l==="none"?{}:{stroke:l==="ink"?o:l,strokeWidth:i.w??1.8,strokeLinecap:"round",strokeLinejoin:"round"}},d)}),t.label&&jsxRuntime.jsx("text",{x:drawuiCore.ICON_GRID/2,y:drawuiCore.ICON_GRID/2+.5,textAnchor:"middle",dominantBaseline:"central",fontFamily:"sans-serif",fontSize:t.label.size??13,fill:t.label.color,children:t.label.text})]})}var Kn="drawui:recentIcons",On=12;function tn(t,e){let o=/^#?([0-9a-f]{6})$/i.exec(t.trim());if(!o)return t;let i=parseInt(o[1],16);return `rgba(${i>>16&255}, ${i>>8&255}, ${i&255}, ${e})`}function Ao(){if(typeof window>"u")return [];try{let t=JSON.parse(window.localStorage.getItem(Kn)||"[]");return Array.isArray(t)?t.filter(e=>typeof e=="string").slice(0,On):[]}catch{return []}}function Ko(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Kn,JSON.stringify(t));}catch{}}var An=t=>({"--dw-icon-cat":t,"--dw-icon-cat-soft":tn(t,.12)}),$n=react.memo(function({onPick:e,onClose:o}){V();let[i,d]=react.useState(""),[s,l]=react.useState(drawuiCore.ICON_CATEGORIES[0].id),[a,L]=react.useState(Ao),w=react.useRef(null),f=react.useRef(null);react.useEffect(()=>{f.current?.focus();},[]),react.useEffect(()=>{let y=T=>{let b=w.current;b&&(b.contains(T.target)||T.target?.closest?.("[data-icon-toggle]")||o());},k=T=>{T.key==="Escape"&&(T.stopPropagation(),o());};return window.addEventListener("pointerdown",y),window.addEventListener("keydown",k),()=>{window.removeEventListener("pointerdown",y),window.removeEventListener("keydown",k);}},[o]);let u=react.useMemo(()=>a.map(y=>drawuiCore.getIcon(y)).filter(y=>!!y),[a]),p=react.useMemo(()=>i.trim()?drawuiCore.searchIcons(i):s==="recent"?u:drawuiCore.iconsByCategory(s),[i,s,u]),M=s==="recent"?drawuiCore.ICON_CATEGORY_INK.status:drawuiCore.ICON_CATEGORY_INK[s]??drawuiCore.ICON_DEFAULT_INK,O=i.trim()?drawuiCore.t("icon.search"):s==="recent"?drawuiCore.t("icon.recent"):drawuiCore.t(drawuiCore.ICON_CATEGORIES.find(y=>y.id===s)?.labelKey??"icon.search"),I=y=>{e(y),L(k=>{let T=[y.id,...k.filter(b=>b!==y.id)].slice(0,On);return Ko(T),T});};return jsxRuntime.jsxs("div",{className:"drawui-icon-panel",ref:w,style:{"--dw-icon-accent":M,"--dw-icon-soft":tn(M,.08),"--dw-icon-ring":tn(M,.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:f,value:i,onChange:y=>d(y.target.value),onKeyDown:y=>{y.key==="Enter"&&p.length>0&&I(p[0]);},placeholder:drawuiCore.t("icon.search"),"aria-label":drawuiCore.t("icon.search")}),jsxRuntime.jsx("span",{className:"drawui-icon-count",children:p.length})]}),!i.trim()&&jsxRuntime.jsxs("div",{className:"drawui-icon-cats",children:[u.length>0&&jsxRuntime.jsxs("button",{type:"button",className:`drawui-icon-cat${s==="recent"?" active":""}`,style:An(drawuiCore.ICON_CATEGORY_INK.status),onClick:()=>l("recent"),children:[jsxRuntime.jsx("i",{className:"drawui-icon-dot"}),drawuiCore.t("icon.recent")]}),drawuiCore.ICON_CATEGORIES.map(y=>jsxRuntime.jsxs("button",{type:"button",className:`drawui-icon-cat${s===y.id?" active":""}`,style:An(drawuiCore.ICON_CATEGORY_INK[y.id]??drawuiCore.ICON_DEFAULT_INK),onClick:()=>l(y.id),children:[jsxRuntime.jsx("i",{className:"drawui-icon-dot"}),drawuiCore.t(y.labelKey)]},y.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:O}),jsxRuntime.jsx("span",{className:"drawui-icon-card-count",children:p.length})]}),jsxRuntime.jsxs("div",{className:"drawui-icon-grid",children:[p.map(y=>jsxRuntime.jsx("button",{type:"button",className:"drawui-icon-item",title:`${y.zh} / ${y.en}`,"aria-label":`${y.zh} ${y.en}`,onClick:()=>I(y),children:jsxRuntime.jsx(Ho,{icon:y,size:30,ink:drawuiCore.iconInk(y)})},y.id)),p.length===0&&jsxRuntime.jsx("div",{className:"drawui-icon-empty",children:drawuiCore.t("icon.empty")})]})]})]})});var Ke=t=>`${t.x.toFixed(1)},${t.y.toFixed(1)}`,Dn=(t,e)=>{let o=e*Math.PI/180;return {x:t.x*Math.cos(o)-t.y*Math.sin(o),y:t.x*Math.sin(o)+t.y*Math.cos(o)}},wt={x:Math.SQRT1_2,y:-Math.SQRT1_2},nn={x:4.6,y:19.4},kt={x:19,y:5};function on(t,e,o){let i={x:-o.y,y:o.x},d=l=>({x:e.x-o.x*l,y:e.y-o.y*l}),s=(l,a)=>({x:l.x+i.x*a,y:l.y+i.y*a});switch(t){case "end":{let l=d(5.6);return jsxRuntime.jsx("polygon",{points:`${Ke(e)} ${Ke(s(l,2.7))} ${Ke(s(l,-2.7))}`,fill:"currentColor",stroke:"none"})}case "inheritance":case "realization":{let l=d(8.6);return jsxRuntime.jsx("polygon",{points:`${Ke(e)} ${Ke(s(l,3.5))} ${Ke(s(l,-3.5))}`,fill:"none"})}case "aggregation":case "composition":{let l=d(4.3),a=d(8.6);return jsxRuntime.jsx("polygon",{points:`${Ke(e)} ${Ke(s(l,2.7))} ${Ke(a)} ${Ke(s(l,-2.7))}`,fill:t==="composition"?"currentColor":"none",stroke:"currentColor"})}case "dependency":{let l=Dn({x:-o.x,y:-o.y},30),a=Dn({x:-o.x,y:-o.y},-30);return jsxRuntime.jsx("path",{d:`M ${Ke({x:e.x+l.x*5.8,y:e.y+l.y*5.8})} L ${Ke(e)} L ${Ke({x:e.x+a.x*5.8,y:e.y+a.y*5.8})}`,fill:"none"})}default:return null}}function Ge(t,e){let o=e||t==="dependency"||t==="realization",i=o?{x:kt.x-wt.x*8.6,y:kt.y-wt.y*8.6}:kt,d={x:-wt.x,y:-wt.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:nn.x,y1:nn.y,x2:i.x,y2:i.y,strokeDasharray:o?"3 2.6":void 0}),(t==="end"||t==="both")&&on("end",kt,wt),(t==="start"||t==="both")&&on("end",nn,d),t!=="none"&&t!=="start"&&t!=="end"&&t!=="both"?on(t,kt,wt):null]})}var Pt=t=>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:t})}),$o=[{type:"straight",labelKey:"style.connection.straight",icon:Pt("M3 12h18")},{type:"polyline",labelKey:"style.connection.polyline",icon:Pt("M4 8 C 12 8, 12 16, 20 16")},{type:"orthogonal",labelKey:"style.connection.orthogonal",icon:Pt("M5 5v14h14")},{type:"curve",labelKey:"style.connection.curve",icon:Pt("M3 13 C 6 7, 9 7, 12 12 C 15 17, 18 17, 21 11")}],zn=[{key:"none",arrowHead:"none",dashed:false,labelKey:"style.arrowhead.none",icon:Ge("none",false)},{key:"end",arrowHead:"end",dashed:false,labelKey:"style.arrowhead.end",icon:Ge("end",false)},{key:"start",arrowHead:"start",dashed:false,labelKey:"style.arrowhead.start",icon:Ge("start",false)},{key:"both",arrowHead:"both",dashed:false,labelKey:"style.arrowhead.both",icon:Ge("both",false)},{key:"none-dashed",arrowHead:"none",dashed:true,labelKey:"style.arrowhead.none-dashed",icon:Ge("none",true)},{key:"both-dashed",arrowHead:"both",dashed:true,labelKey:"style.arrowhead.both-dashed",icon:Ge("both",true)}],_n=[{key:"inheritance",arrowHead:"inheritance",dashed:false,labelKey:"style.arrowhead.inheritance",icon:Ge("inheritance",false)},{key:"composition",arrowHead:"composition",dashed:false,labelKey:"style.arrowhead.composition",icon:Ge("composition",false)},{key:"aggregation",arrowHead:"aggregation",dashed:false,labelKey:"style.arrowhead.aggregation",icon:Ge("aggregation",false)},{key:"dependency",arrowHead:"dependency",dashed:true,labelKey:"style.arrowhead.dependency",icon:Ge("dependency",true)},{key:"realization",arrowHead:"realization",dashed:true,labelKey:"style.arrowhead.realization",icon:Ge("realization",true)}],Bn=[...zn,..._n];function Do(t,e){let o=Bn.find(i=>i.arrowHead===t&&i.dashed===e);return o?o.key:Bn.find(i=>i.arrowHead===t)?.key}var At=react.memo(function({connectionType:e,arrowHead:o,dashed:i,onConnectionTypeChange:d,onArrowStyleChange:s,onOptionHover:l,onOptionLeave:a}){V();let L=Do(o,i),w=f=>jsxRuntime.jsx("div",{className:"drawui-connection-row",children:f.map(u=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${L===u.key?" active":""}`,onClick:()=>s(u),"data-drawui-tip":l?void 0:drawuiCore.t(u.labelKey),onMouseEnter:l?p=>l(u.labelKey,p.currentTarget):void 0,onMouseLeave:l?a: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.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:$o.map(f=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${e===f.type?" active":""}`,onClick:()=>d(f.type),"data-drawui-tip":l?void 0:drawuiCore.t(f.labelKey),onMouseEnter:l?u=>l(f.labelKey,u.currentTarget):void 0,onMouseLeave:l?a:void 0,"aria-label":drawuiCore.t(f.labelKey),type:"button",children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:f.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(f.labelKey)})]},f.type))}),jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.arrow")}),w(zn),jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.uml")}),w(_n)]})});var Wn=[{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"})]})}],_o=[{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"}]}],Wo=new Map(Wn.map(t=>[t.type,t.icon])),Uo=new Set(Wn.map(t=>t.type)),Go=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsxRuntime.jsx("path",{d:"M20 15h-5v5"})]}),Zo=[{type:"arrow",icon:"M5 12h14M12 5l7 7-7 7",labelKey:"toolbar.arrow"},{type:"text",icon:"M4 7V4h16v3M9 20h6M12 4v16",labelKey:"toolbar.text"}],Fo="M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3Z",rn=8,Vo=6,an="M0 -1Q0.24 -0.24 1 0Q0.24 0.24 0 1Q-0.24 0.24 -1 0Q-0.24 -0.24 0 -1Z",Yo=[{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"}],sn=react.memo(function({activeTool:e,onToolChange:o,showGrid:i,onToggleGrid:d,pageTheme:s="light",onPageThemeChange:l,canUndo:a=false,canRedo:L=false,onUndo:w,onRedo:f,onExport:u,onExportData:p,onImportData:M,onHighlighterColorChange:O,onStickyNoteColorChange:I,onInsertIcon:y,onInsertTable:k,onInsertImage:T,arrowStyle:b,onArrowStyleChange:m,hidden:C=false}){let[g,x]=react.useState(false),[U,P]=react.useState(false),[A,ue]=react.useState(null),[ee,E]=react.useState(false),[q,pe]=react.useState(false),[S,se]=react.useState(Et),[ve,$]=react.useState(false),[G,xe]=react.useState(It),[ke,$e]=react.useState(false),[Ne,Fe]=react.useState(false),_e=react.useRef(null),Y=r=>{let Z=Array.from(r.target.files||[]);Z.length&&T?.(Z),r.target.value="";},[H,Ce]=react.useState(null),fe=react.useRef(null),te=react.useRef(null),De=react.useRef(null),X=react.useRef(null),Ee=react.useRef(null);V();let He=[{format:"png",labelKey:"toolbar.export.png"},{format:"svg",labelKey:"toolbar.export.svg"},{format:"pdf",labelKey:"toolbar.export.pdf"}],tt=()=>{fe.current&&(clearTimeout(fe.current),fe.current=null),E(true);},K=()=>{fe.current=window.setTimeout(()=>E(false),200);},Ve=["light","warm","gray","purple","green","eye-care"],Le={light:"#fafafa",warm:"#f8f5e9",gray:"#f1f3f5",purple:"#f7f5ff",green:"#f0fdf4","eye-care":"#f5f0e1"},v=react.useRef(null),D=()=>{E(false),j(),v.current?.click();},_=r=>{let Z=r.target.files?.[0];Z&&M?.(Z),r.target.value="";},W=()=>{te.current&&(clearTimeout(te.current),te.current=null),x(true);},J=()=>{te.current=window.setTimeout(()=>{x(false),j();},200);},le=()=>{De.current&&(clearTimeout(De.current),De.current=null),P(true);},Ye=()=>{De.current=window.setTimeout(()=>{P(false),j();},200);},Ie=(r,Z)=>{let ce=r.closest(".drawui-toolbar");if(!ce)return;let ne=r.getBoundingClientRect(),pt=ce.getBoundingClientRect(),xt=ne.bottom+46>window.innerHeight;ue({label:Z,x:ne.left-pt.left+ne.width/2,y:xt?ne.top-pt.top-8:ne.bottom-pt.top+8,above:xt});},j=()=>ue(null),Be=()=>{X.current&&(clearTimeout(X.current),X.current=null),pe(true);},nt=()=>{X.current=window.setTimeout(()=>pe(false),200);},We=r=>{se(r),Ln(r),O?.(r),o("highlighter");},ge=()=>{Ee.current&&(clearTimeout(Ee.current),Ee.current=null),$(true);},ut=()=>{Ee.current=window.setTimeout(()=>$(false),200);},c=r=>{xe(r),In(r),I?.(r),o("sticky-note"),$(false);};return jsxRuntime.jsx("div",{className:"drawui-toolbar-container",style:{display:C?"none":void 0},children:jsxRuntime.jsxs("div",{className:"drawui-toolbar",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="select"?"active":""}`,onClick:()=>o("select"),onMouseEnter:r=>Ie(r.currentTarget,"toolbar.select"),onMouseLeave:j,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:r=>Ie(r.currentTarget,"toolbar.hand"),onMouseLeave:j,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:W,onMouseLeave:J,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${Uo.has(e)?"active":""}`,onClick:()=>{o("rounded-rectangle"),x(false),j();},"data-drawui-tip":g?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"})})}),g&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-shape-menu",children:jsxRuntime.jsx("div",{className:"drawui-shape-menu-scroll",children:_o.map(r=>jsxRuntime.jsxs("div",{className:"drawui-shape-group",children:[jsxRuntime.jsx("div",{className:"drawui-shape-group-title",children:drawuiCore.t(r.labelKey)}),jsxRuntime.jsx("div",{className:"drawui-shape-group-grid",children:r.items.map(Z=>{let ce=Z.labelKey??`tool.${Z.type}`;return jsxRuntime.jsx("button",{type:"button",className:`drawui-toolbar-shape-item ${e===Z.type?"active":""}`,onClick:()=>{o(Z.type),x(false),j();},onMouseEnter:ne=>Ie(ne.currentTarget,ce),onMouseLeave:j,"aria-label":drawuiCore.t(ce),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:Wo.get(Z.type)})},`${r.key}-${Z.type}`)})})]},r.key))})})]}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:ge,onMouseLeave:ut,children:[jsxRuntime.jsxs("button",{className:`drawui-toolbar-button ${e==="sticky-note"?"active":""}`,onClick:()=>{o("sticky-note"),$(false),j();},"data-drawui-tip":ve?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:Go}),jsxRuntime.jsx("span",{className:"drawui-toolbar-color-chip",style:{background:G}})]}),ve&&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(r=>jsxRuntime.jsx("button",{type:"button","aria-label":r,className:`drawui-sticky-swatch${G.toLowerCase()===r.toLowerCase()?" active":""}`,style:{background:r},onClick:()=>c(r)},r))})]})]}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${ke?"active":""}`,"data-icon-toggle":"","data-drawui-tip":ke?void 0:drawuiCore.t("toolbar.icon"),onClick:()=>{$e(r=>!r),j();},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"})]})}),ke&&jsxRuntime.jsx($n,{onPick:r=>y?.(r.id),onClose:()=>$e(false)})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:le,onMouseLeave:Ye,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="arrow"?"active":""}`,onClick:()=>{o("arrow"),P(false),j();},"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:r=>{r.target.closest("button")||(P(false),j());},children:jsxRuntime.jsx(At,{connectionType:b?.connectionType??"straight",arrowHead:b?.arrowHead??"end",dashed:!!b?.dashed,onConnectionTypeChange:r=>{m?.({connectionType:r}),o("arrow"),P(false),j();},onArrowStyleChange:r=>{m?.({arrowHead:r.arrowHead,dashed:r.dashed}),o("arrow"),P(false),j();},onOptionHover:(r,Z)=>Ie(Z,r),onOptionLeave:j})})]}),Zo.filter(r=>r.type!=="arrow").map(r=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===r.type?"active":""}`,onClick:()=>o(r.type),"data-drawui-tip":drawuiCore.t(r.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:r.icon})})},r.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:Fo})})}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:Be,onMouseLeave:nt,children:[jsxRuntime.jsxs("button",{className:`drawui-toolbar-button ${e==="highlighter"?"active":""}`,onClick:()=>o("highlighter"),onMouseEnter:r=>Ie(r.currentTarget,"toolbar.highlighter"),onMouseLeave:j,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:an,transform:"translate(7.4 5.4) scale(2.4)"}),jsxRuntime.jsx("path",{d:an,transform:"translate(18.4 3.4) scale(2.5)"}),jsxRuntime.jsx("path",{d:an,transform:"translate(21 10.6) scale(2.2)"})]})]}),jsxRuntime.jsx("span",{className:"drawui-toolbar-color-chip",style:{background:S}})]}),q&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-highlighter-grid",children:Mn.map(r=>jsxRuntime.jsx("button",{type:"button","aria-label":r,className:`drawui-highlighter-swatch${S.toLowerCase()===r.toLowerCase()?" active":""}`,style:{background:r},onClick:()=>We(r)},r))})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),Yo.map(r=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===r.type?"active":""}`,onClick:()=>o(r.type),"data-drawui-tip":drawuiCore.t(r.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:r.icon})})},r.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("rect",{x:"2.2",y:"9",width:"6.6",height:"6",rx:"2"}),jsxRuntime.jsx("rect",{x:"15.4",y:"3.8",width:"6.4",height:"5.2",rx:"1.8"}),jsxRuntime.jsx("rect",{x:"15.4",y:"15",width:"6.4",height:"5.2",rx:"1.8"}),jsxRuntime.jsx("path",{d:"M8.8 12 C 12.2 12 12.2 6.4 15.4 6.4"}),jsxRuntime.jsx("path",{d:"M8.8 12 C 12.2 12 12.2 17.6 15.4 17.6"})]})}),jsxRuntime.jsx("button",{className:"drawui-toolbar-button",onClick:()=>_e.current?.click(),"data-drawui-tip":drawuiCore.t("toolbar.image"),"data-image-toggle":true,children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsxRuntime.jsx("circle",{cx:"8.5",cy:"9.5",r:"1.6"}),jsxRuntime.jsx("path",{d:"M21 15.5l-4.5-4.5L6 21"})]})}),jsxRuntime.jsx("input",{ref:_e,type:"file",accept:"image/*",multiple:true,style:{display:"none"},onChange:Y}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${Ne?"active":""}`,onClick:()=>Fe(r=>!r),"data-drawui-tip":drawuiCore.t("toolbar.table"),"data-table-toggle":true,children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsxRuntime.jsx("line",{x1:"3",y1:"9.3",x2:"21",y2:"9.3"}),jsxRuntime.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),jsxRuntime.jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]})}),Ne&&jsxRuntime.jsxs("div",{className:"drawui-table-picker",children:[jsxRuntime.jsx("div",{className:"drawui-table-picker-hint",children:H?`${H.rows} \xD7 ${H.cols}`:drawuiCore.t("table.pickHint")}),jsxRuntime.jsx("div",{className:"drawui-table-picker-grid",children:Array.from({length:Vo*rn},(r,Z)=>{let ce=Math.floor(Z/rn),ne=Z%rn,pt=H&&ce<H.rows&&ne<H.cols;return jsxRuntime.jsx("button",{type:"button","aria-label":`${ce+1}x${ne+1}`,className:"drawui-table-picker-cell",style:pt?{borderColor:"var(--dw-primary)",background:"var(--dw-primary-weak)"}:void 0,onMouseEnter:()=>Ce({rows:ce+1,cols:ne+1}),onClick:()=>{k?.(ce+1,ne+1),Fe(false),Ce(null),j();}},Z)})})]})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:"drawui-toolbar-button",onClick:w,disabled:!a,style:a?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:f,disabled:!L,style:L?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:tt,onMouseLeave:K,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${ee?"active":""}`,"data-drawui-tip":ee?void 0:drawuiCore.t("toolbar.more"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"5",cy:"12",r:"1.8",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"1.8",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"19",cy:"12",r:"1.8",fill:"currentColor"})]})}),ee&&jsxRuntime.jsxs("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-more-grid",children:[jsxRuntime.jsxs("button",{className:"drawui-toolbar-more-row",onClick:()=>{d(),E(false);},children:[jsxRuntime.jsx("span",{className:"drawui-toolbar-more-icon",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("span",{className:"drawui-toolbar-more-label",children:drawuiCore.t("toolbar.grid")}),i&&jsxRuntime.jsx("svg",{className:"drawui-toolbar-more-check",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})})]}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-more-section",children:[jsxRuntime.jsx("div",{className:"drawui-toolbar-more-section-title",children:drawuiCore.t("toolbar.pageTheme")}),jsxRuntime.jsx("div",{className:"drawui-toolbar-more-themes",children:Ve.map(r=>jsxRuntime.jsx("button",{type:"button",className:`drawui-toolbar-more-theme-swatch${s===r?" active":""}`,style:{background:Le[r]},onClick:()=>{l?.(r),E(false);},title:drawuiCore.t(`pageTheme.${r}`),"aria-label":drawuiCore.t(`pageTheme.${r}`)},r))})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-export-divider"}),He.map(r=>jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{u?.(r.format),E(false);},children:drawuiCore.t(r.labelKey)},r.format)),jsxRuntime.jsx("div",{className:"drawui-toolbar-export-divider"}),jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{p?.(),E(false);},children:drawuiCore.t("toolbar.export.data")}),jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:D,children:drawuiCore.t("toolbar.import.data")})]})]}),jsxRuntime.jsx("input",{ref:v,type:"file",accept:".json,application/json",style:{display:"none"},onChange:_}),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 cn=react.memo(function({onZoomIn:e,onZoomOut:o,onReset:i,zoomLevel:d=100}){return V(),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:[d,"%"]}),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:i,"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 Gn=["#ffffff","#f1f5f9","#e2e8f0","#ede9fe","#dbeafe","#e0e7ff","#dcfce7","#fef9c3","#fee2e2"],Zn=["#0f172a","#475569","#94a3b8","#8b5cf6","#3b82f6","#1d4ed8","#16a34a","#eab308","#dc2626"],tr=Gn.filter(t=>t!=="#f1f5f9"),nr=[...tr,...Zn],or=[...Gn,...Zn],Fn=15,Vn="drawui:customColors";function rr(){if(typeof window>"u")return [];try{let t=window.localStorage.getItem(Vn);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e.filter(o=>typeof o=="string").slice(-Fn):[]}catch{return []}}function ar(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Vn,JSON.stringify(t));}catch{}}var dn=[{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}],Un=(t,e)=>!!t&&!!e&&t.toLowerCase()===e.toLowerCase(),St=10,lt=12,it=t=>!t||t==="transparent",Yn=react.memo(function({editor:e,selectedCount:o,hasLineSelection:i,currentConnectionType:d,currentArrowHead:s,currentDashed:l,hidden:a=false}){V();let L=!!e?.getEditingShapeId(),[w,f]=react.useState(null),[u,p]=react.useState(null),[,M]=react.useState(0),O=react.useRef(null),I=react.useRef(null),y=react.useRef(null),[k,T]=react.useState({tw:168,th:42,pw:228,ph:160}),[b,m]=react.useState(rr),C=react.useRef(null),g=react.useCallback(c=>{let r=c.trim().toLowerCase();/^#[0-9a-f]{6}$/.test(r)&&m(Z=>{let ce=Z.filter(ne=>ne!==r);for(ce.push(r);ce.length>Fn;)ce.shift();return ar(ce),ce});},[]);if(react.useEffect(()=>{let c=C.current;if(!c)return;let r=()=>{c.value&&g(c.value);};return c.addEventListener("change",r),()=>c.removeEventListener("change",r)},[g,u]),react.useEffect(()=>{if(!e)return;let c=e.subscribe(()=>M(r=>(r+1)%1e6));return ()=>{c();}},[e]),react.useEffect(()=>{p(null);},[o,L]),react.useEffect(()=>{if(!u)return;let c=r=>{O.current&&!O.current.contains(r.target)&&p(null);};return document.addEventListener("pointerdown",c,true),()=>document.removeEventListener("pointerdown",c,true)},[u]),react.useLayoutEffect(()=>{let c=I.current?.offsetWidth??k.tw,r=I.current?.offsetHeight??k.th,Z=y.current?.offsetWidth??k.pw,ce=y.current?.offsetHeight??k.ph;T(ne=>ne.tw===c&&ne.th===r&&ne.pw===Z&&ne.ph===ce?ne:{tw:c,th:r,pw:Z,ph:ce});}),!e||o===0||L)return null;let x=e.getSelectedIds(),P=e.getShapes().filter(c=>x.includes(c.id)),A=P[0],ue=A?.id??"",ee=P.length===1&&P[0].type==="mind-map"?e.getMindMapSelectedNode():null,E=ee&&ee.shapeId===P[0].id?ee:null,q=E?e.canPromoteMindMapNode(E.shapeId,E.nodeId,1):false,pe=E?e.canPromoteMindMapNode(E.shapeId,E.nodeId,2):false,S=A?.style.fillColor,se=A?.style.strokeColor??"#1f2937",ve=A?.textColor??"#1f2937",$=A?.highlightColor,G={fill:S,stroke:se,text:ve,highlight:$},xe=P.length>0&&P.every(c=>c.type==="sticky-note"),ke={fill:A?.style.fillOpacity??1,stroke:A?.style.strokeOpacity??1,highlight:A?.highlightOpacity??1},$e=c=>w&&w.key===`${ue}:${c}`?w.value:ke[c]??1,Ne=(c,r)=>{switch(c){case "stroke":e.updateSelectedShapesStyle({strokeColor:r});break;case "fill":e.updateSelectedShapesStyle({fillColor:r});break;case "text":e.updateSelectedShapesText({textColor:r});break;case "highlight":e.updateSelectedShapesText({highlightColor:r});break}},Fe=(c,r)=>{f({key:`${ue}:${c}`,value:r}),c==="highlight"?e.updateSelectedShapesText({highlightOpacity:r}):c==="stroke"?e.updateSelectedShapesStyle({strokeOpacity:r}):e.updateSelectedShapesStyle({fillOpacity:r});},_e=c=>e.updateConnectionType(c),Y=c=>e.updateArrowStyle({arrowHead:c.arrowHead,dashed:c.dashed}),H=!!i&&P.length>0&&P.every(c=>c.type==="line"||c.type==="arrow"),Ce=P.length>0&&P.every(c=>c.type==="text"),fe=P.length>0&&P.every(c=>c.type==="sticky-note"||c.type==="icon"),te=H?dn.filter(c=>c.key==="stroke"):fe?dn.filter(c=>c.key!=="stroke"):dn,De=c=>c.key==="stroke"&&H?"style.line":c.labelKey,X=u&&u!=="more"?te.find(c=>c.key===u):void 0,Ee=!!u&&(u==="more"||u==="prefix"||u==="level"||!!X),He=xe&&X?.key==="fill",tt=e.getCamera(),K=drawuiCore.getContentBounds(P,0),Ve=tt.pageToScreen({x:K.x,y:K.y}),Le=tt.pageToScreen({x:K.x+K.width,y:K.y+K.height}),v=window.innerWidth,D=window.innerHeight,_=Le.y+St,W=Ve.y-St,J=k.th+(Ee?St+k.ph:0),le=_+J<=D-lt,Ye=W-J>=lt,Ie=le||!Ye,j=(Ve.x+Le.x)/2,Be=(c,r,Z)=>Math.max(r,Math.min(c,Math.max(r,Z))),nt=Be(j-k.tw/2,lt,v-k.tw-lt),We=Ie?_:W-k.th,ge=Be(j-k.pw/2,lt,v-k.pw-lt),ut=Ee?Be(Ie?We+k.th+St:We-St-k.ph,lt,D-k.ph-lt):0;return jsxRuntime.jsxs("div",{className:"drawui-style-floating",ref:O,style:a?{display:"none"}:void 0,children:[jsxRuntime.jsxs("div",{className:"drawui-style-toolbar",ref:I,style:{left:nt,top:We},children:[te.map(c=>jsxRuntime.jsxs("button",{className:`drawui-style-tool-btn${u===c.key?" active":""}`,onClick:()=>p(u===c.key?null:c.key),"data-drawui-tip":drawuiCore.t(De(c)),type:"button",children:[c.key==="fill"&&jsxRuntime.jsx("span",{className:`drawui-st-swatch${it(S)?" drawui-st-none":""}`,style:it(S)?void 0:{background:S}}),c.key==="stroke"&&(H?jsxRuntime.jsx("span",{className:`drawui-st-line${it(se)?" drawui-st-line-none":""}`,style:it(se)?void 0:{background:se}}):jsxRuntime.jsx("span",{className:`drawui-st-frame${it(se)?" drawui-st-frame-none":""}`,style:it(se)?void 0:{borderColor:se}})),c.key==="text"&&jsxRuntime.jsx("span",{className:"drawui-st-text",style:{color:ve},children:"A"}),c.key==="highlight"&&jsxRuntime.jsx("span",{className:`drawui-st-hl${it($)?" drawui-st-none":""}`,style:it($)?void 0:{background:$},children:"A"})]},c.key)),E&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${u==="level"?" active":""}`,onClick:()=>p(u==="level"?null:"level"),"data-drawui-tip":drawuiCore.t("mindmap.level"),type:"button",children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"5"}),jsxRuntime.jsx("polyline",{points:"6 11 12 5 18 11"})]})}),i&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${u==="more"?" active":""}`,onClick:()=>p(u==="more"?null:"more"),"data-drawui-tip":drawuiCore.t("style.connection"),type:"button",children:"\u22EF"}),Ce&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${u==="prefix"?" active":""}`,onClick:()=>p(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"})]})})]}),Ee&&jsxRuntime.jsx("div",{className:"drawui-style-popover",ref:y,style:{left:ge,top:ut},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")})]}):u==="level"?E?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("mindmap.level")}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:8},children:[jsxRuntime.jsx("button",{type:"button",disabled:!q,onClick:()=>e.promoteMindMapNode(E.shapeId,E.nodeId,1),"data-drawui-tip":q?drawuiCore.t("mindmap.promote1"):drawuiCore.t("mindmap.promoteDisabled"),style:{border:"1px solid #bfdbfe",background:q?"#ffffff":"#f9fafb",color:q?"#3b82f6":"#9ca3af",borderRadius:5,padding:"4px 10px",fontSize:12,cursor:q?"pointer":"not-allowed"},children:drawuiCore.t("mindmap.promote1")}),jsxRuntime.jsx("button",{type:"button",disabled:!pe,onClick:()=>e.promoteMindMapNode(E.shapeId,E.nodeId,2),"data-drawui-tip":pe?drawuiCore.t("mindmap.promote2"):drawuiCore.t("mindmap.promoteDisabled"),style:{border:"1px solid #bfdbfe",background:pe?"#ffffff":"#f9fafb",color:pe?"#3b82f6":"#9ca3af",borderRadius:5,padding:"4px 10px",fontSize:12,cursor:pe?"pointer":"not-allowed"},children:drawuiCore.t("mindmap.promote2")})]})]}):null:X?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t(De(X))}),jsxRuntime.jsxs("div",{className:"drawui-color-row",children:[X.hasTransparent&&!He&&jsxRuntime.jsx("button",{className:`drawui-color-swatch drawui-color-swatch-transparent${it(G[X.key])?" active":""}`,onClick:()=>Ne(X.key,"transparent"),"aria-label":drawuiCore.t("style.none"),type:"button"}),(He?drawuiCore.STICKY_NOTE_COLORS:X.hasTransparent?nr:or).map(c=>jsxRuntime.jsx("button",{className:`drawui-color-swatch${Un(c,G[X.key])?" active":""}`,style:{background:c},onClick:()=>Ne(X.key,c),"aria-label":c,type:"button"},c)),b.map(c=>jsxRuntime.jsx("button",{className:`drawui-color-swatch drawui-color-custom${Un(c,G[X.key])?" active":""}`,style:{background:c},onClick:()=>Ne(X.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:C,type:"color",defaultValue:"#3b82f6",className:"drawui-color-add-input","aria-label":drawuiCore.t("style.addColor")})]})]}),X.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($e(X.key)*100),onChange:c=>Fe(X.key,Number(c.target.value)/100),className:"drawui-opacity-slider"}),jsxRuntime.jsxs("span",{className:"drawui-opacity-value",children:[Math.round($e(X.key)*100),"%"]})]})]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(At,{connectionType:d??"straight",arrowHead:s??"end",dashed:!!l,onConnectionTypeChange:_e,onArrowStyleChange:Y})})})]})});var pn=14,qn=20,pr=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af"],hr=[12,14,16,18,20,24];function Jn(t,e){let o=t,i="",d=o.charAt(0);if(o.length>1&&(d==="+"||d==="-"||d==="#"||d==="~")&&o.charAt(1)===" "&&(i=d,o=o.slice(2)),o=o.replace(/^\s+|\s+$/g,""),e==="attribute"){let f=o.indexOf(":");return f===-1?{visibility:i,name:o,type:"",params:"",returnType:""}:{visibility:i,name:o.slice(0,f).replace(/^\s+|\s+$/g,""),type:o.slice(f+1).replace(/^\s+|\s+$/g,""),params:"",returnType:""}}let s=o.indexOf("(");if(s===-1){let f=o.lastIndexOf(":");return f===-1?{visibility:i,name:o,type:"",params:"",returnType:""}:{visibility:i,name:o.slice(0,f).replace(/^\s+|\s+$/g,""),type:"",params:"",returnType:o.slice(f+1).replace(/^\s+|\s+$/g,"")}}let l=o.slice(0,s).replace(/^\s+|\s+$/g,""),a=o.indexOf(")",s);if(a===-1)return {visibility:i,name:l,type:"",params:o.slice(s+1).replace(/^\s+|\s+$/g,""),returnType:""};let L=o.slice(s+1,a).replace(/^\s+|\s+$/g,""),w=o.slice(a+1).replace(/^\s+|\s+$/g,"");return w.startsWith(":")&&(w=w.slice(1).replace(/^\s+|\s+$/g,"")),{visibility:i,name:l,type:"",params:L,returnType:w}}function yr(t,e){let o=e.visibility?`${e.visibility} `:"";return t==="attribute"?`${o}${e.name}${e.type?`: ${e.type}`:""}`:`${o}${e.name}(${e.params??""})${e.returnType?`: ${e.returnType}`:""}`}var eo=react.memo(function({editor:e,umlClass:o,editing:i}){let[,d]=react.useState(0);V(),react.useEffect(()=>{if(!e)return;let v=e.subscribe(()=>d(D=>D+1));return ()=>{v();}},[e]);let[s,l]=react.useState(null),[a,L]=react.useState(false),[w,f]=react.useState(null),u=react.useRef(null),p=react.useRef(null),M=react.useCallback((v,D)=>{u.current&&(clearTimeout(u.current),u.current=null),l({section:v,rowId:D}),L(false);},[]),O=react.useCallback(()=>{u.current&&clearTimeout(u.current),u.current=window.setTimeout(()=>{l(null),L(false);},150);},[]);if(!e||!o||i!==o.id)return null;let I=e.getCamera(),{id:y,x:k,y:T,width:b,height:m,className:C,methods:g}=o,x=o.type==="uml-interface",U=x?[]:o.attributes,P=b/2,A=m/2,ue=drawuiCore.UML_HEADER_HEIGHT,ee=drawuiCore.UML_LINE_HEIGHT,E=drawuiCore.UML_PADDING_X,q=drawuiCore.UML_PADDING_Y,pe=x?0:U.length>0?U.length*ee+q*2:q*2,S=I.zoom,se=(b-E*2)*S,ve=4*S,$=I.pageToScreen({x:k-P+E,y:T}),G=I.pageToScreen({x:k,y:T-A+ue/2}),xe=v=>I.pageToScreen({x:k,y:v}).y,ke=ee*S,$e=v=>T+(-A+ue+q+ee/2+v*ee),Ne=v=>T+(-A+ue+pe+q+ee/2+v*ee),Fe=T+(-A+ue+pe),_e=T+A,Y={background:"#ffffff",borderWidth:1,borderStyle:"solid",borderColor:"transparent",outline:"none",padding:0,fontFamily:"sans-serif",boxSizing:"border-box"},H=(v,D)=>{if(!U.find(J=>J.id===v))return;let W=Jn(D,"attribute");e.updateUmlClass(y,{attributes:U.map(J=>J.id===v?{...J,...W}:J)});},Ce=(v,D)=>{if(!g.find(le=>le.id===v))return;let W=Jn(D,"method"),J=g.map(le=>le.id===v?{...le,...W}:le);x?e.updateUmlInterface(y,{methods:J}):e.updateUmlClass(y,{methods:J});},fe=(v,D,_)=>{p.current={section:v,from:D},_.dataTransfer.effectAllowed="move",_.dataTransfer.setData("text/plain",`${v}:${D}`);},te=v=>{v.preventDefault(),v.dataTransfer.dropEffect="move";},De=(v,D,_)=>{_.preventDefault();let W=p.current;!W||W.section!==v||(v==="attribute"?e.reorderUmlAttribute(y,W.from,D):e.reorderUmlMethod(y,W.from,D),p.current=null);},X=(v,D,_,W)=>{let J=xe(W),le=s?.section===v&&s.rowId===_.id,Ye=(_.fontSize||drawuiCore.UML_FONT_SIZE)*S,Ie=_.textColor||"#1f2937",j={position:"absolute",left:$.x-pn*S-ve,top:J-ke/2,width:pn*S+ve+se+qn*S,height:ke,display:"flex",alignItems:"center",gap:2,pointerEvents:"none",zIndex:53},Be={...Y,width:se,height:ke-2,fontSize:Ye,color:Ie,textDecoration:_.strikethrough?"line-through":"none",pointerEvents:"auto",...le?{borderColor:"var(--dw-primary)"}:{}},nt={width:pn*S,height:ke-2,cursor:"grab",color:"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",fontSize:12*S,lineHeight:1,opacity:le?1:.55,pointerEvents:"auto"},We={width:qn*S,height:ke-6,border:"none",background:"transparent",color:"#9ca3af",cursor:"pointer",borderRadius:3,fontSize:14*S,opacity:le?1:.35,pointerEvents:"auto"};return jsxRuntime.jsxs("div",{style:j,onDragOver:te,onDrop:ge=>De(v,D,ge),children:[jsxRuntime.jsx("span",{style:nt,draggable:true,onDragStart:ge=>fe(v,D,ge),"data-drawui-tip":drawuiCore.t("uml.drag"),children:"\u22EE\u22EE"}),jsxRuntime.jsx("input",{style:Be,value:w&&w.rowId===_.id?w.text:yr(v,_),onChange:ge=>{f({rowId:_.id,text:ge.target.value}),v==="attribute"?H(_.id,ge.target.value):Ce(_.id,ge.target.value);},onFocus:()=>M(v,_.id),onBlur:()=>{f(null),O();},spellCheck:false}),jsxRuntime.jsx("button",{style:We,onMouseDown:ge=>ge.preventDefault(),onClick:()=>{v==="attribute"?e.removeUmlAttribute(y,_.id):e.removeUmlMethod(y,_.id);},"data-drawui-tip":drawuiCore.t("uml.delete"),children:"\xD7"})]},_.id)},Ee=(v,D,_)=>{let W=xe(D),J=v==="attribute";return jsxRuntime.jsxs("button",{onMouseDown:le=>le.preventDefault(),onClick:()=>J?e.addUmlAttribute(y):e.addUmlMethod(y),className:"drawui-uml-add-row",style:{position:"absolute",left:$.x,top:W-9*S,height:18*S,padding:`0 ${6*S}px`,fontSize:11*S,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":_,children:[jsxRuntime.jsx("span",{style:{fontSize:13*S,lineHeight:1},children:"+"}),jsxRuntime.jsx("span",{children:_})]},`add-${v}`)},He=()=>{if(!s||s.section==="className")return null;let v=s.section,D=s.rowId,W=(v==="attribute"?U:g).find(r=>r.id===D);if(!W)return null;let J=224*S,le=30*S,Ye=I.pageToScreen({x:k,y:T}).x,Ie=I.pageToScreen({x:k,y:T-A}).y,j=20*S,Be=Ie-le-j,nt=Ye-J/2,We=Be+le,ge=W.textColor||"#1f2937",ut=W.fontSize||drawuiCore.UML_FONT_SIZE,c=!!W.strikethrough;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:Ye-.5,top:We,width:1,height:j,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),jsxRuntime.jsxs("div",{className:"drawui-uml-toolbar",style:{position:"absolute",left:nt,top:Be,width:J,height:le,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:6,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",gap:4*S,padding:`0 ${6*S}px`,pointerEvents:"auto",zIndex:60,fontSize:12*S},onMouseDown:r=>r.preventDefault(),children:[jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{onClick:()=>L(r=>!r),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:ge,fontSize:13*S,textDecoration:c?"line-through":"none"},children:"A"}),jsxRuntime.jsx("span",{style:{width:10*S,height:2*S,background:ge,marginLeft:3,borderRadius:1}})]}),a&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"100%",left:0,marginTop:4,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:4,padding:4,display:"flex",gap:2,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:61},children:[jsxRuntime.jsx("button",{onClick:()=>{e.updateUmlRowStyle(y,v,W.id,{textColor:null}),L(false);},style:{width:14,height:14,border:"1px solid #e5e7eb",background:"transparent",cursor:"pointer",borderRadius:2},"data-drawui-tip":drawuiCore.t("uml.defaultColor")}),pr.map(r=>jsxRuntime.jsx("button",{onClick:()=>{e.updateUmlRowStyle(y,v,W.id,{textColor:r}),L(false);},style:{width:14,height:14,border:"none",background:r,cursor:"pointer",borderRadius:2},"data-drawui-tip":r},r))]})]}),jsxRuntime.jsx("select",{value:ut,onChange:r=>e.updateUmlRowStyle(y,v,W.id,{fontSize:Number(r.target.value)}),style:{border:"1px solid #e5e7eb",borderRadius:3,padding:`0 ${2*S}px`,fontSize:12*S,height:20*S,background:"#ffffff"},"data-drawui-tip":drawuiCore.t("uml.fontSize"),children:hr.map(r=>jsxRuntime.jsx("option",{value:r,children:r},r))}),jsxRuntime.jsx("button",{onClick:()=>e.updateUmlRowStyle(y,v,W.id,{strikethrough:!c}),className:"drawui-uml-toolbar-btn","data-drawui-tip":drawuiCore.t("uml.strikethrough"),style:{border:"none",background:c?"var(--dw-primary-weak)":"transparent",cursor:"pointer",padding:2,borderRadius:3},children:jsxRuntime.jsx("span",{style:{fontWeight:700,fontSize:13*S,textDecoration:"line-through"},children:"A"})}),jsxRuntime.jsx("button",{onClick:()=>{v==="attribute"?e.removeUmlAttribute(y,W.id):e.removeUmlMethod(y,W.id),l(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*S,height:14*S,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"})]})})]})]})},tt=I.pageToScreen({x:k-P,y:T}).x,K=I.pageToScreen({x:k,y:T-A}).y,Ve=b*S,Le=m*S;return jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:tt+1,top:K+1,width:Math.max(0,Ve-2),height:Math.max(0,Le-2),background:"#ffffff",pointerEvents:"none",zIndex:51}}),jsxRuntime.jsx("input",{style:{...Y,position:"absolute",left:G.x-se/2,top:G.y-ue*S/2+2,width:se,height:ue*S-4,textAlign:"center",fontWeight:700,fontSize:(o.fontSize||drawuiCore.UML_FONT_SIZE)*S,color:o.textColor||"#1f2937",pointerEvents:"auto",zIndex:52,...s?.section==="className"?{borderColor:"var(--dw-primary)"}:{}},value:C,onChange:v=>x?e.updateUmlInterface(y,{className:v.target.value}):e.updateUmlClass(y,{className:v.target.value}),onFocus:()=>M("className",""),onBlur:O,spellCheck:false}),!x&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[U.map((v,D)=>X("attribute",D,v,$e(D))),Ee("attribute",Fe,"\u5C5E\u6027")]}),g.map((v,D)=>X("method",D,v,Ne(D))),Ee("method",_e,drawuiCore.t("uml.method")),He()]})});var ro=react.memo(function({editor:e,panelOpen:o,onOpenPanel:i}){let[,d]=react.useState(0);V(),react.useEffect(()=>{if(!e)return;let m=e.subscribe(()=>d(C=>C+1));return ()=>{m();}},[e]);let s=react.useRef(false),l=react.useRef(false),a=e?.getMindMapEditingShapeId()??null,L=e?.getMindMapSelectedNode()?.nodeId??"",w=a?`${a}\0${L}`:"";if(react.useEffect(()=>{s.current=false;},[w]),!e)return null;let f=e.getMindMapEditingShapeId();if(!f||o)return null;let u=e.getMindMapSelectedNode();if(!u||u.shapeId!==f)return null;let p=e.getMindMapNode(f,u.nodeId),M=e.getMindMapNodeScreenRect(f,u.nodeId);if(!p||!M)return null;let O=e.getCamera().getZoom(),I=drawuiCore.MINDMAP_FONT_SIZE*O,y=Math.max(100,M.width+24),k=M.height+8,T={position:"absolute",left:M.x+M.width/2,top:M.y-4,transform:"translateX(-50%)",width:y,height:k,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 ${(p.icon?24:12)*O}px`,fontFamily:"sans-serif",fontSize:I,color:"#1f2937",boxSizing:"border-box",pointerEvents:"auto",zIndex:55},b={position:"absolute",left:M.x+M.width+12,top:M.y+M.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:T,value:p.text,spellCheck:false,onChange:m=>{let C=!s.current;s.current=true,e.updateMindMapNode(f,u.nodeId,{text:m.target.value},C);},onBlur:()=>{if(l.current){l.current=false;return}let m=e.getMindMapSelectedNode();m&&(m.shapeId!==f||m.nodeId!==u.nodeId)||e.exitMindMapEdit();},onKeyDown:m=>{m.key==="Enter"?m.target.blur():m.key==="Escape"&&e.exitMindMapEdit();}}),jsxRuntime.jsx("button",{style:b,"data-drawui-tip":drawuiCore.t("mindmap.more"),onMouseDown:m=>{m.preventDefault(),l.current=true,setTimeout(()=>{l.current=false;},300);},onClick:i,children:"\u22EF"})]})});var so=react.memo(function({editor:e,panelOpen:o}){let[,i]=react.useState(0);V(),react.useEffect(()=>{if(!e)return;let k=e.subscribe(()=>i(T=>T+1));return ()=>{k();}},[e]);let d=react.useRef(false),s=e?.getTableEditing()??null,l=s?`${s.shapeId}\0${s.row}\0${s.col}`:"";if(react.useEffect(()=>{d.current=false;},[l]),!e||o)return null;let a=e.getTableEditing();if(!a)return null;let{shapeId:L,row:w,col:f}=a,u=e.getTableCell(L,w,f),p=e.getTableScreenRect(L,w,f);if(!u||!p)return null;let M=e.getSelectedTable(),O=u.fontSize||M?.fontSize||drawuiCore.TABLE_FONT_SIZE,I=e.getCamera().getZoom(),y={left:p.x-1,top:p.y-1,width:p.width+2,height:p.height+2,padding:`${drawuiCore.TABLE_CELL_PADDING_Y*I}px ${drawuiCore.TABLE_CELL_PADDING_X*I}px`,fontFamily:"sans-serif",fontSize:O*I,lineHeight:drawuiCore.TABLE_LINE_HEIGHT_RATIO,fontWeight:u.bold?700:400,color:u.textColor||M?.textColor||"#1f2937",textAlign:u.align==="center"?"center":u.align==="right"?"right":"left"};return jsxRuntime.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:jsxRuntime.jsx("textarea",{autoFocus:true,rows:1,className:"drawui-table-cell-input",style:y,value:u.text,spellCheck:false,onChange:k=>{let T=!d.current;d.current=true,e.updateTableCell(L,w,f,{text:k.target.value},T);},onBlur:()=>{e.exitTableEdit();},onKeyDown:k=>{(k.key==="Enter"||k.key==="Escape")&&(k.preventDefault(),k.target.blur());}})})});var uo=react.memo(function({editor:e,hidden:o=false}){let[,i]=react.useState(0),[d,s]=react.useState(null),l=react.useRef(null);if(V(),react.useEffect(()=>{if(!e)return;let E=e.subscribe(()=>i(q=>q+1));return ()=>{E();}},[e]),react.useEffect(()=>{if(!d)return;let E=pe=>{let S=pe.target;S&&l.current?.contains(S)||s(null);},q=pe=>{pe.key==="Escape"&&s(null);};return window.addEventListener("pointerdown",E,true),window.addEventListener("keydown",q),()=>{window.removeEventListener("pointerdown",E,true),window.removeEventListener("keydown",q);}},[d]),!e||o)return null;let a=e.getSelectedTable();if(!a)return null;let L=e.getTableSelection();if(!L||L.shapeId!==a.id)return null;let w=e.getTableScreenRect(a.id);if(!w)return null;let f=a.cells.length,u=a.cells[0]?.length??0,p=drawuiCore.tableExpandRangeToMerges(a,L.anchor.row,L.anchor.col,L.focus.row,L.focus.col),{r1:M,c1:O,r2:I,c2:y}=p,k=drawuiCore.tableCoveredMap(a.cells),T=0;for(let E=M;E<=I;E++)for(let q=O;q<=y;q++)k[E]?.[q]||T++;let b=T>1,m=drawuiCore.tableRangeHasMerge(a,M,O,I,y),C=M===I?`${M+1}`:`${M+1}\u2013${I+1}`,g=O===y?`${O+1}`:`${O+1}\u2013${y+1}`,x=f-(I-M+1)>=1,U=u-(y-O+1)>=1,A=w.y>56?w.y-40:w.y+w.height+10,ue=E=>E.stopPropagation(),ee=E=>()=>{E(),s(null);};return jsxRuntime.jsxs("div",{className:"drawui-table-toolbar","data-table-toolbar":a.id,style:{left:w.x+w.width/2,top:A},onPointerDown:ue,children:[jsxRuntime.jsxs("div",{className:"drawui-table-split",children:[jsxRuntime.jsx("button",{className:"drawui-table-btn-main",title:drawuiCore.t("table.insertRowBelow"),onClick:()=>e.insertTableRowRelative(a.id,"below"),children:drawuiCore.t("table.insertRow")}),jsxRuntime.jsx("button",{className:`drawui-table-btn-caret ${d==="row"?"active":""}`,"data-table-insert-row":true,title:`${drawuiCore.t("table.insertRowAbove")} / ${drawuiCore.t("table.insertRowBelow")}`,onClick:()=>s(d==="row"?null:"row"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 10 10",width:"8",height:"8","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M1 3l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),d==="row"&&jsxRuntime.jsxs("div",{className:"drawui-table-menu",ref:l,"data-table-row-menu":true,children:[jsxRuntime.jsx("button",{onClick:ee(()=>e.insertTableRowRelative(a.id,"above")),children:drawuiCore.t("table.insertRowAbove")}),jsxRuntime.jsx("button",{onClick:ee(()=>e.insertTableRowRelative(a.id,"below")),children:drawuiCore.t("table.insertRowBelow")})]})]}),jsxRuntime.jsx("button",{title:`${drawuiCore.t("table.deleteRow")} \xB7 ${C}`,disabled:!x,onClick:()=>e.deleteTableRowsInSelection(a.id),children:drawuiCore.t("table.deleteRow")}),jsxRuntime.jsxs("div",{className:"drawui-table-split",children:[jsxRuntime.jsx("button",{className:"drawui-table-btn-main",title:drawuiCore.t("table.insertColRight"),onClick:()=>e.insertTableColumnRelative(a.id,"right"),children:drawuiCore.t("table.insertCol")}),jsxRuntime.jsx("button",{className:`drawui-table-btn-caret ${d==="col"?"active":""}`,"data-table-insert-col":true,title:`${drawuiCore.t("table.insertColLeft")} / ${drawuiCore.t("table.insertColRight")}`,onClick:()=>s(d==="col"?null:"col"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 10 10",width:"8",height:"8","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M1 3l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),d==="col"&&jsxRuntime.jsxs("div",{className:"drawui-table-menu",ref:l,"data-table-col-menu":true,children:[jsxRuntime.jsx("button",{onClick:ee(()=>e.insertTableColumnRelative(a.id,"left")),children:drawuiCore.t("table.insertColLeft")}),jsxRuntime.jsx("button",{onClick:ee(()=>e.insertTableColumnRelative(a.id,"right")),children:drawuiCore.t("table.insertColRight")})]})]}),jsxRuntime.jsx("button",{title:`${drawuiCore.t("table.deleteCol")} \xB7 ${g}`,disabled:!U,onClick:()=>e.deleteTableColsInSelection(a.id),children:drawuiCore.t("table.deleteCol")}),jsxRuntime.jsx("button",{title:drawuiCore.t("table.merge"),disabled:!b,onClick:()=>e.mergeTableCells(a.id),children:drawuiCore.t("table.merge")}),jsxRuntime.jsx("button",{title:drawuiCore.t("table.split"),disabled:!m,onClick:()=>e.splitTableCells(a.id),children:drawuiCore.t("table.split")})]})});var po=[...drawuiCore.MINDMAP_COLORS,"#1f2937","#9ca3af"],ho=["\u{1F4A1}","\u2B50","\u{1F525}","\u{1F4CC}","\u2705","\u2757","\u26A0\uFE0F","\u{1F3F7}\uFE0F"],Dr={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"},zt={fontSize:11,color:"#6b7280",marginBottom:4,display:"block"},Tt={display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},_t={border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:5,padding:"3px 6px",fontSize:12,color:"#374151",cursor:"pointer",lineHeight:1.5,whiteSpace:"nowrap"},hn={width:"100%",border:"1px solid #e5e7eb",borderRadius:5,padding:"4px 8px",fontSize:12,outline:"none",boxSizing:"border-box",background:"#ffffff",color:"#1f2937"},yo=react.memo(function({editor:e,mindMap:o}){let[,i]=react.useState(0);V(),react.useEffect(()=>{if(!e)return;let b=e.subscribe(()=>i(m=>m+1));return ()=>{b();}},[e]);let d=react.useRef(null);if(!e||!o||e.getMindMapEditingShapeId()!==o.id)return null;let s=e.getMindMapSelectedNode();if(!s||s.shapeId!==o.id)return null;let l=b=>{if(b.id===s.nodeId)return b;for(let m of b.children??[]){let C=l(m);if(C)return C}return null},a=l(o.root);if(!a)return null;let L=e.getCamera(),f=drawuiCore.layoutMindMap(o.root).positions.get(a.id);if(!f)return null;let u=L.zoom,p=L.pageToScreen({x:o.x+f.x,y:o.y+f.y}),M=p.x+f.width*u/2+14,O=p.y-80,y=Math.max(8,Math.min(M,(window.innerWidth||1024)-232-8)),k=Math.max(8,Math.min(O,(window.innerHeight||768)-320)),T=b=>{e.updateMindMapNode(o.id,a.id,b);};return jsxRuntime.jsxs("div",{ref:d,style:{...Dr,left:y,top:k},onMouseDown:b=>b.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.jsxs("span",{style:{display:"flex",alignItems:"center",gap:2},children:[!!a.children?.length&&jsxRuntime.jsx("button",{style:{..._t,padding:"1px 5px",color:"#6b7280"},"data-drawui-tip":a.collapsed?drawuiCore.t("mindmap.expand"):drawuiCore.t("mindmap.collapse"),onClick:()=>e.toggleMindMapCollapse(o.id,a.id),children:a.collapsed?drawuiCore.t("mindmap.expand"):drawuiCore.t("mindmap.collapse")}),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:{...hn,marginBottom:8},value:a.text,onChange:b=>T({text:b.target.value}),spellCheck:false}),jsxRuntime.jsx("span",{style:zt,children:drawuiCore.t("mindmap.level")}),jsxRuntime.jsxs("div",{style:{...Tt,marginBottom:10,justifyContent:"flex-start"},children:[jsxRuntime.jsx("button",{style:{..._t,color:"#3b82f6",borderColor:"#bfdbfe"},disabled:!e.canPromoteMindMapNode(o.id,a.id,1),onClick:()=>e.promoteMindMapNode(o.id,a.id,1),"data-drawui-tip":e.canPromoteMindMapNode(o.id,a.id,1)?drawuiCore.t("mindmap.promote1"):drawuiCore.t("mindmap.promoteDisabled"),children:drawuiCore.t("mindmap.promote1")}),jsxRuntime.jsx("button",{style:{..._t,color:"#3b82f6",borderColor:"#bfdbfe"},disabled:!e.canPromoteMindMapNode(o.id,a.id,2),onClick:()=>e.promoteMindMapNode(o.id,a.id,2),"data-drawui-tip":e.canPromoteMindMapNode(o.id,a.id,2)?drawuiCore.t("mindmap.promote2"):drawuiCore.t("mindmap.promoteDisabled"),children:drawuiCore.t("mindmap.promote2")})]}),jsxRuntime.jsx("div",{style:{...Tt,gap:4,marginBottom:10,flexWrap:"nowrap",justifyContent:"flex-end"},children:jsxRuntime.jsx("button",{style:{..._t,color:"#ef4444",borderColor:"#fecaca"},onClick:()=>e.deleteMindMapNode(o.id,a.id),children:drawuiCore.t("mindmap.deleteNode")})}),jsxRuntime.jsx("span",{style:zt,children:drawuiCore.t("mindmap.color")}),jsxRuntime.jsxs("div",{style:{...Tt,marginBottom:10},children:[jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.levelColor"),onClick:()=>T({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}}),po.map(b=>jsxRuntime.jsx("button",{"data-drawui-tip":b,onClick:()=>T({color:b}),style:{width:18,height:18,borderRadius:4,border:a.color===b?"2px solid #111827":"1px solid #d1d5db",background:b,cursor:"pointer",flexShrink:0}},b))]}),jsxRuntime.jsx("span",{style:zt,children:drawuiCore.t("mindmap.icon")}),jsxRuntime.jsxs("div",{style:{...Tt,marginBottom:10},children:[jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.noIcon"),onClick:()=>T({icon:void 0}),style:{width:22,height:22,borderRadius:4,border:a.icon?"1px solid #d1d5db":"2px solid #111827",background:"#f9fafb",cursor:"pointer",fontSize:11,color:"#9ca3af",lineHeight:1},children:"\u2205"}),ho.map(b=>jsxRuntime.jsx("button",{onClick:()=>T({icon:b}),style:{width:22,height:22,borderRadius:4,border:a.icon===b?"2px solid #111827":"1px solid #d1d5db",background:"#f9fafb",cursor:"pointer",fontSize:13,lineHeight:1},children:b},b)),jsxRuntime.jsx("input",{placeholder:"\u270F\uFE0F",defaultValue:a.icon&&!ho.includes(a.icon)?a.icon:"",onKeyDown:b=>{if(b.key==="Enter"){let m=b.target.value.trim();T({icon:m||void 0});}},onBlur:b=>{let m=b.target.value.trim();m!==a.icon&&T({icon:m||void 0});},style:{...hn,width:56,padding:"2px 4px",textAlign:"center"}})]}),jsxRuntime.jsx("span",{style:zt,children:drawuiCore.t("mindmap.note")}),jsxRuntime.jsx("input",{style:{...hn,marginBottom:6},value:a.note??"",placeholder:drawuiCore.t("mindmap.notePlaceholder"),onChange:b=>T({note:b.target.value||void 0}),spellCheck:false}),!!a.note&&jsxRuntime.jsxs("div",{style:{...Tt,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:()=>T({noteColor:void 0}),style:{width:16,height:16,borderRadius:3,border:a.noteColor?"1px solid #d1d5db":"2px solid #111827",background:"repeating-conic-gradient(#ef4444 0% 25%, #f59e0b 0% 50%, #10b981 0% 75%, #3b82f6 0% 100%)",cursor:"pointer"}}),po.map(b=>jsxRuntime.jsx("button",{onClick:()=>T({noteColor:b}),style:{width:16,height:16,borderRadius:3,border:a.noteColor===b?"2px solid #111827":"1px solid #d1d5db",background:b,cursor:"pointer"}},b))]})]})});var mn=220,fn=140,Ur="#fafafa";function Gr(t,e){let o=Math.min(t.x,e.x),i=Math.min(t.y,e.y),d=Math.max(t.x+t.width,e.x+e.width),s=Math.max(t.y+t.height,e.y+e.height);return {x:o,y:i,width:d-o,height:s-i}}function Zr(t){return {x:t.x+t.width/2,y:t.y+t.height/2}}function Fr(){return {x:0,y:0,width:0,height:0}}function Vr(t){let e=1/0,o=1/0,i=-1/0,d=-1/0,s=false;for(let l of t){let a=bn(l);a&&(s=true,a.x<e&&(e=a.x),a.y<o&&(o=a.y),a.x+a.width>i&&(i=a.x+a.width),a.y+a.height>d&&(d=a.y+a.height));}return s?{x:e,y:o,width:i-e,height:d-o}:null}function bn(t){switch(t.type){case "rectangle":case "sticky-note":case "icon":case "image":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 "table":case "text":return {x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height};case "circle":return {x:t.x-t.radius,y:t.y-t.radius,width:t.radius*2,height:t.radius*2};case "line":case "arrow":{let e=t.points;if(!e||e.length===0)return null;let o=1/0,i=1/0,d=-1/0,s=-1/0;for(let l of e)l.x<o&&(o=l.x),l.y<i&&(i=l.y),l.x>d&&(d=l.x),l.y>s&&(s=l.y);return {x:o,y:i,width:d-o,height:s-i}}case "draw":{let e=t,o=e.width,i=e.height;if(typeof o=="number"&&typeof i=="number")return {x:e.x-o/2,y:e.y-i/2,width:o,height:i};let d=e.points;if(!d||d.length===0)return null;let s=1/0,l=1/0,a=-1/0,L=-1/0;for(let w of d){let f=w.x+e.x,u=w.y+e.y;f<s&&(s=f),u<l&&(l=u),f>a&&(a=f),u>L&&(L=u);}return {x:s,y:l,width:a-s,height:L-l}}default:return null}}function Yr(t){let e=t.getCamera(),o=e.screenToPage({x:0,y:0}),i=e.screenToPage({x:window.innerWidth,y:window.innerHeight});return {x:o.x,y:o.y,width:i.x-o.x,height:i.y-o.y}}function jr(t,e,o){if(t.width<=0||t.height<=0)return {x:t.x-e/2,y:t.y-o/2,width:e,height:o};let i=e/o,d=t.width,s=d/i;s<t.height&&(s=t.height,d=s*i);let l=Zr(t);return {x:l.x-d/2,y:l.y-s/2,width:d,height:s}}function gn(t,e,o,i){let d=(t-o.left)/o.width,s=(e-o.top)/o.height;return {x:i.x+d*i.width,y:i.y+s*i.height}}var go=react.memo(function({editor:e}){let o=react.useRef(null),i=react.useRef(null),[d,s]=react.useState(false),[l,a]=react.useState(100),[L,w]=react.useState(false),[f,u]=react.useState(false);V();let p=react.useRef(null),M=react.useRef(null);react.useLayoutEffect(()=>{let m=o.current,C=i.current;if(!m||!C)return;let g=window.devicePixelRatio||1;m.width=Math.round(mn*g),m.height=Math.round(fn*g),m.style.width=`${mn}px`,m.style.height=`${fn}px`;},[d]);let O=react.useCallback(()=>{let m=o.current,C=i.current;if(!m||!C||!e)return;let g=m.getContext("2d");if(!g)return;let x=mn,U=fn,P=m.width,A=m.height,ue=e.getShapes(),ee=new Set(e.getSelectedIds()),E=drawuiCore.getTheme(),q=drawuiCore.hexToRgba(E.text,.16),pe=E.primary,S=drawuiCore.hexToRgba(E.primary,.18),se=drawuiCore.hexToRgba(E.primary,.85),ve=Vr(ue),$=Yr(e),G=ve?Gr(ve,$):$.width>0?$:Fr(),xe=jr(G,x,U);M.current=xe;let ke=P/xe.width,$e=A/xe.height,Ne=x/xe.width;g.setTransform(1,0,0,1,0,0),g.fillStyle=Ur,g.fillRect(0,0,P,A),g.setTransform(ke,0,0,$e,-ke*xe.x,-$e*xe.y),g.fillStyle=q;for(let Y of ue){let H=bn(Y);H&&g.fillRect(H.x,H.y,H.width,H.height);}g.fillStyle=pe;for(let Y of ue){if(!ee.has(Y.id))continue;let H=bn(Y);H&&g.fillRect(H.x,H.y,H.width,H.height);}g.fillStyle=S,g.fillRect($.x,$.y,$.width,$.height);let Fe=1.5/Ne;g.strokeStyle=se,g.lineWidth=Fe,g.lineJoin="round";let _e=Math.min($.width/6,$.height/6,6/Ne);if(g.beginPath(),_e*Ne<1)g.rect($.x,$.y,$.width,$.height);else {let Y=$.x,H=$.y,Ce=$.width,fe=$.height,te=Math.min(_e,Ce/2,fe/2);g.moveTo(Y+te,H),g.lineTo(Y+Ce-te,H),g.quadraticCurveTo(Y+Ce,H,Y+Ce,H+te),g.lineTo(Y+Ce,H+fe-te),g.quadraticCurveTo(Y+Ce,H+fe,Y+Ce-te,H+fe),g.lineTo(Y+te,H+fe),g.quadraticCurveTo(Y,H+fe,Y,H+fe-te),g.lineTo(Y,H+te),g.quadraticCurveTo(Y,H,Y+te,H),g.closePath();}g.stroke(),g.setTransform(1,0,0,1,0,0);},[e]);react.useEffect(()=>{if(!e||d)return;O();let m=e.subscribe(O),C=drawuiCore.subscribeTheme(O),g=()=>O();return window.addEventListener("resize",g),()=>{m(),C(),window.removeEventListener("resize",g);}},[e,d,O]),react.useEffect(()=>{if(!e)return;let m=()=>{let g=e.getCamera().getZoom();a(Math.round(g*100));};m();let C=e.subscribe(m);return ()=>{C();}},[e]);let I=react.useCallback((m,C)=>{if(!e)return;let g=e.getCamera(),x=g.getZoom(),U=window.innerWidth/2,P=window.innerHeight/2,A=g;A.x=U-m*x,A.y=P-C*x,e.requestRender();},[e]),y=m=>{if(!e||!i.current||m.button!==0)return;let C=i.current.getBoundingClientRect(),g=M.current;if(!g)return;let x=gn(m.clientX,m.clientY,C,g);p.current={pointerId:m.pointerId,rect:{left:C.left,top:C.top,width:C.width,height:C.height},canvasBox:g},m.currentTarget.setPointerCapture(m.pointerId),u(true),I(x.x,x.y);},k=m=>{if(!f||!e||!p.current||!i.current)return;let C=p.current,g=gn(m.clientX,m.clientY,C.rect,C.canvasBox);I(g.x,g.y);},T=m=>{if(f){u(false),p.current=null;try{m.currentTarget.releasePointerCapture(m.pointerId);}catch{}}},b=m=>{if(!e||!i.current)return;let C=M.current;if(!C)return;let g=i.current.getBoundingClientRect(),x=gn(m.clientX,m.clientY,g,C);I(x.x,x.y);};return jsxRuntime.jsxs("div",{className:`drawui-minimap ${d?"collapsed":""}`,children:[jsxRuntime.jsx("button",{className:"drawui-minimap-toggle",onClick:()=>s(m=>!m),"data-drawui-tip":d?drawuiCore.t("minimap.expand"):drawuiCore.t("minimap.collapse"),"data-drawui-tip-pos":"top","aria-label":d?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:d?jsxRuntime.jsx("polyline",{points:"9 6 15 12 9 18"}):jsxRuntime.jsx("polyline",{points:"15 6 9 12 15 18"})})}),!d&&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:[l,"%"]})]}),jsxRuntime.jsx("div",{ref:i,className:"drawui-minimap-canvas-wrap",style:{cursor:f?"grabbing":L?"pointer":"default"},onPointerEnter:()=>w(true),onPointerLeave:()=>w(false),children:jsxRuntime.jsx("canvas",{ref:o,className:"drawui-minimap-canvas",onPointerDown:y,onPointerMove:k,onPointerUp:T,onPointerCancel:T,onDoubleClick:b})})]})]})});var Te=t=>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:t}),Jr=[{type:"rectangle",labelKey:"shape.rectangle",glyph:Te(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:Te(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:Te(jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:Te(jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:Te(jsxRuntime.jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:Te(jsxRuntime.jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:Te(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:Te(jsxRuntime.jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:Te(jsxRuntime.jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:Te(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:Te(jsxRuntime.jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:Te(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:Te(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:Te(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:Te(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:Te(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"2.2",y:"9",width:"6.6",height:"6",rx:"2"}),jsxRuntime.jsx("rect",{x:"15.4",y:"3.8",width:"6.4",height:"5.2",rx:"1.8"}),jsxRuntime.jsx("rect",{x:"15.4",y:"15",width:"6.4",height:"5.2",rx:"1.8"}),jsxRuntime.jsx("path",{d:"M8.8 12 C 12.2 12 12.2 6.4 15.4 6.4"}),jsxRuntime.jsx("path",{d:"M8.8 12 C 12.2 12 12.2 17.6 15.4 17.6"})]}))}];function bo({editor:t,x:e,y:o,context:i,existingArrowId:d,defaultShapeType:s,onClose:l}){let a=react.useRef(null);V();let L=w=>{t?.createGeneratedConnection(i,{type:w,existingArrowId:d}),l();};return react.useEffect(()=>{let w=p=>{a.current&&!a.current.contains(p.target)&&l();},f=p=>{p.key==="Escape"&&(p.preventDefault(),l());},u=setTimeout(()=>{window.addEventListener("pointerdown",w,true),window.addEventListener("keydown",f,true);},0);return ()=>{clearTimeout(u),window.removeEventListener("pointerdown",w,true),window.removeEventListener("keydown",f,true);}},[l]),jsxRuntime.jsxs("div",{className:"drawui-gen-menu",ref:a,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:Jr.map(w=>jsxRuntime.jsxs("button",{className:`drawui-gen-shape-btn${w.type===s?" drawui-gen-shape-active":""}`,onClick:()=>L(w.type),"data-drawui-tip":drawuiCore.t(w.labelKey),children:[w.glyph,jsxRuntime.jsx("span",{className:"drawui-gen-shape-label",children:drawuiCore.t(w.labelKey)})]},w.type))}),jsxRuntime.jsx("div",{className:"drawui-gen-menu-hint",children:drawuiCore.t("menu.cancel")})]})}var ta=typeof navigator<"u"&&/mac|iphone|ipad/i.test(navigator.platform||navigator.userAgent);function ze(t){if(ta)switch(t){case "copy":return "\u2318C";case "copyAsImage":return "\u21E7\u2318C";case "paste":return "\u2318V";case "duplicate":return "\u2318D";case "copyStyle":return "\u2325\u2318C";case "pasteStyle":return "\u2325\u2318V";case "lock":return "\u2325\u2318L";case "delete":return "\u232B";case "group":return "\u2318G";case "ungroup":return "\u21E7\u2318G"}switch(t){case "copy":return "Ctrl + C";case "copyAsImage":return "Ctrl + Shift + C";case "paste":return "Ctrl + V";case "duplicate":return "Ctrl + D";case "copyStyle":return "Ctrl + Alt + C";case "pasteStyle":return "Ctrl + Alt + V";case "lock":return "Ctrl + Alt + L";case "delete":return "Del";case "group":return "Ctrl + G";case "ungroup":return "Ctrl + Shift + G"}}var vo={sep:true},na=t=>"sep"in t&&t.sep===true;function xo({editor:t,pos:e,onClose:o}){V();let[,i]=react.useState(0),d=react.useRef(null),[s,l]=react.useState(null),[a,L]=react.useState(null);react.useEffect(()=>{let x=t.subscribe(()=>i(U=>U+1));return ()=>{x();}},[t]),react.useLayoutEffect(()=>{let x=d.current;if(!x)return;let U=x.getBoundingClientRect(),P=Math.max(8,Math.min(e.x,window.innerWidth-U.width-8)),A=Math.max(8,Math.min(e.y,window.innerHeight-U.height-8));l({left:P,top:A});},[e.x,e.y]),react.useEffect(()=>{let x=A=>{d.current&&!d.current.contains(A.target)&&o();},U=A=>{A.key==="Escape"&&(A.preventDefault(),o());},P=setTimeout(()=>{window.addEventListener("pointerdown",x,true),window.addEventListener("keydown",U,true);},0);return ()=>{clearTimeout(P),window.removeEventListener("pointerdown",x,true),window.removeEventListener("keydown",U,true);}},[o]);let w=t.getSelectedIds(),f=w.length>0,u=e.shapeId,p=u?t.isShapeLocked(u):false,M=f&&!p&&t.hasCopiedStyle(),O=t.hasClipboard(),I=f&&!p,y=f&&!p?t.getSelectedGroupId():null,k=f&&!p&&w.length>=2&&!y,b=(u?t.getShapes().find(x=>x.id===u):void 0)?.groupId??null,m=y?true:!!b&&!p,C=x=>()=>{x(),o();},g;return p?g=b?[{key:"ctx.ungroup",shortcut:ze("ungroup"),action:C(()=>b&&t.ungroupIds([b]))}]:[{key:"ctx.unlock",action:()=>u&&t.setShapeLocked(u,false)}]:f?g=[{key:"ctx.copy",shortcut:ze("copy"),action:C(()=>t.copySelected())},{key:"ctx.copyAsImage",shortcut:ze("copyAsImage"),action:C(()=>{t.copySelectedAsImage();})},{key:"ctx.paste",shortcut:ze("paste"),disabled:!O,action:C(()=>t.paste())},{key:"ctx.duplicate",shortcut:ze("duplicate"),action:C(()=>t.duplicateSelected())},{key:"ctx.layer",submenu:[{key:"ctx.bringToFront",disabled:!I,action:()=>t.bringToFront()},{key:"ctx.bringForward",disabled:!I,action:()=>t.bringForward()},{key:"ctx.sendBackward",disabled:!I,action:()=>t.sendBackward()},{key:"ctx.sendToBack",disabled:!I,action:()=>t.sendToBack()}]},{key:"ctx.copyStyle",shortcut:ze("copyStyle"),action:C(()=>t.copyStyle())},{key:"ctx.pasteStyle",shortcut:ze("pasteStyle"),disabled:!M,action:C(()=>t.pasteStyle())},vo,{key:"ctx.rotate",submenu:[{key:"ctx.rotate90",action:()=>t.rotateSelected(90)},{key:"ctx.rotate180",action:()=>t.rotateSelected(180)},{key:"ctx.rotate270",action:()=>t.rotateSelected(270)}]},y?{key:"ctx.ungroup",shortcut:ze("ungroup"),disabled:!m,action:C(()=>t.ungroupSelected())}:{key:"ctx.group",shortcut:ze("group"),disabled:!k,action:C(()=>t.groupSelected())},vo,{key:"ctx.lock",shortcut:ze("lock"),action:C(()=>t.setSelectedShapesLocked(true))},{key:"ctx.delete",shortcut:ze("delete"),action:C(()=>t.deleteSelected())}]:g=[{key:"ctx.paste",shortcut:ze("paste"),disabled:!O,action:C(()=>t.paste())}],jsxRuntime.jsx("div",{ref:d,className:"drawui-context-menu",style:s?{left:s.left,top:s.top}:{visibility:"hidden",left:e.x,top:e.y},onContextMenu:x=>x.preventDefault(),children:g.map((x,U)=>na(x)?jsxRuntime.jsx("div",{className:"drawui-context-sep"},`sep-${U}`):x.submenu?jsxRuntime.jsxs("div",{className:"drawui-context-sub",onMouseEnter:()=>L(x.key),onMouseLeave:()=>L(null),children:[jsxRuntime.jsxs("button",{type:"button",className:"drawui-context-item",disabled:x.disabled,children:[jsxRuntime.jsx("span",{children:drawuiCore.t(x.key)}),jsxRuntime.jsx("svg",{className:"drawui-context-caret",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("polyline",{points:"9 18 15 12 9 6"})})]}),a===x.key&&jsxRuntime.jsx("div",{className:"drawui-context-submenu",children:x.submenu.map(P=>jsxRuntime.jsx("button",{type:"button",className:"drawui-context-item",disabled:P.disabled,onClick:()=>{P.action(),o();},children:jsxRuntime.jsx("span",{children:drawuiCore.t(P.key)})},P.key))})]},x.key):jsxRuntime.jsxs("button",{type:"button",className:"drawui-context-item",disabled:x.disabled,onClick:x.action,children:[jsxRuntime.jsx("span",{children:drawuiCore.t(x.key)}),x.shortcut&&jsxRuntime.jsx("span",{className:"drawui-context-kbd",children:x.shortcut})]},x.key))})}var ca={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",table:"tool.table",image:"tool.image"};function kn(t){let e=t instanceof Error?t.message:String(t);return e.startsWith("image.tooLarge")?drawuiCore.t("image.tooLarge"):`${drawuiCore.t("image.uploadFailed")}\uFF1A${e}`}function da({initialTool:t="select",className:e="",themeColor:o,theme:i,onThemeChange:d,language:s="zh-CN",data:l,onChange:a,onReady:L,imageUpload:w}){let f=react.useRef(null),u=react.useRef(null),p=react.useRef(null),[M,O]=react.useState(null);V();let[I,y]=react.useState(t),[k,T]=react.useState(false),[b,m]=react.useState(0),[C,g]=react.useState(false),[x,U]=react.useState("straight"),[P,A]=react.useState("end"),[ue,ee]=react.useState(false),[E,q]=react.useState(void 0),[pe,S]=react.useState(100),[se,ve]=react.useState(null),[$,G]=react.useState(null),[xe,ke]=react.useState(false),[$e,Ne]=react.useState(false),[Fe,_e]=react.useState(false),[Y,H]=react.useState(null),[Ce,fe]=react.useState(null),[te,De]=react.useState(false),[X,Ee]=react.useState(null),[He,tt]=react.useState(null),K=react.useRef(null),Ve=react.useRef(0),Le=react.useRef(null),v=react.useRef(a);v.current=a;let D=react.useRef(L);D.current=L,react.useEffect(()=>{if(!f.current)return;let h=new drawuiCore.Editor(f.current,{theme:o?{primary:o,editBorder:o,selection:{outline:o,handleStroke:o,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(o,.1),shadow:o}}:void 0,language:s,shapes:l,persist:!l,imageUpload:w});p.current=h,O(h),window.__drawuiEditor=h,h.setHighlighterColor(Et()),h.setStickyNoteColor(It()),D.current?.(h),t&&h.setActiveTool(t);let R=h.subscribe(()=>{y(h.getActiveTool());let z=h.getSelectedIds();m(z.length);let Re=h.getShapes().filter(Xe=>z.includes(Xe.id)&&(Xe.type==="line"||Xe.type==="arrow"));if(g(Re.length>0),Re.length>0&&Re[0].connectionType?U(Re[0].connectionType):Re.length>0&&U("straight"),Re.length>0){let Xe=Re.find(jt=>jt.type==="arrow");Xe&&(A(Xe.arrowHead??"end"),ee(Xe.dashed??false));}S(Math.round(h.getCamera().getZoom()*100)),q(h.getArrowStyle()),Ne(h.canUndo()),_e(h.canRedo());let je=h.getSelectedUml();H(je),je||Ee(null);let ot=h.getSelectedMindMap();fe(ot),h.getMindMapEditingShapeId()||De(false),v.current?.(h.getData());}),he=h.subscribeNotifications(z=>{G({type:"success",text:z}),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),3500);}),Ae=h.subscribeUi(z=>{if(z.kind==="imageError"){G({type:"error",text:kn(z.message)}),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),4e3);return}if(z.kind==="drag"){ke(z.active);return}z.kind==="shapeTypeMenu"&&tt({x:z.screenX,y:z.screenY,context:z.context,existingArrowId:z.existingArrowId,defaultShapeType:z.defaultShapeType});});return ()=>{R(),he(),Ae(),K.current&&clearTimeout(K.current),cancelAnimationFrame(Ve.current),h.dispose();}},[t]),react.useEffect(()=>{if(!o)return;let h=u.current;h&&(h.style.setProperty("--dw-primary",o),h.style.setProperty("--dw-primary-hover",drawuiCore.shadeColor(o,-0.12)),h.style.setProperty("--dw-primary-weak",drawuiCore.hexToRgba(o,.1)),h.style.setProperty("--dw-primary-contrast","#ffffff"),h.style.setProperty("--dw-shadow-primary",`0 2px 8px ${drawuiCore.hexToRgba(o,.3)}`)),p.current?.setTheme({primary:o,editBorder:o,selection:{outline:o,handleStroke:o,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(o,.1),shadow:o}});},[o]);let[_,W]=react.useState(i??drawuiCore.DEFAULT_PAGE_THEME),J=i??_,le=react.useCallback(h=>{W(h),d?.(h);},[d]);react.useEffect(()=>{document.documentElement.setAttribute("data-theme",J),drawuiCore.setTheme({grid:drawuiCore.PAGE_THEMES[J].grid}),p.current?.requestRender();},[J]),react.useEffect(()=>{drawuiCore.setLanguage(s),p.current?.setLanguage(s);},[s]);let Ye=react.useCallback(h=>{p.current?.setActiveTool(h);},[]),Ie=react.useCallback(()=>{p.current?.zoomIn();},[]),j=react.useCallback(()=>{p.current?.zoomOut();},[]),Be=react.useCallback(()=>{p.current?.resetZoom();},[]),nt=react.useCallback(()=>{let h=!k;T(h),p.current?.setShowGrid(h);},[k]),We=react.useCallback(()=>{p.current?.undo();},[]),ge=react.useCallback(()=>{p.current?.redo();},[]),ut=react.useCallback(h=>{p.current?.downloadImage("drawui",h,{background:"#ffffff"});},[]),c=react.useCallback(()=>{p.current?.downloadJSON("drawui-data");},[]),r=react.useCallback(h=>{let R=new FileReader;R.onload=()=>{let he=typeof R.result=="string"?R.result:"";if(p.current?.importJSON(he)??false){let z=p.current?.getShapes().length??0;G({type:"success",text:drawuiCore.t("import.success",{n:z})});}else G({type:"error",text:drawuiCore.t("import.fail")});K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),3500);},R.onerror=()=>{G({type:"error",text:drawuiCore.t("import.fail")}),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),3500);},R.readAsText(h,"utf-8");},[]),Z=react.useCallback(h=>{let R=p.current,he=f.current;if(!R||!he)return;if(R.isPointerDown()){Le.current!==null&&(Le.current=null,ve(null));return}let Ae=h.clientX,z=h.clientY;cancelAnimationFrame(Ve.current),Ve.current=requestAnimationFrame(()=>{let Ue=he.getBoundingClientRect(),Re=Ae-Ue.left,je=z-Ue.top,ot=Re+12,Xe=je+12,jt=R.getSelectedUml()?.id,ht=R.getUmlRowAtScreenPoint({x:Re,y:je});if(ht&&ht.shape.id!==jt&&ht.text&&R.isUmlRowTextTruncated(ht)){Le.current!==ht.text&&(Le.current=ht.text,ve({text:ht.text,x:ot,y:Xe}));return}let bt=R.getShapeAtScreenPoint({x:Re,y:je});bt&&bt.text&&R.isShapeTextTruncated(bt.id)?Le.current!==bt.text&&(Le.current=bt.text,ve({text:bt.text,x:ot,y:Xe})):Le.current!==null&&(Le.current=null,ve(null));});},[]),ce=react.useCallback(()=>{ve(null);},[]),ne=react.useCallback(h=>{let R=p.current,he=f.current;if(!R||!he)return;let Ae=he.getBoundingClientRect(),z=h.clientX-Ae.left,Ue=h.clientY-Ae.top,Re=R.getUmlRowAtScreenPoint({x:z,y:Ue});if(Re){Ee(Re.shape.id);return}let je=R.getMindMapNodeAtScreenPoint({x:z,y:Ue});if(je){R.beginMindMapEdit(je.shapeId,je.nodeId);return}let ot=R.getTableAtScreenPoint({x:z,y:Ue});ot&&R.beginTableEdit(ot.shapeId,ot.row,ot.col);},[]),pt=react.useCallback(()=>{tt(null);},[]),[xt,Cn]=react.useState(null),ko=react.useCallback(()=>Cn(null),[]),Co=react.useCallback(h=>{h.preventDefault();let R=p.current,he=f.current;if(!R||!he||R.isEditing())return;let Ae=he.getBoundingClientRect(),z=R.getShapeAtScreenPoint({x:h.clientX-Ae.left,y:h.clientY-Ae.top});z?R.isShapeLocked(z.id)?R.selectShapeRaw(z.id):R.getSelectedIds().includes(z.id)||R.selectShape(z.id,h.shiftKey):R.selectShape("",false),Cn({x:h.clientX,y:h.clientY,shapeId:z?.id??null});},[]),So=react.useCallback(h=>{h.preventDefault();},[]);return jsxRuntime.jsxs("div",{ref:u,className:`drawui-canvas-board ${e}`,onContextMenu:So,onDragOver:h=>{h.dataTransfer?.types?.includes("Files")&&(h.preventDefault(),h.dataTransfer.dropEffect="copy");},onDrop:h=>{let R=Array.from(h.dataTransfer?.files||[]).filter(Ue=>(Ue.type||"").startsWith("image/"));if(!R.length)return;h.preventDefault();let he=p.current;if(!he)return;let Ae=h.currentTarget.getBoundingClientRect(),z=he.getCamera().screenToPage({x:h.clientX-Ae.left,y:h.clientY-Ae.top});he.insertImageFiles(R,z).then(()=>{!he.hasImageUploader()&&he.hasTemporaryImages()&&(G({type:"success",text:drawuiCore.t("image.temporaryInserted")}),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),4e3));}).catch(Ue=>{G({type:"error",text:kn(Ue)}),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),4e3);});},children:[jsxRuntime.jsx("canvas",{ref:f,className:"drawui-canvas",onMouseMove:Z,onMouseLeave:ce,onDoubleClick:ne,onContextMenu:Co}),se&&jsxRuntime.jsx("div",{className:"drawui-tooltip",style:{left:se.x,top:se.y},children:se.text}),jsxRuntime.jsx(sn,{activeTool:I,onToolChange:Ye,showGrid:k,onToggleGrid:nt,pageTheme:J,onPageThemeChange:le,canUndo:$e,canRedo:Fe,onUndo:We,onRedo:ge,onExport:ut,onExportData:c,onImportData:r,onHighlighterColorChange:h=>p.current?.setHighlighterColor(h),onStickyNoteColorChange:h=>p.current?.setStickyNoteColor(h),onInsertIcon:h=>p.current?.insertIcon(h),onInsertTable:(h,R)=>p.current?.insertTable(h,R),onInsertImage:h=>{let R=p.current;R&&R.insertImageFiles(h).then(()=>{!R.hasImageUploader()&&R.hasTemporaryImages()&&(G({type:"success",text:drawuiCore.t("image.temporaryInserted")}),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),4e3));}).catch(he=>{G({type:"error",text:kn(he)}),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),4e3);});},arrowStyle:E,onArrowStyleChange:h=>p.current?.setArrowStyle(h),hidden:xe}),jsxRuntime.jsx(cn,{onZoomIn:Ie,onZoomOut:j,onReset:Be,zoomLevel:pe}),jsxRuntime.jsx(Yn,{editor:M,selectedCount:b,hasLineSelection:C,currentConnectionType:x,currentArrowHead:P,currentDashed:ue,hidden:xe}),jsxRuntime.jsx(eo,{editor:M,umlClass:Y,editing:X}),jsxRuntime.jsx(uo,{editor:M,hidden:xe}),jsxRuntime.jsx(so,{editor:M,panelOpen:te}),jsxRuntime.jsx(ro,{editor:M,panelOpen:te,onOpenPanel:()=>De(true)}),te&&jsxRuntime.jsx(yo,{editor:M,mindMap:Ce}),jsxRuntime.jsx(go,{editor:M}),He&&jsxRuntime.jsx(bo,{editor:M,x:He.x,y:He.y,context:He.context,existingArrowId:He.existingArrowId,defaultShapeType:He.defaultShapeType,onClose:pt}),xt&&M&&jsxRuntime.jsx(xo,{editor:M,pos:xt,onClose:ko}),jsxRuntime.jsxs("div",{className:"drawui-status-bar",children:[jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:drawuiCore.t(ca[I])})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:b===0?drawuiCore.t("status.none"):drawuiCore.t("status.selected",{n:b})})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsxs("span",{children:[pe,"%"]})})]}),$&&jsxRuntime.jsxs("div",{className:"drawui-toast",children:[$.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"})]}),$.text]})]})}exports.CanvasBoard=da;exports.Toolbar=sn;exports.ZoomControl=cn;
1
+ 'use strict';var react=require('react'),drawuiCore=require('drawui-core'),jsxRuntime=require('react/jsx-runtime');function Y(){let[t,e]=react.useState(drawuiCore.getLanguage());return react.useEffect(()=>drawuiCore.subscribeLanguage(()=>e(drawuiCore.getLanguage())),[]),t}var Pn=["#ffeb3b","#22c55e","#3b82f6","#ec4899","#8b5cf6","#f97316"],Hn="drawui:highlighterColor";function At(){if(typeof window>"u")return drawuiCore.DEFAULT_HIGHLIGHTER_COLOR;try{let t=window.localStorage.getItem(Hn);return t&&/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():drawuiCore.DEFAULT_HIGHLIGHTER_COLOR}catch{return drawuiCore.DEFAULT_HIGHLIGHTER_COLOR}}function An(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Hn,t);}catch{}}var Dn="drawui:stickyNoteColor";function Kt(){if(typeof window>"u")return drawuiCore.STICKY_NOTE_DEFAULT_COLOR;try{let t=window.localStorage.getItem(Dn);return t&&/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():drawuiCore.STICKY_NOTE_DEFAULT_COLOR}catch{return drawuiCore.STICKY_NOTE_DEFAULT_COLOR}}function On(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Dn,t);}catch{}}function Go({icon:t,size:e=24,ink:o=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:[t.disc&&jsxRuntime.jsx("circle",{cx:drawuiCore.ICON_GRID/2,cy:drawuiCore.ICON_GRID/2,r:drawuiCore.ICON_GRID/2-1,fill:t.disc}),t.layers.map((i,d)=>{let l=i.fill??"ink",s=i.stroke??"ink";return jsxRuntime.jsx("path",{d:i.d,fill:l==="none"?"none":l==="ink"?o:l,...s==="none"?{}:{stroke:s==="ink"?o:s,strokeWidth:i.w??1.8,strokeLinecap:"round",strokeLinejoin:"round"}},d)}),t.label&&jsxRuntime.jsx("text",{x:drawuiCore.ICON_GRID/2,y:drawuiCore.ICON_GRID/2+.5,textAnchor:"middle",dominantBaseline:"central",fontFamily:"sans-serif",fontSize:t.label.size??13,fill:t.label.color,children:t.label.text})]})}var _n="drawui:recentIcons",Wn=12;function dn(t,e){let o=/^#?([0-9a-f]{6})$/i.exec(t.trim());if(!o)return t;let i=parseInt(o[1],16);return `rgba(${i>>16&255}, ${i>>8&255}, ${i&255}, ${e})`}function Zo(){if(typeof window>"u")return [];try{let t=JSON.parse(window.localStorage.getItem(_n)||"[]");return Array.isArray(t)?t.filter(e=>typeof e=="string").slice(0,Wn):[]}catch{return []}}function Fo(t){if(!(typeof window>"u"))try{window.localStorage.setItem(_n,JSON.stringify(t));}catch{}}var zn=t=>({"--dw-icon-cat":t,"--dw-icon-cat-soft":dn(t,.12)}),Un=react.memo(function({onPick:e,onClose:o,initialCat:i}){Y();let[d,l]=react.useState(""),[s,r]=react.useState(i??drawuiCore.ICON_CATEGORIES[0].id),[C,b]=react.useState(Zo),[f,p]=react.useState(drawuiCore.isIconCatalogLoaded),a=react.useRef(null),x=react.useRef(null);react.useEffect(()=>{x.current?.focus();},[]),react.useEffect(()=>{if(f)return;let c=true;return drawuiCore.loadIconCatalog().then(()=>{c&&p(true);}).catch(()=>{}),()=>{c=false;}},[f]),react.useEffect(()=>{let c=w=>{let g=a.current;g&&(g.contains(w.target)||w.target?.closest?.("[data-icon-toggle]")||o());},m=w=>{w.key==="Escape"&&(w.stopPropagation(),o());};return window.addEventListener("pointerdown",c),window.addEventListener("keydown",m),()=>{window.removeEventListener("pointerdown",c),window.removeEventListener("keydown",m);}},[o]);let I=react.useMemo(()=>C.map(c=>drawuiCore.getIcon(c)).filter(c=>!!c),[C,f]),S=react.useMemo(()=>d.trim()?drawuiCore.searchIcons(d):s==="recent"?I:drawuiCore.iconsByCategory(s),[d,s,I,f]),N=s==="recent"?drawuiCore.ICON_CATEGORY_INK.status:drawuiCore.ICON_CATEGORY_INK[s]??drawuiCore.ICON_DEFAULT_INK,T=d.trim()?drawuiCore.t("icon.search"):s==="recent"?drawuiCore.t("icon.recent"):drawuiCore.t(drawuiCore.ICON_CATEGORIES.find(c=>c.id===s)?.labelKey??"icon.search"),R=c=>{e(c),b(m=>{let w=[c.id,...m.filter(g=>g!==c.id)].slice(0,Wn);return Fo(w),w});};return jsxRuntime.jsxs("div",{className:"drawui-icon-panel",ref:a,style:{"--dw-icon-accent":N,"--dw-icon-soft":dn(N,.08),"--dw-icon-ring":dn(N,.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:x,value:d,onChange:c=>l(c.target.value),onKeyDown:c=>{c.key==="Enter"&&S.length>0&&R(S[0]);},placeholder:drawuiCore.t("icon.search"),"aria-label":drawuiCore.t("icon.search")}),jsxRuntime.jsx("span",{className:"drawui-icon-count",children:S.length})]}),!d.trim()&&jsxRuntime.jsxs("div",{className:"drawui-icon-cats",children:[I.length>0&&jsxRuntime.jsxs("button",{type:"button",className:`drawui-icon-cat${s==="recent"?" active":""}`,style:zn(drawuiCore.ICON_CATEGORY_INK.status),onClick:()=>r("recent"),children:[jsxRuntime.jsx("i",{className:"drawui-icon-dot"}),drawuiCore.t("icon.recent")]}),drawuiCore.ICON_CATEGORIES.map(c=>jsxRuntime.jsxs("button",{type:"button",className:`drawui-icon-cat${s===c.id?" active":""}`,style:zn(drawuiCore.ICON_CATEGORY_INK[c.id]??drawuiCore.ICON_DEFAULT_INK),onClick:()=>r(c.id),children:[jsxRuntime.jsx("i",{className:"drawui-icon-dot"}),drawuiCore.t(c.labelKey)]},c.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:T}),jsxRuntime.jsx("span",{className:"drawui-icon-card-count",children:S.length})]}),jsxRuntime.jsxs("div",{className:"drawui-icon-grid",children:[S.map(c=>jsxRuntime.jsx("button",{type:"button",className:"drawui-icon-item",title:`${c.zh} / ${c.en}`,"aria-label":`${c.zh} ${c.en}`,onClick:()=>R(c),children:jsxRuntime.jsx(Go,{icon:c,size:30,ink:drawuiCore.iconInk(c)})},c.id)),S.length===0&&jsxRuntime.jsx("div",{className:"drawui-icon-empty",children:drawuiCore.t("icon.empty")})]})]})]})});var Yn=new Map;function Jo(t){let e=Yn.get(t.id);if(e)return e;let o="";try{let i=drawuiCore.renderSVGString(t.build(),{padding:18,background:"#ffffff"});o=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`;}catch{o="";}return Yn.set(t.id,o),o}var jn=react.memo(function({onPick:e,onClose:o}){Y();let[i,d]=react.useState(""),[l,s]=react.useState("all"),r=react.useRef(null),C=react.useRef(null);react.useEffect(()=>{C.current?.focus();},[]),react.useEffect(()=>{let a=I=>{let S=r.current;S&&(S.contains(I.target)||I.target?.closest?.("[data-template-toggle]")||o());},x=I=>{I.key==="Escape"&&(I.stopPropagation(),o());};return window.addEventListener("pointerdown",a),window.addEventListener("keydown",x),()=>{window.removeEventListener("pointerdown",a),window.removeEventListener("keydown",x);}},[o]);let b=react.useMemo(()=>i.trim()?drawuiCore.searchTemplates(i):l==="all"?drawuiCore.TEMPLATES:drawuiCore.TEMPLATES.filter(a=>a.cat===l),[i,l]),f=drawuiCore.getLanguage().startsWith("zh"),p=a=>f?a.zh:a.en;return jsxRuntime.jsxs("div",{className:"drawui-icon-panel drawui-template-panel",ref:r,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:C,value:i,onChange:a=>d(a.target.value),onKeyDown:a=>{a.key==="Enter"&&b.length>0&&e(b[0]);},placeholder:drawuiCore.t("template.search"),"aria-label":drawuiCore.t("template.search")}),jsxRuntime.jsx("span",{className:"drawui-icon-count",children:b.length})]}),!i.trim()&&jsxRuntime.jsxs("div",{className:"drawui-icon-cats",children:[jsxRuntime.jsx("button",{type:"button",className:`drawui-icon-cat${l==="all"?" active":""}`,onClick:()=>s("all"),children:drawuiCore.t("template.all")}),drawuiCore.TEMPLATE_CATEGORIES.map(a=>jsxRuntime.jsx("button",{type:"button",className:`drawui-icon-cat${l===a.id?" active":""}`,onClick:()=>s(a.id),children:f?a.zh:a.en},a.id))]}),jsxRuntime.jsxs("div",{className:"drawui-template-grid",children:[b.map(a=>{let x=Jo(a);return jsxRuntime.jsxs("button",{type:"button",className:"drawui-template-card",title:p(a),onClick:()=>e(a),children:[jsxRuntime.jsx("span",{className:"drawui-template-thumb",children:x?jsxRuntime.jsx("img",{src:x,alt:""}):null}),jsxRuntime.jsx("span",{className:"drawui-template-name",children:p(a)})]},a.id)}),b.length===0&&jsxRuntime.jsx("div",{className:"drawui-template-empty",children:drawuiCore.t("template.empty")})]})]})});var De=t=>`${t.x.toFixed(1)},${t.y.toFixed(1)}`,Xn=(t,e)=>{let o=e*Math.PI/180;return {x:t.x*Math.cos(o)-t.y*Math.sin(o),y:t.x*Math.sin(o)+t.y*Math.cos(o)}},St={x:Math.SQRT1_2,y:-Math.SQRT1_2},un={x:4.6,y:19.4},Lt={x:19,y:5};function pn(t,e,o){let i={x:-o.y,y:o.x},d=s=>({x:e.x-o.x*s,y:e.y-o.y*s}),l=(s,r)=>({x:s.x+i.x*r,y:s.y+i.y*r});switch(t){case "end":{let s=d(5.6);return jsxRuntime.jsx("polygon",{points:`${De(e)} ${De(l(s,2.7))} ${De(l(s,-2.7))}`,fill:"currentColor",stroke:"none"})}case "inheritance":case "realization":{let s=d(8.6);return jsxRuntime.jsx("polygon",{points:`${De(e)} ${De(l(s,3.5))} ${De(l(s,-3.5))}`,fill:"none"})}case "aggregation":case "composition":{let s=d(4.3),r=d(8.6);return jsxRuntime.jsx("polygon",{points:`${De(e)} ${De(l(s,2.7))} ${De(r)} ${De(l(s,-2.7))}`,fill:t==="composition"?"currentColor":"none",stroke:"currentColor"})}case "dependency":{let s=Xn({x:-o.x,y:-o.y},30),r=Xn({x:-o.x,y:-o.y},-30);return jsxRuntime.jsx("path",{d:`M ${De({x:e.x+s.x*5.8,y:e.y+s.y*5.8})} L ${De(e)} L ${De({x:e.x+r.x*5.8,y:e.y+r.y*5.8})}`,fill:"none"})}default:return null}}function je(t,e){let o=e||t==="dependency"||t==="realization",i=o?{x:Lt.x-St.x*8.6,y:Lt.y-St.y*8.6}:Lt,d={x:-St.x,y:-St.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:un.x,y1:un.y,x2:i.x,y2:i.y,strokeDasharray:o?"3 2.6":void 0}),(t==="end"||t==="both")&&pn("end",Lt,St),(t==="start"||t==="both")&&pn("end",un,d),t!=="none"&&t!=="start"&&t!=="end"&&t!=="both"?pn(t,Lt,St):null]})}var Bt=t=>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:t})}),tr=[{type:"straight",labelKey:"style.connection.straight",icon:Bt("M3 12h18")},{type:"polyline",labelKey:"style.connection.polyline",icon:Bt("M4 8 C 12 8, 12 16, 20 16")},{type:"orthogonal",labelKey:"style.connection.orthogonal",icon:Bt("M5 5v14h14")},{type:"curve",labelKey:"style.connection.curve",icon:Bt("M3 13 C 6 7, 9 7, 12 12 C 15 17, 18 17, 21 11")}],Qn=[{key:"none",arrowHead:"none",dashed:false,labelKey:"style.arrowhead.none",icon:je("none",false)},{key:"end",arrowHead:"end",dashed:false,labelKey:"style.arrowhead.end",icon:je("end",false)},{key:"start",arrowHead:"start",dashed:false,labelKey:"style.arrowhead.start",icon:je("start",false)},{key:"both",arrowHead:"both",dashed:false,labelKey:"style.arrowhead.both",icon:je("both",false)},{key:"none-dashed",arrowHead:"none",dashed:true,labelKey:"style.arrowhead.none-dashed",icon:je("none",true)},{key:"both-dashed",arrowHead:"both",dashed:true,labelKey:"style.arrowhead.both-dashed",icon:je("both",true)}],Jn=[{key:"inheritance",arrowHead:"inheritance",dashed:false,labelKey:"style.arrowhead.inheritance",icon:je("inheritance",false)},{key:"composition",arrowHead:"composition",dashed:false,labelKey:"style.arrowhead.composition",icon:je("composition",false)},{key:"aggregation",arrowHead:"aggregation",dashed:false,labelKey:"style.arrowhead.aggregation",icon:je("aggregation",false)},{key:"dependency",arrowHead:"dependency",dashed:true,labelKey:"style.arrowhead.dependency",icon:je("dependency",true)},{key:"realization",arrowHead:"realization",dashed:true,labelKey:"style.arrowhead.realization",icon:je("realization",true)}],qn=[...Qn,...Jn];function nr(t,e){let o=qn.find(i=>i.arrowHead===t&&i.dashed===e);return o?o.key:qn.find(i=>i.arrowHead===t)?.key}var _t=react.memo(function({connectionType:e,arrowHead:o,dashed:i,onConnectionTypeChange:d,onArrowStyleChange:l,onOptionHover:s,onOptionLeave:r}){Y();let C=nr(o,i),b=f=>jsxRuntime.jsx("div",{className:"drawui-connection-row",children:f.map(p=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${C===p.key?" active":""}`,onClick:()=>l(p),"data-drawui-tip":s?void 0:drawuiCore.t(p.labelKey),onMouseEnter:s?a=>s(p.labelKey,a.currentTarget):void 0,onMouseLeave:s?r:void 0,"aria-label":drawuiCore.t(p.labelKey),type:"button",children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:p.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(p.labelKey)})]},p.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:tr.map(f=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${e===f.type?" active":""}`,onClick:()=>d(f.type),"data-drawui-tip":s?void 0:drawuiCore.t(f.labelKey),onMouseEnter:s?p=>s(f.labelKey,p.currentTarget):void 0,onMouseLeave:s?r:void 0,"aria-label":drawuiCore.t(f.labelKey),type:"button",children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:f.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(f.labelKey)})]},f.type))}),jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.arrow")}),b(Qn),jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.uml")}),b(Jn)]})});var eo=[{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"})]})}],ir=[{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"}]}],sr=new Map(eo.map(t=>[t.type,t.icon])),lr=new Set(eo.map(t=>t.type)),cr=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsxRuntime.jsx("path",{d:"M20 15h-5v5"})]}),dr=[{type:"arrow",icon:"M5 12h14M12 5l7 7-7 7",labelKey:"toolbar.arrow"},{type:"text",icon:"M4 7V4h16v3M9 20h6M12 4v16",labelKey:"toolbar.text"}],ur="M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3Z",hn=8,pr=6,yn="M0 -1Q0.24 -0.24 1 0Q0.24 0.24 0 1Q-0.24 0.24 -1 0Q-0.24 -0.24 0 -1Z",hr=[{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"}],mn=react.memo(function({activeTool:e,onToolChange:o,showGrid:i,onToggleGrid:d,pageTheme:l="light",onPageThemeChange:s,canUndo:r=false,canRedo:C=false,onUndo:b,onRedo:f,onExport:p,onExportData:a,onImportData:x,onHighlighterColorChange:I,onStickyNoteColorChange:S,onInsertIcon:N,onInsertTemplate:T,onInsertTable:R,onInsertImage:c,arrowStyle:m,onArrowStyleChange:w,hidden:g=false}){let[k,U]=react.useState(false),[D,H]=react.useState(false),[te,ne]=react.useState(null),[K,G]=react.useState(false),[me,M]=react.useState(false),[oe,xe]=react.useState(At),[z,Z]=react.useState(false),[fe,Ie]=react.useState(Kt),[He,ke]=react.useState(false),[Ge,Be]=react.useState(false),[q,O]=react.useState(void 0),[Ce,Me]=react.useState(false),de=react.useRef(null),st=u=>{let _=Array.from(u.target.files||[]);_.length&&c?.(_),u.target.value="";},[X,ze]=react.useState(null),Se=react.useRef(null),_e=react.useRef(null),A=react.useRef(null),Ae=react.useRef(null),ge=react.useRef(null);Y(),react.useEffect(()=>{let u=_=>{if(_.ctrlKey||_.metaKey||_.altKey||_.shiftKey||_.key!=="s"&&_.key!=="S")return;let ve=_.target;ve&&(ve.tagName==="INPUT"||ve.tagName==="TEXTAREA"||ve.isContentEditable)||(_.preventDefault(),O("sticker"),ke(Te=>!Te));};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[]);let v=[{format:"png",labelKey:"toolbar.export.png"},{format:"svg",labelKey:"toolbar.export.svg"},{format:"pdf",labelKey:"toolbar.export.pdf"}],$=()=>{Se.current&&(clearTimeout(Se.current),Se.current=null),G(true);},F=()=>{Se.current=window.setTimeout(()=>G(false),200);},V=["light","warm","gray","purple","green","eye-care"],J={light:"#fafafa",warm:"#f8f5e9",gray:"#f1f3f5",purple:"#f7f5ff",green:"#f0fdf4","eye-care":"#f5f0e1"},re=react.useRef(null),qe=()=>{G(false),ee(),re.current?.click();},Qe=u=>{let _=u.target.files?.[0];_&&x?.(_),u.target.value="";},Ze=()=>{_e.current&&(clearTimeout(_e.current),_e.current=null),U(true);},We=()=>{_e.current=window.setTimeout(()=>{U(false),ee();},200);},lt=()=>{A.current&&(clearTimeout(A.current),A.current=null),H(true);},Fe=()=>{A.current=window.setTimeout(()=>{H(false),ee();},200);},ae=(u,_)=>{let ve=u.closest(".drawui-toolbar");if(!ve)return;let Te=u.getBoundingClientRect(),gt=ve.getBoundingClientRect(),y=Te.bottom+46>window.innerHeight;ne({label:_,x:Te.left-gt.left+Te.width/2,y:y?Te.top-gt.top-8:Te.bottom-gt.top+8,above:y});},ee=()=>ne(null),h=()=>{Ae.current&&(clearTimeout(Ae.current),Ae.current=null),M(true);},E=()=>{Ae.current=window.setTimeout(()=>M(false),200);},Je=u=>{xe(u),An(u),I?.(u),o("highlighter");},Ue=()=>{ge.current&&(clearTimeout(ge.current),ge.current=null),Z(true);},Ve=()=>{ge.current=window.setTimeout(()=>Z(false),200);},nn=u=>{Ie(u),On(u),S?.(u),o("sticky-note"),Z(false);};return jsxRuntime.jsx("div",{className:"drawui-toolbar-container",style:{display:g?"none":void 0},children:jsxRuntime.jsxs("div",{className:"drawui-toolbar",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="select"?"active":""}`,onClick:()=>o("select"),onMouseEnter:u=>ae(u.currentTarget,"toolbar.select"),onMouseLeave:ee,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:u=>ae(u.currentTarget,"toolbar.hand"),onMouseLeave:ee,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:Ze,onMouseLeave:We,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${lr.has(e)?"active":""}`,onClick:()=>{o("rounded-rectangle"),U(false),ee();},"data-drawui-tip":k?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"})})}),k&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-shape-menu",children:jsxRuntime.jsx("div",{className:"drawui-shape-menu-scroll",children:ir.map(u=>jsxRuntime.jsxs("div",{className:"drawui-shape-group",children:[jsxRuntime.jsx("div",{className:"drawui-shape-group-title",children:drawuiCore.t(u.labelKey)}),jsxRuntime.jsx("div",{className:"drawui-shape-group-grid",children:u.items.map(_=>{let ve=_.labelKey??`tool.${_.type}`;return jsxRuntime.jsx("button",{type:"button",className:`drawui-toolbar-shape-item ${e===_.type?"active":""}`,onClick:()=>{o(_.type),U(false),ee();},onMouseEnter:Te=>ae(Te.currentTarget,ve),onMouseLeave:ee,"aria-label":drawuiCore.t(ve),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:sr.get(_.type)})},`${u.key}-${_.type}`)})})]},u.key))})})]}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:Ue,onMouseLeave:Ve,children:[jsxRuntime.jsxs("button",{className:`drawui-toolbar-button ${e==="sticky-note"?"active":""}`,onClick:()=>{o("sticky-note"),Z(false),ee();},"data-drawui-tip":z?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:cr}),jsxRuntime.jsx("span",{className:"drawui-toolbar-color-chip",style:{background:fe}})]}),z&&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(u=>jsxRuntime.jsx("button",{type:"button","aria-label":u,className:`drawui-sticky-swatch${fe.toLowerCase()===u.toLowerCase()?" active":""}`,style:{background:u},onClick:()=>nn(u)},u))})]})]}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${He?"active":""}`,"data-icon-toggle":"","data-drawui-tip":He?void 0:drawuiCore.t("toolbar.icon"),onClick:()=>{O(void 0),ke(u=>!u),ee();},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"})]})}),He&&jsxRuntime.jsx(Un,{initialCat:q,onPick:u=>N?.(u.id),onClose:()=>ke(false)})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${Ge?"active":""}`,"data-template-toggle":"","data-drawui-tip":Ge?void 0:drawuiCore.t("toolbar.template"),onClick:()=>{ke(false),Be(u=>!u),ee();},children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3.5",y:"3.5",width:"7.5",height:"7.5",rx:"1.6"}),jsxRuntime.jsx("rect",{x:"13",y:"3.5",width:"7.5",height:"7.5",rx:"1.6"}),jsxRuntime.jsx("rect",{x:"3.5",y:"13",width:"7.5",height:"7.5",rx:"1.6"}),jsxRuntime.jsx("path",{d:"M13.6 16.8h6.4M16.8 13.6v6.4"})]})}),Ge&&jsxRuntime.jsx(jn,{onPick:u=>{T?.(u),Be(false);},onClose:()=>Be(false)})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:lt,onMouseLeave:Fe,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="arrow"?"active":""}`,onClick:()=>{o("arrow"),H(false),ee();},"data-drawui-tip":D?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"})})}),D&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-arrow-menu",onPointerDown:u=>{u.target.closest("button")||(H(false),ee());},children:jsxRuntime.jsx(_t,{connectionType:m?.connectionType??"straight",arrowHead:m?.arrowHead??"end",dashed:!!m?.dashed,onConnectionTypeChange:u=>{w?.({connectionType:u}),o("arrow"),H(false),ee();},onArrowStyleChange:u=>{w?.({arrowHead:u.arrowHead,dashed:u.dashed}),o("arrow"),H(false),ee();},onOptionHover:(u,_)=>ae(_,u),onOptionLeave:ee})})]}),dr.filter(u=>u.type!=="arrow").map(u=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===u.type?"active":""}`,onClick:()=>o(u.type),"data-drawui-tip":drawuiCore.t(u.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:u.icon})})},u.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:ur})})}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:h,onMouseLeave:E,children:[jsxRuntime.jsxs("button",{className:`drawui-toolbar-button ${e==="highlighter"?"active":""}`,onClick:()=>o("highlighter"),onMouseEnter:u=>ae(u.currentTarget,"toolbar.highlighter"),onMouseLeave:ee,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:yn,transform:"translate(7.4 5.4) scale(2.4)"}),jsxRuntime.jsx("path",{d:yn,transform:"translate(18.4 3.4) scale(2.5)"}),jsxRuntime.jsx("path",{d:yn,transform:"translate(21 10.6) scale(2.2)"})]})]}),jsxRuntime.jsx("span",{className:"drawui-toolbar-color-chip",style:{background:oe}})]}),me&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-highlighter-grid",children:Pn.map(u=>jsxRuntime.jsx("button",{type:"button","aria-label":u,className:`drawui-highlighter-swatch${oe.toLowerCase()===u.toLowerCase()?" active":""}`,style:{background:u},onClick:()=>Je(u)},u))})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),hr.map(u=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===u.type?"active":""}`,onClick:()=>o(u.type),"data-drawui-tip":drawuiCore.t(u.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:u.icon})})},u.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("rect",{x:"2.2",y:"9",width:"6.6",height:"6",rx:"2"}),jsxRuntime.jsx("rect",{x:"15.4",y:"3.8",width:"6.4",height:"5.2",rx:"1.8"}),jsxRuntime.jsx("rect",{x:"15.4",y:"15",width:"6.4",height:"5.2",rx:"1.8"}),jsxRuntime.jsx("path",{d:"M8.8 12 C 12.2 12 12.2 6.4 15.4 6.4"}),jsxRuntime.jsx("path",{d:"M8.8 12 C 12.2 12 12.2 17.6 15.4 17.6"})]})}),jsxRuntime.jsx("button",{className:"drawui-toolbar-button",onClick:()=>de.current?.click(),"data-drawui-tip":drawuiCore.t("toolbar.image"),"data-image-toggle":true,children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsxRuntime.jsx("circle",{cx:"8.5",cy:"9.5",r:"1.6"}),jsxRuntime.jsx("path",{d:"M21 15.5l-4.5-4.5L6 21"})]})}),jsxRuntime.jsx("input",{ref:de,type:"file",accept:"image/*",multiple:true,style:{display:"none"},onChange:st}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${Ce?"active":""}`,onClick:()=>Me(u=>!u),"data-drawui-tip":drawuiCore.t("toolbar.table"),"data-table-toggle":true,children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsxRuntime.jsx("line",{x1:"3",y1:"9.3",x2:"21",y2:"9.3"}),jsxRuntime.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),jsxRuntime.jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]})}),Ce&&jsxRuntime.jsxs("div",{className:"drawui-table-picker",children:[jsxRuntime.jsx("div",{className:"drawui-table-picker-hint",children:X?`${X.rows} \xD7 ${X.cols}`:drawuiCore.t("table.pickHint")}),jsxRuntime.jsx("div",{className:"drawui-table-picker-grid",children:Array.from({length:pr*hn},(u,_)=>{let ve=Math.floor(_/hn),Te=_%hn,gt=X&&ve<X.rows&&Te<X.cols;return jsxRuntime.jsx("button",{type:"button","aria-label":`${ve+1}x${Te+1}`,className:"drawui-table-picker-cell",style:gt?{borderColor:"var(--dw-primary)",background:"var(--dw-primary-weak)"}:void 0,onMouseEnter:()=>ze({rows:ve+1,cols:Te+1}),onClick:()=>{R?.(ve+1,Te+1),Me(false),ze(null),ee();}},_)})})]})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:"drawui-toolbar-button",onClick:b,disabled:!r,style:r?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:f,disabled:!C,style:C?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:$,onMouseLeave:F,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${K?"active":""}`,"data-drawui-tip":K?void 0:drawuiCore.t("toolbar.more"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"5",cy:"12",r:"1.8",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"1.8",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"19",cy:"12",r:"1.8",fill:"currentColor"})]})}),K&&jsxRuntime.jsxs("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-more-grid",children:[jsxRuntime.jsxs("button",{className:"drawui-toolbar-more-row",onClick:()=>{d(),G(false);},children:[jsxRuntime.jsx("span",{className:"drawui-toolbar-more-icon",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("span",{className:"drawui-toolbar-more-label",children:drawuiCore.t("toolbar.grid")}),i&&jsxRuntime.jsx("svg",{className:"drawui-toolbar-more-check",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})})]}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-more-section",children:[jsxRuntime.jsx("div",{className:"drawui-toolbar-more-section-title",children:drawuiCore.t("toolbar.pageTheme")}),jsxRuntime.jsx("div",{className:"drawui-toolbar-more-themes",children:V.map(u=>jsxRuntime.jsx("button",{type:"button",className:`drawui-toolbar-more-theme-swatch${l===u?" active":""}`,style:{background:J[u]},onClick:()=>{s?.(u),G(false);},title:drawuiCore.t(`pageTheme.${u}`),"aria-label":drawuiCore.t(`pageTheme.${u}`)},u))})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-export-divider"}),v.map(u=>jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{p?.(u.format),G(false);},children:drawuiCore.t(u.labelKey)},u.format)),jsxRuntime.jsx("div",{className:"drawui-toolbar-export-divider"}),jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{a?.(),G(false);},children:drawuiCore.t("toolbar.export.data")}),jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:qe,children:drawuiCore.t("toolbar.import.data")})]})]}),jsxRuntime.jsx("input",{ref:re,type:"file",accept:".json,application/json",style:{display:"none"},onChange:Qe}),te&&jsxRuntime.jsx("div",{className:`drawui-shape-tip ${te.above?"is-above":"is-below"}`,style:{left:te.x,top:te.y},children:drawuiCore.t(te.label)})]})})});var gn=react.memo(function({onZoomIn:e,onZoomOut:o,onReset:i,zoomLevel:d=100}){return Y(),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:[d,"%"]}),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:i,"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 no=["#ffffff","#f1f5f9","#e2e8f0","#ede9fe","#dbeafe","#e0e7ff","#dcfce7","#fef9c3","#fee2e2"],oo=["#0f172a","#475569","#94a3b8","#8b5cf6","#3b82f6","#1d4ed8","#16a34a","#eab308","#dc2626"],vr=no.filter(t=>t!=="#f1f5f9"),xr=[...vr,...oo],kr=[...no,...oo],ro=15,ao="drawui:customColors";function Cr(){if(typeof window>"u")return [];try{let t=window.localStorage.getItem(ao);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e.filter(o=>typeof o=="string").slice(-ro):[]}catch{return []}}function Mr(t){if(!(typeof window>"u"))try{window.localStorage.setItem(ao,JSON.stringify(t));}catch{}}var bn=[{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}],to=(t,e)=>!!t&&!!e&&t.toLowerCase()===e.toLowerCase(),Et=10,yt=12,pt=t=>!t||t==="transparent",io=react.memo(function({editor:e,selectedCount:o,hasLineSelection:i,currentConnectionType:d,currentArrowHead:l,currentDashed:s,hidden:r=false}){Y();let C=!!e?.getEditingShapeId(),[b,f]=react.useState(null),[p,a]=react.useState(null),[,x]=react.useState(0),I=react.useRef(null),S=react.useRef(null),N=react.useRef(null),[T,R]=react.useState({tw:168,th:42,pw:228,ph:160}),[c,m]=react.useState(Cr),w=react.useRef(null),g=react.useCallback(h=>{let E=h.trim().toLowerCase();/^#[0-9a-f]{6}$/.test(E)&&m(Je=>{let Ue=Je.filter(Ve=>Ve!==E);for(Ue.push(E);Ue.length>ro;)Ue.shift();return Mr(Ue),Ue});},[]);if(react.useEffect(()=>{let h=w.current;if(!h)return;let E=()=>{h.value&&g(h.value);};return h.addEventListener("change",E),()=>h.removeEventListener("change",E)},[g,p]),react.useEffect(()=>{if(!e)return;let h=e.subscribe(()=>x(E=>(E+1)%1e6));return ()=>{h();}},[e]),react.useEffect(()=>{a(null);},[o,C]),react.useEffect(()=>{if(!p)return;let h=E=>{I.current&&!I.current.contains(E.target)&&a(null);};return document.addEventListener("pointerdown",h,true),()=>document.removeEventListener("pointerdown",h,true)},[p]),react.useLayoutEffect(()=>{let h=S.current?.offsetWidth??T.tw,E=S.current?.offsetHeight??T.th,Je=N.current?.offsetWidth??T.pw,Ue=N.current?.offsetHeight??T.ph;R(Ve=>Ve.tw===h&&Ve.th===E&&Ve.pw===Je&&Ve.ph===Ue?Ve:{tw:h,th:E,pw:Je,ph:Ue});}),!e||o===0||C)return null;let k=e.getSelectedIds(),D=e.getShapes().filter(h=>k.includes(h.id)),H=D[0],te=H?.id??"",ne=D.length===1&&D[0].type==="mind-map"?e.getMindMapSelectedNode():null,K=ne&&ne.shapeId===D[0].id?ne:null,G=K?e.canPromoteMindMapNode(K.shapeId,K.nodeId,1):false,me=K?e.canPromoteMindMapNode(K.shapeId,K.nodeId,2):false,M=H?.style.fillColor,oe=H?.style.strokeColor??"#1f2937",xe=H?.textColor??"#1f2937",z=H?.highlightColor,Z={fill:M,stroke:oe,text:xe,highlight:z},fe=D.length>0&&D.every(h=>h.type==="sticky-note"),Ie={fill:H?.style.fillOpacity??1,stroke:H?.style.strokeOpacity??1,highlight:H?.highlightOpacity??1},He=h=>b&&b.key===`${te}:${h}`?b.value:Ie[h]??1,ke=(h,E)=>{switch(h){case "stroke":e.updateSelectedShapesStyle({strokeColor:E});break;case "fill":e.updateSelectedShapesStyle({fillColor:E});break;case "text":e.updateSelectedShapesText({textColor:E});break;case "highlight":e.updateSelectedShapesText({highlightColor:E});break}},Ge=(h,E)=>{f({key:`${te}:${h}`,value:E}),h==="highlight"?e.updateSelectedShapesText({highlightOpacity:E}):h==="stroke"?e.updateSelectedShapesStyle({strokeOpacity:E}):e.updateSelectedShapesStyle({fillOpacity:E});},Be=h=>e.updateConnectionType(h),q=h=>e.updateArrowStyle({arrowHead:h.arrowHead,dashed:h.dashed}),O=!!i&&D.length>0&&D.every(h=>h.type==="line"||h.type==="arrow"),Ce=D.length>0&&D.every(h=>h.type==="text"),Me=D.length>0&&D.every(h=>h.type==="sticky-note"||h.type==="icon"),de=O?bn.filter(h=>h.key==="stroke"):Me?bn.filter(h=>h.key!=="stroke"):bn,st=h=>h.key==="stroke"&&O?"style.line":h.labelKey,X=p&&p!=="more"?de.find(h=>h.key===p):void 0,ze=!!p&&(p==="more"||p==="prefix"||p==="level"||!!X),Se=fe&&X?.key==="fill",_e=e.getCamera(),A=drawuiCore.getContentBounds(D,0),Ae=_e.pageToScreen({x:A.x,y:A.y}),ge=_e.pageToScreen({x:A.x+A.width,y:A.y+A.height}),v=window.innerWidth,$=window.innerHeight,F=ge.y+Et,V=Ae.y-Et,J=T.th+(ze?Et+T.ph:0),re=F+J<=$-yt,qe=V-J>=yt,Qe=re||!qe,Ze=(Ae.x+ge.x)/2,We=(h,E,Je)=>Math.max(E,Math.min(h,Math.max(E,Je))),lt=We(Ze-T.tw/2,yt,v-T.tw-yt),Fe=Qe?F:V-T.th,ae=We(Ze-T.pw/2,yt,v-T.pw-yt),ee=ze?We(Qe?Fe+T.th+Et:Fe-Et-T.ph,yt,$-T.ph-yt):0;return jsxRuntime.jsxs("div",{className:"drawui-style-floating",ref:I,style:r?{display:"none"}:void 0,children:[jsxRuntime.jsxs("div",{className:"drawui-style-toolbar",ref:S,style:{left:lt,top:Fe},children:[de.map(h=>jsxRuntime.jsxs("button",{className:`drawui-style-tool-btn${p===h.key?" active":""}`,onClick:()=>a(p===h.key?null:h.key),"data-drawui-tip":drawuiCore.t(st(h)),type:"button",children:[h.key==="fill"&&jsxRuntime.jsx("span",{className:`drawui-st-swatch${pt(M)?" drawui-st-none":""}`,style:pt(M)?void 0:{background:M}}),h.key==="stroke"&&(O?jsxRuntime.jsx("span",{className:`drawui-st-line${pt(oe)?" drawui-st-line-none":""}`,style:pt(oe)?void 0:{background:oe}}):jsxRuntime.jsx("span",{className:`drawui-st-frame${pt(oe)?" drawui-st-frame-none":""}`,style:pt(oe)?void 0:{borderColor:oe}})),h.key==="text"&&jsxRuntime.jsx("span",{className:"drawui-st-text",style:{color:xe},children:"A"}),h.key==="highlight"&&jsxRuntime.jsx("span",{className:`drawui-st-hl${pt(z)?" drawui-st-none":""}`,style:pt(z)?void 0:{background:z},children:"A"})]},h.key)),K&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${p==="level"?" active":""}`,onClick:()=>a(p==="level"?null:"level"),"data-drawui-tip":drawuiCore.t("mindmap.level"),type:"button",children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"5"}),jsxRuntime.jsx("polyline",{points:"6 11 12 5 18 11"})]})}),i&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${p==="more"?" active":""}`,onClick:()=>a(p==="more"?null:"more"),"data-drawui-tip":drawuiCore.t("style.connection"),type:"button",children:"\u22EF"}),Ce&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${p==="prefix"?" active":""}`,onClick:()=>a(p==="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"})]})})]}),ze&&jsxRuntime.jsx("div",{className:"drawui-style-popover",ref:N,style:{left:ae,top:ee},children:p==="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")})]}):p==="level"?K?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("mindmap.level")}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:8},children:[jsxRuntime.jsx("button",{type:"button",disabled:!G,onClick:()=>e.promoteMindMapNode(K.shapeId,K.nodeId,1),"data-drawui-tip":G?drawuiCore.t("mindmap.promote1"):drawuiCore.t("mindmap.promoteDisabled"),style:{border:"1px solid #bfdbfe",background:G?"#ffffff":"#f9fafb",color:G?"#3b82f6":"#9ca3af",borderRadius:5,padding:"4px 10px",fontSize:12,cursor:G?"pointer":"not-allowed"},children:drawuiCore.t("mindmap.promote1")}),jsxRuntime.jsx("button",{type:"button",disabled:!me,onClick:()=>e.promoteMindMapNode(K.shapeId,K.nodeId,2),"data-drawui-tip":me?drawuiCore.t("mindmap.promote2"):drawuiCore.t("mindmap.promoteDisabled"),style:{border:"1px solid #bfdbfe",background:me?"#ffffff":"#f9fafb",color:me?"#3b82f6":"#9ca3af",borderRadius:5,padding:"4px 10px",fontSize:12,cursor:me?"pointer":"not-allowed"},children:drawuiCore.t("mindmap.promote2")})]})]}):null:X?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t(st(X))}),jsxRuntime.jsxs("div",{className:"drawui-color-row",children:[X.hasTransparent&&!Se&&jsxRuntime.jsx("button",{className:`drawui-color-swatch drawui-color-swatch-transparent${pt(Z[X.key])?" active":""}`,onClick:()=>ke(X.key,"transparent"),"aria-label":drawuiCore.t("style.none"),type:"button"}),(Se?drawuiCore.STICKY_NOTE_COLORS:X.hasTransparent?xr:kr).map(h=>jsxRuntime.jsx("button",{className:`drawui-color-swatch${to(h,Z[X.key])?" active":""}`,style:{background:h},onClick:()=>ke(X.key,h),"aria-label":h,type:"button"},h)),c.map(h=>jsxRuntime.jsx("button",{className:`drawui-color-swatch drawui-color-custom${to(h,Z[X.key])?" active":""}`,style:{background:h},onClick:()=>ke(X.key,h),"aria-label":h,type:"button"},`custom-${h}`)),jsxRuntime.jsxs("span",{className:"drawui-color-swatch drawui-color-add","data-drawui-tip":drawuiCore.t("style.addColor"),children:["+",jsxRuntime.jsx("input",{ref:w,type:"color",defaultValue:"#3b82f6",className:"drawui-color-add-input","aria-label":drawuiCore.t("style.addColor")})]})]}),X.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(He(X.key)*100),onChange:h=>Ge(X.key,Number(h.target.value)/100),className:"drawui-opacity-slider"}),jsxRuntime.jsxs("span",{className:"drawui-opacity-value",children:[Math.round(He(X.key)*100),"%"]})]})]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(_t,{connectionType:d??"straight",arrowHead:l??"end",dashed:!!s,onConnectionTypeChange:Be,onArrowStyleChange:q})})})]})});var vn=14,co=20,Rr=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af"],Pr=[12,14,16,18,20,24];function uo(t,e){let o=t,i="",d=o.charAt(0);if(o.length>1&&(d==="+"||d==="-"||d==="#"||d==="~")&&o.charAt(1)===" "&&(i=d,o=o.slice(2)),o=o.replace(/^\s+|\s+$/g,""),e==="attribute"){let f=o.indexOf(":");return f===-1?{visibility:i,name:o,type:"",params:"",returnType:""}:{visibility:i,name:o.slice(0,f).replace(/^\s+|\s+$/g,""),type:o.slice(f+1).replace(/^\s+|\s+$/g,""),params:"",returnType:""}}let l=o.indexOf("(");if(l===-1){let f=o.lastIndexOf(":");return f===-1?{visibility:i,name:o,type:"",params:"",returnType:""}:{visibility:i,name:o.slice(0,f).replace(/^\s+|\s+$/g,""),type:"",params:"",returnType:o.slice(f+1).replace(/^\s+|\s+$/g,"")}}let s=o.slice(0,l).replace(/^\s+|\s+$/g,""),r=o.indexOf(")",l);if(r===-1)return {visibility:i,name:s,type:"",params:o.slice(l+1).replace(/^\s+|\s+$/g,""),returnType:""};let C=o.slice(l+1,r).replace(/^\s+|\s+$/g,""),b=o.slice(r+1).replace(/^\s+|\s+$/g,"");return b.startsWith(":")&&(b=b.slice(1).replace(/^\s+|\s+$/g,"")),{visibility:i,name:s,type:"",params:C,returnType:b}}function Hr(t,e){let o=e.visibility?`${e.visibility} `:"";return t==="attribute"?`${o}${e.name}${e.type?`: ${e.type}`:""}`:`${o}${e.name}(${e.params??""})${e.returnType?`: ${e.returnType}`:""}`}var ho=react.memo(function({editor:e,umlClass:o,editing:i}){let[,d]=react.useState(0);Y(),react.useEffect(()=>{if(!e)return;let v=e.subscribe(()=>d($=>$+1));return ()=>{v();}},[e]);let[l,s]=react.useState(null),[r,C]=react.useState(false),[b,f]=react.useState(null),p=react.useRef(null),a=react.useRef(null),x=react.useCallback((v,$)=>{p.current&&(clearTimeout(p.current),p.current=null),s({section:v,rowId:$}),C(false);},[]),I=react.useCallback(()=>{p.current&&clearTimeout(p.current),p.current=window.setTimeout(()=>{s(null),C(false);},150);},[]);if(!e||!o||i!==o.id)return null;let S=e.getCamera(),{id:N,x:T,y:R,width:c,height:m,className:w,methods:g}=o,k=o.type==="uml-interface",U=k?[]:o.attributes,D=c/2,H=m/2,te=drawuiCore.UML_HEADER_HEIGHT,ne=drawuiCore.UML_LINE_HEIGHT,K=drawuiCore.UML_PADDING_X,G=drawuiCore.UML_PADDING_Y,me=k?0:U.length>0?U.length*ne+G*2:G*2,M=S.zoom,oe=(c-K*2)*M,xe=4*M,z=S.pageToScreen({x:T-D+K,y:R}),Z=S.pageToScreen({x:T,y:R-H+te/2}),fe=v=>S.pageToScreen({x:T,y:v}).y,Ie=ne*M,He=v=>R+(-H+te+G+ne/2+v*ne),ke=v=>R+(-H+te+me+G+ne/2+v*ne),Ge=R+(-H+te+me),Be=R+H,q={background:"#ffffff",borderWidth:1,borderStyle:"solid",borderColor:"transparent",outline:"none",padding:0,fontFamily:"sans-serif",boxSizing:"border-box"},O=(v,$)=>{if(!U.find(J=>J.id===v))return;let V=uo($,"attribute");e.updateUmlClass(N,{attributes:U.map(J=>J.id===v?{...J,...V}:J)});},Ce=(v,$)=>{if(!g.find(re=>re.id===v))return;let V=uo($,"method"),J=g.map(re=>re.id===v?{...re,...V}:re);k?e.updateUmlInterface(N,{methods:J}):e.updateUmlClass(N,{methods:J});},Me=(v,$,F)=>{a.current={section:v,from:$},F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/plain",`${v}:${$}`);},de=v=>{v.preventDefault(),v.dataTransfer.dropEffect="move";},st=(v,$,F)=>{F.preventDefault();let V=a.current;!V||V.section!==v||(v==="attribute"?e.reorderUmlAttribute(N,V.from,$):e.reorderUmlMethod(N,V.from,$),a.current=null);},X=(v,$,F,V)=>{let J=fe(V),re=l?.section===v&&l.rowId===F.id,qe=(F.fontSize||drawuiCore.UML_FONT_SIZE)*M,Qe=F.textColor||"#1f2937",Ze={position:"absolute",left:z.x-vn*M-xe,top:J-Ie/2,width:vn*M+xe+oe+co*M,height:Ie,display:"flex",alignItems:"center",gap:2,pointerEvents:"none",zIndex:53},We={...q,width:oe,height:Ie-2,fontSize:qe,color:Qe,textDecoration:F.strikethrough?"line-through":"none",pointerEvents:"auto",...re?{borderColor:"var(--dw-primary)"}:{}},lt={width:vn*M,height:Ie-2,cursor:"grab",color:"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",fontSize:12*M,lineHeight:1,opacity:re?1:.55,pointerEvents:"auto"},Fe={width:co*M,height:Ie-6,border:"none",background:"transparent",color:"#9ca3af",cursor:"pointer",borderRadius:3,fontSize:14*M,opacity:re?1:.35,pointerEvents:"auto"};return jsxRuntime.jsxs("div",{style:Ze,onDragOver:de,onDrop:ae=>st(v,$,ae),children:[jsxRuntime.jsx("span",{style:lt,draggable:true,onDragStart:ae=>Me(v,$,ae),"data-drawui-tip":drawuiCore.t("uml.drag"),children:"\u22EE\u22EE"}),jsxRuntime.jsx("input",{style:We,value:b&&b.rowId===F.id?b.text:Hr(v,F),onChange:ae=>{f({rowId:F.id,text:ae.target.value}),v==="attribute"?O(F.id,ae.target.value):Ce(F.id,ae.target.value);},onFocus:()=>x(v,F.id),onBlur:()=>{f(null),I();},spellCheck:false}),jsxRuntime.jsx("button",{style:Fe,onMouseDown:ae=>ae.preventDefault(),onClick:()=>{v==="attribute"?e.removeUmlAttribute(N,F.id):e.removeUmlMethod(N,F.id);},"data-drawui-tip":drawuiCore.t("uml.delete"),children:"\xD7"})]},F.id)},ze=(v,$,F)=>{let V=fe($),J=v==="attribute";return jsxRuntime.jsxs("button",{onMouseDown:re=>re.preventDefault(),onClick:()=>J?e.addUmlAttribute(N):e.addUmlMethod(N),className:"drawui-uml-add-row",style:{position:"absolute",left:z.x,top:V-9*M,height:18*M,padding:`0 ${6*M}px`,fontSize:11*M,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":F,children:[jsxRuntime.jsx("span",{style:{fontSize:13*M,lineHeight:1},children:"+"}),jsxRuntime.jsx("span",{children:F})]},`add-${v}`)},Se=()=>{if(!l||l.section==="className")return null;let v=l.section,$=l.rowId,V=(v==="attribute"?U:g).find(E=>E.id===$);if(!V)return null;let J=224*M,re=30*M,qe=S.pageToScreen({x:T,y:R}).x,Qe=S.pageToScreen({x:T,y:R-H}).y,Ze=20*M,We=Qe-re-Ze,lt=qe-J/2,Fe=We+re,ae=V.textColor||"#1f2937",ee=V.fontSize||drawuiCore.UML_FONT_SIZE,h=!!V.strikethrough;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:qe-.5,top:Fe,width:1,height:Ze,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),jsxRuntime.jsxs("div",{className:"drawui-uml-toolbar",style:{position:"absolute",left:lt,top:We,width:J,height:re,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:6,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",gap:4*M,padding:`0 ${6*M}px`,pointerEvents:"auto",zIndex:60,fontSize:12*M},onMouseDown:E=>E.preventDefault(),children:[jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{onClick:()=>C(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:ae,fontSize:13*M,textDecoration:h?"line-through":"none"},children:"A"}),jsxRuntime.jsx("span",{style:{width:10*M,height:2*M,background:ae,marginLeft:3,borderRadius:1}})]}),r&&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(N,v,V.id,{textColor:null}),C(false);},style:{width:14,height:14,border:"1px solid #e5e7eb",background:"transparent",cursor:"pointer",borderRadius:2},"data-drawui-tip":drawuiCore.t("uml.defaultColor")}),Rr.map(E=>jsxRuntime.jsx("button",{onClick:()=>{e.updateUmlRowStyle(N,v,V.id,{textColor:E}),C(false);},style:{width:14,height:14,border:"none",background:E,cursor:"pointer",borderRadius:2},"data-drawui-tip":E},E))]})]}),jsxRuntime.jsx("select",{value:ee,onChange:E=>e.updateUmlRowStyle(N,v,V.id,{fontSize:Number(E.target.value)}),style:{border:"1px solid #e5e7eb",borderRadius:3,padding:`0 ${2*M}px`,fontSize:12*M,height:20*M,background:"#ffffff"},"data-drawui-tip":drawuiCore.t("uml.fontSize"),children:Pr.map(E=>jsxRuntime.jsx("option",{value:E,children:E},E))}),jsxRuntime.jsx("button",{onClick:()=>e.updateUmlRowStyle(N,v,V.id,{strikethrough:!h}),className:"drawui-uml-toolbar-btn","data-drawui-tip":drawuiCore.t("uml.strikethrough"),style:{border:"none",background:h?"var(--dw-primary-weak)":"transparent",cursor:"pointer",padding:2,borderRadius:3},children:jsxRuntime.jsx("span",{style:{fontWeight:700,fontSize:13*M,textDecoration:"line-through"},children:"A"})}),jsxRuntime.jsx("button",{onClick:()=>{v==="attribute"?e.removeUmlAttribute(N,V.id):e.removeUmlMethod(N,V.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*M,height:14*M,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"})]})})]})]})},_e=S.pageToScreen({x:T-D,y:R}).x,A=S.pageToScreen({x:T,y:R-H}).y,Ae=c*M,ge=m*M;return jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:_e+1,top:A+1,width:Math.max(0,Ae-2),height:Math.max(0,ge-2),background:"#ffffff",pointerEvents:"none",zIndex:51}}),jsxRuntime.jsx("input",{style:{...q,position:"absolute",left:Z.x-oe/2,top:Z.y-te*M/2+2,width:oe,height:te*M-4,textAlign:"center",fontWeight:700,fontSize:(o.fontSize||drawuiCore.UML_FONT_SIZE)*M,color:o.textColor||"#1f2937",pointerEvents:"auto",zIndex:52,...l?.section==="className"?{borderColor:"var(--dw-primary)"}:{}},value:w,onChange:v=>k?e.updateUmlInterface(N,{className:v.target.value}):e.updateUmlClass(N,{className:v.target.value}),onFocus:()=>x("className",""),onBlur:I,spellCheck:false}),!k&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[U.map((v,$)=>X("attribute",$,v,He($))),ze("attribute",Ge,"\u5C5E\u6027")]}),g.map((v,$)=>X("method",$,v,ke($))),ze("method",Be,drawuiCore.t("uml.method")),Se()]})});var go=react.memo(function({editor:e,panelOpen:o,onOpenPanel:i}){let[,d]=react.useState(0);Y(),react.useEffect(()=>{if(!e)return;let m=e.subscribe(()=>d(w=>w+1));return ()=>{m();}},[e]);let l=react.useRef(false),s=react.useRef(false),r=e?.getMindMapEditingShapeId()??null,C=e?.getMindMapSelectedNode()?.nodeId??"",b=r?`${r}\0${C}`:"";if(react.useEffect(()=>{l.current=false;},[b]),!e)return null;let f=e.getMindMapEditingShapeId();if(!f||o)return null;let p=e.getMindMapSelectedNode();if(!p||p.shapeId!==f)return null;let a=e.getMindMapNode(f,p.nodeId),x=e.getMindMapNodeScreenRect(f,p.nodeId);if(!a||!x)return null;let I=e.getCamera().getZoom(),S=drawuiCore.MINDMAP_FONT_SIZE*I,N=Math.max(100,x.width+24),T=x.height+8,R={position:"absolute",left:x.x+x.width/2,top:x.y-4,transform:"translateX(-50%)",width:N,height:T,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 ${(a.icon?24:12)*I}px`,fontFamily:"sans-serif",fontSize:S,color:"#1f2937",boxSizing:"border-box",pointerEvents:"auto",zIndex:55},c={position:"absolute",left:x.x+x.width+12,top:x.y+x.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:R,value:a.text,spellCheck:false,onChange:m=>{let w=!l.current;l.current=true,e.updateMindMapNode(f,p.nodeId,{text:m.target.value},w);},onBlur:()=>{if(s.current){s.current=false;return}let m=e.getMindMapSelectedNode();m&&(m.shapeId!==f||m.nodeId!==p.nodeId)||e.exitMindMapEdit();},onKeyDown:m=>{m.key==="Enter"?m.target.blur():m.key==="Escape"&&e.exitMindMapEdit();}}),jsxRuntime.jsx("button",{style:c,"data-drawui-tip":drawuiCore.t("mindmap.more"),onMouseDown:m=>{m.preventDefault(),s.current=true,setTimeout(()=>{s.current=false;},300);},onClick:i,children:"\u22EF"})]})});var vo=react.memo(function({editor:e,panelOpen:o}){let[,i]=react.useState(0);Y(),react.useEffect(()=>{if(!e)return;let T=e.subscribe(()=>i(R=>R+1));return ()=>{T();}},[e]);let d=react.useRef(false),l=e?.getTableEditing()??null,s=l?`${l.shapeId}\0${l.row}\0${l.col}`:"";if(react.useEffect(()=>{d.current=false;},[s]),!e||o)return null;let r=e.getTableEditing();if(!r)return null;let{shapeId:C,row:b,col:f}=r,p=e.getTableCell(C,b,f),a=e.getTableScreenRect(C,b,f);if(!p||!a)return null;let x=e.getSelectedTable(),I=p.fontSize||x?.fontSize||drawuiCore.TABLE_FONT_SIZE,S=e.getCamera().getZoom(),N={left:a.x-1,top:a.y-1,width:a.width+2,height:a.height+2,padding:`${drawuiCore.TABLE_CELL_PADDING_Y*S}px ${drawuiCore.TABLE_CELL_PADDING_X*S}px`,fontFamily:"sans-serif",fontSize:I*S,lineHeight:drawuiCore.TABLE_LINE_HEIGHT_RATIO,fontWeight:p.bold?700:400,color:p.textColor||x?.textColor||"#1f2937",textAlign:p.align==="center"?"center":p.align==="right"?"right":"left"};return jsxRuntime.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:jsxRuntime.jsx("textarea",{autoFocus:true,rows:1,className:"drawui-table-cell-input",style:N,value:p.text,spellCheck:false,onChange:T=>{let R=!d.current;d.current=true,e.updateTableCell(C,b,f,{text:T.target.value},R);},onBlur:()=>{e.exitTableEdit();},onKeyDown:T=>{(T.key==="Enter"||T.key==="Escape")&&(T.preventDefault(),T.target.blur());}})})});var Co=react.memo(function({editor:e,hidden:o=false}){let[,i]=react.useState(0),[d,l]=react.useState(null),s=react.useRef(null);if(Y(),react.useEffect(()=>{if(!e)return;let K=e.subscribe(()=>i(G=>G+1));return ()=>{K();}},[e]),react.useEffect(()=>{if(!d)return;let K=me=>{let M=me.target;M&&s.current?.contains(M)||l(null);},G=me=>{me.key==="Escape"&&l(null);};return window.addEventListener("pointerdown",K,true),window.addEventListener("keydown",G),()=>{window.removeEventListener("pointerdown",K,true),window.removeEventListener("keydown",G);}},[d]),!e||o)return null;let r=e.getSelectedTable();if(!r)return null;let C=e.getTableSelection();if(!C||C.shapeId!==r.id)return null;let b=e.getTableScreenRect(r.id);if(!b)return null;let f=r.cells.length,p=r.cells[0]?.length??0,a=drawuiCore.tableExpandRangeToMerges(r,C.anchor.row,C.anchor.col,C.focus.row,C.focus.col),{r1:x,c1:I,r2:S,c2:N}=a,T=drawuiCore.tableCoveredMap(r.cells),R=0;for(let K=x;K<=S;K++)for(let G=I;G<=N;G++)T[K]?.[G]||R++;let c=R>1,m=drawuiCore.tableRangeHasMerge(r,x,I,S,N),w=x===S?`${x+1}`:`${x+1}\u2013${S+1}`,g=I===N?`${I+1}`:`${I+1}\u2013${N+1}`,k=f-(S-x+1)>=1,U=p-(N-I+1)>=1,H=b.y>56?b.y-40:b.y+b.height+10,te=K=>K.stopPropagation(),ne=K=>()=>{K(),l(null);};return jsxRuntime.jsxs("div",{className:"drawui-table-toolbar","data-table-toolbar":r.id,style:{left:b.x+b.width/2,top:H},onPointerDown:te,children:[jsxRuntime.jsxs("div",{className:"drawui-table-split",children:[jsxRuntime.jsx("button",{className:"drawui-table-btn-main",title:drawuiCore.t("table.insertRowBelow"),onClick:()=>e.insertTableRowRelative(r.id,"below"),children:drawuiCore.t("table.insertRow")}),jsxRuntime.jsx("button",{className:`drawui-table-btn-caret ${d==="row"?"active":""}`,"data-table-insert-row":true,title:`${drawuiCore.t("table.insertRowAbove")} / ${drawuiCore.t("table.insertRowBelow")}`,onClick:()=>l(d==="row"?null:"row"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 10 10",width:"8",height:"8","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M1 3l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),d==="row"&&jsxRuntime.jsxs("div",{className:"drawui-table-menu",ref:s,"data-table-row-menu":true,children:[jsxRuntime.jsx("button",{onClick:ne(()=>e.insertTableRowRelative(r.id,"above")),children:drawuiCore.t("table.insertRowAbove")}),jsxRuntime.jsx("button",{onClick:ne(()=>e.insertTableRowRelative(r.id,"below")),children:drawuiCore.t("table.insertRowBelow")})]})]}),jsxRuntime.jsx("button",{title:`${drawuiCore.t("table.deleteRow")} \xB7 ${w}`,disabled:!k,onClick:()=>e.deleteTableRowsInSelection(r.id),children:drawuiCore.t("table.deleteRow")}),jsxRuntime.jsxs("div",{className:"drawui-table-split",children:[jsxRuntime.jsx("button",{className:"drawui-table-btn-main",title:drawuiCore.t("table.insertColRight"),onClick:()=>e.insertTableColumnRelative(r.id,"right"),children:drawuiCore.t("table.insertCol")}),jsxRuntime.jsx("button",{className:`drawui-table-btn-caret ${d==="col"?"active":""}`,"data-table-insert-col":true,title:`${drawuiCore.t("table.insertColLeft")} / ${drawuiCore.t("table.insertColRight")}`,onClick:()=>l(d==="col"?null:"col"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 10 10",width:"8",height:"8","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M1 3l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),d==="col"&&jsxRuntime.jsxs("div",{className:"drawui-table-menu",ref:s,"data-table-col-menu":true,children:[jsxRuntime.jsx("button",{onClick:ne(()=>e.insertTableColumnRelative(r.id,"left")),children:drawuiCore.t("table.insertColLeft")}),jsxRuntime.jsx("button",{onClick:ne(()=>e.insertTableColumnRelative(r.id,"right")),children:drawuiCore.t("table.insertColRight")})]})]}),jsxRuntime.jsx("button",{title:`${drawuiCore.t("table.deleteCol")} \xB7 ${g}`,disabled:!U,onClick:()=>e.deleteTableColsInSelection(r.id),children:drawuiCore.t("table.deleteCol")}),jsxRuntime.jsx("button",{title:drawuiCore.t("table.merge"),disabled:!c,onClick:()=>e.mergeTableCells(r.id),children:drawuiCore.t("table.merge")}),jsxRuntime.jsx("button",{title:drawuiCore.t("table.split"),disabled:!m,onClick:()=>e.splitTableCells(r.id),children:drawuiCore.t("table.split")})]})});var Mo=[...drawuiCore.MINDMAP_COLORS,"#1f2937","#9ca3af"],So=["\u{1F4A1}","\u2B50","\u{1F525}","\u{1F4CC}","\u2705","\u2757","\u26A0\uFE0F","\u{1F3F7}\uFE0F"],oa={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"},Vt={fontSize:11,color:"#6b7280",marginBottom:4,display:"block"},Rt={display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},Yt={border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:5,padding:"3px 6px",fontSize:12,color:"#374151",cursor:"pointer",lineHeight:1.5,whiteSpace:"nowrap"},xn={width:"100%",border:"1px solid #e5e7eb",borderRadius:5,padding:"4px 8px",fontSize:12,outline:"none",boxSizing:"border-box",background:"#ffffff",color:"#1f2937"},To=react.memo(function({editor:e,mindMap:o}){let[,i]=react.useState(0);Y(),react.useEffect(()=>{if(!e)return;let c=e.subscribe(()=>i(m=>m+1));return ()=>{c();}},[e]);let d=react.useRef(null);if(!e||!o||e.getMindMapEditingShapeId()!==o.id)return null;let l=e.getMindMapSelectedNode();if(!l||l.shapeId!==o.id)return null;let s=c=>{if(c.id===l.nodeId)return c;for(let m of c.children??[]){let w=s(m);if(w)return w}return null},r=s(o.root);if(!r)return null;let C=e.getCamera(),f=drawuiCore.layoutMindMap(o.root).positions.get(r.id);if(!f)return null;let p=C.zoom,a=C.pageToScreen({x:o.x+f.x,y:o.y+f.y}),x=a.x+f.width*p/2+14,I=a.y-80,N=Math.max(8,Math.min(x,(window.innerWidth||1024)-232-8)),T=Math.max(8,Math.min(I,(window.innerHeight||768)-320)),R=c=>{e.updateMindMapNode(o.id,r.id,c);};return jsxRuntime.jsxs("div",{ref:d,style:{...oa,left:N,top:T},onMouseDown:c=>c.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.jsxs("span",{style:{display:"flex",alignItems:"center",gap:2},children:[!!r.children?.length&&jsxRuntime.jsx("button",{style:{...Yt,padding:"1px 5px",color:"#6b7280"},"data-drawui-tip":r.collapsed?drawuiCore.t("mindmap.expand"):drawuiCore.t("mindmap.collapse"),onClick:()=>e.toggleMindMapCollapse(o.id,r.id),children:r.collapsed?drawuiCore.t("mindmap.expand"):drawuiCore.t("mindmap.collapse")}),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:{...xn,marginBottom:8},value:r.text,onChange:c=>R({text:c.target.value}),spellCheck:false}),jsxRuntime.jsx("span",{style:Vt,children:drawuiCore.t("mindmap.level")}),jsxRuntime.jsxs("div",{style:{...Rt,marginBottom:10,justifyContent:"flex-start"},children:[jsxRuntime.jsx("button",{style:{...Yt,color:"#3b82f6",borderColor:"#bfdbfe"},disabled:!e.canPromoteMindMapNode(o.id,r.id,1),onClick:()=>e.promoteMindMapNode(o.id,r.id,1),"data-drawui-tip":e.canPromoteMindMapNode(o.id,r.id,1)?drawuiCore.t("mindmap.promote1"):drawuiCore.t("mindmap.promoteDisabled"),children:drawuiCore.t("mindmap.promote1")}),jsxRuntime.jsx("button",{style:{...Yt,color:"#3b82f6",borderColor:"#bfdbfe"},disabled:!e.canPromoteMindMapNode(o.id,r.id,2),onClick:()=>e.promoteMindMapNode(o.id,r.id,2),"data-drawui-tip":e.canPromoteMindMapNode(o.id,r.id,2)?drawuiCore.t("mindmap.promote2"):drawuiCore.t("mindmap.promoteDisabled"),children:drawuiCore.t("mindmap.promote2")})]}),jsxRuntime.jsx("div",{style:{...Rt,gap:4,marginBottom:10,flexWrap:"nowrap",justifyContent:"flex-end"},children:jsxRuntime.jsx("button",{style:{...Yt,color:"#ef4444",borderColor:"#fecaca"},onClick:()=>e.deleteMindMapNode(o.id,r.id),children:drawuiCore.t("mindmap.deleteNode")})}),jsxRuntime.jsx("span",{style:Vt,children:drawuiCore.t("mindmap.color")}),jsxRuntime.jsxs("div",{style:{...Rt,marginBottom:10},children:[jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.levelColor"),onClick:()=>R({color:void 0}),style:{width:18,height:18,borderRadius:4,border:"1.5px solid #d1d5db",background:"conic-gradient(#ef4444, #f59e0b, #10b981, #3b82f6, #8b5cf6, #ec4899, #ef4444)",cursor:"pointer",flexShrink:0}}),Mo.map(c=>jsxRuntime.jsx("button",{"data-drawui-tip":c,onClick:()=>R({color:c}),style:{width:18,height:18,borderRadius:4,border:r.color===c?"2px solid #111827":"1px solid #d1d5db",background:c,cursor:"pointer",flexShrink:0}},c))]}),jsxRuntime.jsx("span",{style:Vt,children:drawuiCore.t("mindmap.icon")}),jsxRuntime.jsxs("div",{style:{...Rt,marginBottom:10},children:[jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.noIcon"),onClick:()=>R({icon:void 0}),style:{width:22,height:22,borderRadius:4,border:r.icon?"1px solid #d1d5db":"2px solid #111827",background:"#f9fafb",cursor:"pointer",fontSize:11,color:"#9ca3af",lineHeight:1},children:"\u2205"}),So.map(c=>jsxRuntime.jsx("button",{onClick:()=>R({icon:c}),style:{width:22,height:22,borderRadius:4,border:r.icon===c?"2px solid #111827":"1px solid #d1d5db",background:"#f9fafb",cursor:"pointer",fontSize:13,lineHeight:1},children:c},c)),jsxRuntime.jsx("input",{placeholder:"\u270F\uFE0F",defaultValue:r.icon&&!So.includes(r.icon)?r.icon:"",onKeyDown:c=>{if(c.key==="Enter"){let m=c.target.value.trim();R({icon:m||void 0});}},onBlur:c=>{let m=c.target.value.trim();m!==r.icon&&R({icon:m||void 0});},style:{...xn,width:56,padding:"2px 4px",textAlign:"center"}})]}),jsxRuntime.jsx("span",{style:Vt,children:drawuiCore.t("mindmap.note")}),jsxRuntime.jsx("input",{style:{...xn,marginBottom:6},value:r.note??"",placeholder:drawuiCore.t("mindmap.notePlaceholder"),onChange:c=>R({note:c.target.value||void 0}),spellCheck:false}),!!r.note&&jsxRuntime.jsxs("div",{style:{...Rt,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:()=>R({noteColor:void 0}),style:{width:16,height:16,borderRadius:3,border:r.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"}}),Mo.map(c=>jsxRuntime.jsx("button",{onClick:()=>R({noteColor:c}),style:{width:16,height:16,borderRadius:3,border:r.noteColor===c?"2px solid #111827":"1px solid #d1d5db",background:c,cursor:"pointer"}},c))]})]})});var Cn=220,Mn=140,la="#fafafa";function ca(t,e){let o=Math.min(t.x,e.x),i=Math.min(t.y,e.y),d=Math.max(t.x+t.width,e.x+e.width),l=Math.max(t.y+t.height,e.y+e.height);return {x:o,y:i,width:d-o,height:l-i}}function da(t){return {x:t.x+t.width/2,y:t.y+t.height/2}}function ua(){return {x:0,y:0,width:0,height:0}}function pa(t){let e=1/0,o=1/0,i=-1/0,d=-1/0,l=false;for(let s of t){let r=Tn(s);r&&(l=true,r.x<e&&(e=r.x),r.y<o&&(o=r.y),r.x+r.width>i&&(i=r.x+r.width),r.y+r.height>d&&(d=r.y+r.height));}return l?{x:e,y:o,width:i-e,height:d-o}:null}function Tn(t){switch(t.type){case "rectangle":case "sticky-note":case "icon":case "image":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 "table":case "text":return {x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height};case "circle":return {x:t.x-t.radius,y:t.y-t.radius,width:t.radius*2,height:t.radius*2};case "line":case "arrow":{let e=t.points;if(!e||e.length===0)return null;let o=1/0,i=1/0,d=-1/0,l=-1/0;for(let s of e)s.x<o&&(o=s.x),s.y<i&&(i=s.y),s.x>d&&(d=s.x),s.y>l&&(l=s.y);return {x:o,y:i,width:d-o,height:l-i}}case "draw":{let e=t,o=e.width,i=e.height;if(typeof o=="number"&&typeof i=="number")return {x:e.x-o/2,y:e.y-i/2,width:o,height:i};let d=e.points;if(!d||d.length===0)return null;let l=1/0,s=1/0,r=-1/0,C=-1/0;for(let b of d){let f=b.x+e.x,p=b.y+e.y;f<l&&(l=f),p<s&&(s=p),f>r&&(r=f),p>C&&(C=p);}return {x:l,y:s,width:r-l,height:C-s}}default:return null}}function ha(t){let e=t.getCamera(),o=e.screenToPage({x:0,y:0}),i=e.screenToPage({x:window.innerWidth,y:window.innerHeight});return {x:o.x,y:o.y,width:i.x-o.x,height:i.y-o.y}}function ya(t,e,o){if(t.width<=0||t.height<=0)return {x:t.x-e/2,y:t.y-o/2,width:e,height:o};let i=e/o,d=t.width,l=d/i;l<t.height&&(l=t.height,d=l*i);let s=da(t);return {x:s.x-d/2,y:s.y-l/2,width:d,height:l}}function Sn(t,e,o,i){let d=(t-o.left)/o.width,l=(e-o.top)/o.height;return {x:i.x+d*i.width,y:i.y+l*i.height}}var Eo=react.memo(function({editor:e}){let o=react.useRef(null),i=react.useRef(null),[d,l]=react.useState(false),[s,r]=react.useState(100),[C,b]=react.useState(false),[f,p]=react.useState(false);Y();let a=react.useRef(null),x=react.useRef(null);react.useLayoutEffect(()=>{let m=o.current,w=i.current;if(!m||!w)return;let g=window.devicePixelRatio||1;m.width=Math.round(Cn*g),m.height=Math.round(Mn*g),m.style.width=`${Cn}px`,m.style.height=`${Mn}px`;},[d]);let I=react.useCallback(()=>{let m=o.current,w=i.current;if(!m||!w||!e)return;let g=m.getContext("2d");if(!g)return;let k=Cn,U=Mn,D=m.width,H=m.height,te=e.getShapes(),ne=new Set(e.getSelectedIds()),K=drawuiCore.getTheme(),G=drawuiCore.hexToRgba(K.text,.16),me=K.primary,M=drawuiCore.hexToRgba(K.primary,.18),oe=drawuiCore.hexToRgba(K.primary,.85),xe=pa(te),z=ha(e),Z=xe?ca(xe,z):z.width>0?z:ua(),fe=ya(Z,k,U);x.current=fe;let Ie=D/fe.width,He=H/fe.height,ke=k/fe.width;g.setTransform(1,0,0,1,0,0),g.fillStyle=la,g.fillRect(0,0,D,H),g.setTransform(Ie,0,0,He,-Ie*fe.x,-He*fe.y),g.fillStyle=G;for(let q of te){let O=Tn(q);O&&g.fillRect(O.x,O.y,O.width,O.height);}g.fillStyle=me;for(let q of te){if(!ne.has(q.id))continue;let O=Tn(q);O&&g.fillRect(O.x,O.y,O.width,O.height);}g.fillStyle=M,g.fillRect(z.x,z.y,z.width,z.height);let Ge=1.5/ke;g.strokeStyle=oe,g.lineWidth=Ge,g.lineJoin="round";let Be=Math.min(z.width/6,z.height/6,6/ke);if(g.beginPath(),Be*ke<1)g.rect(z.x,z.y,z.width,z.height);else {let q=z.x,O=z.y,Ce=z.width,Me=z.height,de=Math.min(Be,Ce/2,Me/2);g.moveTo(q+de,O),g.lineTo(q+Ce-de,O),g.quadraticCurveTo(q+Ce,O,q+Ce,O+de),g.lineTo(q+Ce,O+Me-de),g.quadraticCurveTo(q+Ce,O+Me,q+Ce-de,O+Me),g.lineTo(q+de,O+Me),g.quadraticCurveTo(q,O+Me,q,O+Me-de),g.lineTo(q,O+de),g.quadraticCurveTo(q,O,q+de,O),g.closePath();}g.stroke(),g.setTransform(1,0,0,1,0,0);},[e]);react.useEffect(()=>{if(!e||d)return;I();let m=e.subscribe(I),w=drawuiCore.subscribeTheme(I),g=()=>I();return window.addEventListener("resize",g),()=>{m(),w(),window.removeEventListener("resize",g);}},[e,d,I]),react.useEffect(()=>{if(!e)return;let m=()=>{let g=e.getCamera().getZoom();r(Math.round(g*100));};m();let w=e.subscribe(m);return ()=>{w();}},[e]);let S=react.useCallback((m,w)=>{if(!e)return;let g=e.getCamera(),k=g.getZoom(),U=window.innerWidth/2,D=window.innerHeight/2,H=g;H.x=U-m*k,H.y=D-w*k,e.requestRender();},[e]),N=m=>{if(!e||!i.current||m.button!==0)return;let w=i.current.getBoundingClientRect(),g=x.current;if(!g)return;let k=Sn(m.clientX,m.clientY,w,g);a.current={pointerId:m.pointerId,rect:{left:w.left,top:w.top,width:w.width,height:w.height},canvasBox:g},m.currentTarget.setPointerCapture(m.pointerId),p(true),S(k.x,k.y);},T=m=>{if(!f||!e||!a.current||!i.current)return;let w=a.current,g=Sn(m.clientX,m.clientY,w.rect,w.canvasBox);S(g.x,g.y);},R=m=>{if(f){p(false),a.current=null;try{m.currentTarget.releasePointerCapture(m.pointerId);}catch{}}},c=m=>{if(!e||!i.current)return;let w=x.current;if(!w)return;let g=i.current.getBoundingClientRect(),k=Sn(m.clientX,m.clientY,g,w);S(k.x,k.y);};return jsxRuntime.jsxs("div",{className:`drawui-minimap ${d?"collapsed":""}`,children:[jsxRuntime.jsx("button",{className:"drawui-minimap-toggle",onClick:()=>l(m=>!m),"data-drawui-tip":d?drawuiCore.t("minimap.expand"):drawuiCore.t("minimap.collapse"),"data-drawui-tip-pos":"top","aria-label":d?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:d?jsxRuntime.jsx("polyline",{points:"9 6 15 12 9 18"}):jsxRuntime.jsx("polyline",{points:"15 6 9 12 15 18"})})}),!d&&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:i,className:"drawui-minimap-canvas-wrap",style:{cursor:f?"grabbing":C?"pointer":"default"},onPointerEnter:()=>b(true),onPointerLeave:()=>b(false),children:jsxRuntime.jsx("canvas",{ref:o,className:"drawui-minimap-canvas",onPointerDown:N,onPointerMove:T,onPointerUp:R,onPointerCancel:R,onDoubleClick:c})})]})]})});var Ee=t=>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:t}),ga=[{type:"rectangle",labelKey:"shape.rectangle",glyph:Ee(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:Ee(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:Ee(jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:Ee(jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:Ee(jsxRuntime.jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:Ee(jsxRuntime.jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:Ee(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:Ee(jsxRuntime.jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:Ee(jsxRuntime.jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:Ee(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:Ee(jsxRuntime.jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:Ee(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:Ee(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:Ee(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:Ee(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:Ee(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"2.2",y:"9",width:"6.6",height:"6",rx:"2"}),jsxRuntime.jsx("rect",{x:"15.4",y:"3.8",width:"6.4",height:"5.2",rx:"1.8"}),jsxRuntime.jsx("rect",{x:"15.4",y:"15",width:"6.4",height:"5.2",rx:"1.8"}),jsxRuntime.jsx("path",{d:"M8.8 12 C 12.2 12 12.2 6.4 15.4 6.4"}),jsxRuntime.jsx("path",{d:"M8.8 12 C 12.2 12 12.2 17.6 15.4 17.6"})]}))}];function Io({editor:t,x:e,y:o,context:i,existingArrowId:d,defaultShapeType:l,onClose:s}){let r=react.useRef(null);Y();let C=b=>{t?.createGeneratedConnection(i,{type:b,existingArrowId:d}),s();};return react.useEffect(()=>{let b=a=>{r.current&&!r.current.contains(a.target)&&s();},f=a=>{a.key==="Escape"&&(a.preventDefault(),s());},p=setTimeout(()=>{window.addEventListener("pointerdown",b,true),window.addEventListener("keydown",f,true);},0);return ()=>{clearTimeout(p),window.removeEventListener("pointerdown",b,true),window.removeEventListener("keydown",f,true);}},[s]),jsxRuntime.jsxs("div",{className:"drawui-gen-menu",ref:r,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:ga.map(b=>jsxRuntime.jsxs("button",{className:`drawui-gen-shape-btn${b.type===l?" drawui-gen-shape-active":""}`,onClick:()=>C(b.type),"data-drawui-tip":drawuiCore.t(b.labelKey),children:[b.glyph,jsxRuntime.jsx("span",{className:"drawui-gen-shape-label",children:drawuiCore.t(b.labelKey)})]},b.type))}),jsxRuntime.jsx("div",{className:"drawui-gen-menu-hint",children:drawuiCore.t("menu.cancel")})]})}var va=typeof navigator<"u"&&/mac|iphone|ipad/i.test(navigator.platform||navigator.userAgent);function Xe(t){if(va)switch(t){case "copy":return "\u2318C";case "paste":return "\u2318V";case "duplicate":return "\u2318D";case "copyStyle":return "\u2325\u2318C";case "pasteStyle":return "\u2325\u2318V";case "lock":return "\u2325\u2318L";case "delete":return "\u232B";case "group":return "\u2318G";case "ungroup":return "\u21E7\u2318G"}switch(t){case "copy":return "Ctrl + C";case "paste":return "Ctrl + V";case "duplicate":return "Ctrl + D";case "copyStyle":return "Ctrl + Alt + C";case "pasteStyle":return "Ctrl + Alt + V";case "lock":return "Ctrl + Alt + L";case "delete":return "Del";case "group":return "Ctrl + G";case "ungroup":return "Ctrl + Shift + G"}}var Po={sep:true},xa=t=>"sep"in t&&t.sep===true;function Ho({editor:t,pos:e,onClose:o}){Y();let[,i]=react.useState(0),d=react.useRef(null),[l,s]=react.useState(null),[r,C]=react.useState(null);react.useEffect(()=>{let k=t.subscribe(()=>i(U=>U+1));return ()=>{k();}},[t]),react.useLayoutEffect(()=>{let k=d.current;if(!k)return;let U=k.getBoundingClientRect(),D=Math.max(8,Math.min(e.x,window.innerWidth-U.width-8)),H=Math.max(8,Math.min(e.y,window.innerHeight-U.height-8));s({left:D,top:H});},[e.x,e.y]),react.useEffect(()=>{let k=H=>{d.current&&!d.current.contains(H.target)&&o();},U=H=>{H.key==="Escape"&&(H.preventDefault(),o());},D=setTimeout(()=>{window.addEventListener("pointerdown",k,true),window.addEventListener("keydown",U,true);},0);return ()=>{clearTimeout(D),window.removeEventListener("pointerdown",k,true),window.removeEventListener("keydown",U,true);}},[o]);let b=t.getSelectedIds(),f=b.length>0,p=e.shapeId,a=p?t.isShapeLocked(p):false,x=f&&!a&&t.hasCopiedStyle(),I=t.hasClipboard(),S=f&&!a,N=f&&!a?t.getSelectedGroupId():null,T=f&&!a&&b.length>=2&&!N,c=(p?t.getShapes().find(k=>k.id===p):void 0)?.groupId??null,m=N?true:!!c&&!a,w=k=>()=>{k(),o();},g;return a?g=c?[{key:"ctx.ungroup",shortcut:Xe("ungroup"),action:w(()=>c&&t.ungroupIds([c]))}]:[{key:"ctx.unlock",action:()=>p&&t.setShapeLocked(p,false)}]:f?g=[{key:"ctx.copy",shortcut:Xe("copy"),action:w(()=>t.copySelected())},{key:"ctx.paste",shortcut:Xe("paste"),disabled:!I,action:w(()=>t.paste())},{key:"ctx.duplicate",shortcut:Xe("duplicate"),action:w(()=>t.duplicateSelected())},{key:"ctx.layer",submenu:[{key:"ctx.bringToFront",disabled:!S,action:()=>t.bringToFront()},{key:"ctx.bringForward",disabled:!S,action:()=>t.bringForward()},{key:"ctx.sendBackward",disabled:!S,action:()=>t.sendBackward()},{key:"ctx.sendToBack",disabled:!S,action:()=>t.sendToBack()}]},{key:"ctx.copyStyle",shortcut:Xe("copyStyle"),action:w(()=>t.copyStyle())},{key:"ctx.pasteStyle",shortcut:Xe("pasteStyle"),disabled:!x,action:w(()=>t.pasteStyle())},Po,{key:"ctx.rotate",submenu:[{key:"ctx.rotate90",action:()=>t.rotateSelected(90)},{key:"ctx.rotate180",action:()=>t.rotateSelected(180)},{key:"ctx.rotate270",action:()=>t.rotateSelected(270)}]},N?{key:"ctx.ungroup",shortcut:Xe("ungroup"),disabled:!m,action:w(()=>t.ungroupSelected())}:{key:"ctx.group",shortcut:Xe("group"),disabled:!T,action:w(()=>t.groupSelected())},Po,{key:"ctx.lock",shortcut:Xe("lock"),action:w(()=>t.setSelectedShapesLocked(true))},{key:"ctx.delete",shortcut:Xe("delete"),action:w(()=>t.deleteSelected())}]:(g=[{key:"ctx.paste",shortcut:Xe("paste"),disabled:!I,action:w(()=>t.paste())}],t.hasLockedShapes()&&g.push({key:"ctx.unlockAll",action:w(()=>t.unlockAll())})),jsxRuntime.jsx("div",{ref:d,className:"drawui-context-menu",style:l?{left:l.left,top:l.top}:{visibility:"hidden",left:e.x,top:e.y},onContextMenu:k=>k.preventDefault(),children:g.map((k,U)=>xa(k)?jsxRuntime.jsx("div",{className:"drawui-context-sep"},`sep-${U}`):k.submenu?jsxRuntime.jsxs("div",{className:"drawui-context-sub",onMouseEnter:()=>C(k.key),onMouseLeave:()=>C(null),children:[jsxRuntime.jsxs("button",{type:"button",className:"drawui-context-item",disabled:k.disabled,children:[jsxRuntime.jsx("span",{children:drawuiCore.t(k.key)}),jsxRuntime.jsx("svg",{className:"drawui-context-caret",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("polyline",{points:"9 18 15 12 9 6"})})]}),r===k.key&&jsxRuntime.jsx("div",{className:"drawui-context-submenu",children:k.submenu.map(D=>jsxRuntime.jsx("button",{type:"button",className:"drawui-context-item",disabled:D.disabled,onClick:()=>{D.action(),o();},children:jsxRuntime.jsx("span",{children:drawuiCore.t(D.key)})},D.key))})]},k.key):jsxRuntime.jsxs("button",{type:"button",className:"drawui-context-item",disabled:k.disabled,onClick:k.action,children:[jsxRuntime.jsx("span",{children:drawuiCore.t(k.key)}),k.shortcut&&jsxRuntime.jsx("span",{className:"drawui-context-kbd",children:k.shortcut})]},k.key))})}var Na={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",table:"tool.table",image:"tool.image"};function In(t){let e=t instanceof Error?t.message:String(t);return e.startsWith("image.tooLarge")?drawuiCore.t("image.tooLarge"):`${drawuiCore.t("image.uploadFailed")}\uFF1A${e}`}function Ea({initialTool:t="select",className:e="",themeColor:o,theme:i,onThemeChange:d,language:l="zh-CN",data:s,onChange:r,onReady:C,imageUpload:b}){let f=react.useRef(null),p=react.useRef(null),a=react.useRef(null),[x,I]=react.useState(null);Y();let[S,N]=react.useState(t),[T,R]=react.useState(false),[c,m]=react.useState(0),[w,g]=react.useState(false),[k,U]=react.useState("straight"),[D,H]=react.useState("end"),[te,ne]=react.useState(false),[K,G]=react.useState(void 0),[me,M]=react.useState(100),[oe,xe]=react.useState(null),[z,Z]=react.useState(null),[fe,Ie]=react.useState(false),[He,ke]=react.useState(false),[Ge,Be]=react.useState(false),[q,O]=react.useState(null),[Ce,Me]=react.useState(null),[de,st]=react.useState(false),[X,ze]=react.useState(null),[Se,_e]=react.useState(null),A=react.useRef(null),Ae=react.useRef(0),ge=react.useRef(null),v=react.useRef(r);v.current=r;let $=react.useRef(C);$.current=C,react.useEffect(()=>{if(!f.current)return;let y=new drawuiCore.Editor(f.current,{theme:o?{primary:o,editBorder:o,selection:{outline:o,handleStroke:o,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(o,.1),shadow:o}}:void 0,language:l,shapes:s,persist:!s,imageUpload:b});a.current=y,I(y),window.__drawuiEditor=y,y.setHighlighterColor(At()),y.setStickyNoteColor(Kt()),$.current?.(y),t&&y.setActiveTool(t);let P=y.subscribe(()=>{N(y.getActiveTool());let W=y.getSelectedIds();m(W.length);let Re=y.getShapes().filter(tt=>W.includes(tt.id)&&(tt.type==="line"||tt.type==="arrow"));if(g(Re.length>0),Re.length>0&&Re[0].connectionType?U(Re[0].connectionType):Re.length>0&&U("straight"),Re.length>0){let tt=Re.find(on=>on.type==="arrow");tt&&(H(tt.arrowHead??"end"),ne(tt.dashed??false));}M(Math.round(y.getCamera().getZoom()*100)),G(y.getArrowStyle()),ke(y.canUndo()),Be(y.canRedo());let et=y.getSelectedUml();O(et),et||ze(null);let ct=y.getSelectedMindMap();Me(ct),y.getMindMapEditingShapeId()||st(false),v.current?.(y.getData());}),pe=y.subscribeNotifications(W=>{Z({type:"success",text:W}),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>Z(null),3500);}),Ke=y.subscribeUi(W=>{if(W.kind==="imageError"){Z({type:"error",text:In(W.message)}),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>Z(null),4e3);return}if(W.kind==="drag"){Ie(W.active);return}W.kind==="shapeTypeMenu"&&_e({x:W.screenX,y:W.screenY,context:W.context,existingArrowId:W.existingArrowId,defaultShapeType:W.defaultShapeType});});return ()=>{P(),pe(),Ke(),A.current&&clearTimeout(A.current),cancelAnimationFrame(Ae.current),y.dispose();}},[t]),react.useEffect(()=>{if(!o)return;let y=p.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)}`)),a.current?.setTheme({primary:o,editBorder:o,selection:{outline:o,handleStroke:o,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(o,.1),shadow:o}});},[o]);let[F,V]=react.useState(i??drawuiCore.DEFAULT_PAGE_THEME),J=i??F,re=react.useCallback(y=>{V(y),d?.(y);},[d]);react.useEffect(()=>{document.documentElement.setAttribute("data-theme",J),drawuiCore.setTheme({grid:drawuiCore.PAGE_THEMES[J].grid}),a.current?.requestRender();},[J]),react.useEffect(()=>{drawuiCore.setLanguage(l),a.current?.setLanguage(l);},[l]);let qe=react.useCallback(y=>{a.current?.setActiveTool(y);},[]),Qe=react.useCallback(()=>{a.current?.zoomIn();},[]),Ze=react.useCallback(()=>{a.current?.zoomOut();},[]),We=react.useCallback(()=>{a.current?.resetZoom();},[]),lt=react.useCallback(()=>{let y=!T;R(y),a.current?.setShowGrid(y);},[T]),Fe=react.useCallback(()=>{a.current?.undo();},[]),ae=react.useCallback(()=>{a.current?.redo();},[]),ee=react.useCallback(y=>{a.current?.downloadImage("drawui",y,{background:"#ffffff"});},[]),h=react.useCallback(()=>{a.current?.downloadJSON("drawui-data");},[]),E=react.useCallback(y=>{let P=new FileReader;P.onload=()=>{let pe=typeof P.result=="string"?P.result:"";if(a.current?.importJSON(pe)??false){let W=a.current?.getShapes().length??0;Z({type:"success",text:drawuiCore.t("import.success",{n:W})});}else Z({type:"error",text:drawuiCore.t("import.fail")});A.current&&clearTimeout(A.current),A.current=setTimeout(()=>Z(null),3500);},P.onerror=()=>{Z({type:"error",text:drawuiCore.t("import.fail")}),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>Z(null),3500);},P.readAsText(y,"utf-8");},[]),Je=react.useCallback(y=>{let P=a.current,pe=f.current;if(!P||!pe)return;if(P.isPointerDown()){ge.current!==null&&(ge.current=null,xe(null));return}let Ke=y.clientX,W=y.clientY;cancelAnimationFrame(Ae.current),Ae.current=requestAnimationFrame(()=>{let Ye=pe.getBoundingClientRect(),Re=Ke-Ye.left,et=W-Ye.top,ct=Re+12,tt=et+12,on=P.getSelectedUml()?.id,bt=P.getUmlRowAtScreenPoint({x:Re,y:et});if(bt&&bt.shape.id!==on&&bt.text&&P.isUmlRowTextTruncated(bt)){ge.current!==bt.text&&(ge.current=bt.text,xe({text:bt.text,x:ct,y:tt}));return}let Ct=P.getShapeAtScreenPoint({x:Re,y:et});Ct&&Ct.text&&P.isShapeTextTruncated(Ct.id)?ge.current!==Ct.text&&(ge.current=Ct.text,xe({text:Ct.text,x:ct,y:tt})):ge.current!==null&&(ge.current=null,xe(null));});},[]),Ue=react.useCallback(()=>{xe(null);},[]),Ve=react.useCallback(y=>{let P=a.current,pe=f.current;if(!P||!pe)return;let Ke=pe.getBoundingClientRect(),W=y.clientX-Ke.left,Ye=y.clientY-Ke.top,Re=P.getUmlRowAtScreenPoint({x:W,y:Ye});if(Re){ze(Re.shape.id);return}let et=P.getMindMapNodeAtScreenPoint({x:W,y:Ye});if(et){P.beginMindMapEdit(et.shapeId,et.nodeId);return}let ct=P.getTableAtScreenPoint({x:W,y:Ye});ct&&P.beginTableEdit(ct.shapeId,ct.row,ct.col);},[]),nn=react.useCallback(()=>{_e(null);},[]),[u,_]=react.useState(null),ve=react.useCallback(()=>_(null),[]),Te=react.useCallback(y=>{y.preventDefault();let P=a.current,pe=f.current;if(!P||!pe||P.isEditing())return;let Ke=pe.getBoundingClientRect(),W=P.getShapeAtScreenPoint({x:y.clientX-Ke.left,y:y.clientY-Ke.top});W?P.isShapeLocked(W.id)?P.selectShapeRaw(W.id):P.getSelectedIds().includes(W.id)||P.selectShape(W.id,y.shiftKey):P.selectShape("",false),_({x:y.clientX,y:y.clientY,shapeId:W?.id??null});},[]),gt=react.useCallback(y=>{y.preventDefault();},[]);return jsxRuntime.jsxs("div",{ref:p,className:`drawui-canvas-board ${e}`,onContextMenu:gt,onDragOver:y=>{y.dataTransfer?.types?.includes("Files")&&(y.preventDefault(),y.dataTransfer.dropEffect="copy");},onDrop:y=>{let P=Array.from(y.dataTransfer?.files||[]).filter(Ye=>(Ye.type||"").startsWith("image/"));if(!P.length)return;y.preventDefault();let pe=a.current;if(!pe)return;let Ke=y.currentTarget.getBoundingClientRect(),W=pe.getCamera().screenToPage({x:y.clientX-Ke.left,y:y.clientY-Ke.top});pe.insertImageFiles(P,W).then(()=>{!pe.hasImageUploader()&&pe.hasTemporaryImages()&&(Z({type:"success",text:drawuiCore.t("image.temporaryInserted")}),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>Z(null),4e3));}).catch(Ye=>{Z({type:"error",text:In(Ye)}),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>Z(null),4e3);});},children:[jsxRuntime.jsx("canvas",{ref:f,className:"drawui-canvas",onMouseMove:Je,onMouseLeave:Ue,onDoubleClick:Ve,onContextMenu:Te}),oe&&jsxRuntime.jsx("div",{className:"drawui-tooltip",style:{left:oe.x,top:oe.y},children:oe.text}),jsxRuntime.jsx(mn,{activeTool:S,onToolChange:qe,showGrid:T,onToggleGrid:lt,pageTheme:J,onPageThemeChange:re,canUndo:He,canRedo:Ge,onUndo:Fe,onRedo:ae,onExport:ee,onExportData:h,onImportData:E,onHighlighterColorChange:y=>a.current?.setHighlighterColor(y),onStickyNoteColorChange:y=>a.current?.setStickyNoteColor(y),onInsertIcon:y=>a.current?.insertIcon(y),onInsertTemplate:y=>a.current?.insertTemplate(y.build()),onInsertTable:(y,P)=>a.current?.insertTable(y,P),onInsertImage:y=>{let P=a.current;P&&P.insertImageFiles(y).then(()=>{!P.hasImageUploader()&&P.hasTemporaryImages()&&(Z({type:"success",text:drawuiCore.t("image.temporaryInserted")}),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>Z(null),4e3));}).catch(pe=>{Z({type:"error",text:In(pe)}),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>Z(null),4e3);});},arrowStyle:K,onArrowStyleChange:y=>a.current?.setArrowStyle(y),hidden:fe}),jsxRuntime.jsx(gn,{onZoomIn:Qe,onZoomOut:Ze,onReset:We,zoomLevel:me}),jsxRuntime.jsx(io,{editor:x,selectedCount:c,hasLineSelection:w,currentConnectionType:k,currentArrowHead:D,currentDashed:te,hidden:fe}),jsxRuntime.jsx(ho,{editor:x,umlClass:q,editing:X}),jsxRuntime.jsx(Co,{editor:x,hidden:fe}),jsxRuntime.jsx(vo,{editor:x,panelOpen:de}),jsxRuntime.jsx(go,{editor:x,panelOpen:de,onOpenPanel:()=>st(true)}),de&&jsxRuntime.jsx(To,{editor:x,mindMap:Ce}),jsxRuntime.jsx(Eo,{editor:x}),Se&&jsxRuntime.jsx(Io,{editor:x,x:Se.x,y:Se.y,context:Se.context,existingArrowId:Se.existingArrowId,defaultShapeType:Se.defaultShapeType,onClose:nn}),u&&x&&jsxRuntime.jsx(Ho,{editor:x,pos:u,onClose:ve}),jsxRuntime.jsxs("div",{className:"drawui-status-bar",children:[jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:drawuiCore.t(Na[S])})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:c===0?drawuiCore.t("status.none"):drawuiCore.t("status.selected",{n:c})})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsxs("span",{children:[me,"%"]})})]}),z&&jsxRuntime.jsxs("div",{className:"drawui-toast",children:[z.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"})]}),z.text]})]})}exports.CanvasBoard=Ea;exports.Toolbar=mn;exports.ZoomControl=gn;