@nice2dev/ui-diagrams 1.4.1 → 1.4.3

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,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),y=require("@nice2dev/ui"),p=require("react");class er{constructor(e){this.liquidFlows=new Map,this.glowStates=new Map,this.particles=[],this.emitters=[],this.rafId=0,this.running=!1,this.lastTime=0,this.tick=()=>{if(!this.running)return;const t=performance.now(),r=Math.min((t-this.lastTime)/1e3,.1);this.lastTime=t;for(const[,i]of this.liquidFlows)if(i.active){i.gradientOffset=(i.gradientOffset+r*.5)%1;for(const a of i.particles)a.t=(a.t+r*.3)%1,a.offset+=(Math.random()-.5)*r*2,a.offset=Math.max(-4,Math.min(4,a.offset)),a.opacity=.3+Math.sin(a.t*Math.PI)*.5}for(const[,i]of this.glowStates)i.pulse=(i.pulse+r*2)%(Math.PI*2);this.particles=this.particles.filter(i=>(i.life-=r/i.maxLife,i.life<=0?!1:(i.x+=i.vx*r,i.y+=i.vy*r,i.opacity=Math.min(1,i.life*2),!0)));for(const i of this.emitters)for(i.accumulator=(i.accumulator??0)+r*i.rate;i.accumulator>=1;){i.accumulator-=1;const a=Math.random()*Math.PI*2,s=i.speed*(.5+Math.random());this.particles.push({x:i.position.x+(Math.random()-.5)*i.spread,y:i.position.y+(Math.random()-.5)*i.spread,vx:Math.cos(a)*s,vy:Math.sin(a)*s,life:1,maxLife:i.particleLife,size:i.particleSize*(.5+Math.random()),color:i.color,opacity:1})}this.onFrame(this.getState()),this.rafId=requestAnimationFrame(this.tick)},this.onFrame=e}startLiquidFlow(e,t){const r=[],i=t.particleDensity??3;for(let a=0;a<i;a++)r.push({t:Math.random(),offset:(Math.random()-.5)*(t.pipeWidth??6),size:1.5+Math.random()*2,opacity:.4+Math.random()*.5});this.liquidFlows.set(e,{edgeId:e,gradientOffset:0,fillProgress:t.progress??0,particles:r,active:!0}),this.running||this.start()}stopLiquidFlow(e){this.liquidFlows.delete(e),this.liquidFlows.size===0&&this.glowStates.size===0&&this.emitters.length===0&&this.stop()}setGlow(e,t,r){this.glowStates.set(e,{elementId:e,color:t,intensity:r,pulse:0}),this.running||this.start()}removeGlow(e){this.glowStates.delete(e)}addEmitter(e){return this.emitters.push(e),this.running||this.start(),e.id}removeEmitter(e){this.emitters=this.emitters.filter(t=>t.id!==e)}start(){this.running||(this.running=!0,this.lastTime=performance.now(),this.tick())}stop(){this.running=!1,this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0}destroy(){this.stop(),this.liquidFlows.clear(),this.glowStates.clear(),this.particles=[],this.emitters=[]}isRunning(){return this.running}getState(){return{liquidFlows:new Map(this.liquidFlows),glowStates:new Map(this.glowStates),particles:[...this.particles]}}}function Ur(o,e,t){if(!t)return{x:0,y:0};const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",o),t.appendChild(r);try{const i=r.getTotalLength(),a=r.getPointAtLength(e*i);return{x:a.x,y:a.y}}finally{t.removeChild(r)}}function tr(o){return`nd-glow-${o.replace(/[^a-zA-Z0-9]/g,"_")}`}function rr(o,e){const t=o*12,r=1+Math.sin(e)*.3;return t*r}function zt(o,e){const t=(e==null?void 0:e.scale)??1,r=(e==null?void 0:e.background)??"transparent";let i=1/0,a=1/0,s=-1/0,c=-1/0;for(const h of o.nodes)i=Math.min(i,h.position.x),a=Math.min(a,h.position.y),s=Math.max(s,h.position.x+h.size.width),c=Math.max(c,h.position.y+h.size.height);o.nodes.length===0&&(i=a=0,s=c=100);const l=40,u=(s-i+l*2)*t,d=(c-a+l*2)*t,b=-i+l,x=-a+l,g=[];g.push(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${u} ${d}" width="${u}" height="${d}">`),g.push("<defs>"),g.push('<marker id="arrowhead" markerWidth="10" markerHeight="7" refX="10" refY="3.5" orient="auto">'),g.push(' <polygon points="0 0, 10 3.5, 0 7" fill="#666" />'),g.push("</marker>"),g.push("</defs>"),r!=="transparent"&&g.push(`<rect width="${u}" height="${d}" fill="${r}" />`),g.push(`<g transform="translate(${b*t}, ${x*t}) scale(${t})">`);for(const h of o.edges){const v=o.nodes.find(V=>V.id===h.sourceNodeId),_=o.nodes.find(V=>V.id===h.targetNodeId);if(!v||!_)continue;const w=v.position.x+v.size.width/2,m=v.position.y+v.size.height/2,P=_.position.x+_.size.width/2,k=_.position.y+_.size.height/2,j=h.style.strokeColor??"#666",C=h.style.strokeWidth??2,X=h.style.targetArrow!=="none"?' marker-end="url(#arrowhead)"':"";if(h.style.lineType==="bezier"){const V=(w+P)/2,F=m,H=(w+P)/2,I=k;g.push(`<path d="M${w},${m} C${V},${F} ${H},${I} ${P},${k}" fill="none" stroke="${j}" stroke-width="${C}"${X} />`)}else g.push(`<line x1="${w}" y1="${m}" x2="${P}" y2="${k}" stroke="${j}" stroke-width="${C}"${X} />`);if(h.label){const V=(w+P)/2,F=(m+k)/2;g.push(`<text x="${V}" y="${F-6}" text-anchor="middle" font-size="12" fill="#333">${Gt(h.label)}</text>`)}}for(const h of o.nodes){const{x:v,y:_}=h.position,{width:w,height:m}=h.size,P=h.style.backgroundColor??"#fff",k=h.style.borderColor??"#ccc",j=h.style.borderWidth??1,C=h.style.borderRadius??(h.shape==="roundedRect"?8:0),X=h.style.fontColor??"#333",V=h.style.fontSize??14;switch(h.shape){case"ellipse":case"circle":g.push(`<ellipse cx="${v+w/2}" cy="${_+m/2}" rx="${w/2}" ry="${m/2}" fill="${P}" stroke="${k}" stroke-width="${j}" />`);break;case"diamond":g.push(`<polygon points="${v+w/2},${_} ${v+w},${_+m/2} ${v+w/2},${_+m} ${v},${_+m/2}" fill="${P}" stroke="${k}" stroke-width="${j}" />`);break;default:g.push(`<rect x="${v}" y="${_}" width="${w}" height="${m}" rx="${C}" fill="${P}" stroke="${k}" stroke-width="${j}" />`)}g.push(`<text x="${v+w/2}" y="${_+m/2+V/3}" text-anchor="middle" font-size="${V}" fill="${X}" font-family="sans-serif">${Gt(h.label)}</text>`)}return g.push("</g>"),g.push("</svg>"),g.join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),y=require("@nice2dev/ui"),p=require("react");class er{constructor(e){this.liquidFlows=new Map,this.glowStates=new Map,this.particles=[],this.emitters=[],this.rafId=0,this.running=!1,this.lastTime=0,this.tick=()=>{if(!this.running)return;const t=performance.now(),r=Math.min((t-this.lastTime)/1e3,.1);this.lastTime=t;for(const[,i]of this.liquidFlows)if(i.active){i.gradientOffset=(i.gradientOffset+r*.5)%1;for(const a of i.particles)a.t=(a.t+r*.3)%1,a.offset+=(Math.random()-.5)*r*2,a.offset=Math.max(-4,Math.min(4,a.offset)),a.opacity=.3+Math.sin(a.t*Math.PI)*.5}for(const[,i]of this.glowStates)i.pulse=(i.pulse+r*2)%(Math.PI*2);this.particles=this.particles.filter(i=>(i.life-=r/i.maxLife,i.life<=0?!1:(i.x+=i.vx*r,i.y+=i.vy*r,i.opacity=Math.min(1,i.life*2),!0)));for(const i of this.emitters)for(i.accumulator=(i.accumulator??0)+r*i.rate;i.accumulator>=1;){i.accumulator-=1;const a=Math.random()*Math.PI*2,s=i.speed*(.5+Math.random());this.particles.push({x:i.position.x+(Math.random()-.5)*i.spread,y:i.position.y+(Math.random()-.5)*i.spread,vx:Math.cos(a)*s,vy:Math.sin(a)*s,life:1,maxLife:i.particleLife,size:i.particleSize*(.5+Math.random()),color:i.color,opacity:1})}this.onFrame(this.getState()),this.rafId=requestAnimationFrame(this.tick)},this.onFrame=e}startLiquidFlow(e,t){const r=[],i=t.particleDensity??3;for(let a=0;a<i;a++)r.push({t:Math.random(),offset:(Math.random()-.5)*(t.pipeWidth??6),size:1.5+Math.random()*2,opacity:.4+Math.random()*.5});this.liquidFlows.set(e,{edgeId:e,gradientOffset:0,fillProgress:t.progress??0,particles:r,active:!0}),this.running||this.start()}stopLiquidFlow(e){this.liquidFlows.delete(e),this.liquidFlows.size===0&&this.glowStates.size===0&&this.emitters.length===0&&this.stop()}setGlow(e,t,r){this.glowStates.set(e,{elementId:e,color:t,intensity:r,pulse:0}),this.running||this.start()}removeGlow(e){this.glowStates.delete(e)}addEmitter(e){return this.emitters.push(e),this.running||this.start(),e.id}removeEmitter(e){this.emitters=this.emitters.filter(t=>t.id!==e)}start(){this.running||(this.running=!0,this.lastTime=performance.now(),this.tick())}stop(){this.running=!1,this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0}destroy(){this.stop(),this.liquidFlows.clear(),this.glowStates.clear(),this.particles=[],this.emitters=[]}isRunning(){return this.running}getState(){return{liquidFlows:new Map(this.liquidFlows),glowStates:new Map(this.glowStates),particles:[...this.particles]}}}function Ur(o,e,t){if(!t)return{x:0,y:0};const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",o),t.appendChild(r);try{const i=r.getTotalLength(),a=r.getPointAtLength(e*i);return{x:a.x,y:a.y}}finally{t.removeChild(r)}}function tr(o){return`nd-glow-${o.replace(/[^a-zA-Z0-9]/g,"_")}`}function rr(o,e){const t=o*12,r=1+Math.sin(e)*.3;return t*r}function zt(o,e){const t=(e==null?void 0:e.scale)??1,r=(e==null?void 0:e.background)??"transparent";let i=1/0,a=1/0,s=-1/0,c=-1/0;for(const h of o.nodes)i=Math.min(i,h.position.x),a=Math.min(a,h.position.y),s=Math.max(s,h.position.x+h.size.width),c=Math.max(c,h.position.y+h.size.height);o.nodes.length===0&&(i=a=0,s=c=100);const l=40,u=(s-i+l*2)*t,d=(c-a+l*2)*t,w=-i+l,x=-a+l,g=[];g.push(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${u} ${d}" width="${u}" height="${d}">`),g.push("<defs>"),g.push('<marker id="arrowhead" markerWidth="10" markerHeight="7" refX="10" refY="3.5" orient="auto">'),g.push(' <polygon points="0 0, 10 3.5, 0 7" fill="#666" />'),g.push("</marker>"),g.push("</defs>"),r!=="transparent"&&g.push(`<rect width="${u}" height="${d}" fill="${r}" />`),g.push(`<g transform="translate(${w*t}, ${x*t}) scale(${t})">`);for(const h of o.edges){const v=o.nodes.find(V=>V.id===h.sourceNodeId),_=o.nodes.find(V=>V.id===h.targetNodeId);if(!v||!_)continue;const b=v.position.x+v.size.width/2,m=v.position.y+v.size.height/2,A=_.position.x+_.size.width/2,k=_.position.y+_.size.height/2,j=h.style.strokeColor??"#666",M=h.style.strokeWidth??2,X=h.style.targetArrow!=="none"?' marker-end="url(#arrowhead)"':"";if(h.style.lineType==="bezier"){const V=(b+A)/2,F=m,R=(b+A)/2,I=k;g.push(`<path d="M${b},${m} C${V},${F} ${R},${I} ${A},${k}" fill="none" stroke="${j}" stroke-width="${M}"${X} />`)}else g.push(`<line x1="${b}" y1="${m}" x2="${A}" y2="${k}" stroke="${j}" stroke-width="${M}"${X} />`);if(h.label){const V=(b+A)/2,F=(m+k)/2;g.push(`<text x="${V}" y="${F-6}" text-anchor="middle" font-size="12" fill="#333">${Gt(h.label)}</text>`)}}for(const h of o.nodes){const{x:v,y:_}=h.position,{width:b,height:m}=h.size,A=h.style.backgroundColor??"#fff",k=h.style.borderColor??"#ccc",j=h.style.borderWidth??1,M=h.style.borderRadius??(h.shape==="roundedRect"?8:0),X=h.style.fontColor??"#333",V=h.style.fontSize??14;switch(h.shape){case"ellipse":case"circle":g.push(`<ellipse cx="${v+b/2}" cy="${_+m/2}" rx="${b/2}" ry="${m/2}" fill="${A}" stroke="${k}" stroke-width="${j}" />`);break;case"diamond":g.push(`<polygon points="${v+b/2},${_} ${v+b},${_+m/2} ${v+b/2},${_+m} ${v},${_+m/2}" fill="${A}" stroke="${k}" stroke-width="${j}" />`);break;default:g.push(`<rect x="${v}" y="${_}" width="${b}" height="${m}" rx="${M}" fill="${A}" stroke="${k}" stroke-width="${j}" />`)}g.push(`<text x="${v+b/2}" y="${_+m/2+V/3}" text-anchor="middle" font-size="${V}" fill="${X}" font-family="sans-serif">${Gt(h.label)}</text>`)}return g.push("</g>"),g.push("</svg>"),g.join(`
2
2
  `)}function or(o){const e=[],t=o.diagramType==="orgchart"||o.diagramType==="mindmap"?"graph TB":o.diagramType==="stateMachine"?"stateDiagram-v2":"flowchart TD";e.push(t);for(const r of o.nodes){const i=St(r.id),a=r.label.replace(/"/g,"'");switch(r.shape){case"diamond":e.push(` ${i}{${a}}`);break;case"circle":case"ellipse":e.push(` ${i}((${a}))`);break;case"cylinder":e.push(` ${i}[(${a})]`);break;default:e.push(` ${i}["${a}"]`)}}for(const r of o.edges){const i=St(r.sourceNodeId),a=St(r.targetNodeId),s=r.label?`|${r.label}|`:"",c=r.style.targetArrow==="none"?"---":"-->";e.push(` ${i} ${c}${s} ${a}`)}return e.join(`
3
- `)}function St(o){return o.replace(/[^a-zA-Z0-9_]/g,"_")}function Gt(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const It={en:{"toolbar.select":"Select","toolbar.addNode":"Add Node","toolbar.addEdge":"Add Edge","toolbar.group":"Group","toolbar.ungroup":"Ungroup","toolbar.delete":"Delete","toolbar.undo":"Undo","toolbar.redo":"Redo","toolbar.zoomIn":"Zoom In","toolbar.zoomOut":"Zoom Out","toolbar.fitToScreen":"Fit to Screen","toolbar.export":"Export","toolbar.import":"Import","toolbar.autoLayout":"Auto Layout","toolbar.animations":"Animations","toolbar.dataBinding":"Data Binding","toolbar.pan":"Pan","toolbar.zoomReset":"Reset Zoom","toolbar.layout":"Layout","layout.dagre":"Hierarchical","layout.forceDirected":"Force-Directed","layout.grid":"Grid","layout.radial":"Radial","layout.tree":"Tree","panel.properties":"Properties","panel.style":"Style","panel.animations":"Animations","panel.data":"Data","panel.noSelection":"Select an element to edit its properties","panel.nodeProperties":"Node Properties","panel.edgeProperties":"Edge Properties","node.label":"Label","node.description":"Description","node.shape":"Shape","node.color":"Color","node.border":"Border","node.width":"Width","node.height":"Height","node.bgColor":"Background","node.borderColor":"Border Color","node.fontSize":"Font Size","node.fontColor":"Font Color","node.locked":"Locked","edge.label":"Label","edge.lineType":"Line Type","edge.arrow":"Arrow","edge.color":"Color","edge.width":"Thickness","edge.animated":"Animated","export.svg":"SVG","export.png":"PNG","export.pdf":"PDF","export.mermaid":"Mermaid","export.ndd":"NDD (Native)","viewer.fullscreen":"Fullscreen","viewer.playAnimations":"Play Animations","viewer.stopAnimations":"Stop","viewer.print":"Print","animation.timeline":"Timeline","animation.play":"Play","animation.stop":"Stop","animation.add":"Add","animation.noAnimations":"No animations yet",untitled:"Untitled Diagram","animation.addFromPreset":"Add from preset","animation.presets":"Presets","animation.clickToEdit":"Click to edit","animation.startMs":"Start (ms)","animation.durationMs":"Duration (ms)","node.effects":"Effects","node.glowColor":"Glow Color","node.glowIntensity":"Glow Intensity","node.opacity":"Opacity","node.borderRadius":"Border Radius","node.borderWidth":"Border Width","node.shadow":"Shadow","node.gradientEnd":"Gradient End","node.gradientDir":"Gradient Dir","node.hiddenGhostInEditor":"Hidden (ghost in editor)","node.flowSpeed":"Flow Speed","node.dashStyle":"Dash Style","node.targetArrow":"Target Arrow","node.sourceArrow":"Source Arrow","node.liquidFlow":"Liquid Flow","node.enableLiquidFlow":"Enable Liquid Flow","node.speed":"Speed","node.pipeWidth":"Pipe Width","toolbar.textT":"Text (T)","toolbar.freehandF":"Freehand (F)","toolbar.copyCtrlC":"Copy (Ctrl+C)","toolbar.pasteCtrlV":"Paste (Ctrl+V)","toolbar.duplicateCtrlD":"Duplicate (Ctrl+D)","toolbar.selectAllCtrlA":"Select All (Ctrl+A)","toolbar.findCtrlF":"Find (Ctrl+F)","toolbar.searchNodes":"Search nodes…","toolbar.mermaid":"Mermaid","toolbar.fontFamily":"Font Family","toolbar.fontSize":"Font Size","toolbar.boldCtrlB":"Bold (Ctrl+B)","toolbar.italicCtrlI":"Italic (Ctrl+I)","toolbar.alignmentDistribution":"Alignment & Distribution","toolbar.align":"Align","toolbar.alignLeft":"Align Left","toolbar.left":"Left","toolbar.alignCenter":"Align Center","toolbar.center":"Center","toolbar.alignRight":"Align Right","toolbar.right":"Right","toolbar.alignTop":"Align Top","toolbar.alignMiddle":"Align Middle","toolbar.middle":"Middle","toolbar.alignBottom":"Align Bottom","toolbar.bottom":"Bottom","toolbar.distribute":"Distribute","toolbar.distributeHorizontally":"Distribute Horizontally","toolbar.distributeVertically":"Distribute Vertically","toolbar.arrange":"Arrange","toolbar.editorMode":"Editor Mode","toolbar.editor":"Editor","toolbar.playerMode":"Player Mode","toolbar.player":"Player","toolbar.animatedPlayerMode":"Animated Player Mode","toolbar.animated":"Animated","toolbar.stylePresets":"Style Presets","toolbar.style":"Style","diagramEditor.addAnimationMode":"Add animation mode","animation.zoomIn":"Zoom in","animation.zoomOut":"Zoom out","toolbar.bringToFront":"Bring to Front","toolbar.sendToBack":"Send to Back","diagramCellRenderer.diagram":"Diagram","diagramCellRenderer.nodesEdges":"{nodes} nodes • {edges} edges","diagramCellRenderer.nodesEdges2":"{nodes} nodes, {edges} edges","node.vertical":"Vertical","node.horizontal":"Horizontal","node.diagonal":"Diagonal","node.radial":"Radial","node.straight":"Straight","node.bezier":"Bezier","node.orthogonal":"Orthogonal","node.step":"Step","node.solid":"Solid","node.dashed":"Dashed","node.dotted":"Dotted","node.dashDot":"Dash-Dot","node.longDash":"Long Dash","node.arrow":"Arrow","node.openArrow":"Open Arrow","node.diamond":"Diamond","node.circle":"Circle","node.none":"None","toolbar.top":"Top","toolbar.selected":"{selectionCount} selected","decisionTreeEditor.decisionTree":"Decision Tree","dependencyGraph.optional":"(optional)","dependencyGraph.dependencyGraph":"Dependency Graph","diagramEditor.modes":"Modes:","networkTopology.networkTopology":"Network Topology","orgChartVisualizer.organizationChart":"Organization Chart","processMiningDiagram.processMiningDiagram":"Process Mining Diagram","workflowDesigner.step.initial":"Start","workflowDesigner.step.intermediate":"State","workflowDesigner.step.approval":"Approval","workflowDesigner.step.final":"End","workflowDesigner.step.error":"Error","workflowDesigner.val.noInitial":"No initial state","workflowDesigner.val.multiInitial":"More than one initial state","workflowDesigner.val.noFinal":"No final state","workflowDesigner.val.deadEnd":'State "{name}" has no outgoing transitions (dead-end)',"workflowDesigner.val.orphan":'State "{name}" is unreachable (orphan)',"workflowDesigner.next":"Next","workflowDesigner.addStep":"Add step","workflowDesigner.loadingSteps":"Loading step types…","workflowDesigner.toolbar":"Workflow toolbar","workflowDesigner.simulate":"Simulate","workflowDesigner.zoomOut":"Zoom out","workflowDesigner.resetView":"Reset view","workflowDesigner.zoomIn":"Zoom in","workflowDesigner.fit":"Fit to view","workflowDesigner.test":"Test","workflowDesigner.publish":"Publish","workflowDesigner.closeProps":"Close properties","workflowDesigner.stateProps":"State properties","workflowDesigner.stateName":"State name","workflowDesigner.stateType":"State type","workflowDesigner.transitions":"Transitions","workflowDesigner.noTransitions":"No transitions yet","workflowDesigner.transitionName":"Transition name","workflowDesigner.target":"To","workflowDesigner.deleteFlow":"Delete flow","workflowDesigner.addTransition":"Add transition","workflowDesigner.deleteState":"Delete state {name}","workflowDesigner.properties":"Properties","workflowDesigner.flowOf":"Flow: {name}","workflowDesigner.from":"From","workflowDesigner.simActiveState":"Simulation active — current state:","workflowDesigner.endSimulation":"End simulation","workflowDesigner.canvas":"Workflow canvas","workflowDesigner.minimap":"Minimap","diagramEditor.nodeTypes":"Add a node"},pl:{"toolbar.select":"Zaznacz","toolbar.addNode":"Dodaj węzeł","toolbar.addEdge":"Dodaj połączenie","toolbar.group":"Grupuj","toolbar.ungroup":"Rozgrupuj","toolbar.delete":"Usuń","toolbar.undo":"Cofnij","toolbar.redo":"Ponów","toolbar.zoomIn":"Powiększ","toolbar.zoomOut":"Pomniejsz","toolbar.fitToScreen":"Dopasuj do ekranu","toolbar.export":"Eksportuj","toolbar.import":"Importuj","toolbar.autoLayout":"Auto układ","toolbar.animations":"Animacje","toolbar.dataBinding":"Dane","toolbar.pan":"Przesuń","toolbar.zoomReset":"Przywróć powiększenie","toolbar.layout":"Układ","layout.dagre":"Hierarchiczny","layout.forceDirected":"Siłowy","layout.grid":"Siatka","layout.radial":"Promieniowy","layout.tree":"Drzewo","panel.properties":"Właściwości","panel.style":"Styl","panel.animations":"Animacje","panel.data":"Dane","panel.noSelection":"Zaznacz element, aby edytować jego właściwości","panel.nodeProperties":"Właściwości węzła","panel.edgeProperties":"Właściwości połączenia","node.label":"Etykieta","node.description":"Opis","node.shape":"Kształt","node.color":"Kolor","node.border":"Obramowanie","node.width":"Szerokość","node.height":"Wysokość","node.bgColor":"Tło","node.borderColor":"Kolor obramowania","node.fontSize":"Rozmiar czcionki","node.fontColor":"Kolor czcionki","node.locked":"Zablokowany","edge.label":"Etykieta","edge.lineType":"Typ linii","edge.arrow":"Strzałka","edge.color":"Kolor","edge.width":"Grubość","edge.animated":"Animowane","export.svg":"SVG","export.png":"PNG","export.pdf":"PDF","export.mermaid":"Mermaid","export.ndd":"NDD (Natywny)","viewer.fullscreen":"Pełny ekran","viewer.playAnimations":"Odtwórz animacje","viewer.stopAnimations":"Zatrzymaj","viewer.print":"Drukuj","animation.timeline":"Oś czasu","animation.play":"Odtwórz","animation.stop":"Zatrzymaj","animation.add":"Dodaj","animation.noAnimations":"Brak animacji",untitled:"Diagram bez nazwy","animation.addFromPreset":"Dodaj z gotowych","animation.presets":"Gotowe","animation.clickToEdit":"Kliknij, aby edytować","animation.startMs":"Początek (ms)","animation.durationMs":"Czas trwania (ms)","node.effects":"Efekty","node.glowColor":"Kolor poświaty","node.glowIntensity":"Siła poświaty","node.opacity":"Krycie","node.borderRadius":"Zaokrąglenie rogów","node.borderWidth":"Grubość obramowania","node.shadow":"Cień","node.gradientEnd":"Koniec gradientu","node.gradientDir":"Kierunek gradientu","node.hiddenGhostInEditor":"Ukryty (półprzezroczysty w edytorze)","node.flowSpeed":"Prędkość przepływu","node.dashStyle":"Styl kreski","node.targetArrow":"Grot końcowy","node.sourceArrow":"Grot początkowy","node.liquidFlow":"Przepływ cieczy","node.enableLiquidFlow":"Włącz przepływ cieczy","node.speed":"Prędkość","node.pipeWidth":"Szerokość rury","toolbar.textT":"Tekst (T)","toolbar.freehandF":"Odręcznie (F)","toolbar.copyCtrlC":"Kopiuj (Ctrl+C)","toolbar.pasteCtrlV":"Wklej (Ctrl+V)","toolbar.duplicateCtrlD":"Duplikuj (Ctrl+D)","toolbar.selectAllCtrlA":"Zaznacz wszystko (Ctrl+A)","toolbar.findCtrlF":"Znajdź (Ctrl+F)","toolbar.searchNodes":"Szukaj węzłów…","toolbar.mermaid":"Mermaid","toolbar.fontFamily":"Krój czcionki","toolbar.fontSize":"Rozmiar czcionki","toolbar.boldCtrlB":"Pogrubienie (Ctrl+B)","toolbar.italicCtrlI":"Kursywa (Ctrl+I)","toolbar.alignmentDistribution":"Wyrównanie i rozmieszczenie","toolbar.align":"Wyrównaj","toolbar.alignLeft":"Wyrównaj do lewej","toolbar.left":"Do lewej","toolbar.alignCenter":"Wyśrodkuj w poziomie","toolbar.center":"Środek","toolbar.alignRight":"Wyrównaj do prawej","toolbar.right":"Do prawej","toolbar.alignTop":"Wyrównaj do góry","toolbar.alignMiddle":"Wyśrodkuj w pionie","toolbar.middle":"Środek","toolbar.alignBottom":"Wyrównaj do dołu","toolbar.bottom":"Dół","toolbar.distribute":"Rozmieść","toolbar.distributeHorizontally":"Rozmieść w poziomie","toolbar.distributeVertically":"Rozmieść w pionie","toolbar.arrange":"Ułóż","toolbar.editorMode":"Tryb edycji","toolbar.editor":"Edytor","toolbar.playerMode":"Tryb odtwarzania","toolbar.player":"Odtwarzacz","toolbar.animatedPlayerMode":"Tryb odtwarzania z animacją","toolbar.animated":"Z animacją","toolbar.stylePresets":"Gotowe style","toolbar.style":"Styl","diagramEditor.addAnimationMode":"Dodaj tryb animacji","animation.zoomIn":"Powiększ","animation.zoomOut":"Pomniejsz","toolbar.bringToFront":"Na wierzch","toolbar.sendToBack":"Na spód","diagramCellRenderer.diagram":"Diagram","diagramCellRenderer.nodesEdges":"Węzły: {nodes} • krawędzie: {edges}","diagramCellRenderer.nodesEdges2":"Węzły: {nodes}, krawędzie: {edges}","node.vertical":"Pionowo","node.horizontal":"Poziomo","node.diagonal":"Ukośnie","node.radial":"Promieniście","node.straight":"Prosta","node.bezier":"Krzywa Béziera","node.orthogonal":"Ortogonalna","node.step":"Schodkowa","node.solid":"Ciągła","node.dashed":"Kreskowana","node.dotted":"Kropkowana","node.dashDot":"Kreska-kropka","node.longDash":"Długa kreska","node.arrow":"Strzałka","node.openArrow":"Strzałka otwarta","node.diamond":"Romb","node.circle":"Koło","node.none":"Brak","toolbar.top":"Do góry","toolbar.selected":"Zaznaczono: {selectionCount}","decisionTreeEditor.decisionTree":"Drzewo decyzyjne","dependencyGraph.optional":"(opcjonalna)","dependencyGraph.dependencyGraph":"Graf zależności","diagramEditor.modes":"Tryby:","networkTopology.networkTopology":"Topologia sieci","orgChartVisualizer.organizationChart":"Schemat organizacyjny","processMiningDiagram.processMiningDiagram":"Diagram eksploracji procesów"},de:{"toolbar.select":"Auswählen","toolbar.addNode":"Knoten hinzufügen","toolbar.addEdge":"Kante hinzufügen","toolbar.group":"Gruppieren","toolbar.ungroup":"Gruppierung aufheben","toolbar.delete":"Löschen","toolbar.undo":"Rückgängig","toolbar.redo":"Wiederholen","toolbar.zoomIn":"Vergrößern","toolbar.zoomOut":"Verkleinern","toolbar.fitToScreen":"An Bildschirm anpassen","toolbar.export":"Exportieren","toolbar.import":"Importieren","toolbar.autoLayout":"Automatisches Layout","toolbar.animations":"Animationen","toolbar.dataBinding":"Datenbindung","toolbar.pan":"Verschieben","toolbar.zoomReset":"Zoom zurücksetzen","toolbar.layout":"Layout","layout.dagre":"Hierarchisch","layout.forceDirected":"Kräftebasiert","layout.grid":"Raster","layout.radial":"Radial","layout.tree":"Baum","panel.properties":"Eigenschaften","panel.style":"Stil","panel.animations":"Animationen","panel.data":"Daten","panel.noSelection":"Wählen Sie ein Element aus, um seine Eigenschaften zu bearbeiten","panel.nodeProperties":"Knoteneigenschaften","panel.edgeProperties":"Kanteneigenschaften","node.label":"Bezeichnung","node.description":"Beschreibung","node.shape":"Form","node.color":"Farbe","node.border":"Rahmen","node.width":"Breite","node.height":"Höhe","node.bgColor":"Hintergrund","node.borderColor":"Rahmenfarbe","node.fontSize":"Schriftgröße","node.fontColor":"Schriftfarbe","node.locked":"Gesperrt","edge.label":"Bezeichnung","edge.lineType":"Linientyp","edge.arrow":"Pfeil","edge.color":"Farbe","edge.width":"Stärke","edge.animated":"Animiert","export.svg":"SVG","export.png":"PNG","export.pdf":"PDF","export.mermaid":"Mermaid","export.ndd":"NDD (Nativ)","viewer.fullscreen":"Vollbild","viewer.playAnimations":"Animationen abspielen","viewer.stopAnimations":"Stopp","viewer.print":"Drucken","animation.timeline":"Zeitleiste","animation.play":"Abspielen","animation.stop":"Stopp","animation.add":"Hinzufügen","animation.noAnimations":"Noch keine Animationen",untitled:"Unbenanntes Diagramm","animation.addFromPreset":"Aus Vorlage hinzufügen","animation.presets":"Vorlagen","animation.clickToEdit":"Zum Bearbeiten klicken","animation.startMs":"Start (ms)","animation.durationMs":"Dauer (ms)","node.effects":"Effekte","node.glowColor":"Leuchtfarbe","node.glowIntensity":"Leuchtstärke","node.opacity":"Deckkraft","node.borderRadius":"Eckenradius","node.borderWidth":"Rahmenbreite","node.shadow":"Schatten","node.gradientEnd":"Verlaufsende","node.gradientDir":"Verlaufsrichtung","node.hiddenGhostInEditor":"Ausgeblendet (im Editor transparent)","node.flowSpeed":"Flussgeschwindigkeit","node.dashStyle":"Strichart","node.targetArrow":"Pfeil am Ziel","node.sourceArrow":"Pfeil an der Quelle","node.liquidFlow":"Flüssigkeitsfluss","node.enableLiquidFlow":"Flüssigkeitsfluss aktivieren","node.speed":"Geschwindigkeit","node.pipeWidth":"Rohrbreite","toolbar.textT":"Text (T)","toolbar.freehandF":"Freihand (F)","toolbar.copyCtrlC":"Kopieren (Strg+C)","toolbar.pasteCtrlV":"Einfügen (Strg+V)","toolbar.duplicateCtrlD":"Duplizieren (Strg+D)","toolbar.selectAllCtrlA":"Alles auswählen (Strg+A)","toolbar.findCtrlF":"Suchen (Strg+F)","toolbar.searchNodes":"Knoten suchen…","toolbar.mermaid":"Mermaid","toolbar.fontFamily":"Schriftart","toolbar.fontSize":"Schriftgröße","toolbar.boldCtrlB":"Fett (Strg+B)","toolbar.italicCtrlI":"Kursiv (Strg+I)","toolbar.alignmentDistribution":"Ausrichten & Verteilen","toolbar.align":"Ausrichten","toolbar.alignLeft":"Links ausrichten","toolbar.left":"Links","toolbar.alignCenter":"Horizontal zentrieren","toolbar.center":"Mitte","toolbar.alignRight":"Rechts ausrichten","toolbar.right":"Rechts","toolbar.alignTop":"Oben ausrichten","toolbar.alignMiddle":"Vertikal zentrieren","toolbar.middle":"Mitte","toolbar.alignBottom":"Unten ausrichten","toolbar.bottom":"Unten","toolbar.distribute":"Verteilen","toolbar.distributeHorizontally":"Horizontal verteilen","toolbar.distributeVertically":"Vertikal verteilen","toolbar.arrange":"Anordnen","toolbar.editorMode":"Bearbeitungsmodus","toolbar.editor":"Editor","toolbar.playerMode":"Wiedergabemodus","toolbar.player":"Player","toolbar.animatedPlayerMode":"Animierter Wiedergabemodus","toolbar.animated":"Animiert","toolbar.stylePresets":"Stilvorlagen","toolbar.style":"Stil","diagramEditor.addAnimationMode":"Animationsmodus hinzufügen","animation.zoomIn":"Vergrößern","animation.zoomOut":"Verkleinern","toolbar.bringToFront":"In den Vordergrund","toolbar.sendToBack":"In den Hintergrund","diagramCellRenderer.diagram":"Diagramm","diagramCellRenderer.nodesEdges":"{nodes} Knoten • {edges} Kanten","diagramCellRenderer.nodesEdges2":"{nodes} Knoten, {edges} Kanten","node.vertical":"Vertikal","node.horizontal":"Horizontal","node.diagonal":"Diagonal","node.radial":"Radial","node.straight":"Gerade","node.bezier":"Bézier","node.orthogonal":"Orthogonal","node.step":"Stufen","node.solid":"Durchgezogen","node.dashed":"Gestrichelt","node.dotted":"Gepunktet","node.dashDot":"Strichpunkt","node.longDash":"Langer Strich","node.arrow":"Pfeil","node.openArrow":"Offener Pfeil","node.diamond":"Raute","node.circle":"Kreis","node.none":"Keine","toolbar.top":"Oben","toolbar.selected":"{selectionCount} ausgewählt","decisionTreeEditor.decisionTree":"Entscheidungsbaum","dependencyGraph.optional":"(optional)","dependencyGraph.dependencyGraph":"Abhängigkeitsgraph","diagramEditor.modes":"Modi:","networkTopology.networkTopology":"Netzwerktopologie","orgChartVisualizer.organizationChart":"Organigramm","processMiningDiagram.processMiningDiagram":"Process-Mining-Diagramm"},fr:{"toolbar.select":"Sélectionner","toolbar.addNode":"Ajouter un nœud","toolbar.addEdge":"Ajouter une arête","toolbar.group":"Grouper","toolbar.ungroup":"Dégrouper","toolbar.delete":"Supprimer","toolbar.undo":"Annuler","toolbar.redo":"Rétablir","toolbar.zoomIn":"Agrandir","toolbar.zoomOut":"Réduire","toolbar.fitToScreen":"Ajuster à l'écran","toolbar.export":"Exporter","toolbar.import":"Importer","toolbar.autoLayout":"Mise en page auto","toolbar.animations":"Animations","toolbar.dataBinding":"Liaison de données","toolbar.pan":"Déplacer","toolbar.zoomReset":"Réinitialiser le zoom","toolbar.layout":"Disposition","layout.dagre":"Hiérarchique","layout.forceDirected":"Force dirigée","layout.grid":"Grille","layout.radial":"Radial","layout.tree":"Arbre","panel.properties":"Propriétés","panel.style":"Style","panel.animations":"Animations","panel.data":"Données","panel.noSelection":"Sélectionnez un élément pour modifier ses propriétés","panel.nodeProperties":"Propriétés du nœud","panel.edgeProperties":"Propriétés de l'arête","node.label":"Étiquette","node.description":"Description","node.shape":"Forme","node.color":"Couleur","node.border":"Bordure","node.width":"Largeur","node.height":"Hauteur","node.bgColor":"Arrière-plan","node.borderColor":"Couleur de bordure","node.fontSize":"Taille de police","node.fontColor":"Couleur de police","node.locked":"Verrouillé","edge.label":"Étiquette","edge.lineType":"Type de ligne","edge.arrow":"Flèche","edge.color":"Couleur","edge.width":"Épaisseur","edge.animated":"Animée","export.svg":"SVG","export.png":"PNG","export.pdf":"PDF","export.mermaid":"Mermaid","export.ndd":"NDD (Natif)","viewer.fullscreen":"Plein écran","viewer.playAnimations":"Lire les animations","viewer.stopAnimations":"Arrêter","viewer.print":"Imprimer","animation.timeline":"Chronologie","animation.play":"Lire","animation.stop":"Arrêter","animation.add":"Ajouter","animation.noAnimations":"Aucune animation",untitled:"Diagramme sans titre","animation.addFromPreset":"Ajouter depuis un préréglage","animation.presets":"Préréglages","animation.clickToEdit":"Cliquer pour modifier","animation.startMs":"Début (ms)","animation.durationMs":"Durée (ms)","node.effects":"Effets","node.glowColor":"Couleur de lueur","node.glowIntensity":"Intensité de la lueur","node.opacity":"Opacité","node.borderRadius":"Rayon des coins","node.borderWidth":"Épaisseur de bordure","node.shadow":"Ombre","node.gradientEnd":"Fin du dégradé","node.gradientDir":"Direction du dégradé","node.hiddenGhostInEditor":"Masqué (fantôme dans l'éditeur)","node.flowSpeed":"Vitesse du flux","node.dashStyle":"Style de tirets","node.targetArrow":"Flèche cible","node.sourceArrow":"Flèche source","node.liquidFlow":"Flux liquide","node.enableLiquidFlow":"Activer le flux liquide","node.speed":"Vitesse","node.pipeWidth":"Largeur du tuyau","toolbar.textT":"Texte (T)","toolbar.freehandF":"Main levée (F)","toolbar.copyCtrlC":"Copier (Ctrl+C)","toolbar.pasteCtrlV":"Coller (Ctrl+V)","toolbar.duplicateCtrlD":"Dupliquer (Ctrl+D)","toolbar.selectAllCtrlA":"Tout sélectionner (Ctrl+A)","toolbar.findCtrlF":"Rechercher (Ctrl+F)","toolbar.searchNodes":"Rechercher des nœuds…","toolbar.mermaid":"Mermaid","toolbar.fontFamily":"Police","toolbar.fontSize":"Taille de police","toolbar.boldCtrlB":"Gras (Ctrl+B)","toolbar.italicCtrlI":"Italique (Ctrl+I)","toolbar.alignmentDistribution":"Alignement et répartition","toolbar.align":"Aligner","toolbar.alignLeft":"Aligner à gauche","toolbar.left":"Gauche","toolbar.alignCenter":"Centrer horizontalement","toolbar.center":"Centre","toolbar.alignRight":"Aligner à droite","toolbar.right":"Droite","toolbar.alignTop":"Aligner en haut","toolbar.alignMiddle":"Centrer verticalement","toolbar.middle":"Milieu","toolbar.alignBottom":"Aligner en bas","toolbar.bottom":"Bas","toolbar.distribute":"Répartir","toolbar.distributeHorizontally":"Répartir horizontalement","toolbar.distributeVertically":"Répartir verticalement","toolbar.arrange":"Organiser","toolbar.editorMode":"Mode édition","toolbar.editor":"Éditeur","toolbar.playerMode":"Mode lecture","toolbar.player":"Lecteur","toolbar.animatedPlayerMode":"Mode lecture animé","toolbar.animated":"Animé","toolbar.stylePresets":"Styles prédéfinis","toolbar.style":"Style","diagramEditor.addAnimationMode":"Ajouter un mode d'animation","animation.zoomIn":"Zoom avant","animation.zoomOut":"Zoom arrière","toolbar.bringToFront":"Mettre au premier plan","toolbar.sendToBack":"Mettre à l'arrière-plan","diagramCellRenderer.diagram":"Diagramme","diagramCellRenderer.nodesEdges":"{nodes} nœuds • {edges} arêtes","diagramCellRenderer.nodesEdges2":"{nodes} nœuds, {edges} arêtes","node.vertical":"Vertical","node.horizontal":"Horizontal","node.diagonal":"Diagonal","node.radial":"Radial","node.straight":"Droite","node.bezier":"Bézier","node.orthogonal":"Orthogonale","node.step":"En escalier","node.solid":"Continue","node.dashed":"Tirets","node.dotted":"Pointillés","node.dashDot":"Tiret-point","node.longDash":"Tiret long","node.arrow":"Flèche","node.openArrow":"Flèche ouverte","node.diamond":"Losange","node.circle":"Cercle","node.none":"Aucune","toolbar.top":"Haut","toolbar.selected":"{selectionCount} sélectionnés","decisionTreeEditor.decisionTree":"Arbre de décision","dependencyGraph.optional":"(facultative)","dependencyGraph.dependencyGraph":"Graphe de dépendances","diagramEditor.modes":"Modes :","networkTopology.networkTopology":"Topologie réseau","orgChartVisualizer.organizationChart":"Organigramme","processMiningDiagram.processMiningDiagram":"Diagramme de process mining"},es:{"toolbar.select":"Seleccionar","toolbar.addNode":"Añadir nodo","toolbar.addEdge":"Añadir arista","toolbar.group":"Agrupar","toolbar.ungroup":"Desagrupar","toolbar.delete":"Eliminar","toolbar.undo":"Deshacer","toolbar.redo":"Rehacer","toolbar.zoomIn":"Ampliar","toolbar.zoomOut":"Reducir","toolbar.fitToScreen":"Ajustar a pantalla","toolbar.export":"Exportar","toolbar.import":"Importar","toolbar.autoLayout":"Diseño automático","toolbar.animations":"Animaciones","toolbar.dataBinding":"Enlace de datos","toolbar.pan":"Desplazar","toolbar.zoomReset":"Restablecer zoom","toolbar.layout":"Diseño","layout.dagre":"Jerárquico","layout.forceDirected":"Fuerza dirigida","layout.grid":"Cuadrícula","layout.radial":"Radial","layout.tree":"Árbol","panel.properties":"Propiedades","panel.style":"Estilo","panel.animations":"Animaciones","panel.data":"Datos","panel.noSelection":"Selecciona un elemento para editar sus propiedades","panel.nodeProperties":"Propiedades del nodo","panel.edgeProperties":"Propiedades de la arista","node.label":"Etiqueta","node.description":"Descripción","node.shape":"Forma","node.color":"Color","node.border":"Borde","node.width":"Ancho","node.height":"Alto","node.bgColor":"Fondo","node.borderColor":"Color del borde","node.fontSize":"Tamaño de fuente","node.fontColor":"Color de fuente","node.locked":"Bloqueado","edge.label":"Etiqueta","edge.lineType":"Tipo de línea","edge.arrow":"Flecha","edge.color":"Color","edge.width":"Grosor","edge.animated":"Animada","export.svg":"SVG","export.png":"PNG","export.pdf":"PDF","export.mermaid":"Mermaid","export.ndd":"NDD (Nativo)","viewer.fullscreen":"Pantalla completa","viewer.playAnimations":"Reproducir animaciones","viewer.stopAnimations":"Detener","viewer.print":"Imprimir","animation.timeline":"Línea de tiempo","animation.play":"Reproducir","animation.stop":"Detener","animation.add":"Añadir","animation.noAnimations":"Sin animaciones",untitled:"Diagrama sin título","animation.addFromPreset":"Añadir desde un preajuste","animation.presets":"Preajustes","animation.clickToEdit":"Haz clic para editar","animation.startMs":"Inicio (ms)","animation.durationMs":"Duración (ms)","node.effects":"Efectos","node.glowColor":"Color del brillo","node.glowIntensity":"Intensidad del brillo","node.opacity":"Opacidad","node.borderRadius":"Radio del borde","node.borderWidth":"Grosor del borde","node.shadow":"Sombra","node.gradientEnd":"Fin del degradado","node.gradientDir":"Dirección del degradado","node.hiddenGhostInEditor":"Oculto (fantasma en el editor)","node.flowSpeed":"Velocidad del flujo","node.dashStyle":"Estilo de trazo","node.targetArrow":"Flecha de destino","node.sourceArrow":"Flecha de origen","node.liquidFlow":"Flujo de líquido","node.enableLiquidFlow":"Activar flujo de líquido","node.speed":"Velocidad","node.pipeWidth":"Ancho de tubería","toolbar.textT":"Texto (T)","toolbar.freehandF":"A mano alzada (F)","toolbar.copyCtrlC":"Copiar (Ctrl+C)","toolbar.pasteCtrlV":"Pegar (Ctrl+V)","toolbar.duplicateCtrlD":"Duplicar (Ctrl+D)","toolbar.selectAllCtrlA":"Seleccionar todo (Ctrl+A)","toolbar.findCtrlF":"Buscar (Ctrl+F)","toolbar.searchNodes":"Buscar nodos…","toolbar.mermaid":"Mermaid","toolbar.fontFamily":"Fuente","toolbar.fontSize":"Tamaño de fuente","toolbar.boldCtrlB":"Negrita (Ctrl+B)","toolbar.italicCtrlI":"Cursiva (Ctrl+I)","toolbar.alignmentDistribution":"Alineación y distribución","toolbar.align":"Alinear","toolbar.alignLeft":"Alinear a la izquierda","toolbar.left":"Izquierda","toolbar.alignCenter":"Centrar horizontalmente","toolbar.center":"Centro","toolbar.alignRight":"Alinear a la derecha","toolbar.right":"Derecha","toolbar.alignTop":"Alinear arriba","toolbar.alignMiddle":"Centrar verticalmente","toolbar.middle":"Medio","toolbar.alignBottom":"Alinear abajo","toolbar.bottom":"Abajo","toolbar.distribute":"Distribuir","toolbar.distributeHorizontally":"Distribuir horizontalmente","toolbar.distributeVertically":"Distribuir verticalmente","toolbar.arrange":"Organizar","toolbar.editorMode":"Modo de edición","toolbar.editor":"Editor","toolbar.playerMode":"Modo de reproducción","toolbar.player":"Reproductor","toolbar.animatedPlayerMode":"Modo de reproducción animado","toolbar.animated":"Animado","toolbar.stylePresets":"Estilos predefinidos","toolbar.style":"Estilo","diagramEditor.addAnimationMode":"Añadir modo de animación","animation.zoomIn":"Acercar","animation.zoomOut":"Alejar","toolbar.bringToFront":"Traer al frente","toolbar.sendToBack":"Enviar al fondo","diagramCellRenderer.diagram":"Diagrama","diagramCellRenderer.nodesEdges":"{nodes} nodos • {edges} aristas","diagramCellRenderer.nodesEdges2":"{nodes} nodos, {edges} aristas","node.vertical":"Vertical","node.horizontal":"Horizontal","node.diagonal":"Diagonal","node.radial":"Radial","node.straight":"Recta","node.bezier":"Bézier","node.orthogonal":"Ortogonal","node.step":"Escalonada","node.solid":"Continua","node.dashed":"Discontinua","node.dotted":"Punteada","node.dashDot":"Raya-punto","node.longDash":"Raya larga","node.arrow":"Flecha","node.openArrow":"Flecha abierta","node.diamond":"Rombo","node.circle":"Círculo","node.none":"Ninguna","toolbar.top":"Arriba","toolbar.selected":"{selectionCount} seleccionados","decisionTreeEditor.decisionTree":"Árbol de decisión","dependencyGraph.optional":"(opcional)","dependencyGraph.dependencyGraph":"Grafo de dependencias","diagramEditor.modes":"Modos:","networkTopology.networkTopology":"Topología de red","orgChartVisualizer.organizationChart":"Organigrama","processMiningDiagram.processMiningDiagram":"Diagrama de minería de procesos"}},ir=p.createContext(null);function ar(o,e){const t={...It.en,...It[o],...e};return{locale:o,t:(i,a)=>t[i]??a??i}}function jt({locale:o="en",overrides:e,children:t}){const r=p.useMemo(()=>ar(o,e),[o,e]);return p.createElement(ir.Provider,{value:r},t)}function Re(){const o=p.useContext(ir),{lang:e}=y.useNiceTranslation(),t=It[e]?e:"en",r=p.useMemo(()=>ar(t),[t]);return o??r}function Xr(o){const e=[];let t;try{t=JSON.parse(o)}catch{return{ok:!1,errors:["Invalid JSON: parse failed"]}}if(typeof t!="object"||t===null||Array.isArray(t))return{ok:!1,errors:["Root must be a JSON object"]};const r=t;if(r.version!=="1.0"&&e.push(`Unsupported version "${String(r.version)}", expected "1.0"`),(typeof r.id!="string"||r.id.length===0)&&e.push('Missing or invalid "id" field'),typeof r.title!="string"&&e.push('Missing or invalid "title" field'),Array.isArray(r.nodes)||e.push('Missing or invalid "nodes" array'),Array.isArray(r.edges)||e.push('Missing or invalid "edges" array'),Array.isArray(r.nodes)&&Array.isArray(r.edges)){const i=new Set(r.nodes.map(a=>a.id).filter(Boolean));for(const a of r.edges)a.sourceNodeId&&!i.has(a.sourceNodeId)&&e.push(`Edge "${a.id}" references non-existent source node "${a.sourceNodeId}"`),a.targetNodeId&&!i.has(a.targetNodeId)&&e.push(`Edge "${a.id}" references non-existent target node "${a.targetNodeId}"`)}return e.length>0?{ok:!1,errors:e}:{ok:!0,document:t,errors:[]}}function nr(o,e=!0){return JSON.stringify(o,null,e?2:void 0)}class pt{constructor(e){this.undoStack=[],this.redoStack=[],this.listeners=new Set,this.maxHistory=100,this.doc=e??pt.createEmpty()}static createEmpty(e="flowchart"){const t=new Date().toISOString();return{version:"1.0",id:it(),title:"Untitled Diagram",diagramType:e,nodes:[],edges:[],groups:[],animations:[],viewport:{x:0,y:0,zoom:1},metadata:{createdAt:t,updatedAt:t}}}getDocument(){return this.doc}getNodes(){return this.doc.nodes}getEdges(){return this.doc.edges}getGroups(){return this.doc.groups}getAnimations(){return this.doc.animations}getNodeById(e){return this.doc.nodes.find(t=>t.id===e)}getEdgeById(e){return this.doc.edges.find(t=>t.id===e)}getViewport(){return{...this.doc.viewport}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.doc.metadata.updatedAt=new Date().toISOString(),this.listeners.forEach(e=>e())}pushUndo(e){this.undoStack.push({label:e,snapshot:JSON.stringify(this.doc)}),this.undoStack.length>this.maxHistory&&this.undoStack.shift(),this.redoStack=[]}undo(){const e=this.undoStack.pop();return e?(this.redoStack.push({label:"redo",snapshot:JSON.stringify(this.doc)}),this.doc=JSON.parse(e.snapshot),this.notify(),!0):!1}redo(){const e=this.redoStack.pop();return e?(this.undoStack.push({label:"undo",snapshot:JSON.stringify(this.doc)}),this.doc=JSON.parse(e.snapshot),this.notify(),!0):!1}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}addNode(e,t,r="roundedRect",i={width:160,height:60}){this.pushUndo("Add node");const a=Kr(),s={id:it(),label:e,position:t,size:i,shape:r,style:{},ports:a};return this.doc.nodes.push(s),this.notify(),s}updateNode(e,t){this.pushUndo("Update node");const r=this.doc.nodes.find(i=>i.id===e);r&&Object.assign(r,t),this.notify()}moveNodes(e,t=!0){const r=[...e].filter(([i])=>this.getNodeById(i));if(r.length!==0){t&&this.pushUndo("Layout");for(const[i,a]of r)this.getNodeById(i).position={...a};this.notify()}}moveNode(e,t){const r=this.doc.nodes.find(i=>i.id===e);r&&(this.pushUndo("Move node"),r.position=t,this.notify())}resizeNode(e,t){const r=this.doc.nodes.find(i=>i.id===e);r&&(this.pushUndo("Resize node"),r.size=t,this.notify())}removeNode(e){this.pushUndo("Remove node"),this.doc.nodes=this.doc.nodes.filter(t=>t.id!==e),this.doc.edges=this.doc.edges.filter(t=>t.sourceNodeId!==e&&t.targetNodeId!==e),this.doc.groups.forEach(t=>{t.nodeIds=t.nodeIds.filter(r=>r!==e)}),this.doc.animations=this.doc.animations.filter(t=>t.targetId!==e),this.notify()}addEdge(e,t,r,i,a){if(e===r||!this.getNodeById(e)||!this.getNodeById(r))return null;this.pushUndo("Add edge");const s={id:it(),sourceNodeId:e,sourcePortId:t,targetNodeId:r,targetPortId:i,label:a,style:{lineType:"bezier",targetArrow:"arrow"}};return this.doc.edges.push(s),this.notify(),s}updateEdge(e,t){this.pushUndo("Update edge");const r=this.doc.edges.find(i=>i.id===e);r&&Object.assign(r,t),this.notify()}removeEdge(e){this.pushUndo("Remove edge"),this.doc.edges=this.doc.edges.filter(t=>t.id!==e),this.doc.animations=this.doc.animations.filter(t=>t.targetId!==e),this.notify()}createGroup(e,t){this.pushUndo("Create group");const r={id:it(),label:e,nodeIds:[...t]};return t.forEach(i=>{const a=this.doc.nodes.find(s=>s.id===i);a&&(a.groupId=r.id)}),this.doc.groups.push(r),this.notify(),r}removeGroup(e){this.pushUndo("Remove group");const t=this.doc.groups.find(r=>r.id===e);t&&t.nodeIds.forEach(r=>{const i=this.doc.nodes.find(a=>a.id===r);i&&(i.groupId=void 0)}),this.doc.groups=this.doc.groups.filter(r=>r.id!==e),this.notify()}addAnimation(e){this.pushUndo("Add animation");const t={id:it(),...e};return this.doc.animations.push(t),this.notify(),t}removeAnimation(e){this.pushUndo("Remove animation"),this.doc.animations=this.doc.animations.filter(t=>t.id!==e),this.notify()}setViewport(e){this.doc.viewport={...e},this.notify()}toggleGroupCollapse(e){const t=this.doc.groups.find(r=>r.id===e);t&&(this.pushUndo("Toggle group collapse"),t.collapsed=!t.collapsed,t.nodeIds.forEach(r=>{const i=this.doc.nodes.find(a=>a.id===r);i&&(i.hidden=t.collapsed)}),this.notify())}toggleNodeCollapse(e){const t=this.doc.nodes.find(r=>r.id===e);t&&(this.pushUndo("Toggle node collapse"),t.collapsed=!t.collapsed,(t.childNodeIds??[]).forEach(r=>{const i=this.doc.nodes.find(a=>a.id===r);i&&(i.hidden=t.collapsed)}),this.notify())}getAnimationModes(){return this.doc.animationModes??[]}getActiveAnimationMode(){var e;if((e=this.doc.animationModes)!=null&&e.length)return this.doc.animationModes.find(t=>t.id===this.doc.activeAnimationModeId)??this.doc.animationModes.find(t=>t.isDefault)??this.doc.animationModes[0]}addAnimationMode(e,t){this.pushUndo("Add animation mode"),this.doc.animationModes||(this.doc.animationModes=[]);const r={id:it(),name:e,animations:t??[],isDefault:this.doc.animationModes.length===0};return this.doc.animationModes.push(r),r.isDefault&&(this.doc.activeAnimationModeId=r.id),this.notify(),r}removeAnimationMode(e){var t;this.doc.animationModes&&(this.pushUndo("Remove animation mode"),this.doc.animationModes=this.doc.animationModes.filter(r=>r.id!==e),this.doc.activeAnimationModeId===e&&(this.doc.activeAnimationModeId=(t=this.doc.animationModes[0])==null?void 0:t.id),this.notify())}setActiveAnimationMode(e){var t;(t=this.doc.animationModes)!=null&&t.find(r=>r.id===e)&&(this.doc.activeAnimationModeId=e,this.notify())}addAnimationToMode(e,t){var a;const r=(a=this.doc.animationModes)==null?void 0:a.find(s=>s.id===e);if(!r)return null;this.pushUndo("Add animation to mode");const i={id:it(),...t};return r.animations.push(i),this.notify(),i}removeAnimationFromMode(e,t){var i;const r=(i=this.doc.animationModes)==null?void 0:i.find(a=>a.id===e);r&&(this.pushUndo("Remove animation from mode"),r.animations=r.animations.filter(a=>a.id!==t),this.notify())}setStylePreset(e){this.pushUndo("Set style preset"),this.doc.stylePresetId=e,this.notify()}setStyleOverrides(e){this.pushUndo("Set style overrides"),this.doc.styleOverrides=e,this.notify()}getPlayerConfig(){return this.doc.playerConfig??{mode:"editor",interactionsEnabled:!0,showModeSwitcher:!0,showPlaybackControls:!0,autoPlay:!1,showGhostElements:!0,ghostOpacity:.15,ghostCursorStyle:"pointer"}}setPlayerConfig(e){this.pushUndo("Update player config"),this.doc.playerConfig={...this.getPlayerConfig(),...e},this.notify()}setViewMode(e){const t=this.getPlayerConfig();t.mode=e,this.doc.playerConfig=t,this.notify()}updateAnimation(e,t){this.pushUndo("Update animation");const r=this.doc.animations.find(i=>i.id===e);r&&Object.assign(r,t),this.notify()}loadDocument(e){this.doc=structuredClone(e),this.undoStack=[],this.redoStack=[],this.notify()}}function it(){return`ndd_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Kr(){return[{id:"top",side:"top",offset:.5},{id:"right",side:"right",offset:.5},{id:"bottom",side:"bottom",offset:.5},{id:"left",side:"left",offset:.5}]}function Dt(o,e,t){switch(t.algorithm){case"dagre":return sr(o,e,t);case"grid":return Jr(o,t);case"radial":return Qr(o,e);case"tree":return eo(o,e,t);case"forceDirected":return to(o,e,t);case"manual":default:return{positions:new Map(o.map(r=>[r.id,{...r.position}]))}}}function Zr(o,e){const t=new Map,r=new Set,i=new Set;e.forEach(s=>s.forEach(c=>i.add(c)));const a=s=>{const c=[{id:s,next:0}];for(t.set(s,1);c.length;){const l=c[c.length-1],u=e.get(l.id)??[];if(l.next>=u.length){t.set(l.id,2),c.pop();continue}const d=u[l.next++],b=t.get(d);b===1?r.add(`${l.id}→${d}`):b===void 0&&(t.set(d,1),c.push({id:d,next:0}))}};for(const s of o)!i.has(s)&&!t.has(s)&&a(s);for(const s of o)t.has(s)||a(s);return r}function sr(o,e,t){const r=t.direction??"TB",i=t.nodeSpacing??60,a=t.rankSpacing??100,s=r==="LR"||r==="RL",c=r==="BT"||r==="RL",l=o.map(I=>I.id),u=new Map(o.map(I=>[I.id,I])),d=new Map(l.map(I=>[I,[]]));for(const I of e){const O=d.get(I.sourceNodeId);O&&u.has(I.targetNodeId)&&I.sourceNodeId!==I.targetNodeId&&(O.includes(I.targetNodeId)||O.push(I.targetNodeId))}const b=Zr(l,d),x=new Map(l.map(I=>[I,[]])),g=new Map(l.map(I=>[I,[]]));d.forEach((I,O)=>{for(const L of I){const[Y,S]=b.has(`${O}→${L}`)?[L,O]:[O,L];x.get(Y).includes(S)||(x.get(Y).push(S),g.get(S).push(Y))}});const h=new Map(l.map(I=>[I,0])),v=new Map(l.map(I=>[I,g.get(I).length])),_=l.filter(I=>v.get(I)===0);for(let I=0;I<_.length;I++){const O=_[I];for(const L of x.get(O))h.set(L,Math.max(h.get(L),h.get(O)+1)),v.set(L,v.get(L)-1),v.get(L)===0&&_.push(L)}const w=[];for(const I of l){const O=h.get(I);(w[O]??(w[O]=[])).push(I)}const m=w.filter(Boolean),P=new Map;m.forEach(I=>I.forEach((O,L)=>P.set(O,L)));const j=(I,O)=>O.length===0?P.get(I):O.reduce((L,Y)=>L+P.get(Y),0)/O.length;for(let I=0;I<4;I++){const O=I%2===0,L=O?m.slice(1):m.slice(0,-1).reverse();for(const Y of L){const S=new Map(Y.map(A=>[A,j(A,O?g.get(A):x.get(A))]));Y.sort((A,R)=>S.get(A)-S.get(R)||P.get(A)-P.get(R)),Y.forEach((A,R)=>P.set(A,R))}}const C=I=>s?I.size.width:I.size.height,X=I=>s?I.size.height:I.size.width,V=new Map;let F=0;for(const I of m){const O=I.map(A=>u.get(A)),L=Math.max(...O.map(C));let S=-(O.reduce((A,R)=>A+X(R),0)+(O.length-1)*i)/2;for(const A of O){const R=F+(L-C(A))/2,q=c?-(R+C(A)):R;V.set(A.id,s?{x:q,y:S}:{x:S,y:q}),S+=X(A)+i}F+=L+a}t.centerGraph&&At(V);const H=new Map;return m.forEach((I,O)=>I.forEach(L=>H.set(L,O))),{positions:V,ranks:H}}function Jr(o,e){const t=e.nodeSpacing??80,r=Math.ceil(Math.sqrt(o.length)),i=new Map;return o.forEach((a,s)=>{const c=s%r,l=Math.floor(s/r);i.set(a.id,{x:c*(a.size.width+t),y:l*(a.size.height+t)})}),e.centerGraph&&At(i),{positions:i}}function Qr(o,e){const t=new Map;if(o.length===0)return{positions:t};const r=new Map;o.forEach(l=>r.set(l.id,0)),e.forEach(l=>{r.set(l.sourceNodeId,(r.get(l.sourceNodeId)??0)+1),r.set(l.targetNodeId,(r.get(l.targetNodeId)??0)+1)});const i=[...o].sort((l,u)=>(r.get(u.id)??0)-(r.get(l.id)??0)),a=i[0];t.set(a.id,{x:0,y:0});const s=i.slice(1),c=200+s.length*20;return s.forEach((l,u)=>{const d=2*Math.PI*u/s.length;t.set(l.id,{x:Math.cos(d)*c,y:Math.sin(d)*c})}),{positions:t}}function eo(o,e,t){return sr(o,e,{...t,direction:t.direction??"TB",nodeSpacing:t.nodeSpacing??40,rankSpacing:t.rankSpacing??80})}function to(o,e,t){const r=new Map;if(o.length===0)return{positions:r};const i=400,a=new Map;o.forEach(b=>{a.set(b.id,{x:(Math.random()-.5)*i,y:(Math.random()-.5)*i})});const s=e.map(b=>({source:b.sourceNodeId,target:b.targetNodeId})),c=t.nodeSpacing??150,l=80,u=.95;let d=i/2;for(let b=0;b<l;b++){const x=new Map;o.forEach(g=>x.set(g.id,{fx:0,fy:0}));for(let g=0;g<o.length;g++)for(let h=g+1;h<o.length;h++){const v=a.get(o[g].id),_=a.get(o[h].id),w=_.x-v.x,m=_.y-v.y,P=Math.max(Math.sqrt(w*w+m*m),1),k=c*c/P,j=w/P*k,C=m/P*k;x.get(o[g].id).fx-=j,x.get(o[g].id).fy-=C,x.get(o[h].id).fx+=j,x.get(o[h].id).fy+=C}for(const g of s){const h=a.get(g.source),v=a.get(g.target);if(!h||!v)continue;const _=v.x-h.x,w=v.y-h.y,m=Math.max(Math.sqrt(_*_+w*w),1),P=m*m/c,k=_/m*P,j=w/m*P;x.get(g.source).fx+=k,x.get(g.source).fy+=j,x.get(g.target).fx-=k,x.get(g.target).fy-=j}o.forEach(g=>{const h=x.get(g.id),v=a.get(g.id),_=Math.sqrt(h.fx*h.fx+h.fy*h.fy);if(_>0){const w=Math.min(_,d);v.x+=h.fx/_*w,v.y+=h.fy/_*w}}),d*=u}return o.forEach(b=>{r.set(b.id,{...a.get(b.id)})}),t.centerGraph&&At(r),{positions:r}}function At(o){if(o.size===0)return;let e=1/0,t=1/0,r=-1/0,i=-1/0;o.forEach(c=>{e=Math.min(e,c.x),t=Math.min(t,c.y),r=Math.max(r,c.x),i=Math.max(i,c.y)});const a=(e+r)/2,s=(t+i)/2;o.forEach(c=>{c.x-=a,c.y-=s})}function lr(o){const e=p.useRef(null);e.current||(e.current=new pt(o));const t=e.current,[r,i]=p.useState(0),a=p.useCallback(()=>i(l=>l+1),[]);p.useEffect(()=>t.subscribe(a),[t,a]);const s=t.getDocument(),c=p.useCallback((l,u)=>{const d=Dt(t.getNodes(),t.getEdges(),l);t.moveNodes(d.positions,(u==null?void 0:u.history)??!0)},[t]);return p.useMemo(()=>({document:s,nodes:s.nodes,edges:s.edges,groups:s.groups,animations:s.animations,viewport:s.viewport,addNode:(l,u,d,b)=>t.addNode(l,u,d,b),updateNode:(l,u)=>t.updateNode(l,u),moveNode:(l,u)=>t.moveNode(l,u),resizeNode:(l,u)=>t.resizeNode(l,u),removeNode:l=>t.removeNode(l),addEdge:(l,u,d,b,x)=>t.addEdge(l,u,d,b,x),updateEdge:(l,u)=>t.updateEdge(l,u),removeEdge:l=>t.removeEdge(l),createGroup:(l,u)=>t.createGroup(l,u),removeGroup:l=>t.removeGroup(l),toggleGroupCollapse:l=>t.toggleGroupCollapse(l),toggleNodeCollapse:l=>t.toggleNodeCollapse(l),addAnimation:l=>t.addAnimation(l),updateAnimation:(l,u)=>t.updateAnimation(l,u),removeAnimation:l=>t.removeAnimation(l),animationModes:t.getAnimationModes(),activeAnimationMode:t.getActiveAnimationMode(),addAnimationMode:(l,u)=>t.addAnimationMode(l,u),removeAnimationMode:l=>t.removeAnimationMode(l),setActiveAnimationMode:l=>t.setActiveAnimationMode(l),addAnimationToMode:(l,u)=>t.addAnimationToMode(l,u),removeAnimationFromMode:(l,u)=>t.removeAnimationFromMode(l,u),setStylePreset:l=>t.setStylePreset(l),setStyleOverrides:l=>t.setStyleOverrides(l),stylePresetId:s.stylePresetId,playerConfig:t.getPlayerConfig(),setPlayerConfig:l=>t.setPlayerConfig(l),setViewMode:l=>t.setViewMode(l),viewMode:t.getPlayerConfig().mode,applyLayout:c,setViewport:l=>t.setViewport(l),undo:()=>t.undo(),redo:()=>t.redo(),canUndo:t.canUndo(),canRedo:t.canRedo(),loadDocument:l=>t.loadDocument(l),model:t,revision:r}),[s,t,c,r])}function ye(o){return{primary:"var(--nice-primary, #3b82f6)",primaryLight:"var(--nice-primary-light, #93c5fd)",secondary:"var(--nice-info, #6366f1)",accent:"var(--nice-warning, #f59e0b)",success:"var(--nice-success, #10b981)",warning:"var(--nice-warning, #f59e0b)",error:"var(--nice-danger, #ef4444)",info:"var(--nice-info, #06b6d4)",text:"var(--nice-text, #1e293b)",textMuted:"var(--nice-text-muted, #94a3b8)",border:"var(--nice-border, #e2e8f0)",surface:"var(--nice-bg, #fff)",surfaceAlt:"var(--nice-bg-secondary, #f8fafc)",...o}}function ro(o,e={}){return{backgroundColor:o.surface,borderColor:o.primary,borderWidth:2,borderRadius:8,fontColor:o.text,fontSize:14,fontWeight:"normal",opacity:1,shadow:!0,...e}}function oo(o,e={}){return{strokeColor:o.border,strokeWidth:2,lineType:"bezier",targetArrow:"arrow",...e}}function io(o,e={}){return{backgroundColor:`${o.primaryLight}18`,borderColor:o.primaryLight,borderWidth:1,borderStyle:"dashed",borderRadius:12,labelColor:o.text,padding:16,...e}}function be(o,e,t,r,i,a,s){return{canvas:o,nodeDefaults:ro(e,r),edgeDefaults:oo(e,i),groupDefaults:io(e,a),fontFamily:t,palette:e,effects:s}}const Be="'Inter', system-ui, sans-serif",$t="'Fira Code', 'Cascadia Code', monospace",ao="'Merriweather', 'Georgia', serif",no={id:"default-light",name:"Default Light",category:"corporate",themeSource:"Light",config:be({background:"var(--nice-bg, #fff)",gridColor:"#e2e8f020",gridSize:20,selectionColor:"var(--nice-primary, #3b82f6)"},ye({}),Be)},so=ye({primary:"var(--nice-primary-light, #60a5fa)",primaryLight:"var(--nice-primary, #3b82f6)",secondary:"var(--nice-accent, #818cf8)",accent:"var(--nice-warning-light, #fbbf24)",success:"var(--nice-success-light, #34d399)",warning:"var(--nice-warning-light, #fbbf24)",error:"var(--nice-danger-light, #f87171)",info:"var(--nice-info, #22d3ee)",text:"var(--nice-text-primary, #f8fafc)",textMuted:"var(--nice-text-secondary, #64748b)",border:"var(--nice-border-color, #334155)",surface:"var(--nice-bg-secondary, #1e293b)",surfaceAlt:"var(--nice-bg-primary, #0f172a)"}),lo={id:"default-dark",name:"Default Dark",category:"dark",themeSource:"Dark",config:be({background:"var(--nice-bg-primary, #0f172a)",gridColor:"var(--nice-text, #334155)",gridSize:20,selectionColor:"var(--nice-primary-light, #60a5fa)"},so,Be,{shadow:!1},{strokeColor:"var(--nice-text-secondary, #475569)"},{backgroundColor:"#60a5fa10",borderColor:"#3b82f680"})},co=ye({primary:"var(--nice-primary-dark, #1d4ed8)",primaryLight:"var(--nice-primary-light, #93c5fd)",secondary:"var(--nice-primary, #3b82f6)",text:"var(--nice-primary-dark, #1e3a5f)",textMuted:"#7da0c4",border:"var(--nice-primary-light, #93c5fd)",surface:"var(--nice-primary-bg, #eff6ff)",surfaceAlt:"var(--nice-primary-bg, #dbeafe)"}),uo={id:"corporate-blue",name:"Corporate Blue",category:"corporate",themeSource:"Blue",config:be({background:"#f0f5ff",gridColor:"#93c5fd20",gridSize:20,selectionColor:"var(--nice-primary-dark, #1d4ed8)"},co,Be,{borderWidth:2,borderRadius:6},{strokeColor:"var(--nice-primary-light, #93c5fd)",strokeWidth:2})},fo=ye({primary:"var(--nice-success, #00ff88)",primaryLight:"#00cc6b",secondary:"#ff00ff",accent:"var(--nice-info, #00ffff)",success:"var(--nice-success, #00ff88)",warning:"var(--nice-warning, #ffff00)",error:"#ff3366",info:"var(--nice-info, #00ffff)",text:"var(--nice-text-secondary, #e0e0e0)",textMuted:"var(--nice-text-secondary, #808080)",border:"#00ff8840",surface:"var(--nice-bg, #1a1a2e)",surfaceAlt:"var(--nice-bg, #16213e)"}),ho={id:"neon-glow",name:"Neon Glow",category:"dark",config:be({background:"#0a0a1a",gridColor:"#00ff8810",gridSize:20,selectionColor:"var(--nice-success, #00ff88)"},fo,$t,{borderColor:"var(--nice-success, #00ff88)",borderWidth:2,shadow:!0,glowColor:"var(--nice-success, #00ff88)",glowIntensity:.6},{strokeColor:"#00ff8880",strokeWidth:2},{backgroundColor:"#00ff880a",borderColor:"#00ff8840"},{glowColor:"var(--nice-success, #00ff88)",glowIntensity:.8,particleColor:"var(--nice-info, #00ffff)",liquidColor:"var(--nice-success, #00ff88)",liquidColorEnd:"var(--nice-info, #00ffff)"})},mo=ye({primary:"var(--nice-color-accent-pink, #ff2d95)",primaryLight:"#ff6db6",secondary:"#7928ca",accent:"#00d4ff",success:"#39ff14",warning:"var(--nice-warning, #FFD700)",error:"#ff073a",info:"#00d4ff",text:"var(--nice-text-primary, #fff)",textMuted:"#b0b0b0",border:"#ff2d9540",surface:"#1a0030",surfaceAlt:"#2d004a"}),go={id:"cyberpunk",name:"Cyberpunk",category:"dark",config:be({background:"#0d001a",gridColor:"#ff2d9510",gridSize:24,selectionColor:"var(--nice-color-accent-pink, #ff2d95)"},mo,$t,{borderColor:"var(--nice-color-accent-pink, #ff2d95)",borderWidth:2,glowColor:"var(--nice-color-accent-pink, #ff2d95)",glowIntensity:.7,shadow:!0,gradientColor:"#2d004a",gradientDirection:"vertical"},{strokeColor:"#7928ca80",strokeWidth:3},{},{glowColor:"var(--nice-color-accent-pink, #ff2d95)",glowIntensity:.9,particleColor:"#00d4ff",liquidColor:"var(--nice-color-accent-pink, #ff2d95)",liquidColorEnd:"#7928ca"})},po=ye({primary:"var(--nice-bg, #fff)",primaryLight:"#ffffffaa",secondary:"#4da6ff",accent:"var(--nice-bg, #fff)",text:"var(--nice-text-primary, #fff)",textMuted:"#ffffffaa",border:"#ffffff40",surface:"#1e3d6e",surfaceAlt:"#163050"}),yo={id:"blueprint",name:"Technical Blueprint",category:"technical",config:be({background:"#0a1929",gridColor:"#4da6ff30",gridSize:16,selectionColor:"var(--nice-color-white, #fff)"},po,$t,{backgroundColor:"transparent",borderColor:"#4da6ff",borderWidth:1,borderStyle:"solid",fontColor:"var(--nice-text-primary, #fff)",shadow:!1},{strokeColor:"#4da6ff",strokeWidth:1,strokeDash:[4,4]},{backgroundColor:"transparent",borderColor:"#4da6ff40",borderStyle:"dashed",borderWidth:1})},bo=ye({primary:"var(--nice-accent, #a78bfa)",primaryLight:"var(--nice-accent, #c4b5fd)",secondary:"var(--nice-color-accent-pink, #f472b6)",accent:"var(--nice-warning-light, #fbbf24)",success:"var(--nice-success-light, #6ee7b7)",warning:"var(--nice-warning-bg, #fde68a)",error:"var(--nice-danger-bg, #fca5a5)",info:"var(--nice-primary-light, #93c5fd)",text:"#4a4a68",textMuted:"#9494b0",border:"#e2d8f4",surface:"#faf5ff",surfaceAlt:"#f3e8ff"}),wo={id:"pastel-dream",name:"Pastel Dream",category:"pastel",config:be({background:"#fefcff",gridColor:"#e2d8f420",gridSize:20,selectionColor:"var(--nice-accent, #a78bfa)"},bo,"'Nunito', 'Quicksand', sans-serif",{borderColor:"var(--nice-accent, #c4b5fd)",borderWidth:2,borderRadius:16,shadow:!0},{strokeColor:"var(--nice-accent, #c4b5fd)",strokeWidth:2},{backgroundColor:"#a78bfa10",borderColor:"var(--nice-accent, #c4b5fd)",borderRadius:16})},xo=ye({primary:"var(--nice-success, #059669)",primaryLight:"var(--nice-success-light, #6ee7b7)",secondary:"#065f46",accent:"var(--nice-warning, #f59e0b)",success:"var(--nice-success, #10b981)",warning:"var(--nice-warning, #f59e0b)",error:"var(--nice-danger-dark, #dc2626)",info:"#0d9488",text:"#1a3d2f",textMuted:"#6b8f7f",border:"#a7d7c5",surface:"#ecfdf5",surfaceAlt:"#d1fae5"}),vo={id:"nature-forest",name:"Nature Forest",category:"nature",config:be({background:"#f0fdf4",gridColor:"#a7d7c520",gridSize:20,selectionColor:"var(--nice-success, #059669)"},xo,Be,{borderColor:"var(--nice-success, #059669)",borderRadius:12},{strokeColor:"var(--nice-success-light, #6ee7b7)"},{backgroundColor:"#05966910",borderColor:"var(--nice-success-light, #6ee7b7)"},{liquidColor:"var(--nice-success, #059669)",liquidColorEnd:"var(--nice-success-light, #6ee7b7)",particleColor:"var(--nice-warning, #f59e0b)"})},ko=ye({primary:"var(--nice-success, #00ff00)",primaryLight:"#00cc00",secondary:"var(--nice-success, #00ff00)",accent:"var(--nice-warning, #ffff00)",text:"var(--nice-success, #00ff00)",textMuted:"#00990088",border:"#00ff0040",surface:"#001100",surfaceAlt:"#002200"}),Co={id:"retro-terminal",name:"Retro Terminal",category:"retro",config:be({background:"#000800",gridColor:"#00ff0010",gridSize:16,selectionColor:"var(--nice-success, #00ff00)"},ko,"'Courier New', 'Fira Code', monospace",{backgroundColor:"#001100",borderColor:"#00ff0060",borderWidth:1,fontColor:"var(--nice-success, #00ff00)",shadow:!1,glowColor:"var(--nice-success, #00ff00)",glowIntensity:.4},{strokeColor:"#00ff0060",strokeWidth:1},{},{glowColor:"var(--nice-success, #00ff00)",glowIntensity:.6,particleColor:"var(--nice-success, #00ff00)",liquidColor:"var(--nice-success, #00ff00)"})},So=ye({primary:"#0000ff",primaryLight:"#6666ff",secondary:"#ff00ff",accent:"var(--nice-warning, #ffff00)",text:"var(--nice-text, #000000)",textMuted:"var(--nice-text-secondary, #555555)",border:"var(--nice-border-color, #000000)",surface:"var(--nice-bg, #fff)",surfaceAlt:"var(--nice-border, #eeeeee)"}),No={id:"high-contrast",name:"High Contrast",category:"accessibility",themeSource:"High Contrast",config:be({background:"var(--nice-bg, #fff)",gridColor:"#00000020",gridSize:20,selectionColor:"#0000ff"},So,"Arial, sans-serif",{borderColor:"var(--nice-border-color, #000000)",borderWidth:3,fontColor:"var(--nice-text, #000000)",fontWeight:"bold"},{strokeColor:"var(--nice-text, #000000)",strokeWidth:3},{borderColor:"var(--nice-border-color, #000000)",borderWidth:2})},_o=ye({primary:"var(--nice-primary-hover, #1976d2)",primaryLight:"#64b5f6",secondary:"var(--nice-accent, #9c27b0)",accent:"var(--nice-warning, #ff9800)",success:"var(--nice-success, #4caf50)",warning:"var(--nice-warning, #ff9800)",error:"var(--nice-danger, #f44336)",info:"#03a9f4",text:"#212121",textMuted:"#757575",border:"var(--nice-border, #e0e0e0)",surface:"var(--nice-bg-secondary, #fafafa)",surfaceAlt:"var(--nice-bg-secondary, #f5f5f5)"}),Mo={id:"material-design",name:"Material Design",category:"theme-based",themeSource:"Material",config:be({background:"var(--nice-bg-secondary, #fafafa)",gridColor:"#e0e0e020",gridSize:20,selectionColor:"var(--nice-primary-hover, #1976d2)"},_o,"'Roboto', 'Noto Sans', sans-serif",{borderRadius:4,borderWidth:0,shadow:!0},{strokeColor:"#bdbdbd",strokeWidth:2},{borderRadius:8})},zo=ye({primary:"#0078d4",primaryLight:"#6cb8f7",secondary:"#8661c5",accent:"#ffaa44",success:"#107c10",warning:"#ffaa44",error:"#d13438",info:"#0078d4",text:"#323130",textMuted:"#a19f9d",border:"#edebe9",surface:"var(--nice-bg, #fff)",surfaceAlt:"#faf9f8"}),Io={id:"fluent-ui",name:"Fluent UI",category:"theme-based",themeSource:"Fluent",config:be({background:"#faf9f8",gridColor:"#edebe920",gridSize:20,selectionColor:"#0078d4"},zo,"'Segoe UI', system-ui, sans-serif",{borderRadius:4,borderWidth:1,shadow:!0},{strokeColor:"#c8c6c4",strokeWidth:1})},jo=ye({primary:"var(--nice-warning-dark, #e65100)",primaryLight:"#ff9e80",secondary:"#ff6f00",accent:"#ffd600",success:"#43a047",warning:"#ff6f00",error:"var(--nice-danger-dark, #c62828)",info:"#0277bd",text:"#3e2723",textMuted:"#8d6e63",border:"#ffccbc",surface:"#fff8e1",surfaceAlt:"var(--nice-warning-bg, #fff3e0)"}),Do={id:"sunset-warm",name:"Sunset Warm",category:"creative",config:be({background:"#fffde7",gridColor:"#ffccbc20",gridSize:20,selectionColor:"var(--nice-warning-dark, #e65100)"},jo,Be,{borderColor:"#ff9e80",gradientColor:"var(--nice-warning-bg, #fff3e0)",gradientDirection:"vertical"},{strokeColor:"#ff9e80"},{},{liquidColor:"var(--nice-warning-dark, #e65100)",liquidColorEnd:"#ffd600",particleColor:"#ffd600"})},Ao=ye({primary:"#006064",primaryLight:"#4dd0e1",secondary:"#00838f",accent:"#ffd54f",success:"#00e676",warning:"#ffd54f",error:"#ff5252",info:"#40c4ff",text:"#004d40",textMuted:"#80cbc4",border:"#b2ebf2",surface:"#e0f7fa",surfaceAlt:"#b2ebf2"}),$o={id:"ocean-deep",name:"Ocean Deep",category:"nature",config:be({background:"#e0f7fa",gridColor:"#b2ebf220",gridSize:20,selectionColor:"#006064"},Ao,Be,{borderColor:"#00838f",borderRadius:12},{strokeColor:"#4dd0e1"},{},{liquidColor:"#006064",liquidColorEnd:"#4dd0e1",particleColor:"#ffd54f"})},To=ye({primary:"#5d4037",primaryLight:"#a1887f",secondary:"#795548",accent:"#c6a263",text:"#3e2723",textMuted:"#8d6e63",border:"#bcaaa4",surface:"#fdf6f0",surfaceAlt:"#efebe9"}),Po={id:"elegant-serif",name:"Elegant Serif",category:"creative",config:be({background:"#fdf6f0",gridColor:"#bcaaa420",gridSize:24,selectionColor:"#5d4037"},To,ao,{borderColor:"#a1887f",borderWidth:1,borderRadius:2,fontStyle:"normal"},{strokeColor:"#bcaaa4",strokeWidth:1},{borderRadius:4})},Eo=ye({primary:"var(--nice-text, #333333)",primaryLight:"var(--nice-text-secondary, #666666)",secondary:"var(--nice-text-secondary, #555555)",accent:"#ff6600",text:"var(--nice-text, #333333)",textMuted:"var(--nice-text-muted, #999999)",border:"var(--nice-border, #cccccc)",surface:"var(--nice-bg, #fff)",surfaceAlt:"var(--nice-bg-secondary, #f5f5f5)"}),Ro={id:"wireframe",name:"Wireframe",category:"technical",config:be({background:"var(--nice-bg, #fff)",gridColor:"#00000008",gridSize:16,selectionColor:"#ff6600"},Eo,"'Balsamiq Sans', 'Comic Sans MS', cursive",{backgroundColor:"transparent",borderColor:"var(--nice-border-color, #999999)",borderWidth:1,borderStyle:"solid",shadow:!1,borderRadius:4},{strokeColor:"var(--nice-text-muted, #999999)",strokeWidth:1},{backgroundColor:"transparent",borderStyle:"dashed",borderWidth:1,borderColor:"var(--nice-border, #cccccc)"})},Oo=ye({primary:"#00bfa5",primaryLight:"#64ffda",secondary:"#00897b",accent:"#ff6e40",success:"#00e676",warning:"#ffc400",error:"#ff1744",info:"#00e5ff",text:"#1b5e20",textMuted:"#81c784",border:"#a7ffeb",surface:"#e0f2f1",surfaceAlt:"#b2dfdb"}),Fo={id:"mint-fresh",name:"Mint Fresh",category:"nature",config:be({background:"var(--nice-success-bg, #e8f5e9)",gridColor:"#a7ffeb20",gridSize:20,selectionColor:"#00bfa5"},Oo,Be,{borderColor:"#00bfa5",borderRadius:20,borderWidth:2,gradientColor:"#b2dfdb",gradientDirection:"radial"},{strokeColor:"#64ffda",strokeWidth:2},{borderRadius:16},{liquidColor:"#00bfa5",liquidColorEnd:"#64ffda",particleColor:"#ff6e40"})},Lo=ye({primary:"#424242",primaryLight:"var(--nice-text-secondary, #9e9e9e)",secondary:"#616161",accent:"var(--nice-danger, #ff5722)",text:"#212121",textMuted:"#bdbdbd",border:"var(--nice-border, #e0e0e0)",surface:"var(--nice-bg-secondary, #fafafa)",surfaceAlt:"var(--nice-bg-secondary, #f5f5f5)"}),Wo={id:"monochrome",name:"Monochrome",category:"corporate",config:be({background:"var(--nice-bg-secondary, #fafafa)",gridColor:"#e0e0e020",gridSize:20,selectionColor:"#424242"},Lo,Be,{borderColor:"var(--nice-border-color, #9e9e9e)",borderWidth:1,shadow:!0,borderRadius:4},{strokeColor:"var(--nice-text-secondary, #9e9e9e)",strokeWidth:1.5})},Bo=ye({primary:"var(--nice-color-accent-pink, #e91e63)",primaryLight:"#f48fb1",secondary:"var(--nice-accent, #9c27b0)",accent:"var(--nice-warning, #ffeb3b)",success:"var(--nice-success, #4caf50)",warning:"var(--nice-warning, #ff9800)",error:"var(--nice-danger, #f44336)",info:"#00bcd4",text:"#4a148c",textMuted:"#ce93d8",border:"#f8bbd0",surface:"#fce4ec",surfaceAlt:"#f3e5f5"}),Vo={id:"candy-pop",name:"Candy Pop",category:"creative",config:be({background:"#fff0f5",gridColor:"#f8bbd020",gridSize:20,selectionColor:"var(--nice-color-accent-pink, #e91e63)"},Bo,"'Quicksand', 'Nunito', sans-serif",{borderColor:"var(--nice-color-accent-pink, #e91e63)",borderRadius:24,borderWidth:3,gradientColor:"#f3e5f5",gradientDirection:"diagonal"},{strokeColor:"#f48fb1",strokeWidth:3},{borderRadius:20,borderColor:"#f48fb1"},{glowColor:"var(--nice-color-accent-pink, #e91e63)",glowIntensity:.5,particleColor:"var(--nice-warning, #ffeb3b)"})},qo=ye({primary:"var(--nice-text-secondary, #475569)",primaryLight:"var(--nice-text-muted, #94a3b8)",secondary:"var(--nice-text, #334155)",accent:"var(--nice-warning, #f59e0b)",text:"var(--nice-text, #0f172a)",textMuted:"var(--nice-text-muted, #94a3b8)",border:"var(--nice-border, #cbd5e1)",surface:"var(--nice-bg-secondary, #f8fafc)",surfaceAlt:"var(--nice-bg-secondary, #f1f5f9)"}),Go={id:"slate-professional",name:"Slate Professional",category:"corporate",config:be({background:"var(--nice-bg-secondary, #f8fafc)",gridColor:"#cbd5e120",gridSize:20,selectionColor:"var(--nice-text-secondary, #475569)"},qo,"'Inter', system-ui, sans-serif",{borderColor:"var(--nice-border, #cbd5e1)",borderWidth:1,borderRadius:6,shadow:!0},{strokeColor:"var(--nice-text-muted, #94a3b8)",strokeWidth:1.5},{borderColor:"var(--nice-border, #cbd5e1)",borderRadius:8})},Yo=ye({primary:"var(--nice-accent, #7c3aed)",primaryLight:"var(--nice-accent, #a78bfa)",secondary:"var(--nice-info, #06b6d4)",accent:"var(--nice-color-accent-pink, #f472b6)",success:"var(--nice-success-light, #34d399)",warning:"var(--nice-warning-light, #fbbf24)",error:"var(--nice-danger-light, #f87171)",info:"var(--nice-info, #22d3ee)",text:"var(--nice-text-secondary, #e2e8f0)",textMuted:"var(--nice-text-muted, #94a3b8)",border:"#7c3aed40",surface:"#1e1b4b",surfaceAlt:"#312e81"}),Ho={id:"aurora-borealis",name:"Aurora Borealis",category:"dark",config:be({background:"#0f0b2e",gridColor:"#7c3aed15",gridSize:24,selectionColor:"var(--nice-accent, #a78bfa)"},Yo,Be,{borderColor:"var(--nice-accent, #7c3aed)",borderWidth:2,gradientColor:"#312e81",gradientDirection:"vertical",glowColor:"var(--nice-accent, #a78bfa)",glowIntensity:.5},{strokeColor:"#7c3aed80",strokeWidth:2},{},{glowColor:"var(--nice-accent, #a78bfa)",glowIntensity:.7,particleColor:"var(--nice-info, #06b6d4)",liquidColor:"var(--nice-accent, #7c3aed)",liquidColorEnd:"var(--nice-info, #06b6d4)"})},Uo=ye({primary:"#2c3e50",primaryLight:"#7f8c8d",secondary:"#2980b9",accent:"#e74c3c",text:"#2c3e50",textMuted:"#95a5a6",border:"#bdc3c7",surface:"#fdfaf6",surfaceAlt:"#f5f0e8"}),Xo={id:"sketch-hand-drawn",name:"Sketch / Hand-drawn",category:"creative",config:be({background:"#fdfaf6",gridColor:"#bdc3c720",gridSize:20,selectionColor:"#2980b9"},Uo,"'Caveat', 'Patrick Hand', cursive",{backgroundColor:"#fdfaf6",borderColor:"#2c3e50",borderWidth:2,borderRadius:2,shadow:!1},{strokeColor:"#2c3e50",strokeWidth:2},{borderStyle:"dashed",borderWidth:2})},Ko=ye({primary:"var(--nice-primary, #2196f3)",primaryLight:"#64b5f6",secondary:"var(--nice-warning, #ff9800)",accent:"var(--nice-danger, #ff5722)",success:"var(--nice-success, #4caf50)",warning:"var(--nice-warning, #ffc107)",error:"var(--nice-danger, #f44336)",info:"#03a9f4",text:"var(--nice-text-primary, #fff)",textMuted:"#b0bec5",border:"#ffffff40",surface:"var(--nice-primary, #2196f3)",surfaceAlt:"var(--nice-primary-dark, #1565c0)"}),Zo={id:"infographic-bold",name:"Infographic Bold",category:"creative",config:be({background:"#eceff1",gridColor:"#b0bec520",gridSize:24,selectionColor:"var(--nice-danger, #ff5722)"},Ko,"'Montserrat', 'Roboto', sans-serif",{backgroundColor:"var(--nice-primary, #2196f3)",borderColor:"var(--nice-primary-dark, #1565c0)",borderWidth:0,fontColor:"var(--nice-text-on-primary, #fff)",fontWeight:"bold",borderRadius:12,shadow:!0},{strokeColor:"#90a4ae",strokeWidth:3},{backgroundColor:"#2196f320",borderWidth:2,borderRadius:16})},Jo=ye({primary:"#9333ea",primaryLight:"var(--nice-accent, #c084fc)",secondary:"var(--nice-info, #6366f1)",accent:"var(--nice-warning, #f59e0b)",text:"var(--nice-text-primary, #f1f5f9)",textMuted:"var(--nice-accent, #a78bfa)",border:"#7c3aed40",surface:"#1c1033",surfaceAlt:"#2d1b69"}),Qo={id:"midnight-purple",name:"Midnight Purple",category:"dark",config:be({background:"#0f0720",gridColor:"#9333ea10",gridSize:20,selectionColor:"var(--nice-accent, #c084fc)"},Jo,Be,{borderColor:"#9333ea",borderWidth:2,gradientColor:"#2d1b69",gradientDirection:"vertical",shadow:!1},{strokeColor:"#9333ea80",strokeWidth:2},{},{glowColor:"#9333ea",glowIntensity:.6,liquidColor:"#9333ea",liquidColorEnd:"var(--nice-accent, #c084fc)"})},yt=[no,lo,uo,Mo,Io,ho,go,yo,Co,wo,Do,$o,Po,vo,Ro,No,Fo,Wo,Vo,Go,Ho,Xo,Zo,Qo],ei=[{id:"fill-solid",name:"Solid Fill",category:"fill",style:{opacity:1}},{id:"fill-gradient-v",name:"Vertical Gradient",category:"fill",style:{gradientColor:"var(--nice-text-secondary, #e2e8f0)",gradientDirection:"vertical"}},{id:"fill-gradient-h",name:"Horizontal Gradient",category:"fill",style:{gradientColor:"var(--nice-text-secondary, #e2e8f0)",gradientDirection:"horizontal"}},{id:"fill-gradient-d",name:"Diagonal Gradient",category:"fill",style:{gradientColor:"var(--nice-text-secondary, #e2e8f0)",gradientDirection:"diagonal"}},{id:"fill-gradient-r",name:"Radial Gradient",category:"fill",style:{gradientColor:"var(--nice-text-secondary, #e2e8f0)",gradientDirection:"radial"}},{id:"fill-transparent",name:"Transparent",category:"fill",style:{backgroundColor:"transparent",opacity:1}},{id:"fill-semi",name:"Semi-transparent",category:"fill",style:{opacity:.6}},{id:"fill-glass",name:"Glassmorphism",category:"fill",style:{opacity:.7,gradientColor:"#ffffff40",gradientDirection:"vertical",borderWidth:1,borderColor:"#ffffff60"}},{id:"border-none",name:"No Border",category:"border",style:{borderWidth:0}},{id:"border-thin",name:"Thin Border",category:"border",style:{borderWidth:1}},{id:"border-medium",name:"Medium Border",category:"border",style:{borderWidth:2}},{id:"border-thick",name:"Thick Border",category:"border",style:{borderWidth:3}},{id:"border-heavy",name:"Heavy Border",category:"border",style:{borderWidth:4}},{id:"border-solid",name:"Solid",category:"border",style:{borderStyle:"solid"}},{id:"border-dashed",name:"Dashed",category:"border",style:{borderStyle:"dashed"}},{id:"border-dotted",name:"Dotted",category:"border",style:{borderStyle:"dotted"}},{id:"border-rounded-sm",name:"Rounded Small",category:"border",style:{borderRadius:4}},{id:"border-rounded-md",name:"Rounded Medium",category:"border",style:{borderRadius:8}},{id:"border-rounded-lg",name:"Rounded Large",category:"border",style:{borderRadius:16}},{id:"border-rounded-xl",name:"Rounded XL",category:"border",style:{borderRadius:24}},{id:"border-pill",name:"Pill / Capsule",category:"border",style:{borderRadius:999}},{id:"border-sharp",name:"Sharp Corners",category:"border",style:{borderRadius:0}},{id:"effect-shadow",name:"Drop Shadow",category:"effect",style:{shadow:!0}},{id:"effect-no-shadow",name:"No Shadow",category:"effect",style:{shadow:!1}},{id:"effect-glow-blue",name:"Blue Glow",category:"effect",style:{glowColor:"var(--nice-primary, #3b82f6)",glowIntensity:.6}},{id:"effect-glow-green",name:"Green Glow",category:"effect",style:{glowColor:"var(--nice-success, #10b981)",glowIntensity:.6}},{id:"effect-glow-red",name:"Red Glow",category:"effect",style:{glowColor:"var(--nice-danger, #ef4444)",glowIntensity:.6}},{id:"effect-glow-purple",name:"Purple Glow",category:"effect",style:{glowColor:"var(--nice-accent, #8b5cf6)",glowIntensity:.6}},{id:"effect-glow-gold",name:"Gold Glow",category:"effect",style:{glowColor:"var(--nice-warning, #f59e0b)",glowIntensity:.6}},{id:"effect-glow-neon",name:"Neon Glow",category:"effect",style:{glowColor:"var(--nice-success, #00ff88)",glowIntensity:.8}}],ti=[{id:"line-straight",name:"Straight",category:"type",style:{lineType:"straight"}},{id:"line-bezier",name:"Bezier Curve",category:"type",style:{lineType:"bezier"}},{id:"line-orthogonal",name:"Orthogonal",category:"type",style:{lineType:"orthogonal"}},{id:"line-step",name:"Step",category:"type",style:{lineType:"step"}},{id:"stroke-thin",name:"Thin Stroke",category:"stroke",style:{strokeWidth:1}},{id:"stroke-medium",name:"Medium Stroke",category:"stroke",style:{strokeWidth:2}},{id:"stroke-thick",name:"Thick Stroke",category:"stroke",style:{strokeWidth:3}},{id:"stroke-heavy",name:"Heavy Stroke",category:"stroke",style:{strokeWidth:4}},{id:"stroke-solid",name:"Solid",category:"stroke",style:{strokeDash:[]}},{id:"stroke-dashed",name:"Dashed",category:"stroke",style:{strokeDash:[8,4]}},{id:"stroke-dotted",name:"Dotted",category:"stroke",style:{strokeDash:[2,4]}},{id:"stroke-dash-dot",name:"Dash-Dot",category:"stroke",style:{strokeDash:[8,4,2,4]}},{id:"stroke-long-dash",name:"Long Dash",category:"stroke",style:{strokeDash:[16,8]}},{id:"arrow-target-none",name:"No Target Arrow",category:"arrow",style:{targetArrow:"none"}},{id:"arrow-target-arrow",name:"Arrow →",category:"arrow",style:{targetArrow:"arrow"}},{id:"arrow-target-open",name:"Open Arrow ▷",category:"arrow",style:{targetArrow:"openArrow"}},{id:"arrow-target-diamond",name:"Diamond ◇",category:"arrow",style:{targetArrow:"diamond"}},{id:"arrow-target-circle",name:"Circle ○",category:"arrow",style:{targetArrow:"circle"}},{id:"arrow-source-none",name:"No Source Arrow",category:"arrow",style:{sourceArrow:"none"}},{id:"arrow-source-arrow",name:"← Source Arrow",category:"arrow",style:{sourceArrow:"arrow"}},{id:"arrow-source-open",name:"◁ Open Source",category:"arrow",style:{sourceArrow:"openArrow"}},{id:"arrow-source-diamond",name:"◇ Diamond Source",category:"arrow",style:{sourceArrow:"diamond"}},{id:"arrow-source-circle",name:"○ Circle Source",category:"arrow",style:{sourceArrow:"circle"}},{id:"arrow-bidirectional",name:"↔ Bidirectional",category:"arrow",style:{sourceArrow:"arrow",targetArrow:"arrow"}},{id:"arrow-association",name:" Association (none)",category:"arrow",style:{sourceArrow:"none",targetArrow:"none"}},{id:"arrow-composition",name:"◆→ Composition",category:"arrow",style:{sourceArrow:"diamond",targetArrow:"arrow"}},{id:"arrow-aggregation",name:"◇→ Aggregation",category:"arrow",style:{sourceArrow:"diamond",targetArrow:"arrow"}},{id:"arrow-dependency",name:"- - → Dependency",category:"arrow",style:{targetArrow:"openArrow",strokeDash:[8,4]}},{id:"arrow-inheritance",name:"△→ Inheritance",category:"arrow",style:{targetArrow:"openArrow"}},{id:"effect-animated",name:"Animated Flow",category:"effect",style:{animated:!0,flowSpeed:1}},{id:"effect-animated-fast",name:"Fast Animated",category:"effect",style:{animated:!0,flowSpeed:2}},{id:"effect-animated-slow",name:"Slow Animated",category:"effect",style:{animated:!0,flowSpeed:.5}},{id:"effect-liquid",name:"Liquid Flow",category:"effect",style:{liquidFlow:{active:!0,color:"var(--nice-primary, #3b82f6)",speed:1}}},{id:"effect-liquid-neon",name:"Neon Liquid",category:"effect",style:{liquidFlow:{active:!0,color:"var(--nice-success, #00ff88)",colorEnd:"var(--nice-info, #00ffff)",speed:1.5,particleDensity:5}}}],cr=[{id:"tp-fade-in",name:"Fade In",effect:"fadeIn",durationMs:400,easing:"easeOut",description:"Smoothly fades in"},{id:"tp-fade-out",name:"Fade Out",effect:"fadeOut",durationMs:400,easing:"easeIn",description:"Smoothly fades out"},{id:"tp-slide-left",name:"Slide Left",effect:"slideInLeft",durationMs:500,easing:"easeOut",description:"Slides in from left"},{id:"tp-slide-right",name:"Slide Right",effect:"slideInRight",durationMs:500,easing:"easeOut",description:"Slides in from right"},{id:"tp-slide-top",name:"Slide Down",effect:"slideInTop",durationMs:500,easing:"easeOut",description:"Slides in from top"},{id:"tp-slide-bottom",name:"Slide Up",effect:"slideInBottom",durationMs:500,easing:"easeOut",description:"Slides in from bottom"},{id:"tp-zoom-in",name:"Zoom In",effect:"zoomIn",durationMs:400,easing:"spring",description:"Zooms in with spring"},{id:"tp-zoom-out",name:"Zoom Out",effect:"zoomOut",durationMs:400,easing:"easeIn",description:"Zooms out"},{id:"tp-bounce",name:"Bounce In",effect:"bounce",durationMs:800,easing:"bounce",description:"Bounces into place"},{id:"tp-pulse",name:"Pulse",effect:"pulse",durationMs:1e3,easing:"easeInOut",description:"Pulsing scale effect"},{id:"tp-shake",name:"Shake",effect:"shake",durationMs:600,easing:"linear",description:"Shakes horizontally"},{id:"tp-glow",name:"Glow",effect:"glow",durationMs:1200,easing:"easeInOut",description:"Glowing highlight"},{id:"tp-highlight",name:"Highlight",effect:"highlight",durationMs:800,easing:"easeInOut",description:"Golden highlight flash"},{id:"tp-ripple",name:"Ripple",effect:"ripple",durationMs:1e3,easing:"easeOut",description:"Ripple wave effect"},{id:"tp-expand",name:"Expand",effect:"expand",durationMs:500,easing:"spring",description:"Expand from collapsed"},{id:"tp-collapse",name:"Collapse",effect:"collapse",durationMs:400,easing:"easeIn",description:"Collapse to hidden"},{id:"tp-color-shift",name:"Color Shift",effect:"colorShift",durationMs:2e3,easing:"linear",description:"Rainbow color cycle"},{id:"tp-liquid-fill",name:"Liquid Fill",effect:"liquidFill",durationMs:1500,easing:"easeInOut",description:"Liquid filling effect"},{id:"tp-draw-path",name:"Draw Path",effect:"drawPath",durationMs:1200,easing:"easeOut",description:"Edge draws itself"},{id:"tp-particle-trail",name:"Particle Trail",effect:"particleTrail",durationMs:2e3,easing:"linear",description:"Particles along edge"},{id:"tp-typewriter",name:"Typewriter",effect:"typewriter",durationMs:1500,easing:"linear",description:"Text appears letter by letter"}];function ri(o){return yt.find(e=>e.id===o)}function oi(o){return yt.filter(e=>e.category===o)}function ii(o){return{canvasBackground:o.canvas.background,gridColor:o.canvas.gridColor,gridSize:o.canvas.gridSize,selectionColor:o.canvas.selectionColor,fontFamily:o.fontFamily,nodeDefaults:o.nodeDefaults,edgeDefaults:o.edgeDefaults,groupDefaults:o.groupDefaults,palette:o.palette,effects:o.effects}}function ai(o,e,t,r,i,a){const s=ye({primary:t.primary,primaryLight:t.primaryHover,secondary:t.info,accent:t.warning,success:t.success,warning:t.warning,error:t.error,info:t.info,text:i.primary,textMuted:i.muted,border:a.color,surface:r.primary,surfaceAlt:r.secondary}),c=ni(r.primary);return{id:o,name:`${e} Theme`,category:"theme-based",themeSource:e,config:be({background:r.primary,gridColor:c?`${a.color}40`:`${a.color}20`,gridSize:20,selectionColor:t.primary},s,Be,{shadow:!c,borderWidth:c?1:2},{strokeColor:c?`${a.color}80`:a.color})}}function ni(o){const e=o.replace("#","");if(e.length<6)return!1;const t=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),i=parseInt(e.slice(4,6),16);return(t*299+r*587+i*114)/1e3<128}const si=["fadeIn","fadeOut","slideInLeft","slideInRight","slideInTop","slideInBottom","zoomIn","zoomOut","pulse","shake","highlight","flowPulse","bounce","glow","colorShift","liquidFill","expand","collapse","ripple","typewriter","morphShape","drawPath","particleTrail"],li=["linear","easeIn","easeOut","easeInOut","spring","bounce"],bt=({animations:o,onAdd:e,onRemove:t,onUpdate:r,onPlay:i,onStop:a,isPlaying:s=!1,availableTargets:c=[],className:l})=>{const{t:u}=Re(),[d,b]=p.useState(!1),[x,g]=p.useState(null),h=p.useCallback(()=>{if(!e||c.length===0)return;const w=c[0];e({name:`Animation ${o.length+1}`,targetId:w.id,targetType:w.type,effect:"fadeIn",startMs:o.length*500,durationMs:600,easing:"easeOut"})},[e,o.length,c]),v=p.useCallback(w=>{if(!e||c.length===0)return;const m=c[0];e({name:w.name,targetId:m.id,targetType:m.type,effect:w.effect,startMs:o.length*500,durationMs:w.durationMs,easing:w.easing}),b(!1)},[e,o.length,c]),_=Math.max(2e3,...o.map(w=>w.startMs+w.durationMs+(w.delayMs??0)));return n.jsxs("div",{className:`nice-diagram-timeline ${l??""}`,children:[n.jsxs("div",{className:"nice-diagram-timeline__header",children:[n.jsx("h4",{className:"nice-diagram-timeline__title",children:u("animation.timeline")}),n.jsxs("div",{className:"nice-diagram-timeline__controls",children:[s?n.jsxs(y.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:a,children:[n.jsx(y.NiceIcon,{name:"stop",size:14})," ",u("animation.stop")]}):n.jsxs(y.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:i,children:[n.jsx(y.NiceIcon,{name:"play",size:14})," ",u("animation.play")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:h,disabled:c.length===0,children:[n.jsx(y.NiceIcon,{name:"plus",size:14})," ",u("animation.add")]}),n.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[n.jsxs(y.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:()=>b(w=>!w),disabled:c.length===0,title:u("animation.addFromPreset","Add from preset"),children:[n.jsx(y.NiceIcon,{name:"video",size:14})," ",u("animation.presets","Presets")]}),d&&n.jsx("div",{style:{position:"absolute",bottom:"100%",left:0,background:"var(--nice-bg, #fff)",border:"1px solid var(--nice-border, #ddd)",borderRadius:6,boxShadow:"0 4px 12px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",maxHeight:280,overflowY:"auto",width:200,zIndex:100},children:cr.map(w=>n.jsx(y.NiceButton,{variant:"ghost",size:"sm",onClick:()=>v(w),style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",fontSize:12,borderBottom:"1px solid var(--nice-bg-secondary, #f0f0f0)"},title:`${w.effect} — ${w.durationMs}ms ${w.easing}`,children:w.name},w.id))})]})]})]}),n.jsxs("div",{className:"nice-diagram-timeline__tracks",children:[o.length===0&&n.jsx("p",{className:"nice-diagram-timeline__empty",children:u("animation.noAnimations")}),o.map(w=>{const m=w.startMs/_*100,P=w.durationMs/_*100,k=x===w.id;return n.jsxs("div",{className:"nice-diagram-timeline__track",children:[n.jsxs("div",{className:"nice-diagram-timeline__track-label",children:[n.jsx("span",{role:"button",tabIndex:0,onKeyDown:y.clickOnActivationKey,className:"nice-diagram-timeline__track-name",onClick:()=>g(k?null:w.id),style:{cursor:"pointer"},title:u("animation.clickToEdit","Click to edit"),children:w.name}),n.jsx("span",{className:"nice-diagram-timeline__track-effect",children:w.effect}),n.jsx(y.NiceButton,{className:"nice-diagram-timeline__track-remove",variant:"ghost",size:"sm",onClick:()=>t==null?void 0:t(w.id),title:u("toolbar.delete"),children:n.jsx(y.NiceIcon,{name:"close",size:14})})]}),k&&n.jsxs("div",{className:"nice-diagram-timeline__track-editor",style:{display:"flex",gap:4,padding:"4px 0",flexWrap:"wrap",fontSize:11},children:[n.jsx(y.NiceSelect,{value:w.effect,onChange:j=>r==null?void 0:r(w.id,{effect:j}),options:si.map(j=>({value:j,label:j})),style:{fontSize:11,padding:"1px 4px"}}),n.jsx(y.NiceSelect,{value:w.easing,onChange:j=>r==null?void 0:r(w.id,{easing:j}),options:li.map(j=>({value:j,label:j})),style:{fontSize:11,padding:"1px 4px"}}),n.jsx(y.NiceSelect,{value:w.targetId,onChange:j=>{const C=c.find(X=>X.id===j);C&&(r==null||r(w.id,{targetId:C.id,targetType:C.type}))},options:c.map(j=>({value:j.id,label:j.label})),style:{fontSize:11,padding:"1px 4px",maxWidth:100}}),n.jsx(y.NiceNumberInput,{value:w.startMs,min:0,step:100,onChange:j=>r==null?void 0:r(w.id,{startMs:j??0}),style:{width:60,fontSize:11},title:u("animation.startMs","Start (ms)")}),n.jsx(y.NiceNumberInput,{value:w.durationMs,min:50,step:50,onChange:j=>r==null?void 0:r(w.id,{durationMs:j??50}),style:{width:60,fontSize:11},title:u("animation.durationMs","Duration (ms)")})]}),n.jsx("div",{className:"nice-diagram-timeline__track-bar",children:n.jsx("div",{className:"nice-diagram-timeline__track-segment",style:{left:`${m}%`,width:`${P}%`},title:`${w.effect} ${w.startMs}ms → ${w.startMs+w.durationMs}ms (${w.easing})`})})]},w.id)})]}),n.jsx("div",{className:"nice-diagram-timeline__ruler",children:Array.from({length:5}).map((w,m)=>{const P=Math.round(_/4*m);return n.jsxs("span",{className:"nice-diagram-timeline__ruler-mark",style:{left:`${m/4*100}%`},children:[P,"ms"]},m)})})]})};process.env.NODE_ENV!=="production"&&(bt.displayName="AnimationTimeline");function Tt(o){let e=1/0,t=1/0,r=-1/0,i=-1/0;for(const a of o)a.hidden||(e=Math.min(e,a.position.x),t=Math.min(t,a.position.y),r=Math.max(r,a.position.x+a.size.width),i=Math.max(i,a.position.y+a.size.height));return Number.isFinite(e)?{x:e,y:t,width:r-e,height:i-t}:null}function Pt(o,e,t={}){const{padding:r=40,maxZoom:i=1.25,minZoom:a=.1}=t;if(!o||e.width<=0||e.height<=0)return{x:0,y:0,zoom:1};const s=(e.width-2*r)/Math.max(o.width,1),c=(e.height-2*r)/Math.max(o.height,1),l=Math.min(i,Math.max(a,Math.min(s,c)));return{x:(e.width-o.width*l)/2-o.x*l,y:(e.height-o.height*l)/2-o.y*l,zoom:l}}const ci=/^[a-z][a-z0-9-]*$/,di=.1,ui=5,ht=8,Nt=[{cursor:"nw-resize",dx:0,dy:0,resizeX:-1,resizeY:-1},{cursor:"n-resize",dx:.5,dy:0,resizeX:0,resizeY:-1},{cursor:"ne-resize",dx:1,dy:0,resizeX:1,resizeY:-1},{cursor:"w-resize",dx:0,dy:.5,resizeX:-1,resizeY:0},{cursor:"e-resize",dx:1,dy:.5,resizeX:1,resizeY:0},{cursor:"sw-resize",dx:0,dy:1,resizeX:-1,resizeY:1},{cursor:"s-resize",dx:.5,dy:1,resizeX:0,resizeY:1},{cursor:"se-resize",dx:1,dy:1,resizeX:1,resizeY:1}],Ee=({nodes:o,edges:e,groups:t=[],viewport:r,onViewportChange:i,theme:a,selectedId:s,selectedIds:c=[],onSelectElement:l,onMultiSelect:u,onNodeDragStart:d,onNodeDrag:b,onNodeDragEnd:x,onNodeResize:g,onNodeLabelChange:h,onEdgeCreate:v,autoFit:_=!1,fitKey:w,refitKey:m,fitPadding:P=40,fitMaxZoom:k=1.25,onResize:j,resizable:C=!0,panOnDrag:X=!1,ariaLabel:V,animationStates:F,particleState:H,viewMode:I="editor",ghostOpacity:O=.15,onGroupCollapse:L,onNodeCollapse:Y,onInteraction:S,onNodeHover:A,onGroupClick:R,interactive:q=!1,showGrid:B=!0,showRulers:K=!1,snapToGrid:Z=!0,gridSnapSize:te=10,className:ge})=>{const he=p.useRef(null),Ce=p.useId().replace(/[^a-zA-Z0-9_-]/g,""),Ae=`nd-arrow-${Ce}`,$e=`nd-open-arrow-${Ce}`,me=`nd-diamond-marker-${Ce}`,Oe=`nd-circle-marker-${Ce}`,[ve,Ue]=p.useState(null),[G,Fe]=p.useState(!1),[Le,Xe]=p.useState({x:0,y:0}),[ze,Ve]=p.useState(null),[Ne,Je]=p.useState({x:0,y:0}),[z,U]=p.useState(null),[ne,pe]=p.useState(null),[le,qe]=p.useState(null),[Qe,rt]=p.useState(null),[ee,Ge]=p.useState(""),[_e,at]=p.useState([]),ct=(a==null?void 0:a.canvasBackground)??"var(--nice-bg-secondary, #f8f9fa)",kt=(a==null?void 0:a.gridColor)??"var(--nice-border, #e0e0e0)",Ye=(a==null?void 0:a.gridSize)??20,M=(a==null?void 0:a.selectionColor)??"var(--nice-primary, #2196f3)",[$,J]=p.useState(null),se=p.useRef(!1),Me=p.useRef(null),Ie=p.useRef({nodes:o,edges:e,onViewportChange:i,onResize:j,fitPadding:P,fitMaxZoom:k});p.useEffect(()=>{Ie.current={nodes:o,edges:e,onViewportChange:i,onResize:j,fitPadding:P,fitMaxZoom:k}}),p.useEffect(()=>{const f=he.current;if(!f)return;const N=()=>{const D=f.getBoundingClientRect();D.width>0&&D.height>0&&J(Q=>Q&&Q.width===D.width&&Q.height===D.height?Q:{width:D.width,height:D.height})};if(N(),typeof ResizeObserver>"u")return;const T=new ResizeObserver(N);return T.observe(f),()=>T.disconnect()},[]),p.useEffect(()=>{var f,N;$&&((N=(f=Ie.current).onResize)==null||N.call(f,$))},[$]),p.useEffect(()=>{const f=Me.current;f&&(f.x!==r.x||f.y!==r.y||f.zoom!==r.zoom)&&(se.current=!0)},[r]);const ot=p.useRef(m);p.useEffect(()=>{const{nodes:f,edges:N,onViewportChange:T,fitPadding:D,fitMaxZoom:Q}=Ie.current,E=m!==ot.current;if(ot.current=m,E&&(se.current=!1),!$||!T||!_&&!E||se.current)return;const W=Pt(fi(f,N),$,{padding:D,maxZoom:Q});Me.current=W,T(W)},[_,$,w,m]);const je=p.useMemo(()=>{const f=new Set(c);return s&&f.add(s),f},[s,c]),Pe=p.useCallback(f=>Z?Math.round(f/te)*te:f,[Z,te]),Lt=p.useCallback((f,N,T)=>{const D=[],E=N.x,W=N.y,ie=E+T.width/2,re=W+T.height/2,oe=E+T.width,ae=W+T.height;for(const we of o){if(we.id===f)continue;const xe=we.position.x,de=we.position.y,Se=xe+we.size.width/2,et=de+we.size.height/2,He=xe+we.size.width,We=de+we.size.height;Math.abs(E-xe)<5&&D.push({x:xe}),Math.abs(oe-He)<5&&D.push({x:He}),Math.abs(ie-Se)<5&&D.push({x:Se}),Math.abs(E-He)<5&&D.push({x:He}),Math.abs(oe-xe)<5&&D.push({x:xe}),Math.abs(W-de)<5&&D.push({y:de}),Math.abs(ae-We)<5&&D.push({y:We}),Math.abs(re-et)<5&&D.push({y:et}),Math.abs(W-We)<5&&D.push({y:We}),Math.abs(ae-de)<5&&D.push({y:de})}at(D)},[o]),Tr=p.useCallback(f=>{if(f.preventDefault(),!i)return;const N=f.deltaY>0?.9:1.1,T=Math.min(ui,Math.max(di,r.zoom*N)),D=he.current;if(!D)return;const Q=D.getBoundingClientRect(),E=f.clientX-Q.left,W=f.clientY-Q.top,ie=T/r.zoom,re=E-(E-r.x)*ie,oe=W-(W-r.y)*ie;se.current=!0,i({x:re,y:oe,zoom:T})},[r,i]),Pr=p.useCallback(f=>{if(f.button===1||f.button===0&&f.target.tagName==="svg"){if(f.button===0&&q&&!X&&!f.shiftKey&&f.target.tagName==="svg"){const N=he.current;if(N){const T=N.getBoundingClientRect(),D=(f.clientX-T.left-r.x)/r.zoom,Q=(f.clientY-T.top-r.y)/r.zoom;pe({x:D,y:Q}),U({x1:D,y1:Q,x2:D,y2:Q})}l&&l(null),u&&u([]);return}Fe(!0),Xe({x:f.clientX-r.x,y:f.clientY-r.y}),l&&f.button===0&&l(null)}},[r,l,u,q,X]),dt=p.useCallback(f=>{const N=he.current;if(!N)return null;const T=N.getBoundingClientRect();return{x:(f.clientX-T.left-r.x)/r.zoom,y:(f.clientY-T.top-r.y)/r.zoom}},[r]),Er=p.useCallback(f=>{if(ve){const N=dt(f);N&&Ue(T=>T&&{...T,to:N});return}if(ne){const N=he.current;if(!N)return;const T=N.getBoundingClientRect(),D=(f.clientX-T.left-r.x)/r.zoom,Q=(f.clientY-T.top-r.y)/r.zoom;U({x1:ne.x,y1:ne.y,x2:D,y2:Q});return}if(G&&i){se.current=!0,i({...r,x:f.clientX-Le.x,y:f.clientY-Le.y});return}if(le&&g){const N=he.current;if(!N)return;const T=N.getBoundingClientRect(),D=(f.clientX-T.left-r.x)/r.zoom,Q=(f.clientY-T.top-r.y)/r.zoom,E=D-le.startMouse.x,W=Q-le.startMouse.y,ie=Nt[le.handleIdx];let re=le.startSize.width+E*ie.resizeX,oe=le.startSize.height+W*ie.resizeY,ae=le.startPos.x+(ie.resizeX<0?E:0),we=le.startPos.y+(ie.resizeY<0?W:0);re=Math.max(30,Pe(re)),oe=Math.max(20,Pe(oe)),ae=Pe(ae),we=Pe(we),g(le.nodeId,{width:re,height:oe},{x:ae,y:we});return}if(ze&&b){const N=he.current;if(!N)return;const T=N.getBoundingClientRect(),D=Pe((f.clientX-T.left-r.x)/r.zoom-Ne.x),Q=Pe((f.clientY-T.top-r.y)/r.zoom-Ne.y);b(ze,{x:D,y:Q});const E=o.find(W=>W.id===ze);E&&Lt(ze,{x:D,y:Q},E.size)}},[ve,dt,ne,G,i,r,Le,le,g,ze,b,Ne,Pe,o,Lt]),Wt=p.useCallback(f=>{if(ve){const N=dt(f),T=N?[...o].reverse().find(D=>D.id!==ve.nodeId&&!D.hidden&&N.x>=D.position.x&&N.x<=D.position.x+D.size.width&&N.y>=D.position.y&&N.y<=D.position.y+D.size.height):void 0;T&&N&&(v==null||v(ve.nodeId,T.id,ve.portId,hi(T,N))),Ue(null);return}if(z&&ne){const N=Math.min(z.x1,z.x2),T=Math.min(z.y1,z.y2),D=Math.max(z.x1,z.x2),Q=Math.max(z.y1,z.y2);if(Math.abs(D-N)>5||Math.abs(Q-T)>5){const E=o.filter(W=>{const ie=W.position.x,re=W.position.y,oe=ie+W.size.width,ae=re+W.size.height;return oe>N&&ie<D&&ae>T&&re<Q}).map(W=>W.id);u==null||u(E),E.length===1&&(l==null||l(E[0]))}U(null),pe(null);return}if(G&&Fe(!1),le){qe(null);return}if(ze&&x){const N=he.current;if(!N)return;const T=N.getBoundingClientRect(),D=Pe((f.clientX-T.left-r.x)/r.zoom-Ne.x),Q=Pe((f.clientY-T.top-r.y)/r.zoom-Ne.y);x(ze,{x:D,y:Q})}Ve(null),at([])},[ve,dt,v,z,ne,G,le,ze,x,r,Ne,Pe,o,u,l]),Rr=p.useCallback((f,N)=>{if(f.stopPropagation(),!q)return;const T=o.find(ie=>ie.id===N);if(!T||T.locked)return;if(f.shiftKey&&u){const ie=[...c],re=ie.indexOf(N);re>=0?ie.splice(re,1):ie.push(N),u(ie);return}l==null||l(N);const D=he.current;if(!D)return;const Q=D.getBoundingClientRect(),E=(f.clientX-Q.left-r.x)/r.zoom,W=(f.clientY-Q.top-r.y)/r.zoom;Je({x:E-T.position.x,y:W-T.position.y}),Ve(N),d==null||d(N)},[q,o,r,l,d,u,c]),Or=p.useCallback((f,N,T)=>{if(f.stopPropagation(),!q)return;const D=o.find(re=>re.id===N);if(!D||D.locked)return;const Q=he.current;if(!Q)return;const E=Q.getBoundingClientRect(),W=(f.clientX-E.left-r.x)/r.zoom,ie=(f.clientY-E.top-r.y)/r.zoom;qe({nodeId:N,handleIdx:T,startMouse:{x:W,y:ie},startPos:{...D.position},startSize:{...D.size}}),l==null||l(N)},[q,o,r,l]),Fr=p.useCallback((f,N)=>{if(f.stopPropagation(),!q||!h)return;const T=o.find(D=>D.id===N);!T||T.locked||(rt(N),Ge(T.label))},[q,o,h]),Bt=p.useCallback(()=>{Qe&&h&&h(Qe,ee),rt(null)},[Qe,ee,h]),Lr=p.useCallback((f,N)=>{f.stopPropagation(),l==null||l(N)},[l]),Wr=p.useCallback(f=>dr(f,o),[o]),Br=p.useCallback((f,N)=>{const{size:T,style:D,shape:Q}=f,E=T.width,W=T.height,re=!!(D.gradientColor&&D.backgroundColor)?`url(#${N})`:D.backgroundColor??"var(--nice-bg, #fff)",oe=D.borderColor??"var(--nice-text, #333333)",ae=D.borderWidth??1,we=D.borderRadius??(Q==="roundedRect"?8:0),xe=D.borderStyle==="dashed"?"8,4":D.borderStyle==="dotted"?"2,4":void 0,de=D.shadow?"url(#nd-shadow)":void 0;switch(Q){case"ellipse":case"circle":return n.jsx("ellipse",{cx:E/2,cy:W/2,rx:E/2,ry:W/2,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:xe,filter:de});case"diamond":return n.jsx("polygon",{points:`${E/2},0 ${E},${W/2} ${E/2},${W} 0,${W/2}`,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:xe,filter:de});case"hexagon":{const Se=E/4;return n.jsx("polygon",{points:`${Se},0 ${E-Se},0 ${E},${W/2} ${E-Se},${W} ${Se},${W} 0,${W/2}`,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:xe,filter:de})}case"parallelogram":{const Se=E*.15;return n.jsx("polygon",{points:`${Se},0 ${E},0 ${E-Se},${W} 0,${W}`,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:xe,filter:de})}case"cylinder":return n.jsxs("g",{filter:de,children:[n.jsx("ellipse",{cx:E/2,cy:W*.1,rx:E/2,ry:W*.1,fill:re,stroke:oe,strokeWidth:ae}),n.jsx("rect",{x:0,y:W*.1,width:E,height:W*.8,fill:re,stroke:"none"}),n.jsx("line",{x1:0,y1:W*.1,x2:0,y2:W*.9,stroke:oe,strokeWidth:ae}),n.jsx("line",{x1:E,y1:W*.1,x2:E,y2:W*.9,stroke:oe,strokeWidth:ae}),n.jsx("ellipse",{cx:E/2,cy:W*.9,rx:E/2,ry:W*.1,fill:re,stroke:oe,strokeWidth:ae})]});case"triangle":return n.jsx("polygon",{points:`${E/2},0 ${E},${W} 0,${W}`,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:xe,filter:de});case"cloud":{const Se=`M${E*.25},${W*.8} A${E*.2},${E*.2},0,1,1,${E*.15},${W*.45} A${E*.18},${E*.18},0,1,1,${E*.35},${W*.2} A${E*.2},${E*.2},0,1,1,${E*.65},${W*.2} A${E*.18},${E*.18},0,1,1,${E*.85},${W*.45} A${E*.2},${E*.2},0,1,1,${E*.75},${W*.8} Z`;return n.jsx("path",{d:Se,fill:re,stroke:oe,strokeWidth:ae,filter:de})}case"document":{const Se=`M 0 0 L ${E} 0 L ${E} ${W*.85} Q ${E*.75} ${W*.7}, ${E*.5} ${W*.85} Q ${E*.25} ${W}, 0 ${W*.85} Z`;return n.jsx("path",{d:Se,fill:re,stroke:oe,strokeWidth:ae,filter:de})}case"actor":return n.jsxs("g",{stroke:oe,strokeWidth:ae,fill:"none",filter:de,children:[n.jsx("circle",{cx:E/2,cy:W*.15,r:W*.12,fill:re}),n.jsx("line",{x1:E/2,y1:W*.27,x2:E/2,y2:W*.6}),n.jsx("line",{x1:E*.15,y1:W*.4,x2:E*.85,y2:W*.4}),n.jsx("line",{x1:E/2,y1:W*.6,x2:E*.2,y2:W}),n.jsx("line",{x1:E/2,y1:W*.6,x2:E*.8,y2:W})]});case"rectangle":case"roundedRect":case"custom":default:return n.jsx("rect",{width:E,height:W,rx:we,ry:we,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:xe,filter:de})}},[]),Vt=p.useCallback(f=>{if(!F)return{};const N=F.get(f);if(!N)return{};const T=N.glow>0?`drop-shadow(0 0 ${N.glow}px gold)`:"",D=N.highlightColor?`drop-shadow(0 0 6px ${N.highlightColor})`:"";return{opacity:N.opacity,transform:`translate(${N.translateX}px, ${N.translateY}px) scale(${N.scale})`,filter:[T,D].filter(Boolean).join(" ")||void 0}},[F]),Vr=p.useMemo(()=>{if(!H)return null;const f=[];for(const[,N]of H.glowStates){const T=tr(N.elementId),D=rr(N.intensity,N.pulse);f.push(n.jsxs("filter",{id:T,x:"-50%",y:"-50%",width:"200%",height:"200%",children:[n.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:D,result:"blur"}),n.jsx("feFlood",{floodColor:N.color,floodOpacity:.6,result:"color"}),n.jsx("feComposite",{in:"color",in2:"blur",operator:"in",result:"glowColored"}),n.jsxs("feMerge",{children:[n.jsx("feMergeNode",{in:"glowColored"}),n.jsx("feMergeNode",{in:"SourceGraphic"})]})]},T))}return f},[H]),qr=p.useMemo(()=>{if(!H)return null;const f=[];for(const[N,T]of H.liquidFlows){if(!T.active)continue;const D=e.find(re=>re.id===N);if(!(D!=null&&D.style.liquidFlow))continue;const{color:Q,colorEnd:E}=D.style.liquidFlow,W=`nd-liquid-${N}`,ie=T.gradientOffset;f.push(n.jsxs("linearGradient",{id:W,x1:"0",y1:"0",x2:"1",y2:"0",children:[n.jsx("stop",{offset:`${ie*100%100}%`,stopColor:Q,stopOpacity:.8}),n.jsx("stop",{offset:`${(ie+.3)*100%100}%`,stopColor:E??Q,stopOpacity:.4}),n.jsx("stop",{offset:`${(ie+.6)*100%100}%`,stopColor:Q,stopOpacity:.8})]},W))}return f},[H,e]),Gr=p.useMemo(()=>o.filter(f=>f.style.gradientColor&&f.style.backgroundColor).map(f=>{const N=`nd-grad-${f.id}`,T=f.style.gradientDirection??"vertical";if(T==="radial")return n.jsxs("radialGradient",{id:N,children:[n.jsx("stop",{offset:"0%",stopColor:f.style.backgroundColor}),n.jsx("stop",{offset:"100%",stopColor:f.style.gradientColor})]},N);const D=T==="horizontal"||T==="diagonal"?"1":"0",Q=T==="vertical"||T==="diagonal"?"1":"0";return n.jsxs("linearGradient",{id:N,x1:"0",y1:"0",x2:D,y2:Q,children:[n.jsx("stop",{offset:"0%",stopColor:f.style.backgroundColor}),n.jsx("stop",{offset:"100%",stopColor:f.style.gradientColor})]},N)}),[o]);return n.jsxs("svg",{ref:he,className:`nice-diagram-canvas ${ge??""}`,style:{width:"100%",height:"100%",background:ct,cursor:G?"grabbing":le?le.nodeId?Nt[le.handleIdx].cursor:"default":ve?"crosshair":X?"grab":"default"},"aria-label":V,onWheel:Tr,onMouseDown:Pr,onMouseMove:Er,onMouseUp:Wt,onMouseLeave:Wt,children:[n.jsxs("defs",{children:[n.jsx("marker",{id:Ae,viewBox:"0 0 10 10",refX:"10",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:n.jsx("path",{d:"M 0 0 L 10 5 L 0 10 Z",fill:"var(--nice-text, #333)"})}),n.jsx("marker",{id:$e,viewBox:"0 0 10 10",refX:"10",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:n.jsx("path",{d:"M 0 0 L 10 5 L 0 10",fill:"none",stroke:"var(--nice-text, #333)",strokeWidth:"1.5"})}),n.jsx("marker",{id:me,viewBox:"0 0 10 10",refX:"5",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"15",markerHeight:"15",orient:"auto-start-reverse",children:n.jsx("polygon",{points:"5,0 10,5 5,10 0,5",fill:"var(--nice-text, #333)"})}),n.jsx("marker",{id:Oe,viewBox:"0 0 10 10",refX:"5",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:n.jsx("circle",{cx:"5",cy:"5",r:"4",fill:"var(--nice-text, #333)"})}),n.jsx("filter",{id:"nd-shadow",x:"-10%",y:"-10%",width:"130%",height:"130%",children:n.jsx("feDropShadow",{dx:"2",dy:"2",stdDeviation:"3",floodColor:"#00000033"})}),B&&n.jsx("pattern",{id:"nd-grid",width:Ye,height:Ye,patternUnits:"userSpaceOnUse",children:n.jsx("path",{d:`M ${Ye} 0 L 0 0 0 ${Ye}`,fill:"none",stroke:kt,strokeWidth:"0.5"})}),Gr,Vr,qr,o.filter(f=>f.style.glowColor).map(f=>{const N=`nd-node-glow-${f.id}`,T=(f.style.glowIntensity??.5)*10;return n.jsxs("filter",{id:N,x:"-50%",y:"-50%",width:"200%",height:"200%",children:[n.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:T,result:"blur"}),n.jsx("feFlood",{floodColor:f.style.glowColor,floodOpacity:.5,result:"color"}),n.jsx("feComposite",{in:"color",in2:"blur",operator:"in",result:"glowColored"}),n.jsxs("feMerge",{children:[n.jsx("feMergeNode",{in:"glowColored"}),n.jsx("feMergeNode",{in:"SourceGraphic"})]})]},N)})]}),K&&n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"0",y:"0",width:"100%",height:"20",fill:"var(--nice-bg-secondary, #f0f0f0)",stroke:"var(--nice-border, #ccc)",strokeWidth:"0.5"}),n.jsx("rect",{x:"0",y:"0",width:"20",height:"100%",fill:"var(--nice-bg-secondary, #f0f0f0)",stroke:"var(--nice-border, #ccc)",strokeWidth:"0.5"}),Array.from({length:100},(f,N)=>{const T=N*Ye*r.zoom+r.x,D=N*Ye;return T>20?n.jsxs("g",{children:[n.jsx("line",{x1:T,y1:"0",x2:T,y2:"20",stroke:"var(--nice-text-muted, #999)",strokeWidth:"0.5"}),n.jsx("text",{x:T+2,y:"14",fontSize:"9",fill:"var(--nice-text-secondary, #666)",children:D})]},`rx${N}`):null}),Array.from({length:100},(f,N)=>{const T=N*Ye*r.zoom+r.y,D=N*Ye;return T>20?n.jsxs("g",{children:[n.jsx("line",{x1:"0",y1:T,x2:"20",y2:T,stroke:"var(--nice-text-muted, #999)",strokeWidth:"0.5"}),n.jsx("text",{x:"2",y:T-2,fontSize:"9",fill:"var(--nice-text-secondary, #666)",writingMode:"tb",children:D})]},`ry${N}`):null})]}),n.jsxs("g",{transform:`translate(${r.x}, ${r.y}) scale(${r.zoom})`,children:[B&&n.jsx("rect",{x:"-10000",y:"-10000",width:"20000",height:"20000",fill:"url(#nd-grid)",pointerEvents:"none"}),t.map(f=>{var ie,re,oe,ae,we,xe,de,Se,et,He,We,ut;const N=o.filter(fe=>f.nodeIds.includes(fe.id));if(N.length===0&&!f.collapsed)return null;const T=((ie=f.style)==null?void 0:ie.padding)??20;if(f.collapsed){const fe=o.find(Ct=>f.nodeIds.includes(Ct.id)),nt=fe?fe.position.x:0,ft=fe?fe.position.y:0;return n.jsxs("g",{"data-group-id":f.id,style:{cursor:"pointer"},onClick:()=>L==null?void 0:L(f.id),children:[n.jsx("rect",{x:nt,y:ft,width:160,height:40,fill:((re=f.style)==null?void 0:re.backgroundColor)??"rgba(200,200,255,0.3)",stroke:((oe=f.style)==null?void 0:oe.borderColor)??"var(--nice-text-muted, #aab)",strokeWidth:((ae=f.style)==null?void 0:ae.borderWidth)??1,rx:((we=f.style)==null?void 0:we.borderRadius)??6,strokeDasharray:"6,3"}),n.jsxs("text",{x:nt+24,y:ft+24,fontSize:"12",fill:((xe=f.style)==null?void 0:xe.labelColor)??"var(--nice-text-secondary, #666)",fontWeight:"bold",children:[f.label," (",f.nodeIds.length,")"]})]},f.id)}const D=Math.min(...N.map(fe=>fe.position.x))-T,Q=Math.min(...N.map(fe=>fe.position.y))-T,E=Math.max(...N.map(fe=>fe.position.x+fe.size.width))+T,W=Math.max(...N.map(fe=>fe.position.y+fe.size.height))+T;return n.jsxs("g",{"data-group-id":f.id,children:[n.jsx("rect",{x:D,y:Q,width:E-D,height:W-Q,fill:((de=f.style)==null?void 0:de.backgroundColor)??"rgba(200,200,255,0.1)",stroke:((Se=f.style)==null?void 0:Se.borderColor)??"var(--nice-text-muted, #aab)",strokeWidth:((et=f.style)==null?void 0:et.borderWidth)??1,rx:((He=f.style)==null?void 0:He.borderRadius)??6,strokeDasharray:((We=f.style)==null?void 0:We.borderStyle)==="dashed"?"6,3":void 0}),n.jsx("text",{x:D+6,y:Q-4,fontSize:"12",fill:((ut=f.style)==null?void 0:ut.labelColor)??"var(--nice-text-secondary, #666)",fontWeight:"bold",style:R?{cursor:"pointer"}:void 0,onClick:R?fe=>{fe.stopPropagation(),R(f.id)}:void 0,children:f.label}),(q||I!=="editor")&&L&&n.jsxs("g",{style:{cursor:"pointer"},onClick:fe=>{fe.stopPropagation(),L(f.id)},children:[n.jsx("rect",{x:E-24,y:Q-12,width:20,height:20,rx:4,fill:"white",stroke:"var(--nice-text-muted, #999)",strokeWidth:1}),n.jsx("g",{transform:`translate(${E-20}, ${Q-8})`,children:n.jsx(y.NiceIcon,{name:"chevron-down",size:12,color:"var(--nice-text-secondary, #666)"})})]})]},f.id)}),_e.map((f,N)=>n.jsx("line",{x1:f.x!=null?f.x:-1e4,y1:f.y!=null?f.y:-1e4,x2:f.x!=null?f.x:1e4,y2:f.y!=null?f.y:1e4,stroke:"#ff4081",strokeWidth:.5,strokeDasharray:"4,4"},`snap-${N}`)),e.map(f=>{var xe;const{d:N,mid:T}=Wr(f),D=je.has(f.id),Q=f.style.targetArrow==="diamond"?`url(#${me})`:f.style.targetArrow==="circle"?`url(#${Oe})`:f.style.targetArrow==="openArrow"?`url(#${$e})`:f.style.targetArrow!=="none"?`url(#${Ae})`:void 0,E=f.style.sourceArrow==="diamond"?`url(#${me})`:f.style.sourceArrow==="circle"?`url(#${Oe})`:f.style.sourceArrow==="openArrow"?`url(#${$e})`:f.style.sourceArrow==="arrow"?`url(#${Ae})`:void 0,W=Vt(f.id),ie=F==null?void 0:F.get(f.id),re=ie==null?void 0:ie.strokeProgress,oe=re!=null&&re>=0&&re<1?{strokeDasharray:"1000",strokeDashoffset:`${1e3*(1-re)}`}:void 0,ae=f.style.liquidFlow,we=H==null?void 0:H.liquidFlows.get(f.id);return n.jsxs("g",{"data-edge-id":f.id,style:W,onClick:de=>Lr(de,f.id),children:[q&&n.jsx("path",{d:N,fill:"none",stroke:"transparent",strokeWidth:12,style:{cursor:"pointer"}}),(ae==null?void 0:ae.active)&&n.jsx("path",{d:N,fill:"none",stroke:`url(#nd-liquid-${f.id})`,strokeWidth:ae.pipeWidth??(f.style.strokeWidth??1.5)*4,strokeLinecap:"round",opacity:.5}),n.jsx("path",{d:N,fill:"none",stroke:D?M:f.style.strokeColor??"var(--nice-text, #333)",strokeWidth:f.style.strokeWidth??1.5,strokeDasharray:(oe==null?void 0:oe.strokeDasharray)??((xe=f.style.strokeDash)==null?void 0:xe.join(","))??(f.style.animated?"6,4":void 0),strokeDashoffset:oe==null?void 0:oe.strokeDashoffset,markerEnd:Q,markerStart:E,opacity:f.style.opacity??1,style:q?{cursor:"pointer",transition:oe?void 0:"stroke-dashoffset 0.1s"}:void 0}),f.style.animated&&n.jsx("circle",{r:3,fill:M,children:n.jsx("animateMotion",{dur:`${1/(f.style.flowSpeed||1)}s`,repeatCount:"indefinite",path:N})}),(we==null?void 0:we.active)&&we.particles.map((de,Se)=>n.jsx("circle",{r:de.size,fill:(ae==null?void 0:ae.color)??"var(--nice-primary, #3b82f6)",opacity:de.opacity*.6,children:n.jsx("animateMotion",{dur:`${3/(((ae==null?void 0:ae.speed)??1)+.5)}s`,repeatCount:"indefinite",path:N,begin:`${de.t*3}s`})},`lp-${f.id}-${Se}`)),ie&&ie.particleTrailT>=0&&n.jsxs(n.Fragment,{children:[n.jsx("circle",{r:4,fill:"var(--nice-warning-light, #fbbf24)",opacity:.8,children:n.jsx("animateMotion",{dur:"2s",repeatCount:"indefinite",path:N,begin:`${ie.particleTrailT*2}s`})}),n.jsx("circle",{r:2,fill:"var(--nice-warning-light, #fbbf24)",opacity:.5,children:n.jsx("animateMotion",{dur:"2s",repeatCount:"indefinite",path:N,begin:`${(ie.particleTrailT+.1)*2}s`})})]}),f.label&&(()=>{const de=f.label.length*7+8;return n.jsxs("g",{children:[n.jsx("rect",{x:T.x-de/2,y:T.y-9,width:de,height:18,rx:3,fill:"var(--nice-bg-primary, #fff)",fillOpacity:.85}),n.jsx("text",{x:T.x,y:T.y+4,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-secondary, #555)",children:f.label})]})})()]},f.id)}),o.filter(f=>!f.hidden||I==="editor").map(f=>{const N=je.has(f.id),T=Vt(f.id),D=F==null?void 0:F.get(f.id),Q=f.style.fontFamily??(a==null?void 0:a.fontFamily)??"sans-serif",E=f.style.fontSize??14,W=f.style.fontColor??"var(--nice-text, #222)",ie=f.style.fontWeight??"normal",re=f.style.fontStyle??"normal",oe=f.style.textAlign??"center",ae=f.style.rotation??0,we=`nd-grad-${f.id}`,xe=!!f.hidden,de=xe?O??.3:f.style.opacity??1,Se=f.style.glowColor?`url(#nd-node-glow-${f.id})`:void 0,et=oe==="left"?"start":oe==="right"?"end":"middle",He=oe==="left"?8:oe==="right"?f.size.width-8:f.size.width/2,We=D==null?void 0:D.typewriterChars,ut=We!=null&&We>=0?f.label.slice(0,We):f.label,fe=D==null?void 0:D.liquidFillProgress,nt=D==null?void 0:D.rippleRadius,ft=D==null?void 0:D.rippleOpacity,Ct=f.childNodeIds&&f.childNodeIds.length>0,Yr=!!f.collapsed;return n.jsxs("g",{"data-node-id":f.id,transform:`translate(${f.position.x}, ${f.position.y})${ae?` rotate(${ae}, ${f.size.width/2}, ${f.size.height/2})`:""}`,style:{...T,cursor:xe?"pointer":q&&!f.locked&&b?"grab":l?"pointer":"default",opacity:de,filter:Se},onMouseDown:ke=>Rr(ke,f.id),onDoubleClick:ke=>Fr(ke,f.id),onClick:ke=>{ke.stopPropagation(),l==null||l(f.id),f.interactions&&f.interactions.length>0&&f.interactions.filter(tt=>tt.trigger==="click").forEach(tt=>S==null?void 0:S(f.id,tt.id))},onMouseEnter:()=>{A==null||A(f.id),f.interactions&&f.interactions.filter(Te=>Te.trigger==="hover").forEach(Te=>S==null?void 0:S(f.id,Te.id))},onMouseLeave:()=>A==null?void 0:A(null),children:[xe&&n.jsx("rect",{x:-1,y:-1,width:f.size.width+2,height:f.size.height+2,fill:"none",stroke:"var(--nice-text-muted, #999)",strokeWidth:1,strokeDasharray:"3,3",rx:4,opacity:.5}),Br(f,we),fe!=null&&fe>0&&fe<1&&n.jsx("clipPath",{id:`nd-liquid-clip-${f.id}`,children:n.jsx("rect",{x:0,y:f.size.height*(1-fe),width:f.size.width,height:f.size.height*fe})}),fe!=null&&fe>0&&fe<1&&n.jsx("rect",{x:0,y:0,width:f.size.width,height:f.size.height,fill:f.style.glowColor??"var(--nice-primary, #3b82f6)",opacity:.25,rx:f.style.borderRadius??4,clipPath:`url(#nd-liquid-clip-${f.id})`}),nt!=null&&nt>0&&n.jsx("circle",{cx:f.size.width/2,cy:f.size.height/2,r:nt,fill:"none",stroke:f.style.glowColor??M,strokeWidth:2,opacity:ft??.5}),N&&n.jsx("rect",{x:-3,y:-3,width:f.size.width+6,height:f.size.height+6,fill:"none",stroke:M,strokeWidth:2,strokeDasharray:"4,3",rx:6}),N&&q&&C&&!f.locked&&Nt.map((ke,Te)=>n.jsx("rect",{x:ke.dx*f.size.width-ht/2,y:ke.dy*f.size.height-ht/2,width:ht,height:ht,fill:"white",stroke:M,strokeWidth:1.5,rx:1,style:{cursor:ke.cursor},onMouseDown:tt=>Or(tt,f.id,Te)},Te)),Qe===f.id?n.jsx("foreignObject",{x:4,y:4,width:f.size.width-8,height:f.size.height-8,children:n.jsx("input",{xmlns:"http://www.w3.org/1999/xhtml",type:"text",value:ee,onChange:ke=>Ge(ke.target.value),onBlur:Bt,onKeyDown:ke=>{ke.key==="Enter"&&Bt(),ke.key==="Escape"&&rt(null)},autoFocus:!0,style:{width:"100%",height:"100%",border:"1px solid "+M,borderRadius:3,padding:"2px 4px",fontSize:E,fontFamily:Q,fontWeight:ie,fontStyle:re,textAlign:oe,background:"var(--nice-overlay-light-95, rgba(255, 255, 255, 0.95))",outline:"none"}})}):n.jsxs(n.Fragment,{children:[n.jsx("text",{x:He,y:f.size.height/2+(f.description?-4:0),textAnchor:et,dominantBaseline:"central",fontFamily:Q,fontSize:E,fontWeight:ie,fontStyle:re,fill:W,pointerEvents:"none",children:ut}),f.description&&n.jsx("text",{x:He,y:f.size.height/2+E*.8,textAnchor:et,dominantBaseline:"central",fontFamily:Q,fontSize:E*.75,fill:"var(--nice-text-secondary, #777)",pointerEvents:"none",children:f.description}),f.icon&&(ci.test(f.icon)?n.jsx("g",{transform:`translate(${f.size.width/2-8}, 4)`,pointerEvents:"none",children:n.jsx(y.NiceIcon,{name:f.icon,size:16,color:"var(--nice-text-secondary, #666)"})}):n.jsx("text",{x:f.size.width/2,y:14,textAnchor:"middle",fontSize:16,pointerEvents:"none",children:f.icon})),f.style.linkUrl&&n.jsx("g",{transform:`translate(${f.size.width-14}, 3)`,pointerEvents:"none",children:n.jsx(y.NiceIcon,{name:"link",size:10,color:"var(--nice-primary-hover, #1976d2)"})}),Ct&&q&&n.jsxs("g",{onClick:ke=>{ke.stopPropagation(),Y==null||Y(f.id)},style:{cursor:"pointer"},children:[n.jsx("rect",{x:f.size.width-18,y:f.size.height-18,width:16,height:16,rx:3,fill:"white",stroke:"var(--nice-text-muted, #aaa)",strokeWidth:.5}),n.jsx("g",{transform:`translate(${f.size.width-15}, ${f.size.height-15})`,children:n.jsx(y.NiceIcon,{name:Yr?"chevron-right":"chevron-down",size:10,color:"var(--nice-text-secondary, #666)"})})]})]}),q&&f.ports.map(ke=>{const Te=ur(f,ke.id),tt=v?Hr=>{if(Hr.stopPropagation(),f.locked)return;const qt={x:f.position.x+Te.x,y:f.position.y+Te.y};Ue({nodeId:f.id,portId:ke.id,from:qt,to:qt})}:void 0;return n.jsxs("g",{"data-port-id":ke.id,onMouseDown:tt,children:[tt&&n.jsx("circle",{cx:Te.x,cy:Te.y,r:9,fill:"transparent",style:{cursor:"crosshair"}}),n.jsx("circle",{cx:Te.x,cy:Te.y,r:4,fill:"var(--nice-bg-primary, #fff)",stroke:"var(--nice-text-secondary, #666)",strokeWidth:1,style:{cursor:"crosshair"}})]},ke.id)})]},f.id)}),H&&H.particles.length>0&&n.jsx("g",{className:"nd-particle-overlay",children:H.particles.map((f,N)=>n.jsx("circle",{cx:f.x,cy:f.y,r:f.size,fill:f.color,opacity:f.opacity},`ptcl-${N}`))}),ve&&n.jsx("path",{d:`M ${ve.from.x} ${ve.from.y} L ${ve.to.x} ${ve.to.y}`,fill:"none",stroke:M,strokeWidth:1.5,strokeDasharray:"5,4",markerEnd:`url(#${Ae})`,pointerEvents:"none"}),z&&n.jsx("rect",{x:Math.min(z.x1,z.x2),y:Math.min(z.y1,z.y2),width:Math.abs(z.x2-z.x1),height:Math.abs(z.y2-z.y1),fill:"rgba(33,150,243,0.1)",stroke:M,strokeWidth:1,strokeDasharray:"4,2"})]})]})};process.env.NODE_ENV!=="production"&&(Ee.displayName="DiagramCanvas");function Yt(o,e,t){const r=o.find(c=>c.id===e);if(!r)return{x:0,y:0};const{position:i,size:a}=r,s=r.ports.find(c=>c.id===t);switch(s==null?void 0:s.side){case"top":return{x:i.x+a.width*s.offset,y:i.y};case"bottom":return{x:i.x+a.width*s.offset,y:i.y+a.height};case"left":return{x:i.x,y:i.y+a.height*s.offset};case"right":return{x:i.x+a.width,y:i.y+a.height*s.offset};default:return{x:i.x+a.width/2,y:i.y+a.height/2}}}function dr(o,e){const t=Yt(e,o.sourceNodeId,o.sourcePortId),r=Yt(e,o.targetNodeId,o.targetPortId),i={x:(t.x+r.x)/2,y:(t.y+r.y)/2};switch(o.style.lineType??"bezier"){case"straight":return{d:`M ${t.x} ${t.y} L ${r.x} ${r.y}`,mid:i,extent:[t,r]};case"orthogonal":{const a=(t.x+r.x)/2;return{d:`M ${t.x} ${t.y} L ${a} ${t.y} L ${a} ${r.y} L ${r.x} ${r.y}`,mid:i,extent:[t,r]}}case"step":{const a=(t.y+r.y)/2;return{d:`M ${t.x} ${t.y} L ${t.x} ${a} L ${r.x} ${a} L ${r.x} ${r.y}`,mid:i,extent:[t,r]}}default:{const a=Math.max(40,Math.hypot(r.x-t.x,r.y-t.y)*.4),s=(x,g)=>{var h,v;return((v=(h=e.find(_=>_.id===x))==null?void 0:h.ports.find(_=>_.id===g))==null?void 0:v.side)??null},c=(x,g,h)=>{switch(g){case"top":return{x:x.x,y:x.y-a};case"bottom":return{x:x.x,y:x.y+a};case"left":return{x:x.x-a,y:x.y};case"right":return{x:x.x+a,y:x.y};default:return{x:x.x+h,y:x.y}}},l=Math.abs(r.x-t.x)*.5,u=c(t,s(o.sourceNodeId,o.sourcePortId),l),d=c(r,s(o.targetNodeId,o.targetPortId),-l),b=x=>{const g=1-x;return{x:g*g*g*t.x+3*g*g*x*u.x+3*g*x*x*d.x+x*x*x*r.x,y:g*g*g*t.y+3*g*g*x*u.y+3*g*x*x*d.y+x*x*x*r.y}};return{d:`M ${t.x} ${t.y} C ${u.x} ${u.y}, ${d.x} ${d.y}, ${r.x} ${r.y}`,mid:b(.5),extent:Array.from({length:9},(x,g)=>b(g/8))}}}}function fi(o,e){const t=Tt(o);if(!t)return null;let[r,i,a,s]=[t.x,t.y,t.x+t.width,t.y+t.height];const c=(l,u=0,d=0)=>{r=Math.min(r,l.x-u),i=Math.min(i,l.y-d),a=Math.max(a,l.x+u),s=Math.max(s,l.y+d)};for(const l of e){const u=dr(l,o);u.extent.forEach(d=>c(d)),l.label&&c(u.mid,(l.label.length*7+8)/2,9)}return{x:r,y:i,width:a-r,height:s-i}}function hi(o,e){let t="",r=1/0;for(const i of o.ports){const a=ur(o,i.id),s=Math.hypot(o.position.x+a.x-e.x,o.position.y+a.y-e.y);s<r&&(r=s,t=i.id)}return t}function ur(o,e){const t=o.ports.find(i=>i.id===e);if(!t)return{x:0,y:0};const{size:r}=o;switch(t.side){case"top":return{x:r.width*t.offset,y:0};case"bottom":return{x:r.width*t.offset,y:r.height};case"left":return{x:0,y:r.height*t.offset};case"right":return{x:r.width,y:r.height*t.offset};default:return{x:0,y:0}}}const mi=180,gi=120,lt=({nodes:o,edges:e,viewport:t,onViewportChange:r,canvasWidth:i=800,canvasHeight:a=600,width:s=mi,height:c=gi,className:l})=>{const u=p.useMemo(()=>{if(o.length===0)return{minX:0,minY:0,maxX:400,maxY:300};let v=1/0,_=1/0,w=-1/0,m=-1/0;for(const k of o)v=Math.min(v,k.position.x),_=Math.min(_,k.position.y),w=Math.max(w,k.position.x+k.size.width),m=Math.max(m,k.position.y+k.size.height);const P=50;return{minX:v-P,minY:_-P,maxX:w+P,maxY:m+P}},[o]),d=u.maxX-u.minX,b=u.maxY-u.minY,x=Math.min(s/d,c/b),g=p.useMemo(()=>{const v=(-t.x/t.zoom-u.minX)*x,_=(-t.y/t.zoom-u.minY)*x,w=i/t.zoom*x,m=a/t.zoom*x;return{x:v,y:_,w,h:m}},[t,u,x,i,a]),h=p.useCallback(v=>{if(!r)return;const _=v.currentTarget.getBoundingClientRect(),w=v.clientX-_.left,m=v.clientY-_.top,P=w/x+u.minX,k=m/x+u.minY;r({...t,x:-(P*t.zoom-i/2),y:-(k*t.zoom-a/2)})},[r,t,x,u,i,a]);return n.jsxs("svg",{className:`nice-diagram-minimap ${l??""}`,width:s,height:c,style:{border:"1px solid var(--nice-border, #ccc)",background:"var(--nice-bg, #fff)",borderRadius:4,cursor:"pointer"},onClick:h,children:[e.map(v=>{const _=o.find(C=>C.id===v.sourceNodeId),w=o.find(C=>C.id===v.targetNodeId);if(!_||!w)return null;const m=(_.position.x+_.size.width/2-u.minX)*x,P=(_.position.y+_.size.height/2-u.minY)*x,k=(w.position.x+w.size.width/2-u.minX)*x,j=(w.position.y+w.size.height/2-u.minY)*x;return n.jsx("line",{x1:m,y1:P,x2:k,y2:j,stroke:"var(--nice-text-muted, #aaa)",strokeWidth:.5},v.id)}),o.map(v=>n.jsx("rect",{x:(v.position.x-u.minX)*x,y:(v.position.y-u.minY)*x,width:v.size.width*x,height:v.size.height*x,fill:v.style.backgroundColor??"var(--nice-border, #ddd)",stroke:"var(--nice-text-muted, #999)",strokeWidth:.5},v.id)),n.jsx("rect",{x:g.x,y:g.y,width:g.w,height:g.h,fill:"color-mix(in srgb, var(--nice-primary, #2196f3) 15%, transparent)",stroke:"var(--nice-primary, #2196f3)",strokeWidth:1})]})};process.env.NODE_ENV!=="production"&&(lt.displayName="DiagramMinimap");const pi=["rectangle","roundedRect","ellipse","circle","diamond","hexagon","parallelogram","cylinder","triangle","cloud","document","actor"],wt=({selectedNode:o,selectedEdge:e,onNodeChange:t,onEdgeChange:r,onRemove:i,className:a})=>{var u,d,b,x,g;const{t:s}=Re(),c=p.useCallback((h,v)=>{!o||!t||t(o.id,{style:{...o.style,[h]:v}})},[o,t]),l=p.useCallback((h,v)=>{!e||!r||r(e.id,{style:{...e.style,[h]:v}})},[e,r]);return!o&&!e?n.jsx("div",{className:`nice-diagram-property-panel nice-diagram-property-panel--empty ${a??""}`,children:n.jsx("p",{className:"nice-diagram-property-panel__hint",children:s("panel.noSelection")})}):o?n.jsxs("div",{className:`nice-diagram-property-panel ${a??""}`,children:[n.jsx("h3",{className:"nice-diagram-property-panel__title",children:s("panel.nodeProperties")}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.label"),n.jsx(y.NiceTextInput,{value:o.label,onChange:h=>t==null?void 0:t(o.id,{label:h}),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.description"),n.jsx(y.NiceTextInput,{value:o.description??"",onChange:h=>t==null?void 0:t(o.id,{description:h||void 0}),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.shape"),n.jsx(y.NiceSelect,{value:o.shape,onChange:h=>t==null?void 0:t(o.id,{shape:h}),options:pi.map(h=>({value:h,label:h})),className:"nice-diagram-property-panel__select"})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.width"),n.jsx(y.NiceNumberInput,{value:o.size.width,min:20,onChange:h=>t==null?void 0:t(o.id,{size:{...o.size,width:h??40}}),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.height"),n.jsx(y.NiceNumberInput,{value:o.size.height,min:20,onChange:h=>t==null?void 0:t(o.id,{size:{...o.size,height:h??40}}),className:"nice-diagram-property-panel__input"})]})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.bgColor"),n.jsx(y.NiceColorPicker,{value:o.style.backgroundColor??"var(--nice-bg, #fff)",onChange:h=>c("backgroundColor",h),className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.borderColor"),n.jsx(y.NiceColorPicker,{value:o.style.borderColor??"var(--nice-text, #333333)",onChange:h=>c("borderColor",h),className:"nice-diagram-property-panel__color"})]})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.fontSize"),n.jsx(y.NiceNumberInput,{value:o.style.fontSize??14,min:8,max:72,onChange:h=>c("fontSize",h??14),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.fontColor"),n.jsx(y.NiceColorPicker,{value:o.style.fontColor??"#222222",onChange:h=>c("fontColor",h),className:"nice-diagram-property-panel__color"})]})]}),n.jsx(y.NiceCheckbox,{checked:o.locked??!1,onChange:h=>t==null?void 0:t(o.id,{locked:h}),label:s("node.locked"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),n.jsx("h4",{className:"nice-diagram-property-panel__section-title",style:{fontSize:12,marginTop:12,marginBottom:4,color:"var(--nice-text-secondary, #666)"},children:s("node.effects","Effects")}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.glowColor","Glow Color"),n.jsx(y.NiceColorPicker,{value:o.style.glowColor??"var(--nice-primary, #3b82f6)",onChange:h=>c("glowColor",h),className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.glowIntensity","Glow Intensity"),n.jsx(y.NiceSlider,{min:0,max:3,step:.1,value:o.style.glowIntensity??0,onChange:h=>c("glowIntensity",h),className:"nice-diagram-property-panel__input"})]})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.opacity","Opacity"),n.jsx(y.NiceSlider,{min:0,max:1,step:.05,value:o.style.opacity??1,onChange:h=>c("opacity",h),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.borderRadius","Border Radius"),n.jsx(y.NiceNumberInput,{min:0,max:50,value:o.style.borderRadius??4,onChange:h=>c("borderRadius",h??4),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.borderWidth","Border Width"),n.jsx(y.NiceNumberInput,{min:0,max:10,step:.5,value:o.style.borderWidth??1,onChange:h=>c("borderWidth",h??1),className:"nice-diagram-property-panel__input"})]}),n.jsx(y.NiceCheckbox,{checked:o.style.shadow??!1,onChange:h=>c("shadow",h),label:s("node.shadow","Shadow"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.gradientEnd","Gradient End"),n.jsx(y.NiceColorPicker,{value:o.style.gradientColor??"var(--nice-bg, #fff)",onChange:h=>c("gradientColor",h),className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.gradientDir","Gradient Dir"),n.jsx(y.NiceSelect,{value:o.style.gradientDirection??"vertical",onChange:h=>c("gradientDirection",h),options:[{value:"vertical",label:s("node.vertical","Vertical")},{value:"horizontal",label:s("node.horizontal","Horizontal")},{value:"diagonal",label:s("node.diagonal","Diagonal")},{value:"radial",label:s("node.radial","Radial")}],className:"nice-diagram-property-panel__select"})]})]}),n.jsx(y.NiceCheckbox,{checked:o.hidden??!1,onChange:h=>t==null?void 0:t(o.id,{hidden:h}),label:s("node.hiddenGhostInEditor","Hidden (ghost in editor)"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),n.jsx(y.NiceButton,{className:"nice-diagram-property-panel__btn nice-diagram-property-panel__btn--danger",variant:"ghost",size:"sm",onClick:()=>i==null?void 0:i(o.id),children:s("toolbar.delete")})]}):e?n.jsxs("div",{className:`nice-diagram-property-panel ${a??""}`,children:[n.jsx("h3",{className:"nice-diagram-property-panel__title",children:s("panel.edgeProperties")}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("edge.label"),n.jsx(y.NiceTextInput,{value:e.label??"",onChange:h=>r==null?void 0:r(e.id,{label:h||void 0}),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("edge.lineType"),n.jsx(y.NiceSelect,{value:e.style.lineType??"bezier",onChange:h=>l("lineType",h),options:[{value:"straight",label:s("node.straight","Straight")},{value:"bezier",label:s("node.bezier","Bezier")},{value:"orthogonal",label:s("node.orthogonal","Orthogonal")},{value:"step",label:s("node.step","Step")}],className:"nice-diagram-property-panel__select"})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("edge.color"),n.jsx(y.NiceColorPicker,{value:e.style.strokeColor??"var(--nice-text, #333333)",onChange:h=>l("strokeColor",h),className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("edge.width"),n.jsx(y.NiceNumberInput,{value:e.style.strokeWidth??1.5,min:.5,max:10,step:.5,onChange:h=>l("strokeWidth",h??1.5),className:"nice-diagram-property-panel__input"})]})]}),n.jsx(y.NiceCheckbox,{checked:e.style.animated??!1,onChange:h=>l("animated",h),label:s("edge.animated"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),e.style.animated&&n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.flowSpeed","Flow Speed"),n.jsx(y.NiceSlider,{min:.1,max:5,step:.1,value:e.style.flowSpeed??1,onChange:h=>l("flowSpeed",h),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.dashStyle","Dash Style"),n.jsx(y.NiceSelect,{value:e.style.strokeDash?e.style.strokeDash.join(","):"solid",onChange:h=>{const v=h;v==="solid"?l("strokeDash",[]):l("strokeDash",v.split(",").map(Number))},options:[{value:"solid",label:s("node.solid","Solid")},{value:"6,4",label:s("node.dashed","Dashed")},{value:"2,2",label:s("node.dotted","Dotted")},{value:"8,4,2,4",label:s("node.dashDot","Dash-Dot")},{value:"12,6",label:s("node.longDash","Long Dash")}],className:"nice-diagram-property-panel__select"})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.targetArrow","Target Arrow"),n.jsx(y.NiceSelect,{value:e.style.targetArrow??"arrow",onChange:h=>l("targetArrow",h),options:[{value:"arrow",label:s("node.arrow","Arrow")},{value:"openArrow",label:s("node.openArrow","Open Arrow")},{value:"diamond",label:s("node.diamond","Diamond")},{value:"circle",label:s("node.circle","Circle")},{value:"none",label:s("node.none","None")}],className:"nice-diagram-property-panel__select"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.sourceArrow","Source Arrow"),n.jsx(y.NiceSelect,{value:e.style.sourceArrow??"none",onChange:h=>l("sourceArrow",h),options:[{value:"none",label:s("node.none","None")},{value:"arrow",label:s("node.arrow","Arrow")},{value:"openArrow",label:s("node.openArrow","Open Arrow")},{value:"diamond",label:s("node.diamond","Diamond")},{value:"circle",label:s("node.circle","Circle")}],className:"nice-diagram-property-panel__select"})]})]}),n.jsx("h4",{className:"nice-diagram-property-panel__section-title",style:{fontSize:12,marginTop:12,marginBottom:4,color:"var(--nice-text-secondary, #666)"},children:s("node.liquidFlow","Liquid Flow")}),n.jsx(y.NiceCheckbox,{checked:((u=e.style.liquidFlow)==null?void 0:u.active)??!1,onChange:h=>{const v=e.style.liquidFlow??{active:!1,color:"var(--nice-primary, #3b82f6)",speed:1,pipeWidth:6};r==null||r(e.id,{style:{...e.style,liquidFlow:{...v,active:h}}})},label:s("node.enableLiquidFlow","Enable Liquid Flow"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),((d=e.style.liquidFlow)==null?void 0:d.active)&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.color","Color"),n.jsx(y.NiceColorPicker,{value:((b=e.style.liquidFlow)==null?void 0:b.color)??"var(--nice-primary, #3b82f6)",onChange:h=>{const v=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...v,color:h}}})},className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.speed","Speed"),n.jsx(y.NiceSlider,{min:.1,max:5,step:.1,value:((x=e.style.liquidFlow)==null?void 0:x.speed)??1,onChange:h=>{const v=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...v,speed:h}}})},className:"nice-diagram-property-panel__input"})]})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.pipeWidth","Pipe Width"),n.jsx(y.NiceNumberInput,{min:2,max:20,value:((g=e.style.liquidFlow)==null?void 0:g.pipeWidth)??6,onChange:h=>{const v=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...v,pipeWidth:h??6}}})},className:"nice-diagram-property-panel__input"})]})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.opacity","Opacity"),n.jsx(y.NiceSlider,{min:0,max:1,step:.05,value:e.style.opacity??1,onChange:h=>l("opacity",h),className:"nice-diagram-property-panel__input"})]}),n.jsx(y.NiceButton,{className:"nice-diagram-property-panel__btn nice-diagram-property-panel__btn--danger",variant:"ghost",size:"sm",onClick:()=>i==null?void 0:i(e.id),children:s("toolbar.delete")})]}):null};process.env.NODE_ENV!=="production"&&(wt.displayName="DiagramPropertyPanel");const Ht={flowchart:["rectangle","roundedRect","diamond","parallelogram","ellipse","circle","document","cylinder"],orgchart:["roundedRect","ellipse","rectangle"],mindmap:["roundedRect","ellipse","cloud","rectangle"],bpmn:["rectangle","roundedRect","circle","diamond","document"],er:["rectangle","diamond","ellipse"],sequence:["rectangle","actor","circle"],stateMachine:["roundedRect","circle","diamond"],networkTopology:["rectangle","circle","cloud","cylinder","hexagon"],decisionTree:["rectangle","diamond","roundedRect"],custom:["rectangle","roundedRect","ellipse","circle","diamond","hexagon","parallelogram","cylinder","triangle","cloud","document","actor"]},yi=["dagre","forceDirected","grid","radial","tree"],bi=["sans-serif","serif","monospace","Arial","Helvetica","Times New Roman","Courier New","Georgia","Verdana","Tahoma","Trebuchet MS"],wi=[8,9,10,11,12,14,16,18,20,24,28,32,36,48,72],xt=({activeTool:o,onToolChange:e,diagramType:t,onAddNode:r,onApplyLayout:i,onUndo:a,onRedo:s,canUndo:c=!1,canRedo:l=!1,onExport:u,onZoomIn:d,onZoomOut:b,onZoomReset:x,zoomLevel:g=1,onToggleBold:h,onToggleItalic:v,isBold:_=!1,isItalic:w=!1,onFontFamilyChange:m,currentFontFamily:P="sans-serif",onFontSizeChange:k,currentFontSize:j=14,onAlignLeft:C,onAlignCenterH:X,onAlignRight:V,onAlignTop:F,onAlignCenterV:H,onAlignBottom:I,onDistributeH:O,onDistributeV:L,onBringToFront:Y,onSendToBack:S,onGroupSelected:A,onUngroupSelected:R,onCopy:q,onPaste:B,onDuplicate:K,onSelectAll:Z,selectionCount:te=0,onFind:ge,showFind:he=!1,findQuery:Ce="",onFindQueryChange:Ae,viewMode:$e="editor",onViewModeChange:me,stylePresetId:Oe,onStylePresetChange:ve,className:Ue})=>{const{t:G}=Re(),[Fe,Le]=p.useState(!1),[Xe,ze]=p.useState(!1),[Ve,Ne]=p.useState(!1),[Je,z]=p.useState(!1),[U,ne]=p.useState(!1),[pe,le]=p.useState(!1),qe=Ht[t]??Ht.custom,Qe=p.useCallback(ee=>{r==null||r(ee),Le(!1)},[r]),rt=p.useCallback(ee=>{i==null||i(ee),ze(!1)},[i]);return n.jsxs("div",{className:`nice-diagram-toolbar ${Ue??""}`,children:[n.jsxs("div",{className:"nice-diagram-toolbar__row",children:[n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:o==="select"?"primary":"ghost",size:"sm",onClick:()=>e("select"),title:`${G("toolbar.select")} (V)`,children:n.jsx(y.NiceIcon,{name:"cursor",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:o==="pan"?"primary":"ghost",size:"sm",onClick:()=>e("pan"),title:`${G("toolbar.pan")} (H)`,children:n.jsx(y.NiceIcon,{name:"move",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:o==="addEdge"?"primary":"ghost",size:"sm",onClick:()=>e("addEdge"),title:`${G("toolbar.addEdge")} (C)`,children:n.jsx(y.NiceIcon,{name:"link",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:o==="text"?"primary":"ghost",size:"sm",onClick:()=>e("text"),title:G("toolbar.textT","Text (T)"),children:n.jsx(y.NiceIcon,{name:"type",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:o==="freehand"?"primary":"ghost",size:"sm",onClick:()=>e("freehand"),title:G("toolbar.freehandF","Freehand (F)"),children:n.jsx(y.NiceIcon,{name:"pen",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:o==="delete"?"primary":"ghost",size:"sm",onClick:()=>e("delete"),title:`${G("toolbar.delete")} (Del)`,children:n.jsx(y.NiceIcon,{name:"trash",size:14})})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:o==="addNode"?"primary":"ghost",size:"sm",onClick:()=>Le(ee=>!ee),title:G("toolbar.addNode"),children:[n.jsx(y.NiceIcon,{name:"plus",size:14})," ",G("toolbar.addNode")]}),Fe&&n.jsx("div",{className:"nice-diagram-toolbar__dropdown nice-diagram-toolbar__dropdown--shapes",children:qe.map(ee=>n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>Qe(ee),children:[n.jsx(y.NiceIcon,{name:xi(ee),size:14})," ",ee]},ee))})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:q,title:G("toolbar.copyCtrlC","Copy (Ctrl+C)"),children:n.jsx(y.NiceIcon,{name:"copy",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:B,title:G("toolbar.pasteCtrlV","Paste (Ctrl+V)"),children:n.jsx(y.NiceIcon,{name:"clipboard",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:K,title:G("toolbar.duplicateCtrlD","Duplicate (Ctrl+D)"),children:n.jsx(y.NiceIcon,{name:"layers",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:Z,title:G("toolbar.selectAllCtrlA","Select All (Ctrl+A)"),children:n.jsx(y.NiceIcon,{name:"check-square",size:14})})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:a,disabled:!c,title:`${G("toolbar.undo")} (Ctrl+Z)`,children:n.jsx(y.NiceIcon,{name:"undo",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:s,disabled:!l,title:`${G("toolbar.redo")} (Ctrl+Y)`,children:n.jsx(y.NiceIcon,{name:"redo",size:14})})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:b,title:G("toolbar.zoomOut"),children:n.jsx(y.NiceIcon,{name:"minus",size:14})}),n.jsxs("span",{className:"nice-diagram-toolbar__zoom-label",children:[Math.round(g*100),"%"]}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:d,title:G("toolbar.zoomIn"),children:n.jsx(y.NiceIcon,{name:"plus",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:x,title:G("toolbar.zoomReset"),children:"1:1"})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:ge,title:G("toolbar.findCtrlF","Find (Ctrl+F)"),children:n.jsx(y.NiceIcon,{name:"search",size:14})}),he&&n.jsx(y.NiceTextInput,{className:"nice-diagram-toolbar__search",placeholder:G("toolbar.searchNodes","Search nodes…"),value:Ce,onChange:ee=>Ae==null?void 0:Ae(ee),autoFocus:!0})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>Ne(ee=>!ee),title:G("toolbar.export"),children:[n.jsx(y.NiceIcon,{name:"download",size:14})," ",G("toolbar.export")]}),Ve&&n.jsxs("div",{className:"nice-diagram-toolbar__dropdown",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{u==null||u("ndd"),Ne(!1)},children:".ndd.json"}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{u==null||u("svg"),Ne(!1)},children:"SVG"}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{u==null||u("mermaid"),Ne(!1)},children:G("toolbar.mermaid","Mermaid")}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{u==null||u("png"),Ne(!1)},children:"PNG"})]})]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__row nice-diagram-toolbar__format-bar",children:[n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceSelect,{className:"nice-diagram-toolbar__font-select",value:P,onChange:ee=>m==null?void 0:m(ee),options:bi.map(ee=>({value:ee,label:ee})),title:G("toolbar.fontFamily","Font Family")}),n.jsx(y.NiceSelect,{className:"nice-diagram-toolbar__size-select",value:String(j),onChange:ee=>k==null?void 0:k(Number(ee)),options:wi.map(ee=>({value:String(ee),label:String(ee)})),title:G("toolbar.fontSize","Font Size")})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:_?"primary":"ghost",size:"sm",onClick:h,title:G("toolbar.boldCtrlB","Bold (Ctrl+B)"),children:n.jsx("strong",{children:"B"})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:w?"primary":"ghost",size:"sm",onClick:v,title:G("toolbar.italicCtrlI","Italic (Ctrl+I)"),children:n.jsx("em",{children:"I"})})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>z(ee=>!ee),title:G("toolbar.alignmentDistribution","Alignment & Distribution"),children:[n.jsx(y.NiceIcon,{name:"align-left",size:14})," ",G("toolbar.align","Align")]}),Je&&n.jsxs("div",{className:"nice-diagram-toolbar__dropdown nice-diagram-toolbar__dropdown--align",children:[n.jsx("div",{className:"nice-diagram-toolbar__dropdown-section",children:G("toolbar.align","Align")}),n.jsxs("div",{className:"nice-diagram-toolbar__dropdown-row",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{C==null||C(),z(!1)},title:G("toolbar.alignLeft","Align Left"),children:[n.jsx(y.NiceIcon,{name:"align-left",size:14})," ",G("toolbar.left","Left")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{X==null||X(),z(!1)},title:G("toolbar.alignCenter","Align Center"),children:[n.jsx(y.NiceIcon,{name:"align-center",size:14})," ",G("toolbar.center","Center")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{V==null||V(),z(!1)},title:G("toolbar.alignRight","Align Right"),children:[n.jsx(y.NiceIcon,{name:"align-right",size:14})," ",G("toolbar.right","Right")]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__dropdown-row",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{F==null||F(),z(!1)},title:G("toolbar.alignTop","Align Top"),children:[n.jsx(y.NiceIcon,{name:"align-top",size:14})," ",G("toolbar.top","Top")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{H==null||H(),z(!1)},title:G("toolbar.alignMiddle","Align Middle"),children:[n.jsx(y.NiceIcon,{name:"align-middle",size:14})," ",G("toolbar.middle","Middle")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{I==null||I(),z(!1)},title:G("toolbar.alignBottom","Align Bottom"),children:[n.jsx(y.NiceIcon,{name:"align-bottom",size:14})," ",G("toolbar.bottom","Bottom")]})]}),n.jsx("div",{className:"nice-diagram-toolbar__dropdown-section",children:G("toolbar.distribute","Distribute")}),n.jsxs("div",{className:"nice-diagram-toolbar__dropdown-row",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{O==null||O(),z(!1)},title:G("toolbar.distributeHorizontally","Distribute Horizontally"),children:[n.jsx(y.NiceIcon,{name:"distribute-h",size:14})," H"]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{L==null||L(),z(!1)},title:G("toolbar.distributeVertically","Distribute Vertically"),children:[n.jsx(y.NiceIcon,{name:"distribute-v",size:14})," V"]})]})]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>ne(ee=>!ee),title:G("toolbar.arrange","Arrange"),children:[n.jsx(y.NiceIcon,{name:"menu",size:14})," ",G("toolbar.arrange","Arrange")]}),U&&n.jsxs("div",{className:"nice-diagram-toolbar__dropdown",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{Y==null||Y(),ne(!1)},children:[n.jsx(y.NiceIcon,{name:"arrow-up",size:14})," ",G("toolbar.bringToFront","Bring to Front")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{S==null||S(),ne(!1)},children:[n.jsx(y.NiceIcon,{name:"arrow-down",size:14})," ",G("toolbar.sendToBack","Send to Back")]}),n.jsx("div",{className:"nice-diagram-toolbar__dropdown-divider"}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{A==null||A(),ne(!1)},disabled:te<2,children:[n.jsx(y.NiceIcon,{name:"group",size:14})," ",G("toolbar.group","Group")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{R==null||R(),ne(!1)},children:[n.jsx(y.NiceIcon,{name:"ungroup",size:14})," ",G("toolbar.ungroup","Ungroup")]})]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>ze(ee=>!ee),title:G("toolbar.layout"),children:[n.jsx(y.NiceIcon,{name:"grid",size:14})," ",G("toolbar.layout")]}),Xe&&n.jsx("div",{className:"nice-diagram-toolbar__dropdown",children:yi.map(ee=>n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>rt(ee),children:G(`layout.${ee}`)},ee))})]}),te>1&&n.jsx("span",{className:"nice-diagram-toolbar__selection-info",children:G("toolbar.selected","{selectionCount} selected").replace("{selectionCount}",String(te))}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:$e==="editor"?"primary":"ghost",size:"sm",onClick:()=>me==null?void 0:me("editor"),title:G("toolbar.editorMode","Editor Mode"),children:[n.jsx(y.NiceIcon,{name:"edit",size:14})," ",G("toolbar.editor","Editor")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:$e==="player"?"primary":"ghost",size:"sm",onClick:()=>me==null?void 0:me("player"),title:G("toolbar.playerMode","Player Mode"),children:[n.jsx(y.NiceIcon,{name:"play",size:14})," ",G("toolbar.player","Player")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:$e==="playerAnimated"?"primary":"ghost",size:"sm",onClick:()=>me==null?void 0:me("playerAnimated"),title:G("toolbar.animatedPlayerMode","Animated Player Mode"),children:[n.jsx(y.NiceIcon,{name:"zap",size:14})," ",G("toolbar.animated","Animated")]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>le(ee=>!ee),title:G("toolbar.stylePresets","Style Presets"),children:[n.jsx(y.NiceIcon,{name:"palette",size:14})," ",G("toolbar.style","Style")]}),pe&&n.jsx("div",{className:"nice-diagram-toolbar__dropdown nice-diagram-toolbar__dropdown--presets",style:{maxHeight:320,overflowY:"auto",width:220},children:Object.entries(yt.reduce((ee,Ge)=>{const _e=Ge.category??"Other";return ee[_e]||(ee[_e]=[]),ee[_e].push(Ge),ee},{})).map(([ee,Ge])=>n.jsxs("div",{children:[n.jsx("div",{className:"nice-diagram-toolbar__dropdown-section",style:{fontSize:10,color:"var(--nice-text-secondary, #888)",padding:"6px 8px 2px",textTransform:"uppercase"},children:ee}),Ge.map(_e=>n.jsxs(y.NiceButton,{className:`nice-diagram-toolbar__dropdown-item ${Oe===_e.id?"nice-diagram-toolbar__dropdown-item--active":""}`,variant:Oe===_e.id?"primary":"ghost",size:"sm",onClick:()=>{ve==null||ve(_e.id),le(!1)},style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("span",{style:{width:16,height:16,borderRadius:3,background:_e.config.palette.primary,border:"1px solid "+(_e.config.palette.border??"var(--nice-border, #ccc)"),display:"inline-block",flexShrink:0}}),n.jsx("span",{style:{fontSize:12},children:_e.name})]},_e.id))]},ee))})]})]})]})};process.env.NODE_ENV!=="production"&&(xt.displayName="DiagramToolbar");function xi(o){switch(o){case"rectangle":return"square";case"roundedRect":return"card";case"ellipse":return"circle";case"circle":return"circle";case"diamond":return"diamond";case"hexagon":return"hexagon";case"parallelogram":return"parallelogram";case"cylinder":return"database";case"triangle":return"triangle";case"cloud":return"cloud";case"document":return"file";case"actor":return"user";default:return"card"}}const vi=[{target:".nice-diagram-editor",titleKey:"tutorial.diagramEditor.intro.title",title:"Diagram editor",contentKey:"tutorial.diagramEditor.intro.content",content:"Pick a tool to add and connect nodes on the canvas, edit them in the property panel, and export the diagram from the toolbar.",placement:"auto"}],fr=({initialDocument:o,document:e,nodeTypes:t,autoLayout:r,fitOnMount:i=!1,readOnly:a=!1,diagramType:s="flowchart",onChange:c,onExport:l,lang:u,showToolbar:d=!0,showPropertyPanel:b=!0,showMinimap:x=!0,showTimeline:g=!0,className:h,style:v,tutorial:_})=>{var Je;const{t:w}=y.useNiceTranslation(),m=lr(e??o),[P,k]=p.useState("select"),[j,C]=p.useState(null),X=p.useRef(null),[V,F]=p.useState("editor"),H=p.useRef(null),[I,O]=p.useState({particles:[],liquidFlows:new Map,glowStates:new Map});p.useEffect(()=>{const z=new er(U=>{O(U)});return H.current=z,z.start(),()=>{z.stop(),H.current=null}},[]),p.useEffect(()=>{var U;const z=H.current;if(z)for(const ne of m.edges)(U=ne.style.liquidFlow)!=null&&U.active?z.startLiquidFlow(ne.id,ne.style.liquidFlow):z.stopLiquidFlow(ne.id)},[m.edges]),p.useEffect(()=>{const z=H.current;if(z)for(const U of m.nodes)U.style.glowColor?z.setGlow(U.id,U.style.glowColor,U.style.glowIntensity??1):z.removeGlow(U.id)},[m.nodes]);const L=p.useCallback(z=>{m.setStylePreset(z)},[m]),Y=p.useCallback((z,U)=>{const ne=m.nodes.find(le=>le.id===z);if(!(ne!=null&&ne.interactions))return;const pe=ne.interactions.find(le=>le.id===U);if(pe)switch(pe.action){case"reveal":{if(pe.targetId){const le=m.nodes.find(qe=>qe.id===pe.targetId);le!=null&&le.hidden&&m.updateNode(pe.targetId,{hidden:!1})}break}case"navigate":{if(pe.targetId){const le=m.nodes.find(qe=>qe.id===pe.targetId);le&&(m.setViewport({x:-le.position.x+300,y:-le.position.y+200,zoom:m.viewport.zoom}),C(pe.targetId))}break}case"switchAnimationMode":{pe.targetId&&m.setActiveAnimationMode(pe.targetId);break}case"highlight":{pe.targetId&&C(pe.targetId);break}case"toggleCollapse":{m.toggleNodeCollapse(z);break}}},[m]),S=p.useRef(c);p.useEffect(()=>{S.current=c});const A=p.useRef(m.revision);p.useEffect(()=>{var z;m.revision!==A.current&&(A.current=m.revision,(z=S.current)==null||z.call(S,m.document))},[m.revision,m.document]);const R=m.model;p.useEffect(()=>{e&&e!==R.getDocument()&&R.loadDocument(e)},[e,R]);const q=`${m.nodes.map(z=>z.id).join(",")}|${m.edges.map(z=>`${z.sourceNodeId}>${z.targetNodeId}`).join(",")}`,B=p.useMemo(()=>r?r===!0?{algorithm:"dagre",direction:"LR",nodeSpacing:40,rankSpacing:80}:r:null,[r]),K=m.applyLayout;p.useEffect(()=>{B&&K(B,{history:!1})},[q,B,K]);const Z=p.useCallback((z,U,ne,pe)=>{m.addEdge(z,ne??"right",U,pe??"left")},[m]),te=p.useCallback(z=>{const U=m.viewport,ne=m.addNode(z.label,{x:(-U.x+400)/U.zoom,y:(-U.y+300)/U.zoom},z.shape,z.size);m.updateNode(ne.id,{style:{...z.style},...z.icon?{icon:z.icon}:{},...z.description?{description:z.description}:{},...z.ports?{ports:z.ports.map(pe=>({...pe}))}:{},data:{...ne.data,nodeType:z.id}}),C(ne.id),k("select")},[m]),[ge,he]=p.useState(0),Ce=p.useMemo(()=>j?m.nodes.find(z=>z.id===j)??null:null,[j,m.nodes]),Ae=p.useMemo(()=>j?m.edges.find(z=>z.id===j)??null:null,[j,m.edges]),$e=p.useCallback(z=>{const U=m.viewport,ne=(-U.x+400)/U.zoom,pe=(-U.y+300)/U.zoom,le=m.addNode("New Node",{x:ne,y:pe},z);C(le.id),k("select")},[m]),me=p.useCallback(z=>{m.applyLayout({algorithm:z,centerGraph:!0})},[m]),Oe=p.useCallback((z,U)=>{m.moveNode(z,U)},[m]),ve=p.useCallback((z,U)=>{m.moveNode(z,U)},[m]),Ue=p.useCallback(z=>{m.nodes.find(U=>U.id===z)?m.removeNode(z):m.edges.find(U=>U.id===z)&&m.removeEdge(z),C(null)},[m]),G=p.useCallback(z=>{const U=m.document;let ne;switch(z){case"ndd":ne=nr(U,!0);break;case"svg":ne=zt(U);break;case"mermaid":ne=or(U);break;case"png":ne=zt(U);break}l==null||l(z,ne)},[m,l]),Fe=p.useCallback(()=>{m.setViewport({...m.viewport,zoom:Math.min(5,m.viewport.zoom*1.2)})},[m]),Le=p.useCallback(()=>{m.setViewport({...m.viewport,zoom:Math.max(.1,m.viewport.zoom/1.2)})},[m]),Xe=p.useCallback(()=>{i?he(z=>z+1):m.setViewport({x:0,y:0,zoom:1})},[m,i]),ze=p.useMemo(()=>[...m.nodes.map(z=>({id:z.id,label:z.label,type:"node"})),...m.edges.map(z=>({id:z.id,label:z.label??z.id,type:"edge"}))],[m.nodes,m.edges]),Ve=d&&!a||m.animationModes.length>0?n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,width:"100%"},children:[d&&!a&&n.jsx(xt,{activeTool:P,onToolChange:k,diagramType:m.document.diagramType,onAddNode:$e,onApplyLayout:me,onUndo:m.undo,onRedo:m.redo,canUndo:m.canUndo,canRedo:m.canRedo,onExport:G,onZoomIn:Fe,onZoomOut:Le,onZoomReset:Xe,zoomLevel:m.viewport.zoom,viewMode:V,onViewModeChange:F,stylePresetId:m.stylePresetId,onStylePresetChange:L}),t&&t.length>0&&!a&&n.jsx("div",{className:"nice-diagram-editor__node-types",role:"group","aria-label":w("diagramEditor.nodeTypes","Add a node"),style:{display:"flex",flexWrap:"wrap",gap:4,padding:"4px 8px"},children:t.map(z=>n.jsx(y.NiceButton,{variant:"ghost",size:"sm",leftIcon:n.jsx(y.NiceIcon,{name:z.icon??"plus",size:14}),onClick:()=>te(z),children:z.label},z.id))}),m.animationModes.length>0&&n.jsxs("div",{className:"nice-diagram-editor__mode-tabs",style:{display:"flex",gap:4,padding:"4px 8px",fontSize:12,alignItems:"center"},children:[n.jsx("span",{style:{color:"var(--nice-text-secondary, #888)",marginRight:4},children:w("diagramEditor.modes","Modes:")}),m.animationModes.map(z=>{var U;return n.jsx(y.NiceButton,{variant:((U=m.activeAnimationMode)==null?void 0:U.id)===z.id?"primary":"ghost",size:"sm",onClick:()=>m.setActiveAnimationMode(z.id),style:{padding:"2px 10px",fontSize:11},children:z.name},z.id)}),n.jsx(y.NiceButton,{variant:"ghost",size:"sm",onClick:()=>m.addAnimationMode(`Mode ${m.animationModes.length+1}`),style:{padding:"2px 8px",fontSize:11,color:"var(--nice-text-secondary, #888)"},title:w("diagramEditor.addAnimationMode","Add animation mode"),children:"+"})]})]}):void 0,Ne=n.jsxs(y.NiceAppShell,{ref:X,flush:!0,className:`nice-diagram-editor ${h??""}`,style:{position:"relative",...v},toolbar:Ve,rightSidebar:b&&!a?n.jsx("div",{className:"nice-diagram-editor__panel",style:{width:260,overflowY:"auto",height:"100%"},children:n.jsx(wt,{selectedNode:Ce,selectedEdge:Ae,onNodeChange:m.updateNode,onEdgeChange:m.updateEdge,onRemove:Ue})}):void 0,bottomPanel:g?n.jsx("div",{className:"nice-diagram-editor__timeline",children:n.jsx(bt,{animations:m.animations,onAdd:m.addAnimation,onRemove:m.removeAnimation,availableTargets:ze})}):void 0,children:[n.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:n.jsx(y.NiceTutorialButton,{steps:y.resolveTutorial(_,vi)})}),n.jsxs("div",{className:"nice-diagram-editor__canvas",style:{height:"100%",position:"relative"},children:[n.jsx(Ee,{nodes:m.nodes,edges:m.edges,groups:m.groups,viewport:m.viewport,onViewportChange:m.setViewport,selectedId:j,onSelectElement:C,onNodeDrag:B||a?void 0:Oe,onNodeDragEnd:B||a?void 0:ve,onEdgeCreate:a?void 0:Z,autoFit:i,fitKey:B?q:void 0,refitKey:ge,interactive:V==="editor"&&!a,showGrid:V==="editor",particleState:I,viewMode:V,ghostOpacity:((Je=m.playerConfig)==null?void 0:Je.ghostOpacity)??.3,onGroupCollapse:m.toggleGroupCollapse,onNodeCollapse:m.toggleNodeCollapse,onInteraction:Y}),x&&n.jsx("div",{style:{position:"absolute",bottom:8,left:8},children:n.jsx(lt,{nodes:m.nodes,edges:m.edges,viewport:m.viewport,onViewportChange:m.setViewport})})]})]});return u?n.jsx(jt,{locale:u,children:Ne}):Ne};process.env.NODE_ENV!=="production"&&(fr.displayName="NiceDiagramEditor");const Ut={linear:o=>o,easeIn:o=>o*o,easeOut:o=>o*(2-o),easeInOut:o=>o<.5?2*o*o:-1+(4-2*o)*o,spring:o=>1-Math.cos(o*Math.PI*.5)*Math.exp(-6*o),bounce:o=>{if(o<1/2.75)return 7.5625*o*o;if(o<2/2.75){const t=o-.5454545454545454;return 7.5625*t*t+.75}if(o<2.5/2.75){const t=o-.8181818181818182;return 7.5625*t*t+.9375}const e=o-2.625/2.75;return 7.5625*e*e+.984375}};function hr(o){return Ut[o]??Ut.linear}const mr={opacity:1,scale:1,translateX:0,translateY:0,glow:0,highlightColor:"",strokeProgress:1,rippleRadius:0,rippleOpacity:0,typewriterChars:-1,liquidFillProgress:-1,particleTrailT:-1};class gr{constructor(e,t){this.startTime=0,this.playing=!1,this.rafId=0,this.stateMap=new Map,this.tick=()=>{if(!this.playing)return;const r=performance.now()-this.startTime;this.stateMap.clear();let i=!1;for(const a of this.animations){const s=a.startMs+(a.delayMs??0);s+a.durationMs;const c=a.repeat??0;let l=r-s;if(l<0){this.stateMap.set(a.targetId,Ci(a)),i=!0;continue}if(c===-1)l=l%a.durationMs,i=!0;else if(c>0){const x=a.durationMs*(c+1);if(l>x)continue;l=l%a.durationMs,i=!0}else{if(l>a.durationMs)continue;i=!0}const u=Math.min(l/a.durationMs,1),d=hr(a.easing)(u),b=ki(a,d);this.stateMap.set(a.targetId,b)}this.onFrame(this.stateMap),i?this.rafId=requestAnimationFrame(this.tick):this.playing=!1},this.animations=[...e].sort((r,i)=>r.startMs-i.startMs),this.onFrame=t}play(){this.playing||(this.playing=!0,this.startTime=performance.now(),this.tick())}stop(){this.playing=!1,this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0,this.stateMap.clear(),this.onFrame(this.stateMap)}pause(){this.playing=!1,this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0}isPlaying(){return this.playing}}function ki(o,e){const t={...mr};switch(o.effect){case"fadeIn":t.opacity=e;break;case"fadeOut":t.opacity=1-e;break;case"slideInLeft":t.translateX=-200*(1-e),t.opacity=e;break;case"slideInRight":t.translateX=200*(1-e),t.opacity=e;break;case"slideInTop":t.translateY=-200*(1-e),t.opacity=e;break;case"slideInBottom":t.translateY=200*(1-e),t.opacity=e;break;case"zoomIn":t.scale=e,t.opacity=e;break;case"zoomOut":t.scale=1-e*.5,t.opacity=1-e;break;case"pulse":t.scale=1+.15*Math.sin(e*Math.PI*2);break;case"shake":t.translateX=10*Math.sin(e*Math.PI*6)*(1-e);break;case"highlight":t.highlightColor=`rgba(255, 200, 0, ${.6*(1-Math.abs(2*e-1))})`;break;case"flowPulse":t.opacity=1,t.translateX=e;break;case"bounce":t.translateY=-40*Math.abs(Math.sin(e*Math.PI*3))*(1-e);break;case"glow":t.glow=12*Math.sin(e*Math.PI);break;case"colorShift":t.highlightColor=`hsl(${e*360}, 70%, 60%)`;break;case"liquidFill":t.liquidFillProgress=e;break;case"expand":t.scale=e,t.opacity=e;break;case"collapse":t.scale=1-e,t.opacity=1-e;break;case"ripple":t.rippleRadius=e*40,t.rippleOpacity=1-e;break;case"typewriter":t.typewriterChars=Math.floor(e*100);break;case"morphShape":t.scale=1+.1*Math.sin(e*Math.PI*4)*(1-e),t.translateX=2*Math.sin(e*Math.PI*3)*(1-e);break;case"drawPath":t.strokeProgress=e;break;case"particleTrail":t.particleTrailT=e;break}return t}function Ci(o){const e={...mr};switch(o.effect){case"fadeIn":case"slideInLeft":case"slideInRight":case"slideInTop":case"slideInBottom":case"zoomIn":case"expand":e.opacity=0;break;case"drawPath":e.strokeProgress=0;break;case"typewriter":e.typewriterChars=0;break;case"liquidFill":e.liquidFillProgress=0;break}return e}function Si(o){return{rectangle:"rectangle",roundedRect:"roundedRect",ellipse:"ellipse",circle:"circle",diamond:"diamond",hexagon:"hexagon",cylinder:"cylinder",cloud:"cloud",triangle:"triangle"}[o||"rectangle"]||"rectangle"}function Ni(o){return o?{backgroundColor:o.fill,borderColor:o.stroke,borderWidth:o.strokeWidth,fontColor:o.fontColor,fontSize:o.fontSize,borderRadius:o.borderRadius,borderStyle:o.strokeDasharray?"dashed":"solid"}:{}}function _i(o){if(!o)return{};let e="straight";return o.lineType==="orthogonal"?e="orthogonal":o.lineType==="curved"||o.lineType==="bezier"?e="bezier":o.lineType==="step"&&(e="step"),{strokeColor:o.stroke,strokeWidth:o.strokeWidth,strokeDash:o.strokeDasharray?o.strokeDasharray.split(",").map(Number):void 0,lineType:e,sourceArrow:"none",targetArrow:o.arrowHead?"arrow":"none",opacity:o.opacity}}function Mi(o){if(o)return{backgroundColor:o.fill,borderColor:o.stroke,borderWidth:o.strokeWidth}}function pr(o){return{id:o.id,label:o.label,position:{x:o.x,y:o.y},size:{width:o.width,height:o.height},shape:Si(o.shape),style:Ni(o.style),ports:(o.ports||[]).map((e,t)=>({id:e.id,side:e.position||"right",offset:.5})),data:o.data}}function yr(o,e){var s,c;const t=e.find(l=>l.id===o.source),r=e.find(l=>l.id===o.target),i=o.sourcePort||((s=t==null?void 0:t.ports[0])==null?void 0:s.id)||`${o.source}-out`,a=o.targetPort||((c=r==null?void 0:r.ports[0])==null?void 0:c.id)||`${o.target}-in`;return{id:o.id,sourceNodeId:o.source,sourcePortId:i,targetNodeId:o.target,targetPortId:a,label:o.label,style:_i(o.style),data:o.data}}function br(o){return{id:o.id,label:o.label,nodeIds:o.nodeIds,style:Mi(o.style)}}function wr(o){var e;return{id:o.id,name:o.id,targetId:o.targetId||((e=o.targets)==null?void 0:e[0])||"",targetType:"node",effect:o.type==="highlight"?"highlight":"fadeIn",startMs:o.delay,durationMs:o.duration,easing:"easeInOut"}}function Ze(o){const e=o.nodes.map(pr);return e.forEach((t,r)=>{t.ports.length===0&&(t.ports=[{id:`${t.id}-out`,side:"right",offset:.5},{id:`${t.id}-in`,side:"left",offset:.5},{id:`${t.id}-top`,side:"top",offset:.5},{id:`${t.id}-bottom`,side:"bottom",offset:.5}])}),{version:"1.0",id:o.id,title:o.title,diagramType:o.diagramType,nodes:e,edges:o.edges.map(t=>yr(t,e)),groups:(o.groups||[]).map(br),animations:(o.animations||[]).map(wr),viewport:{x:0,y:0,zoom:1},metadata:{createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),...o.metadata}}}const zi=Ze({id:"empty",title:"",diagramType:"flowchart",nodes:[],edges:[]}),Et=({document:o=zi,lang:e="en",autoPlay:t=!1,showControls:r,showGrid:i,showWorkspace:a=!1,className:s,style:c})=>{const l=r??a,u=i??a,[d,b]=p.useState({...o.viewport}),[x,g]=p.useState(new Map),[h,v]=p.useState(!1),_=p.useRef(null),w=p.useCallback(()=>{_.current&&_.current.stop();const C=new gr(o.animations,X=>{g(new Map(X)),C.isPlaying()||v(!1)});_.current=C,C.play(),v(!0)},[o.animations]),m=p.useCallback(()=>{var C;(C=_.current)==null||C.stop(),v(!1),g(new Map)},[]);p.useEffect(()=>(t&&o.animations.length>0&&w(),()=>{var C;(C=_.current)==null||C.stop()}),[t]);const P=p.useCallback(()=>b(C=>({...C,zoom:Math.min(5,C.zoom*1.2)})),[]),k=p.useCallback(()=>b(C=>({...C,zoom:Math.max(.1,C.zoom/1.2)})),[]),j=p.useCallback(()=>b({x:0,y:0,zoom:1}),[]);return n.jsx(jt,{locale:e,children:n.jsxs("div",{className:`nice-diagram-viewer ${s??""}`,style:{display:"flex",flexDirection:"column",height:"100%",...c},children:[l&&n.jsx(Ii,{isPlaying:h,hasAnimations:o.animations.length>0,onPlay:w,onStop:m,onZoomIn:P,onZoomOut:k,onZoomReset:j}),n.jsx("div",{style:{flex:1,position:"relative"},children:n.jsx(Ee,{nodes:o.nodes,edges:o.edges,groups:o.groups,viewport:d,onViewportChange:b,theme:o.theme,animationStates:x,interactive:!1,showGrid:u})})]})})};process.env.NODE_ENV!=="production"&&(Et.displayName="NiceDiagramViewer");const Ii=({isPlaying:o,hasAnimations:e,onPlay:t,onStop:r,onZoomIn:i,onZoomOut:a,onZoomReset:s})=>{const{t:c}=Re();return n.jsxs("div",{className:"nice-diagram-viewer__controls",style:{display:"flex",gap:4,padding:"4px 8px",borderBottom:"1px solid var(--nice-border, #ddd)",background:"var(--nice-bg-secondary, #fafafa)"},children:[e&&(o?n.jsxs(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:r,children:[n.jsx(y.NiceIcon,{name:"stop",size:14})," ",c("animation.stop")]}):n.jsxs(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:t,children:[n.jsx(y.NiceIcon,{name:"play",size:14})," ",c("animation.play")]})),n.jsx("span",{style:{flex:1}}),n.jsx(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:i,"aria-label":c("animation.zoomIn","Zoom in"),children:n.jsx(y.NiceIcon,{name:"plus",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:a,"aria-label":c("animation.zoomOut","Zoom out"),children:n.jsx(y.NiceIcon,{name:"minus",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:s,children:"1:1"})]})},ji="_cell_95fwm_9",Di="_expandable_95fwm_29",Ai="_svg_95fwm_57",$i="_emptyText_95fwm_67",Ti="_badge_95fwm_79",Pi="_expandIcon_95fwm_117",Ei="_modalOverlay_95fwm_169",Ri="_modalContent_95fwm_217",Oi="_modalHeader_95fwm_267",Fi="_modalTitle_95fwm_285",Li="_modalClose_95fwm_299",Wi="_modalBody_95fwm_337",Bi="_modalSvg_95fwm_357",Vi="_modalFooter_95fwm_371",qi="_modalInfo_95fwm_389",De={cell:ji,expandable:Di,svg:Ai,emptyText:$i,badge:Ti,expandIcon:Pi,modalOverlay:Ei,modalContent:Ri,modalHeader:Oi,modalTitle:Fi,modalClose:Li,modalBody:Wi,modalSvg:Bi,modalFooter:Vi,modalInfo:qi},Gi=120,Yi=48,Hi=4,Xt={default:"var(--nice-primary, #3b82f6)",process:"var(--nice-success, #22c55e)",decision:"var(--nice-warning, #f59e0b)",start:"var(--nice-info, #6366f1)",end:"var(--nice-danger, #ef4444)",data:"var(--nice-accent, #8b5cf6)",custom:"var(--nice-text-secondary, #64748b)"};function Rt(o){if(o.length===0)return{minX:0,minY:0,maxX:100,maxY:100,width:100,height:100};let e=1/0,t=1/0,r=-1/0,i=-1/0;for(const a of o){const s=a.position.x,c=a.position.y,l=a.position.x+a.size.width,u=a.position.y+a.size.height;s<e&&(e=s),c<t&&(t=c),l>r&&(r=l),u>i&&(i=u)}return{minX:e,minY:t,maxX:r,maxY:i,width:r-e,height:i-t}}function xr(o){var t;if((t=o.style)!=null&&t.backgroundColor)return o.style.backgroundColor;const e=o.shape??"default";return Xt[e]??Xt.default}function vr(o,e){const t=e.get(o.sourceNodeId),r=e.get(o.targetNodeId);if(!t||!r)return null;const i=t.position.x+t.size.width/2,a=t.position.y+t.size.height/2,s=r.position.x+r.size.width/2,c=r.position.y+r.size.height/2;return`M ${i} ${a} L ${s} ${c}`}function Ui(o,e){const t=Rt(o);return{version:"1.0",id:`mini-diagram-${Date.now()}`,title:"Mini Diagram",diagramType:"flowchart",nodes:o,edges:e,groups:[],viewport:{x:t.minX-20,y:t.minY-20,zoom:1},animations:[],metadata:{createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}}const Xi=({document:o,onClose:e})=>{const{t}=Re(),r=Rt(o.nodes),i=40,a=r.width+i*2,s=r.height+i*2,c=p.useMemo(()=>new Map(o.nodes.map(l=>[l.id,l])),[o.nodes]);return n.jsx("div",{role:"presentation",className:De.modalOverlay,onClick:e,children:n.jsxs("div",{role:"presentation",className:De.modalContent,onClick:l=>l.stopPropagation(),children:[n.jsxs("div",{className:De.modalHeader,children:[n.jsx("h3",{className:De.modalTitle,children:o.title||t("diagramCellRenderer.diagram","Diagram")}),n.jsx("button",{className:De.modalClose,onClick:e,children:n.jsx(y.NiceIcon,{name:"close",size:20})})]}),n.jsx("div",{className:De.modalBody,children:n.jsxs("svg",{viewBox:`${r.minX-i} ${r.minY-i} ${a} ${s}`,className:De.modalSvg,children:[o.edges.map(l=>{var d,b,x;const u=vr(l,c);return u?n.jsx("path",{d:u,stroke:((d=l.style)==null?void 0:d.strokeColor)??"var(--nice-text-secondary, #64748b)",strokeWidth:((b=l.style)==null?void 0:b.strokeWidth)??1.5,fill:"none",markerEnd:(x=l.style)!=null&&x.targetArrow&&l.style.targetArrow!=="none"?"url(#arrowhead-modal)":void 0},l.id):null}),o.nodes.map(l=>{var u,d;return n.jsxs("g",{children:[n.jsx("rect",{x:l.position.x,y:l.position.y,width:l.size.width,height:l.size.height,rx:((u=l.style)==null?void 0:u.borderRadius)??4,fill:xr(l),stroke:((d=l.style)==null?void 0:d.borderColor)??"var(--nice-text, #1e293b)",strokeWidth:1}),n.jsx("text",{x:l.position.x+l.size.width/2,y:l.position.y+l.size.height/2,textAnchor:"middle",dominantBaseline:"middle",fill:"var(--nice-color-white, #fff)",fontSize:12,fontFamily:"system-ui, sans-serif",children:l.label.substring(0,30)})]},l.id)}),n.jsx("defs",{children:n.jsx("marker",{id:"arrowhead-modal",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:n.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"var(--nice-text-secondary, #64748b)"})})})]})}),n.jsx("div",{className:De.modalFooter,children:n.jsx("span",{className:De.modalInfo,children:t("diagramCellRenderer.nodesEdges","{nodes} nodes • {edges} edges").replace("{nodes}",String(o.nodes.length)).replace("{edges}",String(o.edges.length))})})]})})},Ki=({document:o,nodes:e,edges:t,width:r=Gi,height:i=Yi,showCount:a=!0,expandable:s=!0,onExpand:c,padding:l=Hi,backgroundColor:u="transparent",borderRadius:d=4,showLabels:b=!1,edgeColor:x="var(--nice-text-muted, #94a3b8)",tooltip:g})=>{const{t:h}=Re(),[v,_]=p.useState(!1),w=p.useMemo(()=>o||(e||t?Ui(e??[],t??[]):null),[o,e,t]),m=p.useMemo(()=>w?new Map(w.nodes.map(V=>[V.id,V])):new Map,[w]),{bounds:P,scale:k,translateX:j,translateY:C}=p.useMemo(()=>{if(!w||w.nodes.length===0)return{bounds:{minX:0,minY:0,width:100,height:100},scale:1,translateX:0,translateY:0};const V=Rt(w.nodes),F=r-l*2,H=i-l*2,I=F/V.width,O=H/V.height,L=Math.min(I,O,1),Y=V.width*L,S=V.height*L,A=(r-Y)/2-V.minX*L,R=(i-S)/2-V.minY*L;return{bounds:V,scale:L,translateX:A,translateY:R}},[w,r,i,l]),X=p.useCallback(()=>{!w||!s||(c?c(w):_(!0))},[w,s,c]);return!w||w.nodes.length===0?n.jsx("div",{className:De.cell,style:{width:r,height:i,backgroundColor:u,borderRadius:d},title:g,children:n.jsx("span",{className:De.emptyText,children:"—"})}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{role:"button",tabIndex:0,onKeyDown:y.clickOnActivationKey,className:`${De.cell} ${s?De.expandable:""}`,style:{width:r,height:i,backgroundColor:u,borderRadius:d},onClick:X,title:g??h("diagramCellRenderer.nodesEdges2","{nodes} nodes, {edges} edges").replace("{nodes}",String(w.nodes.length)).replace("{edges}",String(w.edges.length)),children:[n.jsx("svg",{width:r,height:i,viewBox:`0 0 ${r} ${i}`,className:De.svg,children:n.jsxs("g",{transform:`translate(${j}, ${C}) scale(${k})`,children:[w.edges.map(V=>{const F=vr(V,m);return F?n.jsx("path",{d:F,stroke:x,strokeWidth:1/k,fill:"none"},V.id):null}),w.nodes.map(V=>{const F=xr(V);return n.jsxs("g",{children:[n.jsx("rect",{x:V.position.x,y:V.position.y,width:V.size.width,height:V.size.height,rx:Math.min(4,V.size.width/4),fill:F}),b&&k>.3&&n.jsx("text",{x:V.position.x+V.size.width/2,y:V.position.y+V.size.height/2,textAnchor:"middle",dominantBaseline:"middle",fill:"var(--nice-color-white, #fff)",fontSize:10/k,fontFamily:"system-ui, sans-serif",children:V.label.substring(0,5)})]},V.id)})]})}),a&&n.jsx("span",{className:De.badge,children:w.nodes.length}),s&&n.jsx("span",{className:De.expandIcon,children:n.jsx(y.NiceIcon,{name:"expand",size:12})})]}),v&&w&&n.jsx(Xi,{document:w,onClose:()=>_(!1)})]})};function kr(o,e,t="roundedRect"){const r=[],i=[],a=new Map;for(const s of o){const c=String(s[e.nodeMapping.idField]??"");if(!c)continue;const l=String(s[e.nodeMapping.labelField]??c),u=e.nodeMapping.descriptionField?String(s[e.nodeMapping.descriptionField]??""):void 0,d=e.nodeMapping.iconField?String(s[e.nodeMapping.iconField]??""):void 0,b=e.nodeMapping.colorField?String(s[e.nodeMapping.colorField]??""):void 0,x={id:`data_${c}`,label:l,description:u,icon:d,position:{x:0,y:0},size:{width:180,height:70},shape:t,style:b?{backgroundColor:b}:{},ports:[{id:"top",side:"top",offset:.5},{id:"right",side:"right",offset:.5},{id:"bottom",side:"bottom",offset:.5},{id:"left",side:"left",offset:.5}],data:s};r.push(x),a.set(c,x)}if(e.nodeMapping.parentField)for(const s of o){const c=String(s[e.nodeMapping.idField]??""),l=String(s[e.nodeMapping.parentField]??"");if(!c||!l)continue;const u=a.get(c),d=a.get(l);!u||!d||i.push({id:`edge_${l}_${c}`,sourceNodeId:d.id,sourcePortId:"bottom",targetNodeId:u.id,targetPortId:"top",style:{lineType:"orthogonal",targetArrow:"arrow"}})}if(e.edgeMapping)for(const s of o){const c=String(s[e.edgeMapping.sourceField]??""),l=String(s[e.edgeMapping.targetField]??"");if(!c||!l)continue;const u=a.get(c),d=a.get(l);if(!u||!d)continue;const b=e.edgeMapping.labelField?String(s[e.edgeMapping.labelField]??""):void 0;i.push({id:`edge_${c}_${l}`,sourceNodeId:u.id,sourcePortId:"right",targetNodeId:d.id,targetPortId:"left",label:b,style:{lineType:"bezier",targetArrow:"arrow"}})}return{nodes:r,edges:i}}async function Zi(o,e,t){const r=await fetch(o.sourceUrl,{signal:t});if(!r.ok)throw new Error(`Failed to fetch data: ${r.status} ${r.statusText}`);const i=await r.json(),a=Array.isArray(i)?i:i.value??[];return kr(a,o,e)}const Cr={width:176,height:64},Ke={initial:"var(--nice-color-success)",intermediate:"var(--nice-color-primary)",approval:"var(--nice-color-warning)",final:"var(--nice-text-muted)",error:"var(--nice-color-error)"};function Ji(o){return[{id:"initial",label:o("workflowDesigner.step.initial","Start"),icon:"play",color:Ke.initial,role:"initial"},{id:"intermediate",label:o("workflowDesigner.step.intermediate","State"),icon:"circle",color:Ke.intermediate},{id:"approval",label:o("workflowDesigner.step.approval","Approval"),icon:"check",color:Ke.approval},{id:"final",label:o("workflowDesigner.step.final","End"),icon:"stop",color:Ke.final,role:"final"},{id:"error",label:o("workflowDesigner.step.error","Error"),icon:"error",color:Ke.error,role:"error"}]}const Qi=o=>o.role??(o.id==="initial"||o.id==="final"||o.id==="error"?o.id:"step"),Sr=[{id:"top",side:"top",offset:.5},{id:"right",side:"right",offset:.5},{id:"bottom",side:"bottom",offset:.5},{id:"left",side:"left",offset:.5}];function ea(o,e){const t=new Set(e);if(!t.has(o))return o;for(let r=2;;r++)if(!t.has(`${o} ${r}`))return`${o} ${r}`}function _t(o,e){const t=new Set(e.map(r=>r.id));for(let r=1;;r++)if(!t.has(`${o}-${r}`))return`${o}-${r}`}function ta(o,e,t){return o||{id:"workflow",name:"Workflow",entityType:"generic",version:1,states:(e??[]).map(r=>({id:r.id,name:r.name??r.label??r.id,type:r.type==="start"?"initial":r.type==="end"?"final":r.type??"intermediate",position:{x:r.x??0,y:r.y??0}})),transitions:(t??[]).map((r,i)=>({id:r.id??`t${i}`,fromStateId:r.fromStateId??r.from??r.source,toStateId:r.toStateId??r.to??r.target,name:r.name??r.label??""}))}}function Kt(o,e){const t=new Set(o.states.map(a=>a.id)),r=o.states.map(a=>({id:a.id,label:a.name,position:{x:0,y:0},size:Cr,shape:"roundedRect",style:{},ports:Sr})),i=o.transitions.filter(a=>t.has(a.fromStateId)&&t.has(a.toStateId)).map(a=>({id:a.id,sourceNodeId:a.fromStateId,sourcePortId:"right",targetNodeId:a.toStateId,targetPortId:"left",style:{}}));return Dt(r,i,{algorithm:"dagre",direction:e,nodeSpacing:36,rankSpacing:96})}function ra(o,e,t){const r=[],i=o.states.filter(a=>e(a)==="initial");i.length===0&&r.push({type:"error",message:t("workflowDesigner.val.noInitial","No initial state")}),i.length>1&&r.push({type:"warning",message:t("workflowDesigner.val.multiInitial","More than one initial state")}),o.states.some(a=>e(a)==="final")||r.push({type:"error",message:t("workflowDesigner.val.noFinal","No final state")});for(const a of o.states){const s=e(a);s!=="final"&&s!=="error"&&!o.transitions.some(c=>c.fromStateId===a.id)&&r.push({type:"warning",message:t("workflowDesigner.val.deadEnd",'State "{name}" has no outgoing transitions (dead-end)').replace("{name}",a.name),stateId:a.id}),s!=="initial"&&!o.transitions.some(c=>c.toStateId===a.id)&&r.push({type:"warning",message:t("workflowDesigner.val.orphan",'State "{name}" is unreachable (orphan)').replace("{name}",a.name),stateId:a.id})}return r}const oa=[{target:".nice-workflow-designer",titleKey:"tutorial.workflowDesigner.intro.title",title:"Workflow designer",contentKey:"tutorial.workflowDesigner.intro.content",content:"Add states and transitions on the canvas, validate the flow, simulate it, then test or publish your workflow.",placement:"auto"},{target:".nice-workflow-designer__toolbar",titleKey:"tutorial.workflowDesigner.toolbar.title",title:"Toolbar",contentKey:"tutorial.workflowDesigner.toolbar.content",content:"Add states and approvals, run a simulation, then test or publish the workflow.",placement:"bottom"},{target:".nice-workflow-designer__canvas",titleKey:"tutorial.workflowDesigner.canvas.title",title:"Canvas",contentKey:"tutorial.workflowDesigner.flow.content",content:"The flow lays itself out. Click a step to edit it and its transitions; drag from a step’s dot onto another step to connect them.",placement:"auto"}],ia=.1,aa=3,Nr=({workflow:o,nodes:e,edges:t,onChange:r,readOnly:i=!1,showMinimap:a=!0,showToolbar:s=!0,showValidation:c=!0,onTest:l,onPublish:u,tutorial:d,stepTypes:b,loadStepTypes:x,layoutDirection:g="LR",className:h,style:v,"data-testid":_})=>{const{t:w}=y.useNiceTranslation(),m=p.useRef(null);y.useRovingFocus(m,{orientation:"horizontal",itemSelector:'button, [role="menuitem"]'});const P=p.useMemo(()=>ta(o,e,t),[o,e,t]),[k,j]=p.useState(P),C=p.useRef(null),X=p.useRef(JSON.stringify(P));p.useEffect(()=>{const M=JSON.stringify(P);M!==X.current&&(X.current=M,P!==C.current&&j(P))},[P]);const V=p.useRef(x),[F,H]=p.useState(null),[I,O]=p.useState(!!x);p.useEffect(()=>{const M=V.current;if(!M)return;let $=!0;return M().then(J=>$&&H(J)).catch(()=>{}).finally(()=>$&&O(!1)),()=>{$=!1}},[]);const L=p.useMemo(()=>{const M=b??Ji(w);if(!F)return M;const $=new Map(M.map(J=>[J.id,J]));for(const J of F)$.set(J.id,J);return[...$.values()]},[b,F,w]),Y=p.useCallback(M=>L.find($=>$.id===M.type)??{id:M.type,label:M.type,color:Ke[M.type]??Ke.intermediate},[L]),S=p.useCallback(M=>Qi(Y(M)),[Y]),[A,R]=p.useState(null),[q,B]=p.useState(null),K=q!==null,Z=k.states.find(M=>M.id===A),te=k.transitions.find(M=>M.id===A),ge=p.useMemo(()=>Kt(k,g),[k,g]),he=`${k.states.map(M=>M.id).join(",")}|${k.transitions.map(M=>`${M.fromStateId}>${M.toStateId}`).join(",")}|${g}`,Ce=p.useMemo(()=>k.states.map(M=>{const $=Y(M),J=q===M.id;return{id:M.id,label:M.name,description:$.label,position:ge.positions.get(M.id)??M.position,size:Cr,shape:$.shape??"roundedRect",icon:$.icon,style:{backgroundColor:"var(--nice-bg-primary)",borderColor:$.color??Ke.intermediate,borderWidth:J?4:2,borderRadius:10,fontColor:"var(--nice-text-primary)",fontSize:13,fontWeight:"bold",...J?{glowColor:$.color??Ke.intermediate}:{}},ports:Sr}}),[k.states,Y,ge,q]),Ae=p.useMemo(()=>{const M=ge.ranks??new Map,$=new Set(k.states.map(se=>se.id)),J=g==="LR";return k.transitions.filter(se=>$.has(se.fromStateId)&&$.has(se.toStateId)).map(se=>{const Me=se.fromStateId===se.toStateId,Ie=!Me&&(M.get(se.toStateId)??0)<=(M.get(se.fromStateId)??0),[ot,je]=Me?J?["right","top"]:["bottom","right"]:Ie?J?["bottom","bottom"]:["right","right"]:J?["right","left"]:["bottom","top"],Pe=q===se.fromStateId;return{id:se.id,sourceNodeId:se.fromStateId,sourcePortId:ot,targetNodeId:se.toStateId,targetPortId:je,label:se.name||void 0,style:{lineType:"bezier",targetArrow:"arrow",strokeWidth:Pe?2.5:1.5,...Pe?{strokeColor:"var(--nice-color-primary)"}:{}}}})},[k.transitions,k.states,ge,g,q]),$e=p.useRef(r);p.useEffect(()=>{$e.current=r});const me=p.useCallback(M=>{var se;const $=Kt(M,g).positions,J={...M,states:M.states.map(Me=>{const Ie=$.get(Me.id);return Ie?{...Me,position:{x:Math.round(Ie.x),y:Math.round(Ie.y)}}:Me})};C.current=J,j(J),(se=$e.current)==null||se.call($e,J)},[g]),Oe=p.useCallback(M=>{if(i)return;const $=_t("state",k.states),J={id:$,name:ea(M.label,k.states.map(Ie=>Ie.name)),type:M.id,position:{x:0,y:0}},se=k.states.find(Ie=>Ie.id===A),Me=se?[...k.transitions,{id:_t("t",k.transitions),fromStateId:se.id,toStateId:$,name:w("workflowDesigner.next","Next")}]:k.transitions;me({...k,states:[...k.states,J],transitions:Me}),R($)},[i,k,A,me,w]),ve=p.useCallback((M,$)=>me({...k,states:k.states.map(J=>J.id===M?{...J,...$}:J)}),[k,me]),Ue=p.useCallback(M=>{me({...k,states:k.states.filter($=>$.id!==M),transitions:k.transitions.filter($=>$.fromStateId!==M&&$.toStateId!==M)}),R(null)},[k,me]),G=p.useCallback((M,$)=>{var Ie,ot;const J=$?k.transitions.find(je=>je.fromStateId===M&&je.toStateId===$):void 0;if(J){R(J.id);return}const se=new Set(k.transitions.filter(je=>je.fromStateId===M).map(je=>je.toStateId)),Me=$??((Ie=k.states.find(je=>je.id!==M&&!se.has(je.id)))==null?void 0:Ie.id)??((ot=k.states.find(je=>je.id!==M))==null?void 0:ot.id);Me&&me({...k,transitions:[...k.transitions,{id:_t("t",k.transitions),fromStateId:M,toStateId:Me,name:w("workflowDesigner.next","Next")}]})},[k,me,w]),Fe=p.useCallback((M,$)=>me({...k,transitions:k.transitions.map(J=>J.id===M?{...J,...$}:J)}),[k,me]),Le=p.useCallback(M=>{me({...k,transitions:k.transitions.filter($=>$.id!==M)}),A===M&&R(null)},[k,me,A]),Xe=p.useMemo(()=>c?ra(k,S,w):[],[c,k,S,w]),ze=Xe.filter(M=>M.type==="error"),[Ve,Ne]=p.useState({x:0,y:0,zoom:1}),[Je,z]=p.useState(0),[U,ne]=p.useState(null),pe=p.useCallback(M=>Ne($=>{const J=Math.min(aa,Math.max(ia,$.zoom*M)),se=((U==null?void 0:U.width)??0)/2,Me=((U==null?void 0:U.height)??0)/2;return{x:se-(se-$.x)*(J/$.zoom),y:Me-(Me-$.y)*(J/$.zoom),zoom:J}}),[U]),le=p.useCallback(()=>{U&&Ne(Pt(Tt(Ce),U,{maxZoom:1,minZoom:1}))},[U,Ce]),qe=()=>{const M=k.states.find($=>S($)==="initial");M&&(R(null),B(M.id))},Qe=p.useMemo(()=>[{id:"add-step",label:w("workflowDesigner.addStep","Add step"),icon:n.jsx(y.NiceIcon,{name:"plus",size:14}),children:[...L.map(M=>({id:M.id,label:M.label,description:M.description,icon:M.icon?n.jsx(y.NiceIcon,{name:M.icon,size:14}):void 0,onClick:()=>Oe(M)})),...I?[{id:"loading",label:w("workflowDesigner.loadingSteps","Loading step types…"),disabled:!0}]:[]]}],[L,I,Oe,w]),rt=s?n.jsxs("div",{ref:m,className:"nice-workflow-designer__toolbar",role:"toolbar","aria-label":w("workflowDesigner.toolbar","Workflow toolbar"),children:[!i&&!K&&n.jsx(y.NiceMenu,{variant:"ghost",size:"sm",items:Qe,"data-testid":"workflow-add-step"}),n.jsx(y.NiceButton,{size:"sm",variant:"ghost",leftIcon:n.jsx(y.NiceIcon,{name:"play",size:14}),onClick:qe,disabled:ze.length>0||K,children:w("workflowDesigner.simulate","Simulate")}),n.jsx("span",{className:"nice-workflow-designer__spacer"}),n.jsx(y.NiceButton,{size:"sm",variant:"ghost",ariaLabel:w("workflowDesigner.zoomOut","Zoom out"),onClick:()=>pe(1/1.2),children:n.jsx(y.NiceIcon,{name:"zoom-out",size:14})}),n.jsx(y.NiceButton,{size:"sm",variant:"ghost",className:"nice-workflow-designer__zoom",title:w("workflowDesigner.resetView","Reset view"),onClick:le,children:`${Math.round(Ve.zoom*100)}%`}),n.jsx(y.NiceButton,{size:"sm",variant:"ghost",ariaLabel:w("workflowDesigner.zoomIn","Zoom in"),onClick:()=>pe(1.2),children:n.jsx(y.NiceIcon,{name:"zoom-in",size:14})}),n.jsx(y.NiceButton,{size:"sm",variant:"ghost",leftIcon:n.jsx(y.NiceIcon,{name:"expand",size:14}),onClick:()=>z(M=>M+1),children:w("workflowDesigner.fit","Fit to view")}),l&&!i&&n.jsx(y.NiceButton,{size:"sm",variant:"ghost",onClick:()=>l(k),children:w("workflowDesigner.test","Test")}),u&&!i&&n.jsx(y.NiceButton,{size:"sm",variant:"primary",onClick:()=>u(k),disabled:ze.length>0,children:w("workflowDesigner.publish","Publish")})]}):void 0,ee=M=>k.states.filter($=>$.id!==M).map($=>({value:$.id,label:$.name})),Ge=M=>n.jsxs("div",{className:"nice-workflow-designer__props-header",children:[n.jsx("h3",{children:M}),n.jsx("button",{type:"button",className:"nice-workflow-designer__props-close",onClick:()=>R(null),"aria-label":w("workflowDesigner.closeProps","Close properties"),title:w("workflowDesigner.closeProps","Close properties"),children:n.jsx(y.NiceIcon,{name:"close",size:12})})]});let _e;if(!i&&!K&&Z){const M=k.transitions.filter($=>$.fromStateId===Z.id);_e=n.jsxs("aside",{className:"nice-workflow-designer__props","aria-label":w("workflowDesigner.stateProps","State properties"),children:[Ge(Z.name),n.jsx(y.NiceTextInput,{label:w("workflowDesigner.stateName","State name"),size:"sm",value:Z.name,onChange:$=>ve(Z.id,{name:$})}),n.jsx(y.NiceSelect,{label:w("workflowDesigner.stateType","State type"),size:"sm",value:Z.type,options:L.map($=>({value:$.id,label:$.label})),onChange:$=>{const J=Array.isArray($)?$[0]:$;J&&ve(Z.id,{type:String(J)})}}),n.jsx("h4",{className:"nice-workflow-designer__props-section",children:w("workflowDesigner.transitions","Transitions")}),M.length===0&&n.jsx("p",{className:"nice-workflow-designer__props-empty",children:w("workflowDesigner.noTransitions","No transitions yet")}),M.map($=>n.jsxs("div",{className:"nice-workflow-designer__transition","data-transition-id":$.id,children:[n.jsx(y.NiceTextInput,{"aria-label":w("workflowDesigner.transitionName","Transition name"),size:"sm",value:$.name,onChange:J=>Fe($.id,{name:J})}),n.jsx(y.NiceSelect,{"aria-label":w("workflowDesigner.target","To"),size:"sm",value:$.toStateId,options:ee(),onChange:J=>{const se=Array.isArray(J)?J[0]:J;se&&Fe($.id,{toStateId:String(se)})}}),n.jsx(y.NiceButton,{size:"sm",variant:"ghost",ariaLabel:w("workflowDesigner.deleteFlow","Delete flow"),onClick:()=>Le($.id),children:n.jsx(y.NiceIcon,{name:"trash",size:14})})]},$.id)),n.jsx(y.NiceButton,{size:"sm",variant:"secondary",leftIcon:n.jsx(y.NiceIcon,{name:"plus",size:14}),onClick:()=>G(Z.id),disabled:k.states.length<2,children:w("workflowDesigner.addTransition","Add transition")}),n.jsx(y.NiceButton,{size:"sm",variant:"danger",leftIcon:n.jsx(y.NiceIcon,{name:"trash",size:14}),onClick:()=>Ue(Z.id),className:"nice-workflow-designer__props-delete",children:w("workflowDesigner.deleteState","Delete state {name}").replace("{name}",Z.name)})]})}else if(!i&&!K&&te){const M=k.states.find($=>$.id===te.fromStateId);_e=n.jsxs("aside",{className:"nice-workflow-designer__props","aria-label":w("workflowDesigner.properties","Properties"),children:[Ge(w("workflowDesigner.flowOf","Flow: {name}").replace("{name}",te.name||"→")),n.jsx(y.NiceTextInput,{label:w("workflowDesigner.transitionName","Transition name"),size:"sm",value:te.name,onChange:$=>Fe(te.id,{name:$})}),n.jsxs("p",{className:"nice-workflow-designer__props-from",children:[w("workflowDesigner.from","From"),": ",n.jsx("strong",{children:M==null?void 0:M.name})]}),n.jsx(y.NiceSelect,{label:w("workflowDesigner.target","To"),size:"sm",value:te.toStateId,options:ee(),onChange:$=>{const J=Array.isArray($)?$[0]:$;J&&Fe(te.id,{toStateId:String(J)})}}),n.jsx(y.NiceButton,{size:"sm",variant:"danger",leftIcon:n.jsx(y.NiceIcon,{name:"trash",size:14}),onClick:()=>Le(te.id),children:w("workflowDesigner.deleteFlow","Delete flow")})]})}const at=k.states.find(M=>M.id===q),ct=c&&Xe.length>0&&!K,kt=ct||K?n.jsxs(n.Fragment,{children:[ct&&n.jsx("div",{className:"nice-workflow-designer__validation",role:"status","aria-live":"polite",children:Xe.map((M,$)=>{const J=n.jsxs(n.Fragment,{children:[n.jsx(y.NiceIcon,{name:M.type==="error"?"error":"warning",size:14})," ",M.message]}),se=`nice-workflow-designer__issue nice-workflow-designer__issue--${M.type}`;return M.stateId?n.jsx("button",{type:"button",className:se,onClick:()=>R(M.stateId),children:J},$):n.jsx("div",{className:se,children:J},$)})}),K&&n.jsxs("div",{className:"nice-workflow-designer__sim-toolbar",children:[n.jsxs("span",{children:[w("workflowDesigner.simActiveState","Simulation active — current state:")," ",n.jsx("strong",{children:at==null?void 0:at.name})]}),k.transitions.filter(M=>M.fromStateId===q).map(M=>{var $;return n.jsxs("button",{type:"button",className:"nice-workflow-designer__sim-btn",onClick:()=>B(M.toStateId),children:[n.jsx(y.NiceIcon,{name:"arrow-right",size:12})," ",M.name||(($=k.states.find(J=>J.id===M.toStateId))==null?void 0:$.name)]},M.id)}),n.jsx("button",{type:"button",className:"nice-workflow-designer__sim-end",onClick:()=>B(null),children:w("workflowDesigner.endSimulation","End simulation")})]})]}):void 0,Ye=p.useCallback(M=>{K||R(M)},[K]);return n.jsx(y.NiceAppShell,{flush:!0,className:`nice-workflow-designer${i?" nice-workflow-designer--readonly":""} ${h??""}`,style:v,"data-testid":_,toolbar:rt,rightSidebar:_e,bottomPanel:kt,children:n.jsxs("div",{className:"nice-workflow-designer__canvas",children:[n.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:n.jsx(y.NiceTutorialButton,{steps:y.resolveTutorial(d,oa)})}),n.jsx(Ee,{nodes:Ce,edges:Ae,viewport:Ve,onViewportChange:Ne,selectedId:A,onSelectElement:Ye,interactive:!i&&!K,onEdgeCreate:i||K?void 0:(M,$)=>G(M,$),autoFit:!0,fitKey:he,refitKey:Je,onResize:ne,resizable:!1,panOnDrag:!0,ariaLabel:w("workflowDesigner.canvas","Workflow canvas")}),a&&n.jsx("div",{className:"nice-workflow-designer__minimap","aria-label":w("workflowDesigner.minimap","Minimap"),children:n.jsx(lt,{nodes:Ce,edges:Ae,viewport:Ve,onViewportChange:Ne,canvasWidth:U==null?void 0:U.width,canvasHeight:U==null?void 0:U.height})})]})})};process.env.NODE_ENV!=="production"&&(Nr.displayName="NiceWorkflowDesigner");const na={pending:"var(--nice-text-muted, #9ca3af)",active:"var(--nice-primary, #3b82f6)",completed:"var(--nice-success, #10b981)",failed:"var(--nice-danger, #ef4444)",skipped:"var(--nice-warning, #f59e0b)",waiting:"var(--nice-accent, #8b5cf6)"},sa={start:"ellipse",end:"ellipse",task:"rectangle",decision:"diamond",parallel:"rectangle",join:"rectangle",subprocess:"rectangle",timer:"ellipse",message:"rectangle",error:"rectangle"},la={start:"play",end:"stop",task:"clipboard",decision:"help",parallel:"columns",join:"git-branch",subprocess:"box",timer:"clock",message:"mail",error:"warning"},ca=({data:o,onStepClick:e,onTransitionClick:t,autoPlay:r=!1,animationDelay:i=1e3,showTooltips:a=!0,showMinimap:s=!0,statusColors:c=na,typeShapes:l=sa,direction:u="horizontal",className:d,style:b})=>{const[x,g]=p.useState(0),h=p.useMemo(()=>{const m=o.steps.map((j,C)=>{const X=j.id===o.currentStepId,V=j.status||"pending",F=c[V],H=l[j.type],I=u==="horizontal"?C*200:100,O=u==="horizontal"?100:C*150;return{id:j.id,label:j.name,x:I,y:O,width:150,height:60,shape:H,style:{fill:F,stroke:X?"var(--nice-text, #1f2937)":F,strokeWidth:X?3:1,fontColor:"var(--nice-color-white, #fff)",fontSize:12},data:{type:j.type,status:j.status,assignee:j.assignee,dueDate:j.dueDate,icon:la[j.type],...j.metadata},ports:[{id:`${j.id}-in`,position:"left"},{id:`${j.id}-out`,position:"right"}]}}),P=o.transitions.map(j=>{const C=o.steps.find(F=>F.id===j.from),X=o.steps.find(F=>F.id===j.to);let V="var(--nice-text-muted, #9ca3af)";return(C==null?void 0:C.status)==="completed"&&(X==null?void 0:X.status)!=="pending"?V="var(--nice-success, #10b981)":(C==null?void 0:C.status)==="failed"&&(V="var(--nice-danger, #ef4444)"),{id:j.id,source:j.from,target:j.to,sourcePort:`${j.from}-out`,targetPort:`${j.to}-in`,label:j.label||j.condition,style:{stroke:V,strokeWidth:2,arrowHead:"arrow",lineType:"bezier"},data:{condition:j.condition}}}),k=r?da(o.steps):[];return Ze({id:o.id,title:o.name,diagramType:"flowchart",nodes:m,edges:P,animations:k,metadata:{type:"workflow",...o.metadata}})},[o,c,l,u,r]);p.useEffect(()=>{if(!r)return;const m=o.steps.filter(k=>k.status==="completed").length;if(x>=m)return;const P=setTimeout(()=>{g(k=>k+1)},i);return()=>clearTimeout(P)},[r,x,i,o.steps]);const[v,_]=p.useState({x:0,y:0,zoom:1}),w=p.useCallback(m=>{if(m&&e){const P=o.steps.find(k=>k.id===m);P&&e(P)}if(m&&t){const P=o.transitions.find(k=>k.id===m);P&&t(P)}},[o.steps,o.transitions,e,t]);return n.jsx("div",{className:`nice-workflow-visualizer ${d||""}`,style:{position:"relative",width:"100%",height:"100%",...b},children:n.jsx(Ee,{nodes:h.nodes,edges:h.edges,groups:h.groups,viewport:v,onViewportChange:_,onSelectElement:w,showGrid:!0})})};function da(o){return o.filter(t=>t.status==="completed").map((t,r)=>({id:`anim-${t.id}`,targetId:t.id,type:"highlight",delay:r*500,duration:300,easing:"ease-out"}))}function ua(o){var a,s;const t=new DOMParser().parseFromString(o,"text/xml"),r=[],i=[];return t.querySelectorAll("startEvent").forEach(c=>{r.push({id:c.getAttribute("id")||`start-${r.length}`,name:c.getAttribute("name")||"Start",type:"start"})}),t.querySelectorAll("task, userTask, serviceTask").forEach(c=>{r.push({id:c.getAttribute("id")||`task-${r.length}`,name:c.getAttribute("name")||"Task",type:"task"})}),t.querySelectorAll("exclusiveGateway, parallelGateway").forEach(c=>{const l=c.tagName==="parallelGateway";r.push({id:c.getAttribute("id")||`gateway-${r.length}`,name:c.getAttribute("name")||(l?"Parallel":"Decision"),type:l?"parallel":"decision"})}),t.querySelectorAll("endEvent").forEach(c=>{r.push({id:c.getAttribute("id")||`end-${r.length}`,name:c.getAttribute("name")||"End",type:"end"})}),t.querySelectorAll("sequenceFlow").forEach(c=>{i.push({id:c.getAttribute("id")||`flow-${i.length}`,from:c.getAttribute("sourceRef")||"",to:c.getAttribute("targetRef")||"",label:c.getAttribute("name")||void 0})}),{id:((a=t.querySelector("process"))==null?void 0:a.getAttribute("id"))||"workflow",name:((s=t.querySelector("process"))==null?void 0:s.getAttribute("name"))||"Workflow",steps:r,transitions:i}}function fa(o,e){const t=[],r=[];t.push({id:"start",name:"Start",type:"start",status:"completed"}),o.forEach((i,a)=>{t.push({id:`step-${a}`,name:i,type:"task",status:"pending"})}),t.push({id:"end",name:"End",type:"end",status:"pending"}),r.push({id:"start-to-first",from:"start",to:"step-0"});for(let i=0;i<o.length-1;i++)r.push({id:`step-${i}-to-${i+1}`,from:`step-${i}`,to:`step-${i+1}`});return r.push({id:"last-to-end",from:`step-${o.length-1}`,to:"end"}),{id:"linear-workflow",name:"Linear Workflow",steps:t,transitions:r}}const ha={dbo:"var(--nice-primary, #3b82f6)",public:"var(--nice-success, #10b981)",auth:"var(--nice-accent, #8b5cf6)",billing:"var(--nice-warning, #f59e0b)",audit:"var(--nice-danger, #ef4444)"},ma={"one-to-one":{left:"1",right:"1"},"one-to-many":{left:"1",right:"*"},"many-to-one":{left:"*",right:"1"},"many-to-many":{left:"*",right:"*"}},ga=({schema:o,onTableClick:e,onColumnClick:t,onRelationClick:r,showColumnDetails:i=!0,showOnlyKeys:a=!1,highlightTables:s=[],showMinimap:c=!0,schemaColors:l=ha,layout:u="auto",maxColumnsDisplay:d=15,className:b,style:x})=>{const[g,h]=p.useState(null),v=p.useMemo(()=>{const P=pa(o.tables,u),k=o.tables.map((C,X)=>{const V=P[C.name]||{x:X%4*300,y:Math.floor(X/4)*400},F=s.includes(C.name),H=g===C.name,I=l[C.schema||"dbo"]||"var(--nice-text-secondary, #6b7280)";let O=C.columns;a&&(O=O.filter(A=>A.primaryKey||A.foreignKey)),O.length>d&&(O=O.slice(0,d));const L=40,Y=i?28:20,S=L+O.length*Y+10;return{id:C.name,label:C.schema?`${C.schema}.${C.name}`:C.name,x:V.x,y:V.y,width:250,height:S,shape:"rectangle",style:{fill:F||H?I:"var(--nice-bg, #fff)",stroke:I,strokeWidth:H?3:F?2:1,fontColor:F||H?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:14,borderRadius:8},data:{type:"table",schema:C.schema,columns:O.map(A=>({...A,icon:ya(A)})),totalColumns:C.columns.length,truncated:C.columns.length>d,comment:C.comment,...C.metadata},ports:[...C.columns.filter(A=>A.primaryKey).map(A=>({id:`${C.name}.${A.name}-pk`,position:"left"})),...C.columns.filter(A=>A.foreignKey).map(A=>({id:`${C.name}.${A.name}-fk`,position:"right"}))]}}),j=o.relations.map(C=>{const X=ma[C.type];return{id:C.id,source:C.fromTable,target:C.toTable,sourcePort:`${C.fromTable}.${C.fromColumn}-fk`,targetPort:`${C.toTable}.${C.toColumn}-pk`,label:C.name||`${X.left}─${X.right}`,style:{stroke:"var(--nice-text-secondary, #6b7280)",strokeWidth:1.5,arrowHead:ba(C.type),arrowTail:wa(C.type),lineType:"orthogonal",strokeDasharray:C.type==="many-to-many"?"5,5":void 0},data:{type:C.type,fromColumn:C.fromColumn,toColumn:C.toColumn}}});return Ze({id:`schema-${o.name}`,title:o.name,diagramType:"er",nodes:k,edges:j,metadata:{type:"er-diagram",...o.metadata}})},[o,i,a,s,g,l,u,d]),[_,w]=p.useState({x:0,y:0,zoom:1}),m=p.useCallback(P=>{if(P){if(h(k=>k===P?null:P),e){const k=o.tables.find(j=>j.name===P);k&&e(k)}if(r){const k=o.relations.find(j=>j.id===P);k&&r(k)}}},[o.tables,o.relations,e,r]);return n.jsx("div",{className:`nice-database-schema-viewer ${b||""}`,style:{position:"relative",width:"100%",height:"100%",...x},children:n.jsx(Ee,{nodes:v.nodes,edges:v.edges,groups:v.groups,viewport:_,onViewportChange:w,onSelectElement:m,showGrid:!0})})};function pa(o,e){const t={};if(e==="grid"){const r=Math.ceil(Math.sqrt(o.length));o.forEach((i,a)=>{t[i.name]={x:a%r*320+50,y:Math.floor(a/r)*450+50}})}else if(e==="hierarchical"){const r={};o.forEach(a=>{const s=a.schema||"default";r[s]||(r[s]=[]),r[s].push(a)});let i=50;Object.entries(r).forEach(([a,s])=>{s.forEach((c,l)=>{t[c.name]={x:l*320+50,y:i}}),i+=500})}else o.forEach((r,i)=>{const a=i/o.length*2*Math.PI,s=300+o.length*20;t[r.name]={x:Math.cos(a)*s+500,y:Math.sin(a)*s+400}});return t}function ya(o){return o.primaryKey?"lock":o.foreignKey?"link":o.unique?"zap":"file"}function ba(o){switch(o){case"one-to-one":case"many-to-one":return"none";case"one-to-many":case"many-to-many":return"crow"}}function wa(o){switch(o){case"one-to-one":case"one-to-many":return"none";case"many-to-one":case"many-to-many":return"crow"}}function xa(o){const e=[],t=[],r=/CREATE\s+TABLE\s+(?:`?(\w+)`?\.)?`?(\w+)`?\s*\(([\s\S]*?)\);/gi;let i;for(;(i=r.exec(o))!==null;){const a=i[1]||"dbo",s=i[2],c=i[3],l=[],u=/`?(\w+)`?\s+(\w+(?:\([^)]+\))?)\s*(NOT\s+NULL|NULL)?/gi;let d;for(;(d=u.exec(c))!==null;)l.push({name:d[1],type:d[2],nullable:!d[3]||d[3].toUpperCase()!=="NOT NULL"});const b=/PRIMARY\s+KEY\s*\(`?(\w+)`?\)/i.exec(c);if(b){const h=l.find(v=>v.name===b[1]);h&&(h.primaryKey=!0)}const x=/FOREIGN\s+KEY\s*\(`?(\w+)`?\)\s*REFERENCES\s+`?(\w+)`?\s*\(`?(\w+)`?\)/gi;let g;for(;(g=x.exec(c))!==null;){const h=g,v=l.find(_=>_.name===h[1]);v&&(v.foreignKey={table:h[2],column:h[3]},t.push({id:`fk-${s}-${h[1]}`,fromTable:s,fromColumn:h[1],toTable:h[2],toColumn:h[3],type:"many-to-one"}))}e.push({name:s,schema:a,columns:l})}return{name:"Parsed Schema",tables:e,relations:t}}function va(o,e="postgres"){const t=[];for(const r of o.tables){const i=r.schema?`${r.schema}.${r.name}`:r.name;t.push(`CREATE TABLE ${i} (`);const a=r.columns.map(c=>{let l=` ${c.name} ${c.type}`;return c.nullable||(l+=" NOT NULL"),c.primaryKey&&(l+=" PRIMARY KEY"),c.unique&&(l+=" UNIQUE"),c.defaultValue&&(l+=` DEFAULT ${c.defaultValue}`),l}),s=r.columns.filter(c=>c.foreignKey).map(c=>` FOREIGN KEY (${c.name}) REFERENCES ${c.foreignKey.table}(${c.foreignKey.column})`);t.push([...a,...s].join(`,
3
+ `)}function St(o){return o.replace(/[^a-zA-Z0-9_]/g,"_")}function Gt(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const It={en:{"toolbar.select":"Select","toolbar.addNode":"Add Node","toolbar.addEdge":"Add Edge","toolbar.group":"Group","toolbar.ungroup":"Ungroup","toolbar.delete":"Delete","toolbar.undo":"Undo","toolbar.redo":"Redo","toolbar.zoomIn":"Zoom In","toolbar.zoomOut":"Zoom Out","toolbar.fitToScreen":"Fit to Screen","toolbar.export":"Export","toolbar.import":"Import","toolbar.autoLayout":"Auto Layout","toolbar.animations":"Animations","toolbar.dataBinding":"Data Binding","toolbar.pan":"Pan","toolbar.zoomReset":"Reset Zoom","toolbar.layout":"Layout","layout.dagre":"Hierarchical","layout.forceDirected":"Force-Directed","layout.grid":"Grid","layout.radial":"Radial","layout.tree":"Tree","panel.properties":"Properties","panel.style":"Style","panel.animations":"Animations","panel.data":"Data","panel.noSelection":"Select an element to edit its properties","panel.nodeProperties":"Node Properties","panel.edgeProperties":"Edge Properties","node.label":"Label","node.description":"Description","node.shape":"Shape","node.color":"Color","node.border":"Border","node.width":"Width","node.height":"Height","node.bgColor":"Background","node.borderColor":"Border Color","node.fontSize":"Font Size","node.fontColor":"Font Color","node.locked":"Locked","edge.label":"Label","edge.lineType":"Line Type","edge.arrow":"Arrow","edge.color":"Color","edge.width":"Thickness","edge.animated":"Animated","export.svg":"SVG","export.png":"PNG","export.pdf":"PDF","export.mermaid":"Mermaid","export.ndd":"NDD (Native)","viewer.fullscreen":"Fullscreen","viewer.playAnimations":"Play Animations","viewer.stopAnimations":"Stop","viewer.print":"Print","animation.timeline":"Timeline","animation.play":"Play","animation.stop":"Stop","animation.add":"Add","animation.noAnimations":"No animations yet",untitled:"Untitled Diagram","animation.addFromPreset":"Add from preset","animation.presets":"Presets","animation.clickToEdit":"Click to edit","animation.startMs":"Start (ms)","animation.durationMs":"Duration (ms)","node.effects":"Effects","node.glowColor":"Glow Color","node.glowIntensity":"Glow Intensity","node.opacity":"Opacity","node.borderRadius":"Border Radius","node.borderWidth":"Border Width","node.shadow":"Shadow","node.gradientEnd":"Gradient End","node.gradientDir":"Gradient Dir","node.hiddenGhostInEditor":"Hidden (ghost in editor)","node.flowSpeed":"Flow Speed","node.dashStyle":"Dash Style","node.targetArrow":"Target Arrow","node.sourceArrow":"Source Arrow","node.liquidFlow":"Liquid Flow","node.enableLiquidFlow":"Enable Liquid Flow","node.speed":"Speed","node.pipeWidth":"Pipe Width","toolbar.textT":"Text (T)","toolbar.freehandF":"Freehand (F)","toolbar.copyCtrlC":"Copy (Ctrl+C)","toolbar.pasteCtrlV":"Paste (Ctrl+V)","toolbar.duplicateCtrlD":"Duplicate (Ctrl+D)","toolbar.selectAllCtrlA":"Select All (Ctrl+A)","toolbar.findCtrlF":"Find (Ctrl+F)","toolbar.searchNodes":"Search nodes…","toolbar.mermaid":"Mermaid","toolbar.fontFamily":"Font Family","toolbar.fontSize":"Font Size","toolbar.boldCtrlB":"Bold (Ctrl+B)","toolbar.italicCtrlI":"Italic (Ctrl+I)","toolbar.alignmentDistribution":"Alignment & Distribution","toolbar.align":"Align","toolbar.alignLeft":"Align Left","toolbar.left":"Left","toolbar.alignCenter":"Align Center","toolbar.center":"Center","toolbar.alignRight":"Align Right","toolbar.right":"Right","toolbar.alignTop":"Align Top","toolbar.alignMiddle":"Align Middle","toolbar.middle":"Middle","toolbar.alignBottom":"Align Bottom","toolbar.bottom":"Bottom","toolbar.distribute":"Distribute","toolbar.distributeHorizontally":"Distribute Horizontally","toolbar.distributeVertically":"Distribute Vertically","toolbar.arrange":"Arrange","toolbar.editorMode":"Editor Mode","toolbar.editor":"Editor","toolbar.playerMode":"Player Mode","toolbar.player":"Player","toolbar.animatedPlayerMode":"Animated Player Mode","toolbar.animated":"Animated","toolbar.stylePresets":"Style Presets","toolbar.style":"Style","diagramEditor.addAnimationMode":"Add animation mode","animation.zoomIn":"Zoom in","animation.zoomOut":"Zoom out","toolbar.bringToFront":"Bring to Front","toolbar.sendToBack":"Send to Back","diagramCellRenderer.diagram":"Diagram","diagramCellRenderer.nodesEdges":"{nodes} nodes • {edges} edges","diagramCellRenderer.nodesEdges2":"{nodes} nodes, {edges} edges","node.vertical":"Vertical","node.horizontal":"Horizontal","node.diagonal":"Diagonal","node.radial":"Radial","node.straight":"Straight","node.bezier":"Bezier","node.orthogonal":"Orthogonal","node.step":"Step","node.solid":"Solid","node.dashed":"Dashed","node.dotted":"Dotted","node.dashDot":"Dash-Dot","node.longDash":"Long Dash","node.arrow":"Arrow","node.openArrow":"Open Arrow","node.diamond":"Diamond","node.circle":"Circle","node.none":"None","toolbar.top":"Top","toolbar.selected":"{selectionCount} selected","decisionTreeEditor.decisionTree":"Decision Tree","dependencyGraph.optional":"(optional)","dependencyGraph.dependencyGraph":"Dependency Graph","diagramEditor.modes":"Modes:","networkTopology.networkTopology":"Network Topology","orgChartVisualizer.organizationChart":"Organization Chart","processMiningDiagram.processMiningDiagram":"Process Mining Diagram","workflowDesigner.step.initial":"Start","workflowDesigner.step.intermediate":"State","workflowDesigner.step.approval":"Approval","workflowDesigner.step.final":"End","workflowDesigner.step.error":"Error","workflowDesigner.val.noInitial":"No initial state","workflowDesigner.val.multiInitial":"More than one initial state","workflowDesigner.val.noFinal":"No final state","workflowDesigner.val.deadEnd":'State "{name}" has no outgoing transitions (dead-end)',"workflowDesigner.val.orphan":'State "{name}" is unreachable (orphan)',"workflowDesigner.next":"Next","workflowDesigner.addStep":"Add step","workflowDesigner.loadingSteps":"Loading step types…","workflowDesigner.toolbar":"Workflow toolbar","workflowDesigner.simulate":"Simulate","workflowDesigner.zoomOut":"Zoom out","workflowDesigner.resetView":"Reset view","workflowDesigner.zoomIn":"Zoom in","workflowDesigner.fit":"Fit to view","workflowDesigner.test":"Test","workflowDesigner.publish":"Publish","workflowDesigner.closeProps":"Close properties","workflowDesigner.stateProps":"State properties","workflowDesigner.stateName":"State name","workflowDesigner.stateType":"State type","workflowDesigner.transitions":"Transitions","workflowDesigner.noTransitions":"No transitions yet","workflowDesigner.transitionName":"Transition name","workflowDesigner.target":"To","workflowDesigner.deleteFlow":"Delete flow","workflowDesigner.addTransition":"Add transition","workflowDesigner.deleteState":"Delete state {name}","workflowDesigner.properties":"Properties","workflowDesigner.flowOf":"Flow: {name}","workflowDesigner.from":"From","workflowDesigner.simActiveState":"Simulation active — current state:","workflowDesigner.endSimulation":"End simulation","workflowDesigner.canvas":"Workflow canvas","workflowDesigner.minimap":"Minimap","diagramEditor.nodeTypes":"Add a node"},pl:{"toolbar.select":"Zaznacz","toolbar.addNode":"Dodaj węzeł","toolbar.addEdge":"Dodaj połączenie","toolbar.group":"Grupuj","toolbar.ungroup":"Rozgrupuj","toolbar.delete":"Usuń","toolbar.undo":"Cofnij","toolbar.redo":"Ponów","toolbar.zoomIn":"Powiększ","toolbar.zoomOut":"Pomniejsz","toolbar.fitToScreen":"Dopasuj do ekranu","toolbar.export":"Eksportuj","toolbar.import":"Importuj","toolbar.autoLayout":"Auto układ","toolbar.animations":"Animacje","toolbar.dataBinding":"Dane","toolbar.pan":"Przesuń","toolbar.zoomReset":"Przywróć powiększenie","toolbar.layout":"Układ","layout.dagre":"Hierarchiczny","layout.forceDirected":"Siłowy","layout.grid":"Siatka","layout.radial":"Promieniowy","layout.tree":"Drzewo","panel.properties":"Właściwości","panel.style":"Styl","panel.animations":"Animacje","panel.data":"Dane","panel.noSelection":"Zaznacz element, aby edytować jego właściwości","panel.nodeProperties":"Właściwości węzła","panel.edgeProperties":"Właściwości połączenia","node.label":"Etykieta","node.description":"Opis","node.shape":"Kształt","node.color":"Kolor","node.border":"Obramowanie","node.width":"Szerokość","node.height":"Wysokość","node.bgColor":"Tło","node.borderColor":"Kolor obramowania","node.fontSize":"Rozmiar czcionki","node.fontColor":"Kolor czcionki","node.locked":"Zablokowany","edge.label":"Etykieta","edge.lineType":"Typ linii","edge.arrow":"Strzałka","edge.color":"Kolor","edge.width":"Grubość","edge.animated":"Animowane","export.svg":"SVG","export.png":"PNG","export.pdf":"PDF","export.mermaid":"Mermaid","export.ndd":"NDD (Natywny)","viewer.fullscreen":"Pełny ekran","viewer.playAnimations":"Odtwórz animacje","viewer.stopAnimations":"Zatrzymaj","viewer.print":"Drukuj","animation.timeline":"Oś czasu","animation.play":"Odtwórz","animation.stop":"Zatrzymaj","animation.add":"Dodaj","animation.noAnimations":"Brak animacji",untitled:"Diagram bez nazwy","animation.addFromPreset":"Dodaj z gotowych","animation.presets":"Gotowe","animation.clickToEdit":"Kliknij, aby edytować","animation.startMs":"Początek (ms)","animation.durationMs":"Czas trwania (ms)","node.effects":"Efekty","node.glowColor":"Kolor poświaty","node.glowIntensity":"Siła poświaty","node.opacity":"Krycie","node.borderRadius":"Zaokrąglenie rogów","node.borderWidth":"Grubość obramowania","node.shadow":"Cień","node.gradientEnd":"Koniec gradientu","node.gradientDir":"Kierunek gradientu","node.hiddenGhostInEditor":"Ukryty (półprzezroczysty w edytorze)","node.flowSpeed":"Prędkość przepływu","node.dashStyle":"Styl kreski","node.targetArrow":"Grot końcowy","node.sourceArrow":"Grot początkowy","node.liquidFlow":"Przepływ cieczy","node.enableLiquidFlow":"Włącz przepływ cieczy","node.speed":"Prędkość","node.pipeWidth":"Szerokość rury","toolbar.textT":"Tekst (T)","toolbar.freehandF":"Odręcznie (F)","toolbar.copyCtrlC":"Kopiuj (Ctrl+C)","toolbar.pasteCtrlV":"Wklej (Ctrl+V)","toolbar.duplicateCtrlD":"Duplikuj (Ctrl+D)","toolbar.selectAllCtrlA":"Zaznacz wszystko (Ctrl+A)","toolbar.findCtrlF":"Znajdź (Ctrl+F)","toolbar.searchNodes":"Szukaj węzłów…","toolbar.mermaid":"Mermaid","toolbar.fontFamily":"Krój czcionki","toolbar.fontSize":"Rozmiar czcionki","toolbar.boldCtrlB":"Pogrubienie (Ctrl+B)","toolbar.italicCtrlI":"Kursywa (Ctrl+I)","toolbar.alignmentDistribution":"Wyrównanie i rozmieszczenie","toolbar.align":"Wyrównaj","toolbar.alignLeft":"Wyrównaj do lewej","toolbar.left":"Do lewej","toolbar.alignCenter":"Wyśrodkuj w poziomie","toolbar.center":"Środek","toolbar.alignRight":"Wyrównaj do prawej","toolbar.right":"Do prawej","toolbar.alignTop":"Wyrównaj do góry","toolbar.alignMiddle":"Wyśrodkuj w pionie","toolbar.middle":"Środek","toolbar.alignBottom":"Wyrównaj do dołu","toolbar.bottom":"Dół","toolbar.distribute":"Rozmieść","toolbar.distributeHorizontally":"Rozmieść w poziomie","toolbar.distributeVertically":"Rozmieść w pionie","toolbar.arrange":"Ułóż","toolbar.editorMode":"Tryb edycji","toolbar.editor":"Edytor","toolbar.playerMode":"Tryb odtwarzania","toolbar.player":"Odtwarzacz","toolbar.animatedPlayerMode":"Tryb odtwarzania z animacją","toolbar.animated":"Z animacją","toolbar.stylePresets":"Gotowe style","toolbar.style":"Styl","diagramEditor.addAnimationMode":"Dodaj tryb animacji","animation.zoomIn":"Powiększ","animation.zoomOut":"Pomniejsz","toolbar.bringToFront":"Na wierzch","toolbar.sendToBack":"Na spód","diagramCellRenderer.diagram":"Diagram","diagramCellRenderer.nodesEdges":"Węzły: {nodes} • krawędzie: {edges}","diagramCellRenderer.nodesEdges2":"Węzły: {nodes}, krawędzie: {edges}","node.vertical":"Pionowo","node.horizontal":"Poziomo","node.diagonal":"Ukośnie","node.radial":"Promieniście","node.straight":"Prosta","node.bezier":"Krzywa Béziera","node.orthogonal":"Ortogonalna","node.step":"Schodkowa","node.solid":"Ciągła","node.dashed":"Kreskowana","node.dotted":"Kropkowana","node.dashDot":"Kreska-kropka","node.longDash":"Długa kreska","node.arrow":"Strzałka","node.openArrow":"Strzałka otwarta","node.diamond":"Romb","node.circle":"Koło","node.none":"Brak","toolbar.top":"Do góry","toolbar.selected":"Zaznaczono: {selectionCount}","decisionTreeEditor.decisionTree":"Drzewo decyzyjne","dependencyGraph.optional":"(opcjonalna)","dependencyGraph.dependencyGraph":"Graf zależności","diagramEditor.modes":"Tryby:","networkTopology.networkTopology":"Topologia sieci","orgChartVisualizer.organizationChart":"Schemat organizacyjny","processMiningDiagram.processMiningDiagram":"Diagram eksploracji procesów"},de:{"toolbar.select":"Auswählen","toolbar.addNode":"Knoten hinzufügen","toolbar.addEdge":"Kante hinzufügen","toolbar.group":"Gruppieren","toolbar.ungroup":"Gruppierung aufheben","toolbar.delete":"Löschen","toolbar.undo":"Rückgängig","toolbar.redo":"Wiederholen","toolbar.zoomIn":"Vergrößern","toolbar.zoomOut":"Verkleinern","toolbar.fitToScreen":"An Bildschirm anpassen","toolbar.export":"Exportieren","toolbar.import":"Importieren","toolbar.autoLayout":"Automatisches Layout","toolbar.animations":"Animationen","toolbar.dataBinding":"Datenbindung","toolbar.pan":"Verschieben","toolbar.zoomReset":"Zoom zurücksetzen","toolbar.layout":"Layout","layout.dagre":"Hierarchisch","layout.forceDirected":"Kräftebasiert","layout.grid":"Raster","layout.radial":"Radial","layout.tree":"Baum","panel.properties":"Eigenschaften","panel.style":"Stil","panel.animations":"Animationen","panel.data":"Daten","panel.noSelection":"Wählen Sie ein Element aus, um seine Eigenschaften zu bearbeiten","panel.nodeProperties":"Knoteneigenschaften","panel.edgeProperties":"Kanteneigenschaften","node.label":"Bezeichnung","node.description":"Beschreibung","node.shape":"Form","node.color":"Farbe","node.border":"Rahmen","node.width":"Breite","node.height":"Höhe","node.bgColor":"Hintergrund","node.borderColor":"Rahmenfarbe","node.fontSize":"Schriftgröße","node.fontColor":"Schriftfarbe","node.locked":"Gesperrt","edge.label":"Bezeichnung","edge.lineType":"Linientyp","edge.arrow":"Pfeil","edge.color":"Farbe","edge.width":"Stärke","edge.animated":"Animiert","export.svg":"SVG","export.png":"PNG","export.pdf":"PDF","export.mermaid":"Mermaid","export.ndd":"NDD (Nativ)","viewer.fullscreen":"Vollbild","viewer.playAnimations":"Animationen abspielen","viewer.stopAnimations":"Stopp","viewer.print":"Drucken","animation.timeline":"Zeitleiste","animation.play":"Abspielen","animation.stop":"Stopp","animation.add":"Hinzufügen","animation.noAnimations":"Noch keine Animationen",untitled:"Unbenanntes Diagramm","animation.addFromPreset":"Aus Vorlage hinzufügen","animation.presets":"Vorlagen","animation.clickToEdit":"Zum Bearbeiten klicken","animation.startMs":"Start (ms)","animation.durationMs":"Dauer (ms)","node.effects":"Effekte","node.glowColor":"Leuchtfarbe","node.glowIntensity":"Leuchtstärke","node.opacity":"Deckkraft","node.borderRadius":"Eckenradius","node.borderWidth":"Rahmenbreite","node.shadow":"Schatten","node.gradientEnd":"Verlaufsende","node.gradientDir":"Verlaufsrichtung","node.hiddenGhostInEditor":"Ausgeblendet (im Editor transparent)","node.flowSpeed":"Flussgeschwindigkeit","node.dashStyle":"Strichart","node.targetArrow":"Pfeil am Ziel","node.sourceArrow":"Pfeil an der Quelle","node.liquidFlow":"Flüssigkeitsfluss","node.enableLiquidFlow":"Flüssigkeitsfluss aktivieren","node.speed":"Geschwindigkeit","node.pipeWidth":"Rohrbreite","toolbar.textT":"Text (T)","toolbar.freehandF":"Freihand (F)","toolbar.copyCtrlC":"Kopieren (Strg+C)","toolbar.pasteCtrlV":"Einfügen (Strg+V)","toolbar.duplicateCtrlD":"Duplizieren (Strg+D)","toolbar.selectAllCtrlA":"Alles auswählen (Strg+A)","toolbar.findCtrlF":"Suchen (Strg+F)","toolbar.searchNodes":"Knoten suchen…","toolbar.mermaid":"Mermaid","toolbar.fontFamily":"Schriftart","toolbar.fontSize":"Schriftgröße","toolbar.boldCtrlB":"Fett (Strg+B)","toolbar.italicCtrlI":"Kursiv (Strg+I)","toolbar.alignmentDistribution":"Ausrichten & Verteilen","toolbar.align":"Ausrichten","toolbar.alignLeft":"Links ausrichten","toolbar.left":"Links","toolbar.alignCenter":"Horizontal zentrieren","toolbar.center":"Mitte","toolbar.alignRight":"Rechts ausrichten","toolbar.right":"Rechts","toolbar.alignTop":"Oben ausrichten","toolbar.alignMiddle":"Vertikal zentrieren","toolbar.middle":"Mitte","toolbar.alignBottom":"Unten ausrichten","toolbar.bottom":"Unten","toolbar.distribute":"Verteilen","toolbar.distributeHorizontally":"Horizontal verteilen","toolbar.distributeVertically":"Vertikal verteilen","toolbar.arrange":"Anordnen","toolbar.editorMode":"Bearbeitungsmodus","toolbar.editor":"Editor","toolbar.playerMode":"Wiedergabemodus","toolbar.player":"Player","toolbar.animatedPlayerMode":"Animierter Wiedergabemodus","toolbar.animated":"Animiert","toolbar.stylePresets":"Stilvorlagen","toolbar.style":"Stil","diagramEditor.addAnimationMode":"Animationsmodus hinzufügen","animation.zoomIn":"Vergrößern","animation.zoomOut":"Verkleinern","toolbar.bringToFront":"In den Vordergrund","toolbar.sendToBack":"In den Hintergrund","diagramCellRenderer.diagram":"Diagramm","diagramCellRenderer.nodesEdges":"{nodes} Knoten • {edges} Kanten","diagramCellRenderer.nodesEdges2":"{nodes} Knoten, {edges} Kanten","node.vertical":"Vertikal","node.horizontal":"Horizontal","node.diagonal":"Diagonal","node.radial":"Radial","node.straight":"Gerade","node.bezier":"Bézier","node.orthogonal":"Orthogonal","node.step":"Stufen","node.solid":"Durchgezogen","node.dashed":"Gestrichelt","node.dotted":"Gepunktet","node.dashDot":"Strichpunkt","node.longDash":"Langer Strich","node.arrow":"Pfeil","node.openArrow":"Offener Pfeil","node.diamond":"Raute","node.circle":"Kreis","node.none":"Keine","toolbar.top":"Oben","toolbar.selected":"{selectionCount} ausgewählt","decisionTreeEditor.decisionTree":"Entscheidungsbaum","dependencyGraph.optional":"(optional)","dependencyGraph.dependencyGraph":"Abhängigkeitsgraph","diagramEditor.modes":"Modi:","networkTopology.networkTopology":"Netzwerktopologie","orgChartVisualizer.organizationChart":"Organigramm","processMiningDiagram.processMiningDiagram":"Process-Mining-Diagramm"},fr:{"toolbar.select":"Sélectionner","toolbar.addNode":"Ajouter un nœud","toolbar.addEdge":"Ajouter une arête","toolbar.group":"Grouper","toolbar.ungroup":"Dégrouper","toolbar.delete":"Supprimer","toolbar.undo":"Annuler","toolbar.redo":"Rétablir","toolbar.zoomIn":"Agrandir","toolbar.zoomOut":"Réduire","toolbar.fitToScreen":"Ajuster à l'écran","toolbar.export":"Exporter","toolbar.import":"Importer","toolbar.autoLayout":"Mise en page auto","toolbar.animations":"Animations","toolbar.dataBinding":"Liaison de données","toolbar.pan":"Déplacer","toolbar.zoomReset":"Réinitialiser le zoom","toolbar.layout":"Disposition","layout.dagre":"Hiérarchique","layout.forceDirected":"Force dirigée","layout.grid":"Grille","layout.radial":"Radial","layout.tree":"Arbre","panel.properties":"Propriétés","panel.style":"Style","panel.animations":"Animations","panel.data":"Données","panel.noSelection":"Sélectionnez un élément pour modifier ses propriétés","panel.nodeProperties":"Propriétés du nœud","panel.edgeProperties":"Propriétés de l'arête","node.label":"Étiquette","node.description":"Description","node.shape":"Forme","node.color":"Couleur","node.border":"Bordure","node.width":"Largeur","node.height":"Hauteur","node.bgColor":"Arrière-plan","node.borderColor":"Couleur de bordure","node.fontSize":"Taille de police","node.fontColor":"Couleur de police","node.locked":"Verrouillé","edge.label":"Étiquette","edge.lineType":"Type de ligne","edge.arrow":"Flèche","edge.color":"Couleur","edge.width":"Épaisseur","edge.animated":"Animée","export.svg":"SVG","export.png":"PNG","export.pdf":"PDF","export.mermaid":"Mermaid","export.ndd":"NDD (Natif)","viewer.fullscreen":"Plein écran","viewer.playAnimations":"Lire les animations","viewer.stopAnimations":"Arrêter","viewer.print":"Imprimer","animation.timeline":"Chronologie","animation.play":"Lire","animation.stop":"Arrêter","animation.add":"Ajouter","animation.noAnimations":"Aucune animation",untitled:"Diagramme sans titre","animation.addFromPreset":"Ajouter depuis un préréglage","animation.presets":"Préréglages","animation.clickToEdit":"Cliquer pour modifier","animation.startMs":"Début (ms)","animation.durationMs":"Durée (ms)","node.effects":"Effets","node.glowColor":"Couleur de lueur","node.glowIntensity":"Intensité de la lueur","node.opacity":"Opacité","node.borderRadius":"Rayon des coins","node.borderWidth":"Épaisseur de bordure","node.shadow":"Ombre","node.gradientEnd":"Fin du dégradé","node.gradientDir":"Direction du dégradé","node.hiddenGhostInEditor":"Masqué (fantôme dans l'éditeur)","node.flowSpeed":"Vitesse du flux","node.dashStyle":"Style de tirets","node.targetArrow":"Flèche cible","node.sourceArrow":"Flèche source","node.liquidFlow":"Flux liquide","node.enableLiquidFlow":"Activer le flux liquide","node.speed":"Vitesse","node.pipeWidth":"Largeur du tuyau","toolbar.textT":"Texte (T)","toolbar.freehandF":"Main levée (F)","toolbar.copyCtrlC":"Copier (Ctrl+C)","toolbar.pasteCtrlV":"Coller (Ctrl+V)","toolbar.duplicateCtrlD":"Dupliquer (Ctrl+D)","toolbar.selectAllCtrlA":"Tout sélectionner (Ctrl+A)","toolbar.findCtrlF":"Rechercher (Ctrl+F)","toolbar.searchNodes":"Rechercher des nœuds…","toolbar.mermaid":"Mermaid","toolbar.fontFamily":"Police","toolbar.fontSize":"Taille de police","toolbar.boldCtrlB":"Gras (Ctrl+B)","toolbar.italicCtrlI":"Italique (Ctrl+I)","toolbar.alignmentDistribution":"Alignement et répartition","toolbar.align":"Aligner","toolbar.alignLeft":"Aligner à gauche","toolbar.left":"Gauche","toolbar.alignCenter":"Centrer horizontalement","toolbar.center":"Centre","toolbar.alignRight":"Aligner à droite","toolbar.right":"Droite","toolbar.alignTop":"Aligner en haut","toolbar.alignMiddle":"Centrer verticalement","toolbar.middle":"Milieu","toolbar.alignBottom":"Aligner en bas","toolbar.bottom":"Bas","toolbar.distribute":"Répartir","toolbar.distributeHorizontally":"Répartir horizontalement","toolbar.distributeVertically":"Répartir verticalement","toolbar.arrange":"Organiser","toolbar.editorMode":"Mode édition","toolbar.editor":"Éditeur","toolbar.playerMode":"Mode lecture","toolbar.player":"Lecteur","toolbar.animatedPlayerMode":"Mode lecture animé","toolbar.animated":"Animé","toolbar.stylePresets":"Styles prédéfinis","toolbar.style":"Style","diagramEditor.addAnimationMode":"Ajouter un mode d'animation","animation.zoomIn":"Zoom avant","animation.zoomOut":"Zoom arrière","toolbar.bringToFront":"Mettre au premier plan","toolbar.sendToBack":"Mettre à l'arrière-plan","diagramCellRenderer.diagram":"Diagramme","diagramCellRenderer.nodesEdges":"{nodes} nœuds • {edges} arêtes","diagramCellRenderer.nodesEdges2":"{nodes} nœuds, {edges} arêtes","node.vertical":"Vertical","node.horizontal":"Horizontal","node.diagonal":"Diagonal","node.radial":"Radial","node.straight":"Droite","node.bezier":"Bézier","node.orthogonal":"Orthogonale","node.step":"En escalier","node.solid":"Continue","node.dashed":"Tirets","node.dotted":"Pointillés","node.dashDot":"Tiret-point","node.longDash":"Tiret long","node.arrow":"Flèche","node.openArrow":"Flèche ouverte","node.diamond":"Losange","node.circle":"Cercle","node.none":"Aucune","toolbar.top":"Haut","toolbar.selected":"{selectionCount} sélectionnés","decisionTreeEditor.decisionTree":"Arbre de décision","dependencyGraph.optional":"(facultative)","dependencyGraph.dependencyGraph":"Graphe de dépendances","diagramEditor.modes":"Modes :","networkTopology.networkTopology":"Topologie réseau","orgChartVisualizer.organizationChart":"Organigramme","processMiningDiagram.processMiningDiagram":"Diagramme de process mining"},es:{"toolbar.select":"Seleccionar","toolbar.addNode":"Añadir nodo","toolbar.addEdge":"Añadir arista","toolbar.group":"Agrupar","toolbar.ungroup":"Desagrupar","toolbar.delete":"Eliminar","toolbar.undo":"Deshacer","toolbar.redo":"Rehacer","toolbar.zoomIn":"Ampliar","toolbar.zoomOut":"Reducir","toolbar.fitToScreen":"Ajustar a pantalla","toolbar.export":"Exportar","toolbar.import":"Importar","toolbar.autoLayout":"Diseño automático","toolbar.animations":"Animaciones","toolbar.dataBinding":"Enlace de datos","toolbar.pan":"Desplazar","toolbar.zoomReset":"Restablecer zoom","toolbar.layout":"Diseño","layout.dagre":"Jerárquico","layout.forceDirected":"Fuerza dirigida","layout.grid":"Cuadrícula","layout.radial":"Radial","layout.tree":"Árbol","panel.properties":"Propiedades","panel.style":"Estilo","panel.animations":"Animaciones","panel.data":"Datos","panel.noSelection":"Selecciona un elemento para editar sus propiedades","panel.nodeProperties":"Propiedades del nodo","panel.edgeProperties":"Propiedades de la arista","node.label":"Etiqueta","node.description":"Descripción","node.shape":"Forma","node.color":"Color","node.border":"Borde","node.width":"Ancho","node.height":"Alto","node.bgColor":"Fondo","node.borderColor":"Color del borde","node.fontSize":"Tamaño de fuente","node.fontColor":"Color de fuente","node.locked":"Bloqueado","edge.label":"Etiqueta","edge.lineType":"Tipo de línea","edge.arrow":"Flecha","edge.color":"Color","edge.width":"Grosor","edge.animated":"Animada","export.svg":"SVG","export.png":"PNG","export.pdf":"PDF","export.mermaid":"Mermaid","export.ndd":"NDD (Nativo)","viewer.fullscreen":"Pantalla completa","viewer.playAnimations":"Reproducir animaciones","viewer.stopAnimations":"Detener","viewer.print":"Imprimir","animation.timeline":"Línea de tiempo","animation.play":"Reproducir","animation.stop":"Detener","animation.add":"Añadir","animation.noAnimations":"Sin animaciones",untitled:"Diagrama sin título","animation.addFromPreset":"Añadir desde un preajuste","animation.presets":"Preajustes","animation.clickToEdit":"Haz clic para editar","animation.startMs":"Inicio (ms)","animation.durationMs":"Duración (ms)","node.effects":"Efectos","node.glowColor":"Color del brillo","node.glowIntensity":"Intensidad del brillo","node.opacity":"Opacidad","node.borderRadius":"Radio del borde","node.borderWidth":"Grosor del borde","node.shadow":"Sombra","node.gradientEnd":"Fin del degradado","node.gradientDir":"Dirección del degradado","node.hiddenGhostInEditor":"Oculto (fantasma en el editor)","node.flowSpeed":"Velocidad del flujo","node.dashStyle":"Estilo de trazo","node.targetArrow":"Flecha de destino","node.sourceArrow":"Flecha de origen","node.liquidFlow":"Flujo de líquido","node.enableLiquidFlow":"Activar flujo de líquido","node.speed":"Velocidad","node.pipeWidth":"Ancho de tubería","toolbar.textT":"Texto (T)","toolbar.freehandF":"A mano alzada (F)","toolbar.copyCtrlC":"Copiar (Ctrl+C)","toolbar.pasteCtrlV":"Pegar (Ctrl+V)","toolbar.duplicateCtrlD":"Duplicar (Ctrl+D)","toolbar.selectAllCtrlA":"Seleccionar todo (Ctrl+A)","toolbar.findCtrlF":"Buscar (Ctrl+F)","toolbar.searchNodes":"Buscar nodos…","toolbar.mermaid":"Mermaid","toolbar.fontFamily":"Fuente","toolbar.fontSize":"Tamaño de fuente","toolbar.boldCtrlB":"Negrita (Ctrl+B)","toolbar.italicCtrlI":"Cursiva (Ctrl+I)","toolbar.alignmentDistribution":"Alineación y distribución","toolbar.align":"Alinear","toolbar.alignLeft":"Alinear a la izquierda","toolbar.left":"Izquierda","toolbar.alignCenter":"Centrar horizontalmente","toolbar.center":"Centro","toolbar.alignRight":"Alinear a la derecha","toolbar.right":"Derecha","toolbar.alignTop":"Alinear arriba","toolbar.alignMiddle":"Centrar verticalmente","toolbar.middle":"Medio","toolbar.alignBottom":"Alinear abajo","toolbar.bottom":"Abajo","toolbar.distribute":"Distribuir","toolbar.distributeHorizontally":"Distribuir horizontalmente","toolbar.distributeVertically":"Distribuir verticalmente","toolbar.arrange":"Organizar","toolbar.editorMode":"Modo de edición","toolbar.editor":"Editor","toolbar.playerMode":"Modo de reproducción","toolbar.player":"Reproductor","toolbar.animatedPlayerMode":"Modo de reproducción animado","toolbar.animated":"Animado","toolbar.stylePresets":"Estilos predefinidos","toolbar.style":"Estilo","diagramEditor.addAnimationMode":"Añadir modo de animación","animation.zoomIn":"Acercar","animation.zoomOut":"Alejar","toolbar.bringToFront":"Traer al frente","toolbar.sendToBack":"Enviar al fondo","diagramCellRenderer.diagram":"Diagrama","diagramCellRenderer.nodesEdges":"{nodes} nodos • {edges} aristas","diagramCellRenderer.nodesEdges2":"{nodes} nodos, {edges} aristas","node.vertical":"Vertical","node.horizontal":"Horizontal","node.diagonal":"Diagonal","node.radial":"Radial","node.straight":"Recta","node.bezier":"Bézier","node.orthogonal":"Ortogonal","node.step":"Escalonada","node.solid":"Continua","node.dashed":"Discontinua","node.dotted":"Punteada","node.dashDot":"Raya-punto","node.longDash":"Raya larga","node.arrow":"Flecha","node.openArrow":"Flecha abierta","node.diamond":"Rombo","node.circle":"Círculo","node.none":"Ninguna","toolbar.top":"Arriba","toolbar.selected":"{selectionCount} seleccionados","decisionTreeEditor.decisionTree":"Árbol de decisión","dependencyGraph.optional":"(opcional)","dependencyGraph.dependencyGraph":"Grafo de dependencias","diagramEditor.modes":"Modos:","networkTopology.networkTopology":"Topología de red","orgChartVisualizer.organizationChart":"Organigrama","processMiningDiagram.processMiningDiagram":"Diagrama de minería de procesos"}},ir=p.createContext(null);function ar(o,e){const t={...It.en,...It[o],...e};return{locale:o,t:(i,a)=>t[i]??a??i}}function jt({locale:o="en",overrides:e,children:t}){const r=p.useMemo(()=>ar(o,e),[o,e]);return p.createElement(ir.Provider,{value:r},t)}function Re(){const o=p.useContext(ir),{lang:e}=y.useNiceTranslation(),t=It[e]?e:"en",r=p.useMemo(()=>ar(t),[t]);return o??r}function Xr(o){const e=[];let t;try{t=JSON.parse(o)}catch{return{ok:!1,errors:["Invalid JSON: parse failed"]}}if(typeof t!="object"||t===null||Array.isArray(t))return{ok:!1,errors:["Root must be a JSON object"]};const r=t;if(r.version!=="1.0"&&e.push(`Unsupported version "${String(r.version)}", expected "1.0"`),(typeof r.id!="string"||r.id.length===0)&&e.push('Missing or invalid "id" field'),typeof r.title!="string"&&e.push('Missing or invalid "title" field'),Array.isArray(r.nodes)||e.push('Missing or invalid "nodes" array'),Array.isArray(r.edges)||e.push('Missing or invalid "edges" array'),Array.isArray(r.nodes)&&Array.isArray(r.edges)){const i=new Set(r.nodes.map(a=>a.id).filter(Boolean));for(const a of r.edges)a.sourceNodeId&&!i.has(a.sourceNodeId)&&e.push(`Edge "${a.id}" references non-existent source node "${a.sourceNodeId}"`),a.targetNodeId&&!i.has(a.targetNodeId)&&e.push(`Edge "${a.id}" references non-existent target node "${a.targetNodeId}"`)}return e.length>0?{ok:!1,errors:e}:{ok:!0,document:t,errors:[]}}function nr(o,e=!0){return JSON.stringify(o,null,e?2:void 0)}class pt{constructor(e){this.undoStack=[],this.redoStack=[],this.listeners=new Set,this.maxHistory=100,this.doc=e??pt.createEmpty()}static createEmpty(e="flowchart"){const t=new Date().toISOString();return{version:"1.0",id:it(),title:"Untitled Diagram",diagramType:e,nodes:[],edges:[],groups:[],animations:[],viewport:{x:0,y:0,zoom:1},metadata:{createdAt:t,updatedAt:t}}}getDocument(){return this.doc}getNodes(){return this.doc.nodes}getEdges(){return this.doc.edges}getGroups(){return this.doc.groups}getAnimations(){return this.doc.animations}getNodeById(e){return this.doc.nodes.find(t=>t.id===e)}getEdgeById(e){return this.doc.edges.find(t=>t.id===e)}getViewport(){return{...this.doc.viewport}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.doc.metadata.updatedAt=new Date().toISOString(),this.listeners.forEach(e=>e())}pushUndo(e){this.undoStack.push({label:e,snapshot:JSON.stringify(this.doc)}),this.undoStack.length>this.maxHistory&&this.undoStack.shift(),this.redoStack=[]}undo(){const e=this.undoStack.pop();return e?(this.redoStack.push({label:"redo",snapshot:JSON.stringify(this.doc)}),this.doc=JSON.parse(e.snapshot),this.notify(),!0):!1}redo(){const e=this.redoStack.pop();return e?(this.undoStack.push({label:"undo",snapshot:JSON.stringify(this.doc)}),this.doc=JSON.parse(e.snapshot),this.notify(),!0):!1}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}addNode(e,t,r="roundedRect",i={width:160,height:60}){this.pushUndo("Add node");const a=Kr(),s={id:it(),label:e,position:t,size:i,shape:r,style:{},ports:a};return this.doc.nodes.push(s),this.notify(),s}updateNode(e,t){this.pushUndo("Update node");const r=this.doc.nodes.find(i=>i.id===e);r&&Object.assign(r,t),this.notify()}moveNodes(e,t=!0){const r=[...e].filter(([i])=>this.getNodeById(i));if(r.length!==0){t&&this.pushUndo("Layout");for(const[i,a]of r)this.getNodeById(i).position={...a};this.notify()}}moveNode(e,t){const r=this.doc.nodes.find(i=>i.id===e);r&&(this.pushUndo("Move node"),r.position=t,this.notify())}resizeNode(e,t){const r=this.doc.nodes.find(i=>i.id===e);r&&(this.pushUndo("Resize node"),r.size=t,this.notify())}removeNode(e){this.pushUndo("Remove node"),this.doc.nodes=this.doc.nodes.filter(t=>t.id!==e),this.doc.edges=this.doc.edges.filter(t=>t.sourceNodeId!==e&&t.targetNodeId!==e),this.doc.groups.forEach(t=>{t.nodeIds=t.nodeIds.filter(r=>r!==e)}),this.doc.animations=this.doc.animations.filter(t=>t.targetId!==e),this.notify()}addEdge(e,t,r,i,a){if(e===r||!this.getNodeById(e)||!this.getNodeById(r))return null;this.pushUndo("Add edge");const s={id:it(),sourceNodeId:e,sourcePortId:t,targetNodeId:r,targetPortId:i,label:a,style:{lineType:"bezier",targetArrow:"arrow"}};return this.doc.edges.push(s),this.notify(),s}updateEdge(e,t){this.pushUndo("Update edge");const r=this.doc.edges.find(i=>i.id===e);r&&Object.assign(r,t),this.notify()}removeEdge(e){this.pushUndo("Remove edge"),this.doc.edges=this.doc.edges.filter(t=>t.id!==e),this.doc.animations=this.doc.animations.filter(t=>t.targetId!==e),this.notify()}createGroup(e,t){this.pushUndo("Create group");const r={id:it(),label:e,nodeIds:[...t]};return t.forEach(i=>{const a=this.doc.nodes.find(s=>s.id===i);a&&(a.groupId=r.id)}),this.doc.groups.push(r),this.notify(),r}removeGroup(e){this.pushUndo("Remove group");const t=this.doc.groups.find(r=>r.id===e);t&&t.nodeIds.forEach(r=>{const i=this.doc.nodes.find(a=>a.id===r);i&&(i.groupId=void 0)}),this.doc.groups=this.doc.groups.filter(r=>r.id!==e),this.notify()}addAnimation(e){this.pushUndo("Add animation");const t={id:it(),...e};return this.doc.animations.push(t),this.notify(),t}removeAnimation(e){this.pushUndo("Remove animation"),this.doc.animations=this.doc.animations.filter(t=>t.id!==e),this.notify()}setViewport(e){this.doc.viewport={...e},this.notify()}toggleGroupCollapse(e){const t=this.doc.groups.find(r=>r.id===e);t&&(this.pushUndo("Toggle group collapse"),t.collapsed=!t.collapsed,t.nodeIds.forEach(r=>{const i=this.doc.nodes.find(a=>a.id===r);i&&(i.hidden=t.collapsed)}),this.notify())}toggleNodeCollapse(e){const t=this.doc.nodes.find(r=>r.id===e);t&&(this.pushUndo("Toggle node collapse"),t.collapsed=!t.collapsed,(t.childNodeIds??[]).forEach(r=>{const i=this.doc.nodes.find(a=>a.id===r);i&&(i.hidden=t.collapsed)}),this.notify())}getAnimationModes(){return this.doc.animationModes??[]}getActiveAnimationMode(){var e;if((e=this.doc.animationModes)!=null&&e.length)return this.doc.animationModes.find(t=>t.id===this.doc.activeAnimationModeId)??this.doc.animationModes.find(t=>t.isDefault)??this.doc.animationModes[0]}addAnimationMode(e,t){this.pushUndo("Add animation mode"),this.doc.animationModes||(this.doc.animationModes=[]);const r={id:it(),name:e,animations:t??[],isDefault:this.doc.animationModes.length===0};return this.doc.animationModes.push(r),r.isDefault&&(this.doc.activeAnimationModeId=r.id),this.notify(),r}removeAnimationMode(e){var t;this.doc.animationModes&&(this.pushUndo("Remove animation mode"),this.doc.animationModes=this.doc.animationModes.filter(r=>r.id!==e),this.doc.activeAnimationModeId===e&&(this.doc.activeAnimationModeId=(t=this.doc.animationModes[0])==null?void 0:t.id),this.notify())}setActiveAnimationMode(e){var t;(t=this.doc.animationModes)!=null&&t.find(r=>r.id===e)&&(this.doc.activeAnimationModeId=e,this.notify())}addAnimationToMode(e,t){var a;const r=(a=this.doc.animationModes)==null?void 0:a.find(s=>s.id===e);if(!r)return null;this.pushUndo("Add animation to mode");const i={id:it(),...t};return r.animations.push(i),this.notify(),i}removeAnimationFromMode(e,t){var i;const r=(i=this.doc.animationModes)==null?void 0:i.find(a=>a.id===e);r&&(this.pushUndo("Remove animation from mode"),r.animations=r.animations.filter(a=>a.id!==t),this.notify())}setStylePreset(e){this.pushUndo("Set style preset"),this.doc.stylePresetId=e,this.notify()}setStyleOverrides(e){this.pushUndo("Set style overrides"),this.doc.styleOverrides=e,this.notify()}getPlayerConfig(){return this.doc.playerConfig??{mode:"editor",interactionsEnabled:!0,showModeSwitcher:!0,showPlaybackControls:!0,autoPlay:!1,showGhostElements:!0,ghostOpacity:.15,ghostCursorStyle:"pointer"}}setPlayerConfig(e){this.pushUndo("Update player config"),this.doc.playerConfig={...this.getPlayerConfig(),...e},this.notify()}setViewMode(e){const t=this.getPlayerConfig();t.mode=e,this.doc.playerConfig=t,this.notify()}updateAnimation(e,t){this.pushUndo("Update animation");const r=this.doc.animations.find(i=>i.id===e);r&&Object.assign(r,t),this.notify()}loadDocument(e){this.doc=structuredClone(e),this.undoStack=[],this.redoStack=[],this.notify()}}function it(){return`ndd_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Kr(){return[{id:"top",side:"top",offset:.5},{id:"right",side:"right",offset:.5},{id:"bottom",side:"bottom",offset:.5},{id:"left",side:"left",offset:.5}]}function Dt(o,e,t){switch(t.algorithm){case"dagre":return sr(o,e,t);case"grid":return Jr(o,t);case"radial":return Qr(o,e);case"tree":return eo(o,e,t);case"forceDirected":return to(o,e,t);case"manual":default:return{positions:new Map(o.map(r=>[r.id,{...r.position}]))}}}function Zr(o,e){const t=new Map,r=new Set,i=new Set;e.forEach(s=>s.forEach(c=>i.add(c)));const a=s=>{const c=[{id:s,next:0}];for(t.set(s,1);c.length;){const l=c[c.length-1],u=e.get(l.id)??[];if(l.next>=u.length){t.set(l.id,2),c.pop();continue}const d=u[l.next++],w=t.get(d);w===1?r.add(`${l.id}→${d}`):w===void 0&&(t.set(d,1),c.push({id:d,next:0}))}};for(const s of o)!i.has(s)&&!t.has(s)&&a(s);for(const s of o)t.has(s)||a(s);return r}function sr(o,e,t){const r=t.direction??"TB",i=t.nodeSpacing??60,a=t.rankSpacing??100,s=r==="LR"||r==="RL",c=r==="BT"||r==="RL",l=o.map(I=>I.id),u=new Map(o.map(I=>[I.id,I])),d=new Map(l.map(I=>[I,[]]));for(const I of e){const L=d.get(I.sourceNodeId);L&&u.has(I.targetNodeId)&&I.sourceNodeId!==I.targetNodeId&&(L.includes(I.targetNodeId)||L.push(I.targetNodeId))}const w=Zr(l,d),x=new Map(l.map(I=>[I,[]])),g=new Map(l.map(I=>[I,[]]));d.forEach((I,L)=>{for(const W of I){const[H,C]=w.has(`${L}→${W}`)?[W,L]:[L,W];x.get(H).includes(C)||(x.get(H).push(C),g.get(C).push(H))}});const h=new Map(l.map(I=>[I,0])),v=new Map(l.map(I=>[I,g.get(I).length])),_=l.filter(I=>v.get(I)===0);for(let I=0;I<_.length;I++){const L=_[I];for(const W of x.get(L))h.set(W,Math.max(h.get(W),h.get(L)+1)),v.set(W,v.get(W)-1),v.get(W)===0&&_.push(W)}const b=[];for(const I of l){const L=h.get(I);(b[L]??(b[L]=[])).push(I)}const m=b.filter(Boolean),A=new Map;m.forEach(I=>I.forEach((L,W)=>A.set(L,W)));const j=(I,L)=>L.length===0?A.get(I):L.reduce((W,H)=>W+A.get(H),0)/L.length;for(let I=0;I<4;I++){const L=I%2===0,W=L?m.slice(1):m.slice(0,-1).reverse();for(const H of W){const C=new Map(H.map($=>[$,j($,L?g.get($):x.get($))]));H.sort(($,O)=>C.get($)-C.get(O)||A.get($)-A.get(O)),H.forEach(($,O)=>A.set($,O))}}const M=I=>s?I.size.width:I.size.height,X=I=>s?I.size.height:I.size.width,V=new Map;let F=0;for(const I of m){const L=I.map($=>u.get($)),W=Math.max(...L.map(M));let C=-(L.reduce(($,O)=>$+X(O),0)+(L.length-1)*i)/2;for(const $ of L){const O=F+(W-M($))/2,G=c?-(O+M($)):O;V.set($.id,s?{x:G,y:C}:{x:C,y:G}),C+=X($)+i}F+=W+a}t.centerGraph&&At(V);const R=new Map;return m.forEach((I,L)=>I.forEach(W=>R.set(W,L))),{positions:V,ranks:R}}function Jr(o,e){const t=e.nodeSpacing??80,r=Math.ceil(Math.sqrt(o.length)),i=new Map;return o.forEach((a,s)=>{const c=s%r,l=Math.floor(s/r);i.set(a.id,{x:c*(a.size.width+t),y:l*(a.size.height+t)})}),e.centerGraph&&At(i),{positions:i}}function Qr(o,e){const t=new Map;if(o.length===0)return{positions:t};const r=new Map;o.forEach(l=>r.set(l.id,0)),e.forEach(l=>{r.set(l.sourceNodeId,(r.get(l.sourceNodeId)??0)+1),r.set(l.targetNodeId,(r.get(l.targetNodeId)??0)+1)});const i=[...o].sort((l,u)=>(r.get(u.id)??0)-(r.get(l.id)??0)),a=i[0];t.set(a.id,{x:0,y:0});const s=i.slice(1),c=200+s.length*20;return s.forEach((l,u)=>{const d=2*Math.PI*u/s.length;t.set(l.id,{x:Math.cos(d)*c,y:Math.sin(d)*c})}),{positions:t}}function eo(o,e,t){return sr(o,e,{...t,direction:t.direction??"TB",nodeSpacing:t.nodeSpacing??40,rankSpacing:t.rankSpacing??80})}function to(o,e,t){const r=new Map;if(o.length===0)return{positions:r};const i=400,a=new Map;o.forEach(w=>{a.set(w.id,{x:(Math.random()-.5)*i,y:(Math.random()-.5)*i})});const s=e.map(w=>({source:w.sourceNodeId,target:w.targetNodeId})),c=t.nodeSpacing??150,l=80,u=.95;let d=i/2;for(let w=0;w<l;w++){const x=new Map;o.forEach(g=>x.set(g.id,{fx:0,fy:0}));for(let g=0;g<o.length;g++)for(let h=g+1;h<o.length;h++){const v=a.get(o[g].id),_=a.get(o[h].id),b=_.x-v.x,m=_.y-v.y,A=Math.max(Math.sqrt(b*b+m*m),1),k=c*c/A,j=b/A*k,M=m/A*k;x.get(o[g].id).fx-=j,x.get(o[g].id).fy-=M,x.get(o[h].id).fx+=j,x.get(o[h].id).fy+=M}for(const g of s){const h=a.get(g.source),v=a.get(g.target);if(!h||!v)continue;const _=v.x-h.x,b=v.y-h.y,m=Math.max(Math.sqrt(_*_+b*b),1),A=m*m/c,k=_/m*A,j=b/m*A;x.get(g.source).fx+=k,x.get(g.source).fy+=j,x.get(g.target).fx-=k,x.get(g.target).fy-=j}o.forEach(g=>{const h=x.get(g.id),v=a.get(g.id),_=Math.sqrt(h.fx*h.fx+h.fy*h.fy);if(_>0){const b=Math.min(_,d);v.x+=h.fx/_*b,v.y+=h.fy/_*b}}),d*=u}return o.forEach(w=>{r.set(w.id,{...a.get(w.id)})}),t.centerGraph&&At(r),{positions:r}}function At(o){if(o.size===0)return;let e=1/0,t=1/0,r=-1/0,i=-1/0;o.forEach(c=>{e=Math.min(e,c.x),t=Math.min(t,c.y),r=Math.max(r,c.x),i=Math.max(i,c.y)});const a=(e+r)/2,s=(t+i)/2;o.forEach(c=>{c.x-=a,c.y-=s})}function lr(o){const e=p.useRef(null);e.current||(e.current=new pt(o));const t=e.current,[r,i]=p.useState(0),a=p.useCallback(()=>i(l=>l+1),[]);p.useEffect(()=>t.subscribe(a),[t,a]);const s=t.getDocument(),c=p.useCallback((l,u)=>{const d=Dt(t.getNodes(),t.getEdges(),l);t.moveNodes(d.positions,(u==null?void 0:u.history)??!0)},[t]);return p.useMemo(()=>({document:s,nodes:s.nodes,edges:s.edges,groups:s.groups,animations:s.animations,viewport:s.viewport,addNode:(l,u,d,w)=>t.addNode(l,u,d,w),updateNode:(l,u)=>t.updateNode(l,u),moveNode:(l,u)=>t.moveNode(l,u),resizeNode:(l,u)=>t.resizeNode(l,u),removeNode:l=>t.removeNode(l),addEdge:(l,u,d,w,x)=>t.addEdge(l,u,d,w,x),updateEdge:(l,u)=>t.updateEdge(l,u),removeEdge:l=>t.removeEdge(l),createGroup:(l,u)=>t.createGroup(l,u),removeGroup:l=>t.removeGroup(l),toggleGroupCollapse:l=>t.toggleGroupCollapse(l),toggleNodeCollapse:l=>t.toggleNodeCollapse(l),addAnimation:l=>t.addAnimation(l),updateAnimation:(l,u)=>t.updateAnimation(l,u),removeAnimation:l=>t.removeAnimation(l),animationModes:t.getAnimationModes(),activeAnimationMode:t.getActiveAnimationMode(),addAnimationMode:(l,u)=>t.addAnimationMode(l,u),removeAnimationMode:l=>t.removeAnimationMode(l),setActiveAnimationMode:l=>t.setActiveAnimationMode(l),addAnimationToMode:(l,u)=>t.addAnimationToMode(l,u),removeAnimationFromMode:(l,u)=>t.removeAnimationFromMode(l,u),setStylePreset:l=>t.setStylePreset(l),setStyleOverrides:l=>t.setStyleOverrides(l),stylePresetId:s.stylePresetId,playerConfig:t.getPlayerConfig(),setPlayerConfig:l=>t.setPlayerConfig(l),setViewMode:l=>t.setViewMode(l),viewMode:t.getPlayerConfig().mode,applyLayout:c,setViewport:l=>t.setViewport(l),undo:()=>t.undo(),redo:()=>t.redo(),canUndo:t.canUndo(),canRedo:t.canRedo(),loadDocument:l=>t.loadDocument(l),model:t,revision:r}),[s,t,c,r])}function ye(o){return{primary:"var(--nice-primary, #3b82f6)",primaryLight:"var(--nice-primary-light, #93c5fd)",secondary:"var(--nice-info, #6366f1)",accent:"var(--nice-warning, #f59e0b)",success:"var(--nice-success, #10b981)",warning:"var(--nice-warning, #f59e0b)",error:"var(--nice-danger, #ef4444)",info:"var(--nice-info, #06b6d4)",text:"var(--nice-text, #1e293b)",textMuted:"var(--nice-text-muted, #94a3b8)",border:"var(--nice-border, #e2e8f0)",surface:"var(--nice-bg, #fff)",surfaceAlt:"var(--nice-bg-secondary, #f8fafc)",...o}}function ro(o,e={}){return{backgroundColor:o.surface,borderColor:o.primary,borderWidth:2,borderRadius:8,fontColor:o.text,fontSize:14,fontWeight:"normal",opacity:1,shadow:!0,...e}}function oo(o,e={}){return{strokeColor:o.border,strokeWidth:2,lineType:"bezier",targetArrow:"arrow",...e}}function io(o,e={}){return{backgroundColor:`${o.primaryLight}18`,borderColor:o.primaryLight,borderWidth:1,borderStyle:"dashed",borderRadius:12,labelColor:o.text,padding:16,...e}}function be(o,e,t,r,i,a,s){return{canvas:o,nodeDefaults:ro(e,r),edgeDefaults:oo(e,i),groupDefaults:io(e,a),fontFamily:t,palette:e,effects:s}}const Be="'Inter', system-ui, sans-serif",$t="'Fira Code', 'Cascadia Code', monospace",ao="'Merriweather', 'Georgia', serif",no={id:"default-light",name:"Default Light",category:"corporate",themeSource:"Light",config:be({background:"var(--nice-bg, #fff)",gridColor:"#e2e8f020",gridSize:20,selectionColor:"var(--nice-primary, #3b82f6)"},ye({}),Be)},so=ye({primary:"var(--nice-primary-light, #60a5fa)",primaryLight:"var(--nice-primary, #3b82f6)",secondary:"var(--nice-accent, #818cf8)",accent:"var(--nice-warning-light, #fbbf24)",success:"var(--nice-success-light, #34d399)",warning:"var(--nice-warning-light, #fbbf24)",error:"var(--nice-danger-light, #f87171)",info:"var(--nice-info, #22d3ee)",text:"var(--nice-text-primary, #f8fafc)",textMuted:"var(--nice-text-secondary, #64748b)",border:"var(--nice-border-color, #334155)",surface:"var(--nice-bg-secondary, #1e293b)",surfaceAlt:"var(--nice-bg-primary, #0f172a)"}),lo={id:"default-dark",name:"Default Dark",category:"dark",themeSource:"Dark",config:be({background:"var(--nice-bg-primary, #0f172a)",gridColor:"var(--nice-text, #334155)",gridSize:20,selectionColor:"var(--nice-primary-light, #60a5fa)"},so,Be,{shadow:!1},{strokeColor:"var(--nice-text-secondary, #475569)"},{backgroundColor:"#60a5fa10",borderColor:"#3b82f680"})},co=ye({primary:"var(--nice-primary-dark, #1d4ed8)",primaryLight:"var(--nice-primary-light, #93c5fd)",secondary:"var(--nice-primary, #3b82f6)",text:"var(--nice-primary-dark, #1e3a5f)",textMuted:"#7da0c4",border:"var(--nice-primary-light, #93c5fd)",surface:"var(--nice-primary-bg, #eff6ff)",surfaceAlt:"var(--nice-primary-bg, #dbeafe)"}),uo={id:"corporate-blue",name:"Corporate Blue",category:"corporate",themeSource:"Blue",config:be({background:"#f0f5ff",gridColor:"#93c5fd20",gridSize:20,selectionColor:"var(--nice-primary-dark, #1d4ed8)"},co,Be,{borderWidth:2,borderRadius:6},{strokeColor:"var(--nice-primary-light, #93c5fd)",strokeWidth:2})},fo=ye({primary:"var(--nice-success, #00ff88)",primaryLight:"#00cc6b",secondary:"#ff00ff",accent:"var(--nice-info, #00ffff)",success:"var(--nice-success, #00ff88)",warning:"var(--nice-warning, #ffff00)",error:"#ff3366",info:"var(--nice-info, #00ffff)",text:"var(--nice-text-secondary, #e0e0e0)",textMuted:"var(--nice-text-secondary, #808080)",border:"#00ff8840",surface:"var(--nice-bg, #1a1a2e)",surfaceAlt:"var(--nice-bg, #16213e)"}),ho={id:"neon-glow",name:"Neon Glow",category:"dark",config:be({background:"#0a0a1a",gridColor:"#00ff8810",gridSize:20,selectionColor:"var(--nice-success, #00ff88)"},fo,$t,{borderColor:"var(--nice-success, #00ff88)",borderWidth:2,shadow:!0,glowColor:"var(--nice-success, #00ff88)",glowIntensity:.6},{strokeColor:"#00ff8880",strokeWidth:2},{backgroundColor:"#00ff880a",borderColor:"#00ff8840"},{glowColor:"var(--nice-success, #00ff88)",glowIntensity:.8,particleColor:"var(--nice-info, #00ffff)",liquidColor:"var(--nice-success, #00ff88)",liquidColorEnd:"var(--nice-info, #00ffff)"})},mo=ye({primary:"var(--nice-color-accent-pink, #ff2d95)",primaryLight:"#ff6db6",secondary:"#7928ca",accent:"#00d4ff",success:"#39ff14",warning:"var(--nice-warning, #FFD700)",error:"#ff073a",info:"#00d4ff",text:"var(--nice-text-primary, #fff)",textMuted:"#b0b0b0",border:"#ff2d9540",surface:"#1a0030",surfaceAlt:"#2d004a"}),go={id:"cyberpunk",name:"Cyberpunk",category:"dark",config:be({background:"#0d001a",gridColor:"#ff2d9510",gridSize:24,selectionColor:"var(--nice-color-accent-pink, #ff2d95)"},mo,$t,{borderColor:"var(--nice-color-accent-pink, #ff2d95)",borderWidth:2,glowColor:"var(--nice-color-accent-pink, #ff2d95)",glowIntensity:.7,shadow:!0,gradientColor:"#2d004a",gradientDirection:"vertical"},{strokeColor:"#7928ca80",strokeWidth:3},{},{glowColor:"var(--nice-color-accent-pink, #ff2d95)",glowIntensity:.9,particleColor:"#00d4ff",liquidColor:"var(--nice-color-accent-pink, #ff2d95)",liquidColorEnd:"#7928ca"})},po=ye({primary:"var(--nice-bg, #fff)",primaryLight:"#ffffffaa",secondary:"#4da6ff",accent:"var(--nice-bg, #fff)",text:"var(--nice-text-primary, #fff)",textMuted:"#ffffffaa",border:"#ffffff40",surface:"#1e3d6e",surfaceAlt:"#163050"}),yo={id:"blueprint",name:"Technical Blueprint",category:"technical",config:be({background:"#0a1929",gridColor:"#4da6ff30",gridSize:16,selectionColor:"var(--nice-color-white, #fff)"},po,$t,{backgroundColor:"transparent",borderColor:"#4da6ff",borderWidth:1,borderStyle:"solid",fontColor:"var(--nice-text-primary, #fff)",shadow:!1},{strokeColor:"#4da6ff",strokeWidth:1,strokeDash:[4,4]},{backgroundColor:"transparent",borderColor:"#4da6ff40",borderStyle:"dashed",borderWidth:1})},bo=ye({primary:"var(--nice-accent, #a78bfa)",primaryLight:"var(--nice-accent, #c4b5fd)",secondary:"var(--nice-color-accent-pink, #f472b6)",accent:"var(--nice-warning-light, #fbbf24)",success:"var(--nice-success-light, #6ee7b7)",warning:"var(--nice-warning-bg, #fde68a)",error:"var(--nice-danger-bg, #fca5a5)",info:"var(--nice-primary-light, #93c5fd)",text:"#4a4a68",textMuted:"#9494b0",border:"#e2d8f4",surface:"#faf5ff",surfaceAlt:"#f3e8ff"}),wo={id:"pastel-dream",name:"Pastel Dream",category:"pastel",config:be({background:"#fefcff",gridColor:"#e2d8f420",gridSize:20,selectionColor:"var(--nice-accent, #a78bfa)"},bo,"'Nunito', 'Quicksand', sans-serif",{borderColor:"var(--nice-accent, #c4b5fd)",borderWidth:2,borderRadius:16,shadow:!0},{strokeColor:"var(--nice-accent, #c4b5fd)",strokeWidth:2},{backgroundColor:"#a78bfa10",borderColor:"var(--nice-accent, #c4b5fd)",borderRadius:16})},xo=ye({primary:"var(--nice-success, #059669)",primaryLight:"var(--nice-success-light, #6ee7b7)",secondary:"#065f46",accent:"var(--nice-warning, #f59e0b)",success:"var(--nice-success, #10b981)",warning:"var(--nice-warning, #f59e0b)",error:"var(--nice-danger-dark, #dc2626)",info:"#0d9488",text:"#1a3d2f",textMuted:"#6b8f7f",border:"#a7d7c5",surface:"#ecfdf5",surfaceAlt:"#d1fae5"}),vo={id:"nature-forest",name:"Nature Forest",category:"nature",config:be({background:"#f0fdf4",gridColor:"#a7d7c520",gridSize:20,selectionColor:"var(--nice-success, #059669)"},xo,Be,{borderColor:"var(--nice-success, #059669)",borderRadius:12},{strokeColor:"var(--nice-success-light, #6ee7b7)"},{backgroundColor:"#05966910",borderColor:"var(--nice-success-light, #6ee7b7)"},{liquidColor:"var(--nice-success, #059669)",liquidColorEnd:"var(--nice-success-light, #6ee7b7)",particleColor:"var(--nice-warning, #f59e0b)"})},ko=ye({primary:"var(--nice-success, #00ff00)",primaryLight:"#00cc00",secondary:"var(--nice-success, #00ff00)",accent:"var(--nice-warning, #ffff00)",text:"var(--nice-success, #00ff00)",textMuted:"#00990088",border:"#00ff0040",surface:"#001100",surfaceAlt:"#002200"}),Co={id:"retro-terminal",name:"Retro Terminal",category:"retro",config:be({background:"#000800",gridColor:"#00ff0010",gridSize:16,selectionColor:"var(--nice-success, #00ff00)"},ko,"'Courier New', 'Fira Code', monospace",{backgroundColor:"#001100",borderColor:"#00ff0060",borderWidth:1,fontColor:"var(--nice-success, #00ff00)",shadow:!1,glowColor:"var(--nice-success, #00ff00)",glowIntensity:.4},{strokeColor:"#00ff0060",strokeWidth:1},{},{glowColor:"var(--nice-success, #00ff00)",glowIntensity:.6,particleColor:"var(--nice-success, #00ff00)",liquidColor:"var(--nice-success, #00ff00)"})},So=ye({primary:"#0000ff",primaryLight:"#6666ff",secondary:"#ff00ff",accent:"var(--nice-warning, #ffff00)",text:"var(--nice-text, #000000)",textMuted:"var(--nice-text-secondary, #555555)",border:"var(--nice-border-color, #000000)",surface:"var(--nice-bg, #fff)",surfaceAlt:"var(--nice-border, #eeeeee)"}),No={id:"high-contrast",name:"High Contrast",category:"accessibility",themeSource:"High Contrast",config:be({background:"var(--nice-bg, #fff)",gridColor:"#00000020",gridSize:20,selectionColor:"#0000ff"},So,"Arial, sans-serif",{borderColor:"var(--nice-border-color, #000000)",borderWidth:3,fontColor:"var(--nice-text, #000000)",fontWeight:"bold"},{strokeColor:"var(--nice-text, #000000)",strokeWidth:3},{borderColor:"var(--nice-border-color, #000000)",borderWidth:2})},_o=ye({primary:"var(--nice-primary-hover, #1976d2)",primaryLight:"#64b5f6",secondary:"var(--nice-accent, #9c27b0)",accent:"var(--nice-warning, #ff9800)",success:"var(--nice-success, #4caf50)",warning:"var(--nice-warning, #ff9800)",error:"var(--nice-danger, #f44336)",info:"#03a9f4",text:"#212121",textMuted:"#757575",border:"var(--nice-border, #e0e0e0)",surface:"var(--nice-bg-secondary, #fafafa)",surfaceAlt:"var(--nice-bg-secondary, #f5f5f5)"}),Mo={id:"material-design",name:"Material Design",category:"theme-based",themeSource:"Material",config:be({background:"var(--nice-bg-secondary, #fafafa)",gridColor:"#e0e0e020",gridSize:20,selectionColor:"var(--nice-primary-hover, #1976d2)"},_o,"'Roboto', 'Noto Sans', sans-serif",{borderRadius:4,borderWidth:0,shadow:!0},{strokeColor:"#bdbdbd",strokeWidth:2},{borderRadius:8})},zo=ye({primary:"#0078d4",primaryLight:"#6cb8f7",secondary:"#8661c5",accent:"#ffaa44",success:"#107c10",warning:"#ffaa44",error:"#d13438",info:"#0078d4",text:"#323130",textMuted:"#a19f9d",border:"#edebe9",surface:"var(--nice-bg, #fff)",surfaceAlt:"#faf9f8"}),Io={id:"fluent-ui",name:"Fluent UI",category:"theme-based",themeSource:"Fluent",config:be({background:"#faf9f8",gridColor:"#edebe920",gridSize:20,selectionColor:"#0078d4"},zo,"'Segoe UI', system-ui, sans-serif",{borderRadius:4,borderWidth:1,shadow:!0},{strokeColor:"#c8c6c4",strokeWidth:1})},jo=ye({primary:"var(--nice-warning-dark, #e65100)",primaryLight:"#ff9e80",secondary:"#ff6f00",accent:"#ffd600",success:"#43a047",warning:"#ff6f00",error:"var(--nice-danger-dark, #c62828)",info:"#0277bd",text:"#3e2723",textMuted:"#8d6e63",border:"#ffccbc",surface:"#fff8e1",surfaceAlt:"var(--nice-warning-bg, #fff3e0)"}),Do={id:"sunset-warm",name:"Sunset Warm",category:"creative",config:be({background:"#fffde7",gridColor:"#ffccbc20",gridSize:20,selectionColor:"var(--nice-warning-dark, #e65100)"},jo,Be,{borderColor:"#ff9e80",gradientColor:"var(--nice-warning-bg, #fff3e0)",gradientDirection:"vertical"},{strokeColor:"#ff9e80"},{},{liquidColor:"var(--nice-warning-dark, #e65100)",liquidColorEnd:"#ffd600",particleColor:"#ffd600"})},Ao=ye({primary:"#006064",primaryLight:"#4dd0e1",secondary:"#00838f",accent:"#ffd54f",success:"#00e676",warning:"#ffd54f",error:"#ff5252",info:"#40c4ff",text:"#004d40",textMuted:"#80cbc4",border:"#b2ebf2",surface:"#e0f7fa",surfaceAlt:"#b2ebf2"}),$o={id:"ocean-deep",name:"Ocean Deep",category:"nature",config:be({background:"#e0f7fa",gridColor:"#b2ebf220",gridSize:20,selectionColor:"#006064"},Ao,Be,{borderColor:"#00838f",borderRadius:12},{strokeColor:"#4dd0e1"},{},{liquidColor:"#006064",liquidColorEnd:"#4dd0e1",particleColor:"#ffd54f"})},To=ye({primary:"#5d4037",primaryLight:"#a1887f",secondary:"#795548",accent:"#c6a263",text:"#3e2723",textMuted:"#8d6e63",border:"#bcaaa4",surface:"#fdf6f0",surfaceAlt:"#efebe9"}),Po={id:"elegant-serif",name:"Elegant Serif",category:"creative",config:be({background:"#fdf6f0",gridColor:"#bcaaa420",gridSize:24,selectionColor:"#5d4037"},To,ao,{borderColor:"#a1887f",borderWidth:1,borderRadius:2,fontStyle:"normal"},{strokeColor:"#bcaaa4",strokeWidth:1},{borderRadius:4})},Eo=ye({primary:"var(--nice-text, #333333)",primaryLight:"var(--nice-text-secondary, #666666)",secondary:"var(--nice-text-secondary, #555555)",accent:"#ff6600",text:"var(--nice-text, #333333)",textMuted:"var(--nice-text-muted, #999999)",border:"var(--nice-border, #cccccc)",surface:"var(--nice-bg, #fff)",surfaceAlt:"var(--nice-bg-secondary, #f5f5f5)"}),Ro={id:"wireframe",name:"Wireframe",category:"technical",config:be({background:"var(--nice-bg, #fff)",gridColor:"#00000008",gridSize:16,selectionColor:"#ff6600"},Eo,"'Balsamiq Sans', 'Comic Sans MS', cursive",{backgroundColor:"transparent",borderColor:"var(--nice-border-color, #999999)",borderWidth:1,borderStyle:"solid",shadow:!1,borderRadius:4},{strokeColor:"var(--nice-text-muted, #999999)",strokeWidth:1},{backgroundColor:"transparent",borderStyle:"dashed",borderWidth:1,borderColor:"var(--nice-border, #cccccc)"})},Oo=ye({primary:"#00bfa5",primaryLight:"#64ffda",secondary:"#00897b",accent:"#ff6e40",success:"#00e676",warning:"#ffc400",error:"#ff1744",info:"#00e5ff",text:"#1b5e20",textMuted:"#81c784",border:"#a7ffeb",surface:"#e0f2f1",surfaceAlt:"#b2dfdb"}),Fo={id:"mint-fresh",name:"Mint Fresh",category:"nature",config:be({background:"var(--nice-success-bg, #e8f5e9)",gridColor:"#a7ffeb20",gridSize:20,selectionColor:"#00bfa5"},Oo,Be,{borderColor:"#00bfa5",borderRadius:20,borderWidth:2,gradientColor:"#b2dfdb",gradientDirection:"radial"},{strokeColor:"#64ffda",strokeWidth:2},{borderRadius:16},{liquidColor:"#00bfa5",liquidColorEnd:"#64ffda",particleColor:"#ff6e40"})},Lo=ye({primary:"#424242",primaryLight:"var(--nice-text-secondary, #9e9e9e)",secondary:"#616161",accent:"var(--nice-danger, #ff5722)",text:"#212121",textMuted:"#bdbdbd",border:"var(--nice-border, #e0e0e0)",surface:"var(--nice-bg-secondary, #fafafa)",surfaceAlt:"var(--nice-bg-secondary, #f5f5f5)"}),Wo={id:"monochrome",name:"Monochrome",category:"corporate",config:be({background:"var(--nice-bg-secondary, #fafafa)",gridColor:"#e0e0e020",gridSize:20,selectionColor:"#424242"},Lo,Be,{borderColor:"var(--nice-border-color, #9e9e9e)",borderWidth:1,shadow:!0,borderRadius:4},{strokeColor:"var(--nice-text-secondary, #9e9e9e)",strokeWidth:1.5})},Bo=ye({primary:"var(--nice-color-accent-pink, #e91e63)",primaryLight:"#f48fb1",secondary:"var(--nice-accent, #9c27b0)",accent:"var(--nice-warning, #ffeb3b)",success:"var(--nice-success, #4caf50)",warning:"var(--nice-warning, #ff9800)",error:"var(--nice-danger, #f44336)",info:"#00bcd4",text:"#4a148c",textMuted:"#ce93d8",border:"#f8bbd0",surface:"#fce4ec",surfaceAlt:"#f3e5f5"}),Vo={id:"candy-pop",name:"Candy Pop",category:"creative",config:be({background:"#fff0f5",gridColor:"#f8bbd020",gridSize:20,selectionColor:"var(--nice-color-accent-pink, #e91e63)"},Bo,"'Quicksand', 'Nunito', sans-serif",{borderColor:"var(--nice-color-accent-pink, #e91e63)",borderRadius:24,borderWidth:3,gradientColor:"#f3e5f5",gradientDirection:"diagonal"},{strokeColor:"#f48fb1",strokeWidth:3},{borderRadius:20,borderColor:"#f48fb1"},{glowColor:"var(--nice-color-accent-pink, #e91e63)",glowIntensity:.5,particleColor:"var(--nice-warning, #ffeb3b)"})},qo=ye({primary:"var(--nice-text-secondary, #475569)",primaryLight:"var(--nice-text-muted, #94a3b8)",secondary:"var(--nice-text, #334155)",accent:"var(--nice-warning, #f59e0b)",text:"var(--nice-text, #0f172a)",textMuted:"var(--nice-text-muted, #94a3b8)",border:"var(--nice-border, #cbd5e1)",surface:"var(--nice-bg-secondary, #f8fafc)",surfaceAlt:"var(--nice-bg-secondary, #f1f5f9)"}),Go={id:"slate-professional",name:"Slate Professional",category:"corporate",config:be({background:"var(--nice-bg-secondary, #f8fafc)",gridColor:"#cbd5e120",gridSize:20,selectionColor:"var(--nice-text-secondary, #475569)"},qo,"'Inter', system-ui, sans-serif",{borderColor:"var(--nice-border, #cbd5e1)",borderWidth:1,borderRadius:6,shadow:!0},{strokeColor:"var(--nice-text-muted, #94a3b8)",strokeWidth:1.5},{borderColor:"var(--nice-border, #cbd5e1)",borderRadius:8})},Yo=ye({primary:"var(--nice-accent, #7c3aed)",primaryLight:"var(--nice-accent, #a78bfa)",secondary:"var(--nice-info, #06b6d4)",accent:"var(--nice-color-accent-pink, #f472b6)",success:"var(--nice-success-light, #34d399)",warning:"var(--nice-warning-light, #fbbf24)",error:"var(--nice-danger-light, #f87171)",info:"var(--nice-info, #22d3ee)",text:"var(--nice-text-secondary, #e2e8f0)",textMuted:"var(--nice-text-muted, #94a3b8)",border:"#7c3aed40",surface:"#1e1b4b",surfaceAlt:"#312e81"}),Ho={id:"aurora-borealis",name:"Aurora Borealis",category:"dark",config:be({background:"#0f0b2e",gridColor:"#7c3aed15",gridSize:24,selectionColor:"var(--nice-accent, #a78bfa)"},Yo,Be,{borderColor:"var(--nice-accent, #7c3aed)",borderWidth:2,gradientColor:"#312e81",gradientDirection:"vertical",glowColor:"var(--nice-accent, #a78bfa)",glowIntensity:.5},{strokeColor:"#7c3aed80",strokeWidth:2},{},{glowColor:"var(--nice-accent, #a78bfa)",glowIntensity:.7,particleColor:"var(--nice-info, #06b6d4)",liquidColor:"var(--nice-accent, #7c3aed)",liquidColorEnd:"var(--nice-info, #06b6d4)"})},Uo=ye({primary:"#2c3e50",primaryLight:"#7f8c8d",secondary:"#2980b9",accent:"#e74c3c",text:"#2c3e50",textMuted:"#95a5a6",border:"#bdc3c7",surface:"#fdfaf6",surfaceAlt:"#f5f0e8"}),Xo={id:"sketch-hand-drawn",name:"Sketch / Hand-drawn",category:"creative",config:be({background:"#fdfaf6",gridColor:"#bdc3c720",gridSize:20,selectionColor:"#2980b9"},Uo,"'Caveat', 'Patrick Hand', cursive",{backgroundColor:"#fdfaf6",borderColor:"#2c3e50",borderWidth:2,borderRadius:2,shadow:!1},{strokeColor:"#2c3e50",strokeWidth:2},{borderStyle:"dashed",borderWidth:2})},Ko=ye({primary:"var(--nice-primary, #2196f3)",primaryLight:"#64b5f6",secondary:"var(--nice-warning, #ff9800)",accent:"var(--nice-danger, #ff5722)",success:"var(--nice-success, #4caf50)",warning:"var(--nice-warning, #ffc107)",error:"var(--nice-danger, #f44336)",info:"#03a9f4",text:"var(--nice-text-primary, #fff)",textMuted:"#b0bec5",border:"#ffffff40",surface:"var(--nice-primary, #2196f3)",surfaceAlt:"var(--nice-primary-dark, #1565c0)"}),Zo={id:"infographic-bold",name:"Infographic Bold",category:"creative",config:be({background:"#eceff1",gridColor:"#b0bec520",gridSize:24,selectionColor:"var(--nice-danger, #ff5722)"},Ko,"'Montserrat', 'Roboto', sans-serif",{backgroundColor:"var(--nice-primary, #2196f3)",borderColor:"var(--nice-primary-dark, #1565c0)",borderWidth:0,fontColor:"var(--nice-text-on-primary, #fff)",fontWeight:"bold",borderRadius:12,shadow:!0},{strokeColor:"#90a4ae",strokeWidth:3},{backgroundColor:"#2196f320",borderWidth:2,borderRadius:16})},Jo=ye({primary:"#9333ea",primaryLight:"var(--nice-accent, #c084fc)",secondary:"var(--nice-info, #6366f1)",accent:"var(--nice-warning, #f59e0b)",text:"var(--nice-text-primary, #f1f5f9)",textMuted:"var(--nice-accent, #a78bfa)",border:"#7c3aed40",surface:"#1c1033",surfaceAlt:"#2d1b69"}),Qo={id:"midnight-purple",name:"Midnight Purple",category:"dark",config:be({background:"#0f0720",gridColor:"#9333ea10",gridSize:20,selectionColor:"var(--nice-accent, #c084fc)"},Jo,Be,{borderColor:"#9333ea",borderWidth:2,gradientColor:"#2d1b69",gradientDirection:"vertical",shadow:!1},{strokeColor:"#9333ea80",strokeWidth:2},{},{glowColor:"#9333ea",glowIntensity:.6,liquidColor:"#9333ea",liquidColorEnd:"var(--nice-accent, #c084fc)"})},yt=[no,lo,uo,Mo,Io,ho,go,yo,Co,wo,Do,$o,Po,vo,Ro,No,Fo,Wo,Vo,Go,Ho,Xo,Zo,Qo],ei=[{id:"fill-solid",name:"Solid Fill",category:"fill",style:{opacity:1}},{id:"fill-gradient-v",name:"Vertical Gradient",category:"fill",style:{gradientColor:"var(--nice-text-secondary, #e2e8f0)",gradientDirection:"vertical"}},{id:"fill-gradient-h",name:"Horizontal Gradient",category:"fill",style:{gradientColor:"var(--nice-text-secondary, #e2e8f0)",gradientDirection:"horizontal"}},{id:"fill-gradient-d",name:"Diagonal Gradient",category:"fill",style:{gradientColor:"var(--nice-text-secondary, #e2e8f0)",gradientDirection:"diagonal"}},{id:"fill-gradient-r",name:"Radial Gradient",category:"fill",style:{gradientColor:"var(--nice-text-secondary, #e2e8f0)",gradientDirection:"radial"}},{id:"fill-transparent",name:"Transparent",category:"fill",style:{backgroundColor:"transparent",opacity:1}},{id:"fill-semi",name:"Semi-transparent",category:"fill",style:{opacity:.6}},{id:"fill-glass",name:"Glassmorphism",category:"fill",style:{opacity:.7,gradientColor:"#ffffff40",gradientDirection:"vertical",borderWidth:1,borderColor:"#ffffff60"}},{id:"border-none",name:"No Border",category:"border",style:{borderWidth:0}},{id:"border-thin",name:"Thin Border",category:"border",style:{borderWidth:1}},{id:"border-medium",name:"Medium Border",category:"border",style:{borderWidth:2}},{id:"border-thick",name:"Thick Border",category:"border",style:{borderWidth:3}},{id:"border-heavy",name:"Heavy Border",category:"border",style:{borderWidth:4}},{id:"border-solid",name:"Solid",category:"border",style:{borderStyle:"solid"}},{id:"border-dashed",name:"Dashed",category:"border",style:{borderStyle:"dashed"}},{id:"border-dotted",name:"Dotted",category:"border",style:{borderStyle:"dotted"}},{id:"border-rounded-sm",name:"Rounded Small",category:"border",style:{borderRadius:4}},{id:"border-rounded-md",name:"Rounded Medium",category:"border",style:{borderRadius:8}},{id:"border-rounded-lg",name:"Rounded Large",category:"border",style:{borderRadius:16}},{id:"border-rounded-xl",name:"Rounded XL",category:"border",style:{borderRadius:24}},{id:"border-pill",name:"Pill / Capsule",category:"border",style:{borderRadius:999}},{id:"border-sharp",name:"Sharp Corners",category:"border",style:{borderRadius:0}},{id:"effect-shadow",name:"Drop Shadow",category:"effect",style:{shadow:!0}},{id:"effect-no-shadow",name:"No Shadow",category:"effect",style:{shadow:!1}},{id:"effect-glow-blue",name:"Blue Glow",category:"effect",style:{glowColor:"var(--nice-primary, #3b82f6)",glowIntensity:.6}},{id:"effect-glow-green",name:"Green Glow",category:"effect",style:{glowColor:"var(--nice-success, #10b981)",glowIntensity:.6}},{id:"effect-glow-red",name:"Red Glow",category:"effect",style:{glowColor:"var(--nice-danger, #ef4444)",glowIntensity:.6}},{id:"effect-glow-purple",name:"Purple Glow",category:"effect",style:{glowColor:"var(--nice-accent, #8b5cf6)",glowIntensity:.6}},{id:"effect-glow-gold",name:"Gold Glow",category:"effect",style:{glowColor:"var(--nice-warning, #f59e0b)",glowIntensity:.6}},{id:"effect-glow-neon",name:"Neon Glow",category:"effect",style:{glowColor:"var(--nice-success, #00ff88)",glowIntensity:.8}}],ti=[{id:"line-straight",name:"Straight",category:"type",style:{lineType:"straight"}},{id:"line-bezier",name:"Bezier Curve",category:"type",style:{lineType:"bezier"}},{id:"line-orthogonal",name:"Orthogonal",category:"type",style:{lineType:"orthogonal"}},{id:"line-step",name:"Step",category:"type",style:{lineType:"step"}},{id:"stroke-thin",name:"Thin Stroke",category:"stroke",style:{strokeWidth:1}},{id:"stroke-medium",name:"Medium Stroke",category:"stroke",style:{strokeWidth:2}},{id:"stroke-thick",name:"Thick Stroke",category:"stroke",style:{strokeWidth:3}},{id:"stroke-heavy",name:"Heavy Stroke",category:"stroke",style:{strokeWidth:4}},{id:"stroke-solid",name:"Solid",category:"stroke",style:{strokeDash:[]}},{id:"stroke-dashed",name:"Dashed",category:"stroke",style:{strokeDash:[8,4]}},{id:"stroke-dotted",name:"Dotted",category:"stroke",style:{strokeDash:[2,4]}},{id:"stroke-dash-dot",name:"Dash-Dot",category:"stroke",style:{strokeDash:[8,4,2,4]}},{id:"stroke-long-dash",name:"Long Dash",category:"stroke",style:{strokeDash:[16,8]}},{id:"arrow-target-none",name:"No Target Arrow",category:"arrow",style:{targetArrow:"none"}},{id:"arrow-target-arrow",name:"Arrow →",category:"arrow",style:{targetArrow:"arrow"}},{id:"arrow-target-open",name:"Open Arrow ▷",category:"arrow",style:{targetArrow:"openArrow"}},{id:"arrow-target-diamond",name:"Diamond ◇",category:"arrow",style:{targetArrow:"diamond"}},{id:"arrow-target-circle",name:"Circle ○",category:"arrow",style:{targetArrow:"circle"}},{id:"arrow-source-none",name:"No Source Arrow",category:"arrow",style:{sourceArrow:"none"}},{id:"arrow-source-arrow",name:"← Source Arrow",category:"arrow",style:{sourceArrow:"arrow"}},{id:"arrow-source-open",name:"◁ Open Source",category:"arrow",style:{sourceArrow:"openArrow"}},{id:"arrow-source-diamond",name:"◇ Diamond Source",category:"arrow",style:{sourceArrow:"diamond"}},{id:"arrow-source-circle",name:"○ Circle Source",category:"arrow",style:{sourceArrow:"circle"}},{id:"arrow-bidirectional",name:"↔ Bidirectional",category:"arrow",style:{sourceArrow:"arrow",targetArrow:"arrow"}},{id:"arrow-association",name:" Association (none)",category:"arrow",style:{sourceArrow:"none",targetArrow:"none"}},{id:"arrow-composition",name:"◆→ Composition",category:"arrow",style:{sourceArrow:"diamond",targetArrow:"arrow"}},{id:"arrow-aggregation",name:"◇→ Aggregation",category:"arrow",style:{sourceArrow:"diamond",targetArrow:"arrow"}},{id:"arrow-dependency",name:"- - → Dependency",category:"arrow",style:{targetArrow:"openArrow",strokeDash:[8,4]}},{id:"arrow-inheritance",name:"△→ Inheritance",category:"arrow",style:{targetArrow:"openArrow"}},{id:"effect-animated",name:"Animated Flow",category:"effect",style:{animated:!0,flowSpeed:1}},{id:"effect-animated-fast",name:"Fast Animated",category:"effect",style:{animated:!0,flowSpeed:2}},{id:"effect-animated-slow",name:"Slow Animated",category:"effect",style:{animated:!0,flowSpeed:.5}},{id:"effect-liquid",name:"Liquid Flow",category:"effect",style:{liquidFlow:{active:!0,color:"var(--nice-primary, #3b82f6)",speed:1}}},{id:"effect-liquid-neon",name:"Neon Liquid",category:"effect",style:{liquidFlow:{active:!0,color:"var(--nice-success, #00ff88)",colorEnd:"var(--nice-info, #00ffff)",speed:1.5,particleDensity:5}}}],cr=[{id:"tp-fade-in",name:"Fade In",effect:"fadeIn",durationMs:400,easing:"easeOut",description:"Smoothly fades in"},{id:"tp-fade-out",name:"Fade Out",effect:"fadeOut",durationMs:400,easing:"easeIn",description:"Smoothly fades out"},{id:"tp-slide-left",name:"Slide Left",effect:"slideInLeft",durationMs:500,easing:"easeOut",description:"Slides in from left"},{id:"tp-slide-right",name:"Slide Right",effect:"slideInRight",durationMs:500,easing:"easeOut",description:"Slides in from right"},{id:"tp-slide-top",name:"Slide Down",effect:"slideInTop",durationMs:500,easing:"easeOut",description:"Slides in from top"},{id:"tp-slide-bottom",name:"Slide Up",effect:"slideInBottom",durationMs:500,easing:"easeOut",description:"Slides in from bottom"},{id:"tp-zoom-in",name:"Zoom In",effect:"zoomIn",durationMs:400,easing:"spring",description:"Zooms in with spring"},{id:"tp-zoom-out",name:"Zoom Out",effect:"zoomOut",durationMs:400,easing:"easeIn",description:"Zooms out"},{id:"tp-bounce",name:"Bounce In",effect:"bounce",durationMs:800,easing:"bounce",description:"Bounces into place"},{id:"tp-pulse",name:"Pulse",effect:"pulse",durationMs:1e3,easing:"easeInOut",description:"Pulsing scale effect"},{id:"tp-shake",name:"Shake",effect:"shake",durationMs:600,easing:"linear",description:"Shakes horizontally"},{id:"tp-glow",name:"Glow",effect:"glow",durationMs:1200,easing:"easeInOut",description:"Glowing highlight"},{id:"tp-highlight",name:"Highlight",effect:"highlight",durationMs:800,easing:"easeInOut",description:"Golden highlight flash"},{id:"tp-ripple",name:"Ripple",effect:"ripple",durationMs:1e3,easing:"easeOut",description:"Ripple wave effect"},{id:"tp-expand",name:"Expand",effect:"expand",durationMs:500,easing:"spring",description:"Expand from collapsed"},{id:"tp-collapse",name:"Collapse",effect:"collapse",durationMs:400,easing:"easeIn",description:"Collapse to hidden"},{id:"tp-color-shift",name:"Color Shift",effect:"colorShift",durationMs:2e3,easing:"linear",description:"Rainbow color cycle"},{id:"tp-liquid-fill",name:"Liquid Fill",effect:"liquidFill",durationMs:1500,easing:"easeInOut",description:"Liquid filling effect"},{id:"tp-draw-path",name:"Draw Path",effect:"drawPath",durationMs:1200,easing:"easeOut",description:"Edge draws itself"},{id:"tp-particle-trail",name:"Particle Trail",effect:"particleTrail",durationMs:2e3,easing:"linear",description:"Particles along edge"},{id:"tp-typewriter",name:"Typewriter",effect:"typewriter",durationMs:1500,easing:"linear",description:"Text appears letter by letter"}];function ri(o){return yt.find(e=>e.id===o)}function oi(o){return yt.filter(e=>e.category===o)}function ii(o){return{canvasBackground:o.canvas.background,gridColor:o.canvas.gridColor,gridSize:o.canvas.gridSize,selectionColor:o.canvas.selectionColor,fontFamily:o.fontFamily,nodeDefaults:o.nodeDefaults,edgeDefaults:o.edgeDefaults,groupDefaults:o.groupDefaults,palette:o.palette,effects:o.effects}}function ai(o,e,t,r,i,a){const s=ye({primary:t.primary,primaryLight:t.primaryHover,secondary:t.info,accent:t.warning,success:t.success,warning:t.warning,error:t.error,info:t.info,text:i.primary,textMuted:i.muted,border:a.color,surface:r.primary,surfaceAlt:r.secondary}),c=ni(r.primary);return{id:o,name:`${e} Theme`,category:"theme-based",themeSource:e,config:be({background:r.primary,gridColor:c?`${a.color}40`:`${a.color}20`,gridSize:20,selectionColor:t.primary},s,Be,{shadow:!c,borderWidth:c?1:2},{strokeColor:c?`${a.color}80`:a.color})}}function ni(o){const e=o.replace("#","");if(e.length<6)return!1;const t=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),i=parseInt(e.slice(4,6),16);return(t*299+r*587+i*114)/1e3<128}const si=["fadeIn","fadeOut","slideInLeft","slideInRight","slideInTop","slideInBottom","zoomIn","zoomOut","pulse","shake","highlight","flowPulse","bounce","glow","colorShift","liquidFill","expand","collapse","ripple","typewriter","morphShape","drawPath","particleTrail"],li=["linear","easeIn","easeOut","easeInOut","spring","bounce"],bt=({animations:o,onAdd:e,onRemove:t,onUpdate:r,onPlay:i,onStop:a,isPlaying:s=!1,availableTargets:c=[],className:l})=>{const{t:u}=Re(),[d,w]=p.useState(!1),[x,g]=p.useState(null),h=p.useCallback(()=>{if(!e||c.length===0)return;const b=c[0];e({name:`Animation ${o.length+1}`,targetId:b.id,targetType:b.type,effect:"fadeIn",startMs:o.length*500,durationMs:600,easing:"easeOut"})},[e,o.length,c]),v=p.useCallback(b=>{if(!e||c.length===0)return;const m=c[0];e({name:b.name,targetId:m.id,targetType:m.type,effect:b.effect,startMs:o.length*500,durationMs:b.durationMs,easing:b.easing}),w(!1)},[e,o.length,c]),_=Math.max(2e3,...o.map(b=>b.startMs+b.durationMs+(b.delayMs??0)));return n.jsxs("div",{className:`nice-diagram-timeline ${l??""}`,children:[n.jsxs("div",{className:"nice-diagram-timeline__header",children:[n.jsx("h4",{className:"nice-diagram-timeline__title",children:u("animation.timeline")}),n.jsxs("div",{className:"nice-diagram-timeline__controls",children:[s?n.jsxs(y.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:a,children:[n.jsx(y.NiceIcon,{name:"stop",size:14})," ",u("animation.stop")]}):n.jsxs(y.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:i,children:[n.jsx(y.NiceIcon,{name:"play",size:14})," ",u("animation.play")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:h,disabled:c.length===0,children:[n.jsx(y.NiceIcon,{name:"plus",size:14})," ",u("animation.add")]}),n.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[n.jsxs(y.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:()=>w(b=>!b),disabled:c.length===0,title:u("animation.addFromPreset","Add from preset"),children:[n.jsx(y.NiceIcon,{name:"video",size:14})," ",u("animation.presets","Presets")]}),d&&n.jsx("div",{style:{position:"absolute",bottom:"100%",left:0,background:"var(--nice-bg, #fff)",border:"1px solid var(--nice-border, #ddd)",borderRadius:6,boxShadow:"0 4px 12px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",maxHeight:280,overflowY:"auto",width:200,zIndex:100},children:cr.map(b=>n.jsx(y.NiceButton,{variant:"ghost",size:"sm",onClick:()=>v(b),style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",fontSize:12,borderBottom:"1px solid var(--nice-bg-secondary, #f0f0f0)"},title:`${b.effect} — ${b.durationMs}ms ${b.easing}`,children:b.name},b.id))})]})]})]}),n.jsxs("div",{className:"nice-diagram-timeline__tracks",children:[o.length===0&&n.jsx("p",{className:"nice-diagram-timeline__empty",children:u("animation.noAnimations")}),o.map(b=>{const m=b.startMs/_*100,A=b.durationMs/_*100,k=x===b.id;return n.jsxs("div",{className:"nice-diagram-timeline__track",children:[n.jsxs("div",{className:"nice-diagram-timeline__track-label",children:[n.jsx("span",{role:"button",tabIndex:0,onKeyDown:y.clickOnActivationKey,className:"nice-diagram-timeline__track-name",onClick:()=>g(k?null:b.id),style:{cursor:"pointer"},title:u("animation.clickToEdit","Click to edit"),children:b.name}),n.jsx("span",{className:"nice-diagram-timeline__track-effect",children:b.effect}),n.jsx(y.NiceButton,{className:"nice-diagram-timeline__track-remove",variant:"ghost",size:"sm",onClick:()=>t==null?void 0:t(b.id),title:u("toolbar.delete"),children:n.jsx(y.NiceIcon,{name:"close",size:14})})]}),k&&n.jsxs("div",{className:"nice-diagram-timeline__track-editor",style:{display:"flex",gap:4,padding:"4px 0",flexWrap:"wrap",fontSize:11},children:[n.jsx(y.NiceSelect,{value:b.effect,onChange:j=>r==null?void 0:r(b.id,{effect:j}),options:si.map(j=>({value:j,label:j})),style:{fontSize:11,padding:"1px 4px"}}),n.jsx(y.NiceSelect,{value:b.easing,onChange:j=>r==null?void 0:r(b.id,{easing:j}),options:li.map(j=>({value:j,label:j})),style:{fontSize:11,padding:"1px 4px"}}),n.jsx(y.NiceSelect,{value:b.targetId,onChange:j=>{const M=c.find(X=>X.id===j);M&&(r==null||r(b.id,{targetId:M.id,targetType:M.type}))},options:c.map(j=>({value:j.id,label:j.label})),style:{fontSize:11,padding:"1px 4px",maxWidth:100}}),n.jsx(y.NiceNumberInput,{value:b.startMs,min:0,step:100,onChange:j=>r==null?void 0:r(b.id,{startMs:j??0}),style:{width:60,fontSize:11},title:u("animation.startMs","Start (ms)")}),n.jsx(y.NiceNumberInput,{value:b.durationMs,min:50,step:50,onChange:j=>r==null?void 0:r(b.id,{durationMs:j??50}),style:{width:60,fontSize:11},title:u("animation.durationMs","Duration (ms)")})]}),n.jsx("div",{className:"nice-diagram-timeline__track-bar",children:n.jsx("div",{className:"nice-diagram-timeline__track-segment",style:{left:`${m}%`,width:`${A}%`},title:`${b.effect} ${b.startMs}ms → ${b.startMs+b.durationMs}ms (${b.easing})`})})]},b.id)})]}),n.jsx("div",{className:"nice-diagram-timeline__ruler",children:Array.from({length:5}).map((b,m)=>{const A=Math.round(_/4*m);return n.jsxs("span",{className:"nice-diagram-timeline__ruler-mark",style:{left:`${m/4*100}%`},children:[A,"ms"]},m)})})]})};process.env.NODE_ENV!=="production"&&(bt.displayName="AnimationTimeline");function Tt(o){let e=1/0,t=1/0,r=-1/0,i=-1/0;for(const a of o)a.hidden||(e=Math.min(e,a.position.x),t=Math.min(t,a.position.y),r=Math.max(r,a.position.x+a.size.width),i=Math.max(i,a.position.y+a.size.height));return Number.isFinite(e)?{x:e,y:t,width:r-e,height:i-t}:null}function Pt(o,e,t={}){const{padding:r=40,maxZoom:i=1.25,minZoom:a=.1}=t;if(!o||e.width<=0||e.height<=0)return{x:0,y:0,zoom:1};const s=(e.width-2*r)/Math.max(o.width,1),c=(e.height-2*r)/Math.max(o.height,1),l=Math.min(i,Math.max(a,Math.min(s,c)));return{x:(e.width-o.width*l)/2-o.x*l,y:(e.height-o.height*l)/2-o.y*l,zoom:l}}const ci=/^[a-z][a-z0-9-]*$/,di=.1,ui=5,ht=8,Nt=[{cursor:"nw-resize",dx:0,dy:0,resizeX:-1,resizeY:-1},{cursor:"n-resize",dx:.5,dy:0,resizeX:0,resizeY:-1},{cursor:"ne-resize",dx:1,dy:0,resizeX:1,resizeY:-1},{cursor:"w-resize",dx:0,dy:.5,resizeX:-1,resizeY:0},{cursor:"e-resize",dx:1,dy:.5,resizeX:1,resizeY:0},{cursor:"sw-resize",dx:0,dy:1,resizeX:-1,resizeY:1},{cursor:"s-resize",dx:.5,dy:1,resizeX:0,resizeY:1},{cursor:"se-resize",dx:1,dy:1,resizeX:1,resizeY:1}],Ee=({nodes:o,edges:e,groups:t=[],viewport:r,onViewportChange:i,theme:a,selectedId:s,selectedIds:c=[],onSelectElement:l,onMultiSelect:u,onNodeDragStart:d,onNodeDrag:w,onNodeDragEnd:x,onNodeResize:g,onNodeLabelChange:h,onEdgeCreate:v,autoFit:_=!1,fitKey:b,refitKey:m,fitPadding:A=40,fitMaxZoom:k=1.25,onResize:j,resizable:M=!0,panOnDrag:X=!1,ariaLabel:V,animationStates:F,particleState:R,viewMode:I="editor",ghostOpacity:L=.15,onGroupCollapse:W,onNodeCollapse:H,onInteraction:C,onNodeHover:$,onGroupClick:O,interactive:G=!1,showGrid:q=!0,showRulers:K=!1,snapToGrid:Z=!0,gridSnapSize:te=10,className:ge})=>{const he=p.useRef(null),Ce=p.useId().replace(/[^a-zA-Z0-9_-]/g,""),Ae=`nd-arrow-${Ce}`,$e=`nd-open-arrow-${Ce}`,me=`nd-diamond-marker-${Ce}`,Oe=`nd-circle-marker-${Ce}`,[ve,Ue]=p.useState(null),[Y,Fe]=p.useState(!1),[Le,Xe]=p.useState({x:0,y:0}),[ze,Ve]=p.useState(null),[Ne,Je]=p.useState({x:0,y:0}),[z,U]=p.useState(null),[ne,pe]=p.useState(null),[le,qe]=p.useState(null),[Qe,rt]=p.useState(null),[ee,Ge]=p.useState(""),[_e,at]=p.useState([]),ct=(a==null?void 0:a.canvasBackground)??"var(--nice-bg-secondary, #f8f9fa)",kt=(a==null?void 0:a.gridColor)??"var(--nice-border, #e0e0e0)",Ye=(a==null?void 0:a.gridSize)??20,N=(a==null?void 0:a.selectionColor)??"var(--nice-primary, #2196f3)",[T,J]=p.useState(null),se=p.useRef(!1),Me=p.useRef(null),Ie=p.useRef({nodes:o,edges:e,onViewportChange:i,onResize:j,fitPadding:A,fitMaxZoom:k});p.useEffect(()=>{Ie.current={nodes:o,edges:e,onViewportChange:i,onResize:j,fitPadding:A,fitMaxZoom:k}}),p.useEffect(()=>{const f=he.current;if(!f)return;const S=()=>{const D=f.getBoundingClientRect();D.width>0&&D.height>0&&J(Q=>Q&&Q.width===D.width&&Q.height===D.height?Q:{width:D.width,height:D.height})};if(S(),typeof ResizeObserver>"u")return;const P=new ResizeObserver(S);return P.observe(f),()=>P.disconnect()},[]),p.useEffect(()=>{var f,S;T&&((S=(f=Ie.current).onResize)==null||S.call(f,T))},[T]),p.useEffect(()=>{const f=Me.current;f&&(f.x!==r.x||f.y!==r.y||f.zoom!==r.zoom)&&(se.current=!0)},[r]);const ot=p.useRef(m);p.useEffect(()=>{const{nodes:f,edges:S,onViewportChange:P,fitPadding:D,fitMaxZoom:Q}=Ie.current,E=m!==ot.current;if(ot.current=m,E&&(se.current=!1),!T||!P||!_&&!E||se.current)return;const B=Pt(fi(f,S),T,{padding:D,maxZoom:Q});Me.current=B,P(B)},[_,T,b,m]);const je=p.useMemo(()=>{const f=new Set(c);return s&&f.add(s),f},[s,c]),Pe=p.useCallback(f=>Z?Math.round(f/te)*te:f,[Z,te]),Lt=p.useCallback((f,S,P)=>{const D=[],E=S.x,B=S.y,ie=E+P.width/2,re=B+P.height/2,oe=E+P.width,ae=B+P.height;for(const we of o){if(we.id===f)continue;const xe=we.position.x,de=we.position.y,Se=xe+we.size.width/2,et=de+we.size.height/2,He=xe+we.size.width,We=de+we.size.height;Math.abs(E-xe)<5&&D.push({x:xe}),Math.abs(oe-He)<5&&D.push({x:He}),Math.abs(ie-Se)<5&&D.push({x:Se}),Math.abs(E-He)<5&&D.push({x:He}),Math.abs(oe-xe)<5&&D.push({x:xe}),Math.abs(B-de)<5&&D.push({y:de}),Math.abs(ae-We)<5&&D.push({y:We}),Math.abs(re-et)<5&&D.push({y:et}),Math.abs(B-We)<5&&D.push({y:We}),Math.abs(ae-de)<5&&D.push({y:de})}at(D)},[o]),Tr=p.useCallback(f=>{if(f.preventDefault(),!i)return;const S=f.deltaY>0?.9:1.1,P=Math.min(ui,Math.max(di,r.zoom*S)),D=he.current;if(!D)return;const Q=D.getBoundingClientRect(),E=f.clientX-Q.left,B=f.clientY-Q.top,ie=P/r.zoom,re=E-(E-r.x)*ie,oe=B-(B-r.y)*ie;se.current=!0,i({x:re,y:oe,zoom:P})},[r,i]),Pr=p.useCallback(f=>{if(f.button===1||f.button===0&&f.target.tagName==="svg"){if(f.button===0&&G&&!X&&!f.shiftKey&&f.target.tagName==="svg"){const S=he.current;if(S){const P=S.getBoundingClientRect(),D=(f.clientX-P.left-r.x)/r.zoom,Q=(f.clientY-P.top-r.y)/r.zoom;pe({x:D,y:Q}),U({x1:D,y1:Q,x2:D,y2:Q})}l&&l(null),u&&u([]);return}Fe(!0),Xe({x:f.clientX-r.x,y:f.clientY-r.y}),l&&f.button===0&&l(null)}},[r,l,u,G,X]),dt=p.useCallback(f=>{const S=he.current;if(!S)return null;const P=S.getBoundingClientRect();return{x:(f.clientX-P.left-r.x)/r.zoom,y:(f.clientY-P.top-r.y)/r.zoom}},[r]),Er=p.useCallback(f=>{if(ve){const S=dt(f);S&&Ue(P=>P&&{...P,to:S});return}if(ne){const S=he.current;if(!S)return;const P=S.getBoundingClientRect(),D=(f.clientX-P.left-r.x)/r.zoom,Q=(f.clientY-P.top-r.y)/r.zoom;U({x1:ne.x,y1:ne.y,x2:D,y2:Q});return}if(Y&&i){se.current=!0,i({...r,x:f.clientX-Le.x,y:f.clientY-Le.y});return}if(le&&g){const S=he.current;if(!S)return;const P=S.getBoundingClientRect(),D=(f.clientX-P.left-r.x)/r.zoom,Q=(f.clientY-P.top-r.y)/r.zoom,E=D-le.startMouse.x,B=Q-le.startMouse.y,ie=Nt[le.handleIdx];let re=le.startSize.width+E*ie.resizeX,oe=le.startSize.height+B*ie.resizeY,ae=le.startPos.x+(ie.resizeX<0?E:0),we=le.startPos.y+(ie.resizeY<0?B:0);re=Math.max(30,Pe(re)),oe=Math.max(20,Pe(oe)),ae=Pe(ae),we=Pe(we),g(le.nodeId,{width:re,height:oe},{x:ae,y:we});return}if(ze&&w){const S=he.current;if(!S)return;const P=S.getBoundingClientRect(),D=Pe((f.clientX-P.left-r.x)/r.zoom-Ne.x),Q=Pe((f.clientY-P.top-r.y)/r.zoom-Ne.y);w(ze,{x:D,y:Q});const E=o.find(B=>B.id===ze);E&&Lt(ze,{x:D,y:Q},E.size)}},[ve,dt,ne,Y,i,r,Le,le,g,ze,w,Ne,Pe,o,Lt]),Wt=p.useCallback(f=>{if(ve){const S=dt(f),P=S?[...o].reverse().find(D=>D.id!==ve.nodeId&&!D.hidden&&S.x>=D.position.x&&S.x<=D.position.x+D.size.width&&S.y>=D.position.y&&S.y<=D.position.y+D.size.height):void 0;P&&S&&(v==null||v(ve.nodeId,P.id,ve.portId,hi(P,S))),Ue(null);return}if(z&&ne){const S=Math.min(z.x1,z.x2),P=Math.min(z.y1,z.y2),D=Math.max(z.x1,z.x2),Q=Math.max(z.y1,z.y2);if(Math.abs(D-S)>5||Math.abs(Q-P)>5){const E=o.filter(B=>{const ie=B.position.x,re=B.position.y,oe=ie+B.size.width,ae=re+B.size.height;return oe>S&&ie<D&&ae>P&&re<Q}).map(B=>B.id);u==null||u(E),E.length===1&&(l==null||l(E[0]))}U(null),pe(null);return}if(Y&&Fe(!1),le){qe(null);return}if(ze&&x){const S=he.current;if(!S)return;const P=S.getBoundingClientRect(),D=Pe((f.clientX-P.left-r.x)/r.zoom-Ne.x),Q=Pe((f.clientY-P.top-r.y)/r.zoom-Ne.y);x(ze,{x:D,y:Q})}Ve(null),at([])},[ve,dt,v,z,ne,Y,le,ze,x,r,Ne,Pe,o,u,l]),Rr=p.useCallback((f,S)=>{if(f.stopPropagation(),!G)return;const P=o.find(ie=>ie.id===S);if(!P||P.locked)return;if(f.shiftKey&&u){const ie=[...c],re=ie.indexOf(S);re>=0?ie.splice(re,1):ie.push(S),u(ie);return}l==null||l(S);const D=he.current;if(!D)return;const Q=D.getBoundingClientRect(),E=(f.clientX-Q.left-r.x)/r.zoom,B=(f.clientY-Q.top-r.y)/r.zoom;Je({x:E-P.position.x,y:B-P.position.y}),Ve(S),d==null||d(S)},[G,o,r,l,d,u,c]),Or=p.useCallback((f,S,P)=>{if(f.stopPropagation(),!G)return;const D=o.find(re=>re.id===S);if(!D||D.locked)return;const Q=he.current;if(!Q)return;const E=Q.getBoundingClientRect(),B=(f.clientX-E.left-r.x)/r.zoom,ie=(f.clientY-E.top-r.y)/r.zoom;qe({nodeId:S,handleIdx:P,startMouse:{x:B,y:ie},startPos:{...D.position},startSize:{...D.size}}),l==null||l(S)},[G,o,r,l]),Fr=p.useCallback((f,S)=>{if(f.stopPropagation(),!G||!h)return;const P=o.find(D=>D.id===S);!P||P.locked||(rt(S),Ge(P.label))},[G,o,h]),Bt=p.useCallback(()=>{Qe&&h&&h(Qe,ee),rt(null)},[Qe,ee,h]),Lr=p.useCallback((f,S)=>{f.stopPropagation(),l==null||l(S)},[l]),Wr=p.useCallback(f=>dr(f,o),[o]),Br=p.useCallback((f,S)=>{const{size:P,style:D,shape:Q}=f,E=P.width,B=P.height,re=!!(D.gradientColor&&D.backgroundColor)?`url(#${S})`:D.backgroundColor??"var(--nice-bg, #fff)",oe=D.borderColor??"var(--nice-text, #333333)",ae=D.borderWidth??1,we=D.borderRadius??(Q==="roundedRect"?8:0),xe=D.borderStyle==="dashed"?"8,4":D.borderStyle==="dotted"?"2,4":void 0,de=D.shadow?"url(#nd-shadow)":void 0;switch(Q){case"ellipse":case"circle":return n.jsx("ellipse",{cx:E/2,cy:B/2,rx:E/2,ry:B/2,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:xe,filter:de});case"diamond":return n.jsx("polygon",{points:`${E/2},0 ${E},${B/2} ${E/2},${B} 0,${B/2}`,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:xe,filter:de});case"hexagon":{const Se=E/4;return n.jsx("polygon",{points:`${Se},0 ${E-Se},0 ${E},${B/2} ${E-Se},${B} ${Se},${B} 0,${B/2}`,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:xe,filter:de})}case"parallelogram":{const Se=E*.15;return n.jsx("polygon",{points:`${Se},0 ${E},0 ${E-Se},${B} 0,${B}`,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:xe,filter:de})}case"cylinder":return n.jsxs("g",{filter:de,children:[n.jsx("ellipse",{cx:E/2,cy:B*.1,rx:E/2,ry:B*.1,fill:re,stroke:oe,strokeWidth:ae}),n.jsx("rect",{x:0,y:B*.1,width:E,height:B*.8,fill:re,stroke:"none"}),n.jsx("line",{x1:0,y1:B*.1,x2:0,y2:B*.9,stroke:oe,strokeWidth:ae}),n.jsx("line",{x1:E,y1:B*.1,x2:E,y2:B*.9,stroke:oe,strokeWidth:ae}),n.jsx("ellipse",{cx:E/2,cy:B*.9,rx:E/2,ry:B*.1,fill:re,stroke:oe,strokeWidth:ae})]});case"triangle":return n.jsx("polygon",{points:`${E/2},0 ${E},${B} 0,${B}`,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:xe,filter:de});case"cloud":{const Se=`M${E*.25},${B*.8} A${E*.2},${E*.2},0,1,1,${E*.15},${B*.45} A${E*.18},${E*.18},0,1,1,${E*.35},${B*.2} A${E*.2},${E*.2},0,1,1,${E*.65},${B*.2} A${E*.18},${E*.18},0,1,1,${E*.85},${B*.45} A${E*.2},${E*.2},0,1,1,${E*.75},${B*.8} Z`;return n.jsx("path",{d:Se,fill:re,stroke:oe,strokeWidth:ae,filter:de})}case"document":{const Se=`M 0 0 L ${E} 0 L ${E} ${B*.85} Q ${E*.75} ${B*.7}, ${E*.5} ${B*.85} Q ${E*.25} ${B}, 0 ${B*.85} Z`;return n.jsx("path",{d:Se,fill:re,stroke:oe,strokeWidth:ae,filter:de})}case"actor":return n.jsxs("g",{stroke:oe,strokeWidth:ae,fill:"none",filter:de,children:[n.jsx("circle",{cx:E/2,cy:B*.15,r:B*.12,fill:re}),n.jsx("line",{x1:E/2,y1:B*.27,x2:E/2,y2:B*.6}),n.jsx("line",{x1:E*.15,y1:B*.4,x2:E*.85,y2:B*.4}),n.jsx("line",{x1:E/2,y1:B*.6,x2:E*.2,y2:B}),n.jsx("line",{x1:E/2,y1:B*.6,x2:E*.8,y2:B})]});case"rectangle":case"roundedRect":case"custom":default:return n.jsx("rect",{width:E,height:B,rx:we,ry:we,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:xe,filter:de})}},[]),Vt=p.useCallback(f=>{if(!F)return{};const S=F.get(f);if(!S)return{};const P=S.glow>0?`drop-shadow(0 0 ${S.glow}px gold)`:"",D=S.highlightColor?`drop-shadow(0 0 6px ${S.highlightColor})`:"";return{opacity:S.opacity,transform:`translate(${S.translateX}px, ${S.translateY}px) scale(${S.scale})`,filter:[P,D].filter(Boolean).join(" ")||void 0}},[F]),Vr=p.useMemo(()=>{if(!R)return null;const f=[];for(const[,S]of R.glowStates){const P=tr(S.elementId),D=rr(S.intensity,S.pulse);f.push(n.jsxs("filter",{id:P,x:"-50%",y:"-50%",width:"200%",height:"200%",children:[n.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:D,result:"blur"}),n.jsx("feFlood",{floodColor:S.color,floodOpacity:.6,result:"color"}),n.jsx("feComposite",{in:"color",in2:"blur",operator:"in",result:"glowColored"}),n.jsxs("feMerge",{children:[n.jsx("feMergeNode",{in:"glowColored"}),n.jsx("feMergeNode",{in:"SourceGraphic"})]})]},P))}return f},[R]),qr=p.useMemo(()=>{if(!R)return null;const f=[];for(const[S,P]of R.liquidFlows){if(!P.active)continue;const D=e.find(re=>re.id===S);if(!(D!=null&&D.style.liquidFlow))continue;const{color:Q,colorEnd:E}=D.style.liquidFlow,B=`nd-liquid-${S}`,ie=P.gradientOffset;f.push(n.jsxs("linearGradient",{id:B,x1:"0",y1:"0",x2:"1",y2:"0",children:[n.jsx("stop",{offset:`${ie*100%100}%`,stopColor:Q,stopOpacity:.8}),n.jsx("stop",{offset:`${(ie+.3)*100%100}%`,stopColor:E??Q,stopOpacity:.4}),n.jsx("stop",{offset:`${(ie+.6)*100%100}%`,stopColor:Q,stopOpacity:.8})]},B))}return f},[R,e]),Gr=p.useMemo(()=>o.filter(f=>f.style.gradientColor&&f.style.backgroundColor).map(f=>{const S=`nd-grad-${f.id}`,P=f.style.gradientDirection??"vertical";if(P==="radial")return n.jsxs("radialGradient",{id:S,children:[n.jsx("stop",{offset:"0%",stopColor:f.style.backgroundColor}),n.jsx("stop",{offset:"100%",stopColor:f.style.gradientColor})]},S);const D=P==="horizontal"||P==="diagonal"?"1":"0",Q=P==="vertical"||P==="diagonal"?"1":"0";return n.jsxs("linearGradient",{id:S,x1:"0",y1:"0",x2:D,y2:Q,children:[n.jsx("stop",{offset:"0%",stopColor:f.style.backgroundColor}),n.jsx("stop",{offset:"100%",stopColor:f.style.gradientColor})]},S)}),[o]);return n.jsxs("svg",{ref:he,className:`nice-diagram-canvas ${ge??""}`,style:{width:"100%",height:"100%",background:ct,cursor:Y?"grabbing":le?le.nodeId?Nt[le.handleIdx].cursor:"default":ve?"crosshair":X?"grab":"default"},"aria-label":V,onWheel:Tr,onMouseDown:Pr,onMouseMove:Er,onMouseUp:Wt,onMouseLeave:Wt,children:[n.jsxs("defs",{children:[n.jsx("marker",{id:Ae,viewBox:"0 0 10 10",refX:"10",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:n.jsx("path",{d:"M 0 0 L 10 5 L 0 10 Z",fill:"var(--nice-text, #333)"})}),n.jsx("marker",{id:$e,viewBox:"0 0 10 10",refX:"10",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:n.jsx("path",{d:"M 0 0 L 10 5 L 0 10",fill:"none",stroke:"var(--nice-text, #333)",strokeWidth:"1.5"})}),n.jsx("marker",{id:me,viewBox:"0 0 10 10",refX:"5",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"15",markerHeight:"15",orient:"auto-start-reverse",children:n.jsx("polygon",{points:"5,0 10,5 5,10 0,5",fill:"var(--nice-text, #333)"})}),n.jsx("marker",{id:Oe,viewBox:"0 0 10 10",refX:"5",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:n.jsx("circle",{cx:"5",cy:"5",r:"4",fill:"var(--nice-text, #333)"})}),n.jsx("filter",{id:"nd-shadow",x:"-10%",y:"-10%",width:"130%",height:"130%",children:n.jsx("feDropShadow",{dx:"2",dy:"2",stdDeviation:"3",floodColor:"#00000033"})}),q&&n.jsx("pattern",{id:"nd-grid",width:Ye,height:Ye,patternUnits:"userSpaceOnUse",children:n.jsx("path",{d:`M ${Ye} 0 L 0 0 0 ${Ye}`,fill:"none",stroke:kt,strokeWidth:"0.5"})}),Gr,Vr,qr,o.filter(f=>f.style.glowColor).map(f=>{const S=`nd-node-glow-${f.id}`,P=(f.style.glowIntensity??.5)*10;return n.jsxs("filter",{id:S,x:"-50%",y:"-50%",width:"200%",height:"200%",children:[n.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:P,result:"blur"}),n.jsx("feFlood",{floodColor:f.style.glowColor,floodOpacity:.5,result:"color"}),n.jsx("feComposite",{in:"color",in2:"blur",operator:"in",result:"glowColored"}),n.jsxs("feMerge",{children:[n.jsx("feMergeNode",{in:"glowColored"}),n.jsx("feMergeNode",{in:"SourceGraphic"})]})]},S)})]}),K&&n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"0",y:"0",width:"100%",height:"20",fill:"var(--nice-bg-secondary, #f0f0f0)",stroke:"var(--nice-border, #ccc)",strokeWidth:"0.5"}),n.jsx("rect",{x:"0",y:"0",width:"20",height:"100%",fill:"var(--nice-bg-secondary, #f0f0f0)",stroke:"var(--nice-border, #ccc)",strokeWidth:"0.5"}),Array.from({length:100},(f,S)=>{const P=S*Ye*r.zoom+r.x,D=S*Ye;return P>20?n.jsxs("g",{children:[n.jsx("line",{x1:P,y1:"0",x2:P,y2:"20",stroke:"var(--nice-text-muted, #999)",strokeWidth:"0.5"}),n.jsx("text",{x:P+2,y:"14",fontSize:"9",fill:"var(--nice-text-secondary, #666)",children:D})]},`rx${S}`):null}),Array.from({length:100},(f,S)=>{const P=S*Ye*r.zoom+r.y,D=S*Ye;return P>20?n.jsxs("g",{children:[n.jsx("line",{x1:"0",y1:P,x2:"20",y2:P,stroke:"var(--nice-text-muted, #999)",strokeWidth:"0.5"}),n.jsx("text",{x:"2",y:P-2,fontSize:"9",fill:"var(--nice-text-secondary, #666)",writingMode:"tb",children:D})]},`ry${S}`):null})]}),n.jsxs("g",{transform:`translate(${r.x}, ${r.y}) scale(${r.zoom})`,children:[q&&n.jsx("rect",{x:"-10000",y:"-10000",width:"20000",height:"20000",fill:"url(#nd-grid)",pointerEvents:"none"}),t.map(f=>{var ie,re,oe,ae,we,xe,de,Se,et,He,We,ut;const S=o.filter(fe=>f.nodeIds.includes(fe.id));if(S.length===0&&!f.collapsed)return null;const P=((ie=f.style)==null?void 0:ie.padding)??20;if(f.collapsed){const fe=o.find(Ct=>f.nodeIds.includes(Ct.id)),nt=fe?fe.position.x:0,ft=fe?fe.position.y:0;return n.jsxs("g",{"data-group-id":f.id,style:{cursor:"pointer"},onClick:()=>W==null?void 0:W(f.id),children:[n.jsx("rect",{x:nt,y:ft,width:160,height:40,fill:((re=f.style)==null?void 0:re.backgroundColor)??"rgba(200,200,255,0.3)",stroke:((oe=f.style)==null?void 0:oe.borderColor)??"var(--nice-text-muted, #aab)",strokeWidth:((ae=f.style)==null?void 0:ae.borderWidth)??1,rx:((we=f.style)==null?void 0:we.borderRadius)??6,strokeDasharray:"6,3"}),n.jsxs("text",{x:nt+24,y:ft+24,fontSize:"12",fill:((xe=f.style)==null?void 0:xe.labelColor)??"var(--nice-text-secondary, #666)",fontWeight:"bold",children:[f.label," (",f.nodeIds.length,")"]})]},f.id)}const D=Math.min(...S.map(fe=>fe.position.x))-P,Q=Math.min(...S.map(fe=>fe.position.y))-P,E=Math.max(...S.map(fe=>fe.position.x+fe.size.width))+P,B=Math.max(...S.map(fe=>fe.position.y+fe.size.height))+P;return n.jsxs("g",{"data-group-id":f.id,children:[n.jsx("rect",{x:D,y:Q,width:E-D,height:B-Q,fill:((de=f.style)==null?void 0:de.backgroundColor)??"rgba(200,200,255,0.1)",stroke:((Se=f.style)==null?void 0:Se.borderColor)??"var(--nice-text-muted, #aab)",strokeWidth:((et=f.style)==null?void 0:et.borderWidth)??1,rx:((He=f.style)==null?void 0:He.borderRadius)??6,strokeDasharray:((We=f.style)==null?void 0:We.borderStyle)==="dashed"?"6,3":void 0}),n.jsx("text",{x:D+6,y:Q-4,fontSize:"12",fill:((ut=f.style)==null?void 0:ut.labelColor)??"var(--nice-text-secondary, #666)",fontWeight:"bold",style:O?{cursor:"pointer"}:void 0,onClick:O?fe=>{fe.stopPropagation(),O(f.id)}:void 0,children:f.label}),(G||I!=="editor")&&W&&n.jsxs("g",{style:{cursor:"pointer"},onClick:fe=>{fe.stopPropagation(),W(f.id)},children:[n.jsx("rect",{x:E-24,y:Q-12,width:20,height:20,rx:4,fill:"white",stroke:"var(--nice-text-muted, #999)",strokeWidth:1}),n.jsx("g",{transform:`translate(${E-20}, ${Q-8})`,children:n.jsx(y.NiceIcon,{name:"chevron-down",size:12,color:"var(--nice-text-secondary, #666)"})})]})]},f.id)}),_e.map((f,S)=>n.jsx("line",{x1:f.x!=null?f.x:-1e4,y1:f.y!=null?f.y:-1e4,x2:f.x!=null?f.x:1e4,y2:f.y!=null?f.y:1e4,stroke:"#ff4081",strokeWidth:.5,strokeDasharray:"4,4"},`snap-${S}`)),e.map(f=>{var xe;const{d:S,mid:P}=Wr(f),D=je.has(f.id),Q=f.style.targetArrow==="diamond"?`url(#${me})`:f.style.targetArrow==="circle"?`url(#${Oe})`:f.style.targetArrow==="openArrow"?`url(#${$e})`:f.style.targetArrow!=="none"?`url(#${Ae})`:void 0,E=f.style.sourceArrow==="diamond"?`url(#${me})`:f.style.sourceArrow==="circle"?`url(#${Oe})`:f.style.sourceArrow==="openArrow"?`url(#${$e})`:f.style.sourceArrow==="arrow"?`url(#${Ae})`:void 0,B=Vt(f.id),ie=F==null?void 0:F.get(f.id),re=ie==null?void 0:ie.strokeProgress,oe=re!=null&&re>=0&&re<1?{strokeDasharray:"1000",strokeDashoffset:`${1e3*(1-re)}`}:void 0,ae=f.style.liquidFlow,we=R==null?void 0:R.liquidFlows.get(f.id);return n.jsxs("g",{"data-edge-id":f.id,style:B,onClick:de=>Lr(de,f.id),children:[G&&n.jsx("path",{d:S,fill:"none",stroke:"transparent",strokeWidth:12,style:{cursor:"pointer"}}),(ae==null?void 0:ae.active)&&n.jsx("path",{d:S,fill:"none",stroke:`url(#nd-liquid-${f.id})`,strokeWidth:ae.pipeWidth??(f.style.strokeWidth??1.5)*4,strokeLinecap:"round",opacity:.5}),n.jsx("path",{d:S,fill:"none",stroke:D?N:f.style.strokeColor??"var(--nice-text, #333)",strokeWidth:f.style.strokeWidth??1.5,strokeDasharray:(oe==null?void 0:oe.strokeDasharray)??((xe=f.style.strokeDash)==null?void 0:xe.join(","))??(f.style.animated?"6,4":void 0),strokeDashoffset:oe==null?void 0:oe.strokeDashoffset,markerEnd:Q,markerStart:E,opacity:f.style.opacity??1,style:G?{cursor:"pointer",transition:oe?void 0:"stroke-dashoffset 0.1s"}:void 0}),f.style.animated&&n.jsx("circle",{r:3,fill:N,children:n.jsx("animateMotion",{dur:`${1/(f.style.flowSpeed||1)}s`,repeatCount:"indefinite",path:S})}),(we==null?void 0:we.active)&&we.particles.map((de,Se)=>n.jsx("circle",{r:de.size,fill:(ae==null?void 0:ae.color)??"var(--nice-primary, #3b82f6)",opacity:de.opacity*.6,children:n.jsx("animateMotion",{dur:`${3/(((ae==null?void 0:ae.speed)??1)+.5)}s`,repeatCount:"indefinite",path:S,begin:`${de.t*3}s`})},`lp-${f.id}-${Se}`)),ie&&ie.particleTrailT>=0&&n.jsxs(n.Fragment,{children:[n.jsx("circle",{r:4,fill:"var(--nice-warning-light, #fbbf24)",opacity:.8,children:n.jsx("animateMotion",{dur:"2s",repeatCount:"indefinite",path:S,begin:`${ie.particleTrailT*2}s`})}),n.jsx("circle",{r:2,fill:"var(--nice-warning-light, #fbbf24)",opacity:.5,children:n.jsx("animateMotion",{dur:"2s",repeatCount:"indefinite",path:S,begin:`${(ie.particleTrailT+.1)*2}s`})})]}),f.label&&(()=>{const de=f.label.length*7+8;return n.jsxs("g",{children:[n.jsx("rect",{x:P.x-de/2,y:P.y-9,width:de,height:18,rx:3,fill:"var(--nice-bg-primary, #fff)",fillOpacity:.85}),n.jsx("text",{x:P.x,y:P.y+4,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-secondary, #555)",children:f.label})]})})()]},f.id)}),o.filter(f=>!f.hidden||I==="editor").map(f=>{const S=je.has(f.id),P=Vt(f.id),D=F==null?void 0:F.get(f.id),Q=f.style.fontFamily??(a==null?void 0:a.fontFamily)??"sans-serif",E=f.style.fontSize??14,B=f.style.fontColor??"var(--nice-text, #222)",ie=f.style.fontWeight??"normal",re=f.style.fontStyle??"normal",oe=f.style.textAlign??"center",ae=f.style.rotation??0,we=`nd-grad-${f.id}`,xe=!!f.hidden,de=xe?L??.3:f.style.opacity??1,Se=f.style.glowColor?`url(#nd-node-glow-${f.id})`:void 0,et=oe==="left"?"start":oe==="right"?"end":"middle",He=oe==="left"?8:oe==="right"?f.size.width-8:f.size.width/2,We=D==null?void 0:D.typewriterChars,ut=We!=null&&We>=0?f.label.slice(0,We):f.label,fe=D==null?void 0:D.liquidFillProgress,nt=D==null?void 0:D.rippleRadius,ft=D==null?void 0:D.rippleOpacity,Ct=f.childNodeIds&&f.childNodeIds.length>0,Yr=!!f.collapsed;return n.jsxs("g",{"data-node-id":f.id,transform:`translate(${f.position.x}, ${f.position.y})${ae?` rotate(${ae}, ${f.size.width/2}, ${f.size.height/2})`:""}`,style:{...P,cursor:xe?"pointer":G&&!f.locked&&w?"grab":l?"pointer":"default",opacity:de,filter:Se},onMouseDown:ke=>Rr(ke,f.id),onDoubleClick:ke=>Fr(ke,f.id),onClick:ke=>{ke.stopPropagation(),l==null||l(f.id),f.interactions&&f.interactions.length>0&&f.interactions.filter(tt=>tt.trigger==="click").forEach(tt=>C==null?void 0:C(f.id,tt.id))},onMouseEnter:()=>{$==null||$(f.id),f.interactions&&f.interactions.filter(Te=>Te.trigger==="hover").forEach(Te=>C==null?void 0:C(f.id,Te.id))},onMouseLeave:()=>$==null?void 0:$(null),children:[xe&&n.jsx("rect",{x:-1,y:-1,width:f.size.width+2,height:f.size.height+2,fill:"none",stroke:"var(--nice-text-muted, #999)",strokeWidth:1,strokeDasharray:"3,3",rx:4,opacity:.5}),Br(f,we),fe!=null&&fe>0&&fe<1&&n.jsx("clipPath",{id:`nd-liquid-clip-${f.id}`,children:n.jsx("rect",{x:0,y:f.size.height*(1-fe),width:f.size.width,height:f.size.height*fe})}),fe!=null&&fe>0&&fe<1&&n.jsx("rect",{x:0,y:0,width:f.size.width,height:f.size.height,fill:f.style.glowColor??"var(--nice-primary, #3b82f6)",opacity:.25,rx:f.style.borderRadius??4,clipPath:`url(#nd-liquid-clip-${f.id})`}),nt!=null&&nt>0&&n.jsx("circle",{cx:f.size.width/2,cy:f.size.height/2,r:nt,fill:"none",stroke:f.style.glowColor??N,strokeWidth:2,opacity:ft??.5}),S&&n.jsx("rect",{x:-3,y:-3,width:f.size.width+6,height:f.size.height+6,fill:"none",stroke:N,strokeWidth:2,strokeDasharray:"4,3",rx:6}),S&&G&&M&&!f.locked&&Nt.map((ke,Te)=>n.jsx("rect",{x:ke.dx*f.size.width-ht/2,y:ke.dy*f.size.height-ht/2,width:ht,height:ht,fill:"white",stroke:N,strokeWidth:1.5,rx:1,style:{cursor:ke.cursor},onMouseDown:tt=>Or(tt,f.id,Te)},Te)),Qe===f.id?n.jsx("foreignObject",{x:4,y:4,width:f.size.width-8,height:f.size.height-8,children:n.jsx("input",{xmlns:"http://www.w3.org/1999/xhtml",type:"text",value:ee,onChange:ke=>Ge(ke.target.value),onBlur:Bt,onKeyDown:ke=>{ke.key==="Enter"&&Bt(),ke.key==="Escape"&&rt(null)},autoFocus:!0,style:{width:"100%",height:"100%",border:"1px solid "+N,borderRadius:3,padding:"2px 4px",fontSize:E,fontFamily:Q,fontWeight:ie,fontStyle:re,textAlign:oe,background:"var(--nice-overlay-light-95, rgba(255, 255, 255, 0.95))",outline:"none"}})}):n.jsxs(n.Fragment,{children:[n.jsx("text",{x:He,y:f.size.height/2+(f.description?-4:0),textAnchor:et,dominantBaseline:"central",fontFamily:Q,fontSize:E,fontWeight:ie,fontStyle:re,fill:B,pointerEvents:"none",children:ut}),f.description&&n.jsx("text",{x:He,y:f.size.height/2+E*.8,textAnchor:et,dominantBaseline:"central",fontFamily:Q,fontSize:E*.75,fill:"var(--nice-text-secondary, #777)",pointerEvents:"none",children:f.description}),f.icon&&(ci.test(f.icon)?n.jsx("g",{transform:`translate(${f.size.width/2-8}, 4)`,pointerEvents:"none",children:n.jsx(y.NiceIcon,{name:f.icon,size:16,color:"var(--nice-text-secondary, #666)"})}):n.jsx("text",{x:f.size.width/2,y:14,textAnchor:"middle",fontSize:16,pointerEvents:"none",children:f.icon})),f.style.linkUrl&&n.jsx("g",{transform:`translate(${f.size.width-14}, 3)`,pointerEvents:"none",children:n.jsx(y.NiceIcon,{name:"link",size:10,color:"var(--nice-primary-hover, #1976d2)"})}),Ct&&G&&n.jsxs("g",{onClick:ke=>{ke.stopPropagation(),H==null||H(f.id)},style:{cursor:"pointer"},children:[n.jsx("rect",{x:f.size.width-18,y:f.size.height-18,width:16,height:16,rx:3,fill:"white",stroke:"var(--nice-text-muted, #aaa)",strokeWidth:.5}),n.jsx("g",{transform:`translate(${f.size.width-15}, ${f.size.height-15})`,children:n.jsx(y.NiceIcon,{name:Yr?"chevron-right":"chevron-down",size:10,color:"var(--nice-text-secondary, #666)"})})]})]}),G&&f.ports.map(ke=>{const Te=ur(f,ke.id),tt=v?Hr=>{if(Hr.stopPropagation(),f.locked)return;const qt={x:f.position.x+Te.x,y:f.position.y+Te.y};Ue({nodeId:f.id,portId:ke.id,from:qt,to:qt})}:void 0;return n.jsxs("g",{"data-port-id":ke.id,onMouseDown:tt,children:[tt&&n.jsx("circle",{cx:Te.x,cy:Te.y,r:9,fill:"transparent",style:{cursor:"crosshair"}}),n.jsx("circle",{cx:Te.x,cy:Te.y,r:4,fill:"var(--nice-bg-primary, #fff)",stroke:"var(--nice-text-secondary, #666)",strokeWidth:1,style:{cursor:"crosshair"}})]},ke.id)})]},f.id)}),R&&R.particles.length>0&&n.jsx("g",{className:"nd-particle-overlay",children:R.particles.map((f,S)=>n.jsx("circle",{cx:f.x,cy:f.y,r:f.size,fill:f.color,opacity:f.opacity},`ptcl-${S}`))}),ve&&n.jsx("path",{d:`M ${ve.from.x} ${ve.from.y} L ${ve.to.x} ${ve.to.y}`,fill:"none",stroke:N,strokeWidth:1.5,strokeDasharray:"5,4",markerEnd:`url(#${Ae})`,pointerEvents:"none"}),z&&n.jsx("rect",{x:Math.min(z.x1,z.x2),y:Math.min(z.y1,z.y2),width:Math.abs(z.x2-z.x1),height:Math.abs(z.y2-z.y1),fill:"rgba(33,150,243,0.1)",stroke:N,strokeWidth:1,strokeDasharray:"4,2"})]})]})};process.env.NODE_ENV!=="production"&&(Ee.displayName="DiagramCanvas");function Yt(o,e,t){const r=o.find(c=>c.id===e);if(!r)return{x:0,y:0};const{position:i,size:a}=r,s=r.ports.find(c=>c.id===t);switch(s==null?void 0:s.side){case"top":return{x:i.x+a.width*s.offset,y:i.y};case"bottom":return{x:i.x+a.width*s.offset,y:i.y+a.height};case"left":return{x:i.x,y:i.y+a.height*s.offset};case"right":return{x:i.x+a.width,y:i.y+a.height*s.offset};default:return{x:i.x+a.width/2,y:i.y+a.height/2}}}function dr(o,e){const t=Yt(e,o.sourceNodeId,o.sourcePortId),r=Yt(e,o.targetNodeId,o.targetPortId),i={x:(t.x+r.x)/2,y:(t.y+r.y)/2};switch(o.style.lineType??"bezier"){case"straight":return{d:`M ${t.x} ${t.y} L ${r.x} ${r.y}`,mid:i,extent:[t,r]};case"orthogonal":{const a=(t.x+r.x)/2;return{d:`M ${t.x} ${t.y} L ${a} ${t.y} L ${a} ${r.y} L ${r.x} ${r.y}`,mid:i,extent:[t,r]}}case"step":{const a=(t.y+r.y)/2;return{d:`M ${t.x} ${t.y} L ${t.x} ${a} L ${r.x} ${a} L ${r.x} ${r.y}`,mid:i,extent:[t,r]}}default:{const a=Math.max(40,Math.hypot(r.x-t.x,r.y-t.y)*.4),s=(x,g)=>{var h,v;return((v=(h=e.find(_=>_.id===x))==null?void 0:h.ports.find(_=>_.id===g))==null?void 0:v.side)??null},c=(x,g,h)=>{switch(g){case"top":return{x:x.x,y:x.y-a};case"bottom":return{x:x.x,y:x.y+a};case"left":return{x:x.x-a,y:x.y};case"right":return{x:x.x+a,y:x.y};default:return{x:x.x+h,y:x.y}}},l=Math.abs(r.x-t.x)*.5,u=c(t,s(o.sourceNodeId,o.sourcePortId),l),d=c(r,s(o.targetNodeId,o.targetPortId),-l),w=x=>{const g=1-x;return{x:g*g*g*t.x+3*g*g*x*u.x+3*g*x*x*d.x+x*x*x*r.x,y:g*g*g*t.y+3*g*g*x*u.y+3*g*x*x*d.y+x*x*x*r.y}};return{d:`M ${t.x} ${t.y} C ${u.x} ${u.y}, ${d.x} ${d.y}, ${r.x} ${r.y}`,mid:w(.5),extent:Array.from({length:9},(x,g)=>w(g/8))}}}}function fi(o,e){const t=Tt(o);if(!t)return null;let[r,i,a,s]=[t.x,t.y,t.x+t.width,t.y+t.height];const c=(l,u=0,d=0)=>{r=Math.min(r,l.x-u),i=Math.min(i,l.y-d),a=Math.max(a,l.x+u),s=Math.max(s,l.y+d)};for(const l of e){const u=dr(l,o);u.extent.forEach(d=>c(d)),l.label&&c(u.mid,(l.label.length*7+8)/2,9)}return{x:r,y:i,width:a-r,height:s-i}}function hi(o,e){let t="",r=1/0;for(const i of o.ports){const a=ur(o,i.id),s=Math.hypot(o.position.x+a.x-e.x,o.position.y+a.y-e.y);s<r&&(r=s,t=i.id)}return t}function ur(o,e){const t=o.ports.find(i=>i.id===e);if(!t)return{x:0,y:0};const{size:r}=o;switch(t.side){case"top":return{x:r.width*t.offset,y:0};case"bottom":return{x:r.width*t.offset,y:r.height};case"left":return{x:0,y:r.height*t.offset};case"right":return{x:r.width,y:r.height*t.offset};default:return{x:0,y:0}}}const mi=180,gi=120,lt=({nodes:o,edges:e,viewport:t,onViewportChange:r,canvasWidth:i=800,canvasHeight:a=600,width:s=mi,height:c=gi,className:l})=>{const u=p.useMemo(()=>{if(o.length===0)return{minX:0,minY:0,maxX:400,maxY:300};let v=1/0,_=1/0,b=-1/0,m=-1/0;for(const k of o)v=Math.min(v,k.position.x),_=Math.min(_,k.position.y),b=Math.max(b,k.position.x+k.size.width),m=Math.max(m,k.position.y+k.size.height);const A=50;return{minX:v-A,minY:_-A,maxX:b+A,maxY:m+A}},[o]),d=u.maxX-u.minX,w=u.maxY-u.minY,x=Math.min(s/d,c/w),g=p.useMemo(()=>{const v=(-t.x/t.zoom-u.minX)*x,_=(-t.y/t.zoom-u.minY)*x,b=i/t.zoom*x,m=a/t.zoom*x;return{x:v,y:_,w:b,h:m}},[t,u,x,i,a]),h=p.useCallback(v=>{if(!r)return;const _=v.currentTarget.getBoundingClientRect(),b=v.clientX-_.left,m=v.clientY-_.top,A=b/x+u.minX,k=m/x+u.minY;r({...t,x:-(A*t.zoom-i/2),y:-(k*t.zoom-a/2)})},[r,t,x,u,i,a]);return n.jsxs("svg",{className:`nice-diagram-minimap ${l??""}`,width:s,height:c,style:{border:"1px solid var(--nice-border, #ccc)",background:"var(--nice-bg, #fff)",borderRadius:4,cursor:"pointer"},onClick:h,children:[e.map(v=>{const _=o.find(M=>M.id===v.sourceNodeId),b=o.find(M=>M.id===v.targetNodeId);if(!_||!b)return null;const m=(_.position.x+_.size.width/2-u.minX)*x,A=(_.position.y+_.size.height/2-u.minY)*x,k=(b.position.x+b.size.width/2-u.minX)*x,j=(b.position.y+b.size.height/2-u.minY)*x;return n.jsx("line",{x1:m,y1:A,x2:k,y2:j,stroke:"var(--nice-text-muted, #aaa)",strokeWidth:.5},v.id)}),o.map(v=>n.jsx("rect",{x:(v.position.x-u.minX)*x,y:(v.position.y-u.minY)*x,width:v.size.width*x,height:v.size.height*x,fill:v.style.backgroundColor??"var(--nice-border, #ddd)",stroke:"var(--nice-text-muted, #999)",strokeWidth:.5},v.id)),n.jsx("rect",{x:g.x,y:g.y,width:g.w,height:g.h,fill:"color-mix(in srgb, var(--nice-primary, #2196f3) 15%, transparent)",stroke:"var(--nice-primary, #2196f3)",strokeWidth:1})]})};process.env.NODE_ENV!=="production"&&(lt.displayName="DiagramMinimap");const pi=["rectangle","roundedRect","ellipse","circle","diamond","hexagon","parallelogram","cylinder","triangle","cloud","document","actor"],wt=({selectedNode:o,selectedEdge:e,onNodeChange:t,onEdgeChange:r,onRemove:i,className:a})=>{var u,d,w,x,g;const{t:s}=Re(),c=p.useCallback((h,v)=>{!o||!t||t(o.id,{style:{...o.style,[h]:v}})},[o,t]),l=p.useCallback((h,v)=>{!e||!r||r(e.id,{style:{...e.style,[h]:v}})},[e,r]);return!o&&!e?n.jsx("div",{className:`nice-diagram-property-panel nice-diagram-property-panel--empty ${a??""}`,children:n.jsx("p",{className:"nice-diagram-property-panel__hint",children:s("panel.noSelection")})}):o?n.jsxs("div",{className:`nice-diagram-property-panel ${a??""}`,children:[n.jsx("h3",{className:"nice-diagram-property-panel__title",children:s("panel.nodeProperties")}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.label"),n.jsx(y.NiceTextInput,{value:o.label,onChange:h=>t==null?void 0:t(o.id,{label:h}),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.description"),n.jsx(y.NiceTextInput,{value:o.description??"",onChange:h=>t==null?void 0:t(o.id,{description:h||void 0}),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.shape"),n.jsx(y.NiceSelect,{value:o.shape,onChange:h=>t==null?void 0:t(o.id,{shape:h}),options:pi.map(h=>({value:h,label:h})),className:"nice-diagram-property-panel__select"})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.width"),n.jsx(y.NiceNumberInput,{value:o.size.width,min:20,onChange:h=>t==null?void 0:t(o.id,{size:{...o.size,width:h??40}}),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.height"),n.jsx(y.NiceNumberInput,{value:o.size.height,min:20,onChange:h=>t==null?void 0:t(o.id,{size:{...o.size,height:h??40}}),className:"nice-diagram-property-panel__input"})]})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.bgColor"),n.jsx(y.NiceColorPicker,{value:o.style.backgroundColor??"var(--nice-bg, #fff)",onChange:h=>c("backgroundColor",h),className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.borderColor"),n.jsx(y.NiceColorPicker,{value:o.style.borderColor??"var(--nice-text, #333333)",onChange:h=>c("borderColor",h),className:"nice-diagram-property-panel__color"})]})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.fontSize"),n.jsx(y.NiceNumberInput,{value:o.style.fontSize??14,min:8,max:72,onChange:h=>c("fontSize",h??14),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.fontColor"),n.jsx(y.NiceColorPicker,{value:o.style.fontColor??"#222222",onChange:h=>c("fontColor",h),className:"nice-diagram-property-panel__color"})]})]}),n.jsx(y.NiceCheckbox,{checked:o.locked??!1,onChange:h=>t==null?void 0:t(o.id,{locked:h}),label:s("node.locked"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),n.jsx("h4",{className:"nice-diagram-property-panel__section-title",style:{fontSize:12,marginTop:12,marginBottom:4,color:"var(--nice-text-secondary, #666)"},children:s("node.effects","Effects")}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.glowColor","Glow Color"),n.jsx(y.NiceColorPicker,{value:o.style.glowColor??"var(--nice-primary, #3b82f6)",onChange:h=>c("glowColor",h),className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.glowIntensity","Glow Intensity"),n.jsx(y.NiceSlider,{min:0,max:3,step:.1,value:o.style.glowIntensity??0,onChange:h=>c("glowIntensity",h),className:"nice-diagram-property-panel__input"})]})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.opacity","Opacity"),n.jsx(y.NiceSlider,{min:0,max:1,step:.05,value:o.style.opacity??1,onChange:h=>c("opacity",h),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.borderRadius","Border Radius"),n.jsx(y.NiceNumberInput,{min:0,max:50,value:o.style.borderRadius??4,onChange:h=>c("borderRadius",h??4),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.borderWidth","Border Width"),n.jsx(y.NiceNumberInput,{min:0,max:10,step:.5,value:o.style.borderWidth??1,onChange:h=>c("borderWidth",h??1),className:"nice-diagram-property-panel__input"})]}),n.jsx(y.NiceCheckbox,{checked:o.style.shadow??!1,onChange:h=>c("shadow",h),label:s("node.shadow","Shadow"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.gradientEnd","Gradient End"),n.jsx(y.NiceColorPicker,{value:o.style.gradientColor??"var(--nice-bg, #fff)",onChange:h=>c("gradientColor",h),className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.gradientDir","Gradient Dir"),n.jsx(y.NiceSelect,{value:o.style.gradientDirection??"vertical",onChange:h=>c("gradientDirection",h),options:[{value:"vertical",label:s("node.vertical","Vertical")},{value:"horizontal",label:s("node.horizontal","Horizontal")},{value:"diagonal",label:s("node.diagonal","Diagonal")},{value:"radial",label:s("node.radial","Radial")}],className:"nice-diagram-property-panel__select"})]})]}),n.jsx(y.NiceCheckbox,{checked:o.hidden??!1,onChange:h=>t==null?void 0:t(o.id,{hidden:h}),label:s("node.hiddenGhostInEditor","Hidden (ghost in editor)"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),n.jsx(y.NiceButton,{className:"nice-diagram-property-panel__btn nice-diagram-property-panel__btn--danger",variant:"ghost",size:"sm",onClick:()=>i==null?void 0:i(o.id),children:s("toolbar.delete")})]}):e?n.jsxs("div",{className:`nice-diagram-property-panel ${a??""}`,children:[n.jsx("h3",{className:"nice-diagram-property-panel__title",children:s("panel.edgeProperties")}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("edge.label"),n.jsx(y.NiceTextInput,{value:e.label??"",onChange:h=>r==null?void 0:r(e.id,{label:h||void 0}),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("edge.lineType"),n.jsx(y.NiceSelect,{value:e.style.lineType??"bezier",onChange:h=>l("lineType",h),options:[{value:"straight",label:s("node.straight","Straight")},{value:"bezier",label:s("node.bezier","Bezier")},{value:"orthogonal",label:s("node.orthogonal","Orthogonal")},{value:"step",label:s("node.step","Step")}],className:"nice-diagram-property-panel__select"})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("edge.color"),n.jsx(y.NiceColorPicker,{value:e.style.strokeColor??"var(--nice-text, #333333)",onChange:h=>l("strokeColor",h),className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("edge.width"),n.jsx(y.NiceNumberInput,{value:e.style.strokeWidth??1.5,min:.5,max:10,step:.5,onChange:h=>l("strokeWidth",h??1.5),className:"nice-diagram-property-panel__input"})]})]}),n.jsx(y.NiceCheckbox,{checked:e.style.animated??!1,onChange:h=>l("animated",h),label:s("edge.animated"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),e.style.animated&&n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.flowSpeed","Flow Speed"),n.jsx(y.NiceSlider,{min:.1,max:5,step:.1,value:e.style.flowSpeed??1,onChange:h=>l("flowSpeed",h),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.dashStyle","Dash Style"),n.jsx(y.NiceSelect,{value:e.style.strokeDash?e.style.strokeDash.join(","):"solid",onChange:h=>{const v=h;v==="solid"?l("strokeDash",[]):l("strokeDash",v.split(",").map(Number))},options:[{value:"solid",label:s("node.solid","Solid")},{value:"6,4",label:s("node.dashed","Dashed")},{value:"2,2",label:s("node.dotted","Dotted")},{value:"8,4,2,4",label:s("node.dashDot","Dash-Dot")},{value:"12,6",label:s("node.longDash","Long Dash")}],className:"nice-diagram-property-panel__select"})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.targetArrow","Target Arrow"),n.jsx(y.NiceSelect,{value:e.style.targetArrow??"arrow",onChange:h=>l("targetArrow",h),options:[{value:"arrow",label:s("node.arrow","Arrow")},{value:"openArrow",label:s("node.openArrow","Open Arrow")},{value:"diamond",label:s("node.diamond","Diamond")},{value:"circle",label:s("node.circle","Circle")},{value:"none",label:s("node.none","None")}],className:"nice-diagram-property-panel__select"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.sourceArrow","Source Arrow"),n.jsx(y.NiceSelect,{value:e.style.sourceArrow??"none",onChange:h=>l("sourceArrow",h),options:[{value:"none",label:s("node.none","None")},{value:"arrow",label:s("node.arrow","Arrow")},{value:"openArrow",label:s("node.openArrow","Open Arrow")},{value:"diamond",label:s("node.diamond","Diamond")},{value:"circle",label:s("node.circle","Circle")}],className:"nice-diagram-property-panel__select"})]})]}),n.jsx("h4",{className:"nice-diagram-property-panel__section-title",style:{fontSize:12,marginTop:12,marginBottom:4,color:"var(--nice-text-secondary, #666)"},children:s("node.liquidFlow","Liquid Flow")}),n.jsx(y.NiceCheckbox,{checked:((u=e.style.liquidFlow)==null?void 0:u.active)??!1,onChange:h=>{const v=e.style.liquidFlow??{active:!1,color:"var(--nice-primary, #3b82f6)",speed:1,pipeWidth:6};r==null||r(e.id,{style:{...e.style,liquidFlow:{...v,active:h}}})},label:s("node.enableLiquidFlow","Enable Liquid Flow"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),((d=e.style.liquidFlow)==null?void 0:d.active)&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.color","Color"),n.jsx(y.NiceColorPicker,{value:((w=e.style.liquidFlow)==null?void 0:w.color)??"var(--nice-primary, #3b82f6)",onChange:h=>{const v=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...v,color:h}}})},className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[s("node.speed","Speed"),n.jsx(y.NiceSlider,{min:.1,max:5,step:.1,value:((x=e.style.liquidFlow)==null?void 0:x.speed)??1,onChange:h=>{const v=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...v,speed:h}}})},className:"nice-diagram-property-panel__input"})]})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.pipeWidth","Pipe Width"),n.jsx(y.NiceNumberInput,{min:2,max:20,value:((g=e.style.liquidFlow)==null?void 0:g.pipeWidth)??6,onChange:h=>{const v=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...v,pipeWidth:h??6}}})},className:"nice-diagram-property-panel__input"})]})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[s("node.opacity","Opacity"),n.jsx(y.NiceSlider,{min:0,max:1,step:.05,value:e.style.opacity??1,onChange:h=>l("opacity",h),className:"nice-diagram-property-panel__input"})]}),n.jsx(y.NiceButton,{className:"nice-diagram-property-panel__btn nice-diagram-property-panel__btn--danger",variant:"ghost",size:"sm",onClick:()=>i==null?void 0:i(e.id),children:s("toolbar.delete")})]}):null};process.env.NODE_ENV!=="production"&&(wt.displayName="DiagramPropertyPanel");const Ht={flowchart:["rectangle","roundedRect","diamond","parallelogram","ellipse","circle","document","cylinder"],orgchart:["roundedRect","ellipse","rectangle"],mindmap:["roundedRect","ellipse","cloud","rectangle"],bpmn:["rectangle","roundedRect","circle","diamond","document"],er:["rectangle","diamond","ellipse"],sequence:["rectangle","actor","circle"],stateMachine:["roundedRect","circle","diamond"],networkTopology:["rectangle","circle","cloud","cylinder","hexagon"],decisionTree:["rectangle","diamond","roundedRect"],custom:["rectangle","roundedRect","ellipse","circle","diamond","hexagon","parallelogram","cylinder","triangle","cloud","document","actor"]},yi=["dagre","forceDirected","grid","radial","tree"],bi=["sans-serif","serif","monospace","Arial","Helvetica","Times New Roman","Courier New","Georgia","Verdana","Tahoma","Trebuchet MS"],wi=[8,9,10,11,12,14,16,18,20,24,28,32,36,48,72],xt=({activeTool:o,onToolChange:e,diagramType:t,onAddNode:r,onApplyLayout:i,onUndo:a,onRedo:s,canUndo:c=!1,canRedo:l=!1,onExport:u,onZoomIn:d,onZoomOut:w,onZoomReset:x,zoomLevel:g=1,onToggleBold:h,onToggleItalic:v,isBold:_=!1,isItalic:b=!1,onFontFamilyChange:m,currentFontFamily:A="sans-serif",onFontSizeChange:k,currentFontSize:j=14,onAlignLeft:M,onAlignCenterH:X,onAlignRight:V,onAlignTop:F,onAlignCenterV:R,onAlignBottom:I,onDistributeH:L,onDistributeV:W,onBringToFront:H,onSendToBack:C,onGroupSelected:$,onUngroupSelected:O,onCopy:G,onPaste:q,onDuplicate:K,onSelectAll:Z,selectionCount:te=0,onFind:ge,showFind:he=!1,findQuery:Ce="",onFindQueryChange:Ae,viewMode:$e="editor",onViewModeChange:me,stylePresetId:Oe,onStylePresetChange:ve,className:Ue})=>{const{t:Y}=Re(),[Fe,Le]=p.useState(!1),[Xe,ze]=p.useState(!1),[Ve,Ne]=p.useState(!1),[Je,z]=p.useState(!1),[U,ne]=p.useState(!1),[pe,le]=p.useState(!1),qe=Ht[t]??Ht.custom,Qe=p.useCallback(ee=>{r==null||r(ee),Le(!1)},[r]),rt=p.useCallback(ee=>{i==null||i(ee),ze(!1)},[i]);return n.jsxs("div",{className:`nice-diagram-toolbar ${Ue??""}`,children:[n.jsxs("div",{className:"nice-diagram-toolbar__row",children:[n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:o==="select"?"primary":"ghost",size:"sm",onClick:()=>e("select"),title:`${Y("toolbar.select")} (V)`,children:n.jsx(y.NiceIcon,{name:"cursor",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:o==="pan"?"primary":"ghost",size:"sm",onClick:()=>e("pan"),title:`${Y("toolbar.pan")} (H)`,children:n.jsx(y.NiceIcon,{name:"move",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:o==="addEdge"?"primary":"ghost",size:"sm",onClick:()=>e("addEdge"),title:`${Y("toolbar.addEdge")} (C)`,children:n.jsx(y.NiceIcon,{name:"link",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:o==="text"?"primary":"ghost",size:"sm",onClick:()=>e("text"),title:Y("toolbar.textT","Text (T)"),children:n.jsx(y.NiceIcon,{name:"type",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:o==="freehand"?"primary":"ghost",size:"sm",onClick:()=>e("freehand"),title:Y("toolbar.freehandF","Freehand (F)"),children:n.jsx(y.NiceIcon,{name:"pen",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:o==="delete"?"primary":"ghost",size:"sm",onClick:()=>e("delete"),title:`${Y("toolbar.delete")} (Del)`,children:n.jsx(y.NiceIcon,{name:"trash",size:14})})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:o==="addNode"?"primary":"ghost",size:"sm",onClick:()=>Le(ee=>!ee),title:Y("toolbar.addNode"),children:[n.jsx(y.NiceIcon,{name:"plus",size:14})," ",Y("toolbar.addNode")]}),Fe&&n.jsx("div",{className:"nice-diagram-toolbar__dropdown nice-diagram-toolbar__dropdown--shapes",children:qe.map(ee=>n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>Qe(ee),children:[n.jsx(y.NiceIcon,{name:xi(ee),size:14})," ",ee]},ee))})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:G,title:Y("toolbar.copyCtrlC","Copy (Ctrl+C)"),children:n.jsx(y.NiceIcon,{name:"copy",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:q,title:Y("toolbar.pasteCtrlV","Paste (Ctrl+V)"),children:n.jsx(y.NiceIcon,{name:"clipboard",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:K,title:Y("toolbar.duplicateCtrlD","Duplicate (Ctrl+D)"),children:n.jsx(y.NiceIcon,{name:"layers",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:Z,title:Y("toolbar.selectAllCtrlA","Select All (Ctrl+A)"),children:n.jsx(y.NiceIcon,{name:"check-square",size:14})})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:a,disabled:!c,title:`${Y("toolbar.undo")} (Ctrl+Z)`,children:n.jsx(y.NiceIcon,{name:"undo",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:s,disabled:!l,title:`${Y("toolbar.redo")} (Ctrl+Y)`,children:n.jsx(y.NiceIcon,{name:"redo",size:14})})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:w,title:Y("toolbar.zoomOut"),children:n.jsx(y.NiceIcon,{name:"minus",size:14})}),n.jsxs("span",{className:"nice-diagram-toolbar__zoom-label",children:[Math.round(g*100),"%"]}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:d,title:Y("toolbar.zoomIn"),children:n.jsx(y.NiceIcon,{name:"plus",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:x,title:Y("toolbar.zoomReset"),children:"1:1"})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:ge,title:Y("toolbar.findCtrlF","Find (Ctrl+F)"),children:n.jsx(y.NiceIcon,{name:"search",size:14})}),he&&n.jsx(y.NiceTextInput,{className:"nice-diagram-toolbar__search",placeholder:Y("toolbar.searchNodes","Search nodes…"),value:Ce,onChange:ee=>Ae==null?void 0:Ae(ee),autoFocus:!0})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>Ne(ee=>!ee),title:Y("toolbar.export"),children:[n.jsx(y.NiceIcon,{name:"download",size:14})," ",Y("toolbar.export")]}),Ve&&n.jsxs("div",{className:"nice-diagram-toolbar__dropdown",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{u==null||u("ndd"),Ne(!1)},children:".ndd.json"}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{u==null||u("svg"),Ne(!1)},children:"SVG"}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{u==null||u("mermaid"),Ne(!1)},children:Y("toolbar.mermaid","Mermaid")}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{u==null||u("png"),Ne(!1)},children:"PNG"})]})]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__row nice-diagram-toolbar__format-bar",children:[n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceSelect,{className:"nice-diagram-toolbar__font-select",value:A,onChange:ee=>m==null?void 0:m(ee),options:bi.map(ee=>({value:ee,label:ee})),title:Y("toolbar.fontFamily","Font Family")}),n.jsx(y.NiceSelect,{className:"nice-diagram-toolbar__size-select",value:String(j),onChange:ee=>k==null?void 0:k(Number(ee)),options:wi.map(ee=>({value:String(ee),label:String(ee)})),title:Y("toolbar.fontSize","Font Size")})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:_?"primary":"ghost",size:"sm",onClick:h,title:Y("toolbar.boldCtrlB","Bold (Ctrl+B)"),children:n.jsx("strong",{children:"B"})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:b?"primary":"ghost",size:"sm",onClick:v,title:Y("toolbar.italicCtrlI","Italic (Ctrl+I)"),children:n.jsx("em",{children:"I"})})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>z(ee=>!ee),title:Y("toolbar.alignmentDistribution","Alignment & Distribution"),children:[n.jsx(y.NiceIcon,{name:"align-left",size:14})," ",Y("toolbar.align","Align")]}),Je&&n.jsxs("div",{className:"nice-diagram-toolbar__dropdown nice-diagram-toolbar__dropdown--align",children:[n.jsx("div",{className:"nice-diagram-toolbar__dropdown-section",children:Y("toolbar.align","Align")}),n.jsxs("div",{className:"nice-diagram-toolbar__dropdown-row",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{M==null||M(),z(!1)},title:Y("toolbar.alignLeft","Align Left"),children:[n.jsx(y.NiceIcon,{name:"align-left",size:14})," ",Y("toolbar.left","Left")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{X==null||X(),z(!1)},title:Y("toolbar.alignCenter","Align Center"),children:[n.jsx(y.NiceIcon,{name:"align-center",size:14})," ",Y("toolbar.center","Center")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{V==null||V(),z(!1)},title:Y("toolbar.alignRight","Align Right"),children:[n.jsx(y.NiceIcon,{name:"align-right",size:14})," ",Y("toolbar.right","Right")]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__dropdown-row",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{F==null||F(),z(!1)},title:Y("toolbar.alignTop","Align Top"),children:[n.jsx(y.NiceIcon,{name:"align-top",size:14})," ",Y("toolbar.top","Top")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{R==null||R(),z(!1)},title:Y("toolbar.alignMiddle","Align Middle"),children:[n.jsx(y.NiceIcon,{name:"align-middle",size:14})," ",Y("toolbar.middle","Middle")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{I==null||I(),z(!1)},title:Y("toolbar.alignBottom","Align Bottom"),children:[n.jsx(y.NiceIcon,{name:"align-bottom",size:14})," ",Y("toolbar.bottom","Bottom")]})]}),n.jsx("div",{className:"nice-diagram-toolbar__dropdown-section",children:Y("toolbar.distribute","Distribute")}),n.jsxs("div",{className:"nice-diagram-toolbar__dropdown-row",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{L==null||L(),z(!1)},title:Y("toolbar.distributeHorizontally","Distribute Horizontally"),children:[n.jsx(y.NiceIcon,{name:"distribute-h",size:14})," H"]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{W==null||W(),z(!1)},title:Y("toolbar.distributeVertically","Distribute Vertically"),children:[n.jsx(y.NiceIcon,{name:"distribute-v",size:14})," V"]})]})]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>ne(ee=>!ee),title:Y("toolbar.arrange","Arrange"),children:[n.jsx(y.NiceIcon,{name:"menu",size:14})," ",Y("toolbar.arrange","Arrange")]}),U&&n.jsxs("div",{className:"nice-diagram-toolbar__dropdown",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{H==null||H(),ne(!1)},children:[n.jsx(y.NiceIcon,{name:"arrow-up",size:14})," ",Y("toolbar.bringToFront","Bring to Front")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{C==null||C(),ne(!1)},children:[n.jsx(y.NiceIcon,{name:"arrow-down",size:14})," ",Y("toolbar.sendToBack","Send to Back")]}),n.jsx("div",{className:"nice-diagram-toolbar__dropdown-divider"}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{$==null||$(),ne(!1)},disabled:te<2,children:[n.jsx(y.NiceIcon,{name:"group",size:14})," ",Y("toolbar.group","Group")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{O==null||O(),ne(!1)},children:[n.jsx(y.NiceIcon,{name:"ungroup",size:14})," ",Y("toolbar.ungroup","Ungroup")]})]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>ze(ee=>!ee),title:Y("toolbar.layout"),children:[n.jsx(y.NiceIcon,{name:"grid",size:14})," ",Y("toolbar.layout")]}),Xe&&n.jsx("div",{className:"nice-diagram-toolbar__dropdown",children:yi.map(ee=>n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>rt(ee),children:Y(`layout.${ee}`)},ee))})]}),te>1&&n.jsx("span",{className:"nice-diagram-toolbar__selection-info",children:Y("toolbar.selected","{selectionCount} selected").replace("{selectionCount}",String(te))}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:$e==="editor"?"primary":"ghost",size:"sm",onClick:()=>me==null?void 0:me("editor"),title:Y("toolbar.editorMode","Editor Mode"),children:[n.jsx(y.NiceIcon,{name:"edit",size:14})," ",Y("toolbar.editor","Editor")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:$e==="player"?"primary":"ghost",size:"sm",onClick:()=>me==null?void 0:me("player"),title:Y("toolbar.playerMode","Player Mode"),children:[n.jsx(y.NiceIcon,{name:"play",size:14})," ",Y("toolbar.player","Player")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:$e==="playerAnimated"?"primary":"ghost",size:"sm",onClick:()=>me==null?void 0:me("playerAnimated"),title:Y("toolbar.animatedPlayerMode","Animated Player Mode"),children:[n.jsx(y.NiceIcon,{name:"zap",size:14})," ",Y("toolbar.animated","Animated")]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>le(ee=>!ee),title:Y("toolbar.stylePresets","Style Presets"),children:[n.jsx(y.NiceIcon,{name:"palette",size:14})," ",Y("toolbar.style","Style")]}),pe&&n.jsx("div",{className:"nice-diagram-toolbar__dropdown nice-diagram-toolbar__dropdown--presets",style:{maxHeight:320,overflowY:"auto",width:220},children:Object.entries(yt.reduce((ee,Ge)=>{const _e=Ge.category??"Other";return ee[_e]||(ee[_e]=[]),ee[_e].push(Ge),ee},{})).map(([ee,Ge])=>n.jsxs("div",{children:[n.jsx("div",{className:"nice-diagram-toolbar__dropdown-section",style:{fontSize:10,color:"var(--nice-text-secondary, #888)",padding:"6px 8px 2px",textTransform:"uppercase"},children:ee}),Ge.map(_e=>n.jsxs(y.NiceButton,{className:`nice-diagram-toolbar__dropdown-item ${Oe===_e.id?"nice-diagram-toolbar__dropdown-item--active":""}`,variant:Oe===_e.id?"primary":"ghost",size:"sm",onClick:()=>{ve==null||ve(_e.id),le(!1)},style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("span",{style:{width:16,height:16,borderRadius:3,background:_e.config.palette.primary,border:"1px solid "+(_e.config.palette.border??"var(--nice-border, #ccc)"),display:"inline-block",flexShrink:0}}),n.jsx("span",{style:{fontSize:12},children:_e.name})]},_e.id))]},ee))})]})]})]})};process.env.NODE_ENV!=="production"&&(xt.displayName="DiagramToolbar");function xi(o){switch(o){case"rectangle":return"square";case"roundedRect":return"card";case"ellipse":return"circle";case"circle":return"circle";case"diamond":return"diamond";case"hexagon":return"hexagon";case"parallelogram":return"parallelogram";case"cylinder":return"database";case"triangle":return"triangle";case"cloud":return"cloud";case"document":return"file";case"actor":return"user";default:return"card"}}const vi=[{target:".nice-diagram-editor",titleKey:"tutorial.diagramEditor.intro.title",title:"Diagram editor",contentKey:"tutorial.diagramEditor.intro.content",content:"Pick a tool to add and connect nodes on the canvas, edit them in the property panel, and export the diagram from the toolbar.",placement:"auto"}],fr=({initialDocument:o,document:e,nodeTypes:t,autoLayout:r,fitOnMount:i=!1,readOnly:a=!1,diagramType:s="flowchart",onChange:c,onExport:l,lang:u,showToolbar:d=!0,showPropertyPanel:w=!0,showMinimap:x=!0,showTimeline:g=!0,className:h,style:v,tutorial:_})=>{var Je;const{t:b}=y.useNiceTranslation(),m=lr(e??o),[A,k]=p.useState("select"),[j,M]=p.useState(null),X=p.useRef(null),[V,F]=p.useState("editor"),R=p.useRef(null),[I,L]=p.useState({particles:[],liquidFlows:new Map,glowStates:new Map});p.useEffect(()=>{const z=new er(U=>{L(U)});return R.current=z,z.start(),()=>{z.stop(),R.current=null}},[]),p.useEffect(()=>{var U;const z=R.current;if(z)for(const ne of m.edges)(U=ne.style.liquidFlow)!=null&&U.active?z.startLiquidFlow(ne.id,ne.style.liquidFlow):z.stopLiquidFlow(ne.id)},[m.edges]),p.useEffect(()=>{const z=R.current;if(z)for(const U of m.nodes)U.style.glowColor?z.setGlow(U.id,U.style.glowColor,U.style.glowIntensity??1):z.removeGlow(U.id)},[m.nodes]);const W=p.useCallback(z=>{m.setStylePreset(z)},[m]),H=p.useCallback((z,U)=>{const ne=m.nodes.find(le=>le.id===z);if(!(ne!=null&&ne.interactions))return;const pe=ne.interactions.find(le=>le.id===U);if(pe)switch(pe.action){case"reveal":{if(pe.targetId){const le=m.nodes.find(qe=>qe.id===pe.targetId);le!=null&&le.hidden&&m.updateNode(pe.targetId,{hidden:!1})}break}case"navigate":{if(pe.targetId){const le=m.nodes.find(qe=>qe.id===pe.targetId);le&&(m.setViewport({x:-le.position.x+300,y:-le.position.y+200,zoom:m.viewport.zoom}),M(pe.targetId))}break}case"switchAnimationMode":{pe.targetId&&m.setActiveAnimationMode(pe.targetId);break}case"highlight":{pe.targetId&&M(pe.targetId);break}case"toggleCollapse":{m.toggleNodeCollapse(z);break}}},[m]),C=p.useRef(c);p.useEffect(()=>{C.current=c});const $=p.useRef(m.revision);p.useEffect(()=>{var z;m.revision!==$.current&&($.current=m.revision,(z=C.current)==null||z.call(C,m.document))},[m.revision,m.document]);const O=m.model;p.useEffect(()=>{e&&e!==O.getDocument()&&O.loadDocument(e)},[e,O]);const G=`${m.nodes.map(z=>z.id).join(",")}|${m.edges.map(z=>`${z.sourceNodeId}>${z.targetNodeId}`).join(",")}`,q=p.useMemo(()=>r?r===!0?{algorithm:"dagre",direction:"LR",nodeSpacing:40,rankSpacing:80}:r:null,[r]),K=m.applyLayout;p.useEffect(()=>{q&&K(q,{history:!1})},[G,q,K]);const Z=p.useCallback((z,U,ne,pe)=>{m.addEdge(z,ne??"right",U,pe??"left")},[m]),te=p.useCallback(z=>{const U=m.viewport,ne=m.addNode(z.label,{x:(-U.x+400)/U.zoom,y:(-U.y+300)/U.zoom},z.shape,z.size);m.updateNode(ne.id,{style:{...z.style},...z.icon?{icon:z.icon}:{},...z.description?{description:z.description}:{},...z.ports?{ports:z.ports.map(pe=>({...pe}))}:{},data:{...ne.data,nodeType:z.id}}),M(ne.id),k("select")},[m]),[ge,he]=p.useState(0),Ce=p.useMemo(()=>j?m.nodes.find(z=>z.id===j)??null:null,[j,m.nodes]),Ae=p.useMemo(()=>j?m.edges.find(z=>z.id===j)??null:null,[j,m.edges]),$e=p.useCallback(z=>{const U=m.viewport,ne=(-U.x+400)/U.zoom,pe=(-U.y+300)/U.zoom,le=m.addNode("New Node",{x:ne,y:pe},z);M(le.id),k("select")},[m]),me=p.useCallback(z=>{m.applyLayout({algorithm:z,centerGraph:!0})},[m]),Oe=p.useCallback((z,U)=>{m.moveNode(z,U)},[m]),ve=p.useCallback((z,U)=>{m.moveNode(z,U)},[m]),Ue=p.useCallback(z=>{m.nodes.find(U=>U.id===z)?m.removeNode(z):m.edges.find(U=>U.id===z)&&m.removeEdge(z),M(null)},[m]),Y=p.useCallback(z=>{const U=m.document;let ne;switch(z){case"ndd":ne=nr(U,!0);break;case"svg":ne=zt(U);break;case"mermaid":ne=or(U);break;case"png":ne=zt(U);break}l==null||l(z,ne)},[m,l]),Fe=p.useCallback(()=>{m.setViewport({...m.viewport,zoom:Math.min(5,m.viewport.zoom*1.2)})},[m]),Le=p.useCallback(()=>{m.setViewport({...m.viewport,zoom:Math.max(.1,m.viewport.zoom/1.2)})},[m]),Xe=p.useCallback(()=>{i?he(z=>z+1):m.setViewport({x:0,y:0,zoom:1})},[m,i]),ze=p.useMemo(()=>[...m.nodes.map(z=>({id:z.id,label:z.label,type:"node"})),...m.edges.map(z=>({id:z.id,label:z.label??z.id,type:"edge"}))],[m.nodes,m.edges]),Ve=d&&!a||m.animationModes.length>0?n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,width:"100%"},children:[d&&!a&&n.jsx(xt,{activeTool:A,onToolChange:k,diagramType:m.document.diagramType,onAddNode:$e,onApplyLayout:me,onUndo:m.undo,onRedo:m.redo,canUndo:m.canUndo,canRedo:m.canRedo,onExport:Y,onZoomIn:Fe,onZoomOut:Le,onZoomReset:Xe,zoomLevel:m.viewport.zoom,viewMode:V,onViewModeChange:F,stylePresetId:m.stylePresetId,onStylePresetChange:W}),t&&t.length>0&&!a&&n.jsx("div",{className:"nice-diagram-editor__node-types",role:"group","aria-label":b("diagramEditor.nodeTypes","Add a node"),style:{display:"flex",flexWrap:"wrap",gap:4,padding:"4px 8px"},children:t.map(z=>n.jsx(y.NiceButton,{variant:"ghost",size:"sm",leftIcon:n.jsx(y.NiceIcon,{name:z.icon??"plus",size:14}),onClick:()=>te(z),children:z.label},z.id))}),m.animationModes.length>0&&n.jsxs("div",{className:"nice-diagram-editor__mode-tabs",style:{display:"flex",gap:4,padding:"4px 8px",fontSize:12,alignItems:"center"},children:[n.jsx("span",{style:{color:"var(--nice-text-secondary, #888)",marginRight:4},children:b("diagramEditor.modes","Modes:")}),m.animationModes.map(z=>{var U;return n.jsx(y.NiceButton,{variant:((U=m.activeAnimationMode)==null?void 0:U.id)===z.id?"primary":"ghost",size:"sm",onClick:()=>m.setActiveAnimationMode(z.id),style:{padding:"2px 10px",fontSize:11},children:z.name},z.id)}),n.jsx(y.NiceButton,{variant:"ghost",size:"sm",onClick:()=>m.addAnimationMode(`Mode ${m.animationModes.length+1}`),style:{padding:"2px 8px",fontSize:11,color:"var(--nice-text-secondary, #888)"},title:b("diagramEditor.addAnimationMode","Add animation mode"),children:"+"})]})]}):void 0,Ne=n.jsxs(y.NiceAppShell,{ref:X,flush:!0,className:`nice-diagram-editor ${h??""}`,style:{position:"relative",...v},toolbar:Ve,rightSidebar:w&&!a?n.jsx("div",{className:"nice-diagram-editor__panel",style:{width:260,overflowY:"auto",height:"100%"},children:n.jsx(wt,{selectedNode:Ce,selectedEdge:Ae,onNodeChange:m.updateNode,onEdgeChange:m.updateEdge,onRemove:Ue})}):void 0,bottomPanel:g?n.jsx("div",{className:"nice-diagram-editor__timeline",children:n.jsx(bt,{animations:m.animations,onAdd:m.addAnimation,onRemove:m.removeAnimation,availableTargets:ze})}):void 0,children:[n.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:n.jsx(y.NiceTutorialButton,{steps:y.resolveTutorial(_,vi)})}),n.jsxs("div",{className:"nice-diagram-editor__canvas",style:{height:"100%",position:"relative"},children:[n.jsx(Ee,{nodes:m.nodes,edges:m.edges,groups:m.groups,viewport:m.viewport,onViewportChange:m.setViewport,selectedId:j,onSelectElement:M,onNodeDrag:q||a?void 0:Oe,onNodeDragEnd:q||a?void 0:ve,onEdgeCreate:a?void 0:Z,autoFit:i,fitKey:q?G:void 0,refitKey:ge,interactive:V==="editor"&&!a,showGrid:V==="editor",particleState:I,viewMode:V,ghostOpacity:((Je=m.playerConfig)==null?void 0:Je.ghostOpacity)??.3,onGroupCollapse:m.toggleGroupCollapse,onNodeCollapse:m.toggleNodeCollapse,onInteraction:H}),x&&n.jsx("div",{style:{position:"absolute",bottom:8,left:8},children:n.jsx(lt,{nodes:m.nodes,edges:m.edges,viewport:m.viewport,onViewportChange:m.setViewport})})]})]});return u?n.jsx(jt,{locale:u,children:Ne}):Ne};process.env.NODE_ENV!=="production"&&(fr.displayName="NiceDiagramEditor");const Ut={linear:o=>o,easeIn:o=>o*o,easeOut:o=>o*(2-o),easeInOut:o=>o<.5?2*o*o:-1+(4-2*o)*o,spring:o=>1-Math.cos(o*Math.PI*.5)*Math.exp(-6*o),bounce:o=>{if(o<1/2.75)return 7.5625*o*o;if(o<2/2.75){const t=o-.5454545454545454;return 7.5625*t*t+.75}if(o<2.5/2.75){const t=o-.8181818181818182;return 7.5625*t*t+.9375}const e=o-2.625/2.75;return 7.5625*e*e+.984375}};function hr(o){return Ut[o]??Ut.linear}const mr={opacity:1,scale:1,translateX:0,translateY:0,glow:0,highlightColor:"",strokeProgress:1,rippleRadius:0,rippleOpacity:0,typewriterChars:-1,liquidFillProgress:-1,particleTrailT:-1};class gr{constructor(e,t){this.startTime=0,this.playing=!1,this.rafId=0,this.stateMap=new Map,this.tick=()=>{if(!this.playing)return;const r=performance.now()-this.startTime;this.stateMap.clear();let i=!1;for(const a of this.animations){const s=a.startMs+(a.delayMs??0);s+a.durationMs;const c=a.repeat??0;let l=r-s;if(l<0){this.stateMap.set(a.targetId,Ci(a)),i=!0;continue}if(c===-1)l=l%a.durationMs,i=!0;else if(c>0){const x=a.durationMs*(c+1);if(l>x)continue;l=l%a.durationMs,i=!0}else{if(l>a.durationMs)continue;i=!0}const u=Math.min(l/a.durationMs,1),d=hr(a.easing)(u),w=ki(a,d);this.stateMap.set(a.targetId,w)}this.onFrame(this.stateMap),i?this.rafId=requestAnimationFrame(this.tick):this.playing=!1},this.animations=[...e].sort((r,i)=>r.startMs-i.startMs),this.onFrame=t}play(){this.playing||(this.playing=!0,this.startTime=performance.now(),this.tick())}stop(){this.playing=!1,this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0,this.stateMap.clear(),this.onFrame(this.stateMap)}pause(){this.playing=!1,this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0}isPlaying(){return this.playing}}function ki(o,e){const t={...mr};switch(o.effect){case"fadeIn":t.opacity=e;break;case"fadeOut":t.opacity=1-e;break;case"slideInLeft":t.translateX=-200*(1-e),t.opacity=e;break;case"slideInRight":t.translateX=200*(1-e),t.opacity=e;break;case"slideInTop":t.translateY=-200*(1-e),t.opacity=e;break;case"slideInBottom":t.translateY=200*(1-e),t.opacity=e;break;case"zoomIn":t.scale=e,t.opacity=e;break;case"zoomOut":t.scale=1-e*.5,t.opacity=1-e;break;case"pulse":t.scale=1+.15*Math.sin(e*Math.PI*2);break;case"shake":t.translateX=10*Math.sin(e*Math.PI*6)*(1-e);break;case"highlight":t.highlightColor=`rgba(255, 200, 0, ${.6*(1-Math.abs(2*e-1))})`;break;case"flowPulse":t.opacity=1,t.translateX=e;break;case"bounce":t.translateY=-40*Math.abs(Math.sin(e*Math.PI*3))*(1-e);break;case"glow":t.glow=12*Math.sin(e*Math.PI);break;case"colorShift":t.highlightColor=`hsl(${e*360}, 70%, 60%)`;break;case"liquidFill":t.liquidFillProgress=e;break;case"expand":t.scale=e,t.opacity=e;break;case"collapse":t.scale=1-e,t.opacity=1-e;break;case"ripple":t.rippleRadius=e*40,t.rippleOpacity=1-e;break;case"typewriter":t.typewriterChars=Math.floor(e*100);break;case"morphShape":t.scale=1+.1*Math.sin(e*Math.PI*4)*(1-e),t.translateX=2*Math.sin(e*Math.PI*3)*(1-e);break;case"drawPath":t.strokeProgress=e;break;case"particleTrail":t.particleTrailT=e;break}return t}function Ci(o){const e={...mr};switch(o.effect){case"fadeIn":case"slideInLeft":case"slideInRight":case"slideInTop":case"slideInBottom":case"zoomIn":case"expand":e.opacity=0;break;case"drawPath":e.strokeProgress=0;break;case"typewriter":e.typewriterChars=0;break;case"liquidFill":e.liquidFillProgress=0;break}return e}function Si(o){return{rectangle:"rectangle",roundedRect:"roundedRect",ellipse:"ellipse",circle:"circle",diamond:"diamond",hexagon:"hexagon",cylinder:"cylinder",cloud:"cloud",triangle:"triangle"}[o||"rectangle"]||"rectangle"}function Ni(o){return o?{backgroundColor:o.fill,borderColor:o.stroke,borderWidth:o.strokeWidth,fontColor:o.fontColor,fontSize:o.fontSize,borderRadius:o.borderRadius,borderStyle:o.strokeDasharray?"dashed":"solid"}:{}}function _i(o){if(!o)return{};let e="straight";return o.lineType==="orthogonal"?e="orthogonal":o.lineType==="curved"||o.lineType==="bezier"?e="bezier":o.lineType==="step"&&(e="step"),{strokeColor:o.stroke,strokeWidth:o.strokeWidth,strokeDash:o.strokeDasharray?o.strokeDasharray.split(",").map(Number):void 0,lineType:e,sourceArrow:"none",targetArrow:o.arrowHead?"arrow":"none",opacity:o.opacity}}function Mi(o){if(o)return{backgroundColor:o.fill,borderColor:o.stroke,borderWidth:o.strokeWidth}}function pr(o){return{id:o.id,label:o.label,position:{x:o.x,y:o.y},size:{width:o.width,height:o.height},shape:Si(o.shape),style:Ni(o.style),ports:(o.ports||[]).map((e,t)=>({id:e.id,side:e.position||"right",offset:.5})),data:o.data}}function yr(o,e){var s,c;const t=e.find(l=>l.id===o.source),r=e.find(l=>l.id===o.target),i=o.sourcePort||((s=t==null?void 0:t.ports[0])==null?void 0:s.id)||`${o.source}-out`,a=o.targetPort||((c=r==null?void 0:r.ports[0])==null?void 0:c.id)||`${o.target}-in`;return{id:o.id,sourceNodeId:o.source,sourcePortId:i,targetNodeId:o.target,targetPortId:a,label:o.label,style:_i(o.style),data:o.data}}function br(o){return{id:o.id,label:o.label,nodeIds:o.nodeIds,style:Mi(o.style)}}function wr(o){var e;return{id:o.id,name:o.id,targetId:o.targetId||((e=o.targets)==null?void 0:e[0])||"",targetType:"node",effect:o.type==="highlight"?"highlight":"fadeIn",startMs:o.delay,durationMs:o.duration,easing:"easeInOut"}}function Ze(o){const e=o.nodes.map(pr);return e.forEach((t,r)=>{t.ports.length===0&&(t.ports=[{id:`${t.id}-out`,side:"right",offset:.5},{id:`${t.id}-in`,side:"left",offset:.5},{id:`${t.id}-top`,side:"top",offset:.5},{id:`${t.id}-bottom`,side:"bottom",offset:.5}])}),{version:"1.0",id:o.id,title:o.title,diagramType:o.diagramType,nodes:e,edges:o.edges.map(t=>yr(t,e)),groups:(o.groups||[]).map(br),animations:(o.animations||[]).map(wr),viewport:{x:0,y:0,zoom:1},metadata:{createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),...o.metadata}}}const zi=Ze({id:"empty",title:"",diagramType:"flowchart",nodes:[],edges:[]}),Et=({document:o=zi,lang:e="en",autoPlay:t=!1,showControls:r,showGrid:i,showWorkspace:a=!1,autoFit:s=!0,className:c,style:l})=>{const u=r??a,d=i??a,w=p.useMemo(()=>{var R;return a||(R=o.theme)!=null&&R.canvasBackground?o.theme:{...o.theme,canvasBackground:"transparent"}},[a,o.theme]),[x,g]=p.useState(0),[h,v]=p.useState({...o.viewport}),[_,b]=p.useState(new Map),[m,A]=p.useState(!1),k=p.useRef(null),j=p.useCallback(()=>{k.current&&k.current.stop();const R=new gr(o.animations,I=>{b(new Map(I)),R.isPlaying()||A(!1)});k.current=R,R.play(),A(!0)},[o.animations]),M=p.useCallback(()=>{var R;(R=k.current)==null||R.stop(),A(!1),b(new Map)},[]);p.useEffect(()=>(t&&o.animations.length>0&&j(),()=>{var R;(R=k.current)==null||R.stop()}),[t]);const X=p.useCallback(()=>v(R=>({...R,zoom:Math.min(5,R.zoom*1.2)})),[]),V=p.useCallback(()=>v(R=>({...R,zoom:Math.max(.1,R.zoom/1.2)})),[]),F=p.useCallback(()=>{s?g(R=>R+1):v({x:0,y:0,zoom:1})},[s]);return n.jsx(jt,{locale:e,children:n.jsxs("div",{className:`nice-diagram-viewer ${c??""}`,style:{display:"flex",flexDirection:"column",height:"100%",...l},children:[u&&n.jsx(Ii,{isPlaying:m,hasAnimations:o.animations.length>0,onPlay:j,onStop:M,onZoomIn:X,onZoomOut:V,onZoomReset:F}),n.jsx("div",{style:{flex:1,position:"relative"},children:n.jsx(Ee,{nodes:o.nodes,edges:o.edges,groups:o.groups,viewport:h,onViewportChange:v,theme:w,animationStates:_,interactive:!1,showGrid:d,autoFit:s,fitKey:o.id,refitKey:x})})]})})};process.env.NODE_ENV!=="production"&&(Et.displayName="NiceDiagramViewer");const Ii=({isPlaying:o,hasAnimations:e,onPlay:t,onStop:r,onZoomIn:i,onZoomOut:a,onZoomReset:s})=>{const{t:c}=Re();return n.jsxs("div",{className:"nice-diagram-viewer__controls",style:{display:"flex",gap:4,padding:"4px 8px",borderBottom:"1px solid var(--nice-border, #ddd)",background:"var(--nice-bg-secondary, #fafafa)"},children:[e&&(o?n.jsxs(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:r,children:[n.jsx(y.NiceIcon,{name:"stop",size:14})," ",c("animation.stop")]}):n.jsxs(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:t,children:[n.jsx(y.NiceIcon,{name:"play",size:14})," ",c("animation.play")]})),n.jsx("span",{style:{flex:1}}),n.jsx(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:i,"aria-label":c("animation.zoomIn","Zoom in"),children:n.jsx(y.NiceIcon,{name:"plus",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:a,"aria-label":c("animation.zoomOut","Zoom out"),children:n.jsx(y.NiceIcon,{name:"minus",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:s,children:"1:1"})]})},ji="_cell_95fwm_9",Di="_expandable_95fwm_29",Ai="_svg_95fwm_57",$i="_emptyText_95fwm_67",Ti="_badge_95fwm_79",Pi="_expandIcon_95fwm_117",Ei="_modalOverlay_95fwm_169",Ri="_modalContent_95fwm_217",Oi="_modalHeader_95fwm_267",Fi="_modalTitle_95fwm_285",Li="_modalClose_95fwm_299",Wi="_modalBody_95fwm_337",Bi="_modalSvg_95fwm_357",Vi="_modalFooter_95fwm_371",qi="_modalInfo_95fwm_389",De={cell:ji,expandable:Di,svg:Ai,emptyText:$i,badge:Ti,expandIcon:Pi,modalOverlay:Ei,modalContent:Ri,modalHeader:Oi,modalTitle:Fi,modalClose:Li,modalBody:Wi,modalSvg:Bi,modalFooter:Vi,modalInfo:qi},Gi=120,Yi=48,Hi=4,Xt={default:"var(--nice-primary, #3b82f6)",process:"var(--nice-success, #22c55e)",decision:"var(--nice-warning, #f59e0b)",start:"var(--nice-info, #6366f1)",end:"var(--nice-danger, #ef4444)",data:"var(--nice-accent, #8b5cf6)",custom:"var(--nice-text-secondary, #64748b)"};function Rt(o){if(o.length===0)return{minX:0,minY:0,maxX:100,maxY:100,width:100,height:100};let e=1/0,t=1/0,r=-1/0,i=-1/0;for(const a of o){const s=a.position.x,c=a.position.y,l=a.position.x+a.size.width,u=a.position.y+a.size.height;s<e&&(e=s),c<t&&(t=c),l>r&&(r=l),u>i&&(i=u)}return{minX:e,minY:t,maxX:r,maxY:i,width:r-e,height:i-t}}function xr(o){var t;if((t=o.style)!=null&&t.backgroundColor)return o.style.backgroundColor;const e=o.shape??"default";return Xt[e]??Xt.default}function vr(o,e){const t=e.get(o.sourceNodeId),r=e.get(o.targetNodeId);if(!t||!r)return null;const i=t.position.x+t.size.width/2,a=t.position.y+t.size.height/2,s=r.position.x+r.size.width/2,c=r.position.y+r.size.height/2;return`M ${i} ${a} L ${s} ${c}`}function Ui(o,e){const t=Rt(o);return{version:"1.0",id:`mini-diagram-${Date.now()}`,title:"Mini Diagram",diagramType:"flowchart",nodes:o,edges:e,groups:[],viewport:{x:t.minX-20,y:t.minY-20,zoom:1},animations:[],metadata:{createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}}const Xi=({document:o,onClose:e})=>{const{t}=Re(),r=Rt(o.nodes),i=40,a=r.width+i*2,s=r.height+i*2,c=p.useMemo(()=>new Map(o.nodes.map(l=>[l.id,l])),[o.nodes]);return n.jsx("div",{role:"presentation",className:De.modalOverlay,onClick:e,children:n.jsxs("div",{role:"presentation",className:De.modalContent,onClick:l=>l.stopPropagation(),children:[n.jsxs("div",{className:De.modalHeader,children:[n.jsx("h3",{className:De.modalTitle,children:o.title||t("diagramCellRenderer.diagram","Diagram")}),n.jsx("button",{className:De.modalClose,onClick:e,children:n.jsx(y.NiceIcon,{name:"close",size:20})})]}),n.jsx("div",{className:De.modalBody,children:n.jsxs("svg",{viewBox:`${r.minX-i} ${r.minY-i} ${a} ${s}`,className:De.modalSvg,children:[o.edges.map(l=>{var d,w,x;const u=vr(l,c);return u?n.jsx("path",{d:u,stroke:((d=l.style)==null?void 0:d.strokeColor)??"var(--nice-text-secondary, #64748b)",strokeWidth:((w=l.style)==null?void 0:w.strokeWidth)??1.5,fill:"none",markerEnd:(x=l.style)!=null&&x.targetArrow&&l.style.targetArrow!=="none"?"url(#arrowhead-modal)":void 0},l.id):null}),o.nodes.map(l=>{var u,d;return n.jsxs("g",{children:[n.jsx("rect",{x:l.position.x,y:l.position.y,width:l.size.width,height:l.size.height,rx:((u=l.style)==null?void 0:u.borderRadius)??4,fill:xr(l),stroke:((d=l.style)==null?void 0:d.borderColor)??"var(--nice-text, #1e293b)",strokeWidth:1}),n.jsx("text",{x:l.position.x+l.size.width/2,y:l.position.y+l.size.height/2,textAnchor:"middle",dominantBaseline:"middle",fill:"var(--nice-color-white, #fff)",fontSize:12,fontFamily:"system-ui, sans-serif",children:l.label.substring(0,30)})]},l.id)}),n.jsx("defs",{children:n.jsx("marker",{id:"arrowhead-modal",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:n.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"var(--nice-text-secondary, #64748b)"})})})]})}),n.jsx("div",{className:De.modalFooter,children:n.jsx("span",{className:De.modalInfo,children:t("diagramCellRenderer.nodesEdges","{nodes} nodes • {edges} edges").replace("{nodes}",String(o.nodes.length)).replace("{edges}",String(o.edges.length))})})]})})},Ki=({document:o,nodes:e,edges:t,width:r=Gi,height:i=Yi,showCount:a=!0,expandable:s=!0,onExpand:c,padding:l=Hi,backgroundColor:u="transparent",borderRadius:d=4,showLabels:w=!1,edgeColor:x="var(--nice-text-muted, #94a3b8)",tooltip:g})=>{const{t:h}=Re(),[v,_]=p.useState(!1),b=p.useMemo(()=>o||(e||t?Ui(e??[],t??[]):null),[o,e,t]),m=p.useMemo(()=>b?new Map(b.nodes.map(V=>[V.id,V])):new Map,[b]),{bounds:A,scale:k,translateX:j,translateY:M}=p.useMemo(()=>{if(!b||b.nodes.length===0)return{bounds:{minX:0,minY:0,width:100,height:100},scale:1,translateX:0,translateY:0};const V=Rt(b.nodes),F=r-l*2,R=i-l*2,I=F/V.width,L=R/V.height,W=Math.min(I,L,1),H=V.width*W,C=V.height*W,$=(r-H)/2-V.minX*W,O=(i-C)/2-V.minY*W;return{bounds:V,scale:W,translateX:$,translateY:O}},[b,r,i,l]),X=p.useCallback(()=>{!b||!s||(c?c(b):_(!0))},[b,s,c]);return!b||b.nodes.length===0?n.jsx("div",{className:De.cell,style:{width:r,height:i,backgroundColor:u,borderRadius:d},title:g,children:n.jsx("span",{className:De.emptyText,children:"—"})}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{role:"button",tabIndex:0,onKeyDown:y.clickOnActivationKey,className:`${De.cell} ${s?De.expandable:""}`,style:{width:r,height:i,backgroundColor:u,borderRadius:d},onClick:X,title:g??h("diagramCellRenderer.nodesEdges2","{nodes} nodes, {edges} edges").replace("{nodes}",String(b.nodes.length)).replace("{edges}",String(b.edges.length)),children:[n.jsx("svg",{width:r,height:i,viewBox:`0 0 ${r} ${i}`,className:De.svg,children:n.jsxs("g",{transform:`translate(${j}, ${M}) scale(${k})`,children:[b.edges.map(V=>{const F=vr(V,m);return F?n.jsx("path",{d:F,stroke:x,strokeWidth:1/k,fill:"none"},V.id):null}),b.nodes.map(V=>{const F=xr(V);return n.jsxs("g",{children:[n.jsx("rect",{x:V.position.x,y:V.position.y,width:V.size.width,height:V.size.height,rx:Math.min(4,V.size.width/4),fill:F}),w&&k>.3&&n.jsx("text",{x:V.position.x+V.size.width/2,y:V.position.y+V.size.height/2,textAnchor:"middle",dominantBaseline:"middle",fill:"var(--nice-color-white, #fff)",fontSize:10/k,fontFamily:"system-ui, sans-serif",children:V.label.substring(0,5)})]},V.id)})]})}),a&&n.jsx("span",{className:De.badge,children:b.nodes.length}),s&&n.jsx("span",{className:De.expandIcon,children:n.jsx(y.NiceIcon,{name:"expand",size:12})})]}),v&&b&&n.jsx(Xi,{document:b,onClose:()=>_(!1)})]})};function kr(o,e,t="roundedRect"){const r=[],i=[],a=new Map;for(const s of o){const c=String(s[e.nodeMapping.idField]??"");if(!c)continue;const l=String(s[e.nodeMapping.labelField]??c),u=e.nodeMapping.descriptionField?String(s[e.nodeMapping.descriptionField]??""):void 0,d=e.nodeMapping.iconField?String(s[e.nodeMapping.iconField]??""):void 0,w=e.nodeMapping.colorField?String(s[e.nodeMapping.colorField]??""):void 0,x={id:`data_${c}`,label:l,description:u,icon:d,position:{x:0,y:0},size:{width:180,height:70},shape:t,style:w?{backgroundColor:w}:{},ports:[{id:"top",side:"top",offset:.5},{id:"right",side:"right",offset:.5},{id:"bottom",side:"bottom",offset:.5},{id:"left",side:"left",offset:.5}],data:s};r.push(x),a.set(c,x)}if(e.nodeMapping.parentField)for(const s of o){const c=String(s[e.nodeMapping.idField]??""),l=String(s[e.nodeMapping.parentField]??"");if(!c||!l)continue;const u=a.get(c),d=a.get(l);!u||!d||i.push({id:`edge_${l}_${c}`,sourceNodeId:d.id,sourcePortId:"bottom",targetNodeId:u.id,targetPortId:"top",style:{lineType:"orthogonal",targetArrow:"arrow"}})}if(e.edgeMapping)for(const s of o){const c=String(s[e.edgeMapping.sourceField]??""),l=String(s[e.edgeMapping.targetField]??"");if(!c||!l)continue;const u=a.get(c),d=a.get(l);if(!u||!d)continue;const w=e.edgeMapping.labelField?String(s[e.edgeMapping.labelField]??""):void 0;i.push({id:`edge_${c}_${l}`,sourceNodeId:u.id,sourcePortId:"right",targetNodeId:d.id,targetPortId:"left",label:w,style:{lineType:"bezier",targetArrow:"arrow"}})}return{nodes:r,edges:i}}async function Zi(o,e,t){const r=await fetch(o.sourceUrl,{signal:t});if(!r.ok)throw new Error(`Failed to fetch data: ${r.status} ${r.statusText}`);const i=await r.json(),a=Array.isArray(i)?i:i.value??[];return kr(a,o,e)}const Cr={width:176,height:64},Ke={initial:"var(--nice-color-success)",intermediate:"var(--nice-color-primary)",approval:"var(--nice-color-warning)",final:"var(--nice-text-muted)",error:"var(--nice-color-error)"};function Ji(o){return[{id:"initial",label:o("workflowDesigner.step.initial","Start"),icon:"play",color:Ke.initial,role:"initial"},{id:"intermediate",label:o("workflowDesigner.step.intermediate","State"),icon:"circle",color:Ke.intermediate},{id:"approval",label:o("workflowDesigner.step.approval","Approval"),icon:"check",color:Ke.approval},{id:"final",label:o("workflowDesigner.step.final","End"),icon:"stop",color:Ke.final,role:"final"},{id:"error",label:o("workflowDesigner.step.error","Error"),icon:"error",color:Ke.error,role:"error"}]}const Qi=o=>o.role??(o.id==="initial"||o.id==="final"||o.id==="error"?o.id:"step"),Sr=[{id:"top",side:"top",offset:.5},{id:"right",side:"right",offset:.5},{id:"bottom",side:"bottom",offset:.5},{id:"left",side:"left",offset:.5}];function ea(o,e){const t=new Set(e);if(!t.has(o))return o;for(let r=2;;r++)if(!t.has(`${o} ${r}`))return`${o} ${r}`}function _t(o,e){const t=new Set(e.map(r=>r.id));for(let r=1;;r++)if(!t.has(`${o}-${r}`))return`${o}-${r}`}function ta(o,e,t){return o||{id:"workflow",name:"Workflow",entityType:"generic",version:1,states:(e??[]).map(r=>({id:r.id,name:r.name??r.label??r.id,type:r.type==="start"?"initial":r.type==="end"?"final":r.type??"intermediate",position:{x:r.x??0,y:r.y??0}})),transitions:(t??[]).map((r,i)=>({id:r.id??`t${i}`,fromStateId:r.fromStateId??r.from??r.source,toStateId:r.toStateId??r.to??r.target,name:r.name??r.label??""}))}}function Kt(o,e){const t=new Set(o.states.map(a=>a.id)),r=o.states.map(a=>({id:a.id,label:a.name,position:{x:0,y:0},size:Cr,shape:"roundedRect",style:{},ports:Sr})),i=o.transitions.filter(a=>t.has(a.fromStateId)&&t.has(a.toStateId)).map(a=>({id:a.id,sourceNodeId:a.fromStateId,sourcePortId:"right",targetNodeId:a.toStateId,targetPortId:"left",style:{}}));return Dt(r,i,{algorithm:"dagre",direction:e,nodeSpacing:36,rankSpacing:96})}function ra(o,e,t){const r=[],i=o.states.filter(a=>e(a)==="initial");i.length===0&&r.push({type:"error",message:t("workflowDesigner.val.noInitial","No initial state")}),i.length>1&&r.push({type:"warning",message:t("workflowDesigner.val.multiInitial","More than one initial state")}),o.states.some(a=>e(a)==="final")||r.push({type:"error",message:t("workflowDesigner.val.noFinal","No final state")});for(const a of o.states){const s=e(a);s!=="final"&&s!=="error"&&!o.transitions.some(c=>c.fromStateId===a.id)&&r.push({type:"warning",message:t("workflowDesigner.val.deadEnd",'State "{name}" has no outgoing transitions (dead-end)').replace("{name}",a.name),stateId:a.id}),s!=="initial"&&!o.transitions.some(c=>c.toStateId===a.id)&&r.push({type:"warning",message:t("workflowDesigner.val.orphan",'State "{name}" is unreachable (orphan)').replace("{name}",a.name),stateId:a.id})}return r}const oa=[{target:".nice-workflow-designer",titleKey:"tutorial.workflowDesigner.intro.title",title:"Workflow designer",contentKey:"tutorial.workflowDesigner.intro.content",content:"Add states and transitions on the canvas, validate the flow, simulate it, then test or publish your workflow.",placement:"auto"},{target:".nice-workflow-designer__toolbar",titleKey:"tutorial.workflowDesigner.toolbar.title",title:"Toolbar",contentKey:"tutorial.workflowDesigner.toolbar.content",content:"Add states and approvals, run a simulation, then test or publish the workflow.",placement:"bottom"},{target:".nice-workflow-designer__canvas",titleKey:"tutorial.workflowDesigner.canvas.title",title:"Canvas",contentKey:"tutorial.workflowDesigner.flow.content",content:"The flow lays itself out. Click a step to edit it and its transitions; drag from a step’s dot onto another step to connect them.",placement:"auto"}],ia=.1,aa=3,Nr=({workflow:o,nodes:e,edges:t,onChange:r,readOnly:i=!1,showMinimap:a=!0,showToolbar:s=!0,showValidation:c=!0,onTest:l,onPublish:u,tutorial:d,stepTypes:w,loadStepTypes:x,layoutDirection:g="LR",className:h,style:v,"data-testid":_})=>{const{t:b}=y.useNiceTranslation(),m=p.useRef(null);y.useRovingFocus(m,{orientation:"horizontal",itemSelector:'button, [role="menuitem"]'});const A=p.useMemo(()=>ta(o,e,t),[o,e,t]),[k,j]=p.useState(A),M=p.useRef(null),X=p.useRef(JSON.stringify(A));p.useEffect(()=>{const N=JSON.stringify(A);N!==X.current&&(X.current=N,A!==M.current&&j(A))},[A]);const V=p.useRef(x),[F,R]=p.useState(null),[I,L]=p.useState(!!x);p.useEffect(()=>{const N=V.current;if(!N)return;let T=!0;return N().then(J=>T&&R(J)).catch(()=>{}).finally(()=>T&&L(!1)),()=>{T=!1}},[]);const W=p.useMemo(()=>{const N=w??Ji(b);if(!F)return N;const T=new Map(N.map(J=>[J.id,J]));for(const J of F)T.set(J.id,J);return[...T.values()]},[w,F,b]),H=p.useCallback(N=>W.find(T=>T.id===N.type)??{id:N.type,label:N.type,color:Ke[N.type]??Ke.intermediate},[W]),C=p.useCallback(N=>Qi(H(N)),[H]),[$,O]=p.useState(null),[G,q]=p.useState(null),K=G!==null,Z=k.states.find(N=>N.id===$),te=k.transitions.find(N=>N.id===$),ge=p.useMemo(()=>Kt(k,g),[k,g]),he=`${k.states.map(N=>N.id).join(",")}|${k.transitions.map(N=>`${N.fromStateId}>${N.toStateId}`).join(",")}|${g}`,Ce=p.useMemo(()=>k.states.map(N=>{const T=H(N),J=G===N.id;return{id:N.id,label:N.name,description:T.label,position:ge.positions.get(N.id)??N.position,size:Cr,shape:T.shape??"roundedRect",icon:T.icon,style:{backgroundColor:"var(--nice-bg-primary)",borderColor:T.color??Ke.intermediate,borderWidth:J?4:2,borderRadius:10,fontColor:"var(--nice-text-primary)",fontSize:13,fontWeight:"bold",...J?{glowColor:T.color??Ke.intermediate}:{}},ports:Sr}}),[k.states,H,ge,G]),Ae=p.useMemo(()=>{const N=ge.ranks??new Map,T=new Set(k.states.map(se=>se.id)),J=g==="LR";return k.transitions.filter(se=>T.has(se.fromStateId)&&T.has(se.toStateId)).map(se=>{const Me=se.fromStateId===se.toStateId,Ie=!Me&&(N.get(se.toStateId)??0)<=(N.get(se.fromStateId)??0),[ot,je]=Me?J?["right","top"]:["bottom","right"]:Ie?J?["bottom","bottom"]:["right","right"]:J?["right","left"]:["bottom","top"],Pe=G===se.fromStateId;return{id:se.id,sourceNodeId:se.fromStateId,sourcePortId:ot,targetNodeId:se.toStateId,targetPortId:je,label:se.name||void 0,style:{lineType:"bezier",targetArrow:"arrow",strokeWidth:Pe?2.5:1.5,...Pe?{strokeColor:"var(--nice-color-primary)"}:{}}}})},[k.transitions,k.states,ge,g,G]),$e=p.useRef(r);p.useEffect(()=>{$e.current=r});const me=p.useCallback(N=>{var se;const T=Kt(N,g).positions,J={...N,states:N.states.map(Me=>{const Ie=T.get(Me.id);return Ie?{...Me,position:{x:Math.round(Ie.x),y:Math.round(Ie.y)}}:Me})};M.current=J,j(J),(se=$e.current)==null||se.call($e,J)},[g]),Oe=p.useCallback(N=>{if(i)return;const T=_t("state",k.states),J={id:T,name:ea(N.label,k.states.map(Ie=>Ie.name)),type:N.id,position:{x:0,y:0}},se=k.states.find(Ie=>Ie.id===$),Me=se?[...k.transitions,{id:_t("t",k.transitions),fromStateId:se.id,toStateId:T,name:b("workflowDesigner.next","Next")}]:k.transitions;me({...k,states:[...k.states,J],transitions:Me}),O(T)},[i,k,$,me,b]),ve=p.useCallback((N,T)=>me({...k,states:k.states.map(J=>J.id===N?{...J,...T}:J)}),[k,me]),Ue=p.useCallback(N=>{me({...k,states:k.states.filter(T=>T.id!==N),transitions:k.transitions.filter(T=>T.fromStateId!==N&&T.toStateId!==N)}),O(null)},[k,me]),Y=p.useCallback((N,T)=>{var Ie,ot;const J=T?k.transitions.find(je=>je.fromStateId===N&&je.toStateId===T):void 0;if(J){O(J.id);return}const se=new Set(k.transitions.filter(je=>je.fromStateId===N).map(je=>je.toStateId)),Me=T??((Ie=k.states.find(je=>je.id!==N&&!se.has(je.id)))==null?void 0:Ie.id)??((ot=k.states.find(je=>je.id!==N))==null?void 0:ot.id);Me&&me({...k,transitions:[...k.transitions,{id:_t("t",k.transitions),fromStateId:N,toStateId:Me,name:b("workflowDesigner.next","Next")}]})},[k,me,b]),Fe=p.useCallback((N,T)=>me({...k,transitions:k.transitions.map(J=>J.id===N?{...J,...T}:J)}),[k,me]),Le=p.useCallback(N=>{me({...k,transitions:k.transitions.filter(T=>T.id!==N)}),$===N&&O(null)},[k,me,$]),Xe=p.useMemo(()=>c?ra(k,C,b):[],[c,k,C,b]),ze=Xe.filter(N=>N.type==="error"),[Ve,Ne]=p.useState({x:0,y:0,zoom:1}),[Je,z]=p.useState(0),[U,ne]=p.useState(null),pe=p.useCallback(N=>Ne(T=>{const J=Math.min(aa,Math.max(ia,T.zoom*N)),se=((U==null?void 0:U.width)??0)/2,Me=((U==null?void 0:U.height)??0)/2;return{x:se-(se-T.x)*(J/T.zoom),y:Me-(Me-T.y)*(J/T.zoom),zoom:J}}),[U]),le=p.useCallback(()=>{U&&Ne(Pt(Tt(Ce),U,{maxZoom:1,minZoom:1}))},[U,Ce]),qe=()=>{const N=k.states.find(T=>C(T)==="initial");N&&(O(null),q(N.id))},Qe=p.useMemo(()=>[{id:"add-step",label:b("workflowDesigner.addStep","Add step"),icon:n.jsx(y.NiceIcon,{name:"plus",size:14}),children:[...W.map(N=>({id:N.id,label:N.label,description:N.description,icon:N.icon?n.jsx(y.NiceIcon,{name:N.icon,size:14}):void 0,onClick:()=>Oe(N)})),...I?[{id:"loading",label:b("workflowDesigner.loadingSteps","Loading step types…"),disabled:!0}]:[]]}],[W,I,Oe,b]),rt=s?n.jsxs("div",{ref:m,className:"nice-workflow-designer__toolbar",role:"toolbar","aria-label":b("workflowDesigner.toolbar","Workflow toolbar"),children:[!i&&!K&&n.jsx(y.NiceMenu,{variant:"ghost",size:"sm",items:Qe,"data-testid":"workflow-add-step"}),n.jsx(y.NiceButton,{size:"sm",variant:"ghost",leftIcon:n.jsx(y.NiceIcon,{name:"play",size:14}),onClick:qe,disabled:ze.length>0||K,children:b("workflowDesigner.simulate","Simulate")}),n.jsx("span",{className:"nice-workflow-designer__spacer"}),n.jsx(y.NiceButton,{size:"sm",variant:"ghost",ariaLabel:b("workflowDesigner.zoomOut","Zoom out"),onClick:()=>pe(1/1.2),children:n.jsx(y.NiceIcon,{name:"zoom-out",size:14})}),n.jsx(y.NiceButton,{size:"sm",variant:"ghost",className:"nice-workflow-designer__zoom",title:b("workflowDesigner.resetView","Reset view"),onClick:le,children:`${Math.round(Ve.zoom*100)}%`}),n.jsx(y.NiceButton,{size:"sm",variant:"ghost",ariaLabel:b("workflowDesigner.zoomIn","Zoom in"),onClick:()=>pe(1.2),children:n.jsx(y.NiceIcon,{name:"zoom-in",size:14})}),n.jsx(y.NiceButton,{size:"sm",variant:"ghost",leftIcon:n.jsx(y.NiceIcon,{name:"expand",size:14}),onClick:()=>z(N=>N+1),children:b("workflowDesigner.fit","Fit to view")}),l&&!i&&n.jsx(y.NiceButton,{size:"sm",variant:"ghost",onClick:()=>l(k),children:b("workflowDesigner.test","Test")}),u&&!i&&n.jsx(y.NiceButton,{size:"sm",variant:"primary",onClick:()=>u(k),disabled:ze.length>0,children:b("workflowDesigner.publish","Publish")})]}):void 0,ee=N=>k.states.filter(T=>T.id!==N).map(T=>({value:T.id,label:T.name})),Ge=N=>n.jsxs("div",{className:"nice-workflow-designer__props-header",children:[n.jsx("h3",{children:N}),n.jsx("button",{type:"button",className:"nice-workflow-designer__props-close",onClick:()=>O(null),"aria-label":b("workflowDesigner.closeProps","Close properties"),title:b("workflowDesigner.closeProps","Close properties"),children:n.jsx(y.NiceIcon,{name:"close",size:12})})]});let _e;if(!i&&!K&&Z){const N=k.transitions.filter(T=>T.fromStateId===Z.id);_e=n.jsxs("aside",{className:"nice-workflow-designer__props","aria-label":b("workflowDesigner.stateProps","State properties"),children:[Ge(Z.name),n.jsx(y.NiceTextInput,{label:b("workflowDesigner.stateName","State name"),size:"sm",value:Z.name,onChange:T=>ve(Z.id,{name:T})}),n.jsx(y.NiceSelect,{label:b("workflowDesigner.stateType","State type"),size:"sm",value:Z.type,options:W.map(T=>({value:T.id,label:T.label})),onChange:T=>{const J=Array.isArray(T)?T[0]:T;J&&ve(Z.id,{type:String(J)})}}),n.jsx("h4",{className:"nice-workflow-designer__props-section",children:b("workflowDesigner.transitions","Transitions")}),N.length===0&&n.jsx("p",{className:"nice-workflow-designer__props-empty",children:b("workflowDesigner.noTransitions","No transitions yet")}),N.map(T=>n.jsxs("div",{className:"nice-workflow-designer__transition","data-transition-id":T.id,children:[n.jsx(y.NiceTextInput,{"aria-label":b("workflowDesigner.transitionName","Transition name"),size:"sm",value:T.name,onChange:J=>Fe(T.id,{name:J})}),n.jsx(y.NiceSelect,{"aria-label":b("workflowDesigner.target","To"),size:"sm",value:T.toStateId,options:ee(),onChange:J=>{const se=Array.isArray(J)?J[0]:J;se&&Fe(T.id,{toStateId:String(se)})}}),n.jsx(y.NiceButton,{size:"sm",variant:"ghost",ariaLabel:b("workflowDesigner.deleteFlow","Delete flow"),onClick:()=>Le(T.id),children:n.jsx(y.NiceIcon,{name:"trash",size:14})})]},T.id)),n.jsx(y.NiceButton,{size:"sm",variant:"secondary",leftIcon:n.jsx(y.NiceIcon,{name:"plus",size:14}),onClick:()=>Y(Z.id),disabled:k.states.length<2,children:b("workflowDesigner.addTransition","Add transition")}),n.jsx(y.NiceButton,{size:"sm",variant:"danger",leftIcon:n.jsx(y.NiceIcon,{name:"trash",size:14}),onClick:()=>Ue(Z.id),className:"nice-workflow-designer__props-delete",children:b("workflowDesigner.deleteState","Delete state {name}").replace("{name}",Z.name)})]})}else if(!i&&!K&&te){const N=k.states.find(T=>T.id===te.fromStateId);_e=n.jsxs("aside",{className:"nice-workflow-designer__props","aria-label":b("workflowDesigner.properties","Properties"),children:[Ge(b("workflowDesigner.flowOf","Flow: {name}").replace("{name}",te.name||"→")),n.jsx(y.NiceTextInput,{label:b("workflowDesigner.transitionName","Transition name"),size:"sm",value:te.name,onChange:T=>Fe(te.id,{name:T})}),n.jsxs("p",{className:"nice-workflow-designer__props-from",children:[b("workflowDesigner.from","From"),": ",n.jsx("strong",{children:N==null?void 0:N.name})]}),n.jsx(y.NiceSelect,{label:b("workflowDesigner.target","To"),size:"sm",value:te.toStateId,options:ee(),onChange:T=>{const J=Array.isArray(T)?T[0]:T;J&&Fe(te.id,{toStateId:String(J)})}}),n.jsx(y.NiceButton,{size:"sm",variant:"danger",leftIcon:n.jsx(y.NiceIcon,{name:"trash",size:14}),onClick:()=>Le(te.id),children:b("workflowDesigner.deleteFlow","Delete flow")})]})}const at=k.states.find(N=>N.id===G),ct=c&&Xe.length>0&&!K,kt=ct||K?n.jsxs(n.Fragment,{children:[ct&&n.jsx("div",{className:"nice-workflow-designer__validation",role:"status","aria-live":"polite",children:Xe.map((N,T)=>{const J=n.jsxs(n.Fragment,{children:[n.jsx(y.NiceIcon,{name:N.type==="error"?"error":"warning",size:14})," ",N.message]}),se=`nice-workflow-designer__issue nice-workflow-designer__issue--${N.type}`;return N.stateId?n.jsx("button",{type:"button",className:se,onClick:()=>O(N.stateId),children:J},T):n.jsx("div",{className:se,children:J},T)})}),K&&n.jsxs("div",{className:"nice-workflow-designer__sim-toolbar",children:[n.jsxs("span",{children:[b("workflowDesigner.simActiveState","Simulation active — current state:")," ",n.jsx("strong",{children:at==null?void 0:at.name})]}),k.transitions.filter(N=>N.fromStateId===G).map(N=>{var T;return n.jsxs("button",{type:"button",className:"nice-workflow-designer__sim-btn",onClick:()=>q(N.toStateId),children:[n.jsx(y.NiceIcon,{name:"arrow-right",size:12})," ",N.name||((T=k.states.find(J=>J.id===N.toStateId))==null?void 0:T.name)]},N.id)}),n.jsx("button",{type:"button",className:"nice-workflow-designer__sim-end",onClick:()=>q(null),children:b("workflowDesigner.endSimulation","End simulation")})]})]}):void 0,Ye=p.useCallback(N=>{K||O(N)},[K]);return n.jsx(y.NiceAppShell,{flush:!0,className:`nice-workflow-designer${i?" nice-workflow-designer--readonly":""} ${h??""}`,style:v,"data-testid":_,toolbar:rt,rightSidebar:_e,bottomPanel:kt,children:n.jsxs("div",{className:"nice-workflow-designer__canvas",children:[n.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:n.jsx(y.NiceTutorialButton,{steps:y.resolveTutorial(d,oa)})}),n.jsx(Ee,{nodes:Ce,edges:Ae,viewport:Ve,onViewportChange:Ne,selectedId:$,onSelectElement:Ye,interactive:!i&&!K,onEdgeCreate:i||K?void 0:(N,T)=>Y(N,T),autoFit:!0,fitKey:he,refitKey:Je,onResize:ne,resizable:!1,panOnDrag:!0,ariaLabel:b("workflowDesigner.canvas","Workflow canvas")}),a&&n.jsx("div",{className:"nice-workflow-designer__minimap","aria-label":b("workflowDesigner.minimap","Minimap"),children:n.jsx(lt,{nodes:Ce,edges:Ae,viewport:Ve,onViewportChange:Ne,canvasWidth:U==null?void 0:U.width,canvasHeight:U==null?void 0:U.height})})]})})};process.env.NODE_ENV!=="production"&&(Nr.displayName="NiceWorkflowDesigner");const na={pending:"var(--nice-text-muted, #9ca3af)",active:"var(--nice-primary, #3b82f6)",completed:"var(--nice-success, #10b981)",failed:"var(--nice-danger, #ef4444)",skipped:"var(--nice-warning, #f59e0b)",waiting:"var(--nice-accent, #8b5cf6)"},sa={start:"ellipse",end:"ellipse",task:"rectangle",decision:"diamond",parallel:"rectangle",join:"rectangle",subprocess:"rectangle",timer:"ellipse",message:"rectangle",error:"rectangle"},la={start:"play",end:"stop",task:"clipboard",decision:"help",parallel:"columns",join:"git-branch",subprocess:"box",timer:"clock",message:"mail",error:"warning"},ca=({data:o,onStepClick:e,onTransitionClick:t,autoPlay:r=!1,animationDelay:i=1e3,showTooltips:a=!0,showMinimap:s=!0,statusColors:c=na,typeShapes:l=sa,direction:u="horizontal",className:d,style:w})=>{const[x,g]=p.useState(0),h=p.useMemo(()=>{const m=o.steps.map((j,M)=>{const X=j.id===o.currentStepId,V=j.status||"pending",F=c[V],R=l[j.type],I=u==="horizontal"?M*200:100,L=u==="horizontal"?100:M*150;return{id:j.id,label:j.name,x:I,y:L,width:150,height:60,shape:R,style:{fill:F,stroke:X?"var(--nice-text, #1f2937)":F,strokeWidth:X?3:1,fontColor:"var(--nice-color-white, #fff)",fontSize:12},data:{type:j.type,status:j.status,assignee:j.assignee,dueDate:j.dueDate,icon:la[j.type],...j.metadata},ports:[{id:`${j.id}-in`,position:"left"},{id:`${j.id}-out`,position:"right"}]}}),A=o.transitions.map(j=>{const M=o.steps.find(F=>F.id===j.from),X=o.steps.find(F=>F.id===j.to);let V="var(--nice-text-muted, #9ca3af)";return(M==null?void 0:M.status)==="completed"&&(X==null?void 0:X.status)!=="pending"?V="var(--nice-success, #10b981)":(M==null?void 0:M.status)==="failed"&&(V="var(--nice-danger, #ef4444)"),{id:j.id,source:j.from,target:j.to,sourcePort:`${j.from}-out`,targetPort:`${j.to}-in`,label:j.label||j.condition,style:{stroke:V,strokeWidth:2,arrowHead:"arrow",lineType:"bezier"},data:{condition:j.condition}}}),k=r?da(o.steps):[];return Ze({id:o.id,title:o.name,diagramType:"flowchart",nodes:m,edges:A,animations:k,metadata:{type:"workflow",...o.metadata}})},[o,c,l,u,r]);p.useEffect(()=>{if(!r)return;const m=o.steps.filter(k=>k.status==="completed").length;if(x>=m)return;const A=setTimeout(()=>{g(k=>k+1)},i);return()=>clearTimeout(A)},[r,x,i,o.steps]);const[v,_]=p.useState({x:0,y:0,zoom:1}),b=p.useCallback(m=>{if(m&&e){const A=o.steps.find(k=>k.id===m);A&&e(A)}if(m&&t){const A=o.transitions.find(k=>k.id===m);A&&t(A)}},[o.steps,o.transitions,e,t]);return n.jsx("div",{className:`nice-workflow-visualizer ${d||""}`,style:{position:"relative",width:"100%",height:"100%",...w},children:n.jsx(Ee,{nodes:h.nodes,edges:h.edges,groups:h.groups,viewport:v,onViewportChange:_,onSelectElement:b,showGrid:!0})})};function da(o){return o.filter(t=>t.status==="completed").map((t,r)=>({id:`anim-${t.id}`,targetId:t.id,type:"highlight",delay:r*500,duration:300,easing:"ease-out"}))}function ua(o){var a,s;const t=new DOMParser().parseFromString(o,"text/xml"),r=[],i=[];return t.querySelectorAll("startEvent").forEach(c=>{r.push({id:c.getAttribute("id")||`start-${r.length}`,name:c.getAttribute("name")||"Start",type:"start"})}),t.querySelectorAll("task, userTask, serviceTask").forEach(c=>{r.push({id:c.getAttribute("id")||`task-${r.length}`,name:c.getAttribute("name")||"Task",type:"task"})}),t.querySelectorAll("exclusiveGateway, parallelGateway").forEach(c=>{const l=c.tagName==="parallelGateway";r.push({id:c.getAttribute("id")||`gateway-${r.length}`,name:c.getAttribute("name")||(l?"Parallel":"Decision"),type:l?"parallel":"decision"})}),t.querySelectorAll("endEvent").forEach(c=>{r.push({id:c.getAttribute("id")||`end-${r.length}`,name:c.getAttribute("name")||"End",type:"end"})}),t.querySelectorAll("sequenceFlow").forEach(c=>{i.push({id:c.getAttribute("id")||`flow-${i.length}`,from:c.getAttribute("sourceRef")||"",to:c.getAttribute("targetRef")||"",label:c.getAttribute("name")||void 0})}),{id:((a=t.querySelector("process"))==null?void 0:a.getAttribute("id"))||"workflow",name:((s=t.querySelector("process"))==null?void 0:s.getAttribute("name"))||"Workflow",steps:r,transitions:i}}function fa(o,e){const t=[],r=[];t.push({id:"start",name:"Start",type:"start",status:"completed"}),o.forEach((i,a)=>{t.push({id:`step-${a}`,name:i,type:"task",status:"pending"})}),t.push({id:"end",name:"End",type:"end",status:"pending"}),r.push({id:"start-to-first",from:"start",to:"step-0"});for(let i=0;i<o.length-1;i++)r.push({id:`step-${i}-to-${i+1}`,from:`step-${i}`,to:`step-${i+1}`});return r.push({id:"last-to-end",from:`step-${o.length-1}`,to:"end"}),{id:"linear-workflow",name:"Linear Workflow",steps:t,transitions:r}}const ha={dbo:"var(--nice-primary, #3b82f6)",public:"var(--nice-success, #10b981)",auth:"var(--nice-accent, #8b5cf6)",billing:"var(--nice-warning, #f59e0b)",audit:"var(--nice-danger, #ef4444)"},ma={"one-to-one":{left:"1",right:"1"},"one-to-many":{left:"1",right:"*"},"many-to-one":{left:"*",right:"1"},"many-to-many":{left:"*",right:"*"}},ga=({schema:o,onTableClick:e,onColumnClick:t,onRelationClick:r,showColumnDetails:i=!0,showOnlyKeys:a=!1,highlightTables:s=[],showMinimap:c=!0,schemaColors:l=ha,layout:u="auto",maxColumnsDisplay:d=15,className:w,style:x})=>{const[g,h]=p.useState(null),v=p.useMemo(()=>{const A=pa(o.tables,u),k=o.tables.map((M,X)=>{const V=A[M.name]||{x:X%4*300,y:Math.floor(X/4)*400},F=s.includes(M.name),R=g===M.name,I=l[M.schema||"dbo"]||"var(--nice-text-secondary, #6b7280)";let L=M.columns;a&&(L=L.filter($=>$.primaryKey||$.foreignKey)),L.length>d&&(L=L.slice(0,d));const W=40,H=i?28:20,C=W+L.length*H+10;return{id:M.name,label:M.schema?`${M.schema}.${M.name}`:M.name,x:V.x,y:V.y,width:250,height:C,shape:"rectangle",style:{fill:F||R?I:"var(--nice-bg, #fff)",stroke:I,strokeWidth:R?3:F?2:1,fontColor:F||R?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:14,borderRadius:8},data:{type:"table",schema:M.schema,columns:L.map($=>({...$,icon:ya($)})),totalColumns:M.columns.length,truncated:M.columns.length>d,comment:M.comment,...M.metadata},ports:[...M.columns.filter($=>$.primaryKey).map($=>({id:`${M.name}.${$.name}-pk`,position:"left"})),...M.columns.filter($=>$.foreignKey).map($=>({id:`${M.name}.${$.name}-fk`,position:"right"}))]}}),j=o.relations.map(M=>{const X=ma[M.type];return{id:M.id,source:M.fromTable,target:M.toTable,sourcePort:`${M.fromTable}.${M.fromColumn}-fk`,targetPort:`${M.toTable}.${M.toColumn}-pk`,label:M.name||`${X.left}─${X.right}`,style:{stroke:"var(--nice-text-secondary, #6b7280)",strokeWidth:1.5,arrowHead:ba(M.type),arrowTail:wa(M.type),lineType:"orthogonal",strokeDasharray:M.type==="many-to-many"?"5,5":void 0},data:{type:M.type,fromColumn:M.fromColumn,toColumn:M.toColumn}}});return Ze({id:`schema-${o.name}`,title:o.name,diagramType:"er",nodes:k,edges:j,metadata:{type:"er-diagram",...o.metadata}})},[o,i,a,s,g,l,u,d]),[_,b]=p.useState({x:0,y:0,zoom:1}),m=p.useCallback(A=>{if(A){if(h(k=>k===A?null:A),e){const k=o.tables.find(j=>j.name===A);k&&e(k)}if(r){const k=o.relations.find(j=>j.id===A);k&&r(k)}}},[o.tables,o.relations,e,r]);return n.jsx("div",{className:`nice-database-schema-viewer ${w||""}`,style:{position:"relative",width:"100%",height:"100%",...x},children:n.jsx(Ee,{nodes:v.nodes,edges:v.edges,groups:v.groups,viewport:_,onViewportChange:b,onSelectElement:m,showGrid:!0})})};function pa(o,e){const t={};if(e==="grid"){const r=Math.ceil(Math.sqrt(o.length));o.forEach((i,a)=>{t[i.name]={x:a%r*320+50,y:Math.floor(a/r)*450+50}})}else if(e==="hierarchical"){const r={};o.forEach(a=>{const s=a.schema||"default";r[s]||(r[s]=[]),r[s].push(a)});let i=50;Object.entries(r).forEach(([a,s])=>{s.forEach((c,l)=>{t[c.name]={x:l*320+50,y:i}}),i+=500})}else o.forEach((r,i)=>{const a=i/o.length*2*Math.PI,s=300+o.length*20;t[r.name]={x:Math.cos(a)*s+500,y:Math.sin(a)*s+400}});return t}function ya(o){return o.primaryKey?"lock":o.foreignKey?"link":o.unique?"zap":"file"}function ba(o){switch(o){case"one-to-one":case"many-to-one":return"none";case"one-to-many":case"many-to-many":return"crow"}}function wa(o){switch(o){case"one-to-one":case"one-to-many":return"none";case"many-to-one":case"many-to-many":return"crow"}}function xa(o){const e=[],t=[],r=/CREATE\s+TABLE\s+(?:`?(\w+)`?\.)?`?(\w+)`?\s*\(([\s\S]*?)\);/gi;let i;for(;(i=r.exec(o))!==null;){const a=i[1]||"dbo",s=i[2],c=i[3],l=[],u=/`?(\w+)`?\s+(\w+(?:\([^)]+\))?)\s*(NOT\s+NULL|NULL)?/gi;let d;for(;(d=u.exec(c))!==null;)l.push({name:d[1],type:d[2],nullable:!d[3]||d[3].toUpperCase()!=="NOT NULL"});const w=/PRIMARY\s+KEY\s*\(`?(\w+)`?\)/i.exec(c);if(w){const h=l.find(v=>v.name===w[1]);h&&(h.primaryKey=!0)}const x=/FOREIGN\s+KEY\s*\(`?(\w+)`?\)\s*REFERENCES\s+`?(\w+)`?\s*\(`?(\w+)`?\)/gi;let g;for(;(g=x.exec(c))!==null;){const h=g,v=l.find(_=>_.name===h[1]);v&&(v.foreignKey={table:h[2],column:h[3]},t.push({id:`fk-${s}-${h[1]}`,fromTable:s,fromColumn:h[1],toTable:h[2],toColumn:h[3],type:"many-to-one"}))}e.push({name:s,schema:a,columns:l})}return{name:"Parsed Schema",tables:e,relations:t}}function va(o,e="postgres"){const t=[];for(const r of o.tables){const i=r.schema?`${r.schema}.${r.name}`:r.name;t.push(`CREATE TABLE ${i} (`);const a=r.columns.map(c=>{let l=` ${c.name} ${c.type}`;return c.nullable||(l+=" NOT NULL"),c.primaryKey&&(l+=" PRIMARY KEY"),c.unique&&(l+=" UNIQUE"),c.defaultValue&&(l+=` DEFAULT ${c.defaultValue}`),l}),s=r.columns.filter(c=>c.foreignKey).map(c=>` FOREIGN KEY (${c.name}) REFERENCES ${c.foreignKey.table}(${c.foreignKey.column})`);t.push([...a,...s].join(`,
4
4
  `)),t.push(`);
5
5
  `)}return t.join(`
6
- `)}const ka={active:"var(--nice-success, #10b981)",away:"var(--nice-warning, #f59e0b)",busy:"var(--nice-danger, #ef4444)",offline:"var(--nice-text-secondary, #6b7280)",vacation:"var(--nice-accent, #8b5cf6)",leave:"var(--nice-primary, #3b82f6)"},mt=["var(--nice-primary, #3b82f6)","var(--nice-success, #10b981)","var(--nice-warning, #f59e0b)","var(--nice-danger, #ef4444)","var(--nice-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-info, #14b8a6)","var(--nice-info, #6366f1)"],Ca={employees:[]},Sa=({data:o=Ca,rootEmployeeId:e,onEmployeeClick:t,onDepartmentClick:r,showAvatars:i=!0,showContactInfo:a=!1,groupByDepartment:s=!0,collapsedDepartments:c=[],maxLevels:l=0,orientation:u="vertical",spacing:d={horizontal:200,vertical:150},statusColors:b=ka,showMinimap:x=!0,className:g,style:h})=>{const{t:v}=Re(),[_,w]=p.useState(null),m=p.useMemo(()=>{var H;if(e)return e;const F=o.employees.find(I=>!I.managerId);return(F==null?void 0:F.id)||((H=o.employees[0])==null?void 0:H.id)},[o.employees,e]),P=p.useMemo(()=>Na(o.employees,m),[o.employees,m]),k=p.useMemo(()=>{const F=_a(P,u,d,l),H=[],I={};s&&o.departments&&o.departments.forEach((S,A)=>{const R=S.color||mt[A%mt.length];I[S.id]=R;const q=o.employees.filter(B=>B.department===S.id);q.length!==0&&H.push({id:`dept-${S.id}`,label:S.name,nodeIds:q.map(B=>B.id),style:{fill:`${R}15`,stroke:R,strokeWidth:2},data:{department:S}})});const O=[],L=[],Y=(S,A=0)=>{if(l>0&&A>=l||S.employee.department&&c.includes(S.employee.department))return;const R=F[S.employee.id]||{x:0,y:0},q=_===S.employee.id,B=S.employee.status||"active",K=S.employee.department?I[S.employee.department]:"var(--nice-text-secondary, #6b7280)",Z=180,te=a?120:i?90:70;O.push({id:S.employee.id,label:S.employee.name,x:R.x,y:R.y,width:Z,height:te,shape:"rectangle",style:{fill:q?K:"var(--nice-bg, #fff)",stroke:K,strokeWidth:q?3:1,fontColor:q?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:13,borderRadius:12},data:{type:"employee",employee:S.employee,statusColor:b[B],hasChildren:S.children.length>0,childrenCount:S.children.length}}),S.employee.managerId&&L.push({id:`rel-${S.employee.managerId}-${S.employee.id}`,source:S.employee.managerId,target:S.employee.id,style:{stroke:"var(--nice-border, #cbd5e1)",strokeWidth:2,arrowHead:"none",lineType:u==="vertical"?"orthogonal":"curved"}}),S.children.forEach(ge=>Y(ge,A+1))};return P&&Y(P),Ze({id:"org-chart",title:v("orgChartVisualizer.organizationChart","Organization Chart"),diagramType:"orgchart",nodes:O,edges:L,groups:H,metadata:{type:"org-chart",...o.metadata}})},[o,P,u,d,l,s,c,i,a,b,_,v]),[j,C]=p.useState({x:0,y:0,zoom:1}),X=p.useCallback(F=>{if(F&&(w(H=>H===F?null:F),t)){const H=o.employees.find(I=>I.id===F);H&&t(H)}},[o.employees,t]),V=p.useCallback(F=>{var I;const H=(I=o.departments)==null?void 0:I.find(O=>`dept-${O.id}`===F);H&&(r==null||r(H))},[o.departments,r]);return n.jsx("div",{className:`nice-org-chart-visualizer ${g||""}`,style:{position:"relative",width:"100%",height:"100%",...h},children:n.jsx(Ee,{nodes:k.nodes,edges:k.edges,groups:k.groups,viewport:j,onViewportChange:C,onSelectElement:X,onGroupClick:r?V:void 0,showGrid:!1})})};function Na(o,e){const r=new Map(o.map(a=>[a.id,a])).get(e);if(!r)return null;const i=(a,s)=>{const c=o.filter(l=>l.managerId===a.id);return{employee:a,children:c.map(l=>i(l,s+1)),level:s}};return i(r,0)}function _a(o,e,t,r){const i={};if(!o)return i;const a=(l,u)=>r>0&&u>=r?0:l.children.length===0?1:l.children.reduce((d,b)=>d+a(b,u+1),0),s=(l,u,d,b)=>{if(r>0&&u>=r)return;const x=d+b*t.horizontal/2,g=u*t.vertical+50;i[l.employee.id]=e==="vertical"?{x,y:g}:{x:g,y:x};let h=d;l.children.forEach(v=>{const _=a(v,u+1);s(v,u+1,h,_),h+=_*t.horizontal})},c=a(o,0);return s(o,0,0,c),i}function Ma(o){const t=[...new Set(o.map(r=>r.department).filter(Boolean))].map((r,i)=>({id:r,name:r,color:mt[i%mt.length],headcount:o.filter(a=>a.department===r).length}));return{employees:o,departments:t}}function za(o){var c;const e=new Set(o.employees.map(l=>l.managerId).filter(Boolean)),t=(l,u=new Set)=>{if(u.has(l))return 0;u.add(l);const d=o.employees.find(b=>b.id===l);return d!=null&&d.managerId?1+t(d.managerId,u):1},r=o.employees.map(l=>t(l.id)),i=Math.max(...r,0),a=Array.from(e).map(l=>o.employees.filter(u=>u.managerId===l).length),s=a.length>0?a.reduce((l,u)=>l+u,0)/a.length:0;return{totalEmployees:o.employees.length,departmentCount:((c=o.departments)==null?void 0:c.length)||0,maxDepth:i,averageSpan:Math.round(s*10)/10,managers:e.size}}const Ia=({data:o,onActivityClick:e,onTransitionClick:t,minEdgeFrequency:r=.05,showFrequency:i=!0,showDuration:a=!0,highlightBottlenecks:s=!0,bottleneckThreshold:c=.9,colorScheme:l="frequency",activityColors:u,layout:d="hierarchical",animationSpeed:b=0,showMinimap:x=!0,className:g,style:h})=>{const{t:v}=Re(),[_,w]=p.useState(null),m=p.useMemo(()=>"activities"in o?o:_r(o),[o]),P=p.useMemo(()=>{if(!s)return new Set;const F=m.activities.filter(I=>I.avgDuration!==void 0).map(I=>I.avgDuration);if(F.length===0)return new Set;F.sort((I,O)=>I-O);const H=F[Math.floor(F.length*c)]||0;return new Set(m.activities.filter(I=>(I.avgDuration||0)>=H).map(I=>I.name))},[m.activities,s,c]),k=p.useMemo(()=>{const F=Math.max(...m.activities.map(S=>S.frequency),1),H=ja(m,d),I=m.transitions.filter(S=>S.frequency/m.totalCases>=r),O=m.activities.map(S=>{const A=H[S.name]||{x:0,y:0},R=m.startActivities.includes(S.name),q=m.endActivities.includes(S.name),B=P.has(S.name),K=_===S.name,Z=Aa(S,l,F,u,B);return{id:S.name,label:S.name,x:A.x,y:A.y,width:140,height:60,shape:R?"ellipse":q?"roundedRect":"rectangle",style:{fill:K?Z:"var(--nice-bg, #fff)",stroke:Z,strokeWidth:B?4:K?3:2,fontColor:K?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:12,borderRadius:q?20:8},data:{type:"activity",activity:S,isStart:R,isEnd:q,isBottleneck:B,frequencyPercent:Math.round(S.frequency/m.totalCases*100)}}}),L=I.map(S=>{const A=m.transitions.indexOf(S),R=S.probability||S.frequency/m.totalCases,q=R>.5,B=[];return i&&B.push(`${S.frequency}x`),a&&S.avgDuration&&B.push($a(S.avgDuration)),{id:`trans-${A}`,source:S.from,target:S.to,label:B.join(" | "),style:{stroke:q?"var(--nice-primary, #3b82f6)":"var(--nice-text-muted, #9ca3af)",strokeWidth:Math.max(1,Math.min(6,R*8)),arrowHead:"triangle",lineType:"curved",opacity:Math.max(.3,R)},data:{type:"transition",transition:S,probability:R}}}),Y=b>0?Ta(m,b):[];return Ze({id:"process-mining",title:v("processMiningDiagram.processMiningDiagram","Process Mining Diagram"),diagramType:"flowchart",nodes:O,edges:L,animations:Y,metadata:{type:"process-mining",totalCases:m.totalCases,avgCaseDuration:m.avgCaseDuration}})},[m,r,i,a,P,l,u,d,b,_,v]),j=p.useCallback(F=>{if(!t)return;const H=parseInt(F.replace("trans-",""),10),I=m.transitions[H];I&&t(I)},[m.transitions,t]),[C,X]=p.useState({x:0,y:0,zoom:1}),V=p.useCallback(F=>{if(F){if(F.startsWith("trans-")){j(F);return}if(w(H=>H===F?null:F),e){const H=m.activities.find(I=>I.name===F);H&&e(H)}}},[m.activities,e,j]);return n.jsx("div",{className:`nice-process-mining-diagram ${g||""}`,style:{position:"relative",width:"100%",height:"100%",...h},children:n.jsx(Ee,{nodes:k.nodes,edges:k.edges,groups:k.groups,viewport:C,onViewportChange:X,onSelectElement:V,showGrid:!0})})};function ja(o,e){const t={};if(e==="circular"){const r=o.activities;r.forEach((i,a)=>{const s=a/r.length*2*Math.PI-Math.PI/2,c=200+r.length*15;t[i.name]={x:Math.cos(s)*c+400,y:Math.sin(s)*c+300}})}else{const r=Da(o),i={};o.activities.forEach(s=>{const c=r[s.name]||0;i[c]=(i[c]||0)+1});const a={};o.activities.forEach(s=>{const c=r[s.name]||0,l=a[c]||0;a[c]=l+1;const u=i[c],d=(l-(u-1)/2)*180;t[s.name]={x:400+d,y:50+c*120}})}return t}function Da(o){const e={},t=new Set,r=o.startActivities.map(i=>({activity:i,level:0}));for(;r.length>0;){const{activity:i,level:a}=r.shift();if(t.has(i))continue;t.add(i),e[i]=a,o.transitions.filter(c=>c.from===i).forEach(c=>{t.has(c.to)||r.push({activity:c.to,level:a+1})})}return o.activities.forEach(i=>{e[i.name]===void 0&&(e[i.name]=0)}),e}function Aa(o,e,t,r,i){if(i)return"var(--nice-danger, #ef4444)";if(r!=null&&r[o.name])return r[o.name];const a=o.frequency/t;switch(e){case"frequency":return Mt("var(--nice-success, #10b981)","var(--nice-primary, #3b82f6)",a);case"duration":return o.avgDuration?Mt("var(--nice-success, #10b981)","var(--nice-warning, #f59e0b)",a):"var(--nice-text-secondary, #6b7280)";case"cost":return o.avgCost?Mt("var(--nice-success, #10b981)","var(--nice-danger, #ef4444)",a):"var(--nice-text-secondary, #6b7280)";default:return"var(--nice-primary, #3b82f6)"}}function Mt(o,e,t){const r=u=>{const d=/#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})\b/i.exec(u);return d?{r:parseInt(d[1],16),g:parseInt(d[2],16),b:parseInt(d[3],16)}:{r:0,g:0,b:0}},i=r(o),a=r(e),s=Math.round(i.r+(a.r-i.r)*t),c=Math.round(i.g+(a.g-i.g)*t),l=Math.round(i.b+(a.b-i.b)*t);return`#${[s,c,l].map(u=>u.toString(16).padStart(2,"0")).join("")}`}function $a(o){return o<1e3?`${o}ms`:o<6e4?`${(o/1e3).toFixed(1)}s`:o<36e5?`${(o/6e4).toFixed(1)}m`:o<864e5?`${(o/36e5).toFixed(1)}h`:`${(o/864e5).toFixed(1)}d`}function Ta(o,e){var r;const t=(r=o.variants)==null?void 0:r[0];return t?t.activities.map((i,a)=>({id:`flow-${a}`,type:"highlight",targets:[i],duration:e,delay:a*e})):[]}function _r(o){const e=o.events.map(g=>({...g,timestamp:g.timestamp instanceof Date?g.timestamp:new Date(g.timestamp)})),t=new Map;e.forEach(g=>{t.has(g.caseId)||t.set(g.caseId,[]),t.get(g.caseId).push(g)}),t.forEach(g=>{g.sort((h,v)=>h.timestamp.getTime()-v.timestamp.getTime())});const r=new Map,i=new Map,a=new Set,s=new Set;t.forEach(g=>{if(g.length!==0){a.add(g[0].activity),s.add(g[g.length-1].activity);for(let h=0;h<g.length;h++){const v=g[h];r.has(v.activity)||r.set(v.activity,{frequency:0,durations:[],resources:new Set,costs:[]});const _=r.get(v.activity);if(_.frequency++,v.resource&&_.resources.add(v.resource),v.cost!==void 0&&_.costs.push(v.cost),h<g.length-1){const w=g[h+1],m=w.timestamp.getTime()-v.timestamp.getTime();_.durations.push(m);const P=`${v.activity}→${w.activity}`;i.has(P)||i.set(P,{frequency:0,durations:[]});const k=i.get(P);k.frequency++,k.durations.push(m)}}}});const c=Array.from(r.entries()).map(([g,h])=>({name:g,frequency:h.frequency,avgDuration:h.durations.length>0?h.durations.reduce((v,_)=>v+_,0)/h.durations.length:void 0,minDuration:h.durations.length>0?Math.min(...h.durations):void 0,maxDuration:h.durations.length>0?Math.max(...h.durations):void 0,resources:Array.from(h.resources),avgCost:h.costs.length>0?h.costs.reduce((v,_)=>v+_,0)/h.costs.length:void 0})),l=Array.from(i.entries()).map(([g,h])=>{const[v,_]=g.split("→");return{from:v,to:_,frequency:h.frequency,avgDuration:h.durations.length>0?h.durations.reduce((w,m)=>w+m,0)/h.durations.length:void 0,probability:h.frequency/t.size}}),u=new Map;t.forEach((g,h)=>{const v=g.map(w=>w.activity).join("→");u.has(v)||u.set(v,{caseIds:[],durations:[]});const _=u.get(v);if(_.caseIds.push(h),g.length>=2){const w=g[g.length-1].timestamp.getTime()-g[0].timestamp.getTime();_.durations.push(w)}});const d=Array.from(u.entries()).map(([g,h])=>({activities:g.split("→"),frequency:h.caseIds.length,avgDuration:h.durations.length>0?h.durations.reduce((v,_)=>v+_,0)/h.durations.length:0,caseIds:h.caseIds})).sort((g,h)=>h.frequency-g.frequency),b=Array.from(t.values()).filter(g=>g.length>=2).map(g=>g[g.length-1].timestamp.getTime()-g[0].timestamp.getTime()),x=b.length>0?b.reduce((g,h)=>g+h,0)/b.length:void 0;return{activities:c,transitions:l,variants:d,startActivities:Array.from(a),endActivities:Array.from(s),totalCases:t.size,avgCaseDuration:x}}const Mr={module:"var(--nice-primary, #3b82f6)",package:"var(--nice-success, #10b981)",microservice:"var(--nice-accent, #8b5cf6)",library:"var(--nice-warning, #f59e0b)",api:"var(--nice-color-accent-pink, #ec4899)",database:"var(--nice-info, #14b8a6)",external:"var(--nice-text-secondary, #6b7280)",deprecated:"var(--nice-danger, #ef4444)"},zr={healthy:"var(--nice-success, #10b981)",warning:"var(--nice-warning, #f59e0b)",critical:"var(--nice-danger, #ef4444)",unknown:"var(--nice-text-secondary, #6b7280)",deprecated:"var(--nice-text-muted, #9ca3af)"},Zt={import:{color:"var(--nice-primary, #3b82f6)"},runtime:{color:"var(--nice-success, #10b981)"},dev:{color:"var(--nice-text-secondary, #6b7280)",dash:"5,5"},peer:{color:"var(--nice-warning, #f59e0b)",dash:"10,5"},"api-call":{color:"var(--nice-accent, #8b5cf6)"},database:{color:"var(--nice-info, #14b8a6)"},event:{color:"var(--nice-color-accent-pink, #ec4899)",dash:"2,2"},circular:{color:"var(--nice-danger, #ef4444)"}},Pa={module:"box",package:"folder",microservice:"square",library:"book",api:"plug",database:"database",external:"globe",deprecated:"warning"},Ea=({data:o,onNodeClick:e,onEdgeClick:t,visibleTypes:r,visibleEdgeTypes:i,highlightCircular:a=!0,showOnlyIssues:s=!1,layout:c="force",groupBy:l="type",nodeSizeBy:u="dependencies",colorScheme:d="type",nodeColors:b,showMetrics:x=!0,interactive:g=!0,showMinimap:h=!0,className:v,style:_})=>{const{t:w}=Re(),[m,P]=p.useState(null),[k,j]=p.useState(null),C=p.useMemo(()=>a?Ir(o):new Set,[o,a]),X=p.useMemo(()=>{let Y=o.nodes;return r&&r.length>0&&(Y=Y.filter(S=>r.includes(S.type))),s&&(Y=Y.filter(S=>{var A;return S.status==="critical"||S.status==="warning"||((A=S.metrics)==null?void 0:A.issues)&&S.metrics.issues>0})),Y},[o.nodes,r,s]),V=p.useMemo(()=>{const Y=new Set(X.map(A=>A.id));let S=o.edges.filter(A=>Y.has(A.source)&&Y.has(A.target));return i&&i.length>0&&(S=S.filter(A=>i.includes(A.type))),S},[o.edges,X,i]),F=p.useMemo(()=>{const Y=Ra(X,V,c),S=Fa(X,u),A=[];if(l!=="none"){const B=new Map;X.forEach(Z=>{const te=l==="type"?Z.type:Z.group||"ungrouped";B.has(te)||B.set(te,[]),B.get(te).push(Z.id)});let K=0;B.forEach((Z,te)=>{var he,Ce;const ge=l==="type"?Mr[te]||"var(--nice-text-secondary, #6b7280)":((Ce=(he=o.groups)==null?void 0:he.find(Ae=>Ae.id===te))==null?void 0:Ce.color)||gt[K%gt.length];A.push({id:`group-${te}`,label:te,nodeIds:Z,style:{fill:`${ge}10`,stroke:ge,strokeWidth:1}}),K++})}const R=X.map(B=>{const K=Y[B.id]||{x:0,y:0},Z=m===B.id,te=k===B.id,ge=C.has(B.id),he=La(B,u,S),Ce=Wa(B,d,b,ge);return{id:B.id,label:B.name,x:K.x,y:K.y,width:he.width,height:he.height,shape:Ba(B.type),style:{fill:Z||te?Ce:"var(--nice-bg, #fff)",stroke:Ce,strokeWidth:ge?4:Z?3:2,fontColor:Z||te?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:8,strokeDasharray:B.status==="deprecated"?"4,4":void 0},data:{type:"dependency",node:B,icon:Pa[B.type],isCircular:ge,statusColor:zr[B.status||"unknown"]}}}),q=V.map((B,K)=>{const Z=B.type==="circular"||C.has(B.source)&&C.has(B.target),te=Zt[B.type]||Zt.import;return{id:B.id||`edge-${K}`,source:B.source,target:B.target,label:B.optional?w("dependencyGraph.optional","(optional)"):void 0,style:{stroke:Z?"var(--nice-danger, #ef4444)":te.color,strokeWidth:Math.max(1,Math.min(4,B.weight||1)),strokeDasharray:te.dash,arrowHead:"triangle",lineType:"curved",opacity:B.optional?.5:1},data:{type:B.type,edge:B,isCircular:Z}}});return Ze({id:"dependency-graph",title:w("dependencyGraph.dependencyGraph","Dependency Graph"),diagramType:"custom",nodes:R,edges:q,groups:A,metadata:{type:"dependency-graph",...o.metadata}})},[X,V,c,l,o.groups,u,d,b,C,m,k,o.metadata,w]),H=p.useCallback(Y=>{j(Y)},[]),[I,O]=p.useState({x:0,y:0,zoom:1}),L=p.useCallback(Y=>{if(Y){if(P(S=>S===Y?null:Y),e){const S=o.nodes.find(A=>A.id===Y);S&&e(S)}if(t){const S=o.edges.find(A=>A.id===Y);S&&t(S)}}},[o.nodes,o.edges,e,t]);return n.jsx("div",{className:`nice-dependency-graph ${v||""}`,style:{position:"relative",width:"100%",height:"100%",..._},children:n.jsx(Ee,{nodes:F.nodes,edges:F.edges,groups:F.groups,viewport:I,onViewportChange:O,onSelectElement:L,onNodeHover:H,interactive:g,showGrid:!0})})},gt=["var(--nice-primary, #3b82f6)","var(--nice-success, #10b981)","var(--nice-warning, #f59e0b)","var(--nice-danger, #ef4444)","var(--nice-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-info, #14b8a6)","var(--nice-info, #6366f1)"];function Ir(o){const e=new Set,t=new Map;o.nodes.forEach(s=>t.set(s.id,[])),o.edges.forEach(s=>{var c;(c=t.get(s.source))==null||c.push(s.target)});const r=new Set,i=new Set,a=(s,c)=>{r.add(s),i.add(s),c.push(s);const l=t.get(s)||[];for(const u of l)if(r.has(u)){if(i.has(u)){const d=c.indexOf(u);c.slice(d).forEach(x=>e.add(x))}}else if(a(u,[...c]))return!0;return i.delete(s),!1};return o.nodes.forEach(s=>{r.has(s.id)||a(s.id,[])}),e}function Ra(o,e,t){const r={};switch(t){case"circular":{o.forEach((i,a)=>{const s=a/o.length*2*Math.PI-Math.PI/2,c=150+o.length*12;r[i.id]={x:Math.cos(s)*c+400,y:Math.sin(s)*c+300}});break}case"grid":{const i=Math.ceil(Math.sqrt(o.length));o.forEach((a,s)=>{r[a.id]={x:s%i*200+100,y:Math.floor(s/i)*150+100}});break}case"hierarchical":{const i=Oa(o,e),a={},s={};o.forEach(c=>{const l=i[c.id]||0;a[l]=(a[l]||0)+1}),o.forEach(c=>{const l=i[c.id]||0,u=s[l]||0;s[l]=u+1;const d=a[l],b=(u-(d-1)/2)*200;r[c.id]={x:400+b,y:80+l*130}});break}default:{o.forEach((i,a)=>{const s=a/o.length*2*Math.PI,c=200+o.length*10;r[i.id]={x:Math.cos(s)*c+400,y:Math.sin(s)*c+300}});for(let i=0;i<50;i++){const a={};o.forEach(s=>a[s.id]={x:0,y:0});for(let s=0;s<o.length;s++)for(let c=s+1;c<o.length;c++){const l=o[s].id,u=o[c].id,d=r[u].x-r[l].x,b=r[u].y-r[l].y,x=Math.max(1,Math.sqrt(d*d+b*b)),g=5e3/(x*x);a[l].x-=d/x*g,a[l].y-=b/x*g,a[u].x+=d/x*g,a[u].y+=b/x*g}e.forEach(s=>{const c=r[s.target].x-r[s.source].x,l=r[s.target].y-r[s.source].y,u=Math.sqrt(c*c+l*l),d=u*.01;a[s.source].x+=c/u*d,a[s.source].y+=l/u*d,a[s.target].x-=c/u*d,a[s.target].y-=l/u*d}),o.forEach(s=>{r[s.id].x+=Math.max(-10,Math.min(10,a[s.id].x)),r[s.id].y+=Math.max(-10,Math.min(10,a[s.id].y))})}break}}return r}function Oa(o,e){const t={},r={};o.forEach(a=>{t[a.id]=0,r[a.id]=0}),e.forEach(a=>{r[a.target]=(r[a.target]||0)+1});const i=o.filter(a=>r[a.id]===0).map(a=>a.id);for(;i.length>0;){const a=i.shift();e.filter(c=>c.source===a).forEach(c=>{t[c.target]=Math.max(t[c.target],t[a]+1),r[c.target]--,r[c.target]===0&&i.push(c.target)})}return t}function Fa(o,e){const t=o.map(r=>{var i,a,s;switch(e){case"dependencies":return((i=r.metrics)==null?void 0:i.dependencies)||0;case"dependents":return((a=r.metrics)==null?void 0:a.dependents)||0;case"complexity":return((s=r.metrics)==null?void 0:s.complexity)||0;case"size":return r.size||0;default:return 1}});return{min:Math.min(...t,0),max:Math.max(...t,1)}}function La(o,e,t){var l,u,d;if(e==="fixed")return{width:140,height:70};let r;switch(e){case"dependencies":r=((l=o.metrics)==null?void 0:l.dependencies)||0;break;case"dependents":r=((u=o.metrics)==null?void 0:u.dependents)||0;break;case"complexity":r=((d=o.metrics)==null?void 0:d.complexity)||0;break;case"size":r=o.size||0;break;default:r=1}const i=t.max>t.min?(r-t.min)/(t.max-t.min):.5,a=100,c=a+i*(180-a);return{width:c,height:c*.5}}function Wa(o,e,t,r){if(r)return"var(--nice-danger, #ef4444)";if(t!=null&&t[o.id])return t[o.id];switch(e){case"status":return zr[o.status||"unknown"];case"group":return gt[Va(o.group||"")%gt.length];default:return Mr[o.type]||"var(--nice-text-secondary, #6b7280)"}}function Ba(o){switch(o){case"database":return"cylinder";case"microservice":return"hexagon";case"api":return"diamond";case"external":return"cloud";default:return"rectangle"}}function Va(o){let e=0;for(let t=0;t<o.length;t++)e=(e<<5)-e+o.charCodeAt(t),e|=0;return Math.abs(e)}function qa(o){const e=[{id:o.name,name:o.name,version:o.version,type:"package",status:"healthy"}],t=[];let r=0;const i=(a,s)=>{a&&Object.entries(a).forEach(([c,l])=>{e.find(u=>u.id===c)||e.push({id:c,name:c,version:l.replace(/[\^~>=<]/g,""),type:"library",status:"unknown"}),t.push({id:`edge-${r++}`,source:o.name,target:c,type:s})})};return i(o.dependencies,"runtime"),i(o.devDependencies,"dev"),i(o.peerDependencies,"peer"),e.forEach(a=>{a.metrics={dependencies:t.filter(s=>s.source===a.id).length,dependents:t.filter(s=>s.target===a.id).length}}),{nodes:e,edges:t}}function Ga(o){const e=new Map,t=new Map;o.nodes.forEach(d=>{e.set(d.id,0),t.set(d.id,0)}),o.edges.forEach(d=>{e.set(d.target,(e.get(d.target)||0)+1),t.set(d.source,(t.get(d.source)||0)+1)}),Ir(o);let r=null,i=0;o.nodes.forEach(d=>{const b=e.get(d.id)||0;b>i&&(i=b,r=d)});let a=null,s=0;o.nodes.forEach(d=>{const b=t.get(d.id)||0;b>s&&(s=b,a=d)});const c=o.nodes.filter(d=>(e.get(d.id)||0)===0&&(t.get(d.id)||0)===0),l=Array.from(t.values()).reduce((d,b)=>d+b,0),u=o.nodes.length>0?l/o.nodes.length:0;return{totalNodes:o.nodes.length,totalEdges:o.edges.length,circularDependencies:[],mostDependent:r,mostDependencies:a,orphanNodes:c,avgDependencies:Math.round(u*10)/10}}const Ya={online:"var(--nice-success, #10b981)",offline:"var(--nice-text-secondary, #6b7280)",warning:"var(--nice-warning, #f59e0b)",critical:"var(--nice-danger, #ef4444)",maintenance:"var(--nice-primary, #3b82f6)",unknown:"var(--nice-text-muted, #9ca3af)"},Ha={router:"shuffle",switch:"plug",firewall:"lock",server:"server",workstation:"monitor",laptop:"monitor",phone:"phone",printer:"printer",camera:"camera",iot:"wifi",loadbalancer:"scale",storage:"database",cloud:"cloud",internet:"globe",unknown:"help"},Ua={ethernet:"var(--nice-primary, #3b82f6)",fiber:"var(--nice-success, #10b981)",wireless:"var(--nice-accent, #8b5cf6)",vpn:"var(--nice-warning, #f59e0b)",wan:"var(--nice-color-accent-pink, #ec4899)",trunk:"var(--nice-info, #14b8a6)"},Xa=({data:o,onDeviceClick:e,onConnectionClick:t,onRefresh:r,autoRefreshInterval:i=0,visibleDeviceTypes:a,showOnlyIssues:s=!1,layout:c="hierarchical",groupBy:l="group",showMetrics:u=!0,showBandwidth:d=!0,showLatency:b=!1,animateTraffic:x=!1,statusColors:g=Ya,showMinimap:h=!0,className:v,style:_})=>{const{t:w}=Re(),[m,P]=p.useState(null),[k,j]=p.useState(new Date);p.useEffect(()=>{if(i<=0||!r)return;const O=setInterval(()=>{r(),j(new Date)},i);return()=>clearInterval(O)},[i,r]);const C=p.useMemo(()=>{let O=o.devices;return a&&a.length>0&&(O=O.filter(L=>a.includes(L.type))),s&&(O=O.filter(L=>L.status==="critical"||L.status==="warning"||L.status==="offline")),O},[o.devices,a,s]),X=p.useMemo(()=>{const O=new Set(C.map(L=>L.id));return o.connections.filter(L=>O.has(L.source)&&O.has(L.target))},[o.connections,C]),V=p.useMemo(()=>{const O=Ka(C,X,c,o.groups),L=[];if(l!=="none"){const R=new Map;C.forEach(B=>{let K;switch(l){case"type":K=B.type;break;case"location":K=B.location||"Unknown Location";break;default:K=B.group||"ungrouped"}R.has(K)||R.set(K,[]),R.get(K).push(B.id)});let q=0;R.forEach((B,K)=>{var ge;const Z=(ge=o.groups)==null?void 0:ge.find(he=>he.id===K||he.name===K),te=(Z==null?void 0:Z.color)||Jt[q%Jt.length];L.push({id:`group-${K}`,label:(Z==null?void 0:Z.name)||K,nodeIds:B,style:{fill:`${te}15`,stroke:te,strokeWidth:2}}),q++})}const Y=C.map(R=>{const q=O[R.id]||{x:0,y:0},B=m===R.id,K=g[R.status],Z=Ha[R.type];return{id:R.id,label:R.name,x:q.x,y:q.y,width:120,height:u?90:70,shape:Za(R.type),style:{fill:B?K:"var(--nice-bg, #fff)",stroke:K,strokeWidth:B?3:2,fontColor:B?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:8},data:{type:"network-device",device:R,icon:Z,statusColor:K}}}),S=X.map((R,q)=>{const B=Ua[R.type]||"var(--nice-text-secondary, #6b7280)",K=R.status==="active",Z=R.status==="degraded"||R.status==="error",te=[];if(d&&R.bandwidth){const ge=Math.round(R.bandwidth.used/R.bandwidth.total*100);te.push(`${ge}%`)}return b&&R.latency!==void 0&&te.push(`${R.latency}ms`),{id:R.id||`conn-${q}`,source:R.source,target:R.target,sourcePort:R.sourcePort,targetPort:R.targetPort,label:te.join(" | ")||void 0,style:{stroke:Z?"var(--nice-danger, #ef4444)":B,strokeWidth:Math.max(1,Math.min(6,(R.speed||1e3)/1e3)),strokeDasharray:K?void 0:"5,5",arrowHead:"none",lineType:R.type==="wireless"?"curved":"orthogonal",opacity:R.status==="inactive"?.3:1},data:{type:R.type,connection:R,isActive:K,isDegraded:Z}}}),A=x?Ja(X):[];return Ze({id:"network-topology",title:w("networkTopology.networkTopology","Network Topology"),diagramType:"networkTopology",nodes:Y,edges:S,groups:L,animations:A,metadata:{type:"network-topology",lastRefresh:k.toISOString(),...o.metadata}})},[C,X,c,l,o.groups,u,d,b,x,g,m,k,o.metadata,w]),[F,H]=p.useState({x:0,y:0,zoom:1}),I=p.useCallback(O=>{if(!O)return;const L=o.connections.find(Y=>Y.id===O);if(L){t==null||t(L);return}if(P(Y=>Y===O?null:O),e){const Y=o.devices.find(S=>S.id===O);Y&&e(Y)}},[o.devices,o.connections,e,t]);return n.jsx("div",{className:`nice-network-topology ${v||""}`,style:{position:"relative",width:"100%",height:"100%",..._},children:n.jsx(Ee,{nodes:V.nodes,edges:V.edges,groups:V.groups,viewport:F,onViewportChange:H,onSelectElement:I,showGrid:!0})})},Jt=["var(--nice-primary, #3b82f6)","var(--nice-success, #10b981)","var(--nice-warning, #f59e0b)","var(--nice-danger, #ef4444)","var(--nice-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-info, #14b8a6)","var(--nice-info, #6366f1)"];function Ka(o,e,t,r){var a;const i={};switch(t){case"star":{const s=new Map;o.forEach(d=>s.set(d.id,0)),e.forEach(d=>{s.set(d.source,(s.get(d.source)||0)+1),s.set(d.target,(s.get(d.target)||0)+1)});let c=(a=o[0])==null?void 0:a.id,l=0;s.forEach((d,b)=>{d>l&&(l=d,c=b)}),i[c]={x:400,y:300};const u=o.filter(d=>d.id!==c);u.forEach((d,b)=>{const x=b/u.length*2*Math.PI-Math.PI/2,g=200;i[d.id]={x:Math.cos(x)*g+400,y:Math.sin(x)*g+300}});break}case"mesh":{const s=Math.ceil(Math.sqrt(o.length));o.forEach((c,l)=>{i[c.id]={x:l%s*150+100,y:Math.floor(l/s)*130+100}});break}case"tree":{const s=o.filter(x=>x.type==="internet"||x.type==="cloud"||x.type==="router"),c=new Map,l=s.map(x=>x.id);l.forEach(x=>c.set(x,0));const u=new Set(l);for(;l.length>0;){const x=l.shift(),g=c.get(x)||0;e.forEach(h=>{let v=null;h.source===x&&!u.has(h.target)&&(v=h.target),h.target===x&&!u.has(h.source)&&(v=h.source),v&&(u.add(v),c.set(v,g+1),l.push(v))})}const d={},b={};o.forEach(x=>{const g=c.get(x.id)||0;d[g]=(d[g]||0)+1}),o.forEach(x=>{const g=c.get(x.id)||0,h=b[g]||0;b[g]=h+1;const v=d[g],_=(h-(v-1)/2)*160;i[x.id]={x:400+_,y:80+g*120}});break}case"hierarchical":default:{const s=["internet","cloud","router","firewall","loadbalancer","switch","server","storage","workstation","laptop","phone","printer","camera","iot","unknown"],c=new Map;o.forEach(u=>{c.has(u.type)||c.set(u.type,[]),c.get(u.type).push(u)});let l=50;s.forEach(u=>{const d=c.get(u);!d||d.length===0||(d.forEach((b,x)=>{const g=(x-(d.length-1)/2)*150;i[b.id]={x:400+g,y:l}}),l+=130)});break}}return i}function Za(o){switch(o){case"router":case"switch":return"diamond";case"firewall":return"hexagon";case"server":case"storage":return"rectangle";case"cloud":case"internet":return"cloud";default:return"rectangle"}}function Ja(o){return o.filter(e=>e.status==="active"&&e.bandwidth&&e.bandwidth.used>0).map((e,t)=>({id:`traffic-${t}`,type:"flow",targets:[e.id],duration:2e3,delay:t*200}))}async function Qa(o={}){return{devices:[{id:"internet",name:"Internet",type:"internet",status:"online"},{id:"router-1",name:"Edge Router",type:"router",ipAddress:"192.168.1.1",status:"online",metrics:{cpu:45,memory:60,latency:5}},{id:"firewall-1",name:"Firewall",type:"firewall",ipAddress:"192.168.1.2",status:"online",metrics:{cpu:30,memory:55}},{id:"switch-1",name:"Core Switch",type:"switch",ipAddress:"192.168.1.10",status:"online"},{id:"server-1",name:"Web Server",type:"server",ipAddress:"192.168.1.100",status:"online",metrics:{cpu:75,memory:80}},{id:"server-2",name:"Database Server",type:"server",ipAddress:"192.168.1.101",status:"warning",metrics:{cpu:90,memory:85}}],connections:[{id:"c1",source:"internet",target:"router-1",type:"wan",status:"active",speed:1e3},{id:"c2",source:"router-1",target:"firewall-1",type:"ethernet",status:"active",speed:1e4},{id:"c3",source:"firewall-1",target:"switch-1",type:"ethernet",status:"active",speed:1e4},{id:"c4",source:"switch-1",target:"server-1",type:"ethernet",status:"active",speed:1e4},{id:"c5",source:"switch-1",target:"server-2",type:"ethernet",status:"active",speed:1e4}]}}function en(o){const e=o.devices.filter(b=>b.status==="online").length,t=o.devices.filter(b=>b.status==="offline").length,r=o.devices.filter(b=>b.status==="warning").length,i=o.devices.filter(b=>b.status==="critical").length,a=o.connections.filter(b=>b.status==="active").length,s=o.connections.filter(b=>b.status==="degraded"||b.status==="error").length,c=o.devices.length>0?e/o.devices.length*100:0,l=o.connections.length>0?a/o.connections.length*100:0,u=i*10+r*5+s*5;return{score:Math.max(0,Math.min(100,Math.round(c*.5+l*.5-u))),onlineDevices:e,offlineDevices:t,warningDevices:r,criticalDevices:i,activeConnections:a,degradedConnections:s}}const tn=[{target:".nice-decision-tree-editor",titleKey:"tutorial.decisionTreeEditor.intro.title",title:"Decision tree editor",contentKey:"tutorial.decisionTreeEditor.intro.content",content:"Explore the decision tree: click nodes to inspect conditions and outcomes, toggle metrics, probabilities and samples, and highlight a path for an input.",placement:"auto"}],rn={root:"var(--nice-accent, #8b5cf6)",decision:"var(--nice-primary, #3b82f6)",leaf:"var(--nice-success, #10b981)",chance:"var(--nice-warning, #f59e0b)",end:"var(--nice-danger, #ef4444)"},on=({data:o,onChange:e,onNodeClick:t,editable:r=!1,showMetrics:i=!0,showProbabilities:a=!0,showSamples:s=!0,highlightPath:c,colorScheme:l="outcome",nodeColors:u,orientation:d="vertical",spacing:b={horizontal:180,vertical:120},showMinimap:x=!0,className:g,style:h,tutorial:v})=>{const{t:_}=Re(),[w,m]=p.useState(null),[P,k]=p.useState(new Set),j=p.useMemo(()=>c?cn(o.root,c):new Set,[o.root,c]),{nodes:C,edges:X}=p.useMemo(()=>an(o.root,o.edges),[o.root,o.edges]),V=p.useMemo(()=>sn(C),[C]),F=p.useMemo(()=>{var A,R;const L=nn(o.root,d,b),Y=C.map(q=>{const B=L[q.id]||{x:0,y:0},K=w===q.id,Z=j.has(q.id),te=q.type==="leaf"||q.type==="end",ge=ln(q,l,u,V),he=te?120:160,Ce=i?80:te?60:70;return{id:q.id,label:q.label,x:B.x,y:B.y,width:he,height:Ce,shape:te?"roundedRect":"diamond",style:{fill:K||Z?ge:"var(--nice-bg, #fff)",stroke:ge,strokeWidth:Z?4:K?3:2,fontColor:K||Z?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:te?8:0},data:{type:"decision-tree-node",node:q,isLeaf:te,isHighlighted:Z}}}),S=X.map((q,B)=>{const K=j.has(q.source)&&j.has(q.target);let Z=q.label||"";return a&&q.probability!==void 0&&(Z+=Z?` (${(q.probability*100).toFixed(0)}%)`:`${(q.probability*100).toFixed(0)}%`),{id:q.id||`edge-${B}`,source:q.source,target:q.target,label:Z||void 0,style:{stroke:K?"var(--nice-primary, #3b82f6)":"var(--nice-text-muted, #9ca3af)",strokeWidth:K?3:2,arrowHead:"triangle",lineType:d==="vertical"?"orthogonal":"curved"},data:{type:"decision-edge",edge:q,isHighlighted:K}}});return Ze({id:"decision-tree",title:_("decisionTreeEditor.decisionTree","Decision Tree"),diagramType:"decisionTree",nodes:Y,edges:S,animations:c?dn(Array.from(j)):[],metadata:{type:"decision-tree",algorithm:(A=o.metadata)==null?void 0:A.algorithm,accuracy:(R=o.metadata)==null?void 0:R.accuracy}})},[C,X,d,b,i,a,l,u,V,w,j,c,o.metadata,o.root,_]),[H,I]=p.useState({x:0,y:0,zoom:1}),O=p.useCallback(L=>{if(!L)return;m(S=>S===L?null:L);const Y=C.find(S=>S.id===L);Y&&Y.type!=="leaf"&&Y.type!=="end"&&k(S=>{const A=new Set(S);return A.has(L)?A.delete(L):A.add(L),A}),t&&Y&&t(Y)},[C,t]);return n.jsxs("div",{className:`nice-decision-tree-editor ${g||""}`,style:{position:"relative",width:"100%",height:"100%",...h},children:[n.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:n.jsx(y.NiceTutorialButton,{steps:y.resolveTutorial(v,tn)})}),n.jsx(Ee,{nodes:F.nodes,edges:F.edges,groups:F.groups,viewport:H,onViewportChange:I,onSelectElement:O,interactive:!0,showGrid:!1})]})};function an(o,e){const t=[],r=e?[...e]:[],i=new Set(r.map(s=>`${s.source}-${s.target}`)),a=(s,c)=>{t.push(s),c&&!i.has(`${c}-${s.id}`)&&r.push({id:`e-${c}-${s.id}`,source:c,target:s.id}),s.children&&s.children.forEach((l,u)=>{let d="";s.condition&&(d=u===0?"Yes":"No");const b=`${s.id}-${l.id}`;i.has(b)||(r.push({id:`e-${b}`,source:s.id,target:l.id,label:d,branch:u===0?"yes":"no"}),i.add(b)),a(l,s.id)})};return a(o),{nodes:t,edges:r}}function nn(o,e,t){const r={},i=c=>!c.children||c.children.length===0?1:c.children.reduce((l,u)=>l+i(u),0),a=(c,l,u,d)=>{const b=u+d*t.horizontal/2,x=l*t.vertical+50;if(r[c.id]=e==="vertical"?{x:b,y:x}:{x,y:b},c.children){let g=u;c.children.forEach(h=>{const v=i(h);a(h,l+1,g,v),g+=v*t.horizontal})}},s=i(o);return a(o,0,0,s),r}function sn(o){const e=o.filter(r=>{var i;return((i=r.metrics)==null?void 0:i.impurity)!==void 0}).map(r=>r.metrics.impurity),t=o.filter(r=>{var i;return((i=r.metrics)==null?void 0:i.samples)!==void 0}).map(r=>r.metrics.samples);return{impurity:{min:Math.min(...e,0),max:Math.max(...e,1)},samples:{min:Math.min(...t,0),max:Math.max(...t,100)}}}function ln(o,e,t,r){var i,a,s;if(t!=null&&t[o.id])return t[o.id];switch(e){case"impurity":if(((i=o.metrics)==null?void 0:i.impurity)!==void 0&&r){const c=(o.metrics.impurity-r.impurity.min)/(r.impurity.max-r.impurity.min||1);return Qt("var(--nice-success, #10b981)","var(--nice-danger, #ef4444)",c)}break;case"samples":if(((a=o.metrics)==null?void 0:a.samples)!==void 0&&r){const c=(o.metrics.samples-r.samples.min)/(r.samples.max-r.samples.min||1);return Qt("var(--nice-warning-bg, #fef3c7)","var(--nice-warning, #f59e0b)",c)}break;case"outcome":if(o.type==="leaf"&&((s=o.outcome)!=null&&s.class))return{positive:"var(--nice-success, #10b981)",negative:"var(--nice-danger, #ef4444)",true:"var(--nice-success, #10b981)",false:"var(--nice-danger, #ef4444)",yes:"var(--nice-success, #10b981)",no:"var(--nice-danger, #ef4444)"}[o.outcome.class.toLowerCase()]||"var(--nice-primary, #3b82f6)";break}return rn[o.type]||"var(--nice-text-secondary, #6b7280)"}function Qt(o,e,t){const r=u=>{var b;const d=((b=/#([a-f\d]{6})\b/i.exec(u))==null?void 0:b[1])??"000000";return{r:parseInt(d.slice(0,2),16),g:parseInt(d.slice(2,4),16),b:parseInt(d.slice(4,6),16)}},i=r(o),a=r(e),s=Math.round(i.r+(a.r-i.r)*t),c=Math.round(i.g+(a.g-i.g)*t),l=Math.round(i.b+(a.b-i.b)*t);return`#${[s,c,l].map(u=>u.toString(16).padStart(2,"0")).join("")}`}function cn(o,e){const t=new Set,r=i=>{if(t.add(i.id),i.type==="leaf"||i.type==="end"||!i.children)return!0;if(i.condition){const a=e[i.condition.feature],c=jr(a,i.condition.operator,i.condition.value)?0:1;if(i.children[c])return r(i.children[c])}return i.children[0]?r(i.children[0]):!0};return r(o),t}function jr(o,e,t){switch(e){case"=":return o===t;case"!=":return o!==t;case"<":return Number(o)<Number(t);case"<=":return Number(o)<=Number(t);case">":return Number(o)>Number(t);case">=":return Number(o)>=Number(t);case"in":return Array.isArray(t)&&t.includes(o);case"not_in":return Array.isArray(t)&&!t.includes(o);case"contains":return String(o).includes(String(t));default:return!1}}function dn(o){return o.map((e,t)=>({id:`path-${t}`,type:"highlight",targets:[e],duration:500,delay:t*300}))}function un(o){const{tree:e,feature_names:t,class_names:r}=o;e.children_left.length;const i=s=>{const c=e.children_left[s]===-1,l=e.n_node_samples[s],u=e.impurity[s],d=e.value[s];if(c){const _=Array.isArray(d)?d:[d],w=Array.isArray(_[0])?_[0]:_,m=w.indexOf(Math.max(...w)),P=(r==null?void 0:r[m])||`Class ${m}`,k=w.reduce((C,X)=>C+X,0),j=k>0?w[m]/k:0;return{id:`node-${s}`,type:"leaf",label:P,outcome:{value:P,class:P,probability:j,samples:l},metrics:{samples:l,impurity:u}}}const b=e.feature[s],x=e.threshold[s],g=t[b]||`feature_${b}`,h=i(e.children_left[s]),v=i(e.children_right[s]);return{id:`node-${s}`,type:s===0?"root":"decision",label:`${g} <= ${x.toFixed(2)}`,condition:{feature:g,operator:"<=",value:x},children:[h,v],metrics:{samples:l,impurity:u,giniIndex:u}}},a=i(0);return{root:a,features:t,classes:r,metadata:{algorithm:"sklearn.DecisionTreeClassifier",maxDepth:Dr(a)}}}function Dr(o,e=0){return!o.children||o.children.length===0?e:Math.max(...o.children.map(t=>Dr(t,e+1)))}function fn(o){const e=(r,i)=>typeof r=="string"?{id:i,type:"leaf",label:r,outcome:{value:r}}:{...r,id:i};return{root:{id:"root",type:"root",label:o.question,condition:{feature:o.feature,operator:typeof o.threshold=="number"?"<=":"=",value:o.threshold},children:[e(o.yesOutcome,"yes-outcome"),e(o.noOutcome,"no-outcome")]}}}function hn(o,e){const t=[],r=a=>{var s,c;if(t.push(a.id),a.type==="leaf"||a.type==="end"||!a.children)return{value:((s=a.outcome)==null?void 0:s.value)??a.label,probability:(c=a.outcome)==null?void 0:c.probability};if(a.condition){const l=e[a.condition.feature],d=jr(l,a.condition.operator,a.condition.value)?0:1;if(a.children[d])return r(a.children[d])}return a.children[0]?r(a.children[0]):{value:null}},i=r(o.root);return{prediction:i.value,probability:i.probability,path:t}}let mn=0;function Ot(){return`tmpl-${++mn}-${Date.now().toString(36)}`}function ce(o,e,t="roundedRect",r={width:160,height:60},i){return{id:Ot(),label:o,position:e,size:r,shape:t,style:{},ports:[{id:"top",side:"top",offset:.5},{id:"right",side:"right",offset:.5},{id:"bottom",side:"bottom",offset:.5},{id:"left",side:"left",offset:.5}],data:i}}function ue(o,e,t="bottom",r="top",i){return{id:Ot(),sourceNodeId:o.id,sourcePortId:t,targetNodeId:e.id,targetPortId:r,label:i,style:{lineType:"bezier",targetArrow:"arrow"}}}function st(o,e,t,r){const i=new Date().toISOString();return{version:"1.0",id:Ot(),title:o,diagramType:e,nodes:t,edges:r,groups:[],animations:[],viewport:{x:0,y:0,zoom:1},metadata:{createdAt:i,updatedAt:i}}}function gn(){const o=ce("Commit",{x:40,y:200},"circle",{width:80,height:80}),e=ce("Build",{x:200,y:200},"roundedRect"),t=ce("Test",{x:420,y:200},"roundedRect"),r=ce("Deploy",{x:640,y:200},"roundedRect"),i=ce("Production",{x:860,y:200},"hexagon",{width:140,height:80});return st("CI/CD Pipeline","flowchart",[o,e,t,r,i],[ue(o,e,"right","left"),ue(e,t,"right","left"),ue(t,r,"right","left"),ue(r,i,"right","left")])}function pn(){const o=ce("API Gateway",{x:350,y:40},"hexagon",{width:160,height:80}),e=ce("Auth Service",{x:80,y:200},"roundedRect"),t=ce("User Service",{x:300,y:200},"roundedRect"),r=ce("Order Service",{x:520,y:200},"roundedRect"),i=ce("Notification",{x:740,y:200},"roundedRect"),a=ce("Users DB",{x:180,y:380},"cylinder",{width:120,height:70}),s=ce("Orders DB",{x:520,y:380},"cylinder",{width:120,height:70}),c=ce("Message Queue",{x:620,y:380},"parallelogram",{width:160,height:60}),l=[o,e,t,r,i,a,s,c],u=[ue(o,e,"bottom","top"),ue(o,t,"bottom","top"),ue(o,r,"bottom","top"),ue(r,i,"right","left"),ue(t,a,"bottom","top"),ue(r,s,"bottom","top"),ue(i,c,"bottom","top")];return st("Microservices Architecture","flowchart",l,u)}function yn(){const o=ce("Start",{x:350,y:20},"circle",{width:70,height:70}),e=ce("Landing Page",{x:310,y:140},"roundedRect"),t=ce("Sign Up",{x:140,y:280},"roundedRect"),r=ce("Log In",{x:480,y:280},"roundedRect"),i=ce("Dashboard",{x:310,y:420},"roundedRect"),a=ce("End",{x:350,y:560},"circle",{width:70,height:70});return st("User Flow","flowchart",[o,e,t,r,i,a],[ue(o,e,"bottom","top"),ue(e,t,"bottom","top","New user"),ue(e,r,"bottom","top","Returning"),ue(t,i,"bottom","top"),ue(r,i,"bottom","top"),ue(i,a,"bottom","top")])}function bn(){const o=ce("Users",{x:80,y:100},"rectangle",{width:180,height:100}),e=ce("Orders",{x:380,y:100},"rectangle",{width:180,height:100}),t=ce("Products",{x:380,y:320},"rectangle",{width:180,height:100}),r=ce("Categories",{x:680,y:320},"rectangle",{width:180,height:100});return st("Entity Relationship","er",[o,e,t,r],[ue(o,e,"right","left","1:N"),ue(e,t,"bottom","top","N:M"),ue(t,r,"right","left","N:1")])}function wn(){const o=ce("CEO",{x:350,y:40},"roundedRect"),e=ce("CTO",{x:150,y:180},"roundedRect"),t=ce("CFO",{x:550,y:180},"roundedRect"),r=ce("Engineering",{x:50,y:320},"roundedRect"),i=ce("DevOps",{x:250,y:320},"roundedRect"),a=ce("Accounting",{x:550,y:320},"roundedRect");return st("Organization Chart","orgchart",[o,e,t,r,i,a],[ue(o,e,"bottom","top"),ue(o,t,"bottom","top"),ue(e,r,"bottom","top"),ue(e,i,"bottom","top"),ue(t,a,"bottom","top")])}function xn(){const o=ce("Idle",{x:80,y:200},"circle",{width:90,height:90}),e=ce("Loading",{x:300,y:80},"roundedRect"),t=ce("Success",{x:520,y:80},"roundedRect"),r=ce("Error",{x:520,y:320},"roundedRect"),i=ce("Retry",{x:300,y:320},"diamond",{width:100,height:100});return st("State Machine","stateMachine",[o,e,t,r,i],[ue(o,e,"right","left","fetch"),ue(e,t,"right","left","ok"),ue(e,r,"bottom","top","fail"),ue(r,i,"left","right"),ue(i,e,"top","bottom","retry"),ue(i,o,"left","right","cancel")])}const vt=[{id:"cicd-pipeline",name:"CI/CD Pipeline",description:"Continuous integration and deployment pipeline",category:"software",diagramType:"flowchart",tags:["devops","ci","cd","pipeline","deployment"],create:gn},{id:"microservices",name:"Microservices Architecture",description:"Microservices with API gateway, databases, and message queue",category:"software",diagramType:"flowchart",tags:["architecture","microservices","api","backend"],create:pn},{id:"user-flow",name:"User Flow",description:"User journey through signup, login, and dashboard",category:"general",diagramType:"flowchart",tags:["ux","user-flow","journey","wireframe"],create:yn},{id:"er-diagram",name:"Entity Relationship",description:"Database ER diagram with tables and relations",category:"software",diagramType:"er",tags:["database","er","schema","sql"],create:bn},{id:"org-chart",name:"Organization Chart",description:"Company organizational hierarchy",category:"business",diagramType:"orgchart",tags:["org","hierarchy","team","management"],create:wn},{id:"state-machine",name:"State Machine",description:"Finite state machine with transitions",category:"software",diagramType:"stateMachine",tags:["state","fsm","transitions","machine"],create:xn}];function vn(o){return vt.find(e=>e.id===o)}function kn(o){return vt.filter(e=>e.category===o)}function Cn(o){const e=o.toLowerCase();return vt.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.tags.some(r=>r.includes(e)))}class Ar{constructor(e={}){this.versions=[],this.currentVersionIndex=-1,this.autoSaveTimer=null,this.lastDocument=null,this.listeners=new Set,this.config={maxVersions:e.maxVersions??100,autoSaveInterval:e.autoSaveInterval??3e4,compressOldVersions:e.compressOldVersions??!1,userId:e.userId??"",userName:e.userName??"Anonymous"}}startAutoSave(e){this.config.autoSaveInterval<=0||(this.autoSaveTimer=setInterval(()=>{const t=e();this.hasChanges(t)&&this.saveVersion(t,"Auto-save")},this.config.autoSaveInterval))}stopAutoSave(){this.autoSaveTimer&&(clearInterval(this.autoSaveTimer),this.autoSaveTimer=null)}hasChanges(e){return this.lastDocument?JSON.stringify(e)!==JSON.stringify(this.lastDocument):!0}saveVersion(e,t){const r=this.lastDocument?this.calculateChanges(this.lastDocument,e):[{type:"node-added",description:"Initial version"}],i={id:Sn(),number:this.versions.length+1,timestamp:new Date().toISOString(),userId:this.config.userId,userName:this.config.userName,label:t,snapshot:JSON.stringify(e),changes:r};return this.currentVersionIndex<this.versions.length-1&&(this.versions=this.versions.slice(0,this.currentVersionIndex+1)),this.versions.push(i),this.currentVersionIndex=this.versions.length-1,this.lastDocument=JSON.parse(JSON.stringify(e)),this.versions.length>this.config.maxVersions&&(this.versions.shift(),this.currentVersionIndex--),this.notify(),i}getVersions(){return this.versions}getCurrentVersionIndex(){return this.currentVersionIndex}getCurrentVersion(){return this.versions[this.currentVersionIndex]??null}getVersion(e){return this.versions.find(t=>t.id===e)}getDocumentAtVersion(e){const t=this.getVersion(e);return t?JSON.parse(t.snapshot):null}restoreToVersion(e){const t=this.versions.findIndex(i=>i.id===e);if(t===-1)return null;this.currentVersionIndex=t;const r=JSON.parse(this.versions[t].snapshot);return this.lastDocument=JSON.parse(JSON.stringify(r)),this.notify(),r}diff(e,t){const r=this.getVersion(e),i=this.getVersion(t);if(!r||!i)return null;const a=JSON.parse(r.snapshot),s=JSON.parse(i.snapshot),c=this.calculateChanges(a,s),l={nodesAdded:c.filter(u=>u.type==="node-added").length,nodesRemoved:c.filter(u=>u.type==="node-removed").length,nodesMoved:c.filter(u=>u.type==="node-moved").length,nodesRestyled:c.filter(u=>u.type==="node-restyled").length,edgesAdded:c.filter(u=>u.type==="edge-added").length,edgesRemoved:c.filter(u=>u.type==="edge-removed").length,edgesRestyled:c.filter(u=>u.type==="edge-restyled").length,groupsModified:c.filter(u=>u.type.startsWith("group-")).length,totalChanges:c.length};return{fromVersionId:e,toVersionId:t,changes:c,summary:l}}calculateChanges(e,t){const r=[];e.title!==t.title&&r.push({type:"title-changed",elementType:"document",previousValue:e.title,newValue:t.title,description:`Title changed from "${e.title}" to "${t.title}"`});const i=new Set(e.nodes.map(d=>d.id)),a=new Set(t.nodes.map(d=>d.id));for(const d of t.nodes)i.has(d.id)||r.push({type:"node-added",elementId:d.id,elementType:"node",newValue:d,description:`Node "${d.label||d.id}" added`});for(const d of e.nodes)a.has(d.id)||r.push({type:"node-removed",elementId:d.id,elementType:"node",previousValue:d,description:`Node "${d.label||d.id}" removed`});for(const d of t.nodes){const b=e.nodes.find(x=>x.id===d.id);b&&((b.position.x!==d.position.x||b.position.y!==d.position.y)&&r.push({type:"node-moved",elementId:d.id,elementType:"node",previousValue:{x:b.position.x,y:b.position.y},newValue:{x:d.position.x,y:d.position.y},description:`Node "${d.label||d.id}" moved`}),(b.size.width!==d.size.width||b.size.height!==d.size.height)&&r.push({type:"node-resized",elementId:d.id,elementType:"node",previousValue:{width:b.size.width,height:b.size.height},newValue:{width:d.size.width,height:d.size.height},description:`Node "${d.label||d.id}" resized`}),b.label!==d.label&&r.push({type:"node-relabeled",elementId:d.id,elementType:"node",previousValue:b.label,newValue:d.label,description:`Node label changed from "${b.label}" to "${d.label}"`}),JSON.stringify(b.style)!==JSON.stringify(d.style)&&r.push({type:"node-restyled",elementId:d.id,elementType:"node",previousValue:b.style,newValue:d.style,description:`Node "${d.label||d.id}" style changed`}))}const s=new Set(e.edges.map(d=>d.id)),c=new Set(t.edges.map(d=>d.id));for(const d of t.edges)s.has(d.id)||r.push({type:"edge-added",elementId:d.id,elementType:"edge",newValue:d,description:`Edge from "${d.sourceNodeId}" to "${d.targetNodeId}" added`});for(const d of e.edges)c.has(d.id)||r.push({type:"edge-removed",elementId:d.id,elementType:"edge",previousValue:d,description:`Edge from "${d.sourceNodeId}" to "${d.targetNodeId}" removed`});for(const d of t.edges){const b=e.edges.find(x=>x.id===d.id);b&&((b.sourceNodeId!==d.sourceNodeId||b.targetNodeId!==d.targetNodeId)&&r.push({type:"edge-rerouted",elementId:d.id,elementType:"edge",previousValue:{source:b.sourceNodeId,target:b.targetNodeId},newValue:{source:d.sourceNodeId,target:d.targetNodeId},description:"Edge rerouted"}),JSON.stringify(b.style)!==JSON.stringify(d.style)&&r.push({type:"edge-restyled",elementId:d.id,elementType:"edge",previousValue:b.style,newValue:d.style,description:"Edge style changed"}))}const l=new Set(e.groups.map(d=>d.id)),u=new Set(t.groups.map(d=>d.id));for(const d of t.groups)l.has(d.id)||r.push({type:"group-added",elementId:d.id,elementType:"group",newValue:d,description:`Group "${d.label||d.id}" added`});for(const d of e.groups)u.has(d.id)||r.push({type:"group-removed",elementId:d.id,elementType:"group",previousValue:d,description:`Group "${d.label||d.id}" removed`});return(e.viewport.x!==t.viewport.x||e.viewport.y!==t.viewport.y||e.viewport.zoom!==t.viewport.zoom)&&r.push({type:"viewport-changed",elementType:"document",previousValue:e.viewport,newValue:t.viewport,description:"Viewport changed"}),JSON.stringify(e.theme)!==JSON.stringify(t.theme)&&r.push({type:"theme-changed",elementType:"document",previousValue:e.theme,newValue:t.theme,description:"Theme changed"}),r}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.listeners.forEach(e=>e())}exportHistory(){return JSON.stringify({versions:this.versions,currentVersionIndex:this.currentVersionIndex})}importHistory(e){const t=JSON.parse(e);this.versions=t.versions??[],this.currentVersionIndex=t.currentVersionIndex??-1,this.versions.length>0&&this.currentVersionIndex>=0&&(this.lastDocument=JSON.parse(this.versions[this.currentVersionIndex].snapshot)),this.notify()}clearHistory(){this.versions=[],this.currentVersionIndex=-1,this.lastDocument=null,this.notify()}}function Sn(){return`v_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}function Nn(o){const e=new Ar(o);return{manager:e,saveVersion:e.saveVersion.bind(e),getVersions:e.getVersions.bind(e),restoreToVersion:e.restoreToVersion.bind(e),diff:e.diff.bind(e)}}class _n{constructor(e){this.comments=new Map,this.listeners=new Set,this.mentionListeners=new Set,this.config=e}addComment(e,t,r){const i=this.parseMentions(t),a={id:Mn(),anchor:e,status:"open",authorId:this.config.userId,authorName:this.config.userName,authorAvatar:this.config.userAvatar,text:t,mentions:i,replies:[],createdAt:new Date().toISOString(),style:(r==null?void 0:r.style)??this.config.defaultStyle,tags:r==null?void 0:r.tags,priority:r==null?void 0:r.priority};return this.comments.set(a.id,a),this.notify(),i.forEach(s=>this.notifyMention(a,s.userId)),a}updateComment(e,t){const r=this.comments.get(e);return r?(t.text!==void 0&&(r.text=t.text,r.mentions=this.parseMentions(t.text),r.editedAt=new Date().toISOString()),t.style!==void 0&&(r.style=t.style),t.tags!==void 0&&(r.tags=t.tags),t.priority!==void 0&&(r.priority=t.priority),t.anchor!==void 0&&(r.anchor=t.anchor),this.notify(),r):null}deleteComment(e){const t=this.comments.delete(e);return t&&this.notify(),t}resolveComment(e,t="resolved"){const r=this.comments.get(e);return r?(r.status=t,r.resolvedBy=this.config.userId,r.resolvedAt=new Date().toISOString(),this.notify(),r):null}reopenComment(e){const t=this.comments.get(e);return t?(t.status="open",t.resolvedBy=void 0,t.resolvedAt=void 0,this.notify(),t):null}addReply(e,t){const r=this.comments.get(e);if(!r)return null;const i=this.parseMentions(t),a={id:zn(),authorId:this.config.userId,authorName:this.config.userName,authorAvatar:this.config.userAvatar,text:t,mentions:i,createdAt:new Date().toISOString()};return r.replies.push(a),this.notify(),i.forEach(s=>this.notifyMention(r,s.userId)),a}editReply(e,t,r){const i=this.comments.get(e);if(!i)return null;const a=i.replies.find(s=>s.id===t);return a?(a.text=r,a.mentions=this.parseMentions(r),a.editedAt=new Date().toISOString(),this.notify(),a):null}deleteReply(e,t){const r=this.comments.get(e);if(!r)return!1;const i=r.replies.find(a=>a.id===t);return i?(i.deleted=!0,i.text="[deleted]",this.notify(),!0):!1}getComment(e){return this.comments.get(e)}getAllComments(){return Array.from(this.comments.values())}getCommentsForElement(e){return Array.from(this.comments.values()).filter(t=>t.anchor.elementId===e)}getOpenComments(){return Array.from(this.comments.values()).filter(e=>e.status==="open")}getCommentsMentioningUser(e){return Array.from(this.comments.values()).filter(t=>{const r=t.mentions.some(a=>a.userId===e),i=t.replies.some(a=>a.mentions.some(s=>s.userId===e));return r||i})}filterComments(e){return Array.from(this.comments.values()).filter(t=>{if(e.status&&!e.status.includes(t.status)||e.authorId&&t.authorId!==e.authorId||e.priority&&t.priority&&!e.priority.includes(t.priority)||e.tags&&e.tags.length>0&&(!t.tags||!e.tags.some(r=>t.tags.includes(r)))||e.anchorType&&!e.anchorType.includes(t.anchor.type)||e.elementId&&t.anchor.elementId!==e.elementId)return!1;if(e.searchText){const r=e.searchText.toLowerCase();if(![t.text,...t.replies.map(a=>a.text)].join(" ").toLowerCase().includes(r))return!1}return!(e.mentionedUserId&&!(t.mentions.some(i=>i.userId===e.mentionedUserId)||t.replies.some(i=>i.mentions.some(a=>a.userId===e.mentionedUserId))))})}parseMentions(e){var a;const t=[],r=/@(\w+)/g;let i;for(;(i=r.exec(e))!==null;){const s=i[1],c=(a=this.config.availableUsers)==null?void 0:a.find(l=>l.name.toLowerCase()===s.toLowerCase()||l.id===s);c&&t.push({userId:c.id,userName:c.name,startIndex:i.index,endIndex:i.index+i[0].length})}return t}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}onMention(e){return this.mentionListeners.add(e),()=>this.mentionListeners.delete(e)}notify(){this.listeners.forEach(e=>e())}notifyMention(e,t){this.mentionListeners.forEach(r=>r(e,t))}exportComments(){return JSON.stringify(Array.from(this.comments.values()))}importComments(e){const t=JSON.parse(e);this.comments.clear(),t.forEach(r=>this.comments.set(r.id,r)),this.notify()}getCounts(){const e=Array.from(this.comments.values());return{open:e.filter(t=>t.status==="open").length,resolved:e.filter(t=>t.status==="resolved").length,wontfix:e.filter(t=>t.status==="wontfix").length,total:e.length}}updateConfig(e){Object.assign(this.config,e)}}function Mn(){return`comment_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}function zn(){return`reply_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}const In={low:{backgroundColor:"var(--nice-primary-bg, #e3f2fd)",borderColor:"var(--nice-primary, #2196f3)",textColor:"var(--nice-primary-dark, #1565c0)",icon:"info"},medium:{backgroundColor:"var(--nice-warning-bg, #fff3e0)",borderColor:"var(--nice-warning, #ff9800)",textColor:"var(--nice-warning-dark, #e65100)",icon:"warning"},high:{backgroundColor:"var(--nice-danger-bg, #ffebee)",borderColor:"var(--nice-danger, #f44336)",textColor:"var(--nice-danger-dark, #c62828)",icon:"error"},critical:{backgroundColor:"var(--nice-accent-tint-10, #fce4ec)",borderColor:"var(--nice-color-accent-pink, #e91e63)",textColor:"var(--nice-danger-text, #880e4f)",icon:"flame"}};function jn(o){const e=new Date(o),r=new Date().getTime()-e.getTime(),i=Math.floor(r/(1e3*60)),a=Math.floor(i/60),s=Math.floor(a/24);return i<1?"just now":i<60?`${i}m ago`:a<24?`${a}h ago`:s<7?`${s}d ago`:e.toLocaleDateString()}function Dn(o,e){if(e.length===0)return o;const t=[...e].sort((i,a)=>a.startIndex-i.startIndex);let r=o;for(const i of t){const a=r.slice(0,i.startIndex),s=r.slice(i.endIndex);r=`${a}<span class="mention" data-user-id="${i.userId}">@${i.userName}</span>${s}`}return r}class $r{constructor(){this.profiles=new Map,this.activeProfileId=null,this.listeners=new Set,this.cache=new Map,this.profiles.set("default",{id:"default",name:"Default",description:"Default conditional styling profile",rules:[],enabled:!0}),this.activeProfileId="default"}addRule(e,t="default"){const r=this.profiles.get(t);r&&(r.rules=r.rules.filter(i=>i.id!==e.id),r.rules.push(e),r.rules.sort((i,a)=>i.priority-a.priority),this.invalidateCache(),this.notify())}removeRule(e,t="default"){const r=this.profiles.get(t);r&&(r.rules=r.rules.filter(i=>i.id!==e),this.invalidateCache(),this.notify())}updateRule(e,t,r="default"){const i=this.profiles.get(r);if(!i)return;const a=i.rules.find(s=>s.id===e);a&&(Object.assign(a,t),i.rules.sort((s,c)=>s.priority-c.priority),this.invalidateCache(),this.notify())}toggleRule(e,t,r="default"){this.updateRule(e,{enabled:t},r)}addProfile(e){this.profiles.set(e.id,e),this.notify()}removeProfile(e){e!=="default"&&(this.profiles.delete(e),this.activeProfileId===e&&(this.activeProfileId="default"),this.invalidateCache(),this.notify())}setActiveProfile(e){this.profiles.has(e)&&(this.activeProfileId=e,this.invalidateCache(),this.notify())}getProfiles(){return Array.from(this.profiles.values())}getActiveProfile(){return this.activeProfileId?this.profiles.get(this.activeProfileId)??null:null}applyToNode(e){const t=`node_${e.id}_${JSON.stringify(e.data)}`,r=this.cache.get(t);if(r)return r;const i=this.getActiveProfile();if(!(i!=null&&i.enabled))return this.emptyStyles(e.id);const a=i.rules.filter(c=>c.enabled&&(c.target==="node"||c.target==="both")&&(!c.elementShapes||c.elementShapes.includes(e.shape))),s=this.processRules(e.id,a,e);return this.cache.set(t,s),s}applyToEdge(e){const t=`edge_${e.id}_${JSON.stringify(e.data)}`,r=this.cache.get(t);if(r)return r;const i=this.getActiveProfile();if(!(i!=null&&i.enabled))return this.emptyStyles(e.id);const a=i.rules.filter(c=>c.enabled&&(c.target==="edge"||c.target==="both")),s=this.processRules(e.id,a,e);return this.cache.set(t,s),s}applyToAll(e,t){const r=new Map;for(const i of e)r.set(i.id,this.applyToNode(i));for(const i of t)r.set(i.id,this.applyToEdge(i));return r}processRules(e,t,r){const i={elementId:e,matchedRules:[],styleOverrides:{},addedClasses:[]};for(const a of t)if(this.evaluateCondition(a.condition,r)&&(i.matchedRules.push(a.id),this.applyActions(a.actions,i),a.stopProcessing))break;return i}evaluateCondition(e,t){if("logic"in e)return e.logic==="and"?e.conditions.every(i=>this.evaluateCondition(i,t)):e.conditions.some(i=>this.evaluateCondition(i,t));const r=this.getPropertyValue(t,e.property);return this.compareValues(r,e)}getPropertyValue(e,t){const r=t.split(".");let i=e;for(const a of r){if(i==null)return;i=i[a]}return i}compareValues(e,t){const{operator:r,value:i,valueTo:a,caseInsensitive:s}=t;if(r==="is_null")return e==null;if(r==="is_not_null")return e!=null;if(r==="is_empty")return e===""||Array.isArray(e)&&e.length===0;if(r==="is_not_empty")return e!==""&&(!Array.isArray(e)||e.length>0);const c=s&&typeof e=="string"?e.toLowerCase():e,l=s&&typeof i=="string"?i.toLowerCase():i;switch(r){case"equals":return c===l;case"not_equals":return c!==l;case"greater_than":return e>i;case"greater_than_or_equals":return e>=i;case"less_than":return e<i;case"less_than_or_equals":return e<=i;case"contains":return typeof c=="string"&&typeof l=="string"?c.includes(l):Array.isArray(e)?e.includes(i):!1;case"not_contains":return typeof c=="string"&&typeof l=="string"?!c.includes(l):Array.isArray(e)?!e.includes(i):!0;case"starts_with":return typeof c=="string"&&typeof l=="string"&&c.startsWith(l);case"ends_with":return typeof c=="string"&&typeof l=="string"&&c.endsWith(l);case"regex":if(typeof e!="string"||typeof i!="string")return!1;try{const u=s?"i":"";return new RegExp(i,u).test(e)}catch{return!1}case"in":return Array.isArray(i)&&i.includes(e);case"not_in":return!Array.isArray(i)||!i.includes(e);case"between":return e>=i&&e<=a;default:return!1}}applyActions(e,t){for(const r of e)switch(r.type){case"set_fill":t.styleOverrides.backgroundColor=r.value;break;case"set_stroke":t.styleOverrides.borderColor=r.value;break;case"set_stroke_width":t.styleOverrides.borderWidth=r.value;break;case"set_text_color":t.styleOverrides.fontColor=r.value;break;case"set_opacity":t.styleOverrides.opacity=r.value;break;case"set_icon":t.icon=r.value;break;case"set_class":t.addedClasses=[r.value];break;case"add_class":t.addedClasses.includes(r.value)||t.addedClasses.push(r.value);break;case"remove_class":t.addedClasses=t.addedClasses.filter(i=>i!==r.value);break;case"set_shadow":t.styleOverrides.shadow=r.value;break;case"set_border_radius":t.styleOverrides.borderRadius=r.value;break;case"set_dash_array":t.styleOverrides.strokeDash=r.value;break;case"set_animation":t.animation=r.value;break;case"set_badge":t.badge=r.value;break;case"set_tooltip":t.tooltip=r.value;break}}emptyStyles(e){return{elementId:e,matchedRules:[],styleOverrides:{},addedClasses:[]}}invalidateCache(){this.cache.clear()}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.listeners.forEach(e=>e())}exportConfig(){return JSON.stringify({profiles:Array.from(this.profiles.values()),activeProfileId:this.activeProfileId})}importConfig(e){const t=JSON.parse(e);this.profiles.clear();for(const r of t.profiles)this.profiles.set(r.id,r);this.activeProfileId=t.activeProfileId,this.invalidateCache(),this.notify()}}const Ft=[{id:"status-success",name:"Status: Success",description:"Green fill for successful status",enabled:!0,priority:10,target:"node",condition:{property:"data.status",operator:"in",value:["success","completed","done","active","healthy"],caseInsensitive:!0},actions:[{type:"set_fill",value:"var(--nice-success, #4caf50)"},{type:"set_stroke",value:"var(--nice-success-dark, #2e7d32)"},{type:"set_text_color",value:"var(--nice-bg, #fff)"}]},{id:"status-warning",name:"Status: Warning",description:"Orange fill for warning status",enabled:!0,priority:10,target:"node",condition:{property:"data.status",operator:"in",value:["warning","pending","processing","degraded"],caseInsensitive:!0},actions:[{type:"set_fill",value:"var(--nice-warning, #ff9800)"},{type:"set_stroke",value:"var(--nice-warning-dark, #e65100)"},{type:"set_text_color",value:"var(--nice-text, #000000)"}]},{id:"status-error",name:"Status: Error",description:"Red fill for error status",enabled:!0,priority:10,target:"node",condition:{property:"data.status",operator:"in",value:["error","failed","critical","down","unhealthy"],caseInsensitive:!0},actions:[{type:"set_fill",value:"var(--nice-danger, #f44336)"},{type:"set_stroke",value:"var(--nice-danger-dark, #b71c1c)"},{type:"set_text_color",value:"var(--nice-bg, #fff)"},{type:"set_animation",value:"pulse"}]},{id:"high-value",name:"High Value Highlight",description:"Bold border for high-value nodes",enabled:!1,priority:20,target:"node",condition:{property:"data.value",operator:"greater_than",value:1e6},actions:[{type:"set_stroke_width",value:4},{type:"set_stroke",value:"var(--nice-warning, #FFD700)"},{type:"set_badge",value:{text:"$$$",color:"var(--nice-warning, #FFD700)"}}]},{id:"inactive-dim",name:"Dim Inactive",description:"Reduce opacity for inactive elements",enabled:!1,priority:5,target:"both",condition:{property:"data.active",operator:"equals",value:!1},actions:[{type:"set_opacity",value:.5}]}];function An(o){const e=Ft.find(t=>t.id===o);return e?{...e,id:`${e.id}_${Date.now()}`}:null}function $n(o=!1){const e=new $r;if(o)for(const t of Ft)e.addRule(t);return e}class Tn{constructor(){this.nodes=[],this.edges=[],this.groups=[],this.presets=new Map,this.state={query:"",results:[],selectedIndex:-1,filters:[],isActive:!1,totalCount:0},this.listeners=new Set}updateData(e,t,r){this.nodes=e,this.edges=t,this.groups=r,this.state.isActive&&this.state.query&&this.search(this.state.query)}search(e,t={}){const{scope:r="all",matchType:i="contains",caseSensitive:a=!1,searchData:s=!0,dataProperties:c=[],maxResults:l=100,nodeShapes:u=[],groupIds:d=[]}=t;if(!e.trim())return this.state={...this.state,query:"",results:[],selectedIndex:-1,isActive:!1,totalCount:0},this.notify(),[];const b=[],x=a?e:e.toLowerCase();if(r==="all"||r==="nodes"||r==="labels")for(const g of this.nodes){if(b.length>=l)break;if(u.length>0&&!u.includes(g.shape)||d.length>0&&g.groupId&&!d.includes(g.groupId))continue;const h=this.matchElement(g,x,i,a,s,c);h&&b.push({id:g.id,type:"node",label:g.label||g.id,element:g,matchText:h.text,matchProperty:h.property,matchPositions:h.positions,score:h.score})}if(r==="all"||r==="edges"||r==="labels")for(const g of this.edges){if(b.length>=l)break;const h=this.matchElement(g,x,i,a,s,c);h&&b.push({id:g.id,type:"edge",label:g.label||`${g.sourceNodeId} → ${g.targetNodeId}`,element:g,matchText:h.text,matchProperty:h.property,matchPositions:h.positions,score:h.score})}if(r==="all"||r==="groups")for(const g of this.groups){if(b.length>=l)break;if(d.length>0&&!d.includes(g.id))continue;const h=this.matchElement(g,x,i,a,s,c);h&&b.push({id:g.id,type:"group",label:g.label||g.id,element:g,matchText:h.text,matchProperty:h.property,matchPositions:h.positions,score:h.score})}return b.sort((g,h)=>h.score-g.score),this.state={...this.state,query:e,results:b,selectedIndex:b.length>0?0:-1,isActive:!0,totalCount:b.length},this.notify(),b}matchElement(e,t,r,i,a,s){let c=null;const l=(d,b,x,g)=>{(!c||g>c.score)&&(c={text:d,property:b,positions:x,score:g})},u=this.matchText(e.id,t,r,i);if(u&&l(e.id,"id",u.positions,100+u.positions.length*10),"label"in e&&e.label){const d=this.matchText(e.label,t,r,i);d&&l(e.label,"label",d.positions,150+d.positions.length*10)}if("shape"in e&&e.shape){const d=this.matchText(e.shape,t,r,i);d&&l(e.shape,"shape",d.positions,80+d.positions.length*10)}if(a&&"data"in e&&e.data){const d=this.searchInData(e.data,t,r,i,s);for(const b of d)l(b.text,`data.${b.property}`,b.positions,50+b.positions.length*10)}return c}matchText(e,t,r,i){const a=i?e:e.toLowerCase(),s=i?t:t.toLowerCase(),c=[];switch(r){case"exact":a===s&&c.push({start:0,end:e.length});break;case"starts_with":a.startsWith(s)&&c.push({start:0,end:t.length});break;case"ends_with":a.endsWith(s)&&c.push({start:e.length-t.length,end:e.length});break;case"regex":try{const l=i?"g":"gi",u=new RegExp(t,l);let d;for(;(d=u.exec(e))!==null&&(c.push({start:d.index,end:d.index+d[0].length}),!!u.global););}catch{}break;case"contains":default:{let l=0;for(;(l=a.indexOf(s,l))!==-1;)c.push({start:l,end:l+t.length}),l+=t.length;break}}return c.length>0?{positions:c}:null}searchInData(e,t,r,i,a,s=""){const c=[];for(const[l,u]of Object.entries(e)){const d=s?`${s}.${l}`:l;if(!(a.length>0&&!a.some(b=>d.startsWith(b))))if(typeof u=="string"){const b=this.matchText(u,t,r,i);b&&c.push({text:u,property:d,positions:b.positions})}else if(typeof u=="number"||typeof u=="boolean"){const b=String(u),x=this.matchText(b,t,r,i);x&&c.push({text:b,property:d,positions:x.positions})}else u!=null&&typeof u=="object"&&!Array.isArray(u)&&c.push(...this.searchInData(u,t,r,i,a,d))}return c}filter(e){if(this.state.filters=e,e.length===0)return{nodes:this.nodes,edges:this.edges,groups:this.groups};const t=this.nodes.filter(a=>this.matchFilters(a,e)),r=this.edges.filter(a=>this.matchFilters(a,e)),i=this.groups.filter(a=>this.matchFilters(a,e));return this.notify(),{nodes:t,edges:r,groups:i}}matchFilters(e,t){return t.every(r=>this.matchFilter(e,r))}matchFilter(e,t){const r=this.getPropertyValue(e,t.property);switch(t.operator){case"equals":return r===t.value;case"not_equals":return r!==t.value;case"contains":return typeof r=="string"&&typeof t.value=="string"?r.toLowerCase().includes(t.value.toLowerCase()):Array.isArray(r)?r.includes(t.value):!1;case"greater_than":return typeof r=="number"&&r>t.value;case"less_than":return typeof r=="number"&&r<t.value;case"in":return Array.isArray(t.value)&&t.value.includes(r);case"not_in":return!Array.isArray(t.value)||!t.value.includes(r);case"is_null":return r==null;case"is_not_null":return r!=null;default:return!0}}getPropertyValue(e,t){const r=t.split(".");let i=e;for(const a of r){if(i==null)return;i=i[a]}return i}nextResult(){return this.state.results.length===0?null:(this.state.selectedIndex=(this.state.selectedIndex+1)%this.state.results.length,this.notify(),this.state.results[this.state.selectedIndex])}previousResult(){return this.state.results.length===0?null:(this.state.selectedIndex=(this.state.selectedIndex-1+this.state.results.length)%this.state.results.length,this.notify(),this.state.results[this.state.selectedIndex])}selectResult(e){return e<0||e>=this.state.results.length?null:(this.state.selectedIndex=e,this.notify(),this.state.results[e])}getState(){return{...this.state}}getSelectedResult(){return this.state.selectedIndex<0?null:this.state.results[this.state.selectedIndex]??null}clearSearch(){this.state={query:"",results:[],selectedIndex:-1,filters:this.state.filters,isActive:!1,totalCount:0},this.notify()}clearFilters(){this.state.filters=[],this.notify()}clearAll(){this.state={query:"",results:[],selectedIndex:-1,filters:[],isActive:!1,totalCount:0},this.notify()}savePreset(e,t){const r={id:`preset_${Date.now()}`,name:e,description:t,filters:[...this.state.filters],searchQuery:this.state.query||void 0,searchOptions:void 0};return this.presets.set(r.id,r),r}loadPreset(e){const t=this.presets.get(e);t&&(this.state.filters=[...t.filters],t.searchQuery&&this.search(t.searchQuery,t.searchOptions),this.notify())}deletePreset(e){return this.presets.delete(e)}getPresets(){return Array.from(this.presets.values())}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.listeners.forEach(e=>e(this.state))}getUniqueValues(e,t){const r=new Set;if(!t||t==="node")for(const i of this.nodes){const a=this.getPropertyValue(i,e);a!=null&&r.add(a)}if(!t||t==="edge")for(const i of this.edges){const a=this.getPropertyValue(i,e);a!=null&&r.add(a)}if(!t||t==="group")for(const i of this.groups){const a=this.getPropertyValue(i,e);a!=null&&r.add(a)}return Array.from(r)}getNodeShapes(){return[...new Set(this.nodes.map(e=>e.shape))]}getEdgeLineTypes(){return[...new Set(this.edges.filter(e=>{var t;return(t=e.style)==null?void 0:t.lineType}).map(e=>e.style.lineType))]}getGroups(){return this.groups}exportPresets(){return JSON.stringify(Array.from(this.presets.values()))}importPresets(e){JSON.parse(e).forEach(r=>this.presets.set(r.id,r))}}function Pn(o,e,t="search-highlight"){if(e.length===0)return o;const r=[...e].sort((a,s)=>s.start-a.start);let i=o;for(const a of r){const s=i.slice(0,a.start),c=i.slice(a.start,a.end),l=i.slice(a.end);i=`${s}<span class="${t}">${c}</span>${l}`}return i}function En(o,e){switch(o){case"by-type":return{id:`filter_type_${Date.now()}`,property:"type",operator:"equals",value:e};case"by-layer":return{id:`filter_layer_${Date.now()}`,property:"layer",operator:"equals",value:e};case"by-status":return{id:`filter_status_${Date.now()}`,property:"data.status",operator:"equals",value:e};case"custom":default:return{id:`filter_custom_${Date.now()}`,property:"",operator:"equals",value:e}}}exports.AnimationPlayer=gr;exports.AnimationTimeline=bt;exports.COMMENT_PRIORITY_STYLES=In;exports.ConditionalStylingEngine=$r;exports.DIAGRAM_STYLE_PRESETS=yt;exports.DIAGRAM_TEMPLATES=vt;exports.DiagramCanvas=Ee;exports.DiagramCellRenderer=Ki;exports.DiagramCommentManager=_n;exports.DiagramMinimap=lt;exports.DiagramModel=pt;exports.DiagramParticleEngine=er;exports.DiagramPropertyPanel=wt;exports.DiagramSearchFilterEngine=Tn;exports.DiagramToolbar=xt;exports.DiagramVersioningManager=Ar;exports.EDGE_STYLE_CATALOG=ti;exports.NODE_STYLE_CATALOG=ei;exports.NiceAnimationTimeline=bt;exports.NiceDatabaseSchemaViewer=ga;exports.NiceDecisionTreeEditor=on;exports.NiceDependencyGraph=Ea;exports.NiceDiagram=Et;exports.NiceDiagramCanvas=Ee;exports.NiceDiagramEditor=fr;exports.NiceDiagramMinimap=lt;exports.NiceDiagramPropertyPanel=wt;exports.NiceDiagramToolbar=xt;exports.NiceDiagramViewer=Et;exports.NiceI18nProvider=jt;exports.NiceNetworkTopology=Xa;exports.NiceOrgChartVisualizer=Sa;exports.NiceProcessMiningDiagram=Ia;exports.NiceWorkflowDesigner=Nr;exports.NiceWorkflowVisualizer=ca;exports.PRESET_RULES=Ft;exports.TRANSITION_PRESETS=cr;exports.analyzeDependencyGraph=Ga;exports.calculateNetworkHealth=en;exports.calculateOrgStats=za;exports.computeGlowRadius=rr;exports.computeLayout=Dt;exports.convertAnimation=wr;exports.convertEdge=yr;exports.convertGroup=br;exports.convertNode=pr;exports.createConditionalStylingEngine=$n;exports.createDecisionTree=fn;exports.createDiagramDocument=Ze;exports.createGlowFilterId=tr;exports.createLinearWorkflow=fa;exports.createOrgChartFromEmployees=Ma;exports.createPresetFromTheme=ai;exports.createQuickFilter=En;exports.createRuleFromPreset=An;exports.createVersioningHook=Nn;exports.diagramBounds=Tt;exports.discoverNetworkTopology=Qa;exports.exportToMermaid=or;exports.exportToSvg=zt;exports.fetchAndGenerateDiagram=Zi;exports.fitViewport=Pt;exports.formatCommentDate=jn;exports.generateDiagramFromData=kr;exports.getDiagramStylePreset=ri;exports.getDiagramStylePresetsByCategory=oi;exports.getEasing=hr;exports.getPointOnPath=Ur;exports.getTemplateById=vn;exports.getTemplatesByCategory=kn;exports.highlightMatches=Pn;exports.mineProcessFromLog=_r;exports.parseBPMNToWorkflow=ua;exports.parseNddJson=Xr;exports.parsePackageJsonToDependencies=qa;exports.parseSQLToSchema=xa;exports.parseSklearnTree=un;exports.predictWithTree=hn;exports.presetToThemeOverrides=ii;exports.renderTextWithMentions=Dn;exports.schemaToSQL=va;exports.searchTemplates=Cn;exports.stringifyNddJson=nr;exports.useDiagramEditor=lr;exports.useNiceTranslation=Re;
6
+ `)}const ka={active:"var(--nice-success, #10b981)",away:"var(--nice-warning, #f59e0b)",busy:"var(--nice-danger, #ef4444)",offline:"var(--nice-text-secondary, #6b7280)",vacation:"var(--nice-accent, #8b5cf6)",leave:"var(--nice-primary, #3b82f6)"},mt=["var(--nice-primary, #3b82f6)","var(--nice-success, #10b981)","var(--nice-warning, #f59e0b)","var(--nice-danger, #ef4444)","var(--nice-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-info, #14b8a6)","var(--nice-info, #6366f1)"],Ca={employees:[]},Sa=({data:o=Ca,rootEmployeeId:e,onEmployeeClick:t,onDepartmentClick:r,showAvatars:i=!0,showContactInfo:a=!1,groupByDepartment:s=!0,collapsedDepartments:c=[],maxLevels:l=0,orientation:u="vertical",spacing:d={horizontal:200,vertical:150},statusColors:w=ka,showMinimap:x=!0,className:g,style:h})=>{const{t:v}=Re(),[_,b]=p.useState(null),m=p.useMemo(()=>{var R;if(e)return e;const F=o.employees.find(I=>!I.managerId);return(F==null?void 0:F.id)||((R=o.employees[0])==null?void 0:R.id)},[o.employees,e]),A=p.useMemo(()=>Na(o.employees,m),[o.employees,m]),k=p.useMemo(()=>{const F=_a(A,u,d,l),R=[],I={};s&&o.departments&&o.departments.forEach((C,$)=>{const O=C.color||mt[$%mt.length];I[C.id]=O;const G=o.employees.filter(q=>q.department===C.id);G.length!==0&&R.push({id:`dept-${C.id}`,label:C.name,nodeIds:G.map(q=>q.id),style:{fill:`${O}15`,stroke:O,strokeWidth:2},data:{department:C}})});const L=[],W=[],H=(C,$=0)=>{if(l>0&&$>=l||C.employee.department&&c.includes(C.employee.department))return;const O=F[C.employee.id]||{x:0,y:0},G=_===C.employee.id,q=C.employee.status||"active",K=C.employee.department?I[C.employee.department]:"var(--nice-text-secondary, #6b7280)",Z=180,te=a?120:i?90:70;L.push({id:C.employee.id,label:C.employee.name,x:O.x,y:O.y,width:Z,height:te,shape:"rectangle",style:{fill:G?K:"var(--nice-bg, #fff)",stroke:K,strokeWidth:G?3:1,fontColor:G?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:13,borderRadius:12},data:{type:"employee",employee:C.employee,statusColor:w[q],hasChildren:C.children.length>0,childrenCount:C.children.length}}),C.employee.managerId&&W.push({id:`rel-${C.employee.managerId}-${C.employee.id}`,source:C.employee.managerId,target:C.employee.id,style:{stroke:"var(--nice-border, #cbd5e1)",strokeWidth:2,arrowHead:"none",lineType:u==="vertical"?"orthogonal":"curved"}}),C.children.forEach(ge=>H(ge,$+1))};return A&&H(A),Ze({id:"org-chart",title:v("orgChartVisualizer.organizationChart","Organization Chart"),diagramType:"orgchart",nodes:L,edges:W,groups:R,metadata:{type:"org-chart",...o.metadata}})},[o,A,u,d,l,s,c,i,a,w,_,v]),[j,M]=p.useState({x:0,y:0,zoom:1}),X=p.useCallback(F=>{if(F&&(b(R=>R===F?null:F),t)){const R=o.employees.find(I=>I.id===F);R&&t(R)}},[o.employees,t]),V=p.useCallback(F=>{var I;const R=(I=o.departments)==null?void 0:I.find(L=>`dept-${L.id}`===F);R&&(r==null||r(R))},[o.departments,r]);return n.jsx("div",{className:`nice-org-chart-visualizer ${g||""}`,style:{position:"relative",width:"100%",height:"100%",...h},children:n.jsx(Ee,{nodes:k.nodes,edges:k.edges,groups:k.groups,viewport:j,onViewportChange:M,onSelectElement:X,onGroupClick:r?V:void 0,showGrid:!1})})};function Na(o,e){const r=new Map(o.map(a=>[a.id,a])).get(e);if(!r)return null;const i=(a,s)=>{const c=o.filter(l=>l.managerId===a.id);return{employee:a,children:c.map(l=>i(l,s+1)),level:s}};return i(r,0)}function _a(o,e,t,r){const i={};if(!o)return i;const a=(l,u)=>r>0&&u>=r?0:l.children.length===0?1:l.children.reduce((d,w)=>d+a(w,u+1),0),s=(l,u,d,w)=>{if(r>0&&u>=r)return;const x=d+w*t.horizontal/2,g=u*t.vertical+50;i[l.employee.id]=e==="vertical"?{x,y:g}:{x:g,y:x};let h=d;l.children.forEach(v=>{const _=a(v,u+1);s(v,u+1,h,_),h+=_*t.horizontal})},c=a(o,0);return s(o,0,0,c),i}function Ma(o){const t=[...new Set(o.map(r=>r.department).filter(Boolean))].map((r,i)=>({id:r,name:r,color:mt[i%mt.length],headcount:o.filter(a=>a.department===r).length}));return{employees:o,departments:t}}function za(o){var c;const e=new Set(o.employees.map(l=>l.managerId).filter(Boolean)),t=(l,u=new Set)=>{if(u.has(l))return 0;u.add(l);const d=o.employees.find(w=>w.id===l);return d!=null&&d.managerId?1+t(d.managerId,u):1},r=o.employees.map(l=>t(l.id)),i=Math.max(...r,0),a=Array.from(e).map(l=>o.employees.filter(u=>u.managerId===l).length),s=a.length>0?a.reduce((l,u)=>l+u,0)/a.length:0;return{totalEmployees:o.employees.length,departmentCount:((c=o.departments)==null?void 0:c.length)||0,maxDepth:i,averageSpan:Math.round(s*10)/10,managers:e.size}}const Ia=({data:o,onActivityClick:e,onTransitionClick:t,minEdgeFrequency:r=.05,showFrequency:i=!0,showDuration:a=!0,highlightBottlenecks:s=!0,bottleneckThreshold:c=.9,colorScheme:l="frequency",activityColors:u,layout:d="hierarchical",animationSpeed:w=0,showMinimap:x=!0,className:g,style:h})=>{const{t:v}=Re(),[_,b]=p.useState(null),m=p.useMemo(()=>"activities"in o?o:_r(o),[o]),A=p.useMemo(()=>{if(!s)return new Set;const F=m.activities.filter(I=>I.avgDuration!==void 0).map(I=>I.avgDuration);if(F.length===0)return new Set;F.sort((I,L)=>I-L);const R=F[Math.floor(F.length*c)]||0;return new Set(m.activities.filter(I=>(I.avgDuration||0)>=R).map(I=>I.name))},[m.activities,s,c]),k=p.useMemo(()=>{const F=Math.max(...m.activities.map(C=>C.frequency),1),R=ja(m,d),I=m.transitions.filter(C=>C.frequency/m.totalCases>=r),L=m.activities.map(C=>{const $=R[C.name]||{x:0,y:0},O=m.startActivities.includes(C.name),G=m.endActivities.includes(C.name),q=A.has(C.name),K=_===C.name,Z=Aa(C,l,F,u,q);return{id:C.name,label:C.name,x:$.x,y:$.y,width:140,height:60,shape:O?"ellipse":G?"roundedRect":"rectangle",style:{fill:K?Z:"var(--nice-bg, #fff)",stroke:Z,strokeWidth:q?4:K?3:2,fontColor:K?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:12,borderRadius:G?20:8},data:{type:"activity",activity:C,isStart:O,isEnd:G,isBottleneck:q,frequencyPercent:Math.round(C.frequency/m.totalCases*100)}}}),W=I.map(C=>{const $=m.transitions.indexOf(C),O=C.probability||C.frequency/m.totalCases,G=O>.5,q=[];return i&&q.push(`${C.frequency}x`),a&&C.avgDuration&&q.push($a(C.avgDuration)),{id:`trans-${$}`,source:C.from,target:C.to,label:q.join(" | "),style:{stroke:G?"var(--nice-primary, #3b82f6)":"var(--nice-text-muted, #9ca3af)",strokeWidth:Math.max(1,Math.min(6,O*8)),arrowHead:"triangle",lineType:"curved",opacity:Math.max(.3,O)},data:{type:"transition",transition:C,probability:O}}}),H=w>0?Ta(m,w):[];return Ze({id:"process-mining",title:v("processMiningDiagram.processMiningDiagram","Process Mining Diagram"),diagramType:"flowchart",nodes:L,edges:W,animations:H,metadata:{type:"process-mining",totalCases:m.totalCases,avgCaseDuration:m.avgCaseDuration}})},[m,r,i,a,A,l,u,d,w,_,v]),j=p.useCallback(F=>{if(!t)return;const R=parseInt(F.replace("trans-",""),10),I=m.transitions[R];I&&t(I)},[m.transitions,t]),[M,X]=p.useState({x:0,y:0,zoom:1}),V=p.useCallback(F=>{if(F){if(F.startsWith("trans-")){j(F);return}if(b(R=>R===F?null:F),e){const R=m.activities.find(I=>I.name===F);R&&e(R)}}},[m.activities,e,j]);return n.jsx("div",{className:`nice-process-mining-diagram ${g||""}`,style:{position:"relative",width:"100%",height:"100%",...h},children:n.jsx(Ee,{nodes:k.nodes,edges:k.edges,groups:k.groups,viewport:M,onViewportChange:X,onSelectElement:V,showGrid:!0})})};function ja(o,e){const t={};if(e==="circular"){const r=o.activities;r.forEach((i,a)=>{const s=a/r.length*2*Math.PI-Math.PI/2,c=200+r.length*15;t[i.name]={x:Math.cos(s)*c+400,y:Math.sin(s)*c+300}})}else{const r=Da(o),i={};o.activities.forEach(s=>{const c=r[s.name]||0;i[c]=(i[c]||0)+1});const a={};o.activities.forEach(s=>{const c=r[s.name]||0,l=a[c]||0;a[c]=l+1;const u=i[c],d=(l-(u-1)/2)*180;t[s.name]={x:400+d,y:50+c*120}})}return t}function Da(o){const e={},t=new Set,r=o.startActivities.map(i=>({activity:i,level:0}));for(;r.length>0;){const{activity:i,level:a}=r.shift();if(t.has(i))continue;t.add(i),e[i]=a,o.transitions.filter(c=>c.from===i).forEach(c=>{t.has(c.to)||r.push({activity:c.to,level:a+1})})}return o.activities.forEach(i=>{e[i.name]===void 0&&(e[i.name]=0)}),e}function Aa(o,e,t,r,i){if(i)return"var(--nice-danger, #ef4444)";if(r!=null&&r[o.name])return r[o.name];const a=o.frequency/t;switch(e){case"frequency":return Mt("var(--nice-success, #10b981)","var(--nice-primary, #3b82f6)",a);case"duration":return o.avgDuration?Mt("var(--nice-success, #10b981)","var(--nice-warning, #f59e0b)",a):"var(--nice-text-secondary, #6b7280)";case"cost":return o.avgCost?Mt("var(--nice-success, #10b981)","var(--nice-danger, #ef4444)",a):"var(--nice-text-secondary, #6b7280)";default:return"var(--nice-primary, #3b82f6)"}}function Mt(o,e,t){const r=u=>{const d=/#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})\b/i.exec(u);return d?{r:parseInt(d[1],16),g:parseInt(d[2],16),b:parseInt(d[3],16)}:{r:0,g:0,b:0}},i=r(o),a=r(e),s=Math.round(i.r+(a.r-i.r)*t),c=Math.round(i.g+(a.g-i.g)*t),l=Math.round(i.b+(a.b-i.b)*t);return`#${[s,c,l].map(u=>u.toString(16).padStart(2,"0")).join("")}`}function $a(o){return o<1e3?`${o}ms`:o<6e4?`${(o/1e3).toFixed(1)}s`:o<36e5?`${(o/6e4).toFixed(1)}m`:o<864e5?`${(o/36e5).toFixed(1)}h`:`${(o/864e5).toFixed(1)}d`}function Ta(o,e){var r;const t=(r=o.variants)==null?void 0:r[0];return t?t.activities.map((i,a)=>({id:`flow-${a}`,type:"highlight",targets:[i],duration:e,delay:a*e})):[]}function _r(o){const e=o.events.map(g=>({...g,timestamp:g.timestamp instanceof Date?g.timestamp:new Date(g.timestamp)})),t=new Map;e.forEach(g=>{t.has(g.caseId)||t.set(g.caseId,[]),t.get(g.caseId).push(g)}),t.forEach(g=>{g.sort((h,v)=>h.timestamp.getTime()-v.timestamp.getTime())});const r=new Map,i=new Map,a=new Set,s=new Set;t.forEach(g=>{if(g.length!==0){a.add(g[0].activity),s.add(g[g.length-1].activity);for(let h=0;h<g.length;h++){const v=g[h];r.has(v.activity)||r.set(v.activity,{frequency:0,durations:[],resources:new Set,costs:[]});const _=r.get(v.activity);if(_.frequency++,v.resource&&_.resources.add(v.resource),v.cost!==void 0&&_.costs.push(v.cost),h<g.length-1){const b=g[h+1],m=b.timestamp.getTime()-v.timestamp.getTime();_.durations.push(m);const A=`${v.activity}→${b.activity}`;i.has(A)||i.set(A,{frequency:0,durations:[]});const k=i.get(A);k.frequency++,k.durations.push(m)}}}});const c=Array.from(r.entries()).map(([g,h])=>({name:g,frequency:h.frequency,avgDuration:h.durations.length>0?h.durations.reduce((v,_)=>v+_,0)/h.durations.length:void 0,minDuration:h.durations.length>0?Math.min(...h.durations):void 0,maxDuration:h.durations.length>0?Math.max(...h.durations):void 0,resources:Array.from(h.resources),avgCost:h.costs.length>0?h.costs.reduce((v,_)=>v+_,0)/h.costs.length:void 0})),l=Array.from(i.entries()).map(([g,h])=>{const[v,_]=g.split("→");return{from:v,to:_,frequency:h.frequency,avgDuration:h.durations.length>0?h.durations.reduce((b,m)=>b+m,0)/h.durations.length:void 0,probability:h.frequency/t.size}}),u=new Map;t.forEach((g,h)=>{const v=g.map(b=>b.activity).join("→");u.has(v)||u.set(v,{caseIds:[],durations:[]});const _=u.get(v);if(_.caseIds.push(h),g.length>=2){const b=g[g.length-1].timestamp.getTime()-g[0].timestamp.getTime();_.durations.push(b)}});const d=Array.from(u.entries()).map(([g,h])=>({activities:g.split("→"),frequency:h.caseIds.length,avgDuration:h.durations.length>0?h.durations.reduce((v,_)=>v+_,0)/h.durations.length:0,caseIds:h.caseIds})).sort((g,h)=>h.frequency-g.frequency),w=Array.from(t.values()).filter(g=>g.length>=2).map(g=>g[g.length-1].timestamp.getTime()-g[0].timestamp.getTime()),x=w.length>0?w.reduce((g,h)=>g+h,0)/w.length:void 0;return{activities:c,transitions:l,variants:d,startActivities:Array.from(a),endActivities:Array.from(s),totalCases:t.size,avgCaseDuration:x}}const Mr={module:"var(--nice-primary, #3b82f6)",package:"var(--nice-success, #10b981)",microservice:"var(--nice-accent, #8b5cf6)",library:"var(--nice-warning, #f59e0b)",api:"var(--nice-color-accent-pink, #ec4899)",database:"var(--nice-info, #14b8a6)",external:"var(--nice-text-secondary, #6b7280)",deprecated:"var(--nice-danger, #ef4444)"},zr={healthy:"var(--nice-success, #10b981)",warning:"var(--nice-warning, #f59e0b)",critical:"var(--nice-danger, #ef4444)",unknown:"var(--nice-text-secondary, #6b7280)",deprecated:"var(--nice-text-muted, #9ca3af)"},Zt={import:{color:"var(--nice-primary, #3b82f6)"},runtime:{color:"var(--nice-success, #10b981)"},dev:{color:"var(--nice-text-secondary, #6b7280)",dash:"5,5"},peer:{color:"var(--nice-warning, #f59e0b)",dash:"10,5"},"api-call":{color:"var(--nice-accent, #8b5cf6)"},database:{color:"var(--nice-info, #14b8a6)"},event:{color:"var(--nice-color-accent-pink, #ec4899)",dash:"2,2"},circular:{color:"var(--nice-danger, #ef4444)"}},Pa={module:"box",package:"folder",microservice:"square",library:"book",api:"plug",database:"database",external:"globe",deprecated:"warning"},Ea=({data:o,onNodeClick:e,onEdgeClick:t,visibleTypes:r,visibleEdgeTypes:i,highlightCircular:a=!0,showOnlyIssues:s=!1,layout:c="force",groupBy:l="type",nodeSizeBy:u="dependencies",colorScheme:d="type",nodeColors:w,showMetrics:x=!0,interactive:g=!0,showMinimap:h=!0,className:v,style:_})=>{const{t:b}=Re(),[m,A]=p.useState(null),[k,j]=p.useState(null),M=p.useMemo(()=>a?Ir(o):new Set,[o,a]),X=p.useMemo(()=>{let H=o.nodes;return r&&r.length>0&&(H=H.filter(C=>r.includes(C.type))),s&&(H=H.filter(C=>{var $;return C.status==="critical"||C.status==="warning"||(($=C.metrics)==null?void 0:$.issues)&&C.metrics.issues>0})),H},[o.nodes,r,s]),V=p.useMemo(()=>{const H=new Set(X.map($=>$.id));let C=o.edges.filter($=>H.has($.source)&&H.has($.target));return i&&i.length>0&&(C=C.filter($=>i.includes($.type))),C},[o.edges,X,i]),F=p.useMemo(()=>{const H=Ra(X,V,c),C=Fa(X,u),$=[];if(l!=="none"){const q=new Map;X.forEach(Z=>{const te=l==="type"?Z.type:Z.group||"ungrouped";q.has(te)||q.set(te,[]),q.get(te).push(Z.id)});let K=0;q.forEach((Z,te)=>{var he,Ce;const ge=l==="type"?Mr[te]||"var(--nice-text-secondary, #6b7280)":((Ce=(he=o.groups)==null?void 0:he.find(Ae=>Ae.id===te))==null?void 0:Ce.color)||gt[K%gt.length];$.push({id:`group-${te}`,label:te,nodeIds:Z,style:{fill:`${ge}10`,stroke:ge,strokeWidth:1}}),K++})}const O=X.map(q=>{const K=H[q.id]||{x:0,y:0},Z=m===q.id,te=k===q.id,ge=M.has(q.id),he=La(q,u,C),Ce=Wa(q,d,w,ge);return{id:q.id,label:q.name,x:K.x,y:K.y,width:he.width,height:he.height,shape:Ba(q.type),style:{fill:Z||te?Ce:"var(--nice-bg, #fff)",stroke:Ce,strokeWidth:ge?4:Z?3:2,fontColor:Z||te?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:8,strokeDasharray:q.status==="deprecated"?"4,4":void 0},data:{type:"dependency",node:q,icon:Pa[q.type],isCircular:ge,statusColor:zr[q.status||"unknown"]}}}),G=V.map((q,K)=>{const Z=q.type==="circular"||M.has(q.source)&&M.has(q.target),te=Zt[q.type]||Zt.import;return{id:q.id||`edge-${K}`,source:q.source,target:q.target,label:q.optional?b("dependencyGraph.optional","(optional)"):void 0,style:{stroke:Z?"var(--nice-danger, #ef4444)":te.color,strokeWidth:Math.max(1,Math.min(4,q.weight||1)),strokeDasharray:te.dash,arrowHead:"triangle",lineType:"curved",opacity:q.optional?.5:1},data:{type:q.type,edge:q,isCircular:Z}}});return Ze({id:"dependency-graph",title:b("dependencyGraph.dependencyGraph","Dependency Graph"),diagramType:"custom",nodes:O,edges:G,groups:$,metadata:{type:"dependency-graph",...o.metadata}})},[X,V,c,l,o.groups,u,d,w,M,m,k,o.metadata,b]),R=p.useCallback(H=>{j(H)},[]),[I,L]=p.useState({x:0,y:0,zoom:1}),W=p.useCallback(H=>{if(H){if(A(C=>C===H?null:H),e){const C=o.nodes.find($=>$.id===H);C&&e(C)}if(t){const C=o.edges.find($=>$.id===H);C&&t(C)}}},[o.nodes,o.edges,e,t]);return n.jsx("div",{className:`nice-dependency-graph ${v||""}`,style:{position:"relative",width:"100%",height:"100%",..._},children:n.jsx(Ee,{nodes:F.nodes,edges:F.edges,groups:F.groups,viewport:I,onViewportChange:L,onSelectElement:W,onNodeHover:R,interactive:g,showGrid:!0})})},gt=["var(--nice-primary, #3b82f6)","var(--nice-success, #10b981)","var(--nice-warning, #f59e0b)","var(--nice-danger, #ef4444)","var(--nice-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-info, #14b8a6)","var(--nice-info, #6366f1)"];function Ir(o){const e=new Set,t=new Map;o.nodes.forEach(s=>t.set(s.id,[])),o.edges.forEach(s=>{var c;(c=t.get(s.source))==null||c.push(s.target)});const r=new Set,i=new Set,a=(s,c)=>{r.add(s),i.add(s),c.push(s);const l=t.get(s)||[];for(const u of l)if(r.has(u)){if(i.has(u)){const d=c.indexOf(u);c.slice(d).forEach(x=>e.add(x))}}else if(a(u,[...c]))return!0;return i.delete(s),!1};return o.nodes.forEach(s=>{r.has(s.id)||a(s.id,[])}),e}function Ra(o,e,t){const r={};switch(t){case"circular":{o.forEach((i,a)=>{const s=a/o.length*2*Math.PI-Math.PI/2,c=150+o.length*12;r[i.id]={x:Math.cos(s)*c+400,y:Math.sin(s)*c+300}});break}case"grid":{const i=Math.ceil(Math.sqrt(o.length));o.forEach((a,s)=>{r[a.id]={x:s%i*200+100,y:Math.floor(s/i)*150+100}});break}case"hierarchical":{const i=Oa(o,e),a={},s={};o.forEach(c=>{const l=i[c.id]||0;a[l]=(a[l]||0)+1}),o.forEach(c=>{const l=i[c.id]||0,u=s[l]||0;s[l]=u+1;const d=a[l],w=(u-(d-1)/2)*200;r[c.id]={x:400+w,y:80+l*130}});break}default:{o.forEach((i,a)=>{const s=a/o.length*2*Math.PI,c=200+o.length*10;r[i.id]={x:Math.cos(s)*c+400,y:Math.sin(s)*c+300}});for(let i=0;i<50;i++){const a={};o.forEach(s=>a[s.id]={x:0,y:0});for(let s=0;s<o.length;s++)for(let c=s+1;c<o.length;c++){const l=o[s].id,u=o[c].id,d=r[u].x-r[l].x,w=r[u].y-r[l].y,x=Math.max(1,Math.sqrt(d*d+w*w)),g=5e3/(x*x);a[l].x-=d/x*g,a[l].y-=w/x*g,a[u].x+=d/x*g,a[u].y+=w/x*g}e.forEach(s=>{const c=r[s.target].x-r[s.source].x,l=r[s.target].y-r[s.source].y,u=Math.sqrt(c*c+l*l),d=u*.01;a[s.source].x+=c/u*d,a[s.source].y+=l/u*d,a[s.target].x-=c/u*d,a[s.target].y-=l/u*d}),o.forEach(s=>{r[s.id].x+=Math.max(-10,Math.min(10,a[s.id].x)),r[s.id].y+=Math.max(-10,Math.min(10,a[s.id].y))})}break}}return r}function Oa(o,e){const t={},r={};o.forEach(a=>{t[a.id]=0,r[a.id]=0}),e.forEach(a=>{r[a.target]=(r[a.target]||0)+1});const i=o.filter(a=>r[a.id]===0).map(a=>a.id);for(;i.length>0;){const a=i.shift();e.filter(c=>c.source===a).forEach(c=>{t[c.target]=Math.max(t[c.target],t[a]+1),r[c.target]--,r[c.target]===0&&i.push(c.target)})}return t}function Fa(o,e){const t=o.map(r=>{var i,a,s;switch(e){case"dependencies":return((i=r.metrics)==null?void 0:i.dependencies)||0;case"dependents":return((a=r.metrics)==null?void 0:a.dependents)||0;case"complexity":return((s=r.metrics)==null?void 0:s.complexity)||0;case"size":return r.size||0;default:return 1}});return{min:Math.min(...t,0),max:Math.max(...t,1)}}function La(o,e,t){var l,u,d;if(e==="fixed")return{width:140,height:70};let r;switch(e){case"dependencies":r=((l=o.metrics)==null?void 0:l.dependencies)||0;break;case"dependents":r=((u=o.metrics)==null?void 0:u.dependents)||0;break;case"complexity":r=((d=o.metrics)==null?void 0:d.complexity)||0;break;case"size":r=o.size||0;break;default:r=1}const i=t.max>t.min?(r-t.min)/(t.max-t.min):.5,a=100,c=a+i*(180-a);return{width:c,height:c*.5}}function Wa(o,e,t,r){if(r)return"var(--nice-danger, #ef4444)";if(t!=null&&t[o.id])return t[o.id];switch(e){case"status":return zr[o.status||"unknown"];case"group":return gt[Va(o.group||"")%gt.length];default:return Mr[o.type]||"var(--nice-text-secondary, #6b7280)"}}function Ba(o){switch(o){case"database":return"cylinder";case"microservice":return"hexagon";case"api":return"diamond";case"external":return"cloud";default:return"rectangle"}}function Va(o){let e=0;for(let t=0;t<o.length;t++)e=(e<<5)-e+o.charCodeAt(t),e|=0;return Math.abs(e)}function qa(o){const e=[{id:o.name,name:o.name,version:o.version,type:"package",status:"healthy"}],t=[];let r=0;const i=(a,s)=>{a&&Object.entries(a).forEach(([c,l])=>{e.find(u=>u.id===c)||e.push({id:c,name:c,version:l.replace(/[\^~>=<]/g,""),type:"library",status:"unknown"}),t.push({id:`edge-${r++}`,source:o.name,target:c,type:s})})};return i(o.dependencies,"runtime"),i(o.devDependencies,"dev"),i(o.peerDependencies,"peer"),e.forEach(a=>{a.metrics={dependencies:t.filter(s=>s.source===a.id).length,dependents:t.filter(s=>s.target===a.id).length}}),{nodes:e,edges:t}}function Ga(o){const e=new Map,t=new Map;o.nodes.forEach(d=>{e.set(d.id,0),t.set(d.id,0)}),o.edges.forEach(d=>{e.set(d.target,(e.get(d.target)||0)+1),t.set(d.source,(t.get(d.source)||0)+1)}),Ir(o);let r=null,i=0;o.nodes.forEach(d=>{const w=e.get(d.id)||0;w>i&&(i=w,r=d)});let a=null,s=0;o.nodes.forEach(d=>{const w=t.get(d.id)||0;w>s&&(s=w,a=d)});const c=o.nodes.filter(d=>(e.get(d.id)||0)===0&&(t.get(d.id)||0)===0),l=Array.from(t.values()).reduce((d,w)=>d+w,0),u=o.nodes.length>0?l/o.nodes.length:0;return{totalNodes:o.nodes.length,totalEdges:o.edges.length,circularDependencies:[],mostDependent:r,mostDependencies:a,orphanNodes:c,avgDependencies:Math.round(u*10)/10}}const Ya={online:"var(--nice-success, #10b981)",offline:"var(--nice-text-secondary, #6b7280)",warning:"var(--nice-warning, #f59e0b)",critical:"var(--nice-danger, #ef4444)",maintenance:"var(--nice-primary, #3b82f6)",unknown:"var(--nice-text-muted, #9ca3af)"},Ha={router:"shuffle",switch:"plug",firewall:"lock",server:"server",workstation:"monitor",laptop:"monitor",phone:"phone",printer:"printer",camera:"camera",iot:"wifi",loadbalancer:"scale",storage:"database",cloud:"cloud",internet:"globe",unknown:"help"},Ua={ethernet:"var(--nice-primary, #3b82f6)",fiber:"var(--nice-success, #10b981)",wireless:"var(--nice-accent, #8b5cf6)",vpn:"var(--nice-warning, #f59e0b)",wan:"var(--nice-color-accent-pink, #ec4899)",trunk:"var(--nice-info, #14b8a6)"},Xa=({data:o,onDeviceClick:e,onConnectionClick:t,onRefresh:r,autoRefreshInterval:i=0,visibleDeviceTypes:a,showOnlyIssues:s=!1,layout:c="hierarchical",groupBy:l="group",showMetrics:u=!0,showBandwidth:d=!0,showLatency:w=!1,animateTraffic:x=!1,statusColors:g=Ya,showMinimap:h=!0,className:v,style:_})=>{const{t:b}=Re(),[m,A]=p.useState(null),[k,j]=p.useState(new Date);p.useEffect(()=>{if(i<=0||!r)return;const L=setInterval(()=>{r(),j(new Date)},i);return()=>clearInterval(L)},[i,r]);const M=p.useMemo(()=>{let L=o.devices;return a&&a.length>0&&(L=L.filter(W=>a.includes(W.type))),s&&(L=L.filter(W=>W.status==="critical"||W.status==="warning"||W.status==="offline")),L},[o.devices,a,s]),X=p.useMemo(()=>{const L=new Set(M.map(W=>W.id));return o.connections.filter(W=>L.has(W.source)&&L.has(W.target))},[o.connections,M]),V=p.useMemo(()=>{const L=Ka(M,X,c,o.groups),W=[];if(l!=="none"){const O=new Map;M.forEach(q=>{let K;switch(l){case"type":K=q.type;break;case"location":K=q.location||"Unknown Location";break;default:K=q.group||"ungrouped"}O.has(K)||O.set(K,[]),O.get(K).push(q.id)});let G=0;O.forEach((q,K)=>{var ge;const Z=(ge=o.groups)==null?void 0:ge.find(he=>he.id===K||he.name===K),te=(Z==null?void 0:Z.color)||Jt[G%Jt.length];W.push({id:`group-${K}`,label:(Z==null?void 0:Z.name)||K,nodeIds:q,style:{fill:`${te}15`,stroke:te,strokeWidth:2}}),G++})}const H=M.map(O=>{const G=L[O.id]||{x:0,y:0},q=m===O.id,K=g[O.status],Z=Ha[O.type];return{id:O.id,label:O.name,x:G.x,y:G.y,width:120,height:u?90:70,shape:Za(O.type),style:{fill:q?K:"var(--nice-bg, #fff)",stroke:K,strokeWidth:q?3:2,fontColor:q?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:8},data:{type:"network-device",device:O,icon:Z,statusColor:K}}}),C=X.map((O,G)=>{const q=Ua[O.type]||"var(--nice-text-secondary, #6b7280)",K=O.status==="active",Z=O.status==="degraded"||O.status==="error",te=[];if(d&&O.bandwidth){const ge=Math.round(O.bandwidth.used/O.bandwidth.total*100);te.push(`${ge}%`)}return w&&O.latency!==void 0&&te.push(`${O.latency}ms`),{id:O.id||`conn-${G}`,source:O.source,target:O.target,sourcePort:O.sourcePort,targetPort:O.targetPort,label:te.join(" | ")||void 0,style:{stroke:Z?"var(--nice-danger, #ef4444)":q,strokeWidth:Math.max(1,Math.min(6,(O.speed||1e3)/1e3)),strokeDasharray:K?void 0:"5,5",arrowHead:"none",lineType:O.type==="wireless"?"curved":"orthogonal",opacity:O.status==="inactive"?.3:1},data:{type:O.type,connection:O,isActive:K,isDegraded:Z}}}),$=x?Ja(X):[];return Ze({id:"network-topology",title:b("networkTopology.networkTopology","Network Topology"),diagramType:"networkTopology",nodes:H,edges:C,groups:W,animations:$,metadata:{type:"network-topology",lastRefresh:k.toISOString(),...o.metadata}})},[M,X,c,l,o.groups,u,d,w,x,g,m,k,o.metadata,b]),[F,R]=p.useState({x:0,y:0,zoom:1}),I=p.useCallback(L=>{if(!L)return;const W=o.connections.find(H=>H.id===L);if(W){t==null||t(W);return}if(A(H=>H===L?null:L),e){const H=o.devices.find(C=>C.id===L);H&&e(H)}},[o.devices,o.connections,e,t]);return n.jsx("div",{className:`nice-network-topology ${v||""}`,style:{position:"relative",width:"100%",height:"100%",..._},children:n.jsx(Ee,{nodes:V.nodes,edges:V.edges,groups:V.groups,viewport:F,onViewportChange:R,onSelectElement:I,showGrid:!0})})},Jt=["var(--nice-primary, #3b82f6)","var(--nice-success, #10b981)","var(--nice-warning, #f59e0b)","var(--nice-danger, #ef4444)","var(--nice-accent, #8b5cf6)","var(--nice-color-accent-pink, #ec4899)","var(--nice-info, #14b8a6)","var(--nice-info, #6366f1)"];function Ka(o,e,t,r){var a;const i={};switch(t){case"star":{const s=new Map;o.forEach(d=>s.set(d.id,0)),e.forEach(d=>{s.set(d.source,(s.get(d.source)||0)+1),s.set(d.target,(s.get(d.target)||0)+1)});let c=(a=o[0])==null?void 0:a.id,l=0;s.forEach((d,w)=>{d>l&&(l=d,c=w)}),i[c]={x:400,y:300};const u=o.filter(d=>d.id!==c);u.forEach((d,w)=>{const x=w/u.length*2*Math.PI-Math.PI/2,g=200;i[d.id]={x:Math.cos(x)*g+400,y:Math.sin(x)*g+300}});break}case"mesh":{const s=Math.ceil(Math.sqrt(o.length));o.forEach((c,l)=>{i[c.id]={x:l%s*150+100,y:Math.floor(l/s)*130+100}});break}case"tree":{const s=o.filter(x=>x.type==="internet"||x.type==="cloud"||x.type==="router"),c=new Map,l=s.map(x=>x.id);l.forEach(x=>c.set(x,0));const u=new Set(l);for(;l.length>0;){const x=l.shift(),g=c.get(x)||0;e.forEach(h=>{let v=null;h.source===x&&!u.has(h.target)&&(v=h.target),h.target===x&&!u.has(h.source)&&(v=h.source),v&&(u.add(v),c.set(v,g+1),l.push(v))})}const d={},w={};o.forEach(x=>{const g=c.get(x.id)||0;d[g]=(d[g]||0)+1}),o.forEach(x=>{const g=c.get(x.id)||0,h=w[g]||0;w[g]=h+1;const v=d[g],_=(h-(v-1)/2)*160;i[x.id]={x:400+_,y:80+g*120}});break}case"hierarchical":default:{const s=["internet","cloud","router","firewall","loadbalancer","switch","server","storage","workstation","laptop","phone","printer","camera","iot","unknown"],c=new Map;o.forEach(u=>{c.has(u.type)||c.set(u.type,[]),c.get(u.type).push(u)});let l=50;s.forEach(u=>{const d=c.get(u);!d||d.length===0||(d.forEach((w,x)=>{const g=(x-(d.length-1)/2)*150;i[w.id]={x:400+g,y:l}}),l+=130)});break}}return i}function Za(o){switch(o){case"router":case"switch":return"diamond";case"firewall":return"hexagon";case"server":case"storage":return"rectangle";case"cloud":case"internet":return"cloud";default:return"rectangle"}}function Ja(o){return o.filter(e=>e.status==="active"&&e.bandwidth&&e.bandwidth.used>0).map((e,t)=>({id:`traffic-${t}`,type:"flow",targets:[e.id],duration:2e3,delay:t*200}))}async function Qa(o={}){return{devices:[{id:"internet",name:"Internet",type:"internet",status:"online"},{id:"router-1",name:"Edge Router",type:"router",ipAddress:"192.168.1.1",status:"online",metrics:{cpu:45,memory:60,latency:5}},{id:"firewall-1",name:"Firewall",type:"firewall",ipAddress:"192.168.1.2",status:"online",metrics:{cpu:30,memory:55}},{id:"switch-1",name:"Core Switch",type:"switch",ipAddress:"192.168.1.10",status:"online"},{id:"server-1",name:"Web Server",type:"server",ipAddress:"192.168.1.100",status:"online",metrics:{cpu:75,memory:80}},{id:"server-2",name:"Database Server",type:"server",ipAddress:"192.168.1.101",status:"warning",metrics:{cpu:90,memory:85}}],connections:[{id:"c1",source:"internet",target:"router-1",type:"wan",status:"active",speed:1e3},{id:"c2",source:"router-1",target:"firewall-1",type:"ethernet",status:"active",speed:1e4},{id:"c3",source:"firewall-1",target:"switch-1",type:"ethernet",status:"active",speed:1e4},{id:"c4",source:"switch-1",target:"server-1",type:"ethernet",status:"active",speed:1e4},{id:"c5",source:"switch-1",target:"server-2",type:"ethernet",status:"active",speed:1e4}]}}function en(o){const e=o.devices.filter(w=>w.status==="online").length,t=o.devices.filter(w=>w.status==="offline").length,r=o.devices.filter(w=>w.status==="warning").length,i=o.devices.filter(w=>w.status==="critical").length,a=o.connections.filter(w=>w.status==="active").length,s=o.connections.filter(w=>w.status==="degraded"||w.status==="error").length,c=o.devices.length>0?e/o.devices.length*100:0,l=o.connections.length>0?a/o.connections.length*100:0,u=i*10+r*5+s*5;return{score:Math.max(0,Math.min(100,Math.round(c*.5+l*.5-u))),onlineDevices:e,offlineDevices:t,warningDevices:r,criticalDevices:i,activeConnections:a,degradedConnections:s}}const tn=[{target:".nice-decision-tree-editor",titleKey:"tutorial.decisionTreeEditor.intro.title",title:"Decision tree editor",contentKey:"tutorial.decisionTreeEditor.intro.content",content:"Explore the decision tree: click nodes to inspect conditions and outcomes, toggle metrics, probabilities and samples, and highlight a path for an input.",placement:"auto"}],rn={root:"var(--nice-accent, #8b5cf6)",decision:"var(--nice-primary, #3b82f6)",leaf:"var(--nice-success, #10b981)",chance:"var(--nice-warning, #f59e0b)",end:"var(--nice-danger, #ef4444)"},on=({data:o,onChange:e,onNodeClick:t,editable:r=!1,showMetrics:i=!0,showProbabilities:a=!0,showSamples:s=!0,highlightPath:c,colorScheme:l="outcome",nodeColors:u,orientation:d="vertical",spacing:w={horizontal:180,vertical:120},showMinimap:x=!0,className:g,style:h,tutorial:v})=>{const{t:_}=Re(),[b,m]=p.useState(null),[A,k]=p.useState(new Set),j=p.useMemo(()=>c?cn(o.root,c):new Set,[o.root,c]),{nodes:M,edges:X}=p.useMemo(()=>an(o.root,o.edges),[o.root,o.edges]),V=p.useMemo(()=>sn(M),[M]),F=p.useMemo(()=>{var $,O;const W=nn(o.root,d,w),H=M.map(G=>{const q=W[G.id]||{x:0,y:0},K=b===G.id,Z=j.has(G.id),te=G.type==="leaf"||G.type==="end",ge=ln(G,l,u,V),he=te?120:160,Ce=i?80:te?60:70;return{id:G.id,label:G.label,x:q.x,y:q.y,width:he,height:Ce,shape:te?"roundedRect":"diamond",style:{fill:K||Z?ge:"var(--nice-bg, #fff)",stroke:ge,strokeWidth:Z?4:K?3:2,fontColor:K||Z?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:te?8:0},data:{type:"decision-tree-node",node:G,isLeaf:te,isHighlighted:Z}}}),C=X.map((G,q)=>{const K=j.has(G.source)&&j.has(G.target);let Z=G.label||"";return a&&G.probability!==void 0&&(Z+=Z?` (${(G.probability*100).toFixed(0)}%)`:`${(G.probability*100).toFixed(0)}%`),{id:G.id||`edge-${q}`,source:G.source,target:G.target,label:Z||void 0,style:{stroke:K?"var(--nice-primary, #3b82f6)":"var(--nice-text-muted, #9ca3af)",strokeWidth:K?3:2,arrowHead:"triangle",lineType:d==="vertical"?"orthogonal":"curved"},data:{type:"decision-edge",edge:G,isHighlighted:K}}});return Ze({id:"decision-tree",title:_("decisionTreeEditor.decisionTree","Decision Tree"),diagramType:"decisionTree",nodes:H,edges:C,animations:c?dn(Array.from(j)):[],metadata:{type:"decision-tree",algorithm:($=o.metadata)==null?void 0:$.algorithm,accuracy:(O=o.metadata)==null?void 0:O.accuracy}})},[M,X,d,w,i,a,l,u,V,b,j,c,o.metadata,o.root,_]),[R,I]=p.useState({x:0,y:0,zoom:1}),L=p.useCallback(W=>{if(!W)return;m(C=>C===W?null:W);const H=M.find(C=>C.id===W);H&&H.type!=="leaf"&&H.type!=="end"&&k(C=>{const $=new Set(C);return $.has(W)?$.delete(W):$.add(W),$}),t&&H&&t(H)},[M,t]);return n.jsxs("div",{className:`nice-decision-tree-editor ${g||""}`,style:{position:"relative",width:"100%",height:"100%",...h},children:[n.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:n.jsx(y.NiceTutorialButton,{steps:y.resolveTutorial(v,tn)})}),n.jsx(Ee,{nodes:F.nodes,edges:F.edges,groups:F.groups,viewport:R,onViewportChange:I,onSelectElement:L,interactive:!0,showGrid:!1})]})};function an(o,e){const t=[],r=e?[...e]:[],i=new Set(r.map(s=>`${s.source}-${s.target}`)),a=(s,c)=>{t.push(s),c&&!i.has(`${c}-${s.id}`)&&r.push({id:`e-${c}-${s.id}`,source:c,target:s.id}),s.children&&s.children.forEach((l,u)=>{let d="";s.condition&&(d=u===0?"Yes":"No");const w=`${s.id}-${l.id}`;i.has(w)||(r.push({id:`e-${w}`,source:s.id,target:l.id,label:d,branch:u===0?"yes":"no"}),i.add(w)),a(l,s.id)})};return a(o),{nodes:t,edges:r}}function nn(o,e,t){const r={},i=c=>!c.children||c.children.length===0?1:c.children.reduce((l,u)=>l+i(u),0),a=(c,l,u,d)=>{const w=u+d*t.horizontal/2,x=l*t.vertical+50;if(r[c.id]=e==="vertical"?{x:w,y:x}:{x,y:w},c.children){let g=u;c.children.forEach(h=>{const v=i(h);a(h,l+1,g,v),g+=v*t.horizontal})}},s=i(o);return a(o,0,0,s),r}function sn(o){const e=o.filter(r=>{var i;return((i=r.metrics)==null?void 0:i.impurity)!==void 0}).map(r=>r.metrics.impurity),t=o.filter(r=>{var i;return((i=r.metrics)==null?void 0:i.samples)!==void 0}).map(r=>r.metrics.samples);return{impurity:{min:Math.min(...e,0),max:Math.max(...e,1)},samples:{min:Math.min(...t,0),max:Math.max(...t,100)}}}function ln(o,e,t,r){var i,a,s;if(t!=null&&t[o.id])return t[o.id];switch(e){case"impurity":if(((i=o.metrics)==null?void 0:i.impurity)!==void 0&&r){const c=(o.metrics.impurity-r.impurity.min)/(r.impurity.max-r.impurity.min||1);return Qt("var(--nice-success, #10b981)","var(--nice-danger, #ef4444)",c)}break;case"samples":if(((a=o.metrics)==null?void 0:a.samples)!==void 0&&r){const c=(o.metrics.samples-r.samples.min)/(r.samples.max-r.samples.min||1);return Qt("var(--nice-warning-bg, #fef3c7)","var(--nice-warning, #f59e0b)",c)}break;case"outcome":if(o.type==="leaf"&&((s=o.outcome)!=null&&s.class))return{positive:"var(--nice-success, #10b981)",negative:"var(--nice-danger, #ef4444)",true:"var(--nice-success, #10b981)",false:"var(--nice-danger, #ef4444)",yes:"var(--nice-success, #10b981)",no:"var(--nice-danger, #ef4444)"}[o.outcome.class.toLowerCase()]||"var(--nice-primary, #3b82f6)";break}return rn[o.type]||"var(--nice-text-secondary, #6b7280)"}function Qt(o,e,t){const r=u=>{var w;const d=((w=/#([a-f\d]{6})\b/i.exec(u))==null?void 0:w[1])??"000000";return{r:parseInt(d.slice(0,2),16),g:parseInt(d.slice(2,4),16),b:parseInt(d.slice(4,6),16)}},i=r(o),a=r(e),s=Math.round(i.r+(a.r-i.r)*t),c=Math.round(i.g+(a.g-i.g)*t),l=Math.round(i.b+(a.b-i.b)*t);return`#${[s,c,l].map(u=>u.toString(16).padStart(2,"0")).join("")}`}function cn(o,e){const t=new Set,r=i=>{if(t.add(i.id),i.type==="leaf"||i.type==="end"||!i.children)return!0;if(i.condition){const a=e[i.condition.feature],c=jr(a,i.condition.operator,i.condition.value)?0:1;if(i.children[c])return r(i.children[c])}return i.children[0]?r(i.children[0]):!0};return r(o),t}function jr(o,e,t){switch(e){case"=":return o===t;case"!=":return o!==t;case"<":return Number(o)<Number(t);case"<=":return Number(o)<=Number(t);case">":return Number(o)>Number(t);case">=":return Number(o)>=Number(t);case"in":return Array.isArray(t)&&t.includes(o);case"not_in":return Array.isArray(t)&&!t.includes(o);case"contains":return String(o).includes(String(t));default:return!1}}function dn(o){return o.map((e,t)=>({id:`path-${t}`,type:"highlight",targets:[e],duration:500,delay:t*300}))}function un(o){const{tree:e,feature_names:t,class_names:r}=o;e.children_left.length;const i=s=>{const c=e.children_left[s]===-1,l=e.n_node_samples[s],u=e.impurity[s],d=e.value[s];if(c){const _=Array.isArray(d)?d:[d],b=Array.isArray(_[0])?_[0]:_,m=b.indexOf(Math.max(...b)),A=(r==null?void 0:r[m])||`Class ${m}`,k=b.reduce((M,X)=>M+X,0),j=k>0?b[m]/k:0;return{id:`node-${s}`,type:"leaf",label:A,outcome:{value:A,class:A,probability:j,samples:l},metrics:{samples:l,impurity:u}}}const w=e.feature[s],x=e.threshold[s],g=t[w]||`feature_${w}`,h=i(e.children_left[s]),v=i(e.children_right[s]);return{id:`node-${s}`,type:s===0?"root":"decision",label:`${g} <= ${x.toFixed(2)}`,condition:{feature:g,operator:"<=",value:x},children:[h,v],metrics:{samples:l,impurity:u,giniIndex:u}}},a=i(0);return{root:a,features:t,classes:r,metadata:{algorithm:"sklearn.DecisionTreeClassifier",maxDepth:Dr(a)}}}function Dr(o,e=0){return!o.children||o.children.length===0?e:Math.max(...o.children.map(t=>Dr(t,e+1)))}function fn(o){const e=(r,i)=>typeof r=="string"?{id:i,type:"leaf",label:r,outcome:{value:r}}:{...r,id:i};return{root:{id:"root",type:"root",label:o.question,condition:{feature:o.feature,operator:typeof o.threshold=="number"?"<=":"=",value:o.threshold},children:[e(o.yesOutcome,"yes-outcome"),e(o.noOutcome,"no-outcome")]}}}function hn(o,e){const t=[],r=a=>{var s,c;if(t.push(a.id),a.type==="leaf"||a.type==="end"||!a.children)return{value:((s=a.outcome)==null?void 0:s.value)??a.label,probability:(c=a.outcome)==null?void 0:c.probability};if(a.condition){const l=e[a.condition.feature],d=jr(l,a.condition.operator,a.condition.value)?0:1;if(a.children[d])return r(a.children[d])}return a.children[0]?r(a.children[0]):{value:null}},i=r(o.root);return{prediction:i.value,probability:i.probability,path:t}}let mn=0;function Ot(){return`tmpl-${++mn}-${Date.now().toString(36)}`}function ce(o,e,t="roundedRect",r={width:160,height:60},i){return{id:Ot(),label:o,position:e,size:r,shape:t,style:{},ports:[{id:"top",side:"top",offset:.5},{id:"right",side:"right",offset:.5},{id:"bottom",side:"bottom",offset:.5},{id:"left",side:"left",offset:.5}],data:i}}function ue(o,e,t="bottom",r="top",i){return{id:Ot(),sourceNodeId:o.id,sourcePortId:t,targetNodeId:e.id,targetPortId:r,label:i,style:{lineType:"bezier",targetArrow:"arrow"}}}function st(o,e,t,r){const i=new Date().toISOString();return{version:"1.0",id:Ot(),title:o,diagramType:e,nodes:t,edges:r,groups:[],animations:[],viewport:{x:0,y:0,zoom:1},metadata:{createdAt:i,updatedAt:i}}}function gn(){const o=ce("Commit",{x:40,y:200},"circle",{width:80,height:80}),e=ce("Build",{x:200,y:200},"roundedRect"),t=ce("Test",{x:420,y:200},"roundedRect"),r=ce("Deploy",{x:640,y:200},"roundedRect"),i=ce("Production",{x:860,y:200},"hexagon",{width:140,height:80});return st("CI/CD Pipeline","flowchart",[o,e,t,r,i],[ue(o,e,"right","left"),ue(e,t,"right","left"),ue(t,r,"right","left"),ue(r,i,"right","left")])}function pn(){const o=ce("API Gateway",{x:350,y:40},"hexagon",{width:160,height:80}),e=ce("Auth Service",{x:80,y:200},"roundedRect"),t=ce("User Service",{x:300,y:200},"roundedRect"),r=ce("Order Service",{x:520,y:200},"roundedRect"),i=ce("Notification",{x:740,y:200},"roundedRect"),a=ce("Users DB",{x:180,y:380},"cylinder",{width:120,height:70}),s=ce("Orders DB",{x:520,y:380},"cylinder",{width:120,height:70}),c=ce("Message Queue",{x:620,y:380},"parallelogram",{width:160,height:60}),l=[o,e,t,r,i,a,s,c],u=[ue(o,e,"bottom","top"),ue(o,t,"bottom","top"),ue(o,r,"bottom","top"),ue(r,i,"right","left"),ue(t,a,"bottom","top"),ue(r,s,"bottom","top"),ue(i,c,"bottom","top")];return st("Microservices Architecture","flowchart",l,u)}function yn(){const o=ce("Start",{x:350,y:20},"circle",{width:70,height:70}),e=ce("Landing Page",{x:310,y:140},"roundedRect"),t=ce("Sign Up",{x:140,y:280},"roundedRect"),r=ce("Log In",{x:480,y:280},"roundedRect"),i=ce("Dashboard",{x:310,y:420},"roundedRect"),a=ce("End",{x:350,y:560},"circle",{width:70,height:70});return st("User Flow","flowchart",[o,e,t,r,i,a],[ue(o,e,"bottom","top"),ue(e,t,"bottom","top","New user"),ue(e,r,"bottom","top","Returning"),ue(t,i,"bottom","top"),ue(r,i,"bottom","top"),ue(i,a,"bottom","top")])}function bn(){const o=ce("Users",{x:80,y:100},"rectangle",{width:180,height:100}),e=ce("Orders",{x:380,y:100},"rectangle",{width:180,height:100}),t=ce("Products",{x:380,y:320},"rectangle",{width:180,height:100}),r=ce("Categories",{x:680,y:320},"rectangle",{width:180,height:100});return st("Entity Relationship","er",[o,e,t,r],[ue(o,e,"right","left","1:N"),ue(e,t,"bottom","top","N:M"),ue(t,r,"right","left","N:1")])}function wn(){const o=ce("CEO",{x:350,y:40},"roundedRect"),e=ce("CTO",{x:150,y:180},"roundedRect"),t=ce("CFO",{x:550,y:180},"roundedRect"),r=ce("Engineering",{x:50,y:320},"roundedRect"),i=ce("DevOps",{x:250,y:320},"roundedRect"),a=ce("Accounting",{x:550,y:320},"roundedRect");return st("Organization Chart","orgchart",[o,e,t,r,i,a],[ue(o,e,"bottom","top"),ue(o,t,"bottom","top"),ue(e,r,"bottom","top"),ue(e,i,"bottom","top"),ue(t,a,"bottom","top")])}function xn(){const o=ce("Idle",{x:80,y:200},"circle",{width:90,height:90}),e=ce("Loading",{x:300,y:80},"roundedRect"),t=ce("Success",{x:520,y:80},"roundedRect"),r=ce("Error",{x:520,y:320},"roundedRect"),i=ce("Retry",{x:300,y:320},"diamond",{width:100,height:100});return st("State Machine","stateMachine",[o,e,t,r,i],[ue(o,e,"right","left","fetch"),ue(e,t,"right","left","ok"),ue(e,r,"bottom","top","fail"),ue(r,i,"left","right"),ue(i,e,"top","bottom","retry"),ue(i,o,"left","right","cancel")])}const vt=[{id:"cicd-pipeline",name:"CI/CD Pipeline",description:"Continuous integration and deployment pipeline",category:"software",diagramType:"flowchart",tags:["devops","ci","cd","pipeline","deployment"],create:gn},{id:"microservices",name:"Microservices Architecture",description:"Microservices with API gateway, databases, and message queue",category:"software",diagramType:"flowchart",tags:["architecture","microservices","api","backend"],create:pn},{id:"user-flow",name:"User Flow",description:"User journey through signup, login, and dashboard",category:"general",diagramType:"flowchart",tags:["ux","user-flow","journey","wireframe"],create:yn},{id:"er-diagram",name:"Entity Relationship",description:"Database ER diagram with tables and relations",category:"software",diagramType:"er",tags:["database","er","schema","sql"],create:bn},{id:"org-chart",name:"Organization Chart",description:"Company organizational hierarchy",category:"business",diagramType:"orgchart",tags:["org","hierarchy","team","management"],create:wn},{id:"state-machine",name:"State Machine",description:"Finite state machine with transitions",category:"software",diagramType:"stateMachine",tags:["state","fsm","transitions","machine"],create:xn}];function vn(o){return vt.find(e=>e.id===o)}function kn(o){return vt.filter(e=>e.category===o)}function Cn(o){const e=o.toLowerCase();return vt.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.tags.some(r=>r.includes(e)))}class Ar{constructor(e={}){this.versions=[],this.currentVersionIndex=-1,this.autoSaveTimer=null,this.lastDocument=null,this.listeners=new Set,this.config={maxVersions:e.maxVersions??100,autoSaveInterval:e.autoSaveInterval??3e4,compressOldVersions:e.compressOldVersions??!1,userId:e.userId??"",userName:e.userName??"Anonymous"}}startAutoSave(e){this.config.autoSaveInterval<=0||(this.autoSaveTimer=setInterval(()=>{const t=e();this.hasChanges(t)&&this.saveVersion(t,"Auto-save")},this.config.autoSaveInterval))}stopAutoSave(){this.autoSaveTimer&&(clearInterval(this.autoSaveTimer),this.autoSaveTimer=null)}hasChanges(e){return this.lastDocument?JSON.stringify(e)!==JSON.stringify(this.lastDocument):!0}saveVersion(e,t){const r=this.lastDocument?this.calculateChanges(this.lastDocument,e):[{type:"node-added",description:"Initial version"}],i={id:Sn(),number:this.versions.length+1,timestamp:new Date().toISOString(),userId:this.config.userId,userName:this.config.userName,label:t,snapshot:JSON.stringify(e),changes:r};return this.currentVersionIndex<this.versions.length-1&&(this.versions=this.versions.slice(0,this.currentVersionIndex+1)),this.versions.push(i),this.currentVersionIndex=this.versions.length-1,this.lastDocument=JSON.parse(JSON.stringify(e)),this.versions.length>this.config.maxVersions&&(this.versions.shift(),this.currentVersionIndex--),this.notify(),i}getVersions(){return this.versions}getCurrentVersionIndex(){return this.currentVersionIndex}getCurrentVersion(){return this.versions[this.currentVersionIndex]??null}getVersion(e){return this.versions.find(t=>t.id===e)}getDocumentAtVersion(e){const t=this.getVersion(e);return t?JSON.parse(t.snapshot):null}restoreToVersion(e){const t=this.versions.findIndex(i=>i.id===e);if(t===-1)return null;this.currentVersionIndex=t;const r=JSON.parse(this.versions[t].snapshot);return this.lastDocument=JSON.parse(JSON.stringify(r)),this.notify(),r}diff(e,t){const r=this.getVersion(e),i=this.getVersion(t);if(!r||!i)return null;const a=JSON.parse(r.snapshot),s=JSON.parse(i.snapshot),c=this.calculateChanges(a,s),l={nodesAdded:c.filter(u=>u.type==="node-added").length,nodesRemoved:c.filter(u=>u.type==="node-removed").length,nodesMoved:c.filter(u=>u.type==="node-moved").length,nodesRestyled:c.filter(u=>u.type==="node-restyled").length,edgesAdded:c.filter(u=>u.type==="edge-added").length,edgesRemoved:c.filter(u=>u.type==="edge-removed").length,edgesRestyled:c.filter(u=>u.type==="edge-restyled").length,groupsModified:c.filter(u=>u.type.startsWith("group-")).length,totalChanges:c.length};return{fromVersionId:e,toVersionId:t,changes:c,summary:l}}calculateChanges(e,t){const r=[];e.title!==t.title&&r.push({type:"title-changed",elementType:"document",previousValue:e.title,newValue:t.title,description:`Title changed from "${e.title}" to "${t.title}"`});const i=new Set(e.nodes.map(d=>d.id)),a=new Set(t.nodes.map(d=>d.id));for(const d of t.nodes)i.has(d.id)||r.push({type:"node-added",elementId:d.id,elementType:"node",newValue:d,description:`Node "${d.label||d.id}" added`});for(const d of e.nodes)a.has(d.id)||r.push({type:"node-removed",elementId:d.id,elementType:"node",previousValue:d,description:`Node "${d.label||d.id}" removed`});for(const d of t.nodes){const w=e.nodes.find(x=>x.id===d.id);w&&((w.position.x!==d.position.x||w.position.y!==d.position.y)&&r.push({type:"node-moved",elementId:d.id,elementType:"node",previousValue:{x:w.position.x,y:w.position.y},newValue:{x:d.position.x,y:d.position.y},description:`Node "${d.label||d.id}" moved`}),(w.size.width!==d.size.width||w.size.height!==d.size.height)&&r.push({type:"node-resized",elementId:d.id,elementType:"node",previousValue:{width:w.size.width,height:w.size.height},newValue:{width:d.size.width,height:d.size.height},description:`Node "${d.label||d.id}" resized`}),w.label!==d.label&&r.push({type:"node-relabeled",elementId:d.id,elementType:"node",previousValue:w.label,newValue:d.label,description:`Node label changed from "${w.label}" to "${d.label}"`}),JSON.stringify(w.style)!==JSON.stringify(d.style)&&r.push({type:"node-restyled",elementId:d.id,elementType:"node",previousValue:w.style,newValue:d.style,description:`Node "${d.label||d.id}" style changed`}))}const s=new Set(e.edges.map(d=>d.id)),c=new Set(t.edges.map(d=>d.id));for(const d of t.edges)s.has(d.id)||r.push({type:"edge-added",elementId:d.id,elementType:"edge",newValue:d,description:`Edge from "${d.sourceNodeId}" to "${d.targetNodeId}" added`});for(const d of e.edges)c.has(d.id)||r.push({type:"edge-removed",elementId:d.id,elementType:"edge",previousValue:d,description:`Edge from "${d.sourceNodeId}" to "${d.targetNodeId}" removed`});for(const d of t.edges){const w=e.edges.find(x=>x.id===d.id);w&&((w.sourceNodeId!==d.sourceNodeId||w.targetNodeId!==d.targetNodeId)&&r.push({type:"edge-rerouted",elementId:d.id,elementType:"edge",previousValue:{source:w.sourceNodeId,target:w.targetNodeId},newValue:{source:d.sourceNodeId,target:d.targetNodeId},description:"Edge rerouted"}),JSON.stringify(w.style)!==JSON.stringify(d.style)&&r.push({type:"edge-restyled",elementId:d.id,elementType:"edge",previousValue:w.style,newValue:d.style,description:"Edge style changed"}))}const l=new Set(e.groups.map(d=>d.id)),u=new Set(t.groups.map(d=>d.id));for(const d of t.groups)l.has(d.id)||r.push({type:"group-added",elementId:d.id,elementType:"group",newValue:d,description:`Group "${d.label||d.id}" added`});for(const d of e.groups)u.has(d.id)||r.push({type:"group-removed",elementId:d.id,elementType:"group",previousValue:d,description:`Group "${d.label||d.id}" removed`});return(e.viewport.x!==t.viewport.x||e.viewport.y!==t.viewport.y||e.viewport.zoom!==t.viewport.zoom)&&r.push({type:"viewport-changed",elementType:"document",previousValue:e.viewport,newValue:t.viewport,description:"Viewport changed"}),JSON.stringify(e.theme)!==JSON.stringify(t.theme)&&r.push({type:"theme-changed",elementType:"document",previousValue:e.theme,newValue:t.theme,description:"Theme changed"}),r}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.listeners.forEach(e=>e())}exportHistory(){return JSON.stringify({versions:this.versions,currentVersionIndex:this.currentVersionIndex})}importHistory(e){const t=JSON.parse(e);this.versions=t.versions??[],this.currentVersionIndex=t.currentVersionIndex??-1,this.versions.length>0&&this.currentVersionIndex>=0&&(this.lastDocument=JSON.parse(this.versions[this.currentVersionIndex].snapshot)),this.notify()}clearHistory(){this.versions=[],this.currentVersionIndex=-1,this.lastDocument=null,this.notify()}}function Sn(){return`v_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}function Nn(o){const e=new Ar(o);return{manager:e,saveVersion:e.saveVersion.bind(e),getVersions:e.getVersions.bind(e),restoreToVersion:e.restoreToVersion.bind(e),diff:e.diff.bind(e)}}class _n{constructor(e){this.comments=new Map,this.listeners=new Set,this.mentionListeners=new Set,this.config=e}addComment(e,t,r){const i=this.parseMentions(t),a={id:Mn(),anchor:e,status:"open",authorId:this.config.userId,authorName:this.config.userName,authorAvatar:this.config.userAvatar,text:t,mentions:i,replies:[],createdAt:new Date().toISOString(),style:(r==null?void 0:r.style)??this.config.defaultStyle,tags:r==null?void 0:r.tags,priority:r==null?void 0:r.priority};return this.comments.set(a.id,a),this.notify(),i.forEach(s=>this.notifyMention(a,s.userId)),a}updateComment(e,t){const r=this.comments.get(e);return r?(t.text!==void 0&&(r.text=t.text,r.mentions=this.parseMentions(t.text),r.editedAt=new Date().toISOString()),t.style!==void 0&&(r.style=t.style),t.tags!==void 0&&(r.tags=t.tags),t.priority!==void 0&&(r.priority=t.priority),t.anchor!==void 0&&(r.anchor=t.anchor),this.notify(),r):null}deleteComment(e){const t=this.comments.delete(e);return t&&this.notify(),t}resolveComment(e,t="resolved"){const r=this.comments.get(e);return r?(r.status=t,r.resolvedBy=this.config.userId,r.resolvedAt=new Date().toISOString(),this.notify(),r):null}reopenComment(e){const t=this.comments.get(e);return t?(t.status="open",t.resolvedBy=void 0,t.resolvedAt=void 0,this.notify(),t):null}addReply(e,t){const r=this.comments.get(e);if(!r)return null;const i=this.parseMentions(t),a={id:zn(),authorId:this.config.userId,authorName:this.config.userName,authorAvatar:this.config.userAvatar,text:t,mentions:i,createdAt:new Date().toISOString()};return r.replies.push(a),this.notify(),i.forEach(s=>this.notifyMention(r,s.userId)),a}editReply(e,t,r){const i=this.comments.get(e);if(!i)return null;const a=i.replies.find(s=>s.id===t);return a?(a.text=r,a.mentions=this.parseMentions(r),a.editedAt=new Date().toISOString(),this.notify(),a):null}deleteReply(e,t){const r=this.comments.get(e);if(!r)return!1;const i=r.replies.find(a=>a.id===t);return i?(i.deleted=!0,i.text="[deleted]",this.notify(),!0):!1}getComment(e){return this.comments.get(e)}getAllComments(){return Array.from(this.comments.values())}getCommentsForElement(e){return Array.from(this.comments.values()).filter(t=>t.anchor.elementId===e)}getOpenComments(){return Array.from(this.comments.values()).filter(e=>e.status==="open")}getCommentsMentioningUser(e){return Array.from(this.comments.values()).filter(t=>{const r=t.mentions.some(a=>a.userId===e),i=t.replies.some(a=>a.mentions.some(s=>s.userId===e));return r||i})}filterComments(e){return Array.from(this.comments.values()).filter(t=>{if(e.status&&!e.status.includes(t.status)||e.authorId&&t.authorId!==e.authorId||e.priority&&t.priority&&!e.priority.includes(t.priority)||e.tags&&e.tags.length>0&&(!t.tags||!e.tags.some(r=>t.tags.includes(r)))||e.anchorType&&!e.anchorType.includes(t.anchor.type)||e.elementId&&t.anchor.elementId!==e.elementId)return!1;if(e.searchText){const r=e.searchText.toLowerCase();if(![t.text,...t.replies.map(a=>a.text)].join(" ").toLowerCase().includes(r))return!1}return!(e.mentionedUserId&&!(t.mentions.some(i=>i.userId===e.mentionedUserId)||t.replies.some(i=>i.mentions.some(a=>a.userId===e.mentionedUserId))))})}parseMentions(e){var a;const t=[],r=/@(\w+)/g;let i;for(;(i=r.exec(e))!==null;){const s=i[1],c=(a=this.config.availableUsers)==null?void 0:a.find(l=>l.name.toLowerCase()===s.toLowerCase()||l.id===s);c&&t.push({userId:c.id,userName:c.name,startIndex:i.index,endIndex:i.index+i[0].length})}return t}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}onMention(e){return this.mentionListeners.add(e),()=>this.mentionListeners.delete(e)}notify(){this.listeners.forEach(e=>e())}notifyMention(e,t){this.mentionListeners.forEach(r=>r(e,t))}exportComments(){return JSON.stringify(Array.from(this.comments.values()))}importComments(e){const t=JSON.parse(e);this.comments.clear(),t.forEach(r=>this.comments.set(r.id,r)),this.notify()}getCounts(){const e=Array.from(this.comments.values());return{open:e.filter(t=>t.status==="open").length,resolved:e.filter(t=>t.status==="resolved").length,wontfix:e.filter(t=>t.status==="wontfix").length,total:e.length}}updateConfig(e){Object.assign(this.config,e)}}function Mn(){return`comment_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}function zn(){return`reply_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}const In={low:{backgroundColor:"var(--nice-primary-bg, #e3f2fd)",borderColor:"var(--nice-primary, #2196f3)",textColor:"var(--nice-primary-dark, #1565c0)",icon:"info"},medium:{backgroundColor:"var(--nice-warning-bg, #fff3e0)",borderColor:"var(--nice-warning, #ff9800)",textColor:"var(--nice-warning-dark, #e65100)",icon:"warning"},high:{backgroundColor:"var(--nice-danger-bg, #ffebee)",borderColor:"var(--nice-danger, #f44336)",textColor:"var(--nice-danger-dark, #c62828)",icon:"error"},critical:{backgroundColor:"var(--nice-accent-tint-10, #fce4ec)",borderColor:"var(--nice-color-accent-pink, #e91e63)",textColor:"var(--nice-danger-text, #880e4f)",icon:"flame"}};function jn(o){const e=new Date(o),r=new Date().getTime()-e.getTime(),i=Math.floor(r/(1e3*60)),a=Math.floor(i/60),s=Math.floor(a/24);return i<1?"just now":i<60?`${i}m ago`:a<24?`${a}h ago`:s<7?`${s}d ago`:e.toLocaleDateString()}function Dn(o,e){if(e.length===0)return o;const t=[...e].sort((i,a)=>a.startIndex-i.startIndex);let r=o;for(const i of t){const a=r.slice(0,i.startIndex),s=r.slice(i.endIndex);r=`${a}<span class="mention" data-user-id="${i.userId}">@${i.userName}</span>${s}`}return r}class $r{constructor(){this.profiles=new Map,this.activeProfileId=null,this.listeners=new Set,this.cache=new Map,this.profiles.set("default",{id:"default",name:"Default",description:"Default conditional styling profile",rules:[],enabled:!0}),this.activeProfileId="default"}addRule(e,t="default"){const r=this.profiles.get(t);r&&(r.rules=r.rules.filter(i=>i.id!==e.id),r.rules.push(e),r.rules.sort((i,a)=>i.priority-a.priority),this.invalidateCache(),this.notify())}removeRule(e,t="default"){const r=this.profiles.get(t);r&&(r.rules=r.rules.filter(i=>i.id!==e),this.invalidateCache(),this.notify())}updateRule(e,t,r="default"){const i=this.profiles.get(r);if(!i)return;const a=i.rules.find(s=>s.id===e);a&&(Object.assign(a,t),i.rules.sort((s,c)=>s.priority-c.priority),this.invalidateCache(),this.notify())}toggleRule(e,t,r="default"){this.updateRule(e,{enabled:t},r)}addProfile(e){this.profiles.set(e.id,e),this.notify()}removeProfile(e){e!=="default"&&(this.profiles.delete(e),this.activeProfileId===e&&(this.activeProfileId="default"),this.invalidateCache(),this.notify())}setActiveProfile(e){this.profiles.has(e)&&(this.activeProfileId=e,this.invalidateCache(),this.notify())}getProfiles(){return Array.from(this.profiles.values())}getActiveProfile(){return this.activeProfileId?this.profiles.get(this.activeProfileId)??null:null}applyToNode(e){const t=`node_${e.id}_${JSON.stringify(e.data)}`,r=this.cache.get(t);if(r)return r;const i=this.getActiveProfile();if(!(i!=null&&i.enabled))return this.emptyStyles(e.id);const a=i.rules.filter(c=>c.enabled&&(c.target==="node"||c.target==="both")&&(!c.elementShapes||c.elementShapes.includes(e.shape))),s=this.processRules(e.id,a,e);return this.cache.set(t,s),s}applyToEdge(e){const t=`edge_${e.id}_${JSON.stringify(e.data)}`,r=this.cache.get(t);if(r)return r;const i=this.getActiveProfile();if(!(i!=null&&i.enabled))return this.emptyStyles(e.id);const a=i.rules.filter(c=>c.enabled&&(c.target==="edge"||c.target==="both")),s=this.processRules(e.id,a,e);return this.cache.set(t,s),s}applyToAll(e,t){const r=new Map;for(const i of e)r.set(i.id,this.applyToNode(i));for(const i of t)r.set(i.id,this.applyToEdge(i));return r}processRules(e,t,r){const i={elementId:e,matchedRules:[],styleOverrides:{},addedClasses:[]};for(const a of t)if(this.evaluateCondition(a.condition,r)&&(i.matchedRules.push(a.id),this.applyActions(a.actions,i),a.stopProcessing))break;return i}evaluateCondition(e,t){if("logic"in e)return e.logic==="and"?e.conditions.every(i=>this.evaluateCondition(i,t)):e.conditions.some(i=>this.evaluateCondition(i,t));const r=this.getPropertyValue(t,e.property);return this.compareValues(r,e)}getPropertyValue(e,t){const r=t.split(".");let i=e;for(const a of r){if(i==null)return;i=i[a]}return i}compareValues(e,t){const{operator:r,value:i,valueTo:a,caseInsensitive:s}=t;if(r==="is_null")return e==null;if(r==="is_not_null")return e!=null;if(r==="is_empty")return e===""||Array.isArray(e)&&e.length===0;if(r==="is_not_empty")return e!==""&&(!Array.isArray(e)||e.length>0);const c=s&&typeof e=="string"?e.toLowerCase():e,l=s&&typeof i=="string"?i.toLowerCase():i;switch(r){case"equals":return c===l;case"not_equals":return c!==l;case"greater_than":return e>i;case"greater_than_or_equals":return e>=i;case"less_than":return e<i;case"less_than_or_equals":return e<=i;case"contains":return typeof c=="string"&&typeof l=="string"?c.includes(l):Array.isArray(e)?e.includes(i):!1;case"not_contains":return typeof c=="string"&&typeof l=="string"?!c.includes(l):Array.isArray(e)?!e.includes(i):!0;case"starts_with":return typeof c=="string"&&typeof l=="string"&&c.startsWith(l);case"ends_with":return typeof c=="string"&&typeof l=="string"&&c.endsWith(l);case"regex":if(typeof e!="string"||typeof i!="string")return!1;try{const u=s?"i":"";return new RegExp(i,u).test(e)}catch{return!1}case"in":return Array.isArray(i)&&i.includes(e);case"not_in":return!Array.isArray(i)||!i.includes(e);case"between":return e>=i&&e<=a;default:return!1}}applyActions(e,t){for(const r of e)switch(r.type){case"set_fill":t.styleOverrides.backgroundColor=r.value;break;case"set_stroke":t.styleOverrides.borderColor=r.value;break;case"set_stroke_width":t.styleOverrides.borderWidth=r.value;break;case"set_text_color":t.styleOverrides.fontColor=r.value;break;case"set_opacity":t.styleOverrides.opacity=r.value;break;case"set_icon":t.icon=r.value;break;case"set_class":t.addedClasses=[r.value];break;case"add_class":t.addedClasses.includes(r.value)||t.addedClasses.push(r.value);break;case"remove_class":t.addedClasses=t.addedClasses.filter(i=>i!==r.value);break;case"set_shadow":t.styleOverrides.shadow=r.value;break;case"set_border_radius":t.styleOverrides.borderRadius=r.value;break;case"set_dash_array":t.styleOverrides.strokeDash=r.value;break;case"set_animation":t.animation=r.value;break;case"set_badge":t.badge=r.value;break;case"set_tooltip":t.tooltip=r.value;break}}emptyStyles(e){return{elementId:e,matchedRules:[],styleOverrides:{},addedClasses:[]}}invalidateCache(){this.cache.clear()}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.listeners.forEach(e=>e())}exportConfig(){return JSON.stringify({profiles:Array.from(this.profiles.values()),activeProfileId:this.activeProfileId})}importConfig(e){const t=JSON.parse(e);this.profiles.clear();for(const r of t.profiles)this.profiles.set(r.id,r);this.activeProfileId=t.activeProfileId,this.invalidateCache(),this.notify()}}const Ft=[{id:"status-success",name:"Status: Success",description:"Green fill for successful status",enabled:!0,priority:10,target:"node",condition:{property:"data.status",operator:"in",value:["success","completed","done","active","healthy"],caseInsensitive:!0},actions:[{type:"set_fill",value:"var(--nice-success, #4caf50)"},{type:"set_stroke",value:"var(--nice-success-dark, #2e7d32)"},{type:"set_text_color",value:"var(--nice-bg, #fff)"}]},{id:"status-warning",name:"Status: Warning",description:"Orange fill for warning status",enabled:!0,priority:10,target:"node",condition:{property:"data.status",operator:"in",value:["warning","pending","processing","degraded"],caseInsensitive:!0},actions:[{type:"set_fill",value:"var(--nice-warning, #ff9800)"},{type:"set_stroke",value:"var(--nice-warning-dark, #e65100)"},{type:"set_text_color",value:"var(--nice-text, #000000)"}]},{id:"status-error",name:"Status: Error",description:"Red fill for error status",enabled:!0,priority:10,target:"node",condition:{property:"data.status",operator:"in",value:["error","failed","critical","down","unhealthy"],caseInsensitive:!0},actions:[{type:"set_fill",value:"var(--nice-danger, #f44336)"},{type:"set_stroke",value:"var(--nice-danger-dark, #b71c1c)"},{type:"set_text_color",value:"var(--nice-bg, #fff)"},{type:"set_animation",value:"pulse"}]},{id:"high-value",name:"High Value Highlight",description:"Bold border for high-value nodes",enabled:!1,priority:20,target:"node",condition:{property:"data.value",operator:"greater_than",value:1e6},actions:[{type:"set_stroke_width",value:4},{type:"set_stroke",value:"var(--nice-warning, #FFD700)"},{type:"set_badge",value:{text:"$$$",color:"var(--nice-warning, #FFD700)"}}]},{id:"inactive-dim",name:"Dim Inactive",description:"Reduce opacity for inactive elements",enabled:!1,priority:5,target:"both",condition:{property:"data.active",operator:"equals",value:!1},actions:[{type:"set_opacity",value:.5}]}];function An(o){const e=Ft.find(t=>t.id===o);return e?{...e,id:`${e.id}_${Date.now()}`}:null}function $n(o=!1){const e=new $r;if(o)for(const t of Ft)e.addRule(t);return e}class Tn{constructor(){this.nodes=[],this.edges=[],this.groups=[],this.presets=new Map,this.state={query:"",results:[],selectedIndex:-1,filters:[],isActive:!1,totalCount:0},this.listeners=new Set}updateData(e,t,r){this.nodes=e,this.edges=t,this.groups=r,this.state.isActive&&this.state.query&&this.search(this.state.query)}search(e,t={}){const{scope:r="all",matchType:i="contains",caseSensitive:a=!1,searchData:s=!0,dataProperties:c=[],maxResults:l=100,nodeShapes:u=[],groupIds:d=[]}=t;if(!e.trim())return this.state={...this.state,query:"",results:[],selectedIndex:-1,isActive:!1,totalCount:0},this.notify(),[];const w=[],x=a?e:e.toLowerCase();if(r==="all"||r==="nodes"||r==="labels")for(const g of this.nodes){if(w.length>=l)break;if(u.length>0&&!u.includes(g.shape)||d.length>0&&g.groupId&&!d.includes(g.groupId))continue;const h=this.matchElement(g,x,i,a,s,c);h&&w.push({id:g.id,type:"node",label:g.label||g.id,element:g,matchText:h.text,matchProperty:h.property,matchPositions:h.positions,score:h.score})}if(r==="all"||r==="edges"||r==="labels")for(const g of this.edges){if(w.length>=l)break;const h=this.matchElement(g,x,i,a,s,c);h&&w.push({id:g.id,type:"edge",label:g.label||`${g.sourceNodeId} → ${g.targetNodeId}`,element:g,matchText:h.text,matchProperty:h.property,matchPositions:h.positions,score:h.score})}if(r==="all"||r==="groups")for(const g of this.groups){if(w.length>=l)break;if(d.length>0&&!d.includes(g.id))continue;const h=this.matchElement(g,x,i,a,s,c);h&&w.push({id:g.id,type:"group",label:g.label||g.id,element:g,matchText:h.text,matchProperty:h.property,matchPositions:h.positions,score:h.score})}return w.sort((g,h)=>h.score-g.score),this.state={...this.state,query:e,results:w,selectedIndex:w.length>0?0:-1,isActive:!0,totalCount:w.length},this.notify(),w}matchElement(e,t,r,i,a,s){let c=null;const l=(d,w,x,g)=>{(!c||g>c.score)&&(c={text:d,property:w,positions:x,score:g})},u=this.matchText(e.id,t,r,i);if(u&&l(e.id,"id",u.positions,100+u.positions.length*10),"label"in e&&e.label){const d=this.matchText(e.label,t,r,i);d&&l(e.label,"label",d.positions,150+d.positions.length*10)}if("shape"in e&&e.shape){const d=this.matchText(e.shape,t,r,i);d&&l(e.shape,"shape",d.positions,80+d.positions.length*10)}if(a&&"data"in e&&e.data){const d=this.searchInData(e.data,t,r,i,s);for(const w of d)l(w.text,`data.${w.property}`,w.positions,50+w.positions.length*10)}return c}matchText(e,t,r,i){const a=i?e:e.toLowerCase(),s=i?t:t.toLowerCase(),c=[];switch(r){case"exact":a===s&&c.push({start:0,end:e.length});break;case"starts_with":a.startsWith(s)&&c.push({start:0,end:t.length});break;case"ends_with":a.endsWith(s)&&c.push({start:e.length-t.length,end:e.length});break;case"regex":try{const l=i?"g":"gi",u=new RegExp(t,l);let d;for(;(d=u.exec(e))!==null&&(c.push({start:d.index,end:d.index+d[0].length}),!!u.global););}catch{}break;case"contains":default:{let l=0;for(;(l=a.indexOf(s,l))!==-1;)c.push({start:l,end:l+t.length}),l+=t.length;break}}return c.length>0?{positions:c}:null}searchInData(e,t,r,i,a,s=""){const c=[];for(const[l,u]of Object.entries(e)){const d=s?`${s}.${l}`:l;if(!(a.length>0&&!a.some(w=>d.startsWith(w))))if(typeof u=="string"){const w=this.matchText(u,t,r,i);w&&c.push({text:u,property:d,positions:w.positions})}else if(typeof u=="number"||typeof u=="boolean"){const w=String(u),x=this.matchText(w,t,r,i);x&&c.push({text:w,property:d,positions:x.positions})}else u!=null&&typeof u=="object"&&!Array.isArray(u)&&c.push(...this.searchInData(u,t,r,i,a,d))}return c}filter(e){if(this.state.filters=e,e.length===0)return{nodes:this.nodes,edges:this.edges,groups:this.groups};const t=this.nodes.filter(a=>this.matchFilters(a,e)),r=this.edges.filter(a=>this.matchFilters(a,e)),i=this.groups.filter(a=>this.matchFilters(a,e));return this.notify(),{nodes:t,edges:r,groups:i}}matchFilters(e,t){return t.every(r=>this.matchFilter(e,r))}matchFilter(e,t){const r=this.getPropertyValue(e,t.property);switch(t.operator){case"equals":return r===t.value;case"not_equals":return r!==t.value;case"contains":return typeof r=="string"&&typeof t.value=="string"?r.toLowerCase().includes(t.value.toLowerCase()):Array.isArray(r)?r.includes(t.value):!1;case"greater_than":return typeof r=="number"&&r>t.value;case"less_than":return typeof r=="number"&&r<t.value;case"in":return Array.isArray(t.value)&&t.value.includes(r);case"not_in":return!Array.isArray(t.value)||!t.value.includes(r);case"is_null":return r==null;case"is_not_null":return r!=null;default:return!0}}getPropertyValue(e,t){const r=t.split(".");let i=e;for(const a of r){if(i==null)return;i=i[a]}return i}nextResult(){return this.state.results.length===0?null:(this.state.selectedIndex=(this.state.selectedIndex+1)%this.state.results.length,this.notify(),this.state.results[this.state.selectedIndex])}previousResult(){return this.state.results.length===0?null:(this.state.selectedIndex=(this.state.selectedIndex-1+this.state.results.length)%this.state.results.length,this.notify(),this.state.results[this.state.selectedIndex])}selectResult(e){return e<0||e>=this.state.results.length?null:(this.state.selectedIndex=e,this.notify(),this.state.results[e])}getState(){return{...this.state}}getSelectedResult(){return this.state.selectedIndex<0?null:this.state.results[this.state.selectedIndex]??null}clearSearch(){this.state={query:"",results:[],selectedIndex:-1,filters:this.state.filters,isActive:!1,totalCount:0},this.notify()}clearFilters(){this.state.filters=[],this.notify()}clearAll(){this.state={query:"",results:[],selectedIndex:-1,filters:[],isActive:!1,totalCount:0},this.notify()}savePreset(e,t){const r={id:`preset_${Date.now()}`,name:e,description:t,filters:[...this.state.filters],searchQuery:this.state.query||void 0,searchOptions:void 0};return this.presets.set(r.id,r),r}loadPreset(e){const t=this.presets.get(e);t&&(this.state.filters=[...t.filters],t.searchQuery&&this.search(t.searchQuery,t.searchOptions),this.notify())}deletePreset(e){return this.presets.delete(e)}getPresets(){return Array.from(this.presets.values())}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.listeners.forEach(e=>e(this.state))}getUniqueValues(e,t){const r=new Set;if(!t||t==="node")for(const i of this.nodes){const a=this.getPropertyValue(i,e);a!=null&&r.add(a)}if(!t||t==="edge")for(const i of this.edges){const a=this.getPropertyValue(i,e);a!=null&&r.add(a)}if(!t||t==="group")for(const i of this.groups){const a=this.getPropertyValue(i,e);a!=null&&r.add(a)}return Array.from(r)}getNodeShapes(){return[...new Set(this.nodes.map(e=>e.shape))]}getEdgeLineTypes(){return[...new Set(this.edges.filter(e=>{var t;return(t=e.style)==null?void 0:t.lineType}).map(e=>e.style.lineType))]}getGroups(){return this.groups}exportPresets(){return JSON.stringify(Array.from(this.presets.values()))}importPresets(e){JSON.parse(e).forEach(r=>this.presets.set(r.id,r))}}function Pn(o,e,t="search-highlight"){if(e.length===0)return o;const r=[...e].sort((a,s)=>s.start-a.start);let i=o;for(const a of r){const s=i.slice(0,a.start),c=i.slice(a.start,a.end),l=i.slice(a.end);i=`${s}<span class="${t}">${c}</span>${l}`}return i}function En(o,e){switch(o){case"by-type":return{id:`filter_type_${Date.now()}`,property:"type",operator:"equals",value:e};case"by-layer":return{id:`filter_layer_${Date.now()}`,property:"layer",operator:"equals",value:e};case"by-status":return{id:`filter_status_${Date.now()}`,property:"data.status",operator:"equals",value:e};case"custom":default:return{id:`filter_custom_${Date.now()}`,property:"",operator:"equals",value:e}}}exports.AnimationPlayer=gr;exports.AnimationTimeline=bt;exports.COMMENT_PRIORITY_STYLES=In;exports.ConditionalStylingEngine=$r;exports.DIAGRAM_STYLE_PRESETS=yt;exports.DIAGRAM_TEMPLATES=vt;exports.DiagramCanvas=Ee;exports.DiagramCellRenderer=Ki;exports.DiagramCommentManager=_n;exports.DiagramMinimap=lt;exports.DiagramModel=pt;exports.DiagramParticleEngine=er;exports.DiagramPropertyPanel=wt;exports.DiagramSearchFilterEngine=Tn;exports.DiagramToolbar=xt;exports.DiagramVersioningManager=Ar;exports.EDGE_STYLE_CATALOG=ti;exports.NODE_STYLE_CATALOG=ei;exports.NiceAnimationTimeline=bt;exports.NiceDatabaseSchemaViewer=ga;exports.NiceDecisionTreeEditor=on;exports.NiceDependencyGraph=Ea;exports.NiceDiagram=Et;exports.NiceDiagramCanvas=Ee;exports.NiceDiagramEditor=fr;exports.NiceDiagramMinimap=lt;exports.NiceDiagramPropertyPanel=wt;exports.NiceDiagramToolbar=xt;exports.NiceDiagramViewer=Et;exports.NiceI18nProvider=jt;exports.NiceNetworkTopology=Xa;exports.NiceOrgChartVisualizer=Sa;exports.NiceProcessMiningDiagram=Ia;exports.NiceWorkflowDesigner=Nr;exports.NiceWorkflowVisualizer=ca;exports.PRESET_RULES=Ft;exports.TRANSITION_PRESETS=cr;exports.analyzeDependencyGraph=Ga;exports.calculateNetworkHealth=en;exports.calculateOrgStats=za;exports.computeGlowRadius=rr;exports.computeLayout=Dt;exports.convertAnimation=wr;exports.convertEdge=yr;exports.convertGroup=br;exports.convertNode=pr;exports.createConditionalStylingEngine=$n;exports.createDecisionTree=fn;exports.createDiagramDocument=Ze;exports.createGlowFilterId=tr;exports.createLinearWorkflow=fa;exports.createOrgChartFromEmployees=Ma;exports.createPresetFromTheme=ai;exports.createQuickFilter=En;exports.createRuleFromPreset=An;exports.createVersioningHook=Nn;exports.diagramBounds=Tt;exports.discoverNetworkTopology=Qa;exports.exportToMermaid=or;exports.exportToSvg=zt;exports.fetchAndGenerateDiagram=Zi;exports.fitViewport=Pt;exports.formatCommentDate=jn;exports.generateDiagramFromData=kr;exports.getDiagramStylePreset=ri;exports.getDiagramStylePresetsByCategory=oi;exports.getEasing=hr;exports.getPointOnPath=Ur;exports.getTemplateById=vn;exports.getTemplatesByCategory=kn;exports.highlightMatches=Pn;exports.mineProcessFromLog=_r;exports.parseBPMNToWorkflow=ua;exports.parseNddJson=Xr;exports.parsePackageJsonToDependencies=qa;exports.parseSQLToSchema=xa;exports.parseSklearnTree=un;exports.predictWithTree=hn;exports.presetToThemeOverrides=ii;exports.renderTextWithMentions=Dn;exports.schemaToSQL=va;exports.searchTemplates=Cn;exports.stringifyNddJson=nr;exports.useDiagramEditor=lr;exports.useNiceTranslation=Re;