@nice2dev/ui-diagrams 1.4.13 → 1.4.15

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 s=require("react/jsx-runtime"),k=require("@nice2dev/ui"),g=require("react");class tr{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,n=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)*n,vy:Math.sin(a)*n,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 Xr(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 rr(o){return`nd-glow-${o.replace(/[^a-zA-Z0-9]/g,"_")}`}function or(o,e){const t=o*12,r=1+Math.sin(e)*.3;return t*r}function At(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,n=-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),n=Math.max(n,h.position.x+h.size.width),c=Math.max(c,h.position.y+h.size.height);o.nodes.length===0&&(i=a=0,n=c=100);const l=40,u=(n-i+l*2)*t,d=(c-a+l*2)*t,m=-i+l,w=-a+l,p=[];p.push(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${u} ${d}" width="${u}" height="${d}">`),p.push("<defs>"),p.push('<marker id="arrowhead" markerWidth="10" markerHeight="7" refX="10" refY="3.5" orient="auto">'),p.push(' <polygon points="0 0, 10 3.5, 0 7" fill="#666" />'),p.push("</marker>"),p.push("</defs>"),r!=="transparent"&&p.push(`<rect width="${u}" height="${d}" fill="${r}" />`),p.push(`<g transform="translate(${m*t}, ${w*t}) scale(${t})">`);for(const h of o.edges){const x=o.nodes.find(G=>G.id===h.sourceNodeId),z=o.nodes.find(G=>G.id===h.targetNodeId);if(!x||!z)continue;const y=x.position.x+x.size.width/2,S=x.position.y+x.size.height/2,b=z.position.x+z.size.width/2,v=z.position.y+z.size.height/2,D=h.style.strokeColor??"#666",N=h.style.strokeWidth??2,K=h.style.targetArrow!=="none"?' marker-end="url(#arrowhead)"':"";if(h.style.lineType==="bezier"){const G=(y+b)/2,L=S,W=(y+b)/2,A=v;p.push(`<path d="M${y},${S} C${G},${L} ${W},${A} ${b},${v}" fill="none" stroke="${D}" stroke-width="${N}"${K} />`)}else p.push(`<line x1="${y}" y1="${S}" x2="${b}" y2="${v}" stroke="${D}" stroke-width="${N}"${K} />`);if(h.label){const G=(y+b)/2,L=(S+v)/2;p.push(`<text x="${G}" y="${L-6}" text-anchor="middle" font-size="12" fill="#333">${Yt(h.label)}</text>`)}}for(const h of o.nodes){const{x,y:z}=h.position,{width:y,height:S}=h.size,b=h.style.backgroundColor??"#fff",v=h.style.borderColor??"#ccc",D=h.style.borderWidth??1,N=h.style.borderRadius??(h.shape==="roundedRect"?8:0),K=h.style.fontColor??"#333",G=h.style.fontSize??14;switch(h.shape){case"ellipse":case"circle":p.push(`<ellipse cx="${x+y/2}" cy="${z+S/2}" rx="${y/2}" ry="${S/2}" fill="${b}" stroke="${v}" stroke-width="${D}" />`);break;case"diamond":p.push(`<polygon points="${x+y/2},${z} ${x+y},${z+S/2} ${x+y/2},${z+S} ${x},${z+S/2}" fill="${b}" stroke="${v}" stroke-width="${D}" />`);break;default:p.push(`<rect x="${x}" y="${z}" width="${y}" height="${S}" rx="${N}" fill="${b}" stroke="${v}" stroke-width="${D}" />`)}p.push(`<text x="${x+y/2}" y="${z+S/2+G/3}" text-anchor="middle" font-size="${G}" fill="${K}" font-family="sans-serif">${Yt(h.label)}</text>`)}return p.push("</g>"),p.push("</svg>"),p.join(`
2
- `)}function ir(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=Mt(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=Mt(r.sourceNodeId),a=Mt(r.targetNodeId),n=r.label?`|${r.label}|`:"",c=r.style.targetArrow==="none"?"---":"-->";e.push(` ${i} ${c}${n} ${a}`)}return e.join(`
3
- `)}function Mt(o){return o.replace(/[^a-zA-Z0-9_]/g,"_")}function Yt(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const _t={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","toolbar.tab.home":"Home","toolbar.tab.insert":"Insert","toolbar.tab.format":"Format","toolbar.tab.view":"View","toolbar.section.tools":"Tools","toolbar.section.clipboard":"Clipboard","toolbar.section.history":"History","toolbar.section.shapes":"Shapes","toolbar.section.text":"Text","toolbar.section.zoom":"Zoom","toolbar.section.find":"Find","toolbar.section.mode":"Mode","toolbar.properties":"Properties panel","shape.rectangle":"Rectangle","shape.roundedRect":"Rounded rectangle","shape.ellipse":"Ellipse","shape.circle":"Circle","shape.diamond":"Diamond","shape.hexagon":"Hexagon","shape.parallelogram":"Parallelogram","shape.cylinder":"Cylinder","shape.triangle":"Triangle","shape.cloud":"Cloud","shape.document":"Document","shape.actor":"Actor","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","toolbar.tab.home":"Start","toolbar.tab.insert":"Wstaw","toolbar.tab.format":"Format","toolbar.tab.view":"Widok","toolbar.section.tools":"Narzędzia","toolbar.section.clipboard":"Schowek","toolbar.section.history":"Historia","toolbar.section.shapes":"Kształty","toolbar.section.text":"Tekst","toolbar.section.zoom":"Powiększenie","toolbar.section.find":"Szukaj","toolbar.section.mode":"Tryb","toolbar.properties":"Panel właściwości","shape.rectangle":"Prostokąt","shape.roundedRect":"Zaokrąglony prostokąt","shape.ellipse":"Elipsa","shape.circle":"Koło","shape.diamond":"Romb","shape.hexagon":"Sześciokąt","shape.parallelogram":"Równoległobok","shape.cylinder":"Walec","shape.triangle":"Trójkąt","shape.cloud":"Chmura","shape.document":"Dokument","shape.actor":"Aktor","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","toolbar.tab.home":"Start","toolbar.tab.insert":"Einfügen","toolbar.tab.format":"Format","toolbar.tab.view":"Ansicht","toolbar.section.tools":"Werkzeuge","toolbar.section.clipboard":"Zwischenablage","toolbar.section.history":"Verlauf","toolbar.section.shapes":"Formen","toolbar.section.text":"Text","toolbar.section.zoom":"Zoom","toolbar.section.find":"Suchen","toolbar.section.mode":"Modus","toolbar.properties":"Eigenschaftenbereich","shape.rectangle":"Rechteck","shape.roundedRect":"Abgerundetes Rechteck","shape.ellipse":"Ellipse","shape.circle":"Kreis","shape.diamond":"Raute","shape.hexagon":"Sechseck","shape.parallelogram":"Parallelogramm","shape.cylinder":"Zylinder","shape.triangle":"Dreieck","shape.cloud":"Wolke","shape.document":"Dokument","shape.actor":"Akteur","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","toolbar.tab.home":"Accueil","toolbar.tab.insert":"Insertion","toolbar.tab.format":"Format","toolbar.tab.view":"Affichage","toolbar.section.tools":"Outils","toolbar.section.clipboard":"Presse-papiers","toolbar.section.history":"Historique","toolbar.section.shapes":"Formes","toolbar.section.text":"Texte","toolbar.section.zoom":"Zoom","toolbar.section.find":"Rechercher","toolbar.section.mode":"Mode","toolbar.properties":"Panneau des propriétés","shape.rectangle":"Rectangle","shape.roundedRect":"Rectangle arrondi","shape.ellipse":"Ellipse","shape.circle":"Cercle","shape.diamond":"Losange","shape.hexagon":"Hexagone","shape.parallelogram":"Parallélogramme","shape.cylinder":"Cylindre","shape.triangle":"Triangle","shape.cloud":"Nuage","shape.document":"Document","shape.actor":"Acteur","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","toolbar.tab.home":"Inicio","toolbar.tab.insert":"Insertar","toolbar.tab.format":"Formato","toolbar.tab.view":"Vista","toolbar.section.tools":"Herramientas","toolbar.section.clipboard":"Portapapeles","toolbar.section.history":"Historial","toolbar.section.shapes":"Formas","toolbar.section.text":"Texto","toolbar.section.zoom":"Zoom","toolbar.section.find":"Buscar","toolbar.section.mode":"Modo","toolbar.properties":"Panel de propiedades","shape.rectangle":"Rectángulo","shape.roundedRect":"Rectángulo redondeado","shape.ellipse":"Elipse","shape.circle":"Círculo","shape.diamond":"Rombo","shape.hexagon":"Hexágono","shape.parallelogram":"Paralelogramo","shape.cylinder":"Cilindro","shape.triangle":"Triángulo","shape.cloud":"Nube","shape.document":"Documento","shape.actor":"Actor","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"}},ar=g.createContext(null);function nr(o,e){const t={..._t.en,..._t[o],...e};return{locale:o,t:(i,a)=>t[i]??a??i}}function Dt({locale:o="en",overrides:e,children:t}){const r=g.useMemo(()=>nr(o,e),[o,e]);return g.createElement(ar.Provider,{value:r},t)}function qe(){const o=g.useContext(ar),{lang:e}=k.useNiceTranslation(),t=_t[e]?e:"en",r=g.useMemo(()=>nr(t),[t]);return o??r}function Kr(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 sr(o,e=!0){return JSON.stringify(o,null,e?2:void 0)}class bt{constructor(e){this.undoStack=[],this.redoStack=[],this.listeners=new Set,this.maxHistory=100,this.doc=e??bt.createEmpty()}static createEmpty(e="flowchart"){const t=new Date().toISOString();return{version:"1.0",id:nt(),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=Zr(),n={id:nt(),label:e,position:t,size:i,shape:r,style:{},ports:a};return this.doc.nodes.push(n),this.notify(),n}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 n={id:nt(),sourceNodeId:e,sourcePortId:t,targetNodeId:r,targetPortId:i,label:a,style:{lineType:"bezier",targetArrow:"arrow"}};return this.doc.edges.push(n),this.notify(),n}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:nt(),label:e,nodeIds:[...t]};return t.forEach(i=>{const a=this.doc.nodes.find(n=>n.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:nt(),...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:nt(),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(n=>n.id===e);if(!r)return null;this.pushUndo("Add animation to mode");const i={id:nt(),...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 nt(){return`ndd_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Zr(){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 jt(o,e,t){switch(t.algorithm){case"dagre":return lr(o,e,t);case"grid":return Qr(o,t);case"radial":return eo(o,e);case"tree":return to(o,e,t);case"forceDirected":return ro(o,e,t);case"manual":default:return{positions:new Map(o.map(r=>[r.id,{...r.position}]))}}}function Jr(o,e){const t=new Map,r=new Set,i=new Set;e.forEach(n=>n.forEach(c=>i.add(c)));const a=n=>{const c=[{id:n,next:0}];for(t.set(n,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++],m=t.get(d);m===1?r.add(`${l.id}→${d}`):m===void 0&&(t.set(d,1),c.push({id:d,next:0}))}};for(const n of o)!i.has(n)&&!t.has(n)&&a(n);for(const n of o)t.has(n)||a(n);return r}function lr(o,e,t){const r=t.direction??"TB",i=t.nodeSpacing??60,a=t.rankSpacing??100,n=r==="LR"||r==="RL",c=r==="BT"||r==="RL",l=o.map(A=>A.id),u=new Map(o.map(A=>[A.id,A])),d=new Map(l.map(A=>[A,[]]));for(const A of e){const B=d.get(A.sourceNodeId);B&&u.has(A.targetNodeId)&&A.sourceNodeId!==A.targetNodeId&&(B.includes(A.targetNodeId)||B.push(A.targetNodeId))}const m=Jr(l,d),w=new Map(l.map(A=>[A,[]])),p=new Map(l.map(A=>[A,[]]));d.forEach((A,B)=>{for(const O of A){const[H,M]=m.has(`${B}→${O}`)?[O,B]:[B,O];w.get(H).includes(M)||(w.get(H).push(M),p.get(M).push(H))}});const h=new Map(l.map(A=>[A,0])),x=new Map(l.map(A=>[A,p.get(A).length])),z=l.filter(A=>x.get(A)===0);for(let A=0;A<z.length;A++){const B=z[A];for(const O of w.get(B))h.set(O,Math.max(h.get(O),h.get(B)+1)),x.set(O,x.get(O)-1),x.get(O)===0&&z.push(O)}const y=[];for(const A of l){const B=h.get(A);(y[B]??(y[B]=[])).push(A)}const S=y.filter(Boolean),b=new Map;S.forEach(A=>A.forEach((B,O)=>b.set(B,O)));const D=(A,B)=>B.length===0?b.get(A):B.reduce((O,H)=>O+b.get(H),0)/B.length;for(let A=0;A<4;A++){const B=A%2===0,O=B?S.slice(1):S.slice(0,-1).reverse();for(const H of O){const M=new Map(H.map(R=>[R,D(R,B?p.get(R):w.get(R))]));H.sort((R,F)=>M.get(R)-M.get(F)||b.get(R)-b.get(F)),H.forEach((R,F)=>b.set(R,F))}}const N=A=>n?A.size.width:A.size.height,K=A=>n?A.size.height:A.size.width,G=new Map;let L=0;for(const A of S){const B=A.map(R=>u.get(R)),O=Math.max(...B.map(N));let M=-(B.reduce((R,F)=>R+K(F),0)+(B.length-1)*i)/2;for(const R of B){const F=L+(O-N(R))/2,q=c?-(F+N(R)):F;G.set(R.id,n?{x:q,y:M}:{x:M,y:q}),M+=K(R)+i}L+=O+a}t.centerGraph&&Tt(G);const W=new Map;return S.forEach((A,B)=>A.forEach(O=>W.set(O,B))),{positions:G,ranks:W}}function Qr(o,e){const t=e.nodeSpacing??80,r=Math.ceil(Math.sqrt(o.length)),i=new Map;return o.forEach((a,n)=>{const c=n%r,l=Math.floor(n/r);i.set(a.id,{x:c*(a.size.width+t),y:l*(a.size.height+t)})}),e.centerGraph&&Tt(i),{positions:i}}function eo(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 n=i.slice(1),c=200+n.length*20;return n.forEach((l,u)=>{const d=2*Math.PI*u/n.length;t.set(l.id,{x:Math.cos(d)*c,y:Math.sin(d)*c})}),{positions:t}}function to(o,e,t){return lr(o,e,{...t,direction:t.direction??"TB",nodeSpacing:t.nodeSpacing??40,rankSpacing:t.rankSpacing??80})}function ro(o,e,t){const r=new Map;if(o.length===0)return{positions:r};const i=400,a=new Map;o.forEach(m=>{a.set(m.id,{x:(Math.random()-.5)*i,y:(Math.random()-.5)*i})});const n=e.map(m=>({source:m.sourceNodeId,target:m.targetNodeId})),c=t.nodeSpacing??150,l=80,u=.95;let d=i/2;for(let m=0;m<l;m++){const w=new Map;o.forEach(p=>w.set(p.id,{fx:0,fy:0}));for(let p=0;p<o.length;p++)for(let h=p+1;h<o.length;h++){const x=a.get(o[p].id),z=a.get(o[h].id),y=z.x-x.x,S=z.y-x.y,b=Math.max(Math.sqrt(y*y+S*S),1),v=c*c/b,D=y/b*v,N=S/b*v;w.get(o[p].id).fx-=D,w.get(o[p].id).fy-=N,w.get(o[h].id).fx+=D,w.get(o[h].id).fy+=N}for(const p of n){const h=a.get(p.source),x=a.get(p.target);if(!h||!x)continue;const z=x.x-h.x,y=x.y-h.y,S=Math.max(Math.sqrt(z*z+y*y),1),b=S*S/c,v=z/S*b,D=y/S*b;w.get(p.source).fx+=v,w.get(p.source).fy+=D,w.get(p.target).fx-=v,w.get(p.target).fy-=D}o.forEach(p=>{const h=w.get(p.id),x=a.get(p.id),z=Math.sqrt(h.fx*h.fx+h.fy*h.fy);if(z>0){const y=Math.min(z,d);x.x+=h.fx/z*y,x.y+=h.fy/z*y}}),d*=u}return o.forEach(m=>{r.set(m.id,{...a.get(m.id)})}),t.centerGraph&&Tt(r),{positions:r}}function Tt(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,n=(t+i)/2;o.forEach(c=>{c.x-=a,c.y-=n})}function cr(o){const e=g.useRef(null);e.current||(e.current=new bt(o));const t=e.current,[r,i]=g.useState(0),a=g.useCallback(()=>i(l=>l+1),[]);g.useEffect(()=>t.subscribe(a),[t,a]);const n=t.getDocument(),c=g.useCallback((l,u)=>{const d=jt(t.getNodes(),t.getEdges(),l);t.moveNodes(d.positions,(u==null?void 0:u.history)??!0)},[t]);return g.useMemo(()=>({document:n,nodes:n.nodes,edges:n.edges,groups:n.groups,animations:n.animations,viewport:n.viewport,addNode:(l,u,d,m)=>t.addNode(l,u,d,m),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,m,w)=>t.addEdge(l,u,d,m,w),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:n.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}),[n,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 oo(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 io(o,e={}){return{strokeColor:o.border,strokeWidth:2,lineType:"bezier",targetArrow:"arrow",...e}}function ao(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,n){return{canvas:o,nodeDefaults:oo(e,r),edgeDefaults:io(e,i),groupDefaults:ao(e,a),fontFamily:t,palette:e,effects:n}}const Ue="'Inter', system-ui, sans-serif",$t="'Fira Code', 'Cascadia Code', monospace",no="'Merriweather', 'Georgia', serif",so={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({}),Ue)},lo=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)"}),co={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)"},lo,Ue,{shadow:!1},{strokeColor:"var(--nice-text-secondary, #475569)"},{backgroundColor:"#60a5fa10",borderColor:"#3b82f680"})},uo=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)"}),fo={id:"corporate-blue",name:"Corporate Blue",category:"corporate",themeSource:"Blue",config:be({background:"#f0f5ff",gridColor:"#93c5fd20",gridSize:20,selectionColor:"var(--nice-primary-dark, #1d4ed8)"},uo,Ue,{borderWidth:2,borderRadius:6},{strokeColor:"var(--nice-primary-light, #93c5fd)",strokeWidth:2})},ho=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)"}),po={id:"neon-glow",name:"Neon Glow",category:"dark",config:be({background:"#0a0a1a",gridColor:"#00ff8810",gridSize:20,selectionColor:"var(--nice-success, #00ff88)"},ho,$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)"})},go=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"}),mo={id:"cyberpunk",name:"Cyberpunk",category:"dark",config:be({background:"#0d001a",gridColor:"#ff2d9510",gridSize:24,selectionColor:"var(--nice-color-accent-pink, #ff2d95)"},go,$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"})},yo=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"}),bo={id:"blueprint",name:"Technical Blueprint",category:"technical",config:be({background:"#0a1929",gridColor:"#4da6ff30",gridSize:16,selectionColor:"var(--nice-color-white, #fff)"},yo,$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})},wo=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"}),xo={id:"pastel-dream",name:"Pastel Dream",category:"pastel",config:be({background:"#fefcff",gridColor:"#e2d8f420",gridSize:20,selectionColor:"var(--nice-accent, #a78bfa)"},wo,"'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})},vo=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"}),ko={id:"nature-forest",name:"Nature Forest",category:"nature",config:be({background:"#f0fdf4",gridColor:"#a7d7c520",gridSize:20,selectionColor:"var(--nice-success, #059669)"},vo,Ue,{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)"})},Co=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"}),So={id:"retro-terminal",name:"Retro Terminal",category:"retro",config:be({background:"#000800",gridColor:"#00ff0010",gridSize:16,selectionColor:"var(--nice-success, #00ff00)"},Co,"'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)"})},Mo=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)"}),Io={id:"high-contrast",name:"High Contrast",category:"accessibility",themeSource:"High Contrast",config:be({background:"var(--nice-bg, #fff)",gridColor:"#00000020",gridSize:20,selectionColor:"#0000ff"},Mo,"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})},zo=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)"}),No={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)"},zo,"'Roboto', 'Noto Sans', sans-serif",{borderRadius:4,borderWidth:0,shadow:!0},{strokeColor:"#bdbdbd",strokeWidth:2},{borderRadius:8})},Ao=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"}),_o={id:"fluent-ui",name:"Fluent UI",category:"theme-based",themeSource:"Fluent",config:be({background:"#faf9f8",gridColor:"#edebe920",gridSize:20,selectionColor:"#0078d4"},Ao,"'Segoe UI', system-ui, sans-serif",{borderRadius:4,borderWidth:1,shadow:!0},{strokeColor:"#c8c6c4",strokeWidth:1})},Do=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)"}),jo={id:"sunset-warm",name:"Sunset Warm",category:"creative",config:be({background:"#fffde7",gridColor:"#ffccbc20",gridSize:20,selectionColor:"var(--nice-warning-dark, #e65100)"},Do,Ue,{borderColor:"#ff9e80",gradientColor:"var(--nice-warning-bg, #fff3e0)",gradientDirection:"vertical"},{strokeColor:"#ff9e80"},{},{liquidColor:"var(--nice-warning-dark, #e65100)",liquidColorEnd:"#ffd600",particleColor:"#ffd600"})},To=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"},To,Ue,{borderColor:"#00838f",borderRadius:12},{strokeColor:"#4dd0e1"},{},{liquidColor:"#006064",liquidColorEnd:"#4dd0e1",particleColor:"#ffd54f"})},Po=ye({primary:"#5d4037",primaryLight:"#a1887f",secondary:"#795548",accent:"#c6a263",text:"#3e2723",textMuted:"#8d6e63",border:"#bcaaa4",surface:"#fdf6f0",surfaceAlt:"#efebe9"}),Ro={id:"elegant-serif",name:"Elegant Serif",category:"creative",config:be({background:"#fdf6f0",gridColor:"#bcaaa420",gridSize:24,selectionColor:"#5d4037"},Po,no,{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)"}),Oo={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)"})},Fo=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"}),Lo={id:"mint-fresh",name:"Mint Fresh",category:"nature",config:be({background:"var(--nice-success-bg, #e8f5e9)",gridColor:"#a7ffeb20",gridSize:20,selectionColor:"#00bfa5"},Fo,Ue,{borderColor:"#00bfa5",borderRadius:20,borderWidth:2,gradientColor:"#b2dfdb",gradientDirection:"radial"},{strokeColor:"#64ffda",strokeWidth:2},{borderRadius:16},{liquidColor:"#00bfa5",liquidColorEnd:"#64ffda",particleColor:"#ff6e40"})},Wo=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)"}),Bo={id:"monochrome",name:"Monochrome",category:"corporate",config:be({background:"var(--nice-bg-secondary, #fafafa)",gridColor:"#e0e0e020",gridSize:20,selectionColor:"#424242"},Wo,Ue,{borderColor:"var(--nice-border-color, #9e9e9e)",borderWidth:1,shadow:!0,borderRadius:4},{strokeColor:"var(--nice-text-secondary, #9e9e9e)",strokeWidth:1.5})},Vo=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"}),qo={id:"candy-pop",name:"Candy Pop",category:"creative",config:be({background:"#fff0f5",gridColor:"#f8bbd020",gridSize:20,selectionColor:"var(--nice-color-accent-pink, #e91e63)"},Vo,"'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)"})},Go=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)"}),Yo={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)"},Go,"'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})},Ho=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"}),Uo={id:"aurora-borealis",name:"Aurora Borealis",category:"dark",config:be({background:"#0f0b2e",gridColor:"#7c3aed15",gridSize:24,selectionColor:"var(--nice-accent, #a78bfa)"},Ho,Ue,{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)"})},Xo=ye({primary:"#2c3e50",primaryLight:"#7f8c8d",secondary:"#2980b9",accent:"#e74c3c",text:"#2c3e50",textMuted:"#95a5a6",border:"#bdc3c7",surface:"#fdfaf6",surfaceAlt:"#f5f0e8"}),Ko={id:"sketch-hand-drawn",name:"Sketch / Hand-drawn",category:"creative",config:be({background:"#fdfaf6",gridColor:"#bdc3c720",gridSize:20,selectionColor:"#2980b9"},Xo,"'Caveat', 'Patrick Hand', cursive",{backgroundColor:"#fdfaf6",borderColor:"#2c3e50",borderWidth:2,borderRadius:2,shadow:!1},{strokeColor:"#2c3e50",strokeWidth:2},{borderStyle:"dashed",borderWidth:2})},Zo=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)"}),Jo={id:"infographic-bold",name:"Infographic Bold",category:"creative",config:be({background:"#eceff1",gridColor:"#b0bec520",gridSize:24,selectionColor:"var(--nice-danger, #ff5722)"},Zo,"'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})},Qo=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"}),ei={id:"midnight-purple",name:"Midnight Purple",category:"dark",config:be({background:"#0f0720",gridColor:"#9333ea10",gridSize:20,selectionColor:"var(--nice-accent, #c084fc)"},Qo,Ue,{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)"})},wt=[so,co,fo,No,_o,po,mo,bo,So,xo,jo,$o,Ro,ko,Oo,Io,Lo,Bo,qo,Yo,Uo,Ko,Jo,ei],ti=[{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}}],ri=[{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}}}],dr=[{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 oi(o){return wt.find(e=>e.id===o)}function ii(o){return wt.filter(e=>e.category===o)}function ai(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 ni(o,e,t,r,i,a){const n=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=si(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},n,Ue,{shadow:!c,borderWidth:c?1:2},{strokeColor:c?`${a.color}80`:a.color})}}function si(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 li=["fadeIn","fadeOut","slideInLeft","slideInRight","slideInTop","slideInBottom","zoomIn","zoomOut","pulse","shake","highlight","flowPulse","bounce","glow","colorShift","liquidFill","expand","collapse","ripple","typewriter","morphShape","drawPath","particleTrail"],ci=["linear","easeIn","easeOut","easeInOut","spring","bounce"],xt=({animations:o,onAdd:e,onRemove:t,onUpdate:r,onPlay:i,onStop:a,isPlaying:n=!1,availableTargets:c=[],className:l})=>{const{t:u}=qe(),[d,m]=g.useState(!1),[w,p]=g.useState(null),h=g.useCallback(()=>{if(!e||c.length===0)return;const y=c[0];e({name:`Animation ${o.length+1}`,targetId:y.id,targetType:y.type,effect:"fadeIn",startMs:o.length*500,durationMs:600,easing:"easeOut"})},[e,o.length,c]),x=g.useCallback(y=>{if(!e||c.length===0)return;const S=c[0];e({name:y.name,targetId:S.id,targetType:S.type,effect:y.effect,startMs:o.length*500,durationMs:y.durationMs,easing:y.easing}),m(!1)},[e,o.length,c]),z=Math.max(2e3,...o.map(y=>y.startMs+y.durationMs+(y.delayMs??0)));return s.jsxs("div",{className:`nice-diagram-timeline ${l??""}`,children:[s.jsxs("div",{className:"nice-diagram-timeline__header",children:[s.jsx("h4",{className:"nice-diagram-timeline__title",children:u("animation.timeline")}),s.jsxs("div",{className:"nice-diagram-timeline__controls",children:[n?s.jsxs(k.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:a,children:[s.jsx(k.NiceIcon,{name:"stop",size:14})," ",u("animation.stop")]}):s.jsxs(k.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:i,children:[s.jsx(k.NiceIcon,{name:"play",size:14})," ",u("animation.play")]}),s.jsxs(k.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:h,disabled:c.length===0,children:[s.jsx(k.NiceIcon,{name:"plus",size:14})," ",u("animation.add")]}),s.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[s.jsxs(k.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:()=>m(y=>!y),disabled:c.length===0,title:u("animation.addFromPreset","Add from preset"),children:[s.jsx(k.NiceIcon,{name:"video",size:14})," ",u("animation.presets","Presets")]}),d&&s.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:dr.map(y=>s.jsx(k.NiceButton,{variant:"ghost",size:"sm",onClick:()=>x(y),style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",fontSize:12,borderBottom:"1px solid var(--nice-bg-secondary, #f0f0f0)"},title:`${y.effect} — ${y.durationMs}ms ${y.easing}`,children:y.name},y.id))})]})]})]}),s.jsxs("div",{className:"nice-diagram-timeline__tracks",children:[o.length===0&&s.jsx("p",{className:"nice-diagram-timeline__empty",children:u("animation.noAnimations")}),o.map(y=>{const S=y.startMs/z*100,b=y.durationMs/z*100,v=w===y.id;return s.jsxs("div",{className:"nice-diagram-timeline__track",children:[s.jsxs("div",{className:"nice-diagram-timeline__track-label",children:[s.jsx("span",{role:"button",tabIndex:0,onKeyDown:k.clickOnActivationKey,className:"nice-diagram-timeline__track-name",onClick:()=>p(v?null:y.id),style:{cursor:"pointer"},title:u("animation.clickToEdit","Click to edit"),children:y.name}),s.jsx("span",{className:"nice-diagram-timeline__track-effect",children:y.effect}),s.jsx(k.NiceButton,{className:"nice-diagram-timeline__track-remove",variant:"ghost",size:"sm",onClick:()=>t==null?void 0:t(y.id),title:u("toolbar.delete"),children:s.jsx(k.NiceIcon,{name:"close",size:14})})]}),v&&s.jsxs("div",{className:"nice-diagram-timeline__track-editor",style:{display:"flex",gap:4,padding:"4px 0",flexWrap:"wrap",fontSize:11},children:[s.jsx(k.NiceSelect,{value:y.effect,onChange:D=>r==null?void 0:r(y.id,{effect:D}),options:li.map(D=>({value:D,label:D})),style:{fontSize:11,padding:"1px 4px"}}),s.jsx(k.NiceSelect,{value:y.easing,onChange:D=>r==null?void 0:r(y.id,{easing:D}),options:ci.map(D=>({value:D,label:D})),style:{fontSize:11,padding:"1px 4px"}}),s.jsx(k.NiceSelect,{value:y.targetId,onChange:D=>{const N=c.find(K=>K.id===D);N&&(r==null||r(y.id,{targetId:N.id,targetType:N.type}))},options:c.map(D=>({value:D.id,label:D.label})),style:{fontSize:11,padding:"1px 4px",maxWidth:100}}),s.jsx(k.NiceNumberInput,{value:y.startMs,min:0,step:100,onChange:D=>r==null?void 0:r(y.id,{startMs:D??0}),style:{width:60,fontSize:11},title:u("animation.startMs","Start (ms)")}),s.jsx(k.NiceNumberInput,{value:y.durationMs,min:50,step:50,onChange:D=>r==null?void 0:r(y.id,{durationMs:D??50}),style:{width:60,fontSize:11},title:u("animation.durationMs","Duration (ms)")})]}),s.jsx("div",{className:"nice-diagram-timeline__track-bar",children:s.jsx("div",{className:"nice-diagram-timeline__track-segment",style:{left:`${S}%`,width:`${b}%`},title:`${y.effect} ${y.startMs}ms → ${y.startMs+y.durationMs}ms (${y.easing})`})})]},y.id)})]}),s.jsx("div",{className:"nice-diagram-timeline__ruler",children:Array.from({length:5}).map((y,S)=>{const b=Math.round(z/4*S);return s.jsxs("span",{className:"nice-diagram-timeline__ruler-mark",style:{left:`${S/4*100}%`},children:[b,"ms"]},S)})})]})};process.env.NODE_ENV!=="production"&&(xt.displayName="AnimationTimeline");function Pt(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 Rt(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 n=(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(n,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 di=/^[a-z][a-z0-9-]*$/,ui=.1,fi=5,gt=8,It=[{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}],Be=({nodes:o,edges:e,groups:t=[],viewport:r,onViewportChange:i,theme:a,selectedId:n,selectedIds:c=[],onSelectElement:l,onMultiSelect:u,onNodeDragStart:d,onNodeDrag:m,onNodeDragEnd:w,onNodeResize:p,onNodeLabelChange:h,onEdgeCreate:x,autoFit:z=!1,fitKey:y,refitKey:S,fitPadding:b=40,fitMaxZoom:v=1.25,onResize:D,resizable:N=!0,panOnDrag:K=!1,ariaLabel:G,animationStates:L,particleState:W,viewMode:A="editor",ghostOpacity:B=.15,onGroupCollapse:O,onNodeCollapse:H,onInteraction:M,onNodeHover:R,onGroupClick:F,interactive:q=!1,showGrid:Y=!0,showRulers:Z=!1,snapToGrid:J=!0,gridSnapSize:ee=10,className:ue})=>{const fe=g.useRef(null),Se=g.useId().replace(/[^a-zA-Z0-9_-]/g,""),$e=`nd-arrow-${Se}`,Ee=`nd-open-arrow-${Se}`,xe=`nd-diamond-marker-${Se}`,Ge=`nd-circle-marker-${Se}`,[Me,Je]=g.useState(null),[Ve,Ye]=g.useState(!1),[Xe,U]=g.useState({x:0,y:0}),[_e,Ke]=g.useState(null),[Pe,tt]=g.useState({x:0,y:0}),[me,ge]=g.useState(null),[Oe,E]=g.useState(null),[$,se]=g.useState(null),[pe,ke]=g.useState(null),[Fe,rt]=g.useState(""),[X,Ie]=g.useState([]),ze=(a==null?void 0:a.canvasBackground)??"var(--nice-bg-secondary, #f8f9fa)",st=(a==null?void 0:a.gridColor)??"var(--nice-border, #e0e0e0)",Re=(a==null?void 0:a.gridSize)??20,I=(a==null?void 0:a.selectionColor)??"var(--nice-primary, #2196f3)",[T,Q]=g.useState(null),ne=g.useRef(!1),Ae=g.useRef(null),De=g.useRef({nodes:o,edges:e,onViewportChange:i,onResize:D,fitPadding:b,fitMaxZoom:v});g.useEffect(()=>{De.current={nodes:o,edges:e,onViewportChange:i,onResize:D,fitPadding:b,fitMaxZoom:v}}),g.useEffect(()=>{const f=fe.current;if(!f)return;const C=()=>{const _=f.getBoundingClientRect();_.width>0&&_.height>0&&Q(te=>te&&te.width===_.width&&te.height===_.height?te:{width:_.width,height:_.height})};if(C(),typeof ResizeObserver>"u")return;const j=new ResizeObserver(C);return j.observe(f),()=>j.disconnect()},[]),g.useEffect(()=>{var f,C;T&&((C=(f=De.current).onResize)==null||C.call(f,T))},[T]),g.useEffect(()=>{const f=Ae.current;f&&(f.x!==r.x||f.y!==r.y||f.zoom!==r.zoom)&&(ne.current=!0)},[r]);const at=g.useRef(S);g.useEffect(()=>{const{nodes:f,edges:C,onViewportChange:j,fitPadding:_,fitMaxZoom:te}=De.current,P=S!==at.current;if(at.current=S,P&&(ne.current=!1),!T||!j||!z&&!P||ne.current)return;const V=Rt(hi(f,C),T,{padding:_,maxZoom:te});Ae.current=V,j(V)},[z,T,y,S]);const je=g.useMemo(()=>{const f=new Set(c);return n&&f.add(n),f},[n,c]),We=g.useCallback(f=>J?Math.round(f/ee)*ee:f,[J,ee]),Wt=g.useCallback((f,C,j)=>{const _=[],P=C.x,V=C.y,ie=P+j.width/2,re=V+j.height/2,oe=P+j.width,ae=V+j.height;for(const we of o){if(we.id===f)continue;const ve=we.position.x,ce=we.position.y,Ne=ve+we.size.width/2,ot=ce+we.size.height/2,Ze=ve+we.size.width,He=ce+we.size.height;Math.abs(P-ve)<5&&_.push({x:ve}),Math.abs(oe-Ze)<5&&_.push({x:Ze}),Math.abs(ie-Ne)<5&&_.push({x:Ne}),Math.abs(P-Ze)<5&&_.push({x:Ze}),Math.abs(oe-ve)<5&&_.push({x:ve}),Math.abs(V-ce)<5&&_.push({y:ce}),Math.abs(ae-He)<5&&_.push({y:He}),Math.abs(re-ot)<5&&_.push({y:ot}),Math.abs(V-He)<5&&_.push({y:He}),Math.abs(ae-ce)<5&&_.push({y:ce})}Ie(_)},[o]),Pr=g.useCallback(f=>{if(f.preventDefault(),!i)return;const C=f.deltaY>0?.9:1.1,j=Math.min(fi,Math.max(ui,r.zoom*C)),_=fe.current;if(!_)return;const te=_.getBoundingClientRect(),P=f.clientX-te.left,V=f.clientY-te.top,ie=j/r.zoom,re=P-(P-r.x)*ie,oe=V-(V-r.y)*ie;ne.current=!0,i({x:re,y:oe,zoom:j})},[r,i]),Rr=g.useCallback(f=>{if(f.button===1||f.button===0&&f.target.tagName==="svg"){if(f.button===0&&q&&!K&&!f.shiftKey&&f.target.tagName==="svg"){const C=fe.current;if(C){const j=C.getBoundingClientRect(),_=(f.clientX-j.left-r.x)/r.zoom,te=(f.clientY-j.top-r.y)/r.zoom;E({x:_,y:te}),ge({x1:_,y1:te,x2:_,y2:te})}l&&l(null),u&&u([]);return}Ye(!0),U({x:f.clientX-r.x,y:f.clientY-r.y}),l&&f.button===0&&l(null)}},[r,l,u,q,K]),ft=g.useCallback(f=>{const C=fe.current;if(!C)return null;const j=C.getBoundingClientRect();return{x:(f.clientX-j.left-r.x)/r.zoom,y:(f.clientY-j.top-r.y)/r.zoom}},[r]),Er=g.useCallback(f=>{if(Me){const C=ft(f);C&&Je(j=>j&&{...j,to:C});return}if(Oe){const C=fe.current;if(!C)return;const j=C.getBoundingClientRect(),_=(f.clientX-j.left-r.x)/r.zoom,te=(f.clientY-j.top-r.y)/r.zoom;ge({x1:Oe.x,y1:Oe.y,x2:_,y2:te});return}if(Ve&&i){ne.current=!0,i({...r,x:f.clientX-Xe.x,y:f.clientY-Xe.y});return}if($&&p){const C=fe.current;if(!C)return;const j=C.getBoundingClientRect(),_=(f.clientX-j.left-r.x)/r.zoom,te=(f.clientY-j.top-r.y)/r.zoom,P=_-$.startMouse.x,V=te-$.startMouse.y,ie=It[$.handleIdx];let re=$.startSize.width+P*ie.resizeX,oe=$.startSize.height+V*ie.resizeY,ae=$.startPos.x+(ie.resizeX<0?P:0),we=$.startPos.y+(ie.resizeY<0?V:0);re=Math.max(30,We(re)),oe=Math.max(20,We(oe)),ae=We(ae),we=We(we),p($.nodeId,{width:re,height:oe},{x:ae,y:we});return}if(_e&&m){const C=fe.current;if(!C)return;const j=C.getBoundingClientRect(),_=We((f.clientX-j.left-r.x)/r.zoom-Pe.x),te=We((f.clientY-j.top-r.y)/r.zoom-Pe.y);m(_e,{x:_,y:te});const P=o.find(V=>V.id===_e);P&&Wt(_e,{x:_,y:te},P.size)}},[Me,ft,Oe,Ve,i,r,Xe,$,p,_e,m,Pe,We,o,Wt]),Bt=g.useCallback(f=>{if(Me){const C=ft(f),j=C?[...o].reverse().find(_=>_.id!==Me.nodeId&&!_.hidden&&C.x>=_.position.x&&C.x<=_.position.x+_.size.width&&C.y>=_.position.y&&C.y<=_.position.y+_.size.height):void 0;j&&C&&(x==null||x(Me.nodeId,j.id,Me.portId,pi(j,C))),Je(null);return}if(me&&Oe){const C=Math.min(me.x1,me.x2),j=Math.min(me.y1,me.y2),_=Math.max(me.x1,me.x2),te=Math.max(me.y1,me.y2);if(Math.abs(_-C)>5||Math.abs(te-j)>5){const P=o.filter(V=>{const ie=V.position.x,re=V.position.y,oe=ie+V.size.width,ae=re+V.size.height;return oe>C&&ie<_&&ae>j&&re<te}).map(V=>V.id);u==null||u(P),P.length===1&&(l==null||l(P[0]))}ge(null),E(null);return}if(Ve&&Ye(!1),$){se(null);return}if(_e&&w){const C=fe.current;if(!C)return;const j=C.getBoundingClientRect(),_=We((f.clientX-j.left-r.x)/r.zoom-Pe.x),te=We((f.clientY-j.top-r.y)/r.zoom-Pe.y);w(_e,{x:_,y:te})}Ke(null),Ie([])},[Me,ft,x,me,Oe,Ve,$,_e,w,r,Pe,We,o,u,l]),Or=g.useCallback((f,C)=>{if(f.stopPropagation(),!q)return;const j=o.find(ie=>ie.id===C);if(!j||j.locked)return;if(f.shiftKey&&u){const ie=[...c],re=ie.indexOf(C);re>=0?ie.splice(re,1):ie.push(C),u(ie);return}l==null||l(C);const _=fe.current;if(!_)return;const te=_.getBoundingClientRect(),P=(f.clientX-te.left-r.x)/r.zoom,V=(f.clientY-te.top-r.y)/r.zoom;tt({x:P-j.position.x,y:V-j.position.y}),Ke(C),d==null||d(C)},[q,o,r,l,d,u,c]),Fr=g.useCallback((f,C,j)=>{if(f.stopPropagation(),!q)return;const _=o.find(re=>re.id===C);if(!_||_.locked)return;const te=fe.current;if(!te)return;const P=te.getBoundingClientRect(),V=(f.clientX-P.left-r.x)/r.zoom,ie=(f.clientY-P.top-r.y)/r.zoom;se({nodeId:C,handleIdx:j,startMouse:{x:V,y:ie},startPos:{..._.position},startSize:{..._.size}}),l==null||l(C)},[q,o,r,l]),Lr=g.useCallback((f,C)=>{if(f.stopPropagation(),!q||!h)return;const j=o.find(_=>_.id===C);!j||j.locked||(ke(C),rt(j.label))},[q,o,h]),Vt=g.useCallback(()=>{pe&&h&&h(pe,Fe),ke(null)},[pe,Fe,h]),Wr=g.useCallback((f,C)=>{f.stopPropagation(),l==null||l(C)},[l]),dt=(f,C,j)=>({tabIndex:0,role:"button","aria-label":f,...j!==void 0?{"aria-pressed":j}:{},onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),_.stopPropagation(),C())}}),Br=g.useCallback(f=>ur(f,o),[o]),Vr=g.useCallback((f,C)=>{const{size:j,style:_,shape:te}=f,P=j.width,V=j.height,re=!!(_.gradientColor&&_.backgroundColor)?`url(#${C})`:_.backgroundColor??"var(--nice-bg, #fff)",oe=_.borderColor??"var(--nice-text, #333333)",ae=_.borderWidth??1,we=_.borderRadius??(te==="roundedRect"?8:0),ve=_.borderStyle==="dashed"?"8,4":_.borderStyle==="dotted"?"2,4":void 0,ce=_.shadow?"url(#nd-shadow)":void 0;switch(te){case"ellipse":case"circle":return s.jsx("ellipse",{cx:P/2,cy:V/2,rx:P/2,ry:V/2,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:ve,filter:ce});case"diamond":return s.jsx("polygon",{points:`${P/2},0 ${P},${V/2} ${P/2},${V} 0,${V/2}`,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:ve,filter:ce});case"hexagon":{const Ne=P/4;return s.jsx("polygon",{points:`${Ne},0 ${P-Ne},0 ${P},${V/2} ${P-Ne},${V} ${Ne},${V} 0,${V/2}`,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:ve,filter:ce})}case"parallelogram":{const Ne=P*.15;return s.jsx("polygon",{points:`${Ne},0 ${P},0 ${P-Ne},${V} 0,${V}`,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:ve,filter:ce})}case"cylinder":return s.jsxs("g",{filter:ce,children:[s.jsx("ellipse",{cx:P/2,cy:V*.1,rx:P/2,ry:V*.1,fill:re,stroke:oe,strokeWidth:ae}),s.jsx("rect",{x:0,y:V*.1,width:P,height:V*.8,fill:re,stroke:"none"}),s.jsx("line",{x1:0,y1:V*.1,x2:0,y2:V*.9,stroke:oe,strokeWidth:ae}),s.jsx("line",{x1:P,y1:V*.1,x2:P,y2:V*.9,stroke:oe,strokeWidth:ae}),s.jsx("ellipse",{cx:P/2,cy:V*.9,rx:P/2,ry:V*.1,fill:re,stroke:oe,strokeWidth:ae})]});case"triangle":return s.jsx("polygon",{points:`${P/2},0 ${P},${V} 0,${V}`,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:ve,filter:ce});case"cloud":{const Ne=`M${P*.25},${V*.8} A${P*.2},${P*.2},0,1,1,${P*.15},${V*.45} A${P*.18},${P*.18},0,1,1,${P*.35},${V*.2} A${P*.2},${P*.2},0,1,1,${P*.65},${V*.2} A${P*.18},${P*.18},0,1,1,${P*.85},${V*.45} A${P*.2},${P*.2},0,1,1,${P*.75},${V*.8} Z`;return s.jsx("path",{d:Ne,fill:re,stroke:oe,strokeWidth:ae,filter:ce})}case"document":{const Ne=`M 0 0 L ${P} 0 L ${P} ${V*.85} Q ${P*.75} ${V*.7}, ${P*.5} ${V*.85} Q ${P*.25} ${V}, 0 ${V*.85} Z`;return s.jsx("path",{d:Ne,fill:re,stroke:oe,strokeWidth:ae,filter:ce})}case"actor":return s.jsxs("g",{stroke:oe,strokeWidth:ae,fill:"none",filter:ce,children:[s.jsx("circle",{cx:P/2,cy:V*.15,r:V*.12,fill:re}),s.jsx("line",{x1:P/2,y1:V*.27,x2:P/2,y2:V*.6}),s.jsx("line",{x1:P*.15,y1:V*.4,x2:P*.85,y2:V*.4}),s.jsx("line",{x1:P/2,y1:V*.6,x2:P*.2,y2:V}),s.jsx("line",{x1:P/2,y1:V*.6,x2:P*.8,y2:V})]});case"rectangle":case"roundedRect":case"custom":default:return s.jsx("rect",{width:P,height:V,rx:we,ry:we,fill:re,stroke:oe,strokeWidth:ae,strokeDasharray:ve,filter:ce})}},[]),qt=g.useCallback(f=>{if(!L)return{};const C=L.get(f);if(!C)return{};const j=C.glow>0?`drop-shadow(0 0 ${C.glow}px gold)`:"",_=C.highlightColor?`drop-shadow(0 0 6px ${C.highlightColor})`:"";return{opacity:C.opacity,transform:`translate(${C.translateX}px, ${C.translateY}px) scale(${C.scale})`,filter:[j,_].filter(Boolean).join(" ")||void 0}},[L]),qr=g.useMemo(()=>{if(!W)return null;const f=[];for(const[,C]of W.glowStates){const j=rr(C.elementId),_=or(C.intensity,C.pulse);f.push(s.jsxs("filter",{id:j,x:"-50%",y:"-50%",width:"200%",height:"200%",children:[s.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:_,result:"blur"}),s.jsx("feFlood",{floodColor:C.color,floodOpacity:.6,result:"color"}),s.jsx("feComposite",{in:"color",in2:"blur",operator:"in",result:"glowColored"}),s.jsxs("feMerge",{children:[s.jsx("feMergeNode",{in:"glowColored"}),s.jsx("feMergeNode",{in:"SourceGraphic"})]})]},j))}return f},[W]),Gr=g.useMemo(()=>{if(!W)return null;const f=[];for(const[C,j]of W.liquidFlows){if(!j.active)continue;const _=e.find(re=>re.id===C);if(!(_!=null&&_.style.liquidFlow))continue;const{color:te,colorEnd:P}=_.style.liquidFlow,V=`nd-liquid-${C}`,ie=j.gradientOffset;f.push(s.jsxs("linearGradient",{id:V,x1:"0",y1:"0",x2:"1",y2:"0",children:[s.jsx("stop",{offset:`${ie*100%100}%`,stopColor:te,stopOpacity:.8}),s.jsx("stop",{offset:`${(ie+.3)*100%100}%`,stopColor:P??te,stopOpacity:.4}),s.jsx("stop",{offset:`${(ie+.6)*100%100}%`,stopColor:te,stopOpacity:.8})]},V))}return f},[W,e]),Yr=g.useMemo(()=>o.filter(f=>f.style.gradientColor&&f.style.backgroundColor).map(f=>{const C=`nd-grad-${f.id}`,j=f.style.gradientDirection??"vertical";if(j==="radial")return s.jsxs("radialGradient",{id:C,children:[s.jsx("stop",{offset:"0%",stopColor:f.style.backgroundColor}),s.jsx("stop",{offset:"100%",stopColor:f.style.gradientColor})]},C);const _=j==="horizontal"||j==="diagonal"?"1":"0",te=j==="vertical"||j==="diagonal"?"1":"0";return s.jsxs("linearGradient",{id:C,x1:"0",y1:"0",x2:_,y2:te,children:[s.jsx("stop",{offset:"0%",stopColor:f.style.backgroundColor}),s.jsx("stop",{offset:"100%",stopColor:f.style.gradientColor})]},C)}),[o]);return s.jsxs("svg",{ref:fe,className:`nice-diagram-canvas ${ue??""}`,style:{width:"100%",height:"100%",background:ze,cursor:Ve?"grabbing":$?$.nodeId?It[$.handleIdx].cursor:"default":Me?"crosshair":K?"grab":"default"},"aria-label":G,onWheel:Pr,onMouseDown:Rr,onMouseMove:Er,onMouseUp:Bt,onMouseLeave:Bt,children:[s.jsxs("defs",{children:[s.jsx("marker",{id:$e,viewBox:"0 0 10 10",refX:"10",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 Z",fill:"var(--nice-text, #333)"})}),s.jsx("marker",{id:Ee,viewBox:"0 0 10 10",refX:"10",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10",fill:"none",stroke:"var(--nice-text, #333)",strokeWidth:"1.5"})}),s.jsx("marker",{id:xe,viewBox:"0 0 10 10",refX:"5",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"15",markerHeight:"15",orient:"auto-start-reverse",children:s.jsx("polygon",{points:"5,0 10,5 5,10 0,5",fill:"var(--nice-text, #333)"})}),s.jsx("marker",{id:Ge,viewBox:"0 0 10 10",refX:"5",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:s.jsx("circle",{cx:"5",cy:"5",r:"4",fill:"var(--nice-text, #333)"})}),s.jsx("filter",{id:"nd-shadow",x:"-10%",y:"-10%",width:"130%",height:"130%",children:s.jsx("feDropShadow",{dx:"2",dy:"2",stdDeviation:"3",floodColor:"#00000033"})}),Y&&s.jsx("pattern",{id:"nd-grid",width:Re,height:Re,patternUnits:"userSpaceOnUse",children:s.jsx("path",{d:`M ${Re} 0 L 0 0 0 ${Re}`,fill:"none",stroke:st,strokeWidth:"0.5"})}),Yr,qr,Gr,o.filter(f=>f.style.glowColor).map(f=>{const C=`nd-node-glow-${f.id}`,j=(f.style.glowIntensity??.5)*10;return s.jsxs("filter",{id:C,x:"-50%",y:"-50%",width:"200%",height:"200%",children:[s.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:j,result:"blur"}),s.jsx("feFlood",{floodColor:f.style.glowColor,floodOpacity:.5,result:"color"}),s.jsx("feComposite",{in:"color",in2:"blur",operator:"in",result:"glowColored"}),s.jsxs("feMerge",{children:[s.jsx("feMergeNode",{in:"glowColored"}),s.jsx("feMergeNode",{in:"SourceGraphic"})]})]},C)})]}),Z&&s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"0",y:"0",width:"100%",height:"20",fill:"var(--nice-bg-secondary, #f0f0f0)",stroke:"var(--nice-border, #ccc)",strokeWidth:"0.5"}),s.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,C)=>{const j=C*Re*r.zoom+r.x,_=C*Re;return j>20?s.jsxs("g",{children:[s.jsx("line",{x1:j,y1:"0",x2:j,y2:"20",stroke:"var(--nice-text-muted, #999)",strokeWidth:"0.5"}),s.jsx("text",{x:j+2,y:"14",fontSize:"9",fill:"var(--nice-text-secondary, #666)",children:_})]},`rx${C}`):null}),Array.from({length:100},(f,C)=>{const j=C*Re*r.zoom+r.y,_=C*Re;return j>20?s.jsxs("g",{children:[s.jsx("line",{x1:"0",y1:j,x2:"20",y2:j,stroke:"var(--nice-text-muted, #999)",strokeWidth:"0.5"}),s.jsx("text",{x:"2",y:j-2,fontSize:"9",fill:"var(--nice-text-secondary, #666)",writingMode:"tb",children:_})]},`ry${C}`):null})]}),s.jsxs("g",{transform:`translate(${r.x}, ${r.y}) scale(${r.zoom})`,children:[Y&&s.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,ve,ce,Ne,ot,Ze,He,ht;const C=o.filter(he=>f.nodeIds.includes(he.id));if(C.length===0&&!f.collapsed)return null;const j=((ie=f.style)==null?void 0:ie.padding)??20;if(f.collapsed){const he=o.find(St=>f.nodeIds.includes(St.id)),lt=he?he.position.x:0,pt=he?he.position.y:0;return s.jsxs("g",{"data-group-id":f.id,...O?dt(f.label||f.id,()=>O(f.id),!1):{},style:{cursor:"pointer"},onClick:()=>O==null?void 0:O(f.id),children:[s.jsx("rect",{x:lt,y:pt,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"}),s.jsxs("text",{x:lt+24,y:pt+24,fontSize:"12",fill:((ve=f.style)==null?void 0:ve.labelColor)??"var(--nice-text-secondary, #666)",fontWeight:"bold",children:[f.label," (",f.nodeIds.length,")"]})]},f.id)}const _=Math.min(...C.map(he=>he.position.x))-j,te=Math.min(...C.map(he=>he.position.y))-j,P=Math.max(...C.map(he=>he.position.x+he.size.width))+j,V=Math.max(...C.map(he=>he.position.y+he.size.height))+j;return s.jsxs("g",{"data-group-id":f.id,children:[s.jsx("rect",{x:_,y:te,width:P-_,height:V-te,fill:((ce=f.style)==null?void 0:ce.backgroundColor)??"rgba(200,200,255,0.1)",stroke:((Ne=f.style)==null?void 0:Ne.borderColor)??"var(--nice-text-muted, #aab)",strokeWidth:((ot=f.style)==null?void 0:ot.borderWidth)??1,rx:((Ze=f.style)==null?void 0:Ze.borderRadius)??6,strokeDasharray:((He=f.style)==null?void 0:He.borderStyle)==="dashed"?"6,3":void 0}),s.jsx("text",{x:_+6,y:te-4,fontSize:"12",fill:((ht=f.style)==null?void 0:ht.labelColor)??"var(--nice-text-secondary, #666)",fontWeight:"bold",style:F?{cursor:"pointer"}:void 0,...F?dt(f.label||f.id,()=>F(f.id)):{},onClick:F?he=>{he.stopPropagation(),F(f.id)}:void 0,children:f.label}),(q||A!=="editor")&&O&&s.jsxs("g",{...dt(f.label||f.id,()=>O(f.id),!0),style:{cursor:"pointer"},onClick:he=>{he.stopPropagation(),O(f.id)},children:[s.jsx("rect",{x:P-24,y:te-12,width:20,height:20,rx:4,fill:"white",stroke:"var(--nice-text-muted, #999)",strokeWidth:1}),s.jsx("g",{transform:`translate(${P-20}, ${te-8})`,children:s.jsx(k.NiceIcon,{name:"chevron-down",size:12,color:"var(--nice-text-secondary, #666)"})})]})]},f.id)}),X.map((f,C)=>s.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-${C}`)),e.map(f=>{var ve;const{d:C,mid:j}=Br(f),_=je.has(f.id),te=f.style.targetArrow==="diamond"?`url(#${xe})`:f.style.targetArrow==="circle"?`url(#${Ge})`:f.style.targetArrow==="openArrow"?`url(#${Ee})`:f.style.targetArrow!=="none"?`url(#${$e})`:void 0,P=f.style.sourceArrow==="diamond"?`url(#${xe})`:f.style.sourceArrow==="circle"?`url(#${Ge})`:f.style.sourceArrow==="openArrow"?`url(#${Ee})`:f.style.sourceArrow==="arrow"?`url(#${$e})`:void 0,V=qt(f.id),ie=L==null?void 0:L.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=W==null?void 0:W.liquidFlows.get(f.id);return s.jsxs("g",{"data-edge-id":f.id,...l?dt(f.label||`${f.sourceNodeId} – ${f.targetNodeId}`,()=>l(f.id),_):{},style:V,onClick:ce=>Wr(ce,f.id),children:[q&&s.jsx("path",{d:C,fill:"none",stroke:"transparent",strokeWidth:12,style:{cursor:"pointer"}}),(ae==null?void 0:ae.active)&&s.jsx("path",{d:C,fill:"none",stroke:`url(#nd-liquid-${f.id})`,strokeWidth:ae.pipeWidth??(f.style.strokeWidth??1.5)*4,strokeLinecap:"round",opacity:.5}),s.jsx("path",{d:C,fill:"none",stroke:_?I:f.style.strokeColor??"var(--nice-text, #333)",strokeWidth:f.style.strokeWidth??1.5,strokeDasharray:(oe==null?void 0:oe.strokeDasharray)??((ve=f.style.strokeDash)==null?void 0:ve.join(","))??(f.style.animated?"6,4":void 0),strokeDashoffset:oe==null?void 0:oe.strokeDashoffset,markerEnd:te,markerStart:P,opacity:f.style.opacity??1,style:q?{cursor:"pointer",transition:oe?void 0:"stroke-dashoffset 0.1s"}:void 0}),f.style.animated&&s.jsx("circle",{r:3,fill:I,children:s.jsx("animateMotion",{dur:`${1/(f.style.flowSpeed||1)}s`,repeatCount:"indefinite",path:C})}),(we==null?void 0:we.active)&&we.particles.map((ce,Ne)=>s.jsx("circle",{r:ce.size,fill:(ae==null?void 0:ae.color)??"var(--nice-primary, #3b82f6)",opacity:ce.opacity*.6,children:s.jsx("animateMotion",{dur:`${3/(((ae==null?void 0:ae.speed)??1)+.5)}s`,repeatCount:"indefinite",path:C,begin:`${ce.t*3}s`})},`lp-${f.id}-${Ne}`)),ie&&ie.particleTrailT>=0&&s.jsxs(s.Fragment,{children:[s.jsx("circle",{r:4,fill:"var(--nice-warning-light, #fbbf24)",opacity:.8,children:s.jsx("animateMotion",{dur:"2s",repeatCount:"indefinite",path:C,begin:`${ie.particleTrailT*2}s`})}),s.jsx("circle",{r:2,fill:"var(--nice-warning-light, #fbbf24)",opacity:.5,children:s.jsx("animateMotion",{dur:"2s",repeatCount:"indefinite",path:C,begin:`${(ie.particleTrailT+.1)*2}s`})})]}),f.label&&(()=>{const ce=f.label.length*7+8;return s.jsxs("g",{children:[s.jsx("rect",{x:j.x-ce/2,y:j.y-9,width:ce,height:18,rx:3,fill:"var(--nice-bg-primary, #fff)",fillOpacity:.85}),s.jsx("text",{x:j.x,y:j.y+4,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-secondary, #555)",children:f.label})]})})()]},f.id)}),o.filter(f=>!f.hidden||A==="editor").map(f=>{const C=je.has(f.id),j=qt(f.id),_=L==null?void 0:L.get(f.id),te=f.style.fontFamily??(a==null?void 0:a.fontFamily)??"sans-serif",P=f.style.fontSize??14,V=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}`,ve=!!f.hidden,ce=ve?B??.3:f.style.opacity??1,Ne=f.style.glowColor?`url(#nd-node-glow-${f.id})`:void 0,ot=oe==="left"?"start":oe==="right"?"end":"middle",Ze=oe==="left"?8:oe==="right"?f.size.width-8:f.size.width/2,He=_==null?void 0:_.typewriterChars,ht=He!=null&&He>=0?f.label.slice(0,He):f.label,he=_==null?void 0:_.liquidFillProgress,lt=_==null?void 0:_.rippleRadius,pt=_==null?void 0:_.rippleOpacity,St=f.childNodeIds&&f.childNodeIds.length>0,Hr=!!f.collapsed;return s.jsxs("g",{"data-node-id":f.id,...l?dt(f.label||f.id,()=>l(f.id),C):{},transform:`translate(${f.position.x}, ${f.position.y})${ae?` rotate(${ae}, ${f.size.width/2}, ${f.size.height/2})`:""}`,style:{...j,cursor:ve?"pointer":q&&!f.locked&&m?"grab":l?"pointer":"default",opacity:ce,filter:Ne},onMouseDown:Ce=>Or(Ce,f.id),onDoubleClick:Ce=>Lr(Ce,f.id),onClick:Ce=>{Ce.stopPropagation(),l==null||l(f.id),f.interactions&&f.interactions.length>0&&f.interactions.filter(it=>it.trigger==="click").forEach(it=>M==null?void 0:M(f.id,it.id))},onMouseEnter:()=>{R==null||R(f.id),f.interactions&&f.interactions.filter(Le=>Le.trigger==="hover").forEach(Le=>M==null?void 0:M(f.id,Le.id))},onMouseLeave:()=>R==null?void 0:R(null),children:[ve&&s.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}),Vr(f,we),he!=null&&he>0&&he<1&&s.jsx("clipPath",{id:`nd-liquid-clip-${f.id}`,children:s.jsx("rect",{x:0,y:f.size.height*(1-he),width:f.size.width,height:f.size.height*he})}),he!=null&&he>0&&he<1&&s.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})`}),lt!=null&&lt>0&&s.jsx("circle",{cx:f.size.width/2,cy:f.size.height/2,r:lt,fill:"none",stroke:f.style.glowColor??I,strokeWidth:2,opacity:pt??.5}),C&&s.jsx("rect",{x:-3,y:-3,width:f.size.width+6,height:f.size.height+6,fill:"none",stroke:I,strokeWidth:2,strokeDasharray:"4,3",rx:6}),C&&q&&N&&!f.locked&&It.map((Ce,Le)=>s.jsx("rect",{x:Ce.dx*f.size.width-gt/2,y:Ce.dy*f.size.height-gt/2,width:gt,height:gt,fill:"white",stroke:I,strokeWidth:1.5,rx:1,style:{cursor:Ce.cursor},onMouseDown:it=>Fr(it,f.id,Le)},Le)),pe===f.id?s.jsx("foreignObject",{x:4,y:4,width:f.size.width-8,height:f.size.height-8,children:s.jsx("input",{xmlns:"http://www.w3.org/1999/xhtml",type:"text",value:Fe,onChange:Ce=>rt(Ce.target.value),onBlur:Vt,onKeyDown:Ce=>{Ce.key==="Enter"&&Vt(),Ce.key==="Escape"&&ke(null)},autoFocus:!0,style:{width:"100%",height:"100%",border:"1px solid "+I,borderRadius:3,padding:"2px 4px",fontSize:P,fontFamily:te,fontWeight:ie,fontStyle:re,textAlign:oe,background:"var(--nice-overlay-light-95, rgba(255, 255, 255, 0.95))",outline:"none"}})}):s.jsxs(s.Fragment,{children:[s.jsx("text",{x:Ze,y:f.size.height/2+(f.description?-4:0),textAnchor:ot,dominantBaseline:"central",fontFamily:te,fontSize:P,fontWeight:ie,fontStyle:re,fill:V,pointerEvents:"none",children:ht}),f.description&&s.jsx("text",{x:Ze,y:f.size.height/2+P*.8,textAnchor:ot,dominantBaseline:"central",fontFamily:te,fontSize:P*.75,fill:"var(--nice-text-secondary, #777)",pointerEvents:"none",children:f.description}),f.icon&&(di.test(f.icon)?s.jsx("g",{transform:`translate(${f.size.width/2-8}, 4)`,pointerEvents:"none",children:s.jsx(k.NiceIcon,{name:f.icon,size:16,color:"var(--nice-text-secondary, #666)"})}):s.jsx("text",{x:f.size.width/2,y:14,textAnchor:"middle",fontSize:16,pointerEvents:"none",children:f.icon})),f.style.linkUrl&&s.jsx("g",{transform:`translate(${f.size.width-14}, 3)`,pointerEvents:"none",children:s.jsx(k.NiceIcon,{name:"link",size:10,color:"var(--nice-primary-hover, #1976d2)"})}),St&&q&&s.jsxs("g",{onClick:Ce=>{Ce.stopPropagation(),H==null||H(f.id)},style:{cursor:"pointer"},children:[s.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}),s.jsx("g",{transform:`translate(${f.size.width-15}, ${f.size.height-15})`,children:s.jsx(k.NiceIcon,{name:Hr?"chevron-right":"chevron-down",size:10,color:"var(--nice-text-secondary, #666)"})})]})]}),q&&f.ports.map(Ce=>{const Le=fr(f,Ce.id),it=x?Ur=>{if(Ur.stopPropagation(),f.locked)return;const Gt={x:f.position.x+Le.x,y:f.position.y+Le.y};Je({nodeId:f.id,portId:Ce.id,from:Gt,to:Gt})}:void 0;return s.jsxs("g",{"data-port-id":Ce.id,onMouseDown:it,children:[it&&s.jsx("circle",{cx:Le.x,cy:Le.y,r:9,fill:"transparent",style:{cursor:"crosshair"}}),s.jsx("circle",{cx:Le.x,cy:Le.y,r:4,fill:"var(--nice-bg-primary, #fff)",stroke:"var(--nice-text-secondary, #666)",strokeWidth:1,style:{cursor:"crosshair"}})]},Ce.id)})]},f.id)}),W&&W.particles.length>0&&s.jsx("g",{className:"nd-particle-overlay",children:W.particles.map((f,C)=>s.jsx("circle",{cx:f.x,cy:f.y,r:f.size,fill:f.color,opacity:f.opacity},`ptcl-${C}`))}),Me&&s.jsx("path",{d:`M ${Me.from.x} ${Me.from.y} L ${Me.to.x} ${Me.to.y}`,fill:"none",stroke:I,strokeWidth:1.5,strokeDasharray:"5,4",markerEnd:`url(#${$e})`,pointerEvents:"none"}),me&&s.jsx("rect",{x:Math.min(me.x1,me.x2),y:Math.min(me.y1,me.y2),width:Math.abs(me.x2-me.x1),height:Math.abs(me.y2-me.y1),fill:"rgba(33,150,243,0.1)",stroke:I,strokeWidth:1,strokeDasharray:"4,2"})]})]})};process.env.NODE_ENV!=="production"&&(Be.displayName="DiagramCanvas");function Ht(o,e,t){const r=o.find(c=>c.id===e);if(!r)return{x:0,y:0};const{position:i,size:a}=r,n=r.ports.find(c=>c.id===t);switch(n==null?void 0:n.side){case"top":return{x:i.x+a.width*n.offset,y:i.y};case"bottom":return{x:i.x+a.width*n.offset,y:i.y+a.height};case"left":return{x:i.x,y:i.y+a.height*n.offset};case"right":return{x:i.x+a.width,y:i.y+a.height*n.offset};default:return{x:i.x+a.width/2,y:i.y+a.height/2}}}function ur(o,e){const t=Ht(e,o.sourceNodeId,o.sourcePortId),r=Ht(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),n=(w,p)=>{var h,x;return((x=(h=e.find(z=>z.id===w))==null?void 0:h.ports.find(z=>z.id===p))==null?void 0:x.side)??null},c=(w,p,h)=>{switch(p){case"top":return{x:w.x,y:w.y-a};case"bottom":return{x:w.x,y:w.y+a};case"left":return{x:w.x-a,y:w.y};case"right":return{x:w.x+a,y:w.y};default:return{x:w.x+h,y:w.y}}},l=Math.abs(r.x-t.x)*.5,u=c(t,n(o.sourceNodeId,o.sourcePortId),l),d=c(r,n(o.targetNodeId,o.targetPortId),-l),m=w=>{const p=1-w;return{x:p*p*p*t.x+3*p*p*w*u.x+3*p*w*w*d.x+w*w*w*r.x,y:p*p*p*t.y+3*p*p*w*u.y+3*p*w*w*d.y+w*w*w*r.y}};return{d:`M ${t.x} ${t.y} C ${u.x} ${u.y}, ${d.x} ${d.y}, ${r.x} ${r.y}`,mid:m(.5),extent:Array.from({length:9},(w,p)=>m(p/8))}}}}function hi(o,e){const t=Pt(o);if(!t)return null;let[r,i,a,n]=[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),n=Math.max(n,l.y+d)};for(const l of e){const u=ur(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:n-i}}function pi(o,e){let t="",r=1/0;for(const i of o.ports){const a=fr(o,i.id),n=Math.hypot(o.position.x+a.x-e.x,o.position.y+a.y-e.y);n<r&&(r=n,t=i.id)}return t}function fr(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 gi=180,mi=120,ut=({nodes:o,edges:e,viewport:t,onViewportChange:r,canvasWidth:i=800,canvasHeight:a=600,width:n=gi,height:c=mi,className:l})=>{const u=g.useMemo(()=>{if(o.length===0)return{minX:0,minY:0,maxX:400,maxY:300};let x=1/0,z=1/0,y=-1/0,S=-1/0;for(const v of o)x=Math.min(x,v.position.x),z=Math.min(z,v.position.y),y=Math.max(y,v.position.x+v.size.width),S=Math.max(S,v.position.y+v.size.height);const b=50;return{minX:x-b,minY:z-b,maxX:y+b,maxY:S+b}},[o]),d=u.maxX-u.minX,m=u.maxY-u.minY,w=Math.min(n/d,c/m),p=g.useMemo(()=>{const x=(-t.x/t.zoom-u.minX)*w,z=(-t.y/t.zoom-u.minY)*w,y=i/t.zoom*w,S=a/t.zoom*w;return{x,y:z,w:y,h:S}},[t,u,w,i,a]),h=g.useCallback(x=>{if(!r)return;const z=x.currentTarget.getBoundingClientRect(),y=x.clientX-z.left,S=x.clientY-z.top,b=y/w+u.minX,v=S/w+u.minY;r({...t,x:-(b*t.zoom-i/2),y:-(v*t.zoom-a/2)})},[r,t,w,u,i,a]);return s.jsxs("svg",{className:`nice-diagram-minimap ${l??""}`,width:n,height:c,style:{border:"1px solid var(--nice-border, #ccc)",background:"var(--nice-bg, #fff)",borderRadius:4,cursor:"pointer"},onClick:h,children:[e.map(x=>{const z=o.find(N=>N.id===x.sourceNodeId),y=o.find(N=>N.id===x.targetNodeId);if(!z||!y)return null;const S=(z.position.x+z.size.width/2-u.minX)*w,b=(z.position.y+z.size.height/2-u.minY)*w,v=(y.position.x+y.size.width/2-u.minX)*w,D=(y.position.y+y.size.height/2-u.minY)*w;return s.jsx("line",{x1:S,y1:b,x2:v,y2:D,stroke:"var(--nice-text-muted, #aaa)",strokeWidth:.5},x.id)}),o.map(x=>s.jsx("rect",{x:(x.position.x-u.minX)*w,y:(x.position.y-u.minY)*w,width:x.size.width*w,height:x.size.height*w,fill:x.style.backgroundColor??"var(--nice-border, #ddd)",stroke:"var(--nice-text-muted, #999)",strokeWidth:.5},x.id)),s.jsx("rect",{x:p.x,y:p.y,width:p.w,height:p.h,fill:"color-mix(in srgb, var(--nice-primary, #2196f3) 15%, transparent)",stroke:"var(--nice-primary, #2196f3)",strokeWidth:1})]})};process.env.NODE_ENV!=="production"&&(ut.displayName="DiagramMinimap");const yi=["rectangle","roundedRect","ellipse","circle","diamond","hexagon","parallelogram","cylinder","triangle","cloud","document","actor"],vt=({selectedNode:o,selectedEdge:e,onNodeChange:t,onEdgeChange:r,onRemove:i,className:a})=>{var u,d,m,w,p;const{t:n}=qe(),c=g.useCallback((h,x)=>{!o||!t||t(o.id,{style:{...o.style,[h]:x}})},[o,t]),l=g.useCallback((h,x)=>{!e||!r||r(e.id,{style:{...e.style,[h]:x}})},[e,r]);return!o&&!e?s.jsx("div",{className:`nice-diagram-property-panel nice-diagram-property-panel--empty ${a??""}`,children:s.jsx("p",{className:"nice-diagram-property-panel__hint",children:n("panel.noSelection")})}):o?s.jsxs("div",{className:`nice-diagram-property-panel ${a??""}`,children:[s.jsx("h3",{className:"nice-diagram-property-panel__title",children:n("panel.nodeProperties")}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.label"),s.jsx(k.NiceTextInput,{value:o.label,onChange:h=>t==null?void 0:t(o.id,{label:h}),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.description"),s.jsx(k.NiceTextInput,{value:o.description??"",onChange:h=>t==null?void 0:t(o.id,{description:h||void 0}),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.shape"),s.jsx(k.NiceSelect,{value:o.shape,onChange:h=>t==null?void 0:t(o.id,{shape:h}),options:yi.map(h=>({value:h,label:h})),className:"nice-diagram-property-panel__select"})]}),s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.width"),s.jsx(k.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"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.height"),s.jsx(k.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"})]})]}),s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.bgColor"),s.jsx(k.NiceColorPicker,{value:o.style.backgroundColor??"var(--nice-bg, #fff)",onChange:h=>c("backgroundColor",h),className:"nice-diagram-property-panel__color"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.borderColor"),s.jsx(k.NiceColorPicker,{value:o.style.borderColor??"var(--nice-text, #333333)",onChange:h=>c("borderColor",h),className:"nice-diagram-property-panel__color"})]})]}),s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.fontSize"),s.jsx(k.NiceNumberInput,{value:o.style.fontSize??14,min:8,max:72,onChange:h=>c("fontSize",h??14),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.fontColor"),s.jsx(k.NiceColorPicker,{value:o.style.fontColor??"#222222",onChange:h=>c("fontColor",h),className:"nice-diagram-property-panel__color"})]})]}),s.jsx(k.NiceCheckbox,{checked:o.locked??!1,onChange:h=>t==null?void 0:t(o.id,{locked:h}),label:n("node.locked"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),s.jsx("h4",{className:"nice-diagram-property-panel__section-title",style:{fontSize:12,marginTop:12,marginBottom:4,color:"var(--nice-text-secondary, #666)"},children:n("node.effects","Effects")}),s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.glowColor","Glow Color"),s.jsx(k.NiceColorPicker,{value:o.style.glowColor??"var(--nice-primary, #3b82f6)",onChange:h=>c("glowColor",h),className:"nice-diagram-property-panel__color"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.glowIntensity","Glow Intensity"),s.jsx(k.NiceSlider,{min:0,max:3,step:.1,value:o.style.glowIntensity??0,onChange:h=>c("glowIntensity",h),className:"nice-diagram-property-panel__input"})]})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.opacity","Opacity"),s.jsx(k.NiceSlider,{min:0,max:1,step:.05,value:o.style.opacity??1,onChange:h=>c("opacity",h),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.borderRadius","Border Radius"),s.jsx(k.NiceNumberInput,{min:0,max:50,value:o.style.borderRadius??4,onChange:h=>c("borderRadius",h??4),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.borderWidth","Border Width"),s.jsx(k.NiceNumberInput,{min:0,max:10,step:.5,value:o.style.borderWidth??1,onChange:h=>c("borderWidth",h??1),className:"nice-diagram-property-panel__input"})]}),s.jsx(k.NiceCheckbox,{checked:o.style.shadow??!1,onChange:h=>c("shadow",h),label:n("node.shadow","Shadow"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.gradientEnd","Gradient End"),s.jsx(k.NiceColorPicker,{value:o.style.gradientColor??"var(--nice-bg, #fff)",onChange:h=>c("gradientColor",h),className:"nice-diagram-property-panel__color"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.gradientDir","Gradient Dir"),s.jsx(k.NiceSelect,{value:o.style.gradientDirection??"vertical",onChange:h=>c("gradientDirection",h),options:[{value:"vertical",label:n("node.vertical","Vertical")},{value:"horizontal",label:n("node.horizontal","Horizontal")},{value:"diagonal",label:n("node.diagonal","Diagonal")},{value:"radial",label:n("node.radial","Radial")}],className:"nice-diagram-property-panel__select"})]})]}),s.jsx(k.NiceCheckbox,{checked:o.hidden??!1,onChange:h=>t==null?void 0:t(o.id,{hidden:h}),label:n("node.hiddenGhostInEditor","Hidden (ghost in editor)"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),s.jsx(k.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:n("toolbar.delete")})]}):e?s.jsxs("div",{className:`nice-diagram-property-panel ${a??""}`,children:[s.jsx("h3",{className:"nice-diagram-property-panel__title",children:n("panel.edgeProperties")}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("edge.label"),s.jsx(k.NiceTextInput,{value:e.label??"",onChange:h=>r==null?void 0:r(e.id,{label:h||void 0}),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("edge.lineType"),s.jsx(k.NiceSelect,{value:e.style.lineType??"bezier",onChange:h=>l("lineType",h),options:[{value:"straight",label:n("node.straight","Straight")},{value:"bezier",label:n("node.bezier","Bezier")},{value:"orthogonal",label:n("node.orthogonal","Orthogonal")},{value:"step",label:n("node.step","Step")}],className:"nice-diagram-property-panel__select"})]}),s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("edge.color"),s.jsx(k.NiceColorPicker,{value:e.style.strokeColor??"var(--nice-text, #333333)",onChange:h=>l("strokeColor",h),className:"nice-diagram-property-panel__color"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("edge.width"),s.jsx(k.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"})]})]}),s.jsx(k.NiceCheckbox,{checked:e.style.animated??!1,onChange:h=>l("animated",h),label:n("edge.animated"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),e.style.animated&&s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.flowSpeed","Flow Speed"),s.jsx(k.NiceSlider,{min:.1,max:5,step:.1,value:e.style.flowSpeed??1,onChange:h=>l("flowSpeed",h),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.dashStyle","Dash Style"),s.jsx(k.NiceSelect,{value:e.style.strokeDash?e.style.strokeDash.join(","):"solid",onChange:h=>{const x=h;x==="solid"?l("strokeDash",[]):l("strokeDash",x.split(",").map(Number))},options:[{value:"solid",label:n("node.solid","Solid")},{value:"6,4",label:n("node.dashed","Dashed")},{value:"2,2",label:n("node.dotted","Dotted")},{value:"8,4,2,4",label:n("node.dashDot","Dash-Dot")},{value:"12,6",label:n("node.longDash","Long Dash")}],className:"nice-diagram-property-panel__select"})]}),s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.targetArrow","Target Arrow"),s.jsx(k.NiceSelect,{value:e.style.targetArrow??"arrow",onChange:h=>l("targetArrow",h),options:[{value:"arrow",label:n("node.arrow","Arrow")},{value:"openArrow",label:n("node.openArrow","Open Arrow")},{value:"diamond",label:n("node.diamond","Diamond")},{value:"circle",label:n("node.circle","Circle")},{value:"none",label:n("node.none","None")}],className:"nice-diagram-property-panel__select"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.sourceArrow","Source Arrow"),s.jsx(k.NiceSelect,{value:e.style.sourceArrow??"none",onChange:h=>l("sourceArrow",h),options:[{value:"none",label:n("node.none","None")},{value:"arrow",label:n("node.arrow","Arrow")},{value:"openArrow",label:n("node.openArrow","Open Arrow")},{value:"diamond",label:n("node.diamond","Diamond")},{value:"circle",label:n("node.circle","Circle")}],className:"nice-diagram-property-panel__select"})]})]}),s.jsx("h4",{className:"nice-diagram-property-panel__section-title",style:{fontSize:12,marginTop:12,marginBottom:4,color:"var(--nice-text-secondary, #666)"},children:n("node.liquidFlow","Liquid Flow")}),s.jsx(k.NiceCheckbox,{checked:((u=e.style.liquidFlow)==null?void 0:u.active)??!1,onChange:h=>{const x=e.style.liquidFlow??{active:!1,color:"var(--nice-primary, #3b82f6)",speed:1,pipeWidth:6};r==null||r(e.id,{style:{...e.style,liquidFlow:{...x,active:h}}})},label:n("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)&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.color","Color"),s.jsx(k.NiceColorPicker,{value:((m=e.style.liquidFlow)==null?void 0:m.color)??"var(--nice-primary, #3b82f6)",onChange:h=>{const x=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...x,color:h}}})},className:"nice-diagram-property-panel__color"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.speed","Speed"),s.jsx(k.NiceSlider,{min:.1,max:5,step:.1,value:((w=e.style.liquidFlow)==null?void 0:w.speed)??1,onChange:h=>{const x=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...x,speed:h}}})},className:"nice-diagram-property-panel__input"})]})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.pipeWidth","Pipe Width"),s.jsx(k.NiceNumberInput,{min:2,max:20,value:((p=e.style.liquidFlow)==null?void 0:p.pipeWidth)??6,onChange:h=>{const x=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...x,pipeWidth:h??6}}})},className:"nice-diagram-property-panel__input"})]})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.opacity","Opacity"),s.jsx(k.NiceSlider,{min:0,max:1,step:.05,value:e.style.opacity??1,onChange:h=>l("opacity",h),className:"nice-diagram-property-panel__input"})]}),s.jsx(k.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:n("toolbar.delete")})]}):null};process.env.NODE_ENV!=="production"&&(vt.displayName="DiagramPropertyPanel");const Ut={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"]},bi=[["dagre","list-ordered"],["tree","git-branch"],["forceDirected","shuffle"],["radial","target"],["grid","grid"]],wi=["sans-serif","serif","monospace","Arial","Helvetica","Times New Roman","Courier New","Georgia","Verdana","Tahoma","Trebuchet MS"],xi=[8,9,10,11,12,14,16,18,20,24,28,32,36,48,72],vi=["home","insert","format","view"],ki={home:"Home",insert:"Insert",format:"Format",view:"View"},kt=({activeTool:o,onToolChange:e,diagramType:t,onAddNode:r,onApplyLayout:i,onUndo:a,onRedo:n,canUndo:c=!1,canRedo:l=!1,onExport:u,onZoomIn:d,onZoomOut:m,onZoomReset:w,zoomLevel:p=1,onToggleBold:h,onToggleItalic:x,isBold:z=!1,isItalic:y=!1,onFontFamilyChange:S,currentFontFamily:b="sans-serif",onFontSizeChange:v,currentFontSize:D=14,onAlignLeft:N,onAlignCenterH:K,onAlignRight:G,onAlignTop:L,onAlignCenterV:W,onAlignBottom:A,onDistributeH:B,onDistributeV:O,onBringToFront:H,onSendToBack:M,onGroupSelected:R,onUngroupSelected:F,onCopy:q,onPaste:Y,onDuplicate:Z,onSelectAll:J,selectionCount:ee=0,onFind:ue,showFind:fe=!1,findQuery:Se="",onFindQueryChange:$e,viewMode:Ee="editor",onViewModeChange:xe,stylePresetId:Ge,onStylePresetChange:Me,defaultTab:Je="home",propertiesOpen:Ve=!0,onToggleProperties:Ye,className:Xe})=>{const{t:U}=qe(),[_e,Ke]=g.useState(Je),[Pe,tt]=g.useState(!1),[me,ge]=g.useState(!1),Oe=g.useRef(null);k.useRovingFocus(Oe,{orientation:"horizontal",itemSelector:".nice-diagram-toolbar__tab"});const E=Ut[t]??Ut.custom,$=(X,Ie,ze,st,Re={})=>st?s.jsx(k.NiceButton,{className:"nice-diagram-toolbar__btn",variant:Re.active?"primary":"ghost",size:"sm",onClick:st,disabled:Re.disabled,title:ze,"aria-label":ze,"aria-pressed":Re.active===void 0?void 0:Re.active,children:typeof Ie=="string"?s.jsx(k.NiceIcon,{name:Ie,size:16}):Ie},X):null,se=(X,Ie,ze)=>$(X,Ie,ze,()=>e(X),{active:o===X}),pe={home:[{id:"tools",label:U("toolbar.section.tools","Tools"),items:[se("select","cursor",`${U("toolbar.select")} (V)`),se("pan","move",`${U("toolbar.pan")} (H)`),se("addEdge","link",`${U("toolbar.addEdge")} (C)`),se("text","type",U("toolbar.textT","Text (T)")),se("freehand","pen",U("toolbar.freehandF","Freehand (F)")),se("delete","trash",`${U("toolbar.delete")} (Del)`)]},{id:"clipboard",label:U("toolbar.section.clipboard","Clipboard"),items:[$("copy","copy",U("toolbar.copyCtrlC","Copy (Ctrl+C)"),q),$("paste","clipboard",U("toolbar.pasteCtrlV","Paste (Ctrl+V)"),Y),$("dup","layers",U("toolbar.duplicateCtrlD","Duplicate (Ctrl+D)"),Z),$("all","check-square",U("toolbar.selectAllCtrlA","Select All (Ctrl+A)"),J)]},{id:"history",label:U("toolbar.section.history","History"),items:[$("undo","undo",`${U("toolbar.undo")} (Ctrl+Z)`,a,{disabled:!c}),$("redo","redo",`${U("toolbar.redo")} (Ctrl+Y)`,n,{disabled:!l})]}],insert:[{id:"shapes",label:U("toolbar.section.shapes","Shapes"),items:E.map(X=>$(X,Ci(X),`${U("toolbar.addNode")}: ${U(`shape.${X}`,X)}`,r&&(()=>r(X))))},{id:"layout",label:U("toolbar.layout"),items:bi.map(([X,Ie])=>$(X,Ie,U(`layout.${X}`),i&&(()=>i(X))))}],format:[{id:"text",label:U("toolbar.section.text","Text"),items:[S?s.jsx(k.NiceSelect,{className:"nice-diagram-toolbar__font-select",value:b,onChange:X=>S(X),options:wi.map(X=>({value:X,label:X})),title:U("toolbar.fontFamily","Font Family")},"family"):null,v?s.jsx(k.NiceSelect,{className:"nice-diagram-toolbar__size-select",value:String(D),onChange:X=>v(Number(X)),options:xi.map(X=>({value:String(X),label:String(X)})),title:U("toolbar.fontSize","Font Size")},"size"):null,$("bold",s.jsx("strong",{children:"B"}),U("toolbar.boldCtrlB","Bold (Ctrl+B)"),h,{active:z}),$("italic",s.jsx("em",{children:"I"}),U("toolbar.italicCtrlI","Italic (Ctrl+I)"),x,{active:y})]},{id:"align",label:U("toolbar.align","Align"),items:[$("al","align-left",U("toolbar.alignLeft","Align Left"),N),$("ac","align-center",U("toolbar.alignCenter","Align Center"),K),$("ar","align-right",U("toolbar.alignRight","Align Right"),G),$("at","align-top",U("toolbar.alignTop","Align Top"),L),$("am","align-middle",U("toolbar.alignMiddle","Align Middle"),W),$("ab","align-bottom",U("toolbar.alignBottom","Align Bottom"),A),$("dh","distribute-h",U("toolbar.distributeHorizontally","Distribute Horizontally"),B),$("dv","distribute-v",U("toolbar.distributeVertically","Distribute Vertically"),O)]},{id:"arrange",label:U("toolbar.arrange","Arrange"),items:[$("front","arrow-up",U("toolbar.bringToFront","Bring to Front"),H),$("back","arrow-down",U("toolbar.sendToBack","Send to Back"),M),$("group","group",U("toolbar.group","Group"),R,{disabled:ee<2}),$("ungroup","ungroup",U("toolbar.ungroup","Ungroup"),F)]},{id:"style",label:U("toolbar.style","Style"),items:[Me?s.jsxs("div",{className:"nice-diagram-toolbar__group--relative",children:[$("presets","palette",U("toolbar.stylePresets","Style Presets"),()=>ge(X=>!X)),me&&s.jsx("div",{className:"nice-diagram-toolbar__dropdown nice-diagram-toolbar__dropdown--presets",children:Object.entries(wt.reduce((X,Ie)=>{const ze=Ie.category??"Other";return(X[ze]??(X[ze]=[])).push(Ie),X},{})).map(([X,Ie])=>s.jsxs("div",{children:[s.jsx("div",{className:"nice-diagram-toolbar__dropdown-section",children:X}),Ie.map(ze=>s.jsxs(k.NiceButton,{className:`nice-diagram-toolbar__dropdown-item ${Ge===ze.id?"nice-diagram-toolbar__dropdown-item--active":""}`,variant:Ge===ze.id?"primary":"ghost",size:"sm",onClick:()=>{Me(ze.id),ge(!1)},children:[s.jsx("span",{className:"nice-diagram-toolbar__preset-swatch",style:{background:ze.config.palette.primary,borderColor:ze.config.palette.border}}),ze.name]},ze.id))]},X))})]},"presets"):null]}],view:[{id:"zoom",label:U("toolbar.section.zoom","Zoom"),items:[$("zoomOut","zoom-out",U("toolbar.zoomOut"),m),d||m?s.jsxs("span",{className:"nice-diagram-toolbar__zoom-label",children:[Math.round(p*100),"%"]},"zoom"):null,$("zoomIn","zoom-in",U("toolbar.zoomIn"),d),$("zoomReset","expand",U("toolbar.zoomReset"),w)]},{id:"find",label:U("toolbar.section.find","Find"),items:[$("find","search",U("toolbar.findCtrlF","Find (Ctrl+F)"),ue,{active:fe}),ue&&fe?s.jsx(k.NiceTextInput,{className:"nice-diagram-toolbar__search",placeholder:U("toolbar.searchNodes","Search nodes…"),value:Se,onChange:X=>$e==null?void 0:$e(X),autoFocus:!0},"query"):null]},{id:"mode",label:U("toolbar.section.mode","Mode"),items:xe?[$("editor","edit",U("toolbar.editorMode","Editor Mode"),()=>xe("editor"),{active:Ee==="editor"}),$("player","play",U("toolbar.playerMode","Player Mode"),()=>xe("player"),{active:Ee==="player"}),$("animated","zap",U("toolbar.animatedPlayerMode","Animated Player Mode"),()=>xe("playerAnimated"),{active:Ee==="playerAnimated"})]:[]},{id:"export",label:U("toolbar.export"),items:[u?s.jsxs("div",{className:"nice-diagram-toolbar__group--relative",children:[$("export","download",U("toolbar.export"),()=>tt(X=>!X)),Pe&&s.jsx("div",{className:"nice-diagram-toolbar__dropdown",children:["ndd","svg","mermaid","png"].map(X=>s.jsx(k.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{u(X),tt(!1)},children:X==="ndd"?".ndd.json":X==="mermaid"?U("toolbar.mermaid","Mermaid"):X.toUpperCase()},X))})]},"export"):null]}]},ke=X=>X.filter(Ie=>Ie.items.some(Boolean)),Fe=vi.filter(X=>ke(pe[X]).length>0),rt=Fe.includes(_e)?_e:Fe[0]??"home";return s.jsxs("div",{className:`nice-diagram-toolbar ${Xe??""}`,children:[s.jsxs("div",{ref:Oe,className:"nice-diagram-toolbar__tabs",role:"tablist",children:[Fe.map(X=>s.jsx("button",{type:"button",role:"tab","aria-selected":rt===X,className:"nice-diagram-toolbar__tab",onClick:()=>Ke(X),children:U(`toolbar.tab.${X}`,ki[X])},X)),s.jsxs("span",{className:"nice-diagram-toolbar__tabs-end",children:[ee>1&&s.jsx("span",{className:"nice-diagram-toolbar__selection-info",children:U("toolbar.selected","{selectionCount} selected").replace("{selectionCount}",String(ee))}),$("properties","columns",U("toolbar.properties","Properties panel"),Ye,{active:Ve})]})]}),s.jsx("div",{className:"nice-diagram-toolbar__row",role:"tabpanel",children:ke(pe[rt]).map(X=>s.jsxs("div",{className:"nice-diagram-toolbar__section",role:"group","aria-label":X.label,children:[s.jsx("div",{className:"nice-diagram-toolbar__group",children:X.items}),s.jsx("span",{className:"nice-diagram-toolbar__section-label","aria-hidden":"true",children:X.label})]},X.id))})]})};process.env.NODE_ENV!=="production"&&(kt.displayName="DiagramToolbar");function Ci(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 Si=[{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"}],hr=({initialDocument:o,document:e,nodeTypes:t,autoLayout:r,fitOnMount:i=!1,readOnly:a=!1,diagramType:n="flowchart",onChange:c,onExport:l,lang:u,showToolbar:d=!0,showPropertyPanel:m=!0,defaultPropertiesOpen:w=!0,showMinimap:p=!0,showTimeline:h=!0,className:x,style:z,tutorial:y})=>{var Oe;const{t:S}=k.useNiceTranslation(),b=cr(e??o),[v,D]=g.useState("select"),[N,K]=g.useState(null),[G,L]=g.useState(w),W=g.useRef(null),[A,B]=g.useState("editor"),O=g.useRef(null),[H,M]=g.useState({particles:[],liquidFlows:new Map,glowStates:new Map});g.useEffect(()=>{const E=new tr($=>{M($)});return O.current=E,E.start(),()=>{E.stop(),O.current=null}},[]),g.useEffect(()=>{var $;const E=O.current;if(E)for(const se of b.edges)($=se.style.liquidFlow)!=null&&$.active?E.startLiquidFlow(se.id,se.style.liquidFlow):E.stopLiquidFlow(se.id)},[b.edges]),g.useEffect(()=>{const E=O.current;if(E)for(const $ of b.nodes)$.style.glowColor?E.setGlow($.id,$.style.glowColor,$.style.glowIntensity??1):E.removeGlow($.id)},[b.nodes]);const R=g.useCallback(E=>{b.setStylePreset(E)},[b]),F=g.useCallback((E,$)=>{const se=b.nodes.find(ke=>ke.id===E);if(!(se!=null&&se.interactions))return;const pe=se.interactions.find(ke=>ke.id===$);if(pe)switch(pe.action){case"reveal":{if(pe.targetId){const ke=b.nodes.find(Fe=>Fe.id===pe.targetId);ke!=null&&ke.hidden&&b.updateNode(pe.targetId,{hidden:!1})}break}case"navigate":{if(pe.targetId){const ke=b.nodes.find(Fe=>Fe.id===pe.targetId);ke&&(b.setViewport({x:-ke.position.x+300,y:-ke.position.y+200,zoom:b.viewport.zoom}),K(pe.targetId))}break}case"switchAnimationMode":{pe.targetId&&b.setActiveAnimationMode(pe.targetId);break}case"highlight":{pe.targetId&&K(pe.targetId);break}case"toggleCollapse":{b.toggleNodeCollapse(E);break}}},[b]),q=g.useRef(c);g.useEffect(()=>{q.current=c});const Y=g.useRef(b.revision);g.useEffect(()=>{var E;b.revision!==Y.current&&(Y.current=b.revision,(E=q.current)==null||E.call(q,b.document))},[b.revision,b.document]);const Z=b.model;g.useEffect(()=>{e&&e!==Z.getDocument()&&Z.loadDocument(e)},[e,Z]);const J=`${b.nodes.map(E=>E.id).join(",")}|${b.edges.map(E=>`${E.sourceNodeId}>${E.targetNodeId}`).join(",")}`,ee=g.useMemo(()=>r?r===!0?{algorithm:"dagre",direction:"LR",nodeSpacing:40,rankSpacing:80}:r:null,[r]),ue=b.applyLayout;g.useEffect(()=>{ee&&ue(ee,{history:!1})},[J,ee,ue]);const fe=g.useCallback((E,$,se,pe)=>{b.addEdge(E,se??"right",$,pe??"left")},[b]),Se=g.useCallback(E=>{const $=b.viewport,se=b.addNode(E.label,{x:(-$.x+400)/$.zoom,y:(-$.y+300)/$.zoom},E.shape,E.size);b.updateNode(se.id,{style:{...E.style},...E.icon?{icon:E.icon}:{},...E.description?{description:E.description}:{},...E.ports?{ports:E.ports.map(pe=>({...pe}))}:{},data:{...se.data,nodeType:E.id}}),K(se.id),D("select")},[b]),[$e,Ee]=g.useState(0),xe=g.useMemo(()=>N?b.nodes.find(E=>E.id===N)??null:null,[N,b.nodes]),Ge=g.useMemo(()=>N?b.edges.find(E=>E.id===N)??null:null,[N,b.edges]),Me=g.useCallback(E=>{const $=b.viewport,se=(-$.x+400)/$.zoom,pe=(-$.y+300)/$.zoom,ke=b.addNode("New Node",{x:se,y:pe},E);K(ke.id),D("select")},[b]),Je=g.useCallback(E=>{b.applyLayout({algorithm:E,centerGraph:!0})},[b]),Ve=g.useCallback((E,$)=>{b.moveNode(E,$)},[b]),Ye=g.useCallback((E,$)=>{b.moveNode(E,$)},[b]),Xe=g.useCallback(E=>{b.nodes.find($=>$.id===E)?b.removeNode(E):b.edges.find($=>$.id===E)&&b.removeEdge(E),K(null)},[b]),U=g.useCallback(E=>{const $=b.document;let se;switch(E){case"ndd":se=sr($,!0);break;case"svg":se=At($);break;case"mermaid":se=ir($);break;case"png":se=At($);break}l==null||l(E,se)},[b,l]),_e=g.useCallback(()=>{b.setViewport({...b.viewport,zoom:Math.min(5,b.viewport.zoom*1.2)})},[b]),Ke=g.useCallback(()=>{b.setViewport({...b.viewport,zoom:Math.max(.1,b.viewport.zoom/1.2)})},[b]),Pe=g.useCallback(()=>{i?Ee(E=>E+1):b.setViewport({x:0,y:0,zoom:1})},[b,i]),tt=g.useMemo(()=>[...b.nodes.map(E=>({id:E.id,label:E.label,type:"node"})),...b.edges.map(E=>({id:E.id,label:E.label??E.id,type:"edge"}))],[b.nodes,b.edges]),me=d&&!a||b.animationModes.length>0?s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,width:"100%"},children:[d&&!a&&s.jsx(kt,{activeTool:v,onToolChange:D,diagramType:b.document.diagramType,onAddNode:Me,onApplyLayout:Je,onUndo:b.undo,onRedo:b.redo,canUndo:b.canUndo,canRedo:b.canRedo,onExport:U,onZoomIn:_e,onZoomOut:Ke,onZoomReset:Pe,zoomLevel:b.viewport.zoom,viewMode:A,onViewModeChange:B,stylePresetId:b.stylePresetId,onStylePresetChange:R,propertiesOpen:G,onToggleProperties:m?()=>L(E=>!E):void 0}),t&&t.length>0&&!a&&s.jsx("div",{className:"nice-diagram-editor__node-types",role:"group","aria-label":S("diagramEditor.nodeTypes","Add a node"),style:{display:"flex",flexWrap:"wrap",gap:4,padding:"4px 8px"},children:t.map(E=>s.jsx(k.NiceButton,{variant:"ghost",size:"sm",leftIcon:s.jsx(k.NiceIcon,{name:E.icon??"plus",size:14}),onClick:()=>Se(E),children:E.label},E.id))}),b.animationModes.length>0&&s.jsxs("div",{className:"nice-diagram-editor__mode-tabs",style:{display:"flex",gap:4,padding:"4px 8px",fontSize:12,alignItems:"center"},children:[s.jsx("span",{style:{color:"var(--nice-text-secondary, #888)",marginRight:4},children:S("diagramEditor.modes","Modes:")}),b.animationModes.map(E=>{var $;return s.jsx(k.NiceButton,{variant:(($=b.activeAnimationMode)==null?void 0:$.id)===E.id?"primary":"ghost",size:"sm",onClick:()=>b.setActiveAnimationMode(E.id),style:{padding:"2px 10px",fontSize:11},children:E.name},E.id)}),s.jsx(k.NiceButton,{variant:"ghost",size:"sm",onClick:()=>b.addAnimationMode(`Mode ${b.animationModes.length+1}`),style:{padding:"2px 8px",fontSize:11,color:"var(--nice-text-secondary, #888)"},title:S("diagramEditor.addAnimationMode","Add animation mode"),children:"+"})]})]}):void 0,ge=s.jsxs(k.NiceAppShell,{ref:W,flush:!0,className:`nice-diagram-editor ${x??""}`,style:{position:"relative",...z},toolbar:me,rightSidebar:m&&G&&!a?s.jsx("div",{className:"nice-diagram-editor__panel",style:{width:260,overflowY:"auto",height:"100%"},children:s.jsx(vt,{selectedNode:xe,selectedEdge:Ge,onNodeChange:b.updateNode,onEdgeChange:b.updateEdge,onRemove:Xe})}):void 0,bottomPanel:h?s.jsx("div",{className:"nice-diagram-editor__timeline",children:s.jsx(xt,{animations:b.animations,onAdd:b.addAnimation,onRemove:b.removeAnimation,availableTargets:tt})}):void 0,children:[s.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:s.jsx(k.NiceTutorialButton,{steps:k.resolveTutorial(y,Si)})}),s.jsxs("div",{className:"nice-diagram-editor__canvas",style:{height:"100%",position:"relative"},children:[s.jsx(Be,{nodes:b.nodes,edges:b.edges,groups:b.groups,viewport:b.viewport,onViewportChange:b.setViewport,selectedId:N,onSelectElement:K,onNodeDrag:ee||a?void 0:Ve,onNodeDragEnd:ee||a?void 0:Ye,onEdgeCreate:a?void 0:fe,autoFit:i,fitKey:ee?J:void 0,refitKey:$e,interactive:A==="editor"&&!a,showGrid:A==="editor",particleState:H,viewMode:A,ghostOpacity:((Oe=b.playerConfig)==null?void 0:Oe.ghostOpacity)??.3,onGroupCollapse:b.toggleGroupCollapse,onNodeCollapse:b.toggleNodeCollapse,onInteraction:F}),p&&s.jsx("div",{style:{position:"absolute",bottom:8,left:8},children:s.jsx(ut,{nodes:b.nodes,edges:b.edges,viewport:b.viewport,onViewportChange:b.setViewport})})]})]});return u?s.jsx(Dt,{locale:u,children:ge}):ge};process.env.NODE_ENV!=="production"&&(hr.displayName="NiceDiagramEditor");const Xt={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 pr(o){return Xt[o]??Xt.linear}const gr={opacity:1,scale:1,translateX:0,translateY:0,glow:0,highlightColor:"",strokeProgress:1,rippleRadius:0,rippleOpacity:0,typewriterChars:-1,liquidFillProgress:-1,particleTrailT:-1};class mr{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 n=a.startMs+(a.delayMs??0);n+a.durationMs;const c=a.repeat??0;let l=r-n;if(l<0){this.stateMap.set(a.targetId,Ii(a)),i=!0;continue}if(c===-1)l=l%a.durationMs,i=!0;else if(c>0){const w=a.durationMs*(c+1);if(l>w)continue;l=l%a.durationMs,i=!0}else{if(l>a.durationMs)continue;i=!0}const u=Math.min(l/a.durationMs,1),d=pr(a.easing)(u),m=Mi(a,d);this.stateMap.set(a.targetId,m)}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 Mi(o,e){const t={...gr};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 Ii(o){const e={...gr};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 zi(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 Ai(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 _i(o){if(o)return{backgroundColor:o.fill,borderColor:o.stroke,borderWidth:o.strokeWidth}}function yr(o){return{id:o.id,label:o.label,position:{x:o.x,y:o.y},size:{width:o.width,height:o.height},shape:zi(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 br(o,e){var n,c;const t=e.find(l=>l.id===o.source),r=e.find(l=>l.id===o.target),i=o.sourcePort||((n=t==null?void 0:t.ports[0])==null?void 0:n.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:Ai(o.style),data:o.data}}function wr(o){return{id:o.id,label:o.label,nodeIds:o.nodeIds,style:_i(o.style)}}function xr(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 et(o){const e=o.nodes.map(yr);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=>br(t,e)),groups:(o.groups||[]).map(wr),animations:(o.animations||[]).map(xr),viewport:{x:0,y:0,zoom:1},metadata:{createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),...o.metadata}}}const Di=et({id:"empty",title:"",diagramType:"flowchart",nodes:[],edges:[]}),Et=({document:o=Di,lang:e="en",autoPlay:t=!1,showControls:r,showGrid:i,showWorkspace:a=!1,autoFit:n=!0,className:c,style:l})=>{const u=r??a,d=i??a,m=g.useMemo(()=>{var W;return a||(W=o.theme)!=null&&W.canvasBackground?o.theme:{...o.theme,canvasBackground:"transparent"}},[a,o.theme]),[w,p]=g.useState(0),[h,x]=g.useState({...o.viewport}),[z,y]=g.useState(new Map),[S,b]=g.useState(!1),v=g.useRef(null),D=g.useCallback(()=>{v.current&&v.current.stop();const W=new mr(o.animations,A=>{y(new Map(A)),W.isPlaying()||b(!1)});v.current=W,W.play(),b(!0)},[o.animations]),N=g.useCallback(()=>{var W;(W=v.current)==null||W.stop(),b(!1),y(new Map)},[]);g.useEffect(()=>(t&&o.animations.length>0&&D(),()=>{var W;(W=v.current)==null||W.stop()}),[t]);const K=g.useCallback(()=>x(W=>({...W,zoom:Math.min(5,W.zoom*1.2)})),[]),G=g.useCallback(()=>x(W=>({...W,zoom:Math.max(.1,W.zoom/1.2)})),[]),L=g.useCallback(()=>{n?p(W=>W+1):x({x:0,y:0,zoom:1})},[n]);return s.jsx(Dt,{locale:e,children:s.jsxs("div",{className:`nice-diagram-viewer ${c??""}`,style:{display:"flex",flexDirection:"column",height:"100%",...l},children:[u&&s.jsx(ji,{isPlaying:S,hasAnimations:o.animations.length>0,onPlay:D,onStop:N,onZoomIn:K,onZoomOut:G,onZoomReset:L}),s.jsx("div",{style:{flex:1,position:"relative"},children:s.jsx(Be,{nodes:o.nodes,edges:o.edges,groups:o.groups,viewport:h,onViewportChange:x,theme:m,animationStates:z,interactive:!1,showGrid:d,autoFit:n,fitKey:o.id,refitKey:w})})]})})};process.env.NODE_ENV!=="production"&&(Et.displayName="NiceDiagramViewer");const ji=({isPlaying:o,hasAnimations:e,onPlay:t,onStop:r,onZoomIn:i,onZoomOut:a,onZoomReset:n})=>{const{t:c}=qe();return s.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?s.jsxs(k.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:r,children:[s.jsx(k.NiceIcon,{name:"stop",size:14})," ",c("animation.stop")]}):s.jsxs(k.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:t,children:[s.jsx(k.NiceIcon,{name:"play",size:14})," ",c("animation.play")]})),s.jsx("span",{style:{flex:1}}),s.jsx(k.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:i,"aria-label":c("animation.zoomIn","Zoom in"),children:s.jsx(k.NiceIcon,{name:"plus",size:14})}),s.jsx(k.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:a,"aria-label":c("animation.zoomOut","Zoom out"),children:s.jsx(k.NiceIcon,{name:"minus",size:14})}),s.jsx(k.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:n,children:"1:1"})]})},Ti="_cell_95fwm_9",$i="_expandable_95fwm_29",Pi="_svg_95fwm_57",Ri="_emptyText_95fwm_67",Ei="_badge_95fwm_79",Oi="_expandIcon_95fwm_117",Fi="_modalOverlay_95fwm_169",Li="_modalContent_95fwm_217",Wi="_modalHeader_95fwm_267",Bi="_modalTitle_95fwm_285",Vi="_modalClose_95fwm_299",qi="_modalBody_95fwm_337",Gi="_modalSvg_95fwm_357",Yi="_modalFooter_95fwm_371",Hi="_modalInfo_95fwm_389",Te={cell:Ti,expandable:$i,svg:Pi,emptyText:Ri,badge:Ei,expandIcon:Oi,modalOverlay:Fi,modalContent:Li,modalHeader:Wi,modalTitle:Bi,modalClose:Vi,modalBody:qi,modalSvg:Gi,modalFooter:Yi,modalInfo:Hi},Ui=120,Xi=48,Ki=4,Kt={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 Ot(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 n=a.position.x,c=a.position.y,l=a.position.x+a.size.width,u=a.position.y+a.size.height;n<e&&(e=n),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 vr(o){var t;if((t=o.style)!=null&&t.backgroundColor)return o.style.backgroundColor;const e=o.shape??"default";return Kt[e]??Kt.default}function kr(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,n=r.position.x+r.size.width/2,c=r.position.y+r.size.height/2;return`M ${i} ${a} L ${n} ${c}`}function Zi(o,e){const t=Ot(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 Ji=({document:o,onClose:e})=>{const{t}=qe(),r=Ot(o.nodes),i=40,a=r.width+i*2,n=r.height+i*2,c=g.useMemo(()=>new Map(o.nodes.map(l=>[l.id,l])),[o.nodes]);return s.jsx("div",{role:"presentation",className:Te.modalOverlay,onClick:e,children:s.jsxs("div",{role:"presentation",className:Te.modalContent,onClick:l=>l.stopPropagation(),children:[s.jsxs("div",{className:Te.modalHeader,children:[s.jsx("h3",{className:Te.modalTitle,children:o.title||t("diagramCellRenderer.diagram","Diagram")}),s.jsx("button",{className:Te.modalClose,onClick:e,children:s.jsx(k.NiceIcon,{name:"close",size:20})})]}),s.jsx("div",{className:Te.modalBody,children:s.jsxs("svg",{viewBox:`${r.minX-i} ${r.minY-i} ${a} ${n}`,className:Te.modalSvg,children:[o.edges.map(l=>{var d,m,w;const u=kr(l,c);return u?s.jsx("path",{d:u,stroke:((d=l.style)==null?void 0:d.strokeColor)??"var(--nice-text-secondary, #64748b)",strokeWidth:((m=l.style)==null?void 0:m.strokeWidth)??1.5,fill:"none",markerEnd:(w=l.style)!=null&&w.targetArrow&&l.style.targetArrow!=="none"?"url(#arrowhead-modal)":void 0},l.id):null}),o.nodes.map(l=>{var u,d;return s.jsxs("g",{children:[s.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:vr(l),stroke:((d=l.style)==null?void 0:d.borderColor)??"var(--nice-text, #1e293b)",strokeWidth:1}),s.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)}),s.jsx("defs",{children:s.jsx("marker",{id:"arrowhead-modal",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"var(--nice-text-secondary, #64748b)"})})})]})}),s.jsx("div",{className:Te.modalFooter,children:s.jsx("span",{className:Te.modalInfo,children:t("diagramCellRenderer.nodesEdges","{nodes} nodes • {edges} edges").replace("{nodes}",String(o.nodes.length)).replace("{edges}",String(o.edges.length))})})]})})},Qi=({document:o,nodes:e,edges:t,width:r=Ui,height:i=Xi,showCount:a=!0,expandable:n=!0,onExpand:c,padding:l=Ki,backgroundColor:u="transparent",borderRadius:d=4,showLabels:m=!1,edgeColor:w="var(--nice-text-muted, #94a3b8)",tooltip:p})=>{const{t:h}=qe(),[x,z]=g.useState(!1),y=g.useMemo(()=>o||(e||t?Zi(e??[],t??[]):null),[o,e,t]),S=g.useMemo(()=>y?new Map(y.nodes.map(G=>[G.id,G])):new Map,[y]),{bounds:b,scale:v,translateX:D,translateY:N}=g.useMemo(()=>{if(!y||y.nodes.length===0)return{bounds:{minX:0,minY:0,width:100,height:100},scale:1,translateX:0,translateY:0};const G=Ot(y.nodes),L=r-l*2,W=i-l*2,A=L/G.width,B=W/G.height,O=Math.min(A,B,1),H=G.width*O,M=G.height*O,R=(r-H)/2-G.minX*O,F=(i-M)/2-G.minY*O;return{bounds:G,scale:O,translateX:R,translateY:F}},[y,r,i,l]),K=g.useCallback(()=>{!y||!n||(c?c(y):z(!0))},[y,n,c]);return!y||y.nodes.length===0?s.jsx("div",{className:Te.cell,style:{width:r,height:i,backgroundColor:u,borderRadius:d},title:p,children:s.jsx("span",{className:Te.emptyText,children:"—"})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{role:"button",tabIndex:0,onKeyDown:k.clickOnActivationKey,className:`${Te.cell} ${n?Te.expandable:""}`,style:{width:r,height:i,backgroundColor:u,borderRadius:d},onClick:K,title:p??h("diagramCellRenderer.nodesEdges2","{nodes} nodes, {edges} edges").replace("{nodes}",String(y.nodes.length)).replace("{edges}",String(y.edges.length)),children:[s.jsx("svg",{width:r,height:i,viewBox:`0 0 ${r} ${i}`,className:Te.svg,children:s.jsxs("g",{transform:`translate(${D}, ${N}) scale(${v})`,children:[y.edges.map(G=>{const L=kr(G,S);return L?s.jsx("path",{d:L,stroke:w,strokeWidth:1/v,fill:"none"},G.id):null}),y.nodes.map(G=>{const L=vr(G);return s.jsxs("g",{children:[s.jsx("rect",{x:G.position.x,y:G.position.y,width:G.size.width,height:G.size.height,rx:Math.min(4,G.size.width/4),fill:L}),m&&v>.3&&s.jsx("text",{x:G.position.x+G.size.width/2,y:G.position.y+G.size.height/2,textAnchor:"middle",dominantBaseline:"middle",fill:"var(--nice-color-white, #fff)",fontSize:10/v,fontFamily:"system-ui, sans-serif",children:G.label.substring(0,5)})]},G.id)})]})}),a&&s.jsx("span",{className:Te.badge,children:y.nodes.length}),n&&s.jsx("span",{className:Te.expandIcon,children:s.jsx(k.NiceIcon,{name:"expand",size:12})})]}),x&&y&&s.jsx(Ji,{document:y,onClose:()=>z(!1)})]})};function Cr(o,e,t="roundedRect"){const r=[],i=[],a=new Map;for(const n of o){const c=String(n[e.nodeMapping.idField]??"");if(!c)continue;const l=String(n[e.nodeMapping.labelField]??c),u=e.nodeMapping.descriptionField?String(n[e.nodeMapping.descriptionField]??""):void 0,d=e.nodeMapping.iconField?String(n[e.nodeMapping.iconField]??""):void 0,m=e.nodeMapping.colorField?String(n[e.nodeMapping.colorField]??""):void 0,w={id:`data_${c}`,label:l,description:u,icon:d,position:{x:0,y:0},size:{width:180,height:70},shape:t,style:m?{backgroundColor:m}:{},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:n};r.push(w),a.set(c,w)}if(e.nodeMapping.parentField)for(const n of o){const c=String(n[e.nodeMapping.idField]??""),l=String(n[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 n of o){const c=String(n[e.edgeMapping.sourceField]??""),l=String(n[e.edgeMapping.targetField]??"");if(!c||!l)continue;const u=a.get(c),d=a.get(l);if(!u||!d)continue;const m=e.edgeMapping.labelField?String(n[e.edgeMapping.labelField]??""):void 0;i.push({id:`edge_${c}_${l}`,sourceNodeId:u.id,sourcePortId:"right",targetNodeId:d.id,targetPortId:"left",label:m,style:{lineType:"bezier",targetArrow:"arrow"}})}return{nodes:r,edges:i}}async function ea(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 Cr(a,o,e)}const Sr={width:176,height:64},Qe={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 ta(o){return[{id:"initial",label:o("workflowDesigner.step.initial","Start"),icon:"play",color:Qe.initial,role:"initial"},{id:"intermediate",label:o("workflowDesigner.step.intermediate","State"),icon:"circle",color:Qe.intermediate},{id:"approval",label:o("workflowDesigner.step.approval","Approval"),icon:"check",color:Qe.approval},{id:"final",label:o("workflowDesigner.step.final","End"),icon:"stop",color:Qe.final,role:"final"},{id:"error",label:o("workflowDesigner.step.error","Error"),icon:"error",color:Qe.error,role:"error"}]}const ra=o=>o.role??(o.id==="initial"||o.id==="final"||o.id==="error"?o.id:"step"),Mr=[{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 oa(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 zt(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 ia(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 Zt(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:Sr,shape:"roundedRect",style:{},ports:Mr})),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 jt(r,i,{algorithm:"dagre",direction:e,nodeSpacing:36,rankSpacing:96})}function aa(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 n=e(a);n!=="final"&&n!=="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}),n!=="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 na=[{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"}],sa=.1,la=3,Ir=({workflow:o,nodes:e,edges:t,onChange:r,readOnly:i=!1,showMinimap:a=!0,showToolbar:n=!0,showValidation:c=!0,onTest:l,onPublish:u,tutorial:d,stepTypes:m,loadStepTypes:w,layoutDirection:p="LR",className:h,style:x,"data-testid":z})=>{const{t:y}=k.useNiceTranslation(),S=g.useRef(null);k.useRovingFocus(S,{orientation:"horizontal",itemSelector:'button, [role="menuitem"]'});const b=g.useMemo(()=>ia(o,e,t),[o,e,t]),[v,D]=g.useState(b),N=g.useRef(null),K=g.useRef(JSON.stringify(b));g.useEffect(()=>{const I=JSON.stringify(b);I!==K.current&&(K.current=I,b!==N.current&&D(b))},[b]);const G=g.useRef(w),[L,W]=g.useState(null),[A,B]=g.useState(!!w);g.useEffect(()=>{const I=G.current;if(!I)return;let T=!0;return I().then(Q=>T&&W(Q)).catch(()=>{}).finally(()=>T&&B(!1)),()=>{T=!1}},[]);const O=g.useMemo(()=>{const I=m??ta(y);if(!L)return I;const T=new Map(I.map(Q=>[Q.id,Q]));for(const Q of L)T.set(Q.id,Q);return[...T.values()]},[m,L,y]),H=g.useCallback(I=>O.find(T=>T.id===I.type)??{id:I.type,label:I.type,color:Qe[I.type]??Qe.intermediate},[O]),M=g.useCallback(I=>ra(H(I)),[H]),[R,F]=g.useState(null),[q,Y]=g.useState(null),Z=q!==null,J=v.states.find(I=>I.id===R),ee=v.transitions.find(I=>I.id===R),ue=g.useMemo(()=>Zt(v,p),[v,p]),fe=`${v.states.map(I=>I.id).join(",")}|${v.transitions.map(I=>`${I.fromStateId}>${I.toStateId}`).join(",")}|${p}`,Se=g.useMemo(()=>v.states.map(I=>{const T=H(I),Q=q===I.id;return{id:I.id,label:I.name,description:T.label,position:ue.positions.get(I.id)??I.position,size:Sr,shape:T.shape??"roundedRect",icon:T.icon,style:{backgroundColor:"var(--nice-bg-primary)",borderColor:T.color??Qe.intermediate,borderWidth:Q?4:2,borderRadius:10,fontColor:"var(--nice-text-primary)",fontSize:13,fontWeight:"bold",...Q?{glowColor:T.color??Qe.intermediate}:{}},ports:Mr}}),[v.states,H,ue,q]),$e=g.useMemo(()=>{const I=ue.ranks??new Map,T=new Set(v.states.map(ne=>ne.id)),Q=p==="LR";return v.transitions.filter(ne=>T.has(ne.fromStateId)&&T.has(ne.toStateId)).map(ne=>{const Ae=ne.fromStateId===ne.toStateId,De=!Ae&&(I.get(ne.toStateId)??0)<=(I.get(ne.fromStateId)??0),[at,je]=Ae?Q?["right","top"]:["bottom","right"]:De?Q?["bottom","bottom"]:["right","right"]:Q?["right","left"]:["bottom","top"],We=q===ne.fromStateId;return{id:ne.id,sourceNodeId:ne.fromStateId,sourcePortId:at,targetNodeId:ne.toStateId,targetPortId:je,label:ne.name||void 0,style:{lineType:"bezier",targetArrow:"arrow",strokeWidth:We?2.5:1.5,...We?{strokeColor:"var(--nice-color-primary)"}:{}}}})},[v.transitions,v.states,ue,p,q]),Ee=g.useRef(r);g.useEffect(()=>{Ee.current=r});const xe=g.useCallback(I=>{var ne;const T=Zt(I,p).positions,Q={...I,states:I.states.map(Ae=>{const De=T.get(Ae.id);return De?{...Ae,position:{x:Math.round(De.x),y:Math.round(De.y)}}:Ae})};N.current=Q,D(Q),(ne=Ee.current)==null||ne.call(Ee,Q)},[p]),Ge=g.useCallback(I=>{if(i)return;const T=zt("state",v.states),Q={id:T,name:oa(I.label,v.states.map(De=>De.name)),type:I.id,position:{x:0,y:0}},ne=v.states.find(De=>De.id===R),Ae=ne?[...v.transitions,{id:zt("t",v.transitions),fromStateId:ne.id,toStateId:T,name:y("workflowDesigner.next","Next")}]:v.transitions;xe({...v,states:[...v.states,Q],transitions:Ae}),F(T)},[i,v,R,xe,y]),Me=g.useCallback((I,T)=>xe({...v,states:v.states.map(Q=>Q.id===I?{...Q,...T}:Q)}),[v,xe]),Je=g.useCallback(I=>{xe({...v,states:v.states.filter(T=>T.id!==I),transitions:v.transitions.filter(T=>T.fromStateId!==I&&T.toStateId!==I)}),F(null)},[v,xe]),Ve=g.useCallback((I,T)=>{var De,at;const Q=T?v.transitions.find(je=>je.fromStateId===I&&je.toStateId===T):void 0;if(Q){F(Q.id);return}const ne=new Set(v.transitions.filter(je=>je.fromStateId===I).map(je=>je.toStateId)),Ae=T??((De=v.states.find(je=>je.id!==I&&!ne.has(je.id)))==null?void 0:De.id)??((at=v.states.find(je=>je.id!==I))==null?void 0:at.id);Ae&&xe({...v,transitions:[...v.transitions,{id:zt("t",v.transitions),fromStateId:I,toStateId:Ae,name:y("workflowDesigner.next","Next")}]})},[v,xe,y]),Ye=g.useCallback((I,T)=>xe({...v,transitions:v.transitions.map(Q=>Q.id===I?{...Q,...T}:Q)}),[v,xe]),Xe=g.useCallback(I=>{xe({...v,transitions:v.transitions.filter(T=>T.id!==I)}),R===I&&F(null)},[v,xe,R]),U=g.useMemo(()=>c?aa(v,M,y):[],[c,v,M,y]),_e=U.filter(I=>I.type==="error"),[Ke,Pe]=g.useState({x:0,y:0,zoom:1}),[tt,me]=g.useState(0),[ge,Oe]=g.useState(null),E=g.useCallback(I=>Pe(T=>{const Q=Math.min(la,Math.max(sa,T.zoom*I)),ne=((ge==null?void 0:ge.width)??0)/2,Ae=((ge==null?void 0:ge.height)??0)/2;return{x:ne-(ne-T.x)*(Q/T.zoom),y:Ae-(Ae-T.y)*(Q/T.zoom),zoom:Q}}),[ge]),$=g.useCallback(()=>{ge&&Pe(Rt(Pt(Se),ge,{maxZoom:1,minZoom:1}))},[ge,Se]),se=()=>{const I=v.states.find(T=>M(T)==="initial");I&&(F(null),Y(I.id))},pe=g.useMemo(()=>[{id:"add-step",label:y("workflowDesigner.addStep","Add step"),icon:s.jsx(k.NiceIcon,{name:"plus",size:14}),children:[...O.map(I=>({id:I.id,label:I.label,description:I.description,icon:I.icon?s.jsx(k.NiceIcon,{name:I.icon,size:14}):void 0,onClick:()=>Ge(I)})),...A?[{id:"loading",label:y("workflowDesigner.loadingSteps","Loading step types…"),disabled:!0}]:[]]}],[O,A,Ge,y]),ke=n?s.jsxs("div",{ref:S,className:"nice-workflow-designer__toolbar",role:"toolbar","aria-label":y("workflowDesigner.toolbar","Workflow toolbar"),children:[!i&&!Z&&s.jsx(k.NiceMenu,{variant:"ghost",size:"sm",items:pe,"data-testid":"workflow-add-step"}),s.jsx(k.NiceButton,{size:"sm",variant:"ghost",leftIcon:s.jsx(k.NiceIcon,{name:"play",size:14}),onClick:se,disabled:_e.length>0||Z,children:y("workflowDesigner.simulate","Simulate")}),s.jsx("span",{className:"nice-workflow-designer__spacer"}),s.jsx(k.NiceButton,{size:"sm",variant:"ghost",ariaLabel:y("workflowDesigner.zoomOut","Zoom out"),onClick:()=>E(1/1.2),children:s.jsx(k.NiceIcon,{name:"zoom-out",size:14})}),s.jsx(k.NiceButton,{size:"sm",variant:"ghost",className:"nice-workflow-designer__zoom",title:y("workflowDesigner.resetView","Reset view"),onClick:$,children:`${Math.round(Ke.zoom*100)}%`}),s.jsx(k.NiceButton,{size:"sm",variant:"ghost",ariaLabel:y("workflowDesigner.zoomIn","Zoom in"),onClick:()=>E(1.2),children:s.jsx(k.NiceIcon,{name:"zoom-in",size:14})}),s.jsx(k.NiceButton,{size:"sm",variant:"ghost",leftIcon:s.jsx(k.NiceIcon,{name:"expand",size:14}),onClick:()=>me(I=>I+1),children:y("workflowDesigner.fit","Fit to view")}),l&&!i&&s.jsx(k.NiceButton,{size:"sm",variant:"ghost",onClick:()=>l(v),children:y("workflowDesigner.test","Test")}),u&&!i&&s.jsx(k.NiceButton,{size:"sm",variant:"primary",onClick:()=>u(v),disabled:_e.length>0,children:y("workflowDesigner.publish","Publish")})]}):void 0,Fe=I=>v.states.filter(T=>T.id!==I).map(T=>({value:T.id,label:T.name})),rt=I=>s.jsxs("div",{className:"nice-workflow-designer__props-header",children:[s.jsx("h3",{children:I}),s.jsx("button",{type:"button",className:"nice-workflow-designer__props-close",onClick:()=>F(null),"aria-label":y("workflowDesigner.closeProps","Close properties"),title:y("workflowDesigner.closeProps","Close properties"),children:s.jsx(k.NiceIcon,{name:"close",size:12})})]});let X;if(!i&&!Z&&J){const I=v.transitions.filter(T=>T.fromStateId===J.id);X=s.jsxs("aside",{className:"nice-workflow-designer__props","aria-label":y("workflowDesigner.stateProps","State properties"),children:[rt(J.name),s.jsx(k.NiceTextInput,{label:y("workflowDesigner.stateName","State name"),size:"sm",value:J.name,onChange:T=>Me(J.id,{name:T})}),s.jsx(k.NiceSelect,{label:y("workflowDesigner.stateType","State type"),size:"sm",value:J.type,options:O.map(T=>({value:T.id,label:T.label})),onChange:T=>{const Q=Array.isArray(T)?T[0]:T;Q&&Me(J.id,{type:String(Q)})}}),s.jsx("h4",{className:"nice-workflow-designer__props-section",children:y("workflowDesigner.transitions","Transitions")}),I.length===0&&s.jsx("p",{className:"nice-workflow-designer__props-empty",children:y("workflowDesigner.noTransitions","No transitions yet")}),I.map(T=>s.jsxs("div",{className:"nice-workflow-designer__transition","data-transition-id":T.id,children:[s.jsx(k.NiceTextInput,{"aria-label":y("workflowDesigner.transitionName","Transition name"),size:"sm",value:T.name,onChange:Q=>Ye(T.id,{name:Q})}),s.jsx(k.NiceSelect,{"aria-label":y("workflowDesigner.target","To"),size:"sm",value:T.toStateId,options:Fe(),onChange:Q=>{const ne=Array.isArray(Q)?Q[0]:Q;ne&&Ye(T.id,{toStateId:String(ne)})}}),s.jsx(k.NiceButton,{size:"sm",variant:"ghost",ariaLabel:y("workflowDesigner.deleteFlow","Delete flow"),onClick:()=>Xe(T.id),children:s.jsx(k.NiceIcon,{name:"trash",size:14})})]},T.id)),s.jsx(k.NiceButton,{size:"sm",variant:"secondary",leftIcon:s.jsx(k.NiceIcon,{name:"plus",size:14}),onClick:()=>Ve(J.id),disabled:v.states.length<2,children:y("workflowDesigner.addTransition","Add transition")}),s.jsx(k.NiceButton,{size:"sm",variant:"danger",leftIcon:s.jsx(k.NiceIcon,{name:"trash",size:14}),onClick:()=>Je(J.id),className:"nice-workflow-designer__props-delete",children:y("workflowDesigner.deleteState","Delete state {name}").replace("{name}",J.name)})]})}else if(!i&&!Z&&ee){const I=v.states.find(T=>T.id===ee.fromStateId);X=s.jsxs("aside",{className:"nice-workflow-designer__props","aria-label":y("workflowDesigner.properties","Properties"),children:[rt(y("workflowDesigner.flowOf","Flow: {name}").replace("{name}",ee.name||"→")),s.jsx(k.NiceTextInput,{label:y("workflowDesigner.transitionName","Transition name"),size:"sm",value:ee.name,onChange:T=>Ye(ee.id,{name:T})}),s.jsxs("p",{className:"nice-workflow-designer__props-from",children:[y("workflowDesigner.from","From"),": ",s.jsx("strong",{children:I==null?void 0:I.name})]}),s.jsx(k.NiceSelect,{label:y("workflowDesigner.target","To"),size:"sm",value:ee.toStateId,options:Fe(),onChange:T=>{const Q=Array.isArray(T)?T[0]:T;Q&&Ye(ee.id,{toStateId:String(Q)})}}),s.jsx(k.NiceButton,{size:"sm",variant:"danger",leftIcon:s.jsx(k.NiceIcon,{name:"trash",size:14}),onClick:()=>Xe(ee.id),children:y("workflowDesigner.deleteFlow","Delete flow")})]})}const Ie=v.states.find(I=>I.id===q),ze=c&&U.length>0&&!Z,st=ze||Z?s.jsxs(s.Fragment,{children:[ze&&s.jsx("div",{className:"nice-workflow-designer__validation",role:"status","aria-live":"polite",children:U.map((I,T)=>{const Q=s.jsxs(s.Fragment,{children:[s.jsx(k.NiceIcon,{name:I.type==="error"?"error":"warning",size:14})," ",I.message]}),ne=`nice-workflow-designer__issue nice-workflow-designer__issue--${I.type}`;return I.stateId?s.jsx("button",{type:"button",className:ne,onClick:()=>F(I.stateId),children:Q},T):s.jsx("div",{className:ne,children:Q},T)})}),Z&&s.jsxs("div",{className:"nice-workflow-designer__sim-toolbar",children:[s.jsxs("span",{children:[y("workflowDesigner.simActiveState","Simulation active — current state:")," ",s.jsx("strong",{children:Ie==null?void 0:Ie.name})]}),v.transitions.filter(I=>I.fromStateId===q).map(I=>{var T;return s.jsxs("button",{type:"button",className:"nice-workflow-designer__sim-btn",onClick:()=>Y(I.toStateId),children:[s.jsx(k.NiceIcon,{name:"arrow-right",size:12})," ",I.name||((T=v.states.find(Q=>Q.id===I.toStateId))==null?void 0:T.name)]},I.id)}),s.jsx("button",{type:"button",className:"nice-workflow-designer__sim-end",onClick:()=>Y(null),children:y("workflowDesigner.endSimulation","End simulation")})]})]}):void 0,Re=g.useCallback(I=>{Z||F(I)},[Z]);return s.jsx(k.NiceAppShell,{flush:!0,className:`nice-workflow-designer${i?" nice-workflow-designer--readonly":""} ${h??""}`,style:x,"data-testid":z,toolbar:ke,rightSidebar:X,bottomPanel:st,children:s.jsxs("div",{className:"nice-workflow-designer__canvas",children:[s.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:s.jsx(k.NiceTutorialButton,{steps:k.resolveTutorial(d,na)})}),s.jsx(Be,{nodes:Se,edges:$e,viewport:Ke,onViewportChange:Pe,selectedId:R,onSelectElement:Re,interactive:!i&&!Z,onEdgeCreate:i||Z?void 0:(I,T)=>Ve(I,T),autoFit:!0,fitKey:fe,refitKey:tt,onResize:Oe,resizable:!1,panOnDrag:!0,ariaLabel:y("workflowDesigner.canvas","Workflow canvas")}),a&&s.jsx("div",{className:"nice-workflow-designer__minimap","aria-label":y("workflowDesigner.minimap","Minimap"),children:s.jsx(ut,{nodes:Se,edges:$e,viewport:Ke,onViewportChange:Pe,canvasWidth:ge==null?void 0:ge.width,canvasHeight:ge==null?void 0:ge.height})})]})})};process.env.NODE_ENV!=="production"&&(Ir.displayName="NiceWorkflowDesigner");const ca={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)"},da={start:"ellipse",end:"ellipse",task:"rectangle",decision:"diamond",parallel:"rectangle",join:"rectangle",subprocess:"rectangle",timer:"ellipse",message:"rectangle",error:"rectangle"},ua={start:"play",end:"stop",task:"clipboard",decision:"help",parallel:"columns",join:"git-branch",subprocess:"box",timer:"clock",message:"mail",error:"warning"},fa=({data:o,onStepClick:e,onTransitionClick:t,autoPlay:r=!1,animationDelay:i=1e3,showTooltips:a=!0,showMinimap:n=!0,statusColors:c=ca,typeShapes:l=da,direction:u="horizontal",className:d,style:m})=>{const[w,p]=g.useState(0),h=g.useMemo(()=>{const S=o.steps.map((D,N)=>{const K=D.id===o.currentStepId,G=D.status||"pending",L=c[G],W=l[D.type],A=u==="horizontal"?N*200:100,B=u==="horizontal"?100:N*150;return{id:D.id,label:D.name,x:A,y:B,width:150,height:60,shape:W,style:{fill:L,stroke:K?"var(--nice-text, #1f2937)":L,strokeWidth:K?3:1,fontColor:"var(--nice-color-white, #fff)",fontSize:12},data:{type:D.type,status:D.status,assignee:D.assignee,dueDate:D.dueDate,icon:ua[D.type],...D.metadata},ports:[{id:`${D.id}-in`,position:"left"},{id:`${D.id}-out`,position:"right"}]}}),b=o.transitions.map(D=>{const N=o.steps.find(L=>L.id===D.from),K=o.steps.find(L=>L.id===D.to);let G="var(--nice-text-muted, #9ca3af)";return(N==null?void 0:N.status)==="completed"&&(K==null?void 0:K.status)!=="pending"?G="var(--nice-success, #10b981)":(N==null?void 0:N.status)==="failed"&&(G="var(--nice-danger, #ef4444)"),{id:D.id,source:D.from,target:D.to,sourcePort:`${D.from}-out`,targetPort:`${D.to}-in`,label:D.label||D.condition,style:{stroke:G,strokeWidth:2,arrowHead:"arrow",lineType:"bezier"},data:{condition:D.condition}}}),v=r?ha(o.steps):[];return et({id:o.id,title:o.name,diagramType:"flowchart",nodes:S,edges:b,animations:v,metadata:{type:"workflow",...o.metadata}})},[o,c,l,u,r]);g.useEffect(()=>{if(!r)return;const S=o.steps.filter(v=>v.status==="completed").length;if(w>=S)return;const b=setTimeout(()=>{p(v=>v+1)},i);return()=>clearTimeout(b)},[r,w,i,o.steps]);const[x,z]=g.useState({x:0,y:0,zoom:1}),y=g.useCallback(S=>{if(S&&e){const b=o.steps.find(v=>v.id===S);b&&e(b)}if(S&&t){const b=o.transitions.find(v=>v.id===S);b&&t(b)}},[o.steps,o.transitions,e,t]);return s.jsx("div",{className:`nice-workflow-visualizer ${d||""}`,style:{position:"relative",width:"100%",height:"100%",...m},children:s.jsx(Be,{nodes:h.nodes,edges:h.edges,groups:h.groups,viewport:x,onViewportChange:z,onSelectElement:y,showGrid:!0})})};function ha(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 pa(o){var a,n;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:((n=t.querySelector("process"))==null?void 0:n.getAttribute("name"))||"Workflow",steps:r,transitions:i}}function ga(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 ma={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)"},ya={"one-to-one":{left:"1",right:"1"},"one-to-many":{left:"1",right:"*"},"many-to-one":{left:"*",right:"1"},"many-to-many":{left:"*",right:"*"}},ba=({schema:o,onTableClick:e,onColumnClick:t,onRelationClick:r,showColumnDetails:i=!0,showOnlyKeys:a=!1,highlightTables:n=[],showMinimap:c=!0,schemaColors:l=ma,layout:u="auto",maxColumnsDisplay:d=15,className:m,style:w})=>{const[p,h]=g.useState(null),x=g.useMemo(()=>{const b=wa(o.tables,u),v=o.tables.map((N,K)=>{const G=b[N.name]||{x:K%4*300,y:Math.floor(K/4)*400},L=n.includes(N.name),W=p===N.name,A=l[N.schema||"dbo"]||"var(--nice-text-secondary, #6b7280)";let B=N.columns;a&&(B=B.filter(R=>R.primaryKey||R.foreignKey)),B.length>d&&(B=B.slice(0,d));const O=40,H=i?28:20,M=O+B.length*H+10;return{id:N.name,label:N.schema?`${N.schema}.${N.name}`:N.name,x:G.x,y:G.y,width:250,height:M,shape:"rectangle",style:{fill:L||W?A:"var(--nice-bg, #fff)",stroke:A,strokeWidth:W?3:L?2:1,fontColor:L||W?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:14,borderRadius:8},data:{type:"table",schema:N.schema,columns:B.map(R=>({...R,icon:xa(R)})),totalColumns:N.columns.length,truncated:N.columns.length>d,comment:N.comment,...N.metadata},ports:[...N.columns.filter(R=>R.primaryKey).map(R=>({id:`${N.name}.${R.name}-pk`,position:"left"})),...N.columns.filter(R=>R.foreignKey).map(R=>({id:`${N.name}.${R.name}-fk`,position:"right"}))]}}),D=o.relations.map(N=>{const K=ya[N.type];return{id:N.id,source:N.fromTable,target:N.toTable,sourcePort:`${N.fromTable}.${N.fromColumn}-fk`,targetPort:`${N.toTable}.${N.toColumn}-pk`,label:N.name||`${K.left}─${K.right}`,style:{stroke:"var(--nice-text-secondary, #6b7280)",strokeWidth:1.5,arrowHead:va(N.type),arrowTail:ka(N.type),lineType:"orthogonal",strokeDasharray:N.type==="many-to-many"?"5,5":void 0},data:{type:N.type,fromColumn:N.fromColumn,toColumn:N.toColumn}}});return et({id:`schema-${o.name}`,title:o.name,diagramType:"er",nodes:v,edges:D,metadata:{type:"er-diagram",...o.metadata}})},[o,i,a,n,p,l,u,d]),[z,y]=g.useState({x:0,y:0,zoom:1}),S=g.useCallback(b=>{if(b){if(h(v=>v===b?null:b),e){const v=o.tables.find(D=>D.name===b);v&&e(v)}if(r){const v=o.relations.find(D=>D.id===b);v&&r(v)}}},[o.tables,o.relations,e,r]);return s.jsx("div",{className:`nice-database-schema-viewer ${m||""}`,style:{position:"relative",width:"100%",height:"100%",...w},children:s.jsx(Be,{nodes:x.nodes,edges:x.edges,groups:x.groups,viewport:z,onViewportChange:y,onSelectElement:S,showGrid:!0})})};function wa(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 n=a.schema||"default";r[n]||(r[n]=[]),r[n].push(a)});let i=50;Object.entries(r).forEach(([a,n])=>{n.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,n=300+o.length*20;t[r.name]={x:Math.cos(a)*n+500,y:Math.sin(a)*n+400}});return t}function xa(o){return o.primaryKey?"lock":o.foreignKey?"link":o.unique?"zap":"file"}function va(o){switch(o){case"one-to-one":case"many-to-one":return"none";case"one-to-many":case"many-to-many":return"crow"}}function ka(o){switch(o){case"one-to-one":case"one-to-many":return"none";case"many-to-one":case"many-to-many":return"crow"}}function Ca(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",n=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 m=/PRIMARY\s+KEY\s*\(`?(\w+)`?\)/i.exec(c);if(m){const h=l.find(x=>x.name===m[1]);h&&(h.primaryKey=!0)}const w=/FOREIGN\s+KEY\s*\(`?(\w+)`?\)\s*REFERENCES\s+`?(\w+)`?\s*\(`?(\w+)`?\)/gi;let p;for(;(p=w.exec(c))!==null;){const h=p,x=l.find(z=>z.name===h[1]);x&&(x.foreignKey={table:h[2],column:h[3]},t.push({id:`fk-${n}-${h[1]}`,fromTable:n,fromColumn:h[1],toTable:h[2],toColumn:h[3],type:"many-to-one"}))}e.push({name:n,schema:a,columns:l})}return{name:"Parsed Schema",tables:e,relations:t}}function Sa(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}),n=r.columns.filter(c=>c.foreignKey).map(c=>` FOREIGN KEY (${c.name}) REFERENCES ${c.foreignKey.table}(${c.foreignKey.column})`);t.push([...a,...n].join(`,
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),C=require("@nice2dev/ui"),m=require("react");class nr{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(),o=Math.min((t-this.lastTime)/1e3,.1);this.lastTime=t;for(const[,i]of this.liquidFlows)if(i.active){i.gradientOffset=(i.gradientOffset+o*.5)%1;for(const a of i.particles)a.t=(a.t+o*.3)%1,a.offset+=(Math.random()-.5)*o*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+o*2)%(Math.PI*2);this.particles=this.particles.filter(i=>(i.life-=o/i.maxLife,i.life<=0?!1:(i.x+=i.vx*o,i.y+=i.vy*o,i.opacity=Math.min(1,i.life*2),!0)));for(const i of this.emitters)for(i.accumulator=(i.accumulator??0)+o*i.rate;i.accumulator>=1;){i.accumulator-=1;const a=Math.random()*Math.PI*2,n=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)*n,vy:Math.sin(a)*n,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 o=[],i=t.particleDensity??3;for(let a=0;a<i;a++)o.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:o,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,o){this.glowStates.set(e,{elementId:e,color:t,intensity:o,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 oo(r,e,t){if(!t)return{x:0,y:0};const o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("d",r),t.appendChild(o);try{const i=o.getTotalLength(),a=o.getPointAtLength(e*i);return{x:a.x,y:a.y}}finally{t.removeChild(o)}}function sr(r){return`nd-glow-${r.replace(/[^a-zA-Z0-9]/g,"_")}`}function lr(r,e){const t=r*12,o=1+Math.sin(e)*.3;return t*o}function jt(r,e,t){const o=r.find(l=>l.id===e);if(!o)return{x:0,y:0};const{position:i,size:a}=o,n=o.ports.find(l=>l.id===t);switch(n==null?void 0:n.side){case"top":return{x:i.x+a.width*n.offset,y:i.y};case"bottom":return{x:i.x+a.width*n.offset,y:i.y+a.height};case"left":return{x:i.x,y:i.y+a.height*n.offset};case"right":return{x:i.x+a.width,y:i.y+a.height*n.offset};default:return{x:i.x+a.width/2,y:i.y+a.height/2}}}const Jt=(r,e)=>{const t=(r.y+e.y)/2;return{d:`M ${r.x} ${r.y} L ${r.x} ${t} L ${e.x} ${t} L ${e.x} ${e.y}`,mid:{x:(r.x+e.x)/2,y:t},extent:[r,e]}};function wt(r,e,t={}){if(t.treeEdges&&(r.style.lineType??"bezier")==="bezier"){const n=e.find(c=>c.id===r.sourceNodeId),l=e.find(c=>c.id===r.targetNodeId);if(n&&l)return Jt({x:n.position.x+n.size.width/2,y:n.position.y+n.size.height},{x:l.position.x+l.size.width/2,y:l.position.y})}const o=jt(e,r.sourceNodeId,r.sourcePortId),i=jt(e,r.targetNodeId,r.targetPortId),a={x:(o.x+i.x)/2,y:(o.y+i.y)/2};switch(r.style.lineType??"bezier"){case"straight":return{d:`M ${o.x} ${o.y} L ${i.x} ${i.y}`,mid:a,extent:[o,i]};case"orthogonal":{const n=(o.x+i.x)/2;return{d:`M ${o.x} ${o.y} L ${n} ${o.y} L ${n} ${i.y} L ${i.x} ${i.y}`,mid:a,extent:[o,i]}}case"step":return{...Jt(o,i),mid:a};default:{const n=Math.max(40,Math.hypot(i.x-o.x,i.y-o.y)*.4),l=(g,h)=>{var w,z;return((z=(w=e.find(y=>y.id===g))==null?void 0:w.ports.find(y=>y.id===h))==null?void 0:z.side)??null},c=(g,h,w)=>{switch(h){case"top":return{x:g.x,y:g.y-n};case"bottom":return{x:g.x,y:g.y+n};case"left":return{x:g.x-n,y:g.y};case"right":return{x:g.x+n,y:g.y};default:return{x:g.x+w,y:g.y}}},u=Math.abs(i.x-o.x)*.5,d=c(o,l(r.sourceNodeId,r.sourcePortId),u),p=c(i,l(r.targetNodeId,r.targetPortId),-u),b=g=>{const h=1-g;return{x:h*h*h*o.x+3*h*h*g*d.x+3*h*g*g*p.x+g*g*g*i.x,y:h*h*h*o.y+3*h*h*g*d.y+3*h*g*g*p.y+g*g*g*i.y}};return{d:`M ${o.x} ${o.y} C ${d.x} ${d.y}, ${p.x} ${p.y}, ${i.x} ${i.y}`,mid:b(.5),extent:Array.from({length:9},(g,h)=>b(h/8))}}}}const $t=.5522847498,io=(r,e,t,o,i)=>{const a=Math.max(0,Math.min(i,t/2,o/2));if(a===0)return`M ${r} ${e} L ${r+t} ${e} L ${r+t} ${e+o} L ${r} ${e+o} Z`;const n=a*(1-$t);return[`M ${r+a} ${e}`,`L ${r+t-a} ${e}`,`C ${r+t-n} ${e} ${r+t} ${e+n} ${r+t} ${e+a}`,`L ${r+t} ${e+o-a}`,`C ${r+t} ${e+o-n} ${r+t-n} ${e+o} ${r+t-a} ${e+o}`,`L ${r+a} ${e+o}`,`C ${r+n} ${e+o} ${r} ${e+o-n} ${r} ${e+o-a}`,`L ${r} ${e+a}`,`C ${r} ${e+n} ${r+n} ${e} ${r+a} ${e}`,"Z"].join(" ")},ao=(r,e,t,o)=>{const i=t*$t,a=o*$t;return[`M ${r+t} ${e}`,`C ${r+t} ${e+a} ${r+i} ${e+o} ${r} ${e+o}`,`C ${r-i} ${e+o} ${r-t} ${e+a} ${r-t} ${e}`,`C ${r-t} ${e-a} ${r-i} ${e-o} ${r} ${e-o}`,`C ${r+i} ${e-o} ${r+t} ${e-a} ${r+t} ${e}`,"Z"].join(" ")};function no(r){const{x:e,y:t}=r.position,{width:o,height:i}=r.size;switch(r.shape){case"ellipse":case"circle":return ao(e+o/2,t+i/2,o/2,i/2);case"diamond":return`M ${e+o/2} ${t} L ${e+o} ${t+i/2} L ${e+o/2} ${t+i} L ${e} ${t+i/2} Z`;default:return io(e,t,o,i,r.style.borderRadius??(r.shape==="roundedRect"?8:0))}}function Pt(r){const e=[],t=/([MLCZ])([^MLCZ]*)/gi;let o;for(;o=t.exec(r);){const i=(o[2].match(/-?\d*\.?\d+(?:e[-+]?\d+)?/gi)??[]).map(Number);e.push([o[1].toUpperCase(),i])}return e}function so(r,e){const t=[];for(const[,d]of Pt(r))for(let p=0;p+1<d.length;p+=2)t.push({x:d[p],y:d[p+1]});const o=t[t.length-1];let i;for(let d=t.length-2;d>=0;d--)if(Math.hypot(t[d].x-o.x,t[d].y-o.y)>.5){i=t[d];break}if(!o||!i)return null;const a=Math.atan2(o.y-i.y,o.x-i.x),n={x:o.x-Math.cos(a)*e,y:o.y-Math.sin(a)*e},l=e*.45,c=-Math.sin(a)*l,u=Math.cos(a)*l;return`M ${o.x} ${o.y} L ${n.x+c} ${n.y+u} L ${n.x-c} ${n.y-u} Z`}const cr=(r,e,t)=>Pt(r).map(([o,i])=>o==="Z"?"Z":`${o} ${i.map((a,n)=>+(n%2===0?a+e:a+t).toFixed(3)).join(" ")}`).join(" ");function xt(r,e={}){const t=e.padding??40,o=r.edges.map(b=>({edge:b,shape:wt(b,r.nodes,{treeEdges:e.treeEdges})}));let i=1/0,a=1/0,n=-1/0,l=-1/0;const c=b=>{i=Math.min(i,b.x),a=Math.min(a,b.y),n=Math.max(n,b.x),l=Math.max(l,b.y)};for(const b of r.nodes)c(b.position),c({x:b.position.x+b.size.width,y:b.position.y+b.size.height});o.forEach(({shape:b})=>b.extent.forEach(c)),Number.isFinite(i)||(i=a=0,n=l=100);const u=t-i,d=t-a,p=[];for(const{edge:b,shape:g}of o)p.push(...lo(b,g.d,g.mid,u,d));for(const b of r.nodes)if(p.push({kind:"path",d:cr(no(b),u,d),fill:b.style.backgroundColor??"#ffffff",stroke:b.style.borderColor??"#cccccc",strokeWidth:b.style.borderWidth??1}),b.label){const g=b.style.fontSize??14;p.push({kind:"text",x:b.position.x+b.size.width/2+u,y:b.position.y+b.size.height/2+g/3+d,text:b.label,size:g,color:b.style.fontColor??"#333333",anchor:"middle"})}return{width:n-i+t*2,height:l-a+t*2,background:e.background,items:p}}function lo(r,e,t,o,i){var u;const a=r.style.strokeColor??"#666666",n=r.style.strokeWidth??2,l=cr(e,o,i),c=[{kind:"path",d:l,stroke:a,strokeWidth:n,dash:(u=r.style.strokeDash)!=null&&u.length?r.style.strokeDash:void 0}];if(r.style.targetArrow!=="none"){const d=so(l,6+n*2);d&&c.push({kind:"path",d,fill:a})}return r.label&&c.push({kind:"text",x:t.x+o,y:t.y+i-6,text:r.label,size:12,color:"#333333",anchor:"middle"}),c}function Et(r,e=1){var a;const t=+(r.width*e).toFixed(2),o=+(r.height*e).toFixed(2),i=[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${r.width} ${r.height}" width="${t}" height="${o}">`];r.background&&r.background!=="transparent"&&i.push(`<rect width="${r.width}" height="${r.height}" fill="${r.background}" />`);for(const n of r.items)n.kind==="path"?i.push(`<path d="${n.d}" fill="${n.fill??"none"}"${n.stroke?` stroke="${n.stroke}" stroke-width="${n.strokeWidth??1}"`:""}${(a=n.dash)!=null&&a.length?` stroke-dasharray="${n.dash.join(" ")}"`:""} />`):i.push(`<text x="${n.x}" y="${n.y}" text-anchor="${n.anchor}" font-size="${n.size}" fill="${n.color}" font-family="Helvetica, Arial, sans-serif">${co(n.text)}</text>`);return i.push("</svg>"),i.join(`
2
+ `)}function dr(r,e){return Et(xt(r,{background:e==null?void 0:e.background,treeEdges:e==null?void 0:e.treeEdges}),(e==null?void 0:e.scale)??1)}async function ur(r,e={}){const t=e.scale??2,o=xt(r,{background:e.background??"#ffffff",treeEdges:e.treeEdges}),i=Et(o),a=URL.createObjectURL(new Blob([i],{type:"image/svg+xml"}));try{const n=new Image;await new Promise((u,d)=>{n.onload=()=>u(),n.onerror=()=>d(new Error("The diagram image could not be drawn.")),n.src=a});const l=document.createElement("canvas");l.width=Math.ceil(o.width*t),l.height=Math.ceil(o.height*t);const c=l.getContext("2d");if(!c)throw new Error("No 2D canvas.");return c.drawImage(n,0,0,l.width,l.height),await new Promise((u,d)=>l.toBlob(p=>p?u(p):d(new Error("No PNG.")),"image/png"))}finally{URL.revokeObjectURL(a)}}async function fr(r,e={}){const{writeDiagramPdf:t}=await Promise.resolve().then(()=>require("./pdfWriter-Bc_razGc.cjs"));return t(r,e,Pt)}async function hr(r,e={}){const t=xt(r,{background:e.background??"#ffffff",treeEdges:e.treeEdges}),o=await fr(t,e);return new Blob([o],{type:"application/pdf"})}function pr(r){const e=[],t=r.diagramType==="orgchart"||r.diagramType==="mindmap"?"graph TB":r.diagramType==="stateMachine"?"stateDiagram-v2":"flowchart TD";e.push(t);for(const o of r.nodes){const i=Nt(o.id),a=o.label.replace(/"/g,"'");switch(o.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 o of r.edges){const i=Nt(o.sourceNodeId),a=Nt(o.targetNodeId),n=o.label?`|${o.label}|`:"",l=o.style.targetArrow==="none"?"---":"-->";e.push(` ${i} ${l}${n} ${a}`)}return e.join(`
3
+ `)}function Nt(r){return r.replace(/[^a-zA-Z0-9_]/g,"_")}function co(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Tt={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","toolbar.tab.home":"Home","toolbar.tab.insert":"Insert","toolbar.tab.format":"Format","toolbar.tab.view":"View","toolbar.section.tools":"Tools","toolbar.section.clipboard":"Clipboard","toolbar.section.history":"History","toolbar.section.shapes":"Shapes","toolbar.section.text":"Text","toolbar.section.zoom":"Zoom","toolbar.section.find":"Find","toolbar.section.mode":"Mode","toolbar.properties":"Properties panel","shape.rectangle":"Rectangle","shape.roundedRect":"Rounded rectangle","shape.ellipse":"Ellipse","shape.circle":"Circle","shape.diamond":"Diamond","shape.hexagon":"Hexagon","shape.parallelogram":"Parallelogram","shape.cylinder":"Cylinder","shape.triangle":"Triangle","shape.cloud":"Cloud","shape.document":"Document","shape.actor":"Actor","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:","diagramEditor.export":"Export","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","toolbar.tab.home":"Start","toolbar.tab.insert":"Wstaw","toolbar.tab.format":"Format","toolbar.tab.view":"Widok","toolbar.section.tools":"Narzędzia","toolbar.section.clipboard":"Schowek","toolbar.section.history":"Historia","toolbar.section.shapes":"Kształty","toolbar.section.text":"Tekst","toolbar.section.zoom":"Powiększenie","toolbar.section.find":"Szukaj","toolbar.section.mode":"Tryb","toolbar.properties":"Panel właściwości","shape.rectangle":"Prostokąt","shape.roundedRect":"Zaokrąglony prostokąt","shape.ellipse":"Elipsa","shape.circle":"Koło","shape.diamond":"Romb","shape.hexagon":"Sześciokąt","shape.parallelogram":"Równoległobok","shape.cylinder":"Walec","shape.triangle":"Trójkąt","shape.cloud":"Chmura","shape.document":"Dokument","shape.actor":"Aktor","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:","diagramEditor.export":"Eksportuj","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","toolbar.tab.home":"Start","toolbar.tab.insert":"Einfügen","toolbar.tab.format":"Format","toolbar.tab.view":"Ansicht","toolbar.section.tools":"Werkzeuge","toolbar.section.clipboard":"Zwischenablage","toolbar.section.history":"Verlauf","toolbar.section.shapes":"Formen","toolbar.section.text":"Text","toolbar.section.zoom":"Zoom","toolbar.section.find":"Suchen","toolbar.section.mode":"Modus","toolbar.properties":"Eigenschaftenbereich","shape.rectangle":"Rechteck","shape.roundedRect":"Abgerundetes Rechteck","shape.ellipse":"Ellipse","shape.circle":"Kreis","shape.diamond":"Raute","shape.hexagon":"Sechseck","shape.parallelogram":"Parallelogramm","shape.cylinder":"Zylinder","shape.triangle":"Dreieck","shape.cloud":"Wolke","shape.document":"Dokument","shape.actor":"Akteur","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:","diagramEditor.export":"Exportieren","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","toolbar.tab.home":"Accueil","toolbar.tab.insert":"Insertion","toolbar.tab.format":"Format","toolbar.tab.view":"Affichage","toolbar.section.tools":"Outils","toolbar.section.clipboard":"Presse-papiers","toolbar.section.history":"Historique","toolbar.section.shapes":"Formes","toolbar.section.text":"Texte","toolbar.section.zoom":"Zoom","toolbar.section.find":"Rechercher","toolbar.section.mode":"Mode","toolbar.properties":"Panneau des propriétés","shape.rectangle":"Rectangle","shape.roundedRect":"Rectangle arrondi","shape.ellipse":"Ellipse","shape.circle":"Cercle","shape.diamond":"Losange","shape.hexagon":"Hexagone","shape.parallelogram":"Parallélogramme","shape.cylinder":"Cylindre","shape.triangle":"Triangle","shape.cloud":"Nuage","shape.document":"Document","shape.actor":"Acteur","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 :","diagramEditor.export":"Exporter","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","toolbar.tab.home":"Inicio","toolbar.tab.insert":"Insertar","toolbar.tab.format":"Formato","toolbar.tab.view":"Vista","toolbar.section.tools":"Herramientas","toolbar.section.clipboard":"Portapapeles","toolbar.section.history":"Historial","toolbar.section.shapes":"Formas","toolbar.section.text":"Texto","toolbar.section.zoom":"Zoom","toolbar.section.find":"Buscar","toolbar.section.mode":"Modo","toolbar.properties":"Panel de propiedades","shape.rectangle":"Rectángulo","shape.roundedRect":"Rectángulo redondeado","shape.ellipse":"Elipse","shape.circle":"Círculo","shape.diamond":"Rombo","shape.hexagon":"Hexágono","shape.parallelogram":"Paralelogramo","shape.cylinder":"Cilindro","shape.triangle":"Triángulo","shape.cloud":"Nube","shape.document":"Documento","shape.actor":"Actor","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:","diagramEditor.export":"Exportar","networkTopology.networkTopology":"Topología de red","orgChartVisualizer.organizationChart":"Organigrama","processMiningDiagram.processMiningDiagram":"Diagrama de minería de procesos"}},gr=m.createContext(null);function mr(r,e){const t={...Tt.en,...Tt[r],...e};return{locale:r,t:(i,a)=>t[i]??a??i}}function Rt({locale:r="en",overrides:e,children:t}){const o=m.useMemo(()=>mr(r,e),[r,e]);return m.createElement(gr.Provider,{value:o},t)}function Be(){const r=m.useContext(gr),{lang:e}=C.useNiceTranslation(),t=Tt[e]?e:"en",o=m.useMemo(()=>mr(t),[t]);return r??o}function uo(r){const e=[];let t;try{t=JSON.parse(r)}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 o=t;if(o.version!=="1.0"&&e.push(`Unsupported version "${String(o.version)}", expected "1.0"`),(typeof o.id!="string"||o.id.length===0)&&e.push('Missing or invalid "id" field'),typeof o.title!="string"&&e.push('Missing or invalid "title" field'),Array.isArray(o.nodes)||e.push('Missing or invalid "nodes" array'),Array.isArray(o.edges)||e.push('Missing or invalid "edges" array'),Array.isArray(o.nodes)&&Array.isArray(o.edges)){const i=new Set(o.nodes.map(a=>a.id).filter(Boolean));for(const a of o.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 yr(r,e=!0){return JSON.stringify(r,null,e?2:void 0)}class vt{constructor(e){this.undoStack=[],this.redoStack=[],this.listeners=new Set,this.maxHistory=100,this.doc=e??vt.createEmpty()}static createEmpty(e="flowchart"){const t=new Date().toISOString();return{version:"1.0",id:st(),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,o="roundedRect",i={width:160,height:60}){this.pushUndo("Add node");const a=fo(),n={id:st(),label:e,position:t,size:i,shape:o,style:{},ports:a};return this.doc.nodes.push(n),this.notify(),n}updateNode(e,t){this.pushUndo("Update node");const o=this.doc.nodes.find(i=>i.id===e);o&&Object.assign(o,t),this.notify()}moveNodes(e,t=!0){const o=[...e].filter(([i])=>this.getNodeById(i));if(o.length!==0){t&&this.pushUndo("Layout");for(const[i,a]of o)this.getNodeById(i).position={...a};this.notify()}}moveNode(e,t){const o=this.doc.nodes.find(i=>i.id===e);o&&(this.pushUndo("Move node"),o.position=t,this.notify())}resizeNode(e,t){const o=this.doc.nodes.find(i=>i.id===e);o&&(this.pushUndo("Resize node"),o.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(o=>o!==e)}),this.doc.animations=this.doc.animations.filter(t=>t.targetId!==e),this.notify()}addEdge(e,t,o,i,a){if(e===o||!this.getNodeById(e)||!this.getNodeById(o))return null;this.pushUndo("Add edge");const n={id:st(),sourceNodeId:e,sourcePortId:t,targetNodeId:o,targetPortId:i,label:a,style:{lineType:"bezier",targetArrow:"arrow"}};return this.doc.edges.push(n),this.notify(),n}updateEdge(e,t){this.pushUndo("Update edge");const o=this.doc.edges.find(i=>i.id===e);o&&Object.assign(o,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 o={id:st(),label:e,nodeIds:[...t]};return t.forEach(i=>{const a=this.doc.nodes.find(n=>n.id===i);a&&(a.groupId=o.id)}),this.doc.groups.push(o),this.notify(),o}removeGroup(e){this.pushUndo("Remove group");const t=this.doc.groups.find(o=>o.id===e);t&&t.nodeIds.forEach(o=>{const i=this.doc.nodes.find(a=>a.id===o);i&&(i.groupId=void 0)}),this.doc.groups=this.doc.groups.filter(o=>o.id!==e),this.notify()}addAnimation(e){this.pushUndo("Add animation");const t={id:st(),...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(o=>o.id===e);t&&(this.pushUndo("Toggle group collapse"),t.collapsed=!t.collapsed,t.nodeIds.forEach(o=>{const i=this.doc.nodes.find(a=>a.id===o);i&&(i.hidden=t.collapsed)}),this.notify())}toggleNodeCollapse(e){const t=this.doc.nodes.find(o=>o.id===e);t&&(this.pushUndo("Toggle node collapse"),t.collapsed=!t.collapsed,(t.childNodeIds??[]).forEach(o=>{const i=this.doc.nodes.find(a=>a.id===o);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 o={id:st(),name:e,animations:t??[],isDefault:this.doc.animationModes.length===0};return this.doc.animationModes.push(o),o.isDefault&&(this.doc.activeAnimationModeId=o.id),this.notify(),o}removeAnimationMode(e){var t;this.doc.animationModes&&(this.pushUndo("Remove animation mode"),this.doc.animationModes=this.doc.animationModes.filter(o=>o.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(o=>o.id===e)&&(this.doc.activeAnimationModeId=e,this.notify())}addAnimationToMode(e,t){var a;const o=(a=this.doc.animationModes)==null?void 0:a.find(n=>n.id===e);if(!o)return null;this.pushUndo("Add animation to mode");const i={id:st(),...t};return o.animations.push(i),this.notify(),i}removeAnimationFromMode(e,t){var i;const o=(i=this.doc.animationModes)==null?void 0:i.find(a=>a.id===e);o&&(this.pushUndo("Remove animation from mode"),o.animations=o.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 o=this.doc.animations.find(i=>i.id===e);o&&Object.assign(o,t),this.notify()}loadDocument(e){this.doc=structuredClone(e),this.undoStack=[],this.redoStack=[],this.notify()}}function st(){return`ndd_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function fo(){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 Ot(r,e,t){switch(t.algorithm){case"dagre":return po(r,e,t);case"grid":return go(r,t);case"radial":return mo(r,e);case"tree":return yo(r,e,t);case"forceDirected":return bo(r,e,t);case"manual":default:return{positions:new Map(r.map(o=>[o.id,{...o.position}]))}}}function ho(r,e){const t=new Map,o=new Set,i=new Set;e.forEach(n=>n.forEach(l=>i.add(l)));const a=n=>{const l=[{id:n,next:0}];for(t.set(n,1);l.length;){const c=l[l.length-1],u=e.get(c.id)??[];if(c.next>=u.length){t.set(c.id,2),l.pop();continue}const d=u[c.next++],p=t.get(d);p===1?o.add(`${c.id}→${d}`):p===void 0&&(t.set(d,1),l.push({id:d,next:0}))}};for(const n of r)!i.has(n)&&!t.has(n)&&a(n);for(const n of r)t.has(n)||a(n);return o}function po(r,e,t){const o=t.direction??"TB",i=t.nodeSpacing??60,a=t.rankSpacing??100,n=o==="LR"||o==="RL",l=o==="BT"||o==="RL",c=r.map(M=>M.id),u=new Map(r.map(M=>[M.id,M])),d=new Map(c.map(M=>[M,[]]));for(const M of e){const W=d.get(M.sourceNodeId);W&&u.has(M.targetNodeId)&&M.sourceNodeId!==M.targetNodeId&&(W.includes(M.targetNodeId)||W.push(M.targetNodeId))}const p=ho(c,d),b=new Map(c.map(M=>[M,[]])),g=new Map(c.map(M=>[M,[]]));d.forEach((M,W)=>{for(const V of M){const[G,N]=p.has(`${W}→${V}`)?[V,W]:[W,V];b.get(G).includes(N)||(b.get(G).push(N),g.get(N).push(G))}});const h=new Map(c.map(M=>[M,0])),w=new Map(c.map(M=>[M,g.get(M).length])),z=c.filter(M=>w.get(M)===0);for(let M=0;M<z.length;M++){const W=z[M];for(const V of b.get(W))h.set(V,Math.max(h.get(V),h.get(W)+1)),w.set(V,w.get(V)-1),w.get(V)===0&&z.push(V)}const y=[];for(const M of c){const W=h.get(M);(y[W]??(y[W]=[])).push(M)}const _=y.filter(Boolean),O=new Map;_.forEach(M=>M.forEach((W,V)=>O.set(W,V)));const P=(M,W)=>W.length===0?O.get(M):W.reduce((V,G)=>V+O.get(G),0)/W.length;for(let M=0;M<4;M++){const W=M%2===0,V=W?_.slice(1):_.slice(0,-1).reverse();for(const G of V){const N=new Map(G.map(T=>[T,P(T,W?g.get(T):b.get(T))]));G.sort((T,F)=>N.get(T)-N.get(F)||O.get(T)-O.get(F)),G.forEach((T,F)=>O.set(T,F))}}const D=M=>n?M.size.width:M.size.height,v=M=>n?M.size.height:M.size.width,X=new Map;let q=0;for(const M of _){const W=M.map(T=>u.get(T)),V=Math.max(...W.map(D));let N=-(W.reduce((T,F)=>T+v(F),0)+(W.length-1)*i)/2;for(const T of W){const F=q+(V-D(T))/2,U=l?-(F+D(T)):F;X.set(T.id,n?{x:U,y:N}:{x:N,y:U}),N+=v(T)+i}q+=V+a}t.centerGraph&&Ft(X);const L=new Map;return _.forEach((M,W)=>M.forEach(V=>L.set(V,W))),{positions:X,ranks:L}}function go(r,e){const t=e.nodeSpacing??80,o=Math.ceil(Math.sqrt(r.length)),i=new Map;return r.forEach((a,n)=>{const l=n%o,c=Math.floor(n/o);i.set(a.id,{x:l*(a.size.width+t),y:c*(a.size.height+t)})}),e.centerGraph&&Ft(i),{positions:i}}function mo(r,e){const t=new Map;if(r.length===0)return{positions:t};const o=new Map;r.forEach(c=>o.set(c.id,0)),e.forEach(c=>{o.set(c.sourceNodeId,(o.get(c.sourceNodeId)??0)+1),o.set(c.targetNodeId,(o.get(c.targetNodeId)??0)+1)});const i=[...r].sort((c,u)=>(o.get(u.id)??0)-(o.get(c.id)??0)),a=i[0];t.set(a.id,{x:0,y:0});const n=i.slice(1),l=200+n.length*20;return n.forEach((c,u)=>{const d=2*Math.PI*u/n.length;t.set(c.id,{x:Math.cos(d)*l,y:Math.sin(d)*l})}),{positions:t}}function yo(r,e,t){const o=new Map(r.map(w=>[w.id,w])),i=new Map,a=new Set;for(const w of e)w.sourceNodeId===w.targetNodeId||!o.has(w.sourceNodeId)||!o.has(w.targetNodeId)||a.has(w.targetNodeId)||(a.add(w.targetNodeId),i.set(w.sourceNodeId,[...i.get(w.sourceNodeId)??[],w.targetNodeId]));const n=r.filter(w=>!a.has(w.id)),l=t.direction??"TB",c=l==="LR"||l==="RL",u=C.tidyTreeLayout(n.map(w=>d(w.id)),{siblingGap:t.nodeSpacing??40,levelGap:t.rankSpacing??80,direction:c?"LR":"TB"});function d(w,z=new Set){z.add(w);const y=o.get(w);return{id:w,width:y.size.width,height:y.size.height,children:(i.get(w)??[]).filter(_=>!z.has(_)).map(_=>d(_,z))}}const p=new Map,b=new Map;let g=0;for(const[w,z]of u)p.set(w,{x:l==="RL"?-z.x-z.width:z.x,y:l==="BT"?-z.y-z.height:z.y}),b.set(w,z.depth),g=Math.max(g,z.y+z.height);let h=0;for(const w of r)p.has(w.id)||(p.set(w.id,{x:h,y:g+(t.rankSpacing??80)}),h+=w.size.width+(t.nodeSpacing??40));return{positions:p,ranks:b}}function bo(r,e,t){const o=new Map;if(r.length===0)return{positions:o};const i=400,a=new Map;r.forEach(p=>{a.set(p.id,{x:(Math.random()-.5)*i,y:(Math.random()-.5)*i})});const n=e.map(p=>({source:p.sourceNodeId,target:p.targetNodeId})),l=t.nodeSpacing??150,c=80,u=.95;let d=i/2;for(let p=0;p<c;p++){const b=new Map;r.forEach(g=>b.set(g.id,{fx:0,fy:0}));for(let g=0;g<r.length;g++)for(let h=g+1;h<r.length;h++){const w=a.get(r[g].id),z=a.get(r[h].id),y=z.x-w.x,_=z.y-w.y,O=Math.max(Math.sqrt(y*y+_*_),1),k=l*l/O,P=y/O*k,D=_/O*k;b.get(r[g].id).fx-=P,b.get(r[g].id).fy-=D,b.get(r[h].id).fx+=P,b.get(r[h].id).fy+=D}for(const g of n){const h=a.get(g.source),w=a.get(g.target);if(!h||!w)continue;const z=w.x-h.x,y=w.y-h.y,_=Math.max(Math.sqrt(z*z+y*y),1),O=_*_/l,k=z/_*O,P=y/_*O;b.get(g.source).fx+=k,b.get(g.source).fy+=P,b.get(g.target).fx-=k,b.get(g.target).fy-=P}r.forEach(g=>{const h=b.get(g.id),w=a.get(g.id),z=Math.sqrt(h.fx*h.fx+h.fy*h.fy);if(z>0){const y=Math.min(z,d);w.x+=h.fx/z*y,w.y+=h.fy/z*y}}),d*=u}return r.forEach(p=>{o.set(p.id,{...a.get(p.id)})}),t.centerGraph&&Ft(o),{positions:o}}function Ft(r){if(r.size===0)return;let e=1/0,t=1/0,o=-1/0,i=-1/0;r.forEach(l=>{e=Math.min(e,l.x),t=Math.min(t,l.y),o=Math.max(o,l.x),i=Math.max(i,l.y)});const a=(e+o)/2,n=(t+i)/2;r.forEach(l=>{l.x-=a,l.y-=n})}function br(r){const e=m.useRef(null);e.current||(e.current=new vt(r));const t=e.current,[o,i]=m.useState(0),a=m.useCallback(()=>i(c=>c+1),[]);m.useEffect(()=>t.subscribe(a),[t,a]);const n=t.getDocument(),l=m.useCallback((c,u)=>{const d=Ot(t.getNodes(),t.getEdges(),c);t.moveNodes(d.positions,(u==null?void 0:u.history)??!0)},[t]);return m.useMemo(()=>({document:n,nodes:n.nodes,edges:n.edges,groups:n.groups,animations:n.animations,viewport:n.viewport,addNode:(c,u,d,p)=>t.addNode(c,u,d,p),updateNode:(c,u)=>t.updateNode(c,u),moveNode:(c,u)=>t.moveNode(c,u),resizeNode:(c,u)=>t.resizeNode(c,u),removeNode:c=>t.removeNode(c),addEdge:(c,u,d,p,b)=>t.addEdge(c,u,d,p,b),updateEdge:(c,u)=>t.updateEdge(c,u),removeEdge:c=>t.removeEdge(c),createGroup:(c,u)=>t.createGroup(c,u),removeGroup:c=>t.removeGroup(c),toggleGroupCollapse:c=>t.toggleGroupCollapse(c),toggleNodeCollapse:c=>t.toggleNodeCollapse(c),addAnimation:c=>t.addAnimation(c),updateAnimation:(c,u)=>t.updateAnimation(c,u),removeAnimation:c=>t.removeAnimation(c),animationModes:t.getAnimationModes(),activeAnimationMode:t.getActiveAnimationMode(),addAnimationMode:(c,u)=>t.addAnimationMode(c,u),removeAnimationMode:c=>t.removeAnimationMode(c),setActiveAnimationMode:c=>t.setActiveAnimationMode(c),addAnimationToMode:(c,u)=>t.addAnimationToMode(c,u),removeAnimationFromMode:(c,u)=>t.removeAnimationFromMode(c,u),setStylePreset:c=>t.setStylePreset(c),setStyleOverrides:c=>t.setStyleOverrides(c),stylePresetId:n.stylePresetId,playerConfig:t.getPlayerConfig(),setPlayerConfig:c=>t.setPlayerConfig(c),setViewMode:c=>t.setViewMode(c),viewMode:t.getPlayerConfig().mode,applyLayout:l,setViewport:c=>t.setViewport(c),undo:()=>t.undo(),redo:()=>t.redo(),canUndo:t.canUndo(),canRedo:t.canRedo(),loadDocument:c=>t.loadDocument(c),model:t,revision:o}),[n,t,l,o])}function be(r){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)",...r}}function wo(r,e={}){return{backgroundColor:r.surface,borderColor:r.primary,borderWidth:2,borderRadius:8,fontColor:r.text,fontSize:14,fontWeight:"normal",opacity:1,shadow:!0,...e}}function xo(r,e={}){return{strokeColor:r.border,strokeWidth:2,lineType:"bezier",targetArrow:"arrow",...e}}function vo(r,e={}){return{backgroundColor:`${r.primaryLight}18`,borderColor:r.primaryLight,borderWidth:1,borderStyle:"dashed",borderRadius:12,labelColor:r.text,padding:16,...e}}function we(r,e,t,o,i,a,n){return{canvas:r,nodeDefaults:wo(e,o),edgeDefaults:xo(e,i),groupDefaults:vo(e,a),fontFamily:t,palette:e,effects:n}}const Ue="'Inter', system-ui, sans-serif",Lt="'Fira Code', 'Cascadia Code', monospace",ko="'Merriweather', 'Georgia', serif",Co={id:"default-light",name:"Default Light",category:"corporate",themeSource:"Light",config:we({background:"var(--nice-bg, #fff)",gridColor:"#e2e8f020",gridSize:20,selectionColor:"var(--nice-primary, #3b82f6)"},be({}),Ue)},So=be({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)"}),Mo={id:"default-dark",name:"Default Dark",category:"dark",themeSource:"Dark",config:we({background:"var(--nice-bg-primary, #0f172a)",gridColor:"var(--nice-text, #334155)",gridSize:20,selectionColor:"var(--nice-primary-light, #60a5fa)"},So,Ue,{shadow:!1},{strokeColor:"var(--nice-text-secondary, #475569)"},{backgroundColor:"#60a5fa10",borderColor:"#3b82f680"})},Io=be({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)"}),zo={id:"corporate-blue",name:"Corporate Blue",category:"corporate",themeSource:"Blue",config:we({background:"#f0f5ff",gridColor:"#93c5fd20",gridSize:20,selectionColor:"var(--nice-primary-dark, #1d4ed8)"},Io,Ue,{borderWidth:2,borderRadius:6},{strokeColor:"var(--nice-primary-light, #93c5fd)",strokeWidth:2})},No=be({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)"}),Ao={id:"neon-glow",name:"Neon Glow",category:"dark",config:we({background:"#0a0a1a",gridColor:"#00ff8810",gridSize:20,selectionColor:"var(--nice-success, #00ff88)"},No,Lt,{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)"})},_o=be({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"}),Do={id:"cyberpunk",name:"Cyberpunk",category:"dark",config:we({background:"#0d001a",gridColor:"#ff2d9510",gridSize:24,selectionColor:"var(--nice-color-accent-pink, #ff2d95)"},_o,Lt,{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"})},jo=be({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"}),$o={id:"blueprint",name:"Technical Blueprint",category:"technical",config:we({background:"#0a1929",gridColor:"#4da6ff30",gridSize:16,selectionColor:"var(--nice-color-white, #fff)"},jo,Lt,{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})},To=be({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"}),Po={id:"pastel-dream",name:"Pastel Dream",category:"pastel",config:we({background:"#fefcff",gridColor:"#e2d8f420",gridSize:20,selectionColor:"var(--nice-accent, #a78bfa)"},To,"'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})},Eo=be({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"}),Ro={id:"nature-forest",name:"Nature Forest",category:"nature",config:we({background:"#f0fdf4",gridColor:"#a7d7c520",gridSize:20,selectionColor:"var(--nice-success, #059669)"},Eo,Ue,{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)"})},Oo=be({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"}),Fo={id:"retro-terminal",name:"Retro Terminal",category:"retro",config:we({background:"#000800",gridColor:"#00ff0010",gridSize:16,selectionColor:"var(--nice-success, #00ff00)"},Oo,"'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)"})},Lo=be({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)"}),Wo={id:"high-contrast",name:"High Contrast",category:"accessibility",themeSource:"High Contrast",config:we({background:"var(--nice-bg, #fff)",gridColor:"#00000020",gridSize:20,selectionColor:"#0000ff"},Lo,"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})},Bo=be({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)"}),Vo={id:"material-design",name:"Material Design",category:"theme-based",themeSource:"Material",config:we({background:"var(--nice-bg-secondary, #fafafa)",gridColor:"#e0e0e020",gridSize:20,selectionColor:"var(--nice-primary-hover, #1976d2)"},Bo,"'Roboto', 'Noto Sans', sans-serif",{borderRadius:4,borderWidth:0,shadow:!0},{strokeColor:"#bdbdbd",strokeWidth:2},{borderRadius:8})},qo=be({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"}),Go={id:"fluent-ui",name:"Fluent UI",category:"theme-based",themeSource:"Fluent",config:we({background:"#faf9f8",gridColor:"#edebe920",gridSize:20,selectionColor:"#0078d4"},qo,"'Segoe UI', system-ui, sans-serif",{borderRadius:4,borderWidth:1,shadow:!0},{strokeColor:"#c8c6c4",strokeWidth:1})},Yo=be({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)"}),Ho={id:"sunset-warm",name:"Sunset Warm",category:"creative",config:we({background:"#fffde7",gridColor:"#ffccbc20",gridSize:20,selectionColor:"var(--nice-warning-dark, #e65100)"},Yo,Ue,{borderColor:"#ff9e80",gradientColor:"var(--nice-warning-bg, #fff3e0)",gradientDirection:"vertical"},{strokeColor:"#ff9e80"},{},{liquidColor:"var(--nice-warning-dark, #e65100)",liquidColorEnd:"#ffd600",particleColor:"#ffd600"})},Uo=be({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"}),Xo={id:"ocean-deep",name:"Ocean Deep",category:"nature",config:we({background:"#e0f7fa",gridColor:"#b2ebf220",gridSize:20,selectionColor:"#006064"},Uo,Ue,{borderColor:"#00838f",borderRadius:12},{strokeColor:"#4dd0e1"},{},{liquidColor:"#006064",liquidColorEnd:"#4dd0e1",particleColor:"#ffd54f"})},Ko=be({primary:"#5d4037",primaryLight:"#a1887f",secondary:"#795548",accent:"#c6a263",text:"#3e2723",textMuted:"#8d6e63",border:"#bcaaa4",surface:"#fdf6f0",surfaceAlt:"#efebe9"}),Zo={id:"elegant-serif",name:"Elegant Serif",category:"creative",config:we({background:"#fdf6f0",gridColor:"#bcaaa420",gridSize:24,selectionColor:"#5d4037"},Ko,ko,{borderColor:"#a1887f",borderWidth:1,borderRadius:2,fontStyle:"normal"},{strokeColor:"#bcaaa4",strokeWidth:1},{borderRadius:4})},Jo=be({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)"}),Qo={id:"wireframe",name:"Wireframe",category:"technical",config:we({background:"var(--nice-bg, #fff)",gridColor:"#00000008",gridSize:16,selectionColor:"#ff6600"},Jo,"'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)"})},ei=be({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"}),ti={id:"mint-fresh",name:"Mint Fresh",category:"nature",config:we({background:"var(--nice-success-bg, #e8f5e9)",gridColor:"#a7ffeb20",gridSize:20,selectionColor:"#00bfa5"},ei,Ue,{borderColor:"#00bfa5",borderRadius:20,borderWidth:2,gradientColor:"#b2dfdb",gradientDirection:"radial"},{strokeColor:"#64ffda",strokeWidth:2},{borderRadius:16},{liquidColor:"#00bfa5",liquidColorEnd:"#64ffda",particleColor:"#ff6e40"})},ri=be({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)"}),oi={id:"monochrome",name:"Monochrome",category:"corporate",config:we({background:"var(--nice-bg-secondary, #fafafa)",gridColor:"#e0e0e020",gridSize:20,selectionColor:"#424242"},ri,Ue,{borderColor:"var(--nice-border-color, #9e9e9e)",borderWidth:1,shadow:!0,borderRadius:4},{strokeColor:"var(--nice-text-secondary, #9e9e9e)",strokeWidth:1.5})},ii=be({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"}),ai={id:"candy-pop",name:"Candy Pop",category:"creative",config:we({background:"#fff0f5",gridColor:"#f8bbd020",gridSize:20,selectionColor:"var(--nice-color-accent-pink, #e91e63)"},ii,"'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)"})},ni=be({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)"}),si={id:"slate-professional",name:"Slate Professional",category:"corporate",config:we({background:"var(--nice-bg-secondary, #f8fafc)",gridColor:"#cbd5e120",gridSize:20,selectionColor:"var(--nice-text-secondary, #475569)"},ni,"'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})},li=be({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"}),ci={id:"aurora-borealis",name:"Aurora Borealis",category:"dark",config:we({background:"#0f0b2e",gridColor:"#7c3aed15",gridSize:24,selectionColor:"var(--nice-accent, #a78bfa)"},li,Ue,{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)"})},di=be({primary:"#2c3e50",primaryLight:"#7f8c8d",secondary:"#2980b9",accent:"#e74c3c",text:"#2c3e50",textMuted:"#95a5a6",border:"#bdc3c7",surface:"#fdfaf6",surfaceAlt:"#f5f0e8"}),ui={id:"sketch-hand-drawn",name:"Sketch / Hand-drawn",category:"creative",config:we({background:"#fdfaf6",gridColor:"#bdc3c720",gridSize:20,selectionColor:"#2980b9"},di,"'Caveat', 'Patrick Hand', cursive",{backgroundColor:"#fdfaf6",borderColor:"#2c3e50",borderWidth:2,borderRadius:2,shadow:!1},{strokeColor:"#2c3e50",strokeWidth:2},{borderStyle:"dashed",borderWidth:2})},fi=be({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)"}),hi={id:"infographic-bold",name:"Infographic Bold",category:"creative",config:we({background:"#eceff1",gridColor:"#b0bec520",gridSize:24,selectionColor:"var(--nice-danger, #ff5722)"},fi,"'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})},pi=be({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"}),gi={id:"midnight-purple",name:"Midnight Purple",category:"dark",config:we({background:"#0f0720",gridColor:"#9333ea10",gridSize:20,selectionColor:"var(--nice-accent, #c084fc)"},pi,Ue,{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)"})},kt=[Co,Mo,zo,Vo,Go,Ao,Do,$o,Fo,Po,Ho,Xo,Zo,Ro,Qo,Wo,ti,oi,ai,si,ci,ui,hi,gi],mi=[{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}}],yi=[{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}}}],wr=[{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 bi(r){return kt.find(e=>e.id===r)}function wi(r){return kt.filter(e=>e.category===r)}function xi(r){return{canvasBackground:r.canvas.background,gridColor:r.canvas.gridColor,gridSize:r.canvas.gridSize,selectionColor:r.canvas.selectionColor,fontFamily:r.fontFamily,nodeDefaults:r.nodeDefaults,edgeDefaults:r.edgeDefaults,groupDefaults:r.groupDefaults,palette:r.palette,effects:r.effects}}function vi(r,e,t,o,i,a){const n=be({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:o.primary,surfaceAlt:o.secondary}),l=ki(o.primary);return{id:r,name:`${e} Theme`,category:"theme-based",themeSource:e,config:we({background:o.primary,gridColor:l?`${a.color}40`:`${a.color}20`,gridSize:20,selectionColor:t.primary},n,Ue,{shadow:!l,borderWidth:l?1:2},{strokeColor:l?`${a.color}80`:a.color})}}function ki(r){const e=r.replace("#","");if(e.length<6)return!1;const t=parseInt(e.slice(0,2),16),o=parseInt(e.slice(2,4),16),i=parseInt(e.slice(4,6),16);return(t*299+o*587+i*114)/1e3<128}const Ci=["fadeIn","fadeOut","slideInLeft","slideInRight","slideInTop","slideInBottom","zoomIn","zoomOut","pulse","shake","highlight","flowPulse","bounce","glow","colorShift","liquidFill","expand","collapse","ripple","typewriter","morphShape","drawPath","particleTrail"],Si=["linear","easeIn","easeOut","easeInOut","spring","bounce"],Ct=({animations:r,onAdd:e,onRemove:t,onUpdate:o,onPlay:i,onStop:a,isPlaying:n=!1,availableTargets:l=[],className:c})=>{const{t:u}=Be(),[d,p]=m.useState(!1),[b,g]=m.useState(null),h=m.useCallback(()=>{if(!e||l.length===0)return;const y=l[0];e({name:`Animation ${r.length+1}`,targetId:y.id,targetType:y.type,effect:"fadeIn",startMs:r.length*500,durationMs:600,easing:"easeOut"})},[e,r.length,l]),w=m.useCallback(y=>{if(!e||l.length===0)return;const _=l[0];e({name:y.name,targetId:_.id,targetType:_.type,effect:y.effect,startMs:r.length*500,durationMs:y.durationMs,easing:y.easing}),p(!1)},[e,r.length,l]),z=Math.max(2e3,...r.map(y=>y.startMs+y.durationMs+(y.delayMs??0)));return s.jsxs("div",{className:`nice-diagram-timeline ${c??""}`,children:[s.jsxs("div",{className:"nice-diagram-timeline__header",children:[s.jsx("h4",{className:"nice-diagram-timeline__title",children:u("animation.timeline")}),s.jsxs("div",{className:"nice-diagram-timeline__controls",children:[n?s.jsxs(C.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:a,children:[s.jsx(C.NiceIcon,{name:"stop",size:14})," ",u("animation.stop")]}):s.jsxs(C.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:i,children:[s.jsx(C.NiceIcon,{name:"play",size:14})," ",u("animation.play")]}),s.jsxs(C.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:h,disabled:l.length===0,children:[s.jsx(C.NiceIcon,{name:"plus",size:14})," ",u("animation.add")]}),s.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[s.jsxs(C.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:()=>p(y=>!y),disabled:l.length===0,title:u("animation.addFromPreset","Add from preset"),children:[s.jsx(C.NiceIcon,{name:"video",size:14})," ",u("animation.presets","Presets")]}),d&&s.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:wr.map(y=>s.jsx(C.NiceButton,{variant:"ghost",size:"sm",onClick:()=>w(y),style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",fontSize:12,borderBottom:"1px solid var(--nice-bg-secondary, #f0f0f0)"},title:`${y.effect} — ${y.durationMs}ms ${y.easing}`,children:y.name},y.id))})]})]})]}),s.jsxs("div",{className:"nice-diagram-timeline__tracks",children:[r.length===0&&s.jsx("p",{className:"nice-diagram-timeline__empty",children:u("animation.noAnimations")}),r.map(y=>{const _=y.startMs/z*100,O=y.durationMs/z*100,k=b===y.id;return s.jsxs("div",{className:"nice-diagram-timeline__track",children:[s.jsxs("div",{className:"nice-diagram-timeline__track-label",children:[s.jsx("span",{role:"button",tabIndex:0,onKeyDown:C.clickOnActivationKey,className:"nice-diagram-timeline__track-name",onClick:()=>g(k?null:y.id),style:{cursor:"pointer"},title:u("animation.clickToEdit","Click to edit"),children:y.name}),s.jsx("span",{className:"nice-diagram-timeline__track-effect",children:y.effect}),s.jsx(C.NiceButton,{className:"nice-diagram-timeline__track-remove",variant:"ghost",size:"sm",onClick:()=>t==null?void 0:t(y.id),title:u("toolbar.delete"),children:s.jsx(C.NiceIcon,{name:"close",size:14})})]}),k&&s.jsxs("div",{className:"nice-diagram-timeline__track-editor",style:{display:"flex",gap:4,padding:"4px 0",flexWrap:"wrap",fontSize:11},children:[s.jsx(C.NiceSelect,{value:y.effect,onChange:P=>o==null?void 0:o(y.id,{effect:P}),options:Ci.map(P=>({value:P,label:P})),style:{fontSize:11,padding:"1px 4px"}}),s.jsx(C.NiceSelect,{value:y.easing,onChange:P=>o==null?void 0:o(y.id,{easing:P}),options:Si.map(P=>({value:P,label:P})),style:{fontSize:11,padding:"1px 4px"}}),s.jsx(C.NiceSelect,{value:y.targetId,onChange:P=>{const D=l.find(v=>v.id===P);D&&(o==null||o(y.id,{targetId:D.id,targetType:D.type}))},options:l.map(P=>({value:P.id,label:P.label})),style:{fontSize:11,padding:"1px 4px",maxWidth:100}}),s.jsx(C.NiceNumberInput,{value:y.startMs,min:0,step:100,onChange:P=>o==null?void 0:o(y.id,{startMs:P??0}),style:{width:60,fontSize:11},title:u("animation.startMs","Start (ms)")}),s.jsx(C.NiceNumberInput,{value:y.durationMs,min:50,step:50,onChange:P=>o==null?void 0:o(y.id,{durationMs:P??50}),style:{width:60,fontSize:11},title:u("animation.durationMs","Duration (ms)")})]}),s.jsx("div",{className:"nice-diagram-timeline__track-bar",children:s.jsx("div",{className:"nice-diagram-timeline__track-segment",style:{left:`${_}%`,width:`${O}%`},title:`${y.effect} ${y.startMs}ms → ${y.startMs+y.durationMs}ms (${y.easing})`})})]},y.id)})]}),s.jsx("div",{className:"nice-diagram-timeline__ruler",children:Array.from({length:5}).map((y,_)=>{const O=Math.round(z/4*_);return s.jsxs("span",{className:"nice-diagram-timeline__ruler-mark",style:{left:`${_/4*100}%`},children:[O,"ms"]},_)})})]})};process.env.NODE_ENV!=="production"&&(Ct.displayName="AnimationTimeline");function Wt(r){let e=1/0,t=1/0,o=-1/0,i=-1/0;for(const a of r)a.hidden||(e=Math.min(e,a.position.x),t=Math.min(t,a.position.y),o=Math.max(o,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:o-e,height:i-t}:null}function Bt(r,e,t={}){const{padding:o=40,maxZoom:i=1.25,minZoom:a=.1}=t;if(!r||e.width<=0||e.height<=0)return{x:0,y:0,zoom:1};const n=(e.width-2*o)/Math.max(r.width,1),l=(e.height-2*o)/Math.max(r.height,1),c=Math.min(i,Math.max(a,Math.min(n,l)));return{x:(e.width-r.width*c)/2-r.x*c,y:(e.height-r.height*c)/2-r.y*c,zoom:c}}const Mi=/^[a-z][a-z0-9-]*$/,Ii=.1,zi=5,mt=8,At=[{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}],Fe=({treeEdges:r=!1,nodes:e,edges:t,groups:o=[],viewport:i,onViewportChange:a,theme:n,selectedId:l,selectedIds:c=[],onSelectElement:u,onMultiSelect:d,onNodeDragStart:p,onNodeDrag:b,onNodeDragEnd:g,onNodeResize:h,onNodeLabelChange:w,onEdgeCreate:z,autoFit:y=!1,fitKey:_,refitKey:O,fitPadding:k=40,fitMaxZoom:P=1.25,onResize:D,resizable:v=!0,panOnDrag:X=!1,ariaLabel:q,animationStates:L,particleState:M,viewMode:W="editor",ghostOpacity:V=.15,onGroupCollapse:G,onNodeCollapse:N,onInteraction:T,onNodeHover:F,onGroupClick:U,interactive:R=!1,showGrid:K=!0,showRulers:J=!1,snapToGrid:ee=!0,gridSnapSize:ce=10,className:Me})=>{const he=m.useRef(null),Ae=m.useId().replace(/[^a-zA-Z0-9_-]/g,""),Ie=`nd-arrow-${Ae}`,ge=`nd-open-arrow-${Ae}`,Le=`nd-diamond-marker-${Ae}`,Ve=`nd-circle-marker-${Ae}`,[Ne,Xe]=m.useState(null),[Te,Je]=m.useState(!1),[Y,Qe]=m.useState({x:0,y:0}),[_e,qe]=m.useState(null),[Ee,nt]=m.useState({x:0,y:0}),[te,Ge]=m.useState(null),[Re,ae]=m.useState(null),[me,et]=m.useState(null),[Ye,Oe]=m.useState(null),[We,x]=m.useState(""),[H,re]=m.useState([]),ye=(n==null?void 0:n.canvasBackground)??"var(--nice-bg-secondary, #f8f9fa)",ke=(n==null?void 0:n.gridColor)??"var(--nice-border, #e0e0e0)",I=(n==null?void 0:n.gridSize)??20,$=(n==null?void 0:n.selectionColor)??"var(--nice-primary, #2196f3)",[Z,de]=m.useState(null),ze=m.useRef(!1),$e=m.useRef(null),ot=m.useRef({nodes:e,edges:t,onViewportChange:a,onResize:D,fitPadding:k,fitMaxZoom:P});m.useEffect(()=>{ot.current={nodes:e,edges:t,onViewportChange:a,onResize:D,fitPadding:k,fitMaxZoom:P}}),m.useEffect(()=>{const f=he.current;if(!f)return;const S=()=>{const A=f.getBoundingClientRect();A.width>0&&A.height>0&&de(Q=>Q&&Q.width===A.width&&Q.height===A.height?Q:{width:A.width,height:A.height})};if(S(),typeof ResizeObserver>"u")return;const j=new ResizeObserver(S);return j.observe(f),()=>j.disconnect()},[]),m.useEffect(()=>{var f,S;Z&&((S=(f=ot.current).onResize)==null||S.call(f,Z))},[Z]),m.useEffect(()=>{const f=$e.current;f&&(f.x!==i.x||f.y!==i.y||f.zoom!==i.zoom)&&(ze.current=!0)},[i]);const De=m.useRef(O);m.useEffect(()=>{const{nodes:f,edges:S,onViewportChange:j,fitPadding:A,fitMaxZoom:Q}=ot.current,E=O!==De.current;if(De.current=O,E&&(ze.current=!1),!Z||!j||!y&&!E||ze.current)return;const B=Bt(Ni(f,S),Z,{padding:A,maxZoom:Q});$e.current=B,j(B)},[y,Z,_,O]);const dt=m.useMemo(()=>{const f=new Set(c);return l&&f.add(l),f},[l,c]),Ke=m.useCallback(f=>ee?Math.round(f/ce)*ce:f,[ee,ce]),Ht=m.useCallback((f,S,j)=>{const A=[],E=S.x,B=S.y,ne=E+j.width/2,oe=B+j.height/2,ie=E+j.width,se=B+j.height;for(const xe of e){if(xe.id===f)continue;const ve=xe.position.x,ue=xe.position.y,Se=ve+xe.size.width/2,it=ue+xe.size.height/2,Ze=ve+xe.size.width,He=ue+xe.size.height;Math.abs(E-ve)<5&&A.push({x:ve}),Math.abs(ie-Ze)<5&&A.push({x:Ze}),Math.abs(ne-Se)<5&&A.push({x:Se}),Math.abs(E-Ze)<5&&A.push({x:Ze}),Math.abs(ie-ve)<5&&A.push({x:ve}),Math.abs(B-ue)<5&&A.push({y:ue}),Math.abs(se-He)<5&&A.push({y:He}),Math.abs(oe-it)<5&&A.push({y:it}),Math.abs(B-He)<5&&A.push({y:He}),Math.abs(se-ue)<5&&A.push({y:ue})}re(A)},[e]),Vr=m.useCallback(f=>{if(f.preventDefault(),!a)return;const S=f.deltaY>0?.9:1.1,j=Math.min(zi,Math.max(Ii,i.zoom*S)),A=he.current;if(!A)return;const Q=A.getBoundingClientRect(),E=f.clientX-Q.left,B=f.clientY-Q.top,ne=j/i.zoom,oe=E-(E-i.x)*ne,ie=B-(B-i.y)*ne;ze.current=!0,a({x:oe,y:ie,zoom:j})},[i,a]),qr=m.useCallback(f=>{if(f.button===1||f.button===0&&f.target.tagName==="svg"){if(f.button===0&&R&&!X&&!f.shiftKey&&f.target.tagName==="svg"){const S=he.current;if(S){const j=S.getBoundingClientRect(),A=(f.clientX-j.left-i.x)/i.zoom,Q=(f.clientY-j.top-i.y)/i.zoom;ae({x:A,y:Q}),Ge({x1:A,y1:Q,x2:A,y2:Q})}u&&u(null),d&&d([]);return}Je(!0),Qe({x:f.clientX-i.x,y:f.clientY-i.y}),u&&f.button===0&&u(null)}},[i,u,d,R,X]),ht=m.useCallback(f=>{const S=he.current;if(!S)return null;const j=S.getBoundingClientRect();return{x:(f.clientX-j.left-i.x)/i.zoom,y:(f.clientY-j.top-i.y)/i.zoom}},[i]),Gr=m.useCallback(f=>{if(Ne){const S=ht(f);S&&Xe(j=>j&&{...j,to:S});return}if(Re){const S=he.current;if(!S)return;const j=S.getBoundingClientRect(),A=(f.clientX-j.left-i.x)/i.zoom,Q=(f.clientY-j.top-i.y)/i.zoom;Ge({x1:Re.x,y1:Re.y,x2:A,y2:Q});return}if(Te&&a){ze.current=!0,a({...i,x:f.clientX-Y.x,y:f.clientY-Y.y});return}if(me&&h){const S=he.current;if(!S)return;const j=S.getBoundingClientRect(),A=(f.clientX-j.left-i.x)/i.zoom,Q=(f.clientY-j.top-i.y)/i.zoom,E=A-me.startMouse.x,B=Q-me.startMouse.y,ne=At[me.handleIdx];let oe=me.startSize.width+E*ne.resizeX,ie=me.startSize.height+B*ne.resizeY,se=me.startPos.x+(ne.resizeX<0?E:0),xe=me.startPos.y+(ne.resizeY<0?B:0);oe=Math.max(30,Ke(oe)),ie=Math.max(20,Ke(ie)),se=Ke(se),xe=Ke(xe),h(me.nodeId,{width:oe,height:ie},{x:se,y:xe});return}if(_e&&b){const S=he.current;if(!S)return;const j=S.getBoundingClientRect(),A=Ke((f.clientX-j.left-i.x)/i.zoom-Ee.x),Q=Ke((f.clientY-j.top-i.y)/i.zoom-Ee.y);b(_e,{x:A,y:Q});const E=e.find(B=>B.id===_e);E&&Ht(_e,{x:A,y:Q},E.size)}},[Ne,ht,Re,Te,a,i,Y,me,h,_e,b,Ee,Ke,e,Ht]),Ut=m.useCallback(f=>{if(Ne){const S=ht(f),j=S?[...e].reverse().find(A=>A.id!==Ne.nodeId&&!A.hidden&&S.x>=A.position.x&&S.x<=A.position.x+A.size.width&&S.y>=A.position.y&&S.y<=A.position.y+A.size.height):void 0;j&&S&&(z==null||z(Ne.nodeId,j.id,Ne.portId,Ai(j,S))),Xe(null);return}if(te&&Re){const S=Math.min(te.x1,te.x2),j=Math.min(te.y1,te.y2),A=Math.max(te.x1,te.x2),Q=Math.max(te.y1,te.y2);if(Math.abs(A-S)>5||Math.abs(Q-j)>5){const E=e.filter(B=>{const ne=B.position.x,oe=B.position.y,ie=ne+B.size.width,se=oe+B.size.height;return ie>S&&ne<A&&se>j&&oe<Q}).map(B=>B.id);d==null||d(E),E.length===1&&(u==null||u(E[0]))}Ge(null),ae(null);return}if(Te&&Je(!1),me){et(null);return}if(_e&&g){const S=he.current;if(!S)return;const j=S.getBoundingClientRect(),A=Ke((f.clientX-j.left-i.x)/i.zoom-Ee.x),Q=Ke((f.clientY-j.top-i.y)/i.zoom-Ee.y);g(_e,{x:A,y:Q})}qe(null),re([])},[Ne,ht,z,te,Re,Te,me,_e,g,i,Ee,Ke,e,d,u]),Yr=m.useCallback((f,S)=>{if(f.stopPropagation(),!R)return;const j=e.find(ne=>ne.id===S);if(!j||j.locked)return;if(f.shiftKey&&d){const ne=[...c],oe=ne.indexOf(S);oe>=0?ne.splice(oe,1):ne.push(S),d(ne);return}u==null||u(S);const A=he.current;if(!A)return;const Q=A.getBoundingClientRect(),E=(f.clientX-Q.left-i.x)/i.zoom,B=(f.clientY-Q.top-i.y)/i.zoom;nt({x:E-j.position.x,y:B-j.position.y}),qe(S),p==null||p(S)},[R,e,i,u,p,d,c]),Hr=m.useCallback((f,S,j)=>{if(f.stopPropagation(),!R)return;const A=e.find(oe=>oe.id===S);if(!A||A.locked)return;const Q=he.current;if(!Q)return;const E=Q.getBoundingClientRect(),B=(f.clientX-E.left-i.x)/i.zoom,ne=(f.clientY-E.top-i.y)/i.zoom;et({nodeId:S,handleIdx:j,startMouse:{x:B,y:ne},startPos:{...A.position},startSize:{...A.size}}),u==null||u(S)},[R,e,i,u]),Ur=m.useCallback((f,S)=>{if(f.stopPropagation(),!R||!w)return;const j=e.find(A=>A.id===S);!j||j.locked||(Oe(S),x(j.label))},[R,e,w]),Xt=m.useCallback(()=>{Ye&&w&&w(Ye,We),Oe(null)},[Ye,We,w]),Xr=m.useCallback((f,S)=>{f.stopPropagation(),u==null||u(S)},[u]),ut=(f,S,j)=>({tabIndex:0,role:"button","aria-label":f,...j!==void 0?{"aria-pressed":j}:{},onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),A.stopPropagation(),S())}}),Kr=m.useCallback(f=>wt(f,e,{treeEdges:r}),[e,r]),Zr=m.useCallback((f,S)=>{const{size:j,style:A,shape:Q}=f,E=j.width,B=j.height,oe=!!(A.gradientColor&&A.backgroundColor)?`url(#${S})`:A.backgroundColor??"var(--nice-bg, #fff)",ie=A.borderColor??"var(--nice-text, #333333)",se=A.borderWidth??1,xe=A.borderRadius??(Q==="roundedRect"?8:0),ve=A.borderStyle==="dashed"?"8,4":A.borderStyle==="dotted"?"2,4":void 0,ue=A.shadow?"url(#nd-shadow)":void 0;switch(Q){case"ellipse":case"circle":return s.jsx("ellipse",{cx:E/2,cy:B/2,rx:E/2,ry:B/2,fill:oe,stroke:ie,strokeWidth:se,strokeDasharray:ve,filter:ue});case"diamond":return s.jsx("polygon",{points:`${E/2},0 ${E},${B/2} ${E/2},${B} 0,${B/2}`,fill:oe,stroke:ie,strokeWidth:se,strokeDasharray:ve,filter:ue});case"hexagon":{const Se=E/4;return s.jsx("polygon",{points:`${Se},0 ${E-Se},0 ${E},${B/2} ${E-Se},${B} ${Se},${B} 0,${B/2}`,fill:oe,stroke:ie,strokeWidth:se,strokeDasharray:ve,filter:ue})}case"parallelogram":{const Se=E*.15;return s.jsx("polygon",{points:`${Se},0 ${E},0 ${E-Se},${B} 0,${B}`,fill:oe,stroke:ie,strokeWidth:se,strokeDasharray:ve,filter:ue})}case"cylinder":return s.jsxs("g",{filter:ue,children:[s.jsx("ellipse",{cx:E/2,cy:B*.1,rx:E/2,ry:B*.1,fill:oe,stroke:ie,strokeWidth:se}),s.jsx("rect",{x:0,y:B*.1,width:E,height:B*.8,fill:oe,stroke:"none"}),s.jsx("line",{x1:0,y1:B*.1,x2:0,y2:B*.9,stroke:ie,strokeWidth:se}),s.jsx("line",{x1:E,y1:B*.1,x2:E,y2:B*.9,stroke:ie,strokeWidth:se}),s.jsx("ellipse",{cx:E/2,cy:B*.9,rx:E/2,ry:B*.1,fill:oe,stroke:ie,strokeWidth:se})]});case"triangle":return s.jsx("polygon",{points:`${E/2},0 ${E},${B} 0,${B}`,fill:oe,stroke:ie,strokeWidth:se,strokeDasharray:ve,filter:ue});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 s.jsx("path",{d:Se,fill:oe,stroke:ie,strokeWidth:se,filter:ue})}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 s.jsx("path",{d:Se,fill:oe,stroke:ie,strokeWidth:se,filter:ue})}case"actor":return s.jsxs("g",{stroke:ie,strokeWidth:se,fill:"none",filter:ue,children:[s.jsx("circle",{cx:E/2,cy:B*.15,r:B*.12,fill:oe}),s.jsx("line",{x1:E/2,y1:B*.27,x2:E/2,y2:B*.6}),s.jsx("line",{x1:E*.15,y1:B*.4,x2:E*.85,y2:B*.4}),s.jsx("line",{x1:E/2,y1:B*.6,x2:E*.2,y2:B}),s.jsx("line",{x1:E/2,y1:B*.6,x2:E*.8,y2:B})]});case"rectangle":case"roundedRect":case"custom":default:return s.jsx("rect",{width:E,height:B,rx:xe,ry:xe,fill:oe,stroke:ie,strokeWidth:se,strokeDasharray:ve,filter:ue})}},[]),Kt=m.useCallback(f=>{if(!L)return{};const S=L.get(f);if(!S)return{};const j=S.glow>0?`drop-shadow(0 0 ${S.glow}px gold)`:"",A=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:[j,A].filter(Boolean).join(" ")||void 0}},[L]),Jr=m.useMemo(()=>{if(!M)return null;const f=[];for(const[,S]of M.glowStates){const j=sr(S.elementId),A=lr(S.intensity,S.pulse);f.push(s.jsxs("filter",{id:j,x:"-50%",y:"-50%",width:"200%",height:"200%",children:[s.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:A,result:"blur"}),s.jsx("feFlood",{floodColor:S.color,floodOpacity:.6,result:"color"}),s.jsx("feComposite",{in:"color",in2:"blur",operator:"in",result:"glowColored"}),s.jsxs("feMerge",{children:[s.jsx("feMergeNode",{in:"glowColored"}),s.jsx("feMergeNode",{in:"SourceGraphic"})]})]},j))}return f},[M]),Qr=m.useMemo(()=>{if(!M)return null;const f=[];for(const[S,j]of M.liquidFlows){if(!j.active)continue;const A=t.find(oe=>oe.id===S);if(!(A!=null&&A.style.liquidFlow))continue;const{color:Q,colorEnd:E}=A.style.liquidFlow,B=`nd-liquid-${S}`,ne=j.gradientOffset;f.push(s.jsxs("linearGradient",{id:B,x1:"0",y1:"0",x2:"1",y2:"0",children:[s.jsx("stop",{offset:`${ne*100%100}%`,stopColor:Q,stopOpacity:.8}),s.jsx("stop",{offset:`${(ne+.3)*100%100}%`,stopColor:E??Q,stopOpacity:.4}),s.jsx("stop",{offset:`${(ne+.6)*100%100}%`,stopColor:Q,stopOpacity:.8})]},B))}return f},[M,t]),eo=m.useMemo(()=>e.filter(f=>f.style.gradientColor&&f.style.backgroundColor).map(f=>{const S=`nd-grad-${f.id}`,j=f.style.gradientDirection??"vertical";if(j==="radial")return s.jsxs("radialGradient",{id:S,children:[s.jsx("stop",{offset:"0%",stopColor:f.style.backgroundColor}),s.jsx("stop",{offset:"100%",stopColor:f.style.gradientColor})]},S);const A=j==="horizontal"||j==="diagonal"?"1":"0",Q=j==="vertical"||j==="diagonal"?"1":"0";return s.jsxs("linearGradient",{id:S,x1:"0",y1:"0",x2:A,y2:Q,children:[s.jsx("stop",{offset:"0%",stopColor:f.style.backgroundColor}),s.jsx("stop",{offset:"100%",stopColor:f.style.gradientColor})]},S)}),[e]);return s.jsxs("svg",{ref:he,className:`nice-diagram-canvas ${Me??""}`,style:{width:"100%",height:"100%",background:ye,cursor:Te?"grabbing":me?me.nodeId?At[me.handleIdx].cursor:"default":Ne?"crosshair":X?"grab":"default"},"aria-label":q,onWheel:Vr,onMouseDown:qr,onMouseMove:Gr,onMouseUp:Ut,onMouseLeave:Ut,children:[s.jsxs("defs",{children:[s.jsx("marker",{id:Ie,viewBox:"0 0 10 10",refX:"10",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 Z",fill:"var(--nice-text, #333)"})}),s.jsx("marker",{id:ge,viewBox:"0 0 10 10",refX:"10",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10",fill:"none",stroke:"var(--nice-text, #333)",strokeWidth:"1.5"})}),s.jsx("marker",{id:Le,viewBox:"0 0 10 10",refX:"5",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"15",markerHeight:"15",orient:"auto-start-reverse",children:s.jsx("polygon",{points:"5,0 10,5 5,10 0,5",fill:"var(--nice-text, #333)"})}),s.jsx("marker",{id:Ve,viewBox:"0 0 10 10",refX:"5",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:s.jsx("circle",{cx:"5",cy:"5",r:"4",fill:"var(--nice-text, #333)"})}),s.jsx("filter",{id:"nd-shadow",x:"-10%",y:"-10%",width:"130%",height:"130%",children:s.jsx("feDropShadow",{dx:"2",dy:"2",stdDeviation:"3",floodColor:"#00000033"})}),K&&s.jsx("pattern",{id:"nd-grid",width:I,height:I,patternUnits:"userSpaceOnUse",children:s.jsx("path",{d:`M ${I} 0 L 0 0 0 ${I}`,fill:"none",stroke:ke,strokeWidth:"0.5"})}),eo,Jr,Qr,e.filter(f=>f.style.glowColor).map(f=>{const S=`nd-node-glow-${f.id}`,j=(f.style.glowIntensity??.5)*10;return s.jsxs("filter",{id:S,x:"-50%",y:"-50%",width:"200%",height:"200%",children:[s.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:j,result:"blur"}),s.jsx("feFlood",{floodColor:f.style.glowColor,floodOpacity:.5,result:"color"}),s.jsx("feComposite",{in:"color",in2:"blur",operator:"in",result:"glowColored"}),s.jsxs("feMerge",{children:[s.jsx("feMergeNode",{in:"glowColored"}),s.jsx("feMergeNode",{in:"SourceGraphic"})]})]},S)})]}),J&&s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"0",y:"0",width:"100%",height:"20",fill:"var(--nice-bg-secondary, #f0f0f0)",stroke:"var(--nice-border, #ccc)",strokeWidth:"0.5"}),s.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 j=S*I*i.zoom+i.x,A=S*I;return j>20?s.jsxs("g",{children:[s.jsx("line",{x1:j,y1:"0",x2:j,y2:"20",stroke:"var(--nice-text-muted, #999)",strokeWidth:"0.5"}),s.jsx("text",{x:j+2,y:"14",fontSize:"9",fill:"var(--nice-text-secondary, #666)",children:A})]},`rx${S}`):null}),Array.from({length:100},(f,S)=>{const j=S*I*i.zoom+i.y,A=S*I;return j>20?s.jsxs("g",{children:[s.jsx("line",{x1:"0",y1:j,x2:"20",y2:j,stroke:"var(--nice-text-muted, #999)",strokeWidth:"0.5"}),s.jsx("text",{x:"2",y:j-2,fontSize:"9",fill:"var(--nice-text-secondary, #666)",writingMode:"tb",children:A})]},`ry${S}`):null})]}),s.jsxs("g",{transform:`translate(${i.x}, ${i.y}) scale(${i.zoom})`,children:[K&&s.jsx("rect",{x:"-10000",y:"-10000",width:"20000",height:"20000",fill:"url(#nd-grid)",pointerEvents:"none"}),o.map(f=>{var ne,oe,ie,se,xe,ve,ue,Se,it,Ze,He,pt;const S=e.filter(pe=>f.nodeIds.includes(pe.id));if(S.length===0&&!f.collapsed)return null;const j=((ne=f.style)==null?void 0:ne.padding)??20;if(f.collapsed){const pe=e.find(zt=>f.nodeIds.includes(zt.id)),lt=pe?pe.position.x:0,gt=pe?pe.position.y:0;return s.jsxs("g",{"data-group-id":f.id,...G?ut(f.label||f.id,()=>G(f.id),!1):{},style:{cursor:"pointer"},onClick:()=>G==null?void 0:G(f.id),children:[s.jsx("rect",{x:lt,y:gt,width:160,height:40,fill:((oe=f.style)==null?void 0:oe.backgroundColor)??"rgba(200,200,255,0.3)",stroke:((ie=f.style)==null?void 0:ie.borderColor)??"var(--nice-text-muted, #aab)",strokeWidth:((se=f.style)==null?void 0:se.borderWidth)??1,rx:((xe=f.style)==null?void 0:xe.borderRadius)??6,strokeDasharray:"6,3"}),s.jsxs("text",{x:lt+24,y:gt+24,fontSize:"12",fill:((ve=f.style)==null?void 0:ve.labelColor)??"var(--nice-text-secondary, #666)",fontWeight:"bold",children:[f.label," (",f.nodeIds.length,")"]})]},f.id)}const A=Math.min(...S.map(pe=>pe.position.x))-j,Q=Math.min(...S.map(pe=>pe.position.y))-j,E=Math.max(...S.map(pe=>pe.position.x+pe.size.width))+j,B=Math.max(...S.map(pe=>pe.position.y+pe.size.height))+j;return s.jsxs("g",{"data-group-id":f.id,children:[s.jsx("rect",{x:A,y:Q,width:E-A,height:B-Q,fill:((ue=f.style)==null?void 0:ue.backgroundColor)??"rgba(200,200,255,0.1)",stroke:((Se=f.style)==null?void 0:Se.borderColor)??"var(--nice-text-muted, #aab)",strokeWidth:((it=f.style)==null?void 0:it.borderWidth)??1,rx:((Ze=f.style)==null?void 0:Ze.borderRadius)??6,strokeDasharray:((He=f.style)==null?void 0:He.borderStyle)==="dashed"?"6,3":void 0}),s.jsx("text",{x:A+6,y:Q-4,fontSize:"12",fill:((pt=f.style)==null?void 0:pt.labelColor)??"var(--nice-text-secondary, #666)",fontWeight:"bold",style:U?{cursor:"pointer"}:void 0,...U?ut(f.label||f.id,()=>U(f.id)):{},onClick:U?pe=>{pe.stopPropagation(),U(f.id)}:void 0,children:f.label}),(R||W!=="editor")&&G&&s.jsxs("g",{...ut(f.label||f.id,()=>G(f.id),!0),style:{cursor:"pointer"},onClick:pe=>{pe.stopPropagation(),G(f.id)},children:[s.jsx("rect",{x:E-24,y:Q-12,width:20,height:20,rx:4,fill:"white",stroke:"var(--nice-text-muted, #999)",strokeWidth:1}),s.jsx("g",{transform:`translate(${E-20}, ${Q-8})`,children:s.jsx(C.NiceIcon,{name:"chevron-down",size:12,color:"var(--nice-text-secondary, #666)"})})]})]},f.id)}),H.map((f,S)=>s.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}`)),t.map(f=>{var ve;const{d:S,mid:j}=Kr(f),A=dt.has(f.id),Q=f.style.targetArrow==="diamond"?`url(#${Le})`:f.style.targetArrow==="circle"?`url(#${Ve})`:f.style.targetArrow==="openArrow"?`url(#${ge})`:f.style.targetArrow!=="none"?`url(#${Ie})`:void 0,E=f.style.sourceArrow==="diamond"?`url(#${Le})`:f.style.sourceArrow==="circle"?`url(#${Ve})`:f.style.sourceArrow==="openArrow"?`url(#${ge})`:f.style.sourceArrow==="arrow"?`url(#${Ie})`:void 0,B=Kt(f.id),ne=L==null?void 0:L.get(f.id),oe=ne==null?void 0:ne.strokeProgress,ie=oe!=null&&oe>=0&&oe<1?{strokeDasharray:"1000",strokeDashoffset:`${1e3*(1-oe)}`}:void 0,se=f.style.liquidFlow,xe=M==null?void 0:M.liquidFlows.get(f.id);return s.jsxs("g",{"data-edge-id":f.id,...u?ut(f.label||`${f.sourceNodeId} – ${f.targetNodeId}`,()=>u(f.id),A):{},style:B,onClick:ue=>Xr(ue,f.id),children:[R&&s.jsx("path",{d:S,fill:"none",stroke:"transparent",strokeWidth:12,style:{cursor:"pointer"}}),(se==null?void 0:se.active)&&s.jsx("path",{d:S,fill:"none",stroke:`url(#nd-liquid-${f.id})`,strokeWidth:se.pipeWidth??(f.style.strokeWidth??1.5)*4,strokeLinecap:"round",opacity:.5}),s.jsx("path",{d:S,fill:"none",stroke:A?$:f.style.strokeColor??"var(--nice-text, #333)",strokeWidth:f.style.strokeWidth??1.5,strokeDasharray:(ie==null?void 0:ie.strokeDasharray)??((ve=f.style.strokeDash)==null?void 0:ve.join(","))??(f.style.animated?"6,4":void 0),strokeDashoffset:ie==null?void 0:ie.strokeDashoffset,markerEnd:Q,markerStart:E,opacity:f.style.opacity??1,style:R?{cursor:"pointer",transition:ie?void 0:"stroke-dashoffset 0.1s"}:void 0}),f.style.animated&&s.jsx("circle",{r:3,fill:$,children:s.jsx("animateMotion",{dur:`${1/(f.style.flowSpeed||1)}s`,repeatCount:"indefinite",path:S})}),(xe==null?void 0:xe.active)&&xe.particles.map((ue,Se)=>s.jsx("circle",{r:ue.size,fill:(se==null?void 0:se.color)??"var(--nice-primary, #3b82f6)",opacity:ue.opacity*.6,children:s.jsx("animateMotion",{dur:`${3/(((se==null?void 0:se.speed)??1)+.5)}s`,repeatCount:"indefinite",path:S,begin:`${ue.t*3}s`})},`lp-${f.id}-${Se}`)),ne&&ne.particleTrailT>=0&&s.jsxs(s.Fragment,{children:[s.jsx("circle",{r:4,fill:"var(--nice-warning-light, #fbbf24)",opacity:.8,children:s.jsx("animateMotion",{dur:"2s",repeatCount:"indefinite",path:S,begin:`${ne.particleTrailT*2}s`})}),s.jsx("circle",{r:2,fill:"var(--nice-warning-light, #fbbf24)",opacity:.5,children:s.jsx("animateMotion",{dur:"2s",repeatCount:"indefinite",path:S,begin:`${(ne.particleTrailT+.1)*2}s`})})]}),f.label&&(()=>{const ue=f.label.length*7+8;return s.jsxs("g",{children:[s.jsx("rect",{x:j.x-ue/2,y:j.y-9,width:ue,height:18,rx:3,fill:"var(--nice-bg-primary, #fff)",fillOpacity:.85}),s.jsx("text",{x:j.x,y:j.y+4,textAnchor:"middle",fontSize:"11",fill:"var(--nice-text-secondary, #555)",children:f.label})]})})()]},f.id)}),e.filter(f=>!f.hidden||W==="editor").map(f=>{const S=dt.has(f.id),j=Kt(f.id),A=L==null?void 0:L.get(f.id),Q=f.style.fontFamily??(n==null?void 0:n.fontFamily)??"sans-serif",E=f.style.fontSize??14,B=f.style.fontColor??"var(--nice-text, #222)",ne=f.style.fontWeight??"normal",oe=f.style.fontStyle??"normal",ie=f.style.textAlign??"center",se=f.style.rotation??0,xe=`nd-grad-${f.id}`,ve=!!f.hidden,ue=ve?V??.3:f.style.opacity??1,Se=f.style.glowColor?`url(#nd-node-glow-${f.id})`:void 0,it=ie==="left"?"start":ie==="right"?"end":"middle",Ze=ie==="left"?8:ie==="right"?f.size.width-8:f.size.width/2,He=A==null?void 0:A.typewriterChars,pt=He!=null&&He>=0?f.label.slice(0,He):f.label,pe=A==null?void 0:A.liquidFillProgress,lt=A==null?void 0:A.rippleRadius,gt=A==null?void 0:A.rippleOpacity,zt=f.childNodeIds&&f.childNodeIds.length>0,to=!!f.collapsed;return s.jsxs("g",{"data-node-id":f.id,...u?ut(f.label||f.id,()=>u(f.id),S):{},transform:`translate(${f.position.x}, ${f.position.y})${se?` rotate(${se}, ${f.size.width/2}, ${f.size.height/2})`:""}`,style:{...j,cursor:ve?"pointer":R&&!f.locked&&b?"grab":u?"pointer":"default",opacity:ue,filter:Se},onMouseDown:Ce=>Yr(Ce,f.id),onDoubleClick:Ce=>Ur(Ce,f.id),onClick:Ce=>{Ce.stopPropagation(),u==null||u(f.id),f.interactions&&f.interactions.length>0&&f.interactions.filter(at=>at.trigger==="click").forEach(at=>T==null?void 0:T(f.id,at.id))},onMouseEnter:()=>{F==null||F(f.id),f.interactions&&f.interactions.filter(Pe=>Pe.trigger==="hover").forEach(Pe=>T==null?void 0:T(f.id,Pe.id))},onMouseLeave:()=>F==null?void 0:F(null),children:[ve&&s.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}),Zr(f,xe),pe!=null&&pe>0&&pe<1&&s.jsx("clipPath",{id:`nd-liquid-clip-${f.id}`,children:s.jsx("rect",{x:0,y:f.size.height*(1-pe),width:f.size.width,height:f.size.height*pe})}),pe!=null&&pe>0&&pe<1&&s.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})`}),lt!=null&&lt>0&&s.jsx("circle",{cx:f.size.width/2,cy:f.size.height/2,r:lt,fill:"none",stroke:f.style.glowColor??$,strokeWidth:2,opacity:gt??.5}),S&&s.jsx("rect",{x:-3,y:-3,width:f.size.width+6,height:f.size.height+6,fill:"none",stroke:$,strokeWidth:2,strokeDasharray:"4,3",rx:6}),S&&R&&v&&!f.locked&&At.map((Ce,Pe)=>s.jsx("rect",{x:Ce.dx*f.size.width-mt/2,y:Ce.dy*f.size.height-mt/2,width:mt,height:mt,fill:"white",stroke:$,strokeWidth:1.5,rx:1,style:{cursor:Ce.cursor},onMouseDown:at=>Hr(at,f.id,Pe)},Pe)),Ye===f.id?s.jsx("foreignObject",{x:4,y:4,width:f.size.width-8,height:f.size.height-8,children:s.jsx("input",{xmlns:"http://www.w3.org/1999/xhtml",type:"text",value:We,onChange:Ce=>x(Ce.target.value),onBlur:Xt,onKeyDown:Ce=>{Ce.key==="Enter"&&Xt(),Ce.key==="Escape"&&Oe(null)},autoFocus:!0,style:{width:"100%",height:"100%",border:"1px solid "+$,borderRadius:3,padding:"2px 4px",fontSize:E,fontFamily:Q,fontWeight:ne,fontStyle:oe,textAlign:ie,background:"var(--nice-overlay-light-95, rgba(255, 255, 255, 0.95))",outline:"none"}})}):s.jsxs(s.Fragment,{children:[s.jsx("text",{x:Ze,y:f.size.height/2+(f.description?-4:0),textAnchor:it,dominantBaseline:"central",fontFamily:Q,fontSize:E,fontWeight:ne,fontStyle:oe,fill:B,pointerEvents:"none",children:pt}),f.description&&s.jsx("text",{x:Ze,y:f.size.height/2+E*.8,textAnchor:it,dominantBaseline:"central",fontFamily:Q,fontSize:E*.75,fill:"var(--nice-text-secondary, #777)",pointerEvents:"none",children:f.description}),f.icon&&(Mi.test(f.icon)?s.jsx("g",{transform:`translate(${f.size.width/2-8}, 4)`,pointerEvents:"none",children:s.jsx(C.NiceIcon,{name:f.icon,size:16,color:"var(--nice-text-secondary, #666)"})}):s.jsx("text",{x:f.size.width/2,y:14,textAnchor:"middle",fontSize:16,pointerEvents:"none",children:f.icon})),f.style.linkUrl&&s.jsx("g",{transform:`translate(${f.size.width-14}, 3)`,pointerEvents:"none",children:s.jsx(C.NiceIcon,{name:"link",size:10,color:"var(--nice-primary-hover, #1976d2)"})}),zt&&R&&s.jsxs("g",{onClick:Ce=>{Ce.stopPropagation(),N==null||N(f.id)},style:{cursor:"pointer"},children:[s.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}),s.jsx("g",{transform:`translate(${f.size.width-15}, ${f.size.height-15})`,children:s.jsx(C.NiceIcon,{name:to?"chevron-right":"chevron-down",size:10,color:"var(--nice-text-secondary, #666)"})})]})]}),R&&f.ports.map(Ce=>{const Pe=xr(f,Ce.id),at=z?ro=>{if(ro.stopPropagation(),f.locked)return;const Zt={x:f.position.x+Pe.x,y:f.position.y+Pe.y};Xe({nodeId:f.id,portId:Ce.id,from:Zt,to:Zt})}:void 0;return s.jsxs("g",{"data-port-id":Ce.id,onMouseDown:at,children:[at&&s.jsx("circle",{cx:Pe.x,cy:Pe.y,r:9,fill:"transparent",style:{cursor:"crosshair"}}),s.jsx("circle",{cx:Pe.x,cy:Pe.y,r:4,fill:"var(--nice-bg-primary, #fff)",stroke:"var(--nice-text-secondary, #666)",strokeWidth:1,style:{cursor:"crosshair"}})]},Ce.id)})]},f.id)}),M&&M.particles.length>0&&s.jsx("g",{className:"nd-particle-overlay",children:M.particles.map((f,S)=>s.jsx("circle",{cx:f.x,cy:f.y,r:f.size,fill:f.color,opacity:f.opacity},`ptcl-${S}`))}),Ne&&s.jsx("path",{d:`M ${Ne.from.x} ${Ne.from.y} L ${Ne.to.x} ${Ne.to.y}`,fill:"none",stroke:$,strokeWidth:1.5,strokeDasharray:"5,4",markerEnd:`url(#${Ie})`,pointerEvents:"none"}),te&&s.jsx("rect",{x:Math.min(te.x1,te.x2),y:Math.min(te.y1,te.y2),width:Math.abs(te.x2-te.x1),height:Math.abs(te.y2-te.y1),fill:"rgba(33,150,243,0.1)",stroke:$,strokeWidth:1,strokeDasharray:"4,2"})]})]})};process.env.NODE_ENV!=="production"&&(Fe.displayName="DiagramCanvas");function Ni(r,e){const t=Wt(r);if(!t)return null;let[o,i,a,n]=[t.x,t.y,t.x+t.width,t.y+t.height];const l=(c,u=0,d=0)=>{o=Math.min(o,c.x-u),i=Math.min(i,c.y-d),a=Math.max(a,c.x+u),n=Math.max(n,c.y+d)};for(const c of e){const u=wt(c,r);u.extent.forEach(d=>l(d)),c.label&&l(u.mid,(c.label.length*7+8)/2,9)}return{x:o,y:i,width:a-o,height:n-i}}function Ai(r,e){let t="",o=1/0;for(const i of r.ports){const a=xr(r,i.id),n=Math.hypot(r.position.x+a.x-e.x,r.position.y+a.y-e.y);n<o&&(o=n,t=i.id)}return t}function xr(r,e){const t=r.ports.find(i=>i.id===e);if(!t)return{x:0,y:0};const{size:o}=r;switch(t.side){case"top":return{x:o.width*t.offset,y:0};case"bottom":return{x:o.width*t.offset,y:o.height};case"left":return{x:0,y:o.height*t.offset};case"right":return{x:o.width,y:o.height*t.offset};default:return{x:0,y:0}}}const _i=180,Di=120,ft=({nodes:r,edges:e,viewport:t,onViewportChange:o,canvasWidth:i=800,canvasHeight:a=600,width:n=_i,height:l=Di,className:c})=>{const u=m.useMemo(()=>{if(r.length===0)return{minX:0,minY:0,maxX:400,maxY:300};let w=1/0,z=1/0,y=-1/0,_=-1/0;for(const k of r)w=Math.min(w,k.position.x),z=Math.min(z,k.position.y),y=Math.max(y,k.position.x+k.size.width),_=Math.max(_,k.position.y+k.size.height);const O=50;return{minX:w-O,minY:z-O,maxX:y+O,maxY:_+O}},[r]),d=u.maxX-u.minX,p=u.maxY-u.minY,b=Math.min(n/d,l/p),g=m.useMemo(()=>{const w=(-t.x/t.zoom-u.minX)*b,z=(-t.y/t.zoom-u.minY)*b,y=i/t.zoom*b,_=a/t.zoom*b;return{x:w,y:z,w:y,h:_}},[t,u,b,i,a]),h=m.useCallback(w=>{if(!o)return;const z=w.currentTarget.getBoundingClientRect(),y=w.clientX-z.left,_=w.clientY-z.top,O=y/b+u.minX,k=_/b+u.minY;o({...t,x:-(O*t.zoom-i/2),y:-(k*t.zoom-a/2)})},[o,t,b,u,i,a]);return s.jsxs("svg",{className:`nice-diagram-minimap ${c??""}`,width:n,height:l,style:{border:"1px solid var(--nice-border, #ccc)",background:"var(--nice-bg, #fff)",borderRadius:4,cursor:"pointer"},onClick:h,children:[e.map(w=>{const z=r.find(D=>D.id===w.sourceNodeId),y=r.find(D=>D.id===w.targetNodeId);if(!z||!y)return null;const _=(z.position.x+z.size.width/2-u.minX)*b,O=(z.position.y+z.size.height/2-u.minY)*b,k=(y.position.x+y.size.width/2-u.minX)*b,P=(y.position.y+y.size.height/2-u.minY)*b;return s.jsx("line",{x1:_,y1:O,x2:k,y2:P,stroke:"var(--nice-text-muted, #aaa)",strokeWidth:.5},w.id)}),r.map(w=>s.jsx("rect",{x:(w.position.x-u.minX)*b,y:(w.position.y-u.minY)*b,width:w.size.width*b,height:w.size.height*b,fill:w.style.backgroundColor??"var(--nice-border, #ddd)",stroke:"var(--nice-text-muted, #999)",strokeWidth:.5},w.id)),s.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"&&(ft.displayName="DiagramMinimap");const ji=["rectangle","roundedRect","ellipse","circle","diamond","hexagon","parallelogram","cylinder","triangle","cloud","document","actor"],St=({selectedNode:r,selectedEdge:e,onNodeChange:t,onEdgeChange:o,onRemove:i,className:a})=>{var u,d,p,b,g;const{t:n}=Be(),l=m.useCallback((h,w)=>{!r||!t||t(r.id,{style:{...r.style,[h]:w}})},[r,t]),c=m.useCallback((h,w)=>{!e||!o||o(e.id,{style:{...e.style,[h]:w}})},[e,o]);return!r&&!e?s.jsx("div",{className:`nice-diagram-property-panel nice-diagram-property-panel--empty ${a??""}`,children:s.jsx("p",{className:"nice-diagram-property-panel__hint",children:n("panel.noSelection")})}):r?s.jsxs("div",{className:`nice-diagram-property-panel ${a??""}`,children:[s.jsx("h3",{className:"nice-diagram-property-panel__title",children:n("panel.nodeProperties")}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.label"),s.jsx(C.NiceTextInput,{value:r.label,onChange:h=>t==null?void 0:t(r.id,{label:h}),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.description"),s.jsx(C.NiceTextInput,{value:r.description??"",onChange:h=>t==null?void 0:t(r.id,{description:h||void 0}),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.shape"),s.jsx(C.NiceSelect,{value:r.shape,onChange:h=>t==null?void 0:t(r.id,{shape:h}),options:ji.map(h=>({value:h,label:h})),className:"nice-diagram-property-panel__select"})]}),s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.width"),s.jsx(C.NiceNumberInput,{value:r.size.width,min:20,onChange:h=>t==null?void 0:t(r.id,{size:{...r.size,width:h??40}}),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.height"),s.jsx(C.NiceNumberInput,{value:r.size.height,min:20,onChange:h=>t==null?void 0:t(r.id,{size:{...r.size,height:h??40}}),className:"nice-diagram-property-panel__input"})]})]}),s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.bgColor"),s.jsx(C.NiceColorPicker,{value:r.style.backgroundColor??"var(--nice-bg, #fff)",onChange:h=>l("backgroundColor",h),className:"nice-diagram-property-panel__color"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.borderColor"),s.jsx(C.NiceColorPicker,{value:r.style.borderColor??"var(--nice-text, #333333)",onChange:h=>l("borderColor",h),className:"nice-diagram-property-panel__color"})]})]}),s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.fontSize"),s.jsx(C.NiceNumberInput,{value:r.style.fontSize??14,min:8,max:72,onChange:h=>l("fontSize",h??14),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.fontColor"),s.jsx(C.NiceColorPicker,{value:r.style.fontColor??"#222222",onChange:h=>l("fontColor",h),className:"nice-diagram-property-panel__color"})]})]}),s.jsx(C.NiceCheckbox,{checked:r.locked??!1,onChange:h=>t==null?void 0:t(r.id,{locked:h}),label:n("node.locked"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),s.jsx("h4",{className:"nice-diagram-property-panel__section-title",style:{fontSize:12,marginTop:12,marginBottom:4,color:"var(--nice-text-secondary, #666)"},children:n("node.effects","Effects")}),s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.glowColor","Glow Color"),s.jsx(C.NiceColorPicker,{value:r.style.glowColor??"var(--nice-primary, #3b82f6)",onChange:h=>l("glowColor",h),className:"nice-diagram-property-panel__color"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.glowIntensity","Glow Intensity"),s.jsx(C.NiceSlider,{min:0,max:3,step:.1,value:r.style.glowIntensity??0,onChange:h=>l("glowIntensity",h),className:"nice-diagram-property-panel__input"})]})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.opacity","Opacity"),s.jsx(C.NiceSlider,{min:0,max:1,step:.05,value:r.style.opacity??1,onChange:h=>l("opacity",h),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.borderRadius","Border Radius"),s.jsx(C.NiceNumberInput,{min:0,max:50,value:r.style.borderRadius??4,onChange:h=>l("borderRadius",h??4),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.borderWidth","Border Width"),s.jsx(C.NiceNumberInput,{min:0,max:10,step:.5,value:r.style.borderWidth??1,onChange:h=>l("borderWidth",h??1),className:"nice-diagram-property-panel__input"})]}),s.jsx(C.NiceCheckbox,{checked:r.style.shadow??!1,onChange:h=>l("shadow",h),label:n("node.shadow","Shadow"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.gradientEnd","Gradient End"),s.jsx(C.NiceColorPicker,{value:r.style.gradientColor??"var(--nice-bg, #fff)",onChange:h=>l("gradientColor",h),className:"nice-diagram-property-panel__color"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.gradientDir","Gradient Dir"),s.jsx(C.NiceSelect,{value:r.style.gradientDirection??"vertical",onChange:h=>l("gradientDirection",h),options:[{value:"vertical",label:n("node.vertical","Vertical")},{value:"horizontal",label:n("node.horizontal","Horizontal")},{value:"diagonal",label:n("node.diagonal","Diagonal")},{value:"radial",label:n("node.radial","Radial")}],className:"nice-diagram-property-panel__select"})]})]}),s.jsx(C.NiceCheckbox,{checked:r.hidden??!1,onChange:h=>t==null?void 0:t(r.id,{hidden:h}),label:n("node.hiddenGhostInEditor","Hidden (ghost in editor)"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),s.jsx(C.NiceButton,{className:"nice-diagram-property-panel__btn nice-diagram-property-panel__btn--danger",variant:"ghost",size:"sm",onClick:()=>i==null?void 0:i(r.id),children:n("toolbar.delete")})]}):e?s.jsxs("div",{className:`nice-diagram-property-panel ${a??""}`,children:[s.jsx("h3",{className:"nice-diagram-property-panel__title",children:n("panel.edgeProperties")}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("edge.label"),s.jsx(C.NiceTextInput,{value:e.label??"",onChange:h=>o==null?void 0:o(e.id,{label:h||void 0}),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("edge.lineType"),s.jsx(C.NiceSelect,{value:e.style.lineType??"bezier",onChange:h=>c("lineType",h),options:[{value:"straight",label:n("node.straight","Straight")},{value:"bezier",label:n("node.bezier","Bezier")},{value:"orthogonal",label:n("node.orthogonal","Orthogonal")},{value:"step",label:n("node.step","Step")}],className:"nice-diagram-property-panel__select"})]}),s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("edge.color"),s.jsx(C.NiceColorPicker,{value:e.style.strokeColor??"var(--nice-text, #333333)",onChange:h=>c("strokeColor",h),className:"nice-diagram-property-panel__color"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("edge.width"),s.jsx(C.NiceNumberInput,{value:e.style.strokeWidth??1.5,min:.5,max:10,step:.5,onChange:h=>c("strokeWidth",h??1.5),className:"nice-diagram-property-panel__input"})]})]}),s.jsx(C.NiceCheckbox,{checked:e.style.animated??!1,onChange:h=>c("animated",h),label:n("edge.animated"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),e.style.animated&&s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.flowSpeed","Flow Speed"),s.jsx(C.NiceSlider,{min:.1,max:5,step:.1,value:e.style.flowSpeed??1,onChange:h=>c("flowSpeed",h),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.dashStyle","Dash Style"),s.jsx(C.NiceSelect,{value:e.style.strokeDash?e.style.strokeDash.join(","):"solid",onChange:h=>{const w=h;w==="solid"?c("strokeDash",[]):c("strokeDash",w.split(",").map(Number))},options:[{value:"solid",label:n("node.solid","Solid")},{value:"6,4",label:n("node.dashed","Dashed")},{value:"2,2",label:n("node.dotted","Dotted")},{value:"8,4,2,4",label:n("node.dashDot","Dash-Dot")},{value:"12,6",label:n("node.longDash","Long Dash")}],className:"nice-diagram-property-panel__select"})]}),s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.targetArrow","Target Arrow"),s.jsx(C.NiceSelect,{value:e.style.targetArrow??"arrow",onChange:h=>c("targetArrow",h),options:[{value:"arrow",label:n("node.arrow","Arrow")},{value:"openArrow",label:n("node.openArrow","Open Arrow")},{value:"diamond",label:n("node.diamond","Diamond")},{value:"circle",label:n("node.circle","Circle")},{value:"none",label:n("node.none","None")}],className:"nice-diagram-property-panel__select"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.sourceArrow","Source Arrow"),s.jsx(C.NiceSelect,{value:e.style.sourceArrow??"none",onChange:h=>c("sourceArrow",h),options:[{value:"none",label:n("node.none","None")},{value:"arrow",label:n("node.arrow","Arrow")},{value:"openArrow",label:n("node.openArrow","Open Arrow")},{value:"diamond",label:n("node.diamond","Diamond")},{value:"circle",label:n("node.circle","Circle")}],className:"nice-diagram-property-panel__select"})]})]}),s.jsx("h4",{className:"nice-diagram-property-panel__section-title",style:{fontSize:12,marginTop:12,marginBottom:4,color:"var(--nice-text-secondary, #666)"},children:n("node.liquidFlow","Liquid Flow")}),s.jsx(C.NiceCheckbox,{checked:((u=e.style.liquidFlow)==null?void 0:u.active)??!1,onChange:h=>{const w=e.style.liquidFlow??{active:!1,color:"var(--nice-primary, #3b82f6)",speed:1,pipeWidth:6};o==null||o(e.id,{style:{...e.style,liquidFlow:{...w,active:h}}})},label:n("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)&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"nice-diagram-property-panel__row",children:[s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.color","Color"),s.jsx(C.NiceColorPicker,{value:((p=e.style.liquidFlow)==null?void 0:p.color)??"var(--nice-primary, #3b82f6)",onChange:h=>{const w=e.style.liquidFlow;o==null||o(e.id,{style:{...e.style,liquidFlow:{...w,color:h}}})},className:"nice-diagram-property-panel__color"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[n("node.speed","Speed"),s.jsx(C.NiceSlider,{min:.1,max:5,step:.1,value:((b=e.style.liquidFlow)==null?void 0:b.speed)??1,onChange:h=>{const w=e.style.liquidFlow;o==null||o(e.id,{style:{...e.style,liquidFlow:{...w,speed:h}}})},className:"nice-diagram-property-panel__input"})]})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.pipeWidth","Pipe Width"),s.jsx(C.NiceNumberInput,{min:2,max:20,value:((g=e.style.liquidFlow)==null?void 0:g.pipeWidth)??6,onChange:h=>{const w=e.style.liquidFlow;o==null||o(e.id,{style:{...e.style,liquidFlow:{...w,pipeWidth:h??6}}})},className:"nice-diagram-property-panel__input"})]})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[n("node.opacity","Opacity"),s.jsx(C.NiceSlider,{min:0,max:1,step:.05,value:e.style.opacity??1,onChange:h=>c("opacity",h),className:"nice-diagram-property-panel__input"})]}),s.jsx(C.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:n("toolbar.delete")})]}):null};process.env.NODE_ENV!=="production"&&(St.displayName="DiagramPropertyPanel");const Qt={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"]},$i=[["dagre","list-ordered"],["tree","git-branch"],["forceDirected","shuffle"],["radial","target"],["grid","grid"]],Ti=["sans-serif","serif","monospace","Arial","Helvetica","Times New Roman","Courier New","Georgia","Verdana","Tahoma","Trebuchet MS"],Pi=[8,9,10,11,12,14,16,18,20,24,28,32,36,48,72],Ei=["home","insert","format","view"],Ri={home:"Home",insert:"Insert",format:"Format",view:"View"},Mt=({activeTool:r,onToolChange:e,diagramType:t,onAddNode:o,onApplyLayout:i,onUndo:a,onRedo:n,canUndo:l=!1,canRedo:c=!1,onExport:u,onZoomIn:d,onZoomOut:p,onZoomReset:b,zoomLevel:g=1,onToggleBold:h,onToggleItalic:w,isBold:z=!1,isItalic:y=!1,onFontFamilyChange:_,currentFontFamily:O="sans-serif",onFontSizeChange:k,currentFontSize:P=14,onAlignLeft:D,onAlignCenterH:v,onAlignRight:X,onAlignTop:q,onAlignCenterV:L,onAlignBottom:M,onDistributeH:W,onDistributeV:V,onBringToFront:G,onSendToBack:N,onGroupSelected:T,onUngroupSelected:F,onCopy:U,onPaste:R,onDuplicate:K,onSelectAll:J,selectionCount:ee=0,onFind:ce,showFind:Me=!1,findQuery:he="",onFindQueryChange:Ae,viewMode:Ie="editor",onViewModeChange:ge,stylePresetId:Le,onStylePresetChange:Ve,defaultTab:Ne="home",propertiesOpen:Xe=!0,onToggleProperties:Te,className:Je})=>{const{t:Y}=Be(),[Qe,_e]=m.useState(Ne),[qe,Ee]=m.useState(!1),[nt,te]=m.useState(!1),Ge=m.useRef(null);C.useRovingFocus(Ge,{orientation:"horizontal",itemSelector:".nice-diagram-toolbar__tab"});const Re=Qt[t]??Qt.custom,ae=(x,H,re,ye,ke={})=>ye?s.jsx(C.NiceButton,{className:"nice-diagram-toolbar__btn",variant:ke.active?"primary":"ghost",size:"sm",onClick:ye,disabled:ke.disabled,title:re,"aria-label":re,"aria-pressed":ke.active===void 0?void 0:ke.active,children:typeof H=="string"?s.jsx(C.NiceIcon,{name:H,size:16}):H},x):null,me=(x,H,re)=>ae(x,H,re,()=>e(x),{active:r===x}),et={home:[{id:"tools",label:Y("toolbar.section.tools","Tools"),items:[me("select","cursor",`${Y("toolbar.select")} (V)`),me("pan","move",`${Y("toolbar.pan")} (H)`),me("addEdge","link",`${Y("toolbar.addEdge")} (C)`),me("text","type",Y("toolbar.textT","Text (T)")),me("freehand","pen",Y("toolbar.freehandF","Freehand (F)")),me("delete","trash",`${Y("toolbar.delete")} (Del)`)]},{id:"clipboard",label:Y("toolbar.section.clipboard","Clipboard"),items:[ae("copy","copy",Y("toolbar.copyCtrlC","Copy (Ctrl+C)"),U),ae("paste","clipboard",Y("toolbar.pasteCtrlV","Paste (Ctrl+V)"),R),ae("dup","layers",Y("toolbar.duplicateCtrlD","Duplicate (Ctrl+D)"),K),ae("all","check-square",Y("toolbar.selectAllCtrlA","Select All (Ctrl+A)"),J)]},{id:"history",label:Y("toolbar.section.history","History"),items:[ae("undo","undo",`${Y("toolbar.undo")} (Ctrl+Z)`,a,{disabled:!l}),ae("redo","redo",`${Y("toolbar.redo")} (Ctrl+Y)`,n,{disabled:!c})]}],insert:[{id:"shapes",label:Y("toolbar.section.shapes","Shapes"),items:Re.map(x=>ae(x,Oi(x),`${Y("toolbar.addNode")}: ${Y(`shape.${x}`,x)}`,o&&(()=>o(x))))},{id:"layout",label:Y("toolbar.layout"),items:$i.map(([x,H])=>ae(x,H,Y(`layout.${x}`),i&&(()=>i(x))))}],format:[{id:"text",label:Y("toolbar.section.text","Text"),items:[_?s.jsx(C.NiceSelect,{className:"nice-diagram-toolbar__font-select",value:O,onChange:x=>_(x),options:Ti.map(x=>({value:x,label:x})),title:Y("toolbar.fontFamily","Font Family")},"family"):null,k?s.jsx(C.NiceSelect,{className:"nice-diagram-toolbar__size-select",value:String(P),onChange:x=>k(Number(x)),options:Pi.map(x=>({value:String(x),label:String(x)})),title:Y("toolbar.fontSize","Font Size")},"size"):null,ae("bold",s.jsx("strong",{children:"B"}),Y("toolbar.boldCtrlB","Bold (Ctrl+B)"),h,{active:z}),ae("italic",s.jsx("em",{children:"I"}),Y("toolbar.italicCtrlI","Italic (Ctrl+I)"),w,{active:y})]},{id:"align",label:Y("toolbar.align","Align"),items:[ae("al","align-left",Y("toolbar.alignLeft","Align Left"),D),ae("ac","align-center",Y("toolbar.alignCenter","Align Center"),v),ae("ar","align-right",Y("toolbar.alignRight","Align Right"),X),ae("at","align-top",Y("toolbar.alignTop","Align Top"),q),ae("am","align-middle",Y("toolbar.alignMiddle","Align Middle"),L),ae("ab","align-bottom",Y("toolbar.alignBottom","Align Bottom"),M),ae("dh","distribute-h",Y("toolbar.distributeHorizontally","Distribute Horizontally"),W),ae("dv","distribute-v",Y("toolbar.distributeVertically","Distribute Vertically"),V)]},{id:"arrange",label:Y("toolbar.arrange","Arrange"),items:[ae("front","arrow-up",Y("toolbar.bringToFront","Bring to Front"),G),ae("back","arrow-down",Y("toolbar.sendToBack","Send to Back"),N),ae("group","group",Y("toolbar.group","Group"),T,{disabled:ee<2}),ae("ungroup","ungroup",Y("toolbar.ungroup","Ungroup"),F)]},{id:"style",label:Y("toolbar.style","Style"),items:[Ve?s.jsxs("div",{className:"nice-diagram-toolbar__group--relative",children:[ae("presets","palette",Y("toolbar.stylePresets","Style Presets"),()=>te(x=>!x)),nt&&s.jsx("div",{className:"nice-diagram-toolbar__dropdown nice-diagram-toolbar__dropdown--presets",children:Object.entries(kt.reduce((x,H)=>{const re=H.category??"Other";return(x[re]??(x[re]=[])).push(H),x},{})).map(([x,H])=>s.jsxs("div",{children:[s.jsx("div",{className:"nice-diagram-toolbar__dropdown-section",children:x}),H.map(re=>s.jsxs(C.NiceButton,{className:`nice-diagram-toolbar__dropdown-item ${Le===re.id?"nice-diagram-toolbar__dropdown-item--active":""}`,variant:Le===re.id?"primary":"ghost",size:"sm",onClick:()=>{Ve(re.id),te(!1)},children:[s.jsx("span",{className:"nice-diagram-toolbar__preset-swatch",style:{background:re.config.palette.primary,borderColor:re.config.palette.border}}),re.name]},re.id))]},x))})]},"presets"):null]}],view:[{id:"zoom",label:Y("toolbar.section.zoom","Zoom"),items:[ae("zoomOut","zoom-out",Y("toolbar.zoomOut"),p),d||p?s.jsxs("span",{className:"nice-diagram-toolbar__zoom-label",children:[Math.round(g*100),"%"]},"zoom"):null,ae("zoomIn","zoom-in",Y("toolbar.zoomIn"),d),ae("zoomReset","expand",Y("toolbar.zoomReset"),b)]},{id:"find",label:Y("toolbar.section.find","Find"),items:[ae("find","search",Y("toolbar.findCtrlF","Find (Ctrl+F)"),ce,{active:Me}),ce&&Me?s.jsx(C.NiceTextInput,{className:"nice-diagram-toolbar__search",placeholder:Y("toolbar.searchNodes","Search nodes…"),value:he,onChange:x=>Ae==null?void 0:Ae(x),autoFocus:!0},"query"):null]},{id:"mode",label:Y("toolbar.section.mode","Mode"),items:ge?[ae("editor","edit",Y("toolbar.editorMode","Editor Mode"),()=>ge("editor"),{active:Ie==="editor"}),ae("player","play",Y("toolbar.playerMode","Player Mode"),()=>ge("player"),{active:Ie==="player"}),ae("animated","zap",Y("toolbar.animatedPlayerMode","Animated Player Mode"),()=>ge("playerAnimated"),{active:Ie==="playerAnimated"})]:[]},{id:"export",label:Y("toolbar.export"),items:[u?s.jsxs("div",{className:"nice-diagram-toolbar__group--relative",children:[ae("export","download",Y("toolbar.export"),()=>Ee(x=>!x)),qe&&s.jsx("div",{className:"nice-diagram-toolbar__dropdown",children:["ndd","svg","mermaid","png","pdf"].map(x=>s.jsx(C.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{u(x),Ee(!1)},children:x==="ndd"?".ndd.json":x==="mermaid"?Y("toolbar.mermaid","Mermaid"):x.toUpperCase()},x))})]},"export"):null]}]},Ye=x=>x.filter(H=>H.items.some(Boolean)),Oe=Ei.filter(x=>Ye(et[x]).length>0),We=Oe.includes(Qe)?Qe:Oe[0]??"home";return s.jsxs("div",{className:`nice-diagram-toolbar ${Je??""}`,children:[s.jsxs("div",{ref:Ge,className:"nice-diagram-toolbar__tabs",role:"tablist",children:[Oe.map(x=>s.jsx("button",{type:"button",role:"tab","aria-selected":We===x,className:"nice-diagram-toolbar__tab",onClick:()=>_e(x),children:Y(`toolbar.tab.${x}`,Ri[x])},x)),s.jsxs("span",{className:"nice-diagram-toolbar__tabs-end",children:[ee>1&&s.jsx("span",{className:"nice-diagram-toolbar__selection-info",children:Y("toolbar.selected","{selectionCount} selected").replace("{selectionCount}",String(ee))}),ae("properties","columns",Y("toolbar.properties","Properties panel"),Te,{active:Xe})]})]}),s.jsx("div",{className:"nice-diagram-toolbar__row",role:"tabpanel",children:Ye(et[We]).map(x=>s.jsxs("div",{className:"nice-diagram-toolbar__section",role:"group","aria-label":x.label,children:[s.jsx("div",{className:"nice-diagram-toolbar__group",children:x.items}),s.jsx("span",{className:"nice-diagram-toolbar__section-label","aria-hidden":"true",children:x.label})]},x.id))})]})};process.env.NODE_ENV!=="production"&&(Mt.displayName="DiagramToolbar");function Oi(r){switch(r){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 Fi=[{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"}];function Li(r,e){const t=URL.createObjectURL(r),o=document.createElement("a");o.href=t,o.download=e,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(t),0)}const vr=m.forwardRef(function({initialDocument:e,document:t,nodeTypes:o,autoLayout:i,fitOnMount:a=!1,readOnly:n=!1,diagramType:l,onChange:c,onExport:u,onExportFile:d,showExportInReadOnly:p=!1,lang:b,showToolbar:g=!0,showPropertyPanel:h=!0,defaultPropertiesOpen:w=!0,showMinimap:z=!0,showTimeline:y=!0,className:_,style:O,tutorial:k},P){var We;const{t:D}=C.useNiceTranslation(),v=br(t??e),[X,q]=m.useState("select"),[L,M]=m.useState(null),[W,V]=m.useState(w),G=m.useRef(null),N=m.useRef(null);C.useRovingFocus(N,{orientation:"horizontal"});const[T,F]=m.useState("editor"),U=m.useRef(null),[R,K]=m.useState({particles:[],liquidFlows:new Map,glowStates:new Map});m.useEffect(()=>{const x=new nr(H=>{K(H)});return U.current=x,x.start(),()=>{x.stop(),U.current=null}},[]),m.useEffect(()=>{var H;const x=U.current;if(x)for(const re of v.edges)(H=re.style.liquidFlow)!=null&&H.active?x.startLiquidFlow(re.id,re.style.liquidFlow):x.stopLiquidFlow(re.id)},[v.edges]),m.useEffect(()=>{const x=U.current;if(x)for(const H of v.nodes)H.style.glowColor?x.setGlow(H.id,H.style.glowColor,H.style.glowIntensity??1):x.removeGlow(H.id)},[v.nodes]);const J=m.useCallback(x=>{v.setStylePreset(x)},[v]),ee=m.useCallback((x,H)=>{const re=v.nodes.find(ke=>ke.id===x);if(!(re!=null&&re.interactions))return;const ye=re.interactions.find(ke=>ke.id===H);if(ye)switch(ye.action){case"reveal":{if(ye.targetId){const ke=v.nodes.find(I=>I.id===ye.targetId);ke!=null&&ke.hidden&&v.updateNode(ye.targetId,{hidden:!1})}break}case"navigate":{if(ye.targetId){const ke=v.nodes.find(I=>I.id===ye.targetId);ke&&(v.setViewport({x:-ke.position.x+300,y:-ke.position.y+200,zoom:v.viewport.zoom}),M(ye.targetId))}break}case"switchAnimationMode":{ye.targetId&&v.setActiveAnimationMode(ye.targetId);break}case"highlight":{ye.targetId&&M(ye.targetId);break}case"toggleCollapse":{v.toggleNodeCollapse(x);break}}},[v]),ce=m.useRef(c);m.useEffect(()=>{ce.current=c});const Me=m.useRef(v.revision);m.useEffect(()=>{var x;v.revision!==Me.current&&(Me.current=v.revision,(x=ce.current)==null||x.call(ce,v.document))},[v.revision,v.document]);const he=v.model;m.useEffect(()=>{t&&t!==he.getDocument()&&he.loadDocument(t)},[t,he]);const Ae=`${v.nodes.map(x=>x.id).join(",")}|${v.edges.map(x=>`${x.sourceNodeId}>${x.targetNodeId}`).join(",")}`,Ie=l??v.document.diagramType,ge=m.useMemo(()=>i?i===!0?Ie==="orgchart"?{algorithm:"tree",direction:"TB",nodeSpacing:24,rankSpacing:56}:{algorithm:"dagre",direction:"LR",nodeSpacing:40,rankSpacing:80}:i:null,[i,Ie]),Le=v.applyLayout;m.useEffect(()=>{ge&&Le(ge,{history:!1})},[Ae,ge,Le]);const Ve=m.useCallback((x,H,re,ye)=>{v.addEdge(x,re??"right",H,ye??"left")},[v]),Ne=m.useCallback(x=>{const H=v.viewport,re=v.addNode(x.label,{x:(-H.x+400)/H.zoom,y:(-H.y+300)/H.zoom},x.shape,x.size);v.updateNode(re.id,{style:{...x.style},...x.icon?{icon:x.icon}:{},...x.description?{description:x.description}:{},...x.ports?{ports:x.ports.map(ye=>({...ye}))}:{},data:{...re.data,nodeType:x.id}}),M(re.id),q("select")},[v]),[Xe,Te]=m.useState(0),Je=m.useMemo(()=>L?v.nodes.find(x=>x.id===L)??null:null,[L,v.nodes]),Y=m.useMemo(()=>L?v.edges.find(x=>x.id===L)??null:null,[L,v.edges]),Qe=m.useCallback(x=>{const H=v.viewport,re=(-H.x+400)/H.zoom,ye=(-H.y+300)/H.zoom,ke=v.addNode("New Node",{x:re,y:ye},x);M(ke.id),q("select")},[v]),_e=m.useCallback(x=>{v.applyLayout({algorithm:x,centerGraph:!0})},[v]),qe=m.useCallback((x,H)=>{v.moveNode(x,H)},[v]),Ee=m.useCallback((x,H)=>{v.moveNode(x,H)},[v]),nt=m.useCallback(x=>{v.nodes.find(H=>H.id===x)?v.removeNode(x):v.edges.find(H=>H.id===x)&&v.removeEdge(x),M(null)},[v]),te=m.useCallback(async x=>{const H=v.document,re=Ie==="orgchart";switch(x){case"ndd":return yr(H,!0);case"mermaid":return pr(H);case"png":return ur(H,{treeEdges:re});case"pdf":return hr(H,{treeEdges:re,title:H.title});default:return dr(H,{treeEdges:re})}},[v,Ie]);m.useImperativeHandle(P,()=>({export:te}),[te]);const Ge=m.useCallback(x=>{te(x).then(H=>{typeof H=="string"?u==null||u(x,H):(x==="png"||x==="pdf")&&(d?d(x,H):Li(H,`${v.document.title||"diagram"}.${x}`))})},[te,u,d,v]),Re=m.useCallback(()=>{v.setViewport({...v.viewport,zoom:Math.min(5,v.viewport.zoom*1.2)})},[v]),ae=m.useCallback(()=>{v.setViewport({...v.viewport,zoom:Math.max(.1,v.viewport.zoom/1.2)})},[v]),me=m.useCallback(()=>{a?Te(x=>x+1):v.setViewport({x:0,y:0,zoom:1})},[v,a]),et=m.useMemo(()=>[...v.nodes.map(x=>({id:x.id,label:x.label,type:"node"})),...v.edges.map(x=>({id:x.id,label:x.label??x.id,type:"edge"}))],[v.nodes,v.edges]),Ye=g&&!n||n&&p||v.animationModes.length>0?s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,width:"100%"},children:[n&&p&&s.jsx("div",{ref:N,className:"nice-diagram-editor__export",role:"toolbar","aria-label":D("diagramEditor.export","Export"),style:{display:"flex",gap:4,padding:"4px 8px"},children:["svg","png","pdf"].map(x=>s.jsx(C.NiceButton,{variant:"ghost",size:"sm",leftIcon:s.jsx(C.NiceIcon,{name:"download",size:14}),onClick:()=>Ge(x),children:x.toUpperCase()},x))}),g&&!n&&s.jsx(Mt,{activeTool:X,onToolChange:q,diagramType:Ie,onAddNode:Qe,onApplyLayout:_e,onUndo:v.undo,onRedo:v.redo,canUndo:v.canUndo,canRedo:v.canRedo,onExport:Ge,onZoomIn:Re,onZoomOut:ae,onZoomReset:me,zoomLevel:v.viewport.zoom,viewMode:T,onViewModeChange:F,stylePresetId:v.stylePresetId,onStylePresetChange:J,propertiesOpen:W,onToggleProperties:h?()=>V(x=>!x):void 0}),o&&o.length>0&&!n&&s.jsx("div",{className:"nice-diagram-editor__node-types",role:"group","aria-label":D("diagramEditor.nodeTypes","Add a node"),style:{display:"flex",flexWrap:"wrap",gap:4,padding:"4px 8px"},children:o.map(x=>s.jsx(C.NiceButton,{variant:"ghost",size:"sm",leftIcon:s.jsx(C.NiceIcon,{name:x.icon??"plus",size:14}),onClick:()=>Ne(x),children:x.label},x.id))}),v.animationModes.length>0&&s.jsxs("div",{className:"nice-diagram-editor__mode-tabs",style:{display:"flex",gap:4,padding:"4px 8px",fontSize:12,alignItems:"center"},children:[s.jsx("span",{style:{color:"var(--nice-text-secondary, #888)",marginRight:4},children:D("diagramEditor.modes","Modes:")}),v.animationModes.map(x=>{var H;return s.jsx(C.NiceButton,{variant:((H=v.activeAnimationMode)==null?void 0:H.id)===x.id?"primary":"ghost",size:"sm",onClick:()=>v.setActiveAnimationMode(x.id),style:{padding:"2px 10px",fontSize:11},children:x.name},x.id)}),s.jsx(C.NiceButton,{variant:"ghost",size:"sm",onClick:()=>v.addAnimationMode(`Mode ${v.animationModes.length+1}`),style:{padding:"2px 8px",fontSize:11,color:"var(--nice-text-secondary, #888)"},title:D("diagramEditor.addAnimationMode","Add animation mode"),children:"+"})]})]}):void 0,Oe=s.jsxs(C.NiceAppShell,{ref:G,flush:!0,className:`nice-diagram-editor ${_??""}`,style:{position:"relative",...O},toolbar:Ye,rightSidebar:h&&W&&!n?s.jsx("div",{className:"nice-diagram-editor__panel",style:{width:260,overflowY:"auto",height:"100%"},children:s.jsx(St,{selectedNode:Je,selectedEdge:Y,onNodeChange:v.updateNode,onEdgeChange:v.updateEdge,onRemove:nt})}):void 0,bottomPanel:y?s.jsx("div",{className:"nice-diagram-editor__timeline",children:s.jsx(Ct,{animations:v.animations,onAdd:v.addAnimation,onRemove:v.removeAnimation,availableTargets:et})}):void 0,children:[s.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:s.jsx(C.NiceTutorialButton,{steps:C.resolveTutorial(k,Fi)})}),s.jsxs("div",{className:"nice-diagram-editor__canvas",style:{height:"100%",position:"relative"},children:[s.jsx(Fe,{treeEdges:Ie==="orgchart",nodes:v.nodes,edges:v.edges,groups:v.groups,viewport:v.viewport,onViewportChange:v.setViewport,selectedId:L,onSelectElement:M,onNodeDrag:ge||n?void 0:qe,onNodeDragEnd:ge||n?void 0:Ee,onEdgeCreate:n?void 0:Ve,autoFit:a,fitKey:ge?Ae:void 0,refitKey:Xe,interactive:T==="editor"&&!n,showGrid:T==="editor",particleState:R,viewMode:T,ghostOpacity:((We=v.playerConfig)==null?void 0:We.ghostOpacity)??.3,onGroupCollapse:v.toggleGroupCollapse,onNodeCollapse:v.toggleNodeCollapse,onInteraction:ee}),z&&s.jsx("div",{style:{position:"absolute",bottom:8,left:8},children:s.jsx(ft,{nodes:v.nodes,edges:v.edges,viewport:v.viewport,onViewportChange:v.setViewport})})]})]});return b?s.jsx(Rt,{locale:b,children:Oe}):Oe});process.env.NODE_ENV!=="production"&&(vr.displayName="NiceDiagramEditor");const er={linear:r=>r,easeIn:r=>r*r,easeOut:r=>r*(2-r),easeInOut:r=>r<.5?2*r*r:-1+(4-2*r)*r,spring:r=>1-Math.cos(r*Math.PI*.5)*Math.exp(-6*r),bounce:r=>{if(r<1/2.75)return 7.5625*r*r;if(r<2/2.75){const t=r-.5454545454545454;return 7.5625*t*t+.75}if(r<2.5/2.75){const t=r-.8181818181818182;return 7.5625*t*t+.9375}const e=r-2.625/2.75;return 7.5625*e*e+.984375}};function kr(r){return er[r]??er.linear}const Cr={opacity:1,scale:1,translateX:0,translateY:0,glow:0,highlightColor:"",strokeProgress:1,rippleRadius:0,rippleOpacity:0,typewriterChars:-1,liquidFillProgress:-1,particleTrailT:-1};class Sr{constructor(e,t){this.startTime=0,this.playing=!1,this.rafId=0,this.stateMap=new Map,this.tick=()=>{if(!this.playing)return;const o=performance.now()-this.startTime;this.stateMap.clear();let i=!1;for(const a of this.animations){const n=a.startMs+(a.delayMs??0);n+a.durationMs;const l=a.repeat??0;let c=o-n;if(c<0){this.stateMap.set(a.targetId,Bi(a)),i=!0;continue}if(l===-1)c=c%a.durationMs,i=!0;else if(l>0){const b=a.durationMs*(l+1);if(c>b)continue;c=c%a.durationMs,i=!0}else{if(c>a.durationMs)continue;i=!0}const u=Math.min(c/a.durationMs,1),d=kr(a.easing)(u),p=Wi(a,d);this.stateMap.set(a.targetId,p)}this.onFrame(this.stateMap),i?this.rafId=requestAnimationFrame(this.tick):this.playing=!1},this.animations=[...e].sort((o,i)=>o.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 Wi(r,e){const t={...Cr};switch(r.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 Bi(r){const e={...Cr};switch(r.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 Vi(r){return{rectangle:"rectangle",roundedRect:"roundedRect",ellipse:"ellipse",circle:"circle",diamond:"diamond",hexagon:"hexagon",cylinder:"cylinder",cloud:"cloud",triangle:"triangle"}[r||"rectangle"]||"rectangle"}function qi(r){return r?{backgroundColor:r.fill,borderColor:r.stroke,borderWidth:r.strokeWidth,fontColor:r.fontColor,fontSize:r.fontSize,borderRadius:r.borderRadius,borderStyle:r.strokeDasharray?"dashed":"solid"}:{}}function Gi(r){if(!r)return{};let e="straight";return r.lineType==="orthogonal"?e="orthogonal":r.lineType==="curved"||r.lineType==="bezier"?e="bezier":r.lineType==="step"&&(e="step"),{strokeColor:r.stroke,strokeWidth:r.strokeWidth,strokeDash:r.strokeDasharray?r.strokeDasharray.split(",").map(Number):void 0,lineType:e,sourceArrow:"none",targetArrow:r.arrowHead?"arrow":"none",opacity:r.opacity}}function Yi(r){if(r)return{backgroundColor:r.fill,borderColor:r.stroke,borderWidth:r.strokeWidth}}function Mr(r){return{id:r.id,label:r.label,position:{x:r.x,y:r.y},size:{width:r.width,height:r.height},shape:Vi(r.shape),style:qi(r.style),ports:(r.ports||[]).map((e,t)=>({id:e.id,side:e.position||"right",offset:.5})),data:r.data}}function Ir(r,e){var n,l;const t=e.find(c=>c.id===r.source),o=e.find(c=>c.id===r.target),i=r.sourcePort||((n=t==null?void 0:t.ports[0])==null?void 0:n.id)||`${r.source}-out`,a=r.targetPort||((l=o==null?void 0:o.ports[0])==null?void 0:l.id)||`${r.target}-in`;return{id:r.id,sourceNodeId:r.source,sourcePortId:i,targetNodeId:r.target,targetPortId:a,label:r.label,style:Gi(r.style),data:r.data}}function zr(r){return{id:r.id,label:r.label,nodeIds:r.nodeIds,style:Yi(r.style)}}function Nr(r){var e;return{id:r.id,name:r.id,targetId:r.targetId||((e=r.targets)==null?void 0:e[0])||"",targetType:"node",effect:r.type==="highlight"?"highlight":"fadeIn",startMs:r.delay,durationMs:r.duration,easing:"easeInOut"}}function rt(r){const e=r.nodes.map(Mr);return e.forEach((t,o)=>{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:r.id,title:r.title,diagramType:r.diagramType,nodes:e,edges:r.edges.map(t=>Ir(t,e)),groups:(r.groups||[]).map(zr),animations:(r.animations||[]).map(Nr),viewport:{x:0,y:0,zoom:1},metadata:{createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),...r.metadata}}}const Hi=rt({id:"empty",title:"",diagramType:"flowchart",nodes:[],edges:[]}),Vt=({document:r=Hi,lang:e="en",autoPlay:t=!1,showControls:o,showGrid:i,showWorkspace:a=!1,autoFit:n=!0,className:l,style:c})=>{const u=o??a,d=i??a,p=m.useMemo(()=>{var L;return a||(L=r.theme)!=null&&L.canvasBackground?r.theme:{...r.theme,canvasBackground:"transparent"}},[a,r.theme]),[b,g]=m.useState(0),[h,w]=m.useState({...r.viewport}),[z,y]=m.useState(new Map),[_,O]=m.useState(!1),k=m.useRef(null),P=m.useCallback(()=>{k.current&&k.current.stop();const L=new Sr(r.animations,M=>{y(new Map(M)),L.isPlaying()||O(!1)});k.current=L,L.play(),O(!0)},[r.animations]),D=m.useCallback(()=>{var L;(L=k.current)==null||L.stop(),O(!1),y(new Map)},[]);m.useEffect(()=>(t&&r.animations.length>0&&P(),()=>{var L;(L=k.current)==null||L.stop()}),[t]);const v=m.useCallback(()=>w(L=>({...L,zoom:Math.min(5,L.zoom*1.2)})),[]),X=m.useCallback(()=>w(L=>({...L,zoom:Math.max(.1,L.zoom/1.2)})),[]),q=m.useCallback(()=>{n?g(L=>L+1):w({x:0,y:0,zoom:1})},[n]);return s.jsx(Rt,{locale:e,children:s.jsxs("div",{className:`nice-diagram-viewer ${l??""}`,style:{display:"flex",flexDirection:"column",height:"100%",...c},children:[u&&s.jsx(Ui,{isPlaying:_,hasAnimations:r.animations.length>0,onPlay:P,onStop:D,onZoomIn:v,onZoomOut:X,onZoomReset:q}),s.jsx("div",{style:{flex:1,position:"relative"},children:s.jsx(Fe,{nodes:r.nodes,edges:r.edges,groups:r.groups,viewport:h,onViewportChange:w,theme:p,animationStates:z,interactive:!1,showGrid:d,autoFit:n,fitKey:r.id,refitKey:b})})]})})};process.env.NODE_ENV!=="production"&&(Vt.displayName="NiceDiagramViewer");const Ui=({isPlaying:r,hasAnimations:e,onPlay:t,onStop:o,onZoomIn:i,onZoomOut:a,onZoomReset:n})=>{const{t:l}=Be();return s.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&&(r?s.jsxs(C.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:o,children:[s.jsx(C.NiceIcon,{name:"stop",size:14})," ",l("animation.stop")]}):s.jsxs(C.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:t,children:[s.jsx(C.NiceIcon,{name:"play",size:14})," ",l("animation.play")]})),s.jsx("span",{style:{flex:1}}),s.jsx(C.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:i,"aria-label":l("animation.zoomIn","Zoom in"),children:s.jsx(C.NiceIcon,{name:"plus",size:14})}),s.jsx(C.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:a,"aria-label":l("animation.zoomOut","Zoom out"),children:s.jsx(C.NiceIcon,{name:"minus",size:14})}),s.jsx(C.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:n,children:"1:1"})]})},Xi="_cell_95fwm_9",Ki="_expandable_95fwm_29",Zi="_svg_95fwm_57",Ji="_emptyText_95fwm_67",Qi="_badge_95fwm_79",ea="_expandIcon_95fwm_117",ta="_modalOverlay_95fwm_169",ra="_modalContent_95fwm_217",oa="_modalHeader_95fwm_267",ia="_modalTitle_95fwm_285",aa="_modalClose_95fwm_299",na="_modalBody_95fwm_337",sa="_modalSvg_95fwm_357",la="_modalFooter_95fwm_371",ca="_modalInfo_95fwm_389",je={cell:Xi,expandable:Ki,svg:Zi,emptyText:Ji,badge:Qi,expandIcon:ea,modalOverlay:ta,modalContent:ra,modalHeader:oa,modalTitle:ia,modalClose:aa,modalBody:na,modalSvg:sa,modalFooter:la,modalInfo:ca},da=120,ua=48,fa=4,tr={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 qt(r){if(r.length===0)return{minX:0,minY:0,maxX:100,maxY:100,width:100,height:100};let e=1/0,t=1/0,o=-1/0,i=-1/0;for(const a of r){const n=a.position.x,l=a.position.y,c=a.position.x+a.size.width,u=a.position.y+a.size.height;n<e&&(e=n),l<t&&(t=l),c>o&&(o=c),u>i&&(i=u)}return{minX:e,minY:t,maxX:o,maxY:i,width:o-e,height:i-t}}function Ar(r){var t;if((t=r.style)!=null&&t.backgroundColor)return r.style.backgroundColor;const e=r.shape??"default";return tr[e]??tr.default}function _r(r,e){const t=e.get(r.sourceNodeId),o=e.get(r.targetNodeId);if(!t||!o)return null;const i=t.position.x+t.size.width/2,a=t.position.y+t.size.height/2,n=o.position.x+o.size.width/2,l=o.position.y+o.size.height/2;return`M ${i} ${a} L ${n} ${l}`}function ha(r,e){const t=qt(r);return{version:"1.0",id:`mini-diagram-${Date.now()}`,title:"Mini Diagram",diagramType:"flowchart",nodes:r,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 pa=({document:r,onClose:e})=>{const{t}=Be(),o=qt(r.nodes),i=40,a=o.width+i*2,n=o.height+i*2,l=m.useMemo(()=>new Map(r.nodes.map(c=>[c.id,c])),[r.nodes]);return s.jsx("div",{role:"presentation",className:je.modalOverlay,onClick:e,children:s.jsxs("div",{role:"presentation",className:je.modalContent,onClick:c=>c.stopPropagation(),children:[s.jsxs("div",{className:je.modalHeader,children:[s.jsx("h3",{className:je.modalTitle,children:r.title||t("diagramCellRenderer.diagram","Diagram")}),s.jsx("button",{className:je.modalClose,onClick:e,children:s.jsx(C.NiceIcon,{name:"close",size:20})})]}),s.jsx("div",{className:je.modalBody,children:s.jsxs("svg",{viewBox:`${o.minX-i} ${o.minY-i} ${a} ${n}`,className:je.modalSvg,children:[r.edges.map(c=>{var d,p,b;const u=_r(c,l);return u?s.jsx("path",{d:u,stroke:((d=c.style)==null?void 0:d.strokeColor)??"var(--nice-text-secondary, #64748b)",strokeWidth:((p=c.style)==null?void 0:p.strokeWidth)??1.5,fill:"none",markerEnd:(b=c.style)!=null&&b.targetArrow&&c.style.targetArrow!=="none"?"url(#arrowhead-modal)":void 0},c.id):null}),r.nodes.map(c=>{var u,d;return s.jsxs("g",{children:[s.jsx("rect",{x:c.position.x,y:c.position.y,width:c.size.width,height:c.size.height,rx:((u=c.style)==null?void 0:u.borderRadius)??4,fill:Ar(c),stroke:((d=c.style)==null?void 0:d.borderColor)??"var(--nice-text, #1e293b)",strokeWidth:1}),s.jsx("text",{x:c.position.x+c.size.width/2,y:c.position.y+c.size.height/2,textAnchor:"middle",dominantBaseline:"middle",fill:"var(--nice-color-white, #fff)",fontSize:12,fontFamily:"system-ui, sans-serif",children:c.label.substring(0,30)})]},c.id)}),s.jsx("defs",{children:s.jsx("marker",{id:"arrowhead-modal",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"var(--nice-text-secondary, #64748b)"})})})]})}),s.jsx("div",{className:je.modalFooter,children:s.jsx("span",{className:je.modalInfo,children:t("diagramCellRenderer.nodesEdges","{nodes} nodes • {edges} edges").replace("{nodes}",String(r.nodes.length)).replace("{edges}",String(r.edges.length))})})]})})},ga=({document:r,nodes:e,edges:t,width:o=da,height:i=ua,showCount:a=!0,expandable:n=!0,onExpand:l,padding:c=fa,backgroundColor:u="transparent",borderRadius:d=4,showLabels:p=!1,edgeColor:b="var(--nice-text-muted, #94a3b8)",tooltip:g})=>{const{t:h}=Be(),[w,z]=m.useState(!1),y=m.useMemo(()=>r||(e||t?ha(e??[],t??[]):null),[r,e,t]),_=m.useMemo(()=>y?new Map(y.nodes.map(X=>[X.id,X])):new Map,[y]),{bounds:O,scale:k,translateX:P,translateY:D}=m.useMemo(()=>{if(!y||y.nodes.length===0)return{bounds:{minX:0,minY:0,width:100,height:100},scale:1,translateX:0,translateY:0};const X=qt(y.nodes),q=o-c*2,L=i-c*2,M=q/X.width,W=L/X.height,V=Math.min(M,W,1),G=X.width*V,N=X.height*V,T=(o-G)/2-X.minX*V,F=(i-N)/2-X.minY*V;return{bounds:X,scale:V,translateX:T,translateY:F}},[y,o,i,c]),v=m.useCallback(()=>{!y||!n||(l?l(y):z(!0))},[y,n,l]);return!y||y.nodes.length===0?s.jsx("div",{className:je.cell,style:{width:o,height:i,backgroundColor:u,borderRadius:d},title:g,children:s.jsx("span",{className:je.emptyText,children:"—"})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{role:"button",tabIndex:0,onKeyDown:C.clickOnActivationKey,className:`${je.cell} ${n?je.expandable:""}`,style:{width:o,height:i,backgroundColor:u,borderRadius:d},onClick:v,title:g??h("diagramCellRenderer.nodesEdges2","{nodes} nodes, {edges} edges").replace("{nodes}",String(y.nodes.length)).replace("{edges}",String(y.edges.length)),children:[s.jsx("svg",{width:o,height:i,viewBox:`0 0 ${o} ${i}`,className:je.svg,children:s.jsxs("g",{transform:`translate(${P}, ${D}) scale(${k})`,children:[y.edges.map(X=>{const q=_r(X,_);return q?s.jsx("path",{d:q,stroke:b,strokeWidth:1/k,fill:"none"},X.id):null}),y.nodes.map(X=>{const q=Ar(X);return s.jsxs("g",{children:[s.jsx("rect",{x:X.position.x,y:X.position.y,width:X.size.width,height:X.size.height,rx:Math.min(4,X.size.width/4),fill:q}),p&&k>.3&&s.jsx("text",{x:X.position.x+X.size.width/2,y:X.position.y+X.size.height/2,textAnchor:"middle",dominantBaseline:"middle",fill:"var(--nice-color-white, #fff)",fontSize:10/k,fontFamily:"system-ui, sans-serif",children:X.label.substring(0,5)})]},X.id)})]})}),a&&s.jsx("span",{className:je.badge,children:y.nodes.length}),n&&s.jsx("span",{className:je.expandIcon,children:s.jsx(C.NiceIcon,{name:"expand",size:12})})]}),w&&y&&s.jsx(pa,{document:y,onClose:()=>z(!1)})]})};function Dr(r,e,t="roundedRect"){const o=[],i=[],a=new Map;for(const n of r){const l=String(n[e.nodeMapping.idField]??"");if(!l)continue;const c=String(n[e.nodeMapping.labelField]??l),u=e.nodeMapping.descriptionField?String(n[e.nodeMapping.descriptionField]??""):void 0,d=e.nodeMapping.iconField?String(n[e.nodeMapping.iconField]??""):void 0,p=e.nodeMapping.colorField?String(n[e.nodeMapping.colorField]??""):void 0,b={id:`data_${l}`,label:c,description:u,icon:d,position:{x:0,y:0},size:{width:180,height:70},shape:t,style:p?{backgroundColor:p}:{},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:n};o.push(b),a.set(l,b)}if(e.nodeMapping.parentField)for(const n of r){const l=String(n[e.nodeMapping.idField]??""),c=String(n[e.nodeMapping.parentField]??"");if(!l||!c)continue;const u=a.get(l),d=a.get(c);!u||!d||i.push({id:`edge_${c}_${l}`,sourceNodeId:d.id,sourcePortId:"bottom",targetNodeId:u.id,targetPortId:"top",style:{lineType:"orthogonal",targetArrow:"arrow"}})}if(e.edgeMapping)for(const n of r){const l=String(n[e.edgeMapping.sourceField]??""),c=String(n[e.edgeMapping.targetField]??"");if(!l||!c)continue;const u=a.get(l),d=a.get(c);if(!u||!d)continue;const p=e.edgeMapping.labelField?String(n[e.edgeMapping.labelField]??""):void 0;i.push({id:`edge_${l}_${c}`,sourceNodeId:u.id,sourcePortId:"right",targetNodeId:d.id,targetPortId:"left",label:p,style:{lineType:"bezier",targetArrow:"arrow"}})}return{nodes:o,edges:i}}async function ma(r,e,t){const o=await fetch(r.sourceUrl,{signal:t});if(!o.ok)throw new Error(`Failed to fetch data: ${o.status} ${o.statusText}`);const i=await o.json(),a=Array.isArray(i)?i:i.value??[];return Dr(a,r,e)}const jr={width:176,height:64},tt={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 ya(r){return[{id:"initial",label:r("workflowDesigner.step.initial","Start"),icon:"play",color:tt.initial,role:"initial"},{id:"intermediate",label:r("workflowDesigner.step.intermediate","State"),icon:"circle",color:tt.intermediate},{id:"approval",label:r("workflowDesigner.step.approval","Approval"),icon:"check",color:tt.approval},{id:"final",label:r("workflowDesigner.step.final","End"),icon:"stop",color:tt.final,role:"final"},{id:"error",label:r("workflowDesigner.step.error","Error"),icon:"error",color:tt.error,role:"error"}]}const ba=r=>r.role??(r.id==="initial"||r.id==="final"||r.id==="error"?r.id:"step"),$r=[{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 wa(r,e){const t=new Set(e);if(!t.has(r))return r;for(let o=2;;o++)if(!t.has(`${r} ${o}`))return`${r} ${o}`}function _t(r,e){const t=new Set(e.map(o=>o.id));for(let o=1;;o++)if(!t.has(`${r}-${o}`))return`${r}-${o}`}function xa(r,e,t){return r||{id:"workflow",name:"Workflow",entityType:"generic",version:1,states:(e??[]).map(o=>({id:o.id,name:o.name??o.label??o.id,type:o.type==="start"?"initial":o.type==="end"?"final":o.type??"intermediate",position:{x:o.x??0,y:o.y??0}})),transitions:(t??[]).map((o,i)=>({id:o.id??`t${i}`,fromStateId:o.fromStateId??o.from??o.source,toStateId:o.toStateId??o.to??o.target,name:o.name??o.label??""}))}}function rr(r,e){const t=new Set(r.states.map(a=>a.id)),o=r.states.map(a=>({id:a.id,label:a.name,position:{x:0,y:0},size:jr,shape:"roundedRect",style:{},ports:$r})),i=r.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 Ot(o,i,{algorithm:"dagre",direction:e,nodeSpacing:36,rankSpacing:96})}function va(r,e,t){const o=[],i=r.states.filter(a=>e(a)==="initial");i.length===0&&o.push({type:"error",message:t("workflowDesigner.val.noInitial","No initial state")}),i.length>1&&o.push({type:"warning",message:t("workflowDesigner.val.multiInitial","More than one initial state")}),r.states.some(a=>e(a)==="final")||o.push({type:"error",message:t("workflowDesigner.val.noFinal","No final state")});for(const a of r.states){const n=e(a);n!=="final"&&n!=="error"&&!r.transitions.some(l=>l.fromStateId===a.id)&&o.push({type:"warning",message:t("workflowDesigner.val.deadEnd",'State "{name}" has no outgoing transitions (dead-end)').replace("{name}",a.name),stateId:a.id}),n!=="initial"&&!r.transitions.some(l=>l.toStateId===a.id)&&o.push({type:"warning",message:t("workflowDesigner.val.orphan",'State "{name}" is unreachable (orphan)').replace("{name}",a.name),stateId:a.id})}return o}const ka=[{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"}],Ca=.1,Sa=3,Tr=({workflow:r,nodes:e,edges:t,onChange:o,readOnly:i=!1,showMinimap:a=!0,showToolbar:n=!0,showValidation:l=!0,onTest:c,onPublish:u,tutorial:d,stepTypes:p,loadStepTypes:b,layoutDirection:g="LR",className:h,style:w,"data-testid":z})=>{const{t:y}=C.useNiceTranslation(),_=m.useRef(null);C.useRovingFocus(_,{orientation:"horizontal",itemSelector:'button, [role="menuitem"]'});const O=m.useMemo(()=>xa(r,e,t),[r,e,t]),[k,P]=m.useState(O),D=m.useRef(null),v=m.useRef(JSON.stringify(O));m.useEffect(()=>{const I=JSON.stringify(O);I!==v.current&&(v.current=I,O!==D.current&&P(O))},[O]);const X=m.useRef(b),[q,L]=m.useState(null),[M,W]=m.useState(!!b);m.useEffect(()=>{const I=X.current;if(!I)return;let $=!0;return I().then(Z=>$&&L(Z)).catch(()=>{}).finally(()=>$&&W(!1)),()=>{$=!1}},[]);const V=m.useMemo(()=>{const I=p??ya(y);if(!q)return I;const $=new Map(I.map(Z=>[Z.id,Z]));for(const Z of q)$.set(Z.id,Z);return[...$.values()]},[p,q,y]),G=m.useCallback(I=>V.find($=>$.id===I.type)??{id:I.type,label:I.type,color:tt[I.type]??tt.intermediate},[V]),N=m.useCallback(I=>ba(G(I)),[G]),[T,F]=m.useState(null),[U,R]=m.useState(null),K=U!==null,J=k.states.find(I=>I.id===T),ee=k.transitions.find(I=>I.id===T),ce=m.useMemo(()=>rr(k,g),[k,g]),Me=`${k.states.map(I=>I.id).join(",")}|${k.transitions.map(I=>`${I.fromStateId}>${I.toStateId}`).join(",")}|${g}`,he=m.useMemo(()=>k.states.map(I=>{const $=G(I),Z=U===I.id;return{id:I.id,label:I.name,description:$.label,position:ce.positions.get(I.id)??I.position,size:jr,shape:$.shape??"roundedRect",icon:$.icon,style:{backgroundColor:"var(--nice-bg-primary)",borderColor:$.color??tt.intermediate,borderWidth:Z?4:2,borderRadius:10,fontColor:"var(--nice-text-primary)",fontSize:13,fontWeight:"bold",...Z?{glowColor:$.color??tt.intermediate}:{}},ports:$r}}),[k.states,G,ce,U]),Ae=m.useMemo(()=>{const I=ce.ranks??new Map,$=new Set(k.states.map(de=>de.id)),Z=g==="LR";return k.transitions.filter(de=>$.has(de.fromStateId)&&$.has(de.toStateId)).map(de=>{const ze=de.fromStateId===de.toStateId,$e=!ze&&(I.get(de.toStateId)??0)<=(I.get(de.fromStateId)??0),[ot,De]=ze?Z?["right","top"]:["bottom","right"]:$e?Z?["bottom","bottom"]:["right","right"]:Z?["right","left"]:["bottom","top"],dt=U===de.fromStateId;return{id:de.id,sourceNodeId:de.fromStateId,sourcePortId:ot,targetNodeId:de.toStateId,targetPortId:De,label:de.name||void 0,style:{lineType:"bezier",targetArrow:"arrow",strokeWidth:dt?2.5:1.5,...dt?{strokeColor:"var(--nice-color-primary)"}:{}}}})},[k.transitions,k.states,ce,g,U]),Ie=m.useRef(o);m.useEffect(()=>{Ie.current=o});const ge=m.useCallback(I=>{var de;const $=rr(I,g).positions,Z={...I,states:I.states.map(ze=>{const $e=$.get(ze.id);return $e?{...ze,position:{x:Math.round($e.x),y:Math.round($e.y)}}:ze})};D.current=Z,P(Z),(de=Ie.current)==null||de.call(Ie,Z)},[g]),Le=m.useCallback(I=>{if(i)return;const $=_t("state",k.states),Z={id:$,name:wa(I.label,k.states.map($e=>$e.name)),type:I.id,position:{x:0,y:0}},de=k.states.find($e=>$e.id===T),ze=de?[...k.transitions,{id:_t("t",k.transitions),fromStateId:de.id,toStateId:$,name:y("workflowDesigner.next","Next")}]:k.transitions;ge({...k,states:[...k.states,Z],transitions:ze}),F($)},[i,k,T,ge,y]),Ve=m.useCallback((I,$)=>ge({...k,states:k.states.map(Z=>Z.id===I?{...Z,...$}:Z)}),[k,ge]),Ne=m.useCallback(I=>{ge({...k,states:k.states.filter($=>$.id!==I),transitions:k.transitions.filter($=>$.fromStateId!==I&&$.toStateId!==I)}),F(null)},[k,ge]),Xe=m.useCallback((I,$)=>{var $e,ot;const Z=$?k.transitions.find(De=>De.fromStateId===I&&De.toStateId===$):void 0;if(Z){F(Z.id);return}const de=new Set(k.transitions.filter(De=>De.fromStateId===I).map(De=>De.toStateId)),ze=$??(($e=k.states.find(De=>De.id!==I&&!de.has(De.id)))==null?void 0:$e.id)??((ot=k.states.find(De=>De.id!==I))==null?void 0:ot.id);ze&&ge({...k,transitions:[...k.transitions,{id:_t("t",k.transitions),fromStateId:I,toStateId:ze,name:y("workflowDesigner.next","Next")}]})},[k,ge,y]),Te=m.useCallback((I,$)=>ge({...k,transitions:k.transitions.map(Z=>Z.id===I?{...Z,...$}:Z)}),[k,ge]),Je=m.useCallback(I=>{ge({...k,transitions:k.transitions.filter($=>$.id!==I)}),T===I&&F(null)},[k,ge,T]),Y=m.useMemo(()=>l?va(k,N,y):[],[l,k,N,y]),Qe=Y.filter(I=>I.type==="error"),[_e,qe]=m.useState({x:0,y:0,zoom:1}),[Ee,nt]=m.useState(0),[te,Ge]=m.useState(null),Re=m.useCallback(I=>qe($=>{const Z=Math.min(Sa,Math.max(Ca,$.zoom*I)),de=((te==null?void 0:te.width)??0)/2,ze=((te==null?void 0:te.height)??0)/2;return{x:de-(de-$.x)*(Z/$.zoom),y:ze-(ze-$.y)*(Z/$.zoom),zoom:Z}}),[te]),ae=m.useCallback(()=>{te&&qe(Bt(Wt(he),te,{maxZoom:1,minZoom:1}))},[te,he]),me=()=>{const I=k.states.find($=>N($)==="initial");I&&(F(null),R(I.id))},et=m.useMemo(()=>[{id:"add-step",label:y("workflowDesigner.addStep","Add step"),icon:s.jsx(C.NiceIcon,{name:"plus",size:14}),children:[...V.map(I=>({id:I.id,label:I.label,description:I.description,icon:I.icon?s.jsx(C.NiceIcon,{name:I.icon,size:14}):void 0,onClick:()=>Le(I)})),...M?[{id:"loading",label:y("workflowDesigner.loadingSteps","Loading step types…"),disabled:!0}]:[]]}],[V,M,Le,y]),Ye=n?s.jsxs("div",{ref:_,className:"nice-workflow-designer__toolbar",role:"toolbar","aria-label":y("workflowDesigner.toolbar","Workflow toolbar"),children:[!i&&!K&&s.jsx(C.NiceMenu,{variant:"ghost",size:"sm",items:et,"data-testid":"workflow-add-step"}),s.jsx(C.NiceButton,{size:"sm",variant:"ghost",leftIcon:s.jsx(C.NiceIcon,{name:"play",size:14}),onClick:me,disabled:Qe.length>0||K,children:y("workflowDesigner.simulate","Simulate")}),s.jsx("span",{className:"nice-workflow-designer__spacer"}),s.jsx(C.NiceButton,{size:"sm",variant:"ghost",ariaLabel:y("workflowDesigner.zoomOut","Zoom out"),onClick:()=>Re(1/1.2),children:s.jsx(C.NiceIcon,{name:"zoom-out",size:14})}),s.jsx(C.NiceButton,{size:"sm",variant:"ghost",className:"nice-workflow-designer__zoom",title:y("workflowDesigner.resetView","Reset view"),onClick:ae,children:`${Math.round(_e.zoom*100)}%`}),s.jsx(C.NiceButton,{size:"sm",variant:"ghost",ariaLabel:y("workflowDesigner.zoomIn","Zoom in"),onClick:()=>Re(1.2),children:s.jsx(C.NiceIcon,{name:"zoom-in",size:14})}),s.jsx(C.NiceButton,{size:"sm",variant:"ghost",leftIcon:s.jsx(C.NiceIcon,{name:"expand",size:14}),onClick:()=>nt(I=>I+1),children:y("workflowDesigner.fit","Fit to view")}),c&&!i&&s.jsx(C.NiceButton,{size:"sm",variant:"ghost",onClick:()=>c(k),children:y("workflowDesigner.test","Test")}),u&&!i&&s.jsx(C.NiceButton,{size:"sm",variant:"primary",onClick:()=>u(k),disabled:Qe.length>0,children:y("workflowDesigner.publish","Publish")})]}):void 0,Oe=I=>k.states.filter($=>$.id!==I).map($=>({value:$.id,label:$.name})),We=I=>s.jsxs("div",{className:"nice-workflow-designer__props-header",children:[s.jsx("h3",{children:I}),s.jsx("button",{type:"button",className:"nice-workflow-designer__props-close",onClick:()=>F(null),"aria-label":y("workflowDesigner.closeProps","Close properties"),title:y("workflowDesigner.closeProps","Close properties"),children:s.jsx(C.NiceIcon,{name:"close",size:12})})]});let x;if(!i&&!K&&J){const I=k.transitions.filter($=>$.fromStateId===J.id);x=s.jsxs("aside",{className:"nice-workflow-designer__props","aria-label":y("workflowDesigner.stateProps","State properties"),children:[We(J.name),s.jsx(C.NiceTextInput,{label:y("workflowDesigner.stateName","State name"),size:"sm",value:J.name,onChange:$=>Ve(J.id,{name:$})}),s.jsx(C.NiceSelect,{label:y("workflowDesigner.stateType","State type"),size:"sm",value:J.type,options:V.map($=>({value:$.id,label:$.label})),onChange:$=>{const Z=Array.isArray($)?$[0]:$;Z&&Ve(J.id,{type:String(Z)})}}),s.jsx("h4",{className:"nice-workflow-designer__props-section",children:y("workflowDesigner.transitions","Transitions")}),I.length===0&&s.jsx("p",{className:"nice-workflow-designer__props-empty",children:y("workflowDesigner.noTransitions","No transitions yet")}),I.map($=>s.jsxs("div",{className:"nice-workflow-designer__transition","data-transition-id":$.id,children:[s.jsx(C.NiceTextInput,{"aria-label":y("workflowDesigner.transitionName","Transition name"),size:"sm",value:$.name,onChange:Z=>Te($.id,{name:Z})}),s.jsx(C.NiceSelect,{"aria-label":y("workflowDesigner.target","To"),size:"sm",value:$.toStateId,options:Oe(),onChange:Z=>{const de=Array.isArray(Z)?Z[0]:Z;de&&Te($.id,{toStateId:String(de)})}}),s.jsx(C.NiceButton,{size:"sm",variant:"ghost",ariaLabel:y("workflowDesigner.deleteFlow","Delete flow"),onClick:()=>Je($.id),children:s.jsx(C.NiceIcon,{name:"trash",size:14})})]},$.id)),s.jsx(C.NiceButton,{size:"sm",variant:"secondary",leftIcon:s.jsx(C.NiceIcon,{name:"plus",size:14}),onClick:()=>Xe(J.id),disabled:k.states.length<2,children:y("workflowDesigner.addTransition","Add transition")}),s.jsx(C.NiceButton,{size:"sm",variant:"danger",leftIcon:s.jsx(C.NiceIcon,{name:"trash",size:14}),onClick:()=>Ne(J.id),className:"nice-workflow-designer__props-delete",children:y("workflowDesigner.deleteState","Delete state {name}").replace("{name}",J.name)})]})}else if(!i&&!K&&ee){const I=k.states.find($=>$.id===ee.fromStateId);x=s.jsxs("aside",{className:"nice-workflow-designer__props","aria-label":y("workflowDesigner.properties","Properties"),children:[We(y("workflowDesigner.flowOf","Flow: {name}").replace("{name}",ee.name||"→")),s.jsx(C.NiceTextInput,{label:y("workflowDesigner.transitionName","Transition name"),size:"sm",value:ee.name,onChange:$=>Te(ee.id,{name:$})}),s.jsxs("p",{className:"nice-workflow-designer__props-from",children:[y("workflowDesigner.from","From"),": ",s.jsx("strong",{children:I==null?void 0:I.name})]}),s.jsx(C.NiceSelect,{label:y("workflowDesigner.target","To"),size:"sm",value:ee.toStateId,options:Oe(),onChange:$=>{const Z=Array.isArray($)?$[0]:$;Z&&Te(ee.id,{toStateId:String(Z)})}}),s.jsx(C.NiceButton,{size:"sm",variant:"danger",leftIcon:s.jsx(C.NiceIcon,{name:"trash",size:14}),onClick:()=>Je(ee.id),children:y("workflowDesigner.deleteFlow","Delete flow")})]})}const H=k.states.find(I=>I.id===U),re=l&&Y.length>0&&!K,ye=re||K?s.jsxs(s.Fragment,{children:[re&&s.jsx("div",{className:"nice-workflow-designer__validation",role:"status","aria-live":"polite",children:Y.map((I,$)=>{const Z=s.jsxs(s.Fragment,{children:[s.jsx(C.NiceIcon,{name:I.type==="error"?"error":"warning",size:14})," ",I.message]}),de=`nice-workflow-designer__issue nice-workflow-designer__issue--${I.type}`;return I.stateId?s.jsx("button",{type:"button",className:de,onClick:()=>F(I.stateId),children:Z},$):s.jsx("div",{className:de,children:Z},$)})}),K&&s.jsxs("div",{className:"nice-workflow-designer__sim-toolbar",children:[s.jsxs("span",{children:[y("workflowDesigner.simActiveState","Simulation active — current state:")," ",s.jsx("strong",{children:H==null?void 0:H.name})]}),k.transitions.filter(I=>I.fromStateId===U).map(I=>{var $;return s.jsxs("button",{type:"button",className:"nice-workflow-designer__sim-btn",onClick:()=>R(I.toStateId),children:[s.jsx(C.NiceIcon,{name:"arrow-right",size:12})," ",I.name||(($=k.states.find(Z=>Z.id===I.toStateId))==null?void 0:$.name)]},I.id)}),s.jsx("button",{type:"button",className:"nice-workflow-designer__sim-end",onClick:()=>R(null),children:y("workflowDesigner.endSimulation","End simulation")})]})]}):void 0,ke=m.useCallback(I=>{K||F(I)},[K]);return s.jsx(C.NiceAppShell,{flush:!0,className:`nice-workflow-designer${i?" nice-workflow-designer--readonly":""} ${h??""}`,style:w,"data-testid":z,toolbar:Ye,rightSidebar:x,bottomPanel:ye,children:s.jsxs("div",{className:"nice-workflow-designer__canvas",children:[s.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:s.jsx(C.NiceTutorialButton,{steps:C.resolveTutorial(d,ka)})}),s.jsx(Fe,{nodes:he,edges:Ae,viewport:_e,onViewportChange:qe,selectedId:T,onSelectElement:ke,interactive:!i&&!K,onEdgeCreate:i||K?void 0:(I,$)=>Xe(I,$),autoFit:!0,fitKey:Me,refitKey:Ee,onResize:Ge,resizable:!1,panOnDrag:!0,ariaLabel:y("workflowDesigner.canvas","Workflow canvas")}),a&&s.jsx("div",{className:"nice-workflow-designer__minimap","aria-label":y("workflowDesigner.minimap","Minimap"),children:s.jsx(ft,{nodes:he,edges:Ae,viewport:_e,onViewportChange:qe,canvasWidth:te==null?void 0:te.width,canvasHeight:te==null?void 0:te.height})})]})})};process.env.NODE_ENV!=="production"&&(Tr.displayName="NiceWorkflowDesigner");const Ma={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)"},Ia={start:"ellipse",end:"ellipse",task:"rectangle",decision:"diamond",parallel:"rectangle",join:"rectangle",subprocess:"rectangle",timer:"ellipse",message:"rectangle",error:"rectangle"},za={start:"play",end:"stop",task:"clipboard",decision:"help",parallel:"columns",join:"git-branch",subprocess:"box",timer:"clock",message:"mail",error:"warning"},Na=({data:r,onStepClick:e,onTransitionClick:t,autoPlay:o=!1,animationDelay:i=1e3,showTooltips:a=!0,showMinimap:n=!0,statusColors:l=Ma,typeShapes:c=Ia,direction:u="horizontal",className:d,style:p})=>{const[b,g]=m.useState(0),h=m.useMemo(()=>{const _=r.steps.map((P,D)=>{const v=P.id===r.currentStepId,X=P.status||"pending",q=l[X],L=c[P.type],M=u==="horizontal"?D*200:100,W=u==="horizontal"?100:D*150;return{id:P.id,label:P.name,x:M,y:W,width:150,height:60,shape:L,style:{fill:q,stroke:v?"var(--nice-text, #1f2937)":q,strokeWidth:v?3:1,fontColor:"var(--nice-color-white, #fff)",fontSize:12},data:{type:P.type,status:P.status,assignee:P.assignee,dueDate:P.dueDate,icon:za[P.type],...P.metadata},ports:[{id:`${P.id}-in`,position:"left"},{id:`${P.id}-out`,position:"right"}]}}),O=r.transitions.map(P=>{const D=r.steps.find(q=>q.id===P.from),v=r.steps.find(q=>q.id===P.to);let X="var(--nice-text-muted, #9ca3af)";return(D==null?void 0:D.status)==="completed"&&(v==null?void 0:v.status)!=="pending"?X="var(--nice-success, #10b981)":(D==null?void 0:D.status)==="failed"&&(X="var(--nice-danger, #ef4444)"),{id:P.id,source:P.from,target:P.to,sourcePort:`${P.from}-out`,targetPort:`${P.to}-in`,label:P.label||P.condition,style:{stroke:X,strokeWidth:2,arrowHead:"arrow",lineType:"bezier"},data:{condition:P.condition}}}),k=o?Aa(r.steps):[];return rt({id:r.id,title:r.name,diagramType:"flowchart",nodes:_,edges:O,animations:k,metadata:{type:"workflow",...r.metadata}})},[r,l,c,u,o]);m.useEffect(()=>{if(!o)return;const _=r.steps.filter(k=>k.status==="completed").length;if(b>=_)return;const O=setTimeout(()=>{g(k=>k+1)},i);return()=>clearTimeout(O)},[o,b,i,r.steps]);const[w,z]=m.useState({x:0,y:0,zoom:1}),y=m.useCallback(_=>{if(_&&e){const O=r.steps.find(k=>k.id===_);O&&e(O)}if(_&&t){const O=r.transitions.find(k=>k.id===_);O&&t(O)}},[r.steps,r.transitions,e,t]);return s.jsx("div",{className:`nice-workflow-visualizer ${d||""}`,style:{position:"relative",width:"100%",height:"100%",...p},children:s.jsx(Fe,{nodes:h.nodes,edges:h.edges,groups:h.groups,viewport:w,onViewportChange:z,onSelectElement:y,showGrid:!0})})};function Aa(r){return r.filter(t=>t.status==="completed").map((t,o)=>({id:`anim-${t.id}`,targetId:t.id,type:"highlight",delay:o*500,duration:300,easing:"ease-out"}))}function _a(r){var a,n;const t=new DOMParser().parseFromString(r,"text/xml"),o=[],i=[];return t.querySelectorAll("startEvent").forEach(l=>{o.push({id:l.getAttribute("id")||`start-${o.length}`,name:l.getAttribute("name")||"Start",type:"start"})}),t.querySelectorAll("task, userTask, serviceTask").forEach(l=>{o.push({id:l.getAttribute("id")||`task-${o.length}`,name:l.getAttribute("name")||"Task",type:"task"})}),t.querySelectorAll("exclusiveGateway, parallelGateway").forEach(l=>{const c=l.tagName==="parallelGateway";o.push({id:l.getAttribute("id")||`gateway-${o.length}`,name:l.getAttribute("name")||(c?"Parallel":"Decision"),type:c?"parallel":"decision"})}),t.querySelectorAll("endEvent").forEach(l=>{o.push({id:l.getAttribute("id")||`end-${o.length}`,name:l.getAttribute("name")||"End",type:"end"})}),t.querySelectorAll("sequenceFlow").forEach(l=>{i.push({id:l.getAttribute("id")||`flow-${i.length}`,from:l.getAttribute("sourceRef")||"",to:l.getAttribute("targetRef")||"",label:l.getAttribute("name")||void 0})}),{id:((a=t.querySelector("process"))==null?void 0:a.getAttribute("id"))||"workflow",name:((n=t.querySelector("process"))==null?void 0:n.getAttribute("name"))||"Workflow",steps:o,transitions:i}}function Da(r,e){const t=[],o=[];t.push({id:"start",name:"Start",type:"start",status:"completed"}),r.forEach((i,a)=>{t.push({id:`step-${a}`,name:i,type:"task",status:"pending"})}),t.push({id:"end",name:"End",type:"end",status:"pending"}),o.push({id:"start-to-first",from:"start",to:"step-0"});for(let i=0;i<r.length-1;i++)o.push({id:`step-${i}-to-${i+1}`,from:`step-${i}`,to:`step-${i+1}`});return o.push({id:"last-to-end",from:`step-${r.length-1}`,to:"end"}),{id:"linear-workflow",name:"Linear Workflow",steps:t,transitions:o}}const ja={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)"},$a={"one-to-one":{left:"1",right:"1"},"one-to-many":{left:"1",right:"*"},"many-to-one":{left:"*",right:"1"},"many-to-many":{left:"*",right:"*"}},Ta=({schema:r,onTableClick:e,onColumnClick:t,onRelationClick:o,showColumnDetails:i=!0,showOnlyKeys:a=!1,highlightTables:n=[],showMinimap:l=!0,schemaColors:c=ja,layout:u="auto",maxColumnsDisplay:d=15,className:p,style:b})=>{const[g,h]=m.useState(null),w=m.useMemo(()=>{const O=Pa(r.tables,u),k=r.tables.map((D,v)=>{const X=O[D.name]||{x:v%4*300,y:Math.floor(v/4)*400},q=n.includes(D.name),L=g===D.name,M=c[D.schema||"dbo"]||"var(--nice-text-secondary, #6b7280)";let W=D.columns;a&&(W=W.filter(T=>T.primaryKey||T.foreignKey)),W.length>d&&(W=W.slice(0,d));const V=40,G=i?28:20,N=V+W.length*G+10;return{id:D.name,label:D.schema?`${D.schema}.${D.name}`:D.name,x:X.x,y:X.y,width:250,height:N,shape:"rectangle",style:{fill:q||L?M:"var(--nice-bg, #fff)",stroke:M,strokeWidth:L?3:q?2:1,fontColor:q||L?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:14,borderRadius:8},data:{type:"table",schema:D.schema,columns:W.map(T=>({...T,icon:Ea(T)})),totalColumns:D.columns.length,truncated:D.columns.length>d,comment:D.comment,...D.metadata},ports:[...D.columns.filter(T=>T.primaryKey).map(T=>({id:`${D.name}.${T.name}-pk`,position:"left"})),...D.columns.filter(T=>T.foreignKey).map(T=>({id:`${D.name}.${T.name}-fk`,position:"right"}))]}}),P=r.relations.map(D=>{const v=$a[D.type];return{id:D.id,source:D.fromTable,target:D.toTable,sourcePort:`${D.fromTable}.${D.fromColumn}-fk`,targetPort:`${D.toTable}.${D.toColumn}-pk`,label:D.name||`${v.left}─${v.right}`,style:{stroke:"var(--nice-text-secondary, #6b7280)",strokeWidth:1.5,arrowHead:Ra(D.type),arrowTail:Oa(D.type),lineType:"orthogonal",strokeDasharray:D.type==="many-to-many"?"5,5":void 0},data:{type:D.type,fromColumn:D.fromColumn,toColumn:D.toColumn}}});return rt({id:`schema-${r.name}`,title:r.name,diagramType:"er",nodes:k,edges:P,metadata:{type:"er-diagram",...r.metadata}})},[r,i,a,n,g,c,u,d]),[z,y]=m.useState({x:0,y:0,zoom:1}),_=m.useCallback(O=>{if(O){if(h(k=>k===O?null:O),e){const k=r.tables.find(P=>P.name===O);k&&e(k)}if(o){const k=r.relations.find(P=>P.id===O);k&&o(k)}}},[r.tables,r.relations,e,o]);return s.jsx("div",{className:`nice-database-schema-viewer ${p||""}`,style:{position:"relative",width:"100%",height:"100%",...b},children:s.jsx(Fe,{nodes:w.nodes,edges:w.edges,groups:w.groups,viewport:z,onViewportChange:y,onSelectElement:_,showGrid:!0})})};function Pa(r,e){const t={};if(e==="grid"){const o=Math.ceil(Math.sqrt(r.length));r.forEach((i,a)=>{t[i.name]={x:a%o*320+50,y:Math.floor(a/o)*450+50}})}else if(e==="hierarchical"){const o={};r.forEach(a=>{const n=a.schema||"default";o[n]||(o[n]=[]),o[n].push(a)});let i=50;Object.entries(o).forEach(([a,n])=>{n.forEach((l,c)=>{t[l.name]={x:c*320+50,y:i}}),i+=500})}else r.forEach((o,i)=>{const a=i/r.length*2*Math.PI,n=300+r.length*20;t[o.name]={x:Math.cos(a)*n+500,y:Math.sin(a)*n+400}});return t}function Ea(r){return r.primaryKey?"lock":r.foreignKey?"link":r.unique?"zap":"file"}function Ra(r){switch(r){case"one-to-one":case"many-to-one":return"none";case"one-to-many":case"many-to-many":return"crow"}}function Oa(r){switch(r){case"one-to-one":case"one-to-many":return"none";case"many-to-one":case"many-to-many":return"crow"}}function Fa(r){const e=[],t=[],o=/CREATE\s+TABLE\s+(?:`?(\w+)`?\.)?`?(\w+)`?\s*\(([\s\S]*?)\);/gi;let i;for(;(i=o.exec(r))!==null;){const a=i[1]||"dbo",n=i[2],l=i[3],c=[],u=/`?(\w+)`?\s+(\w+(?:\([^)]+\))?)\s*(NOT\s+NULL|NULL)?/gi;let d;for(;(d=u.exec(l))!==null;)c.push({name:d[1],type:d[2],nullable:!d[3]||d[3].toUpperCase()!=="NOT NULL"});const p=/PRIMARY\s+KEY\s*\(`?(\w+)`?\)/i.exec(l);if(p){const h=c.find(w=>w.name===p[1]);h&&(h.primaryKey=!0)}const b=/FOREIGN\s+KEY\s*\(`?(\w+)`?\)\s*REFERENCES\s+`?(\w+)`?\s*\(`?(\w+)`?\)/gi;let g;for(;(g=b.exec(l))!==null;){const h=g,w=c.find(z=>z.name===h[1]);w&&(w.foreignKey={table:h[2],column:h[3]},t.push({id:`fk-${n}-${h[1]}`,fromTable:n,fromColumn:h[1],toTable:h[2],toColumn:h[3],type:"many-to-one"}))}e.push({name:n,schema:a,columns:c})}return{name:"Parsed Schema",tables:e,relations:t}}function La(r,e="postgres"){const t=[];for(const o of r.tables){const i=o.schema?`${o.schema}.${o.name}`:o.name;t.push(`CREATE TABLE ${i} (`);const a=o.columns.map(l=>{let c=` ${l.name} ${l.type}`;return l.nullable||(c+=" NOT NULL"),l.primaryKey&&(c+=" PRIMARY KEY"),l.unique&&(c+=" UNIQUE"),l.defaultValue&&(c+=` DEFAULT ${l.defaultValue}`),c}),n=o.columns.filter(l=>l.foreignKey).map(l=>` FOREIGN KEY (${l.name}) REFERENCES ${l.foreignKey.table}(${l.foreignKey.column})`);t.push([...a,...n].join(`,
4
4
  `)),t.push(`);
5
5
  `)}return t.join(`
6
- `)}const Ma={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)"],Ia={employees:[]},za=({data:o=Ia,rootEmployeeId:e,onEmployeeClick:t,onDepartmentClick:r,showAvatars:i=!0,showContactInfo:a=!1,groupByDepartment:n=!0,collapsedDepartments:c=[],maxLevels:l=0,orientation:u="vertical",spacing:d={horizontal:200,vertical:150},statusColors:m=Ma,showMinimap:w=!0,className:p,style:h})=>{const{t:x}=qe(),[z,y]=g.useState(null),S=g.useMemo(()=>{var W;if(e)return e;const L=o.employees.find(A=>!A.managerId);return(L==null?void 0:L.id)||((W=o.employees[0])==null?void 0:W.id)},[o.employees,e]),b=g.useMemo(()=>Na(o.employees,S),[o.employees,S]),v=g.useMemo(()=>{const L=Aa(b,u,d,l),W=[],A={};n&&o.departments&&o.departments.forEach((M,R)=>{const F=M.color||mt[R%mt.length];A[M.id]=F;const q=o.employees.filter(Y=>Y.department===M.id);q.length!==0&&W.push({id:`dept-${M.id}`,label:M.name,nodeIds:q.map(Y=>Y.id),style:{fill:`${F}15`,stroke:F,strokeWidth:2},data:{department:M}})});const B=[],O=[],H=(M,R=0)=>{if(l>0&&R>=l||M.employee.department&&c.includes(M.employee.department))return;const F=L[M.employee.id]||{x:0,y:0},q=z===M.employee.id,Y=M.employee.status||"active",Z=M.employee.department?A[M.employee.department]:"var(--nice-text-secondary, #6b7280)",J=180,ee=a?120:i?90:70;B.push({id:M.employee.id,label:M.employee.name,x:F.x,y:F.y,width:J,height:ee,shape:"rectangle",style:{fill:q?Z:"var(--nice-bg, #fff)",stroke:Z,strokeWidth:q?3:1,fontColor:q?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:13,borderRadius:12},data:{type:"employee",employee:M.employee,statusColor:m[Y],hasChildren:M.children.length>0,childrenCount:M.children.length}}),M.employee.managerId&&O.push({id:`rel-${M.employee.managerId}-${M.employee.id}`,source:M.employee.managerId,target:M.employee.id,style:{stroke:"var(--nice-border, #cbd5e1)",strokeWidth:2,arrowHead:"none",lineType:u==="vertical"?"orthogonal":"curved"}}),M.children.forEach(ue=>H(ue,R+1))};return b&&H(b),et({id:"org-chart",title:x("orgChartVisualizer.organizationChart","Organization Chart"),diagramType:"orgchart",nodes:B,edges:O,groups:W,metadata:{type:"org-chart",...o.metadata}})},[o,b,u,d,l,n,c,i,a,m,z,x]),[D,N]=g.useState({x:0,y:0,zoom:1}),K=g.useCallback(L=>{if(L&&(y(W=>W===L?null:L),t)){const W=o.employees.find(A=>A.id===L);W&&t(W)}},[o.employees,t]),G=g.useCallback(L=>{var A;const W=(A=o.departments)==null?void 0:A.find(B=>`dept-${B.id}`===L);W&&(r==null||r(W))},[o.departments,r]);return s.jsx("div",{className:`nice-org-chart-visualizer ${p||""}`,style:{position:"relative",width:"100%",height:"100%",...h},children:s.jsx(Be,{nodes:v.nodes,edges:v.edges,groups:v.groups,viewport:D,onViewportChange:N,onSelectElement:K,onGroupClick:r?G: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,n)=>{const c=o.filter(l=>l.managerId===a.id);return{employee:a,children:c.map(l=>i(l,n+1)),level:n}};return i(r,0)}function Aa(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,m)=>d+a(m,u+1),0),n=(l,u,d,m)=>{if(r>0&&u>=r)return;const w=d+m*t.horizontal/2,p=u*t.vertical+50;i[l.employee.id]=e==="vertical"?{x:w,y:p}:{x:p,y:w};let h=d;l.children.forEach(x=>{const z=a(x,u+1);n(x,u+1,h,z),h+=z*t.horizontal})},c=a(o,0);return n(o,0,0,c),i}function _a(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 Da(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(m=>m.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),n=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(n*10)/10,managers:e.size}}const ja=({data:o,onActivityClick:e,onTransitionClick:t,minEdgeFrequency:r=.05,showFrequency:i=!0,showDuration:a=!0,highlightBottlenecks:n=!0,bottleneckThreshold:c=.9,colorScheme:l="frequency",activityColors:u,layout:d="hierarchical",animationSpeed:m=0,showMinimap:w=!0,className:p,style:h})=>{const{t:x}=qe(),[z,y]=g.useState(null),S=g.useMemo(()=>"activities"in o?o:zr(o),[o]),b=g.useMemo(()=>{if(!n)return new Set;const L=S.activities.filter(A=>A.avgDuration!==void 0).map(A=>A.avgDuration);if(L.length===0)return new Set;L.sort((A,B)=>A-B);const W=L[Math.floor(L.length*c)]||0;return new Set(S.activities.filter(A=>(A.avgDuration||0)>=W).map(A=>A.name))},[S.activities,n,c]),v=g.useMemo(()=>{const L=Math.max(...S.activities.map(M=>M.frequency),1),W=Ta(S,d),A=S.transitions.filter(M=>M.frequency/S.totalCases>=r),B=S.activities.map(M=>{const R=W[M.name]||{x:0,y:0},F=S.startActivities.includes(M.name),q=S.endActivities.includes(M.name),Y=b.has(M.name),Z=z===M.name,J=Pa(M,l,L,u,Y);return{id:M.name,label:M.name,x:R.x,y:R.y,width:140,height:60,shape:F?"ellipse":q?"roundedRect":"rectangle",style:{fill:Z?J:"var(--nice-bg, #fff)",stroke:J,strokeWidth:Y?4:Z?3:2,fontColor:Z?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:12,borderRadius:q?20:8},data:{type:"activity",activity:M,isStart:F,isEnd:q,isBottleneck:Y,frequencyPercent:Math.round(M.frequency/S.totalCases*100)}}}),O=A.map(M=>{const R=S.transitions.indexOf(M),F=M.probability||M.frequency/S.totalCases,q=F>.5,Y=[];return i&&Y.push(`${M.frequency}x`),a&&M.avgDuration&&Y.push(Ra(M.avgDuration)),{id:`trans-${R}`,source:M.from,target:M.to,label:Y.join(" | "),style:{stroke:q?"var(--nice-primary, #3b82f6)":"var(--nice-text-muted, #9ca3af)",strokeWidth:Math.max(1,Math.min(6,F*8)),arrowHead:"triangle",lineType:"curved",opacity:Math.max(.3,F)},data:{type:"transition",transition:M,probability:F}}}),H=m>0?Ea(S,m):[];return et({id:"process-mining",title:x("processMiningDiagram.processMiningDiagram","Process Mining Diagram"),diagramType:"flowchart",nodes:B,edges:O,animations:H,metadata:{type:"process-mining",totalCases:S.totalCases,avgCaseDuration:S.avgCaseDuration}})},[S,r,i,a,b,l,u,d,m,z,x]),D=g.useCallback(L=>{if(!t)return;const W=parseInt(L.replace("trans-",""),10),A=S.transitions[W];A&&t(A)},[S.transitions,t]),[N,K]=g.useState({x:0,y:0,zoom:1}),G=g.useCallback(L=>{if(L){if(L.startsWith("trans-")){D(L);return}if(y(W=>W===L?null:L),e){const W=S.activities.find(A=>A.name===L);W&&e(W)}}},[S.activities,e,D]);return s.jsx("div",{className:`nice-process-mining-diagram ${p||""}`,style:{position:"relative",width:"100%",height:"100%",...h},children:s.jsx(Be,{nodes:v.nodes,edges:v.edges,groups:v.groups,viewport:N,onViewportChange:K,onSelectElement:G,showGrid:!0})})};function Ta(o,e){const t={};if(e==="circular"){const r=o.activities;r.forEach((i,a)=>{const n=a/r.length*2*Math.PI-Math.PI/2,c=200+r.length*15;t[i.name]={x:Math.cos(n)*c+400,y:Math.sin(n)*c+300}})}else{const r=$a(o),i={};o.activities.forEach(n=>{const c=r[n.name]||0;i[c]=(i[c]||0)+1});const a={};o.activities.forEach(n=>{const c=r[n.name]||0,l=a[c]||0;a[c]=l+1;const u=i[c],d=(l-(u-1)/2)*180;t[n.name]={x:400+d,y:50+c*120}})}return t}function $a(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 Pa(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 Nt("var(--nice-success, #10b981)","var(--nice-primary, #3b82f6)",a);case"duration":return o.avgDuration?Nt("var(--nice-success, #10b981)","var(--nice-warning, #f59e0b)",a):"var(--nice-text-secondary, #6b7280)";case"cost":return o.avgCost?Nt("var(--nice-success, #10b981)","var(--nice-danger, #ef4444)",a):"var(--nice-text-secondary, #6b7280)";default:return"var(--nice-primary, #3b82f6)"}}function Nt(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),n=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`#${[n,c,l].map(u=>u.toString(16).padStart(2,"0")).join("")}`}function Ra(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 Ea(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 zr(o){const e=o.events.map(p=>({...p,timestamp:p.timestamp instanceof Date?p.timestamp:new Date(p.timestamp)})),t=new Map;e.forEach(p=>{t.has(p.caseId)||t.set(p.caseId,[]),t.get(p.caseId).push(p)}),t.forEach(p=>{p.sort((h,x)=>h.timestamp.getTime()-x.timestamp.getTime())});const r=new Map,i=new Map,a=new Set,n=new Set;t.forEach(p=>{if(p.length!==0){a.add(p[0].activity),n.add(p[p.length-1].activity);for(let h=0;h<p.length;h++){const x=p[h];r.has(x.activity)||r.set(x.activity,{frequency:0,durations:[],resources:new Set,costs:[]});const z=r.get(x.activity);if(z.frequency++,x.resource&&z.resources.add(x.resource),x.cost!==void 0&&z.costs.push(x.cost),h<p.length-1){const y=p[h+1],S=y.timestamp.getTime()-x.timestamp.getTime();z.durations.push(S);const b=`${x.activity}→${y.activity}`;i.has(b)||i.set(b,{frequency:0,durations:[]});const v=i.get(b);v.frequency++,v.durations.push(S)}}}});const c=Array.from(r.entries()).map(([p,h])=>({name:p,frequency:h.frequency,avgDuration:h.durations.length>0?h.durations.reduce((x,z)=>x+z,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((x,z)=>x+z,0)/h.costs.length:void 0})),l=Array.from(i.entries()).map(([p,h])=>{const[x,z]=p.split("→");return{from:x,to:z,frequency:h.frequency,avgDuration:h.durations.length>0?h.durations.reduce((y,S)=>y+S,0)/h.durations.length:void 0,probability:h.frequency/t.size}}),u=new Map;t.forEach((p,h)=>{const x=p.map(y=>y.activity).join("→");u.has(x)||u.set(x,{caseIds:[],durations:[]});const z=u.get(x);if(z.caseIds.push(h),p.length>=2){const y=p[p.length-1].timestamp.getTime()-p[0].timestamp.getTime();z.durations.push(y)}});const d=Array.from(u.entries()).map(([p,h])=>({activities:p.split("→"),frequency:h.caseIds.length,avgDuration:h.durations.length>0?h.durations.reduce((x,z)=>x+z,0)/h.durations.length:0,caseIds:h.caseIds})).sort((p,h)=>h.frequency-p.frequency),m=Array.from(t.values()).filter(p=>p.length>=2).map(p=>p[p.length-1].timestamp.getTime()-p[0].timestamp.getTime()),w=m.length>0?m.reduce((p,h)=>p+h,0)/m.length:void 0;return{activities:c,transitions:l,variants:d,startActivities:Array.from(a),endActivities:Array.from(n),totalCases:t.size,avgCaseDuration:w}}const Nr={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)"},Ar={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)"},Jt={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)"}},Oa={module:"box",package:"folder",microservice:"square",library:"book",api:"plug",database:"database",external:"globe",deprecated:"warning"},Fa=({data:o,onNodeClick:e,onEdgeClick:t,visibleTypes:r,visibleEdgeTypes:i,highlightCircular:a=!0,showOnlyIssues:n=!1,layout:c="force",groupBy:l="type",nodeSizeBy:u="dependencies",colorScheme:d="type",nodeColors:m,showMetrics:w=!0,interactive:p=!0,showMinimap:h=!0,className:x,style:z})=>{const{t:y}=qe(),[S,b]=g.useState(null),[v,D]=g.useState(null),N=g.useMemo(()=>a?_r(o):new Set,[o,a]),K=g.useMemo(()=>{let H=o.nodes;return r&&r.length>0&&(H=H.filter(M=>r.includes(M.type))),n&&(H=H.filter(M=>{var R;return M.status==="critical"||M.status==="warning"||((R=M.metrics)==null?void 0:R.issues)&&M.metrics.issues>0})),H},[o.nodes,r,n]),G=g.useMemo(()=>{const H=new Set(K.map(R=>R.id));let M=o.edges.filter(R=>H.has(R.source)&&H.has(R.target));return i&&i.length>0&&(M=M.filter(R=>i.includes(R.type))),M},[o.edges,K,i]),L=g.useMemo(()=>{const H=La(K,G,c),M=Ba(K,u),R=[];if(l!=="none"){const Y=new Map;K.forEach(J=>{const ee=l==="type"?J.type:J.group||"ungrouped";Y.has(ee)||Y.set(ee,[]),Y.get(ee).push(J.id)});let Z=0;Y.forEach((J,ee)=>{var fe,Se;const ue=l==="type"?Nr[ee]||"var(--nice-text-secondary, #6b7280)":((Se=(fe=o.groups)==null?void 0:fe.find($e=>$e.id===ee))==null?void 0:Se.color)||yt[Z%yt.length];R.push({id:`group-${ee}`,label:ee,nodeIds:J,style:{fill:`${ue}10`,stroke:ue,strokeWidth:1}}),Z++})}const F=K.map(Y=>{const Z=H[Y.id]||{x:0,y:0},J=S===Y.id,ee=v===Y.id,ue=N.has(Y.id),fe=Va(Y,u,M),Se=qa(Y,d,m,ue);return{id:Y.id,label:Y.name,x:Z.x,y:Z.y,width:fe.width,height:fe.height,shape:Ga(Y.type),style:{fill:J||ee?Se:"var(--nice-bg, #fff)",stroke:Se,strokeWidth:ue?4:J?3:2,fontColor:J||ee?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:8,strokeDasharray:Y.status==="deprecated"?"4,4":void 0},data:{type:"dependency",node:Y,icon:Oa[Y.type],isCircular:ue,statusColor:Ar[Y.status||"unknown"]}}}),q=G.map((Y,Z)=>{const J=Y.type==="circular"||N.has(Y.source)&&N.has(Y.target),ee=Jt[Y.type]||Jt.import;return{id:Y.id||`edge-${Z}`,source:Y.source,target:Y.target,label:Y.optional?y("dependencyGraph.optional","(optional)"):void 0,style:{stroke:J?"var(--nice-danger, #ef4444)":ee.color,strokeWidth:Math.max(1,Math.min(4,Y.weight||1)),strokeDasharray:ee.dash,arrowHead:"triangle",lineType:"curved",opacity:Y.optional?.5:1},data:{type:Y.type,edge:Y,isCircular:J}}});return et({id:"dependency-graph",title:y("dependencyGraph.dependencyGraph","Dependency Graph"),diagramType:"custom",nodes:F,edges:q,groups:R,metadata:{type:"dependency-graph",...o.metadata}})},[K,G,c,l,o.groups,u,d,m,N,S,v,o.metadata,y]),W=g.useCallback(H=>{D(H)},[]),[A,B]=g.useState({x:0,y:0,zoom:1}),O=g.useCallback(H=>{if(H){if(b(M=>M===H?null:H),e){const M=o.nodes.find(R=>R.id===H);M&&e(M)}if(t){const M=o.edges.find(R=>R.id===H);M&&t(M)}}},[o.nodes,o.edges,e,t]);return s.jsx("div",{className:`nice-dependency-graph ${x||""}`,style:{position:"relative",width:"100%",height:"100%",...z},children:s.jsx(Be,{nodes:L.nodes,edges:L.edges,groups:L.groups,viewport:A,onViewportChange:B,onSelectElement:O,onNodeHover:W,interactive:p,showGrid:!0})})},yt=["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 _r(o){const e=new Set,t=new Map;o.nodes.forEach(n=>t.set(n.id,[])),o.edges.forEach(n=>{var c;(c=t.get(n.source))==null||c.push(n.target)});const r=new Set,i=new Set,a=(n,c)=>{r.add(n),i.add(n),c.push(n);const l=t.get(n)||[];for(const u of l)if(r.has(u)){if(i.has(u)){const d=c.indexOf(u);c.slice(d).forEach(w=>e.add(w))}}else if(a(u,[...c]))return!0;return i.delete(n),!1};return o.nodes.forEach(n=>{r.has(n.id)||a(n.id,[])}),e}function La(o,e,t){const r={};switch(t){case"circular":{o.forEach((i,a)=>{const n=a/o.length*2*Math.PI-Math.PI/2,c=150+o.length*12;r[i.id]={x:Math.cos(n)*c+400,y:Math.sin(n)*c+300}});break}case"grid":{const i=Math.ceil(Math.sqrt(o.length));o.forEach((a,n)=>{r[a.id]={x:n%i*200+100,y:Math.floor(n/i)*150+100}});break}case"hierarchical":{const i=Wa(o,e),a={},n={};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=n[l]||0;n[l]=u+1;const d=a[l],m=(u-(d-1)/2)*200;r[c.id]={x:400+m,y:80+l*130}});break}default:{o.forEach((i,a)=>{const n=a/o.length*2*Math.PI,c=200+o.length*10;r[i.id]={x:Math.cos(n)*c+400,y:Math.sin(n)*c+300}});for(let i=0;i<50;i++){const a={};o.forEach(n=>a[n.id]={x:0,y:0});for(let n=0;n<o.length;n++)for(let c=n+1;c<o.length;c++){const l=o[n].id,u=o[c].id,d=r[u].x-r[l].x,m=r[u].y-r[l].y,w=Math.max(1,Math.sqrt(d*d+m*m)),p=5e3/(w*w);a[l].x-=d/w*p,a[l].y-=m/w*p,a[u].x+=d/w*p,a[u].y+=m/w*p}e.forEach(n=>{const c=r[n.target].x-r[n.source].x,l=r[n.target].y-r[n.source].y,u=Math.sqrt(c*c+l*l),d=u*.01;a[n.source].x+=c/u*d,a[n.source].y+=l/u*d,a[n.target].x-=c/u*d,a[n.target].y-=l/u*d}),o.forEach(n=>{r[n.id].x+=Math.max(-10,Math.min(10,a[n.id].x)),r[n.id].y+=Math.max(-10,Math.min(10,a[n.id].y))})}break}}return r}function Wa(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 Ba(o,e){const t=o.map(r=>{var i,a,n;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((n=r.metrics)==null?void 0:n.complexity)||0;case"size":return r.size||0;default:return 1}});return{min:Math.min(...t,0),max:Math.max(...t,1)}}function Va(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 qa(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 Ar[o.status||"unknown"];case"group":return yt[Ya(o.group||"")%yt.length];default:return Nr[o.type]||"var(--nice-text-secondary, #6b7280)"}}function Ga(o){switch(o){case"database":return"cylinder";case"microservice":return"hexagon";case"api":return"diamond";case"external":return"cloud";default:return"rectangle"}}function Ya(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 Ha(o){const e=[{id:o.name,name:o.name,version:o.version,type:"package",status:"healthy"}],t=[];let r=0;const i=(a,n)=>{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:n})})};return i(o.dependencies,"runtime"),i(o.devDependencies,"dev"),i(o.peerDependencies,"peer"),e.forEach(a=>{a.metrics={dependencies:t.filter(n=>n.source===a.id).length,dependents:t.filter(n=>n.target===a.id).length}}),{nodes:e,edges:t}}function Ua(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)}),_r(o);let r=null,i=0;o.nodes.forEach(d=>{const m=e.get(d.id)||0;m>i&&(i=m,r=d)});let a=null,n=0;o.nodes.forEach(d=>{const m=t.get(d.id)||0;m>n&&(n=m,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,m)=>d+m,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 Xa={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)"},Ka={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"},Za={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)"},Ja=({data:o,onDeviceClick:e,onConnectionClick:t,onRefresh:r,autoRefreshInterval:i=0,visibleDeviceTypes:a,showOnlyIssues:n=!1,layout:c="hierarchical",groupBy:l="group",showMetrics:u=!0,showBandwidth:d=!0,showLatency:m=!1,animateTraffic:w=!1,statusColors:p=Xa,showMinimap:h=!0,className:x,style:z})=>{const{t:y}=qe(),[S,b]=g.useState(null),[v,D]=g.useState(new Date);g.useEffect(()=>{if(i<=0||!r)return;const B=setInterval(()=>{r(),D(new Date)},i);return()=>clearInterval(B)},[i,r]);const N=g.useMemo(()=>{let B=o.devices;return a&&a.length>0&&(B=B.filter(O=>a.includes(O.type))),n&&(B=B.filter(O=>O.status==="critical"||O.status==="warning"||O.status==="offline")),B},[o.devices,a,n]),K=g.useMemo(()=>{const B=new Set(N.map(O=>O.id));return o.connections.filter(O=>B.has(O.source)&&B.has(O.target))},[o.connections,N]),G=g.useMemo(()=>{const B=Qa(N,K,c,o.groups),O=[];if(l!=="none"){const F=new Map;N.forEach(Y=>{let Z;switch(l){case"type":Z=Y.type;break;case"location":Z=Y.location||"Unknown Location";break;default:Z=Y.group||"ungrouped"}F.has(Z)||F.set(Z,[]),F.get(Z).push(Y.id)});let q=0;F.forEach((Y,Z)=>{var ue;const J=(ue=o.groups)==null?void 0:ue.find(fe=>fe.id===Z||fe.name===Z),ee=(J==null?void 0:J.color)||Qt[q%Qt.length];O.push({id:`group-${Z}`,label:(J==null?void 0:J.name)||Z,nodeIds:Y,style:{fill:`${ee}15`,stroke:ee,strokeWidth:2}}),q++})}const H=N.map(F=>{const q=B[F.id]||{x:0,y:0},Y=S===F.id,Z=p[F.status],J=Ka[F.type];return{id:F.id,label:F.name,x:q.x,y:q.y,width:120,height:u?90:70,shape:en(F.type),style:{fill:Y?Z:"var(--nice-bg, #fff)",stroke:Z,strokeWidth:Y?3:2,fontColor:Y?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:8},data:{type:"network-device",device:F,icon:J,statusColor:Z}}}),M=K.map((F,q)=>{const Y=Za[F.type]||"var(--nice-text-secondary, #6b7280)",Z=F.status==="active",J=F.status==="degraded"||F.status==="error",ee=[];if(d&&F.bandwidth){const ue=Math.round(F.bandwidth.used/F.bandwidth.total*100);ee.push(`${ue}%`)}return m&&F.latency!==void 0&&ee.push(`${F.latency}ms`),{id:F.id||`conn-${q}`,source:F.source,target:F.target,sourcePort:F.sourcePort,targetPort:F.targetPort,label:ee.join(" | ")||void 0,style:{stroke:J?"var(--nice-danger, #ef4444)":Y,strokeWidth:Math.max(1,Math.min(6,(F.speed||1e3)/1e3)),strokeDasharray:Z?void 0:"5,5",arrowHead:"none",lineType:F.type==="wireless"?"curved":"orthogonal",opacity:F.status==="inactive"?.3:1},data:{type:F.type,connection:F,isActive:Z,isDegraded:J}}}),R=w?tn(K):[];return et({id:"network-topology",title:y("networkTopology.networkTopology","Network Topology"),diagramType:"networkTopology",nodes:H,edges:M,groups:O,animations:R,metadata:{type:"network-topology",lastRefresh:v.toISOString(),...o.metadata}})},[N,K,c,l,o.groups,u,d,m,w,p,S,v,o.metadata,y]),[L,W]=g.useState({x:0,y:0,zoom:1}),A=g.useCallback(B=>{if(!B)return;const O=o.connections.find(H=>H.id===B);if(O){t==null||t(O);return}if(b(H=>H===B?null:B),e){const H=o.devices.find(M=>M.id===B);H&&e(H)}},[o.devices,o.connections,e,t]);return s.jsx("div",{className:`nice-network-topology ${x||""}`,style:{position:"relative",width:"100%",height:"100%",...z},children:s.jsx(Be,{nodes:G.nodes,edges:G.edges,groups:G.groups,viewport:L,onViewportChange:W,onSelectElement:A,showGrid:!0})})},Qt=["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 Qa(o,e,t,r){var a;const i={};switch(t){case"star":{const n=new Map;o.forEach(d=>n.set(d.id,0)),e.forEach(d=>{n.set(d.source,(n.get(d.source)||0)+1),n.set(d.target,(n.get(d.target)||0)+1)});let c=(a=o[0])==null?void 0:a.id,l=0;n.forEach((d,m)=>{d>l&&(l=d,c=m)}),i[c]={x:400,y:300};const u=o.filter(d=>d.id!==c);u.forEach((d,m)=>{const w=m/u.length*2*Math.PI-Math.PI/2,p=200;i[d.id]={x:Math.cos(w)*p+400,y:Math.sin(w)*p+300}});break}case"mesh":{const n=Math.ceil(Math.sqrt(o.length));o.forEach((c,l)=>{i[c.id]={x:l%n*150+100,y:Math.floor(l/n)*130+100}});break}case"tree":{const n=o.filter(w=>w.type==="internet"||w.type==="cloud"||w.type==="router"),c=new Map,l=n.map(w=>w.id);l.forEach(w=>c.set(w,0));const u=new Set(l);for(;l.length>0;){const w=l.shift(),p=c.get(w)||0;e.forEach(h=>{let x=null;h.source===w&&!u.has(h.target)&&(x=h.target),h.target===w&&!u.has(h.source)&&(x=h.source),x&&(u.add(x),c.set(x,p+1),l.push(x))})}const d={},m={};o.forEach(w=>{const p=c.get(w.id)||0;d[p]=(d[p]||0)+1}),o.forEach(w=>{const p=c.get(w.id)||0,h=m[p]||0;m[p]=h+1;const x=d[p],z=(h-(x-1)/2)*160;i[w.id]={x:400+z,y:80+p*120}});break}case"hierarchical":default:{const n=["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;n.forEach(u=>{const d=c.get(u);!d||d.length===0||(d.forEach((m,w)=>{const p=(w-(d.length-1)/2)*150;i[m.id]={x:400+p,y:l}}),l+=130)});break}}return i}function en(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 tn(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 rn(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 on(o){const e=o.devices.filter(m=>m.status==="online").length,t=o.devices.filter(m=>m.status==="offline").length,r=o.devices.filter(m=>m.status==="warning").length,i=o.devices.filter(m=>m.status==="critical").length,a=o.connections.filter(m=>m.status==="active").length,n=o.connections.filter(m=>m.status==="degraded"||m.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+n*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:n}}const an=[{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"}],nn={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)"},sn=({data:o,onChange:e,onNodeClick:t,editable:r=!1,showMetrics:i=!0,showProbabilities:a=!0,showSamples:n=!0,highlightPath:c,colorScheme:l="outcome",nodeColors:u,orientation:d="vertical",spacing:m={horizontal:180,vertical:120},showMinimap:w=!0,className:p,style:h,tutorial:x})=>{const{t:z}=qe(),[y,S]=g.useState(null),[b,v]=g.useState(new Set),D=g.useMemo(()=>c?fn(o.root,c):new Set,[o.root,c]),{nodes:N,edges:K}=g.useMemo(()=>ln(o.root,o.edges),[o.root,o.edges]),G=g.useMemo(()=>dn(N),[N]),L=g.useMemo(()=>{var R,F;const O=cn(o.root,d,m),H=N.map(q=>{const Y=O[q.id]||{x:0,y:0},Z=y===q.id,J=D.has(q.id),ee=q.type==="leaf"||q.type==="end",ue=un(q,l,u,G),fe=ee?120:160,Se=i?80:ee?60:70;return{id:q.id,label:q.label,x:Y.x,y:Y.y,width:fe,height:Se,shape:ee?"roundedRect":"diamond",style:{fill:Z||J?ue:"var(--nice-bg, #fff)",stroke:ue,strokeWidth:J?4:Z?3:2,fontColor:Z||J?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:ee?8:0},data:{type:"decision-tree-node",node:q,isLeaf:ee,isHighlighted:J}}}),M=K.map((q,Y)=>{const Z=D.has(q.source)&&D.has(q.target);let J=q.label||"";return a&&q.probability!==void 0&&(J+=J?` (${(q.probability*100).toFixed(0)}%)`:`${(q.probability*100).toFixed(0)}%`),{id:q.id||`edge-${Y}`,source:q.source,target:q.target,label:J||void 0,style:{stroke:Z?"var(--nice-primary, #3b82f6)":"var(--nice-text-muted, #9ca3af)",strokeWidth:Z?3:2,arrowHead:"triangle",lineType:d==="vertical"?"orthogonal":"curved"},data:{type:"decision-edge",edge:q,isHighlighted:Z}}});return et({id:"decision-tree",title:z("decisionTreeEditor.decisionTree","Decision Tree"),diagramType:"decisionTree",nodes:H,edges:M,animations:c?hn(Array.from(D)):[],metadata:{type:"decision-tree",algorithm:(R=o.metadata)==null?void 0:R.algorithm,accuracy:(F=o.metadata)==null?void 0:F.accuracy}})},[N,K,d,m,i,a,l,u,G,y,D,c,o.metadata,o.root,z]),[W,A]=g.useState({x:0,y:0,zoom:1}),B=g.useCallback(O=>{if(!O)return;S(M=>M===O?null:O);const H=N.find(M=>M.id===O);H&&H.type!=="leaf"&&H.type!=="end"&&v(M=>{const R=new Set(M);return R.has(O)?R.delete(O):R.add(O),R}),t&&H&&t(H)},[N,t]);return s.jsxs("div",{className:`nice-decision-tree-editor ${p||""}`,style:{position:"relative",width:"100%",height:"100%",...h},children:[s.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:s.jsx(k.NiceTutorialButton,{steps:k.resolveTutorial(x,an)})}),s.jsx(Be,{nodes:L.nodes,edges:L.edges,groups:L.groups,viewport:W,onViewportChange:A,onSelectElement:B,interactive:!0,showGrid:!1})]})};function ln(o,e){const t=[],r=e?[...e]:[],i=new Set(r.map(n=>`${n.source}-${n.target}`)),a=(n,c)=>{t.push(n),c&&!i.has(`${c}-${n.id}`)&&r.push({id:`e-${c}-${n.id}`,source:c,target:n.id}),n.children&&n.children.forEach((l,u)=>{let d="";n.condition&&(d=u===0?"Yes":"No");const m=`${n.id}-${l.id}`;i.has(m)||(r.push({id:`e-${m}`,source:n.id,target:l.id,label:d,branch:u===0?"yes":"no"}),i.add(m)),a(l,n.id)})};return a(o),{nodes:t,edges:r}}function cn(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 m=u+d*t.horizontal/2,w=l*t.vertical+50;if(r[c.id]=e==="vertical"?{x:m,y:w}:{x:w,y:m},c.children){let p=u;c.children.forEach(h=>{const x=i(h);a(h,l+1,p,x),p+=x*t.horizontal})}},n=i(o);return a(o,0,0,n),r}function dn(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 un(o,e,t,r){var i,a,n;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 er("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 er("var(--nice-warning-bg, #fef3c7)","var(--nice-warning, #f59e0b)",c)}break;case"outcome":if(o.type==="leaf"&&((n=o.outcome)!=null&&n.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 nn[o.type]||"var(--nice-text-secondary, #6b7280)"}function er(o,e,t){const r=u=>{var m;const d=((m=/#([a-f\d]{6})\b/i.exec(u))==null?void 0:m[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),n=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`#${[n,c,l].map(u=>u.toString(16).padStart(2,"0")).join("")}`}function fn(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=Dr(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 Dr(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 hn(o){return o.map((e,t)=>({id:`path-${t}`,type:"highlight",targets:[e],duration:500,delay:t*300}))}function pn(o){const{tree:e,feature_names:t,class_names:r}=o;e.children_left.length;const i=n=>{const c=e.children_left[n]===-1,l=e.n_node_samples[n],u=e.impurity[n],d=e.value[n];if(c){const z=Array.isArray(d)?d:[d],y=Array.isArray(z[0])?z[0]:z,S=y.indexOf(Math.max(...y)),b=(r==null?void 0:r[S])||`Class ${S}`,v=y.reduce((N,K)=>N+K,0),D=v>0?y[S]/v:0;return{id:`node-${n}`,type:"leaf",label:b,outcome:{value:b,class:b,probability:D,samples:l},metrics:{samples:l,impurity:u}}}const m=e.feature[n],w=e.threshold[n],p=t[m]||`feature_${m}`,h=i(e.children_left[n]),x=i(e.children_right[n]);return{id:`node-${n}`,type:n===0?"root":"decision",label:`${p} <= ${w.toFixed(2)}`,condition:{feature:p,operator:"<=",value:w},children:[h,x],metrics:{samples:l,impurity:u,giniIndex:u}}},a=i(0);return{root:a,features:t,classes:r,metadata:{algorithm:"sklearn.DecisionTreeClassifier",maxDepth:jr(a)}}}function jr(o,e=0){return!o.children||o.children.length===0?e:Math.max(...o.children.map(t=>jr(t,e+1)))}function gn(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 mn(o,e){const t=[],r=a=>{var n,c;if(t.push(a.id),a.type==="leaf"||a.type==="end"||!a.children)return{value:((n=a.outcome)==null?void 0:n.value)??a.label,probability:(c=a.outcome)==null?void 0:c.probability};if(a.condition){const l=e[a.condition.feature],d=Dr(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 yn=0;function Ft(){return`tmpl-${++yn}-${Date.now().toString(36)}`}function le(o,e,t="roundedRect",r={width:160,height:60},i){return{id:Ft(),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 de(o,e,t="bottom",r="top",i){return{id:Ft(),sourceNodeId:o.id,sourcePortId:t,targetNodeId:e.id,targetPortId:r,label:i,style:{lineType:"bezier",targetArrow:"arrow"}}}function ct(o,e,t,r){const i=new Date().toISOString();return{version:"1.0",id:Ft(),title:o,diagramType:e,nodes:t,edges:r,groups:[],animations:[],viewport:{x:0,y:0,zoom:1},metadata:{createdAt:i,updatedAt:i}}}function bn(){const o=le("Commit",{x:40,y:200},"circle",{width:80,height:80}),e=le("Build",{x:200,y:200},"roundedRect"),t=le("Test",{x:420,y:200},"roundedRect"),r=le("Deploy",{x:640,y:200},"roundedRect"),i=le("Production",{x:860,y:200},"hexagon",{width:140,height:80});return ct("CI/CD Pipeline","flowchart",[o,e,t,r,i],[de(o,e,"right","left"),de(e,t,"right","left"),de(t,r,"right","left"),de(r,i,"right","left")])}function wn(){const o=le("API Gateway",{x:350,y:40},"hexagon",{width:160,height:80}),e=le("Auth Service",{x:80,y:200},"roundedRect"),t=le("User Service",{x:300,y:200},"roundedRect"),r=le("Order Service",{x:520,y:200},"roundedRect"),i=le("Notification",{x:740,y:200},"roundedRect"),a=le("Users DB",{x:180,y:380},"cylinder",{width:120,height:70}),n=le("Orders DB",{x:520,y:380},"cylinder",{width:120,height:70}),c=le("Message Queue",{x:620,y:380},"parallelogram",{width:160,height:60}),l=[o,e,t,r,i,a,n,c],u=[de(o,e,"bottom","top"),de(o,t,"bottom","top"),de(o,r,"bottom","top"),de(r,i,"right","left"),de(t,a,"bottom","top"),de(r,n,"bottom","top"),de(i,c,"bottom","top")];return ct("Microservices Architecture","flowchart",l,u)}function xn(){const o=le("Start",{x:350,y:20},"circle",{width:70,height:70}),e=le("Landing Page",{x:310,y:140},"roundedRect"),t=le("Sign Up",{x:140,y:280},"roundedRect"),r=le("Log In",{x:480,y:280},"roundedRect"),i=le("Dashboard",{x:310,y:420},"roundedRect"),a=le("End",{x:350,y:560},"circle",{width:70,height:70});return ct("User Flow","flowchart",[o,e,t,r,i,a],[de(o,e,"bottom","top"),de(e,t,"bottom","top","New user"),de(e,r,"bottom","top","Returning"),de(t,i,"bottom","top"),de(r,i,"bottom","top"),de(i,a,"bottom","top")])}function vn(){const o=le("Users",{x:80,y:100},"rectangle",{width:180,height:100}),e=le("Orders",{x:380,y:100},"rectangle",{width:180,height:100}),t=le("Products",{x:380,y:320},"rectangle",{width:180,height:100}),r=le("Categories",{x:680,y:320},"rectangle",{width:180,height:100});return ct("Entity Relationship","er",[o,e,t,r],[de(o,e,"right","left","1:N"),de(e,t,"bottom","top","N:M"),de(t,r,"right","left","N:1")])}function kn(){const o=le("CEO",{x:350,y:40},"roundedRect"),e=le("CTO",{x:150,y:180},"roundedRect"),t=le("CFO",{x:550,y:180},"roundedRect"),r=le("Engineering",{x:50,y:320},"roundedRect"),i=le("DevOps",{x:250,y:320},"roundedRect"),a=le("Accounting",{x:550,y:320},"roundedRect");return ct("Organization Chart","orgchart",[o,e,t,r,i,a],[de(o,e,"bottom","top"),de(o,t,"bottom","top"),de(e,r,"bottom","top"),de(e,i,"bottom","top"),de(t,a,"bottom","top")])}function Cn(){const o=le("Idle",{x:80,y:200},"circle",{width:90,height:90}),e=le("Loading",{x:300,y:80},"roundedRect"),t=le("Success",{x:520,y:80},"roundedRect"),r=le("Error",{x:520,y:320},"roundedRect"),i=le("Retry",{x:300,y:320},"diamond",{width:100,height:100});return ct("State Machine","stateMachine",[o,e,t,r,i],[de(o,e,"right","left","fetch"),de(e,t,"right","left","ok"),de(e,r,"bottom","top","fail"),de(r,i,"left","right"),de(i,e,"top","bottom","retry"),de(i,o,"left","right","cancel")])}const Ct=[{id:"cicd-pipeline",name:"CI/CD Pipeline",description:"Continuous integration and deployment pipeline",category:"software",diagramType:"flowchart",tags:["devops","ci","cd","pipeline","deployment"],create:bn},{id:"microservices",name:"Microservices Architecture",description:"Microservices with API gateway, databases, and message queue",category:"software",diagramType:"flowchart",tags:["architecture","microservices","api","backend"],create:wn},{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:xn},{id:"er-diagram",name:"Entity Relationship",description:"Database ER diagram with tables and relations",category:"software",diagramType:"er",tags:["database","er","schema","sql"],create:vn},{id:"org-chart",name:"Organization Chart",description:"Company organizational hierarchy",category:"business",diagramType:"orgchart",tags:["org","hierarchy","team","management"],create:kn},{id:"state-machine",name:"State Machine",description:"Finite state machine with transitions",category:"software",diagramType:"stateMachine",tags:["state","fsm","transitions","machine"],create:Cn}];function Sn(o){return Ct.find(e=>e.id===o)}function Mn(o){return Ct.filter(e=>e.category===o)}function In(o){const e=o.toLowerCase();return Ct.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.tags.some(r=>r.includes(e)))}class Tr{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:zn(),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),n=JSON.parse(i.snapshot),c=this.calculateChanges(a,n),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 m=e.nodes.find(w=>w.id===d.id);m&&((m.position.x!==d.position.x||m.position.y!==d.position.y)&&r.push({type:"node-moved",elementId:d.id,elementType:"node",previousValue:{x:m.position.x,y:m.position.y},newValue:{x:d.position.x,y:d.position.y},description:`Node "${d.label||d.id}" moved`}),(m.size.width!==d.size.width||m.size.height!==d.size.height)&&r.push({type:"node-resized",elementId:d.id,elementType:"node",previousValue:{width:m.size.width,height:m.size.height},newValue:{width:d.size.width,height:d.size.height},description:`Node "${d.label||d.id}" resized`}),m.label!==d.label&&r.push({type:"node-relabeled",elementId:d.id,elementType:"node",previousValue:m.label,newValue:d.label,description:`Node label changed from "${m.label}" to "${d.label}"`}),JSON.stringify(m.style)!==JSON.stringify(d.style)&&r.push({type:"node-restyled",elementId:d.id,elementType:"node",previousValue:m.style,newValue:d.style,description:`Node "${d.label||d.id}" style changed`}))}const n=new Set(e.edges.map(d=>d.id)),c=new Set(t.edges.map(d=>d.id));for(const d of t.edges)n.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 m=e.edges.find(w=>w.id===d.id);m&&((m.sourceNodeId!==d.sourceNodeId||m.targetNodeId!==d.targetNodeId)&&r.push({type:"edge-rerouted",elementId:d.id,elementType:"edge",previousValue:{source:m.sourceNodeId,target:m.targetNodeId},newValue:{source:d.sourceNodeId,target:d.targetNodeId},description:"Edge rerouted"}),JSON.stringify(m.style)!==JSON.stringify(d.style)&&r.push({type:"edge-restyled",elementId:d.id,elementType:"edge",previousValue:m.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 zn(){return`v_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}function Nn(o){const e=new Tr(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 An{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:_n(),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(n=>this.notifyMention(a,n.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:Dn(),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(n=>this.notifyMention(r,n.userId)),a}editReply(e,t,r){const i=this.comments.get(e);if(!i)return null;const a=i.replies.find(n=>n.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(n=>n.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 n=i[1],c=(a=this.config.availableUsers)==null?void 0:a.find(l=>l.name.toLowerCase()===n.toLowerCase()||l.id===n);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 _n(){return`comment_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}function Dn(){return`reply_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}const jn={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 Tn(o){const e=new Date(o),r=new Date().getTime()-e.getTime(),i=Math.floor(r/(1e3*60)),a=Math.floor(i/60),n=Math.floor(a/24);return i<1?"just now":i<60?`${i}m ago`:a<24?`${a}h ago`:n<7?`${n}d ago`:e.toLocaleDateString()}function $n(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),n=r.slice(i.endIndex);r=`${a}<span class="mention" data-user-id="${i.userId}">@${i.userName}</span>${n}`}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(n=>n.id===e);a&&(Object.assign(a,t),i.rules.sort((n,c)=>n.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))),n=this.processRules(e.id,a,e);return this.cache.set(t,n),n}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")),n=this.processRules(e.id,a,e);return this.cache.set(t,n),n}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:n}=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=n&&typeof e=="string"?e.toLowerCase():e,l=n&&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=n?"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 Lt=[{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 Pn(o){const e=Lt.find(t=>t.id===o);return e?{...e,id:`${e.id}_${Date.now()}`}:null}function Rn(o=!1){const e=new $r;if(o)for(const t of Lt)e.addRule(t);return e}class En{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:n=!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 m=[],w=a?e:e.toLowerCase();if(r==="all"||r==="nodes"||r==="labels")for(const p of this.nodes){if(m.length>=l)break;if(u.length>0&&!u.includes(p.shape)||d.length>0&&p.groupId&&!d.includes(p.groupId))continue;const h=this.matchElement(p,w,i,a,n,c);h&&m.push({id:p.id,type:"node",label:p.label||p.id,element:p,matchText:h.text,matchProperty:h.property,matchPositions:h.positions,score:h.score})}if(r==="all"||r==="edges"||r==="labels")for(const p of this.edges){if(m.length>=l)break;const h=this.matchElement(p,w,i,a,n,c);h&&m.push({id:p.id,type:"edge",label:p.label||`${p.sourceNodeId} → ${p.targetNodeId}`,element:p,matchText:h.text,matchProperty:h.property,matchPositions:h.positions,score:h.score})}if(r==="all"||r==="groups")for(const p of this.groups){if(m.length>=l)break;if(d.length>0&&!d.includes(p.id))continue;const h=this.matchElement(p,w,i,a,n,c);h&&m.push({id:p.id,type:"group",label:p.label||p.id,element:p,matchText:h.text,matchProperty:h.property,matchPositions:h.positions,score:h.score})}return m.sort((p,h)=>h.score-p.score),this.state={...this.state,query:e,results:m,selectedIndex:m.length>0?0:-1,isActive:!0,totalCount:m.length},this.notify(),m}matchElement(e,t,r,i,a,n){let c=null;const l=(d,m,w,p)=>{(!c||p>c.score)&&(c={text:d,property:m,positions:w,score:p})},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,n);for(const m of d)l(m.text,`data.${m.property}`,m.positions,50+m.positions.length*10)}return c}matchText(e,t,r,i){const a=i?e:e.toLowerCase(),n=i?t:t.toLowerCase(),c=[];switch(r){case"exact":a===n&&c.push({start:0,end:e.length});break;case"starts_with":a.startsWith(n)&&c.push({start:0,end:t.length});break;case"ends_with":a.endsWith(n)&&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(n,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,n=""){const c=[];for(const[l,u]of Object.entries(e)){const d=n?`${n}.${l}`:l;if(!(a.length>0&&!a.some(m=>d.startsWith(m))))if(typeof u=="string"){const m=this.matchText(u,t,r,i);m&&c.push({text:u,property:d,positions:m.positions})}else if(typeof u=="number"||typeof u=="boolean"){const m=String(u),w=this.matchText(m,t,r,i);w&&c.push({text:m,property:d,positions:w.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 On(o,e,t="search-highlight"){if(e.length===0)return o;const r=[...e].sort((a,n)=>n.start-a.start);let i=o;for(const a of r){const n=i.slice(0,a.start),c=i.slice(a.start,a.end),l=i.slice(a.end);i=`${n}<span class="${t}">${c}</span>${l}`}return i}function Fn(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=mr;exports.AnimationTimeline=xt;exports.COMMENT_PRIORITY_STYLES=jn;exports.ConditionalStylingEngine=$r;exports.DIAGRAM_STYLE_PRESETS=wt;exports.DIAGRAM_TEMPLATES=Ct;exports.DiagramCanvas=Be;exports.DiagramCellRenderer=Qi;exports.DiagramCommentManager=An;exports.DiagramMinimap=ut;exports.DiagramModel=bt;exports.DiagramParticleEngine=tr;exports.DiagramPropertyPanel=vt;exports.DiagramSearchFilterEngine=En;exports.DiagramToolbar=kt;exports.DiagramVersioningManager=Tr;exports.EDGE_STYLE_CATALOG=ri;exports.NODE_STYLE_CATALOG=ti;exports.NiceAnimationTimeline=xt;exports.NiceDatabaseSchemaViewer=ba;exports.NiceDecisionTreeEditor=sn;exports.NiceDependencyGraph=Fa;exports.NiceDiagram=Et;exports.NiceDiagramCanvas=Be;exports.NiceDiagramEditor=hr;exports.NiceDiagramMinimap=ut;exports.NiceDiagramPropertyPanel=vt;exports.NiceDiagramToolbar=kt;exports.NiceDiagramViewer=Et;exports.NiceI18nProvider=Dt;exports.NiceNetworkTopology=Ja;exports.NiceOrgChartVisualizer=za;exports.NiceProcessMiningDiagram=ja;exports.NiceWorkflowDesigner=Ir;exports.NiceWorkflowVisualizer=fa;exports.PRESET_RULES=Lt;exports.TRANSITION_PRESETS=dr;exports.analyzeDependencyGraph=Ua;exports.calculateNetworkHealth=on;exports.calculateOrgStats=Da;exports.computeGlowRadius=or;exports.computeLayout=jt;exports.convertAnimation=xr;exports.convertEdge=br;exports.convertGroup=wr;exports.convertNode=yr;exports.createConditionalStylingEngine=Rn;exports.createDecisionTree=gn;exports.createDiagramDocument=et;exports.createGlowFilterId=rr;exports.createLinearWorkflow=ga;exports.createOrgChartFromEmployees=_a;exports.createPresetFromTheme=ni;exports.createQuickFilter=Fn;exports.createRuleFromPreset=Pn;exports.createVersioningHook=Nn;exports.diagramBounds=Pt;exports.discoverNetworkTopology=rn;exports.exportToMermaid=ir;exports.exportToSvg=At;exports.fetchAndGenerateDiagram=ea;exports.fitViewport=Rt;exports.formatCommentDate=Tn;exports.generateDiagramFromData=Cr;exports.getDiagramStylePreset=oi;exports.getDiagramStylePresetsByCategory=ii;exports.getEasing=pr;exports.getPointOnPath=Xr;exports.getTemplateById=Sn;exports.getTemplatesByCategory=Mn;exports.highlightMatches=On;exports.mineProcessFromLog=zr;exports.parseBPMNToWorkflow=pa;exports.parseNddJson=Kr;exports.parsePackageJsonToDependencies=Ha;exports.parseSQLToSchema=Ca;exports.parseSklearnTree=pn;exports.predictWithTree=mn;exports.presetToThemeOverrides=ai;exports.renderTextWithMentions=$n;exports.schemaToSQL=Sa;exports.searchTemplates=In;exports.stringifyNddJson=sr;exports.useDiagramEditor=cr;exports.useNiceTranslation=qe;
6
+ `)}const Wa={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)"},yt=["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)"],Ba={employees:[]},Va=({data:r=Ba,rootEmployeeId:e,onEmployeeClick:t,onDepartmentClick:o,showAvatars:i=!0,showContactInfo:a=!1,groupByDepartment:n=!0,collapsedDepartments:l=[],maxLevels:c=0,orientation:u="vertical",spacing:d={horizontal:200,vertical:150},statusColors:p=Wa,showMinimap:b=!0,className:g,style:h})=>{const{t:w}=Be(),[z,y]=m.useState(null),_=m.useMemo(()=>{var L;if(e)return e;const q=r.employees.find(M=>!M.managerId);return(q==null?void 0:q.id)||((L=r.employees[0])==null?void 0:L.id)},[r.employees,e]),O=m.useMemo(()=>qa(r.employees,_),[r.employees,_]),k=m.useMemo(()=>{const q=Ga(O,u,d,c),L=[],M={};n&&r.departments&&r.departments.forEach((N,T)=>{const F=N.color||yt[T%yt.length];M[N.id]=F;const U=r.employees.filter(R=>R.department===N.id);U.length!==0&&L.push({id:`dept-${N.id}`,label:N.name,nodeIds:U.map(R=>R.id),style:{fill:`${F}15`,stroke:F,strokeWidth:2},data:{department:N}})});const W=[],V=[],G=(N,T=0)=>{if(c>0&&T>=c||N.employee.department&&l.includes(N.employee.department))return;const F=q[N.employee.id]||{x:0,y:0},U=z===N.employee.id,R=N.employee.status||"active",K=N.employee.department?M[N.employee.department]:"var(--nice-text-secondary, #6b7280)",J=180,ee=a?120:i?90:70;W.push({id:N.employee.id,label:N.employee.name,x:F.x,y:F.y,width:J,height:ee,shape:"rectangle",style:{fill:U?K:"var(--nice-bg, #fff)",stroke:K,strokeWidth:U?3:1,fontColor:U?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:13,borderRadius:12},data:{type:"employee",employee:N.employee,statusColor:p[R],hasChildren:N.children.length>0,childrenCount:N.children.length}}),N.employee.managerId&&V.push({id:`rel-${N.employee.managerId}-${N.employee.id}`,source:N.employee.managerId,target:N.employee.id,style:{stroke:"var(--nice-border, #cbd5e1)",strokeWidth:2,arrowHead:"none",lineType:u==="vertical"?"orthogonal":"curved"}}),N.children.forEach(ce=>G(ce,T+1))};return O&&G(O),rt({id:"org-chart",title:w("orgChartVisualizer.organizationChart","Organization Chart"),diagramType:"orgchart",nodes:W,edges:V,groups:L,metadata:{type:"org-chart",...r.metadata}})},[r,O,u,d,c,n,l,i,a,p,z,w]),[P,D]=m.useState({x:0,y:0,zoom:1}),v=m.useCallback(q=>{if(q&&(y(L=>L===q?null:q),t)){const L=r.employees.find(M=>M.id===q);L&&t(L)}},[r.employees,t]),X=m.useCallback(q=>{var M;const L=(M=r.departments)==null?void 0:M.find(W=>`dept-${W.id}`===q);L&&(o==null||o(L))},[r.departments,o]);return s.jsx("div",{className:`nice-org-chart-visualizer ${g||""}`,style:{position:"relative",width:"100%",height:"100%",...h},children:s.jsx(Fe,{nodes:k.nodes,edges:k.edges,groups:k.groups,viewport:P,onViewportChange:D,onSelectElement:v,onGroupClick:o?X:void 0,showGrid:!1})})};function qa(r,e){const o=new Map(r.map(a=>[a.id,a])).get(e);if(!o)return null;const i=(a,n)=>{const l=r.filter(c=>c.managerId===a.id);return{employee:a,children:l.map(c=>i(c,n+1)),level:n}};return i(o,0)}function Ga(r,e,t,o){const i={};if(!r)return i;const a=(c,u)=>o>0&&u>=o?0:c.children.length===0?1:c.children.reduce((d,p)=>d+a(p,u+1),0),n=(c,u,d,p)=>{if(o>0&&u>=o)return;const b=d+p*t.horizontal/2,g=u*t.vertical+50;i[c.employee.id]=e==="vertical"?{x:b,y:g}:{x:g,y:b};let h=d;c.children.forEach(w=>{const z=a(w,u+1);n(w,u+1,h,z),h+=z*t.horizontal})},l=a(r,0);return n(r,0,0,l),i}function Ya(r){const t=[...new Set(r.map(o=>o.department).filter(Boolean))].map((o,i)=>({id:o,name:o,color:yt[i%yt.length],headcount:r.filter(a=>a.department===o).length}));return{employees:r,departments:t}}function Ha(r){var l;const e=new Set(r.employees.map(c=>c.managerId).filter(Boolean)),t=(c,u=new Set)=>{if(u.has(c))return 0;u.add(c);const d=r.employees.find(p=>p.id===c);return d!=null&&d.managerId?1+t(d.managerId,u):1},o=r.employees.map(c=>t(c.id)),i=Math.max(...o,0),a=Array.from(e).map(c=>r.employees.filter(u=>u.managerId===c).length),n=a.length>0?a.reduce((c,u)=>c+u,0)/a.length:0;return{totalEmployees:r.employees.length,departmentCount:((l=r.departments)==null?void 0:l.length)||0,maxDepth:i,averageSpan:Math.round(n*10)/10,managers:e.size}}const Ua=({data:r,onActivityClick:e,onTransitionClick:t,minEdgeFrequency:o=.05,showFrequency:i=!0,showDuration:a=!0,highlightBottlenecks:n=!0,bottleneckThreshold:l=.9,colorScheme:c="frequency",activityColors:u,layout:d="hierarchical",animationSpeed:p=0,showMinimap:b=!0,className:g,style:h})=>{const{t:w}=Be(),[z,y]=m.useState(null),_=m.useMemo(()=>"activities"in r?r:Pr(r),[r]),O=m.useMemo(()=>{if(!n)return new Set;const q=_.activities.filter(M=>M.avgDuration!==void 0).map(M=>M.avgDuration);if(q.length===0)return new Set;q.sort((M,W)=>M-W);const L=q[Math.floor(q.length*l)]||0;return new Set(_.activities.filter(M=>(M.avgDuration||0)>=L).map(M=>M.name))},[_.activities,n,l]),k=m.useMemo(()=>{const q=Math.max(..._.activities.map(N=>N.frequency),1),L=Xa(_,d),M=_.transitions.filter(N=>N.frequency/_.totalCases>=o),W=_.activities.map(N=>{const T=L[N.name]||{x:0,y:0},F=_.startActivities.includes(N.name),U=_.endActivities.includes(N.name),R=O.has(N.name),K=z===N.name,J=Za(N,c,q,u,R);return{id:N.name,label:N.name,x:T.x,y:T.y,width:140,height:60,shape:F?"ellipse":U?"roundedRect":"rectangle",style:{fill:K?J:"var(--nice-bg, #fff)",stroke:J,strokeWidth:R?4:K?3:2,fontColor:K?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:12,borderRadius:U?20:8},data:{type:"activity",activity:N,isStart:F,isEnd:U,isBottleneck:R,frequencyPercent:Math.round(N.frequency/_.totalCases*100)}}}),V=M.map(N=>{const T=_.transitions.indexOf(N),F=N.probability||N.frequency/_.totalCases,U=F>.5,R=[];return i&&R.push(`${N.frequency}x`),a&&N.avgDuration&&R.push(Ja(N.avgDuration)),{id:`trans-${T}`,source:N.from,target:N.to,label:R.join(" | "),style:{stroke:U?"var(--nice-primary, #3b82f6)":"var(--nice-text-muted, #9ca3af)",strokeWidth:Math.max(1,Math.min(6,F*8)),arrowHead:"triangle",lineType:"curved",opacity:Math.max(.3,F)},data:{type:"transition",transition:N,probability:F}}}),G=p>0?Qa(_,p):[];return rt({id:"process-mining",title:w("processMiningDiagram.processMiningDiagram","Process Mining Diagram"),diagramType:"flowchart",nodes:W,edges:V,animations:G,metadata:{type:"process-mining",totalCases:_.totalCases,avgCaseDuration:_.avgCaseDuration}})},[_,o,i,a,O,c,u,d,p,z,w]),P=m.useCallback(q=>{if(!t)return;const L=parseInt(q.replace("trans-",""),10),M=_.transitions[L];M&&t(M)},[_.transitions,t]),[D,v]=m.useState({x:0,y:0,zoom:1}),X=m.useCallback(q=>{if(q){if(q.startsWith("trans-")){P(q);return}if(y(L=>L===q?null:q),e){const L=_.activities.find(M=>M.name===q);L&&e(L)}}},[_.activities,e,P]);return s.jsx("div",{className:`nice-process-mining-diagram ${g||""}`,style:{position:"relative",width:"100%",height:"100%",...h},children:s.jsx(Fe,{nodes:k.nodes,edges:k.edges,groups:k.groups,viewport:D,onViewportChange:v,onSelectElement:X,showGrid:!0})})};function Xa(r,e){const t={};if(e==="circular"){const o=r.activities;o.forEach((i,a)=>{const n=a/o.length*2*Math.PI-Math.PI/2,l=200+o.length*15;t[i.name]={x:Math.cos(n)*l+400,y:Math.sin(n)*l+300}})}else{const o=Ka(r),i={};r.activities.forEach(n=>{const l=o[n.name]||0;i[l]=(i[l]||0)+1});const a={};r.activities.forEach(n=>{const l=o[n.name]||0,c=a[l]||0;a[l]=c+1;const u=i[l],d=(c-(u-1)/2)*180;t[n.name]={x:400+d,y:50+l*120}})}return t}function Ka(r){const e={},t=new Set,o=r.startActivities.map(i=>({activity:i,level:0}));for(;o.length>0;){const{activity:i,level:a}=o.shift();if(t.has(i))continue;t.add(i),e[i]=a,r.transitions.filter(l=>l.from===i).forEach(l=>{t.has(l.to)||o.push({activity:l.to,level:a+1})})}return r.activities.forEach(i=>{e[i.name]===void 0&&(e[i.name]=0)}),e}function Za(r,e,t,o,i){if(i)return"var(--nice-danger, #ef4444)";if(o!=null&&o[r.name])return o[r.name];const a=r.frequency/t;switch(e){case"frequency":return Dt("var(--nice-success, #10b981)","var(--nice-primary, #3b82f6)",a);case"duration":return r.avgDuration?Dt("var(--nice-success, #10b981)","var(--nice-warning, #f59e0b)",a):"var(--nice-text-secondary, #6b7280)";case"cost":return r.avgCost?Dt("var(--nice-success, #10b981)","var(--nice-danger, #ef4444)",a):"var(--nice-text-secondary, #6b7280)";default:return"var(--nice-primary, #3b82f6)"}}function Dt(r,e,t){const o=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=o(r),a=o(e),n=Math.round(i.r+(a.r-i.r)*t),l=Math.round(i.g+(a.g-i.g)*t),c=Math.round(i.b+(a.b-i.b)*t);return`#${[n,l,c].map(u=>u.toString(16).padStart(2,"0")).join("")}`}function Ja(r){return r<1e3?`${r}ms`:r<6e4?`${(r/1e3).toFixed(1)}s`:r<36e5?`${(r/6e4).toFixed(1)}m`:r<864e5?`${(r/36e5).toFixed(1)}h`:`${(r/864e5).toFixed(1)}d`}function Qa(r,e){var o;const t=(o=r.variants)==null?void 0:o[0];return t?t.activities.map((i,a)=>({id:`flow-${a}`,type:"highlight",targets:[i],duration:e,delay:a*e})):[]}function Pr(r){const e=r.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,w)=>h.timestamp.getTime()-w.timestamp.getTime())});const o=new Map,i=new Map,a=new Set,n=new Set;t.forEach(g=>{if(g.length!==0){a.add(g[0].activity),n.add(g[g.length-1].activity);for(let h=0;h<g.length;h++){const w=g[h];o.has(w.activity)||o.set(w.activity,{frequency:0,durations:[],resources:new Set,costs:[]});const z=o.get(w.activity);if(z.frequency++,w.resource&&z.resources.add(w.resource),w.cost!==void 0&&z.costs.push(w.cost),h<g.length-1){const y=g[h+1],_=y.timestamp.getTime()-w.timestamp.getTime();z.durations.push(_);const O=`${w.activity}→${y.activity}`;i.has(O)||i.set(O,{frequency:0,durations:[]});const k=i.get(O);k.frequency++,k.durations.push(_)}}}});const l=Array.from(o.entries()).map(([g,h])=>({name:g,frequency:h.frequency,avgDuration:h.durations.length>0?h.durations.reduce((w,z)=>w+z,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((w,z)=>w+z,0)/h.costs.length:void 0})),c=Array.from(i.entries()).map(([g,h])=>{const[w,z]=g.split("→");return{from:w,to:z,frequency:h.frequency,avgDuration:h.durations.length>0?h.durations.reduce((y,_)=>y+_,0)/h.durations.length:void 0,probability:h.frequency/t.size}}),u=new Map;t.forEach((g,h)=>{const w=g.map(y=>y.activity).join("→");u.has(w)||u.set(w,{caseIds:[],durations:[]});const z=u.get(w);if(z.caseIds.push(h),g.length>=2){const y=g[g.length-1].timestamp.getTime()-g[0].timestamp.getTime();z.durations.push(y)}});const d=Array.from(u.entries()).map(([g,h])=>({activities:g.split("→"),frequency:h.caseIds.length,avgDuration:h.durations.length>0?h.durations.reduce((w,z)=>w+z,0)/h.durations.length:0,caseIds:h.caseIds})).sort((g,h)=>h.frequency-g.frequency),p=Array.from(t.values()).filter(g=>g.length>=2).map(g=>g[g.length-1].timestamp.getTime()-g[0].timestamp.getTime()),b=p.length>0?p.reduce((g,h)=>g+h,0)/p.length:void 0;return{activities:l,transitions:c,variants:d,startActivities:Array.from(a),endActivities:Array.from(n),totalCases:t.size,avgCaseDuration:b}}const Er={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)"},Rr={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)"},or={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)"}},en={module:"box",package:"folder",microservice:"square",library:"book",api:"plug",database:"database",external:"globe",deprecated:"warning"},tn=({data:r,onNodeClick:e,onEdgeClick:t,visibleTypes:o,visibleEdgeTypes:i,highlightCircular:a=!0,showOnlyIssues:n=!1,layout:l="force",groupBy:c="type",nodeSizeBy:u="dependencies",colorScheme:d="type",nodeColors:p,showMetrics:b=!0,interactive:g=!0,showMinimap:h=!0,className:w,style:z})=>{const{t:y}=Be(),[_,O]=m.useState(null),[k,P]=m.useState(null),D=m.useMemo(()=>a?Or(r):new Set,[r,a]),v=m.useMemo(()=>{let G=r.nodes;return o&&o.length>0&&(G=G.filter(N=>o.includes(N.type))),n&&(G=G.filter(N=>{var T;return N.status==="critical"||N.status==="warning"||((T=N.metrics)==null?void 0:T.issues)&&N.metrics.issues>0})),G},[r.nodes,o,n]),X=m.useMemo(()=>{const G=new Set(v.map(T=>T.id));let N=r.edges.filter(T=>G.has(T.source)&&G.has(T.target));return i&&i.length>0&&(N=N.filter(T=>i.includes(T.type))),N},[r.edges,v,i]),q=m.useMemo(()=>{const G=rn(v,X,l),N=an(v,u),T=[];if(c!=="none"){const R=new Map;v.forEach(J=>{const ee=c==="type"?J.type:J.group||"ungrouped";R.has(ee)||R.set(ee,[]),R.get(ee).push(J.id)});let K=0;R.forEach((J,ee)=>{var Me,he;const ce=c==="type"?Er[ee]||"var(--nice-text-secondary, #6b7280)":((he=(Me=r.groups)==null?void 0:Me.find(Ae=>Ae.id===ee))==null?void 0:he.color)||bt[K%bt.length];T.push({id:`group-${ee}`,label:ee,nodeIds:J,style:{fill:`${ce}10`,stroke:ce,strokeWidth:1}}),K++})}const F=v.map(R=>{const K=G[R.id]||{x:0,y:0},J=_===R.id,ee=k===R.id,ce=D.has(R.id),Me=nn(R,u,N),he=sn(R,d,p,ce);return{id:R.id,label:R.name,x:K.x,y:K.y,width:Me.width,height:Me.height,shape:ln(R.type),style:{fill:J||ee?he:"var(--nice-bg, #fff)",stroke:he,strokeWidth:ce?4:J?3:2,fontColor:J||ee?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:8,strokeDasharray:R.status==="deprecated"?"4,4":void 0},data:{type:"dependency",node:R,icon:en[R.type],isCircular:ce,statusColor:Rr[R.status||"unknown"]}}}),U=X.map((R,K)=>{const J=R.type==="circular"||D.has(R.source)&&D.has(R.target),ee=or[R.type]||or.import;return{id:R.id||`edge-${K}`,source:R.source,target:R.target,label:R.optional?y("dependencyGraph.optional","(optional)"):void 0,style:{stroke:J?"var(--nice-danger, #ef4444)":ee.color,strokeWidth:Math.max(1,Math.min(4,R.weight||1)),strokeDasharray:ee.dash,arrowHead:"triangle",lineType:"curved",opacity:R.optional?.5:1},data:{type:R.type,edge:R,isCircular:J}}});return rt({id:"dependency-graph",title:y("dependencyGraph.dependencyGraph","Dependency Graph"),diagramType:"custom",nodes:F,edges:U,groups:T,metadata:{type:"dependency-graph",...r.metadata}})},[v,X,l,c,r.groups,u,d,p,D,_,k,r.metadata,y]),L=m.useCallback(G=>{P(G)},[]),[M,W]=m.useState({x:0,y:0,zoom:1}),V=m.useCallback(G=>{if(G){if(O(N=>N===G?null:G),e){const N=r.nodes.find(T=>T.id===G);N&&e(N)}if(t){const N=r.edges.find(T=>T.id===G);N&&t(N)}}},[r.nodes,r.edges,e,t]);return s.jsx("div",{className:`nice-dependency-graph ${w||""}`,style:{position:"relative",width:"100%",height:"100%",...z},children:s.jsx(Fe,{nodes:q.nodes,edges:q.edges,groups:q.groups,viewport:M,onViewportChange:W,onSelectElement:V,onNodeHover:L,interactive:g,showGrid:!0})})},bt=["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 Or(r){const e=new Set,t=new Map;r.nodes.forEach(n=>t.set(n.id,[])),r.edges.forEach(n=>{var l;(l=t.get(n.source))==null||l.push(n.target)});const o=new Set,i=new Set,a=(n,l)=>{o.add(n),i.add(n),l.push(n);const c=t.get(n)||[];for(const u of c)if(o.has(u)){if(i.has(u)){const d=l.indexOf(u);l.slice(d).forEach(b=>e.add(b))}}else if(a(u,[...l]))return!0;return i.delete(n),!1};return r.nodes.forEach(n=>{o.has(n.id)||a(n.id,[])}),e}function rn(r,e,t){const o={};switch(t){case"circular":{r.forEach((i,a)=>{const n=a/r.length*2*Math.PI-Math.PI/2,l=150+r.length*12;o[i.id]={x:Math.cos(n)*l+400,y:Math.sin(n)*l+300}});break}case"grid":{const i=Math.ceil(Math.sqrt(r.length));r.forEach((a,n)=>{o[a.id]={x:n%i*200+100,y:Math.floor(n/i)*150+100}});break}case"hierarchical":{const i=on(r,e),a={},n={};r.forEach(l=>{const c=i[l.id]||0;a[c]=(a[c]||0)+1}),r.forEach(l=>{const c=i[l.id]||0,u=n[c]||0;n[c]=u+1;const d=a[c],p=(u-(d-1)/2)*200;o[l.id]={x:400+p,y:80+c*130}});break}default:{r.forEach((i,a)=>{const n=a/r.length*2*Math.PI,l=200+r.length*10;o[i.id]={x:Math.cos(n)*l+400,y:Math.sin(n)*l+300}});for(let i=0;i<50;i++){const a={};r.forEach(n=>a[n.id]={x:0,y:0});for(let n=0;n<r.length;n++)for(let l=n+1;l<r.length;l++){const c=r[n].id,u=r[l].id,d=o[u].x-o[c].x,p=o[u].y-o[c].y,b=Math.max(1,Math.sqrt(d*d+p*p)),g=5e3/(b*b);a[c].x-=d/b*g,a[c].y-=p/b*g,a[u].x+=d/b*g,a[u].y+=p/b*g}e.forEach(n=>{const l=o[n.target].x-o[n.source].x,c=o[n.target].y-o[n.source].y,u=Math.sqrt(l*l+c*c),d=u*.01;a[n.source].x+=l/u*d,a[n.source].y+=c/u*d,a[n.target].x-=l/u*d,a[n.target].y-=c/u*d}),r.forEach(n=>{o[n.id].x+=Math.max(-10,Math.min(10,a[n.id].x)),o[n.id].y+=Math.max(-10,Math.min(10,a[n.id].y))})}break}}return o}function on(r,e){const t={},o={};r.forEach(a=>{t[a.id]=0,o[a.id]=0}),e.forEach(a=>{o[a.target]=(o[a.target]||0)+1});const i=r.filter(a=>o[a.id]===0).map(a=>a.id);for(;i.length>0;){const a=i.shift();e.filter(l=>l.source===a).forEach(l=>{t[l.target]=Math.max(t[l.target],t[a]+1),o[l.target]--,o[l.target]===0&&i.push(l.target)})}return t}function an(r,e){const t=r.map(o=>{var i,a,n;switch(e){case"dependencies":return((i=o.metrics)==null?void 0:i.dependencies)||0;case"dependents":return((a=o.metrics)==null?void 0:a.dependents)||0;case"complexity":return((n=o.metrics)==null?void 0:n.complexity)||0;case"size":return o.size||0;default:return 1}});return{min:Math.min(...t,0),max:Math.max(...t,1)}}function nn(r,e,t){var c,u,d;if(e==="fixed")return{width:140,height:70};let o;switch(e){case"dependencies":o=((c=r.metrics)==null?void 0:c.dependencies)||0;break;case"dependents":o=((u=r.metrics)==null?void 0:u.dependents)||0;break;case"complexity":o=((d=r.metrics)==null?void 0:d.complexity)||0;break;case"size":o=r.size||0;break;default:o=1}const i=t.max>t.min?(o-t.min)/(t.max-t.min):.5,a=100,l=a+i*(180-a);return{width:l,height:l*.5}}function sn(r,e,t,o){if(o)return"var(--nice-danger, #ef4444)";if(t!=null&&t[r.id])return t[r.id];switch(e){case"status":return Rr[r.status||"unknown"];case"group":return bt[cn(r.group||"")%bt.length];default:return Er[r.type]||"var(--nice-text-secondary, #6b7280)"}}function ln(r){switch(r){case"database":return"cylinder";case"microservice":return"hexagon";case"api":return"diamond";case"external":return"cloud";default:return"rectangle"}}function cn(r){let e=0;for(let t=0;t<r.length;t++)e=(e<<5)-e+r.charCodeAt(t),e|=0;return Math.abs(e)}function dn(r){const e=[{id:r.name,name:r.name,version:r.version,type:"package",status:"healthy"}],t=[];let o=0;const i=(a,n)=>{a&&Object.entries(a).forEach(([l,c])=>{e.find(u=>u.id===l)||e.push({id:l,name:l,version:c.replace(/[\^~>=<]/g,""),type:"library",status:"unknown"}),t.push({id:`edge-${o++}`,source:r.name,target:l,type:n})})};return i(r.dependencies,"runtime"),i(r.devDependencies,"dev"),i(r.peerDependencies,"peer"),e.forEach(a=>{a.metrics={dependencies:t.filter(n=>n.source===a.id).length,dependents:t.filter(n=>n.target===a.id).length}}),{nodes:e,edges:t}}function un(r){const e=new Map,t=new Map;r.nodes.forEach(d=>{e.set(d.id,0),t.set(d.id,0)}),r.edges.forEach(d=>{e.set(d.target,(e.get(d.target)||0)+1),t.set(d.source,(t.get(d.source)||0)+1)}),Or(r);let o=null,i=0;r.nodes.forEach(d=>{const p=e.get(d.id)||0;p>i&&(i=p,o=d)});let a=null,n=0;r.nodes.forEach(d=>{const p=t.get(d.id)||0;p>n&&(n=p,a=d)});const l=r.nodes.filter(d=>(e.get(d.id)||0)===0&&(t.get(d.id)||0)===0),c=Array.from(t.values()).reduce((d,p)=>d+p,0),u=r.nodes.length>0?c/r.nodes.length:0;return{totalNodes:r.nodes.length,totalEdges:r.edges.length,circularDependencies:[],mostDependent:o,mostDependencies:a,orphanNodes:l,avgDependencies:Math.round(u*10)/10}}const fn={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)"},hn={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"},pn={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)"},gn=({data:r,onDeviceClick:e,onConnectionClick:t,onRefresh:o,autoRefreshInterval:i=0,visibleDeviceTypes:a,showOnlyIssues:n=!1,layout:l="hierarchical",groupBy:c="group",showMetrics:u=!0,showBandwidth:d=!0,showLatency:p=!1,animateTraffic:b=!1,statusColors:g=fn,showMinimap:h=!0,className:w,style:z})=>{const{t:y}=Be(),[_,O]=m.useState(null),[k,P]=m.useState(new Date);m.useEffect(()=>{if(i<=0||!o)return;const W=setInterval(()=>{o(),P(new Date)},i);return()=>clearInterval(W)},[i,o]);const D=m.useMemo(()=>{let W=r.devices;return a&&a.length>0&&(W=W.filter(V=>a.includes(V.type))),n&&(W=W.filter(V=>V.status==="critical"||V.status==="warning"||V.status==="offline")),W},[r.devices,a,n]),v=m.useMemo(()=>{const W=new Set(D.map(V=>V.id));return r.connections.filter(V=>W.has(V.source)&&W.has(V.target))},[r.connections,D]),X=m.useMemo(()=>{const W=mn(D,v,l,r.groups),V=[];if(c!=="none"){const F=new Map;D.forEach(R=>{let K;switch(c){case"type":K=R.type;break;case"location":K=R.location||"Unknown Location";break;default:K=R.group||"ungrouped"}F.has(K)||F.set(K,[]),F.get(K).push(R.id)});let U=0;F.forEach((R,K)=>{var ce;const J=(ce=r.groups)==null?void 0:ce.find(Me=>Me.id===K||Me.name===K),ee=(J==null?void 0:J.color)||ir[U%ir.length];V.push({id:`group-${K}`,label:(J==null?void 0:J.name)||K,nodeIds:R,style:{fill:`${ee}15`,stroke:ee,strokeWidth:2}}),U++})}const G=D.map(F=>{const U=W[F.id]||{x:0,y:0},R=_===F.id,K=g[F.status],J=hn[F.type];return{id:F.id,label:F.name,x:U.x,y:U.y,width:120,height:u?90:70,shape:yn(F.type),style:{fill:R?K:"var(--nice-bg, #fff)",stroke:K,strokeWidth:R?3:2,fontColor:R?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:8},data:{type:"network-device",device:F,icon:J,statusColor:K}}}),N=v.map((F,U)=>{const R=pn[F.type]||"var(--nice-text-secondary, #6b7280)",K=F.status==="active",J=F.status==="degraded"||F.status==="error",ee=[];if(d&&F.bandwidth){const ce=Math.round(F.bandwidth.used/F.bandwidth.total*100);ee.push(`${ce}%`)}return p&&F.latency!==void 0&&ee.push(`${F.latency}ms`),{id:F.id||`conn-${U}`,source:F.source,target:F.target,sourcePort:F.sourcePort,targetPort:F.targetPort,label:ee.join(" | ")||void 0,style:{stroke:J?"var(--nice-danger, #ef4444)":R,strokeWidth:Math.max(1,Math.min(6,(F.speed||1e3)/1e3)),strokeDasharray:K?void 0:"5,5",arrowHead:"none",lineType:F.type==="wireless"?"curved":"orthogonal",opacity:F.status==="inactive"?.3:1},data:{type:F.type,connection:F,isActive:K,isDegraded:J}}}),T=b?bn(v):[];return rt({id:"network-topology",title:y("networkTopology.networkTopology","Network Topology"),diagramType:"networkTopology",nodes:G,edges:N,groups:V,animations:T,metadata:{type:"network-topology",lastRefresh:k.toISOString(),...r.metadata}})},[D,v,l,c,r.groups,u,d,p,b,g,_,k,r.metadata,y]),[q,L]=m.useState({x:0,y:0,zoom:1}),M=m.useCallback(W=>{if(!W)return;const V=r.connections.find(G=>G.id===W);if(V){t==null||t(V);return}if(O(G=>G===W?null:W),e){const G=r.devices.find(N=>N.id===W);G&&e(G)}},[r.devices,r.connections,e,t]);return s.jsx("div",{className:`nice-network-topology ${w||""}`,style:{position:"relative",width:"100%",height:"100%",...z},children:s.jsx(Fe,{nodes:X.nodes,edges:X.edges,groups:X.groups,viewport:q,onViewportChange:L,onSelectElement:M,showGrid:!0})})},ir=["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 mn(r,e,t,o){var a;const i={};switch(t){case"star":{const n=new Map;r.forEach(d=>n.set(d.id,0)),e.forEach(d=>{n.set(d.source,(n.get(d.source)||0)+1),n.set(d.target,(n.get(d.target)||0)+1)});let l=(a=r[0])==null?void 0:a.id,c=0;n.forEach((d,p)=>{d>c&&(c=d,l=p)}),i[l]={x:400,y:300};const u=r.filter(d=>d.id!==l);u.forEach((d,p)=>{const b=p/u.length*2*Math.PI-Math.PI/2,g=200;i[d.id]={x:Math.cos(b)*g+400,y:Math.sin(b)*g+300}});break}case"mesh":{const n=Math.ceil(Math.sqrt(r.length));r.forEach((l,c)=>{i[l.id]={x:c%n*150+100,y:Math.floor(c/n)*130+100}});break}case"tree":{const n=r.filter(b=>b.type==="internet"||b.type==="cloud"||b.type==="router"),l=new Map,c=n.map(b=>b.id);c.forEach(b=>l.set(b,0));const u=new Set(c);for(;c.length>0;){const b=c.shift(),g=l.get(b)||0;e.forEach(h=>{let w=null;h.source===b&&!u.has(h.target)&&(w=h.target),h.target===b&&!u.has(h.source)&&(w=h.source),w&&(u.add(w),l.set(w,g+1),c.push(w))})}const d={},p={};r.forEach(b=>{const g=l.get(b.id)||0;d[g]=(d[g]||0)+1}),r.forEach(b=>{const g=l.get(b.id)||0,h=p[g]||0;p[g]=h+1;const w=d[g],z=(h-(w-1)/2)*160;i[b.id]={x:400+z,y:80+g*120}});break}case"hierarchical":default:{const n=["internet","cloud","router","firewall","loadbalancer","switch","server","storage","workstation","laptop","phone","printer","camera","iot","unknown"],l=new Map;r.forEach(u=>{l.has(u.type)||l.set(u.type,[]),l.get(u.type).push(u)});let c=50;n.forEach(u=>{const d=l.get(u);!d||d.length===0||(d.forEach((p,b)=>{const g=(b-(d.length-1)/2)*150;i[p.id]={x:400+g,y:c}}),c+=130)});break}}return i}function yn(r){switch(r){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 bn(r){return r.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 wn(r={}){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 xn(r){const e=r.devices.filter(p=>p.status==="online").length,t=r.devices.filter(p=>p.status==="offline").length,o=r.devices.filter(p=>p.status==="warning").length,i=r.devices.filter(p=>p.status==="critical").length,a=r.connections.filter(p=>p.status==="active").length,n=r.connections.filter(p=>p.status==="degraded"||p.status==="error").length,l=r.devices.length>0?e/r.devices.length*100:0,c=r.connections.length>0?a/r.connections.length*100:0,u=i*10+o*5+n*5;return{score:Math.max(0,Math.min(100,Math.round(l*.5+c*.5-u))),onlineDevices:e,offlineDevices:t,warningDevices:o,criticalDevices:i,activeConnections:a,degradedConnections:n}}const vn=[{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"}],kn={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)"},Cn=({data:r,onChange:e,onNodeClick:t,editable:o=!1,showMetrics:i=!0,showProbabilities:a=!0,showSamples:n=!0,highlightPath:l,colorScheme:c="outcome",nodeColors:u,orientation:d="vertical",spacing:p={horizontal:180,vertical:120},showMinimap:b=!0,className:g,style:h,tutorial:w})=>{const{t:z}=Be(),[y,_]=m.useState(null),[O,k]=m.useState(new Set),P=m.useMemo(()=>l?Nn(r.root,l):new Set,[r.root,l]),{nodes:D,edges:v}=m.useMemo(()=>Sn(r.root,r.edges),[r.root,r.edges]),X=m.useMemo(()=>In(D),[D]),q=m.useMemo(()=>{var T,F;const V=Mn(r.root,d,p),G=D.map(U=>{const R=V[U.id]||{x:0,y:0},K=y===U.id,J=P.has(U.id),ee=U.type==="leaf"||U.type==="end",ce=zn(U,c,u,X),Me=ee?120:160,he=i?80:ee?60:70;return{id:U.id,label:U.label,x:R.x,y:R.y,width:Me,height:he,shape:ee?"roundedRect":"diamond",style:{fill:K||J?ce:"var(--nice-bg, #fff)",stroke:ce,strokeWidth:J?4:K?3:2,fontColor:K||J?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:ee?8:0},data:{type:"decision-tree-node",node:U,isLeaf:ee,isHighlighted:J}}}),N=v.map((U,R)=>{const K=P.has(U.source)&&P.has(U.target);let J=U.label||"";return a&&U.probability!==void 0&&(J+=J?` (${(U.probability*100).toFixed(0)}%)`:`${(U.probability*100).toFixed(0)}%`),{id:U.id||`edge-${R}`,source:U.source,target:U.target,label:J||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:U,isHighlighted:K}}});return rt({id:"decision-tree",title:z("decisionTreeEditor.decisionTree","Decision Tree"),diagramType:"decisionTree",nodes:G,edges:N,animations:l?An(Array.from(P)):[],metadata:{type:"decision-tree",algorithm:(T=r.metadata)==null?void 0:T.algorithm,accuracy:(F=r.metadata)==null?void 0:F.accuracy}})},[D,v,d,p,i,a,c,u,X,y,P,l,r.metadata,r.root,z]),[L,M]=m.useState({x:0,y:0,zoom:1}),W=m.useCallback(V=>{if(!V)return;_(N=>N===V?null:V);const G=D.find(N=>N.id===V);G&&G.type!=="leaf"&&G.type!=="end"&&k(N=>{const T=new Set(N);return T.has(V)?T.delete(V):T.add(V),T}),t&&G&&t(G)},[D,t]);return s.jsxs("div",{className:`nice-decision-tree-editor ${g||""}`,style:{position:"relative",width:"100%",height:"100%",...h},children:[s.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:s.jsx(C.NiceTutorialButton,{steps:C.resolveTutorial(w,vn)})}),s.jsx(Fe,{nodes:q.nodes,edges:q.edges,groups:q.groups,viewport:L,onViewportChange:M,onSelectElement:W,interactive:!0,showGrid:!1})]})};function Sn(r,e){const t=[],o=e?[...e]:[],i=new Set(o.map(n=>`${n.source}-${n.target}`)),a=(n,l)=>{t.push(n),l&&!i.has(`${l}-${n.id}`)&&o.push({id:`e-${l}-${n.id}`,source:l,target:n.id}),n.children&&n.children.forEach((c,u)=>{let d="";n.condition&&(d=u===0?"Yes":"No");const p=`${n.id}-${c.id}`;i.has(p)||(o.push({id:`e-${p}`,source:n.id,target:c.id,label:d,branch:u===0?"yes":"no"}),i.add(p)),a(c,n.id)})};return a(r),{nodes:t,edges:o}}function Mn(r,e,t){const o={},i=l=>!l.children||l.children.length===0?1:l.children.reduce((c,u)=>c+i(u),0),a=(l,c,u,d)=>{const p=u+d*t.horizontal/2,b=c*t.vertical+50;if(o[l.id]=e==="vertical"?{x:p,y:b}:{x:b,y:p},l.children){let g=u;l.children.forEach(h=>{const w=i(h);a(h,c+1,g,w),g+=w*t.horizontal})}},n=i(r);return a(r,0,0,n),o}function In(r){const e=r.filter(o=>{var i;return((i=o.metrics)==null?void 0:i.impurity)!==void 0}).map(o=>o.metrics.impurity),t=r.filter(o=>{var i;return((i=o.metrics)==null?void 0:i.samples)!==void 0}).map(o=>o.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 zn(r,e,t,o){var i,a,n;if(t!=null&&t[r.id])return t[r.id];switch(e){case"impurity":if(((i=r.metrics)==null?void 0:i.impurity)!==void 0&&o){const l=(r.metrics.impurity-o.impurity.min)/(o.impurity.max-o.impurity.min||1);return ar("var(--nice-success, #10b981)","var(--nice-danger, #ef4444)",l)}break;case"samples":if(((a=r.metrics)==null?void 0:a.samples)!==void 0&&o){const l=(r.metrics.samples-o.samples.min)/(o.samples.max-o.samples.min||1);return ar("var(--nice-warning-bg, #fef3c7)","var(--nice-warning, #f59e0b)",l)}break;case"outcome":if(r.type==="leaf"&&((n=r.outcome)!=null&&n.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)"}[r.outcome.class.toLowerCase()]||"var(--nice-primary, #3b82f6)";break}return kn[r.type]||"var(--nice-text-secondary, #6b7280)"}function ar(r,e,t){const o=u=>{var p;const d=((p=/#([a-f\d]{6})\b/i.exec(u))==null?void 0:p[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=o(r),a=o(e),n=Math.round(i.r+(a.r-i.r)*t),l=Math.round(i.g+(a.g-i.g)*t),c=Math.round(i.b+(a.b-i.b)*t);return`#${[n,l,c].map(u=>u.toString(16).padStart(2,"0")).join("")}`}function Nn(r,e){const t=new Set,o=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],l=Fr(a,i.condition.operator,i.condition.value)?0:1;if(i.children[l])return o(i.children[l])}return i.children[0]?o(i.children[0]):!0};return o(r),t}function Fr(r,e,t){switch(e){case"=":return r===t;case"!=":return r!==t;case"<":return Number(r)<Number(t);case"<=":return Number(r)<=Number(t);case">":return Number(r)>Number(t);case">=":return Number(r)>=Number(t);case"in":return Array.isArray(t)&&t.includes(r);case"not_in":return Array.isArray(t)&&!t.includes(r);case"contains":return String(r).includes(String(t));default:return!1}}function An(r){return r.map((e,t)=>({id:`path-${t}`,type:"highlight",targets:[e],duration:500,delay:t*300}))}function _n(r){const{tree:e,feature_names:t,class_names:o}=r;e.children_left.length;const i=n=>{const l=e.children_left[n]===-1,c=e.n_node_samples[n],u=e.impurity[n],d=e.value[n];if(l){const z=Array.isArray(d)?d:[d],y=Array.isArray(z[0])?z[0]:z,_=y.indexOf(Math.max(...y)),O=(o==null?void 0:o[_])||`Class ${_}`,k=y.reduce((D,v)=>D+v,0),P=k>0?y[_]/k:0;return{id:`node-${n}`,type:"leaf",label:O,outcome:{value:O,class:O,probability:P,samples:c},metrics:{samples:c,impurity:u}}}const p=e.feature[n],b=e.threshold[n],g=t[p]||`feature_${p}`,h=i(e.children_left[n]),w=i(e.children_right[n]);return{id:`node-${n}`,type:n===0?"root":"decision",label:`${g} <= ${b.toFixed(2)}`,condition:{feature:g,operator:"<=",value:b},children:[h,w],metrics:{samples:c,impurity:u,giniIndex:u}}},a=i(0);return{root:a,features:t,classes:o,metadata:{algorithm:"sklearn.DecisionTreeClassifier",maxDepth:Lr(a)}}}function Lr(r,e=0){return!r.children||r.children.length===0?e:Math.max(...r.children.map(t=>Lr(t,e+1)))}function Dn(r){const e=(o,i)=>typeof o=="string"?{id:i,type:"leaf",label:o,outcome:{value:o}}:{...o,id:i};return{root:{id:"root",type:"root",label:r.question,condition:{feature:r.feature,operator:typeof r.threshold=="number"?"<=":"=",value:r.threshold},children:[e(r.yesOutcome,"yes-outcome"),e(r.noOutcome,"no-outcome")]}}}function jn(r,e){const t=[],o=a=>{var n,l;if(t.push(a.id),a.type==="leaf"||a.type==="end"||!a.children)return{value:((n=a.outcome)==null?void 0:n.value)??a.label,probability:(l=a.outcome)==null?void 0:l.probability};if(a.condition){const c=e[a.condition.feature],d=Fr(c,a.condition.operator,a.condition.value)?0:1;if(a.children[d])return o(a.children[d])}return a.children[0]?o(a.children[0]):{value:null}},i=o(r.root);return{prediction:i.value,probability:i.probability,path:t}}let $n=0;function Gt(){return`tmpl-${++$n}-${Date.now().toString(36)}`}function le(r,e,t="roundedRect",o={width:160,height:60},i){return{id:Gt(),label:r,position:e,size:o,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 fe(r,e,t="bottom",o="top",i){return{id:Gt(),sourceNodeId:r.id,sourcePortId:t,targetNodeId:e.id,targetPortId:o,label:i,style:{lineType:"bezier",targetArrow:"arrow"}}}function ct(r,e,t,o){const i=new Date().toISOString();return{version:"1.0",id:Gt(),title:r,diagramType:e,nodes:t,edges:o,groups:[],animations:[],viewport:{x:0,y:0,zoom:1},metadata:{createdAt:i,updatedAt:i}}}function Tn(){const r=le("Commit",{x:40,y:200},"circle",{width:80,height:80}),e=le("Build",{x:200,y:200},"roundedRect"),t=le("Test",{x:420,y:200},"roundedRect"),o=le("Deploy",{x:640,y:200},"roundedRect"),i=le("Production",{x:860,y:200},"hexagon",{width:140,height:80});return ct("CI/CD Pipeline","flowchart",[r,e,t,o,i],[fe(r,e,"right","left"),fe(e,t,"right","left"),fe(t,o,"right","left"),fe(o,i,"right","left")])}function Pn(){const r=le("API Gateway",{x:350,y:40},"hexagon",{width:160,height:80}),e=le("Auth Service",{x:80,y:200},"roundedRect"),t=le("User Service",{x:300,y:200},"roundedRect"),o=le("Order Service",{x:520,y:200},"roundedRect"),i=le("Notification",{x:740,y:200},"roundedRect"),a=le("Users DB",{x:180,y:380},"cylinder",{width:120,height:70}),n=le("Orders DB",{x:520,y:380},"cylinder",{width:120,height:70}),l=le("Message Queue",{x:620,y:380},"parallelogram",{width:160,height:60}),c=[r,e,t,o,i,a,n,l],u=[fe(r,e,"bottom","top"),fe(r,t,"bottom","top"),fe(r,o,"bottom","top"),fe(o,i,"right","left"),fe(t,a,"bottom","top"),fe(o,n,"bottom","top"),fe(i,l,"bottom","top")];return ct("Microservices Architecture","flowchart",c,u)}function En(){const r=le("Start",{x:350,y:20},"circle",{width:70,height:70}),e=le("Landing Page",{x:310,y:140},"roundedRect"),t=le("Sign Up",{x:140,y:280},"roundedRect"),o=le("Log In",{x:480,y:280},"roundedRect"),i=le("Dashboard",{x:310,y:420},"roundedRect"),a=le("End",{x:350,y:560},"circle",{width:70,height:70});return ct("User Flow","flowchart",[r,e,t,o,i,a],[fe(r,e,"bottom","top"),fe(e,t,"bottom","top","New user"),fe(e,o,"bottom","top","Returning"),fe(t,i,"bottom","top"),fe(o,i,"bottom","top"),fe(i,a,"bottom","top")])}function Rn(){const r=le("Users",{x:80,y:100},"rectangle",{width:180,height:100}),e=le("Orders",{x:380,y:100},"rectangle",{width:180,height:100}),t=le("Products",{x:380,y:320},"rectangle",{width:180,height:100}),o=le("Categories",{x:680,y:320},"rectangle",{width:180,height:100});return ct("Entity Relationship","er",[r,e,t,o],[fe(r,e,"right","left","1:N"),fe(e,t,"bottom","top","N:M"),fe(t,o,"right","left","N:1")])}function On(){const r=le("CEO",{x:350,y:40},"roundedRect"),e=le("CTO",{x:150,y:180},"roundedRect"),t=le("CFO",{x:550,y:180},"roundedRect"),o=le("Engineering",{x:50,y:320},"roundedRect"),i=le("DevOps",{x:250,y:320},"roundedRect"),a=le("Accounting",{x:550,y:320},"roundedRect");return ct("Organization Chart","orgchart",[r,e,t,o,i,a],[fe(r,e,"bottom","top"),fe(r,t,"bottom","top"),fe(e,o,"bottom","top"),fe(e,i,"bottom","top"),fe(t,a,"bottom","top")])}function Fn(){const r=le("Idle",{x:80,y:200},"circle",{width:90,height:90}),e=le("Loading",{x:300,y:80},"roundedRect"),t=le("Success",{x:520,y:80},"roundedRect"),o=le("Error",{x:520,y:320},"roundedRect"),i=le("Retry",{x:300,y:320},"diamond",{width:100,height:100});return ct("State Machine","stateMachine",[r,e,t,o,i],[fe(r,e,"right","left","fetch"),fe(e,t,"right","left","ok"),fe(e,o,"bottom","top","fail"),fe(o,i,"left","right"),fe(i,e,"top","bottom","retry"),fe(i,r,"left","right","cancel")])}const It=[{id:"cicd-pipeline",name:"CI/CD Pipeline",description:"Continuous integration and deployment pipeline",category:"software",diagramType:"flowchart",tags:["devops","ci","cd","pipeline","deployment"],create:Tn},{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:En},{id:"er-diagram",name:"Entity Relationship",description:"Database ER diagram with tables and relations",category:"software",diagramType:"er",tags:["database","er","schema","sql"],create:Rn},{id:"org-chart",name:"Organization Chart",description:"Company organizational hierarchy",category:"business",diagramType:"orgchart",tags:["org","hierarchy","team","management"],create:On},{id:"state-machine",name:"State Machine",description:"Finite state machine with transitions",category:"software",diagramType:"stateMachine",tags:["state","fsm","transitions","machine"],create:Fn}];function Ln(r){return It.find(e=>e.id===r)}function Wn(r){return It.filter(e=>e.category===r)}function Bn(r){const e=r.toLowerCase();return It.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.tags.some(o=>o.includes(e)))}class Wr{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 o=this.lastDocument?this.calculateChanges(this.lastDocument,e):[{type:"node-added",description:"Initial version"}],i={id:Vn(),number:this.versions.length+1,timestamp:new Date().toISOString(),userId:this.config.userId,userName:this.config.userName,label:t,snapshot:JSON.stringify(e),changes:o};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 o=JSON.parse(this.versions[t].snapshot);return this.lastDocument=JSON.parse(JSON.stringify(o)),this.notify(),o}diff(e,t){const o=this.getVersion(e),i=this.getVersion(t);if(!o||!i)return null;const a=JSON.parse(o.snapshot),n=JSON.parse(i.snapshot),l=this.calculateChanges(a,n),c={nodesAdded:l.filter(u=>u.type==="node-added").length,nodesRemoved:l.filter(u=>u.type==="node-removed").length,nodesMoved:l.filter(u=>u.type==="node-moved").length,nodesRestyled:l.filter(u=>u.type==="node-restyled").length,edgesAdded:l.filter(u=>u.type==="edge-added").length,edgesRemoved:l.filter(u=>u.type==="edge-removed").length,edgesRestyled:l.filter(u=>u.type==="edge-restyled").length,groupsModified:l.filter(u=>u.type.startsWith("group-")).length,totalChanges:l.length};return{fromVersionId:e,toVersionId:t,changes:l,summary:c}}calculateChanges(e,t){const o=[];e.title!==t.title&&o.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)||o.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)||o.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 p=e.nodes.find(b=>b.id===d.id);p&&((p.position.x!==d.position.x||p.position.y!==d.position.y)&&o.push({type:"node-moved",elementId:d.id,elementType:"node",previousValue:{x:p.position.x,y:p.position.y},newValue:{x:d.position.x,y:d.position.y},description:`Node "${d.label||d.id}" moved`}),(p.size.width!==d.size.width||p.size.height!==d.size.height)&&o.push({type:"node-resized",elementId:d.id,elementType:"node",previousValue:{width:p.size.width,height:p.size.height},newValue:{width:d.size.width,height:d.size.height},description:`Node "${d.label||d.id}" resized`}),p.label!==d.label&&o.push({type:"node-relabeled",elementId:d.id,elementType:"node",previousValue:p.label,newValue:d.label,description:`Node label changed from "${p.label}" to "${d.label}"`}),JSON.stringify(p.style)!==JSON.stringify(d.style)&&o.push({type:"node-restyled",elementId:d.id,elementType:"node",previousValue:p.style,newValue:d.style,description:`Node "${d.label||d.id}" style changed`}))}const n=new Set(e.edges.map(d=>d.id)),l=new Set(t.edges.map(d=>d.id));for(const d of t.edges)n.has(d.id)||o.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)l.has(d.id)||o.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 p=e.edges.find(b=>b.id===d.id);p&&((p.sourceNodeId!==d.sourceNodeId||p.targetNodeId!==d.targetNodeId)&&o.push({type:"edge-rerouted",elementId:d.id,elementType:"edge",previousValue:{source:p.sourceNodeId,target:p.targetNodeId},newValue:{source:d.sourceNodeId,target:d.targetNodeId},description:"Edge rerouted"}),JSON.stringify(p.style)!==JSON.stringify(d.style)&&o.push({type:"edge-restyled",elementId:d.id,elementType:"edge",previousValue:p.style,newValue:d.style,description:"Edge style changed"}))}const c=new Set(e.groups.map(d=>d.id)),u=new Set(t.groups.map(d=>d.id));for(const d of t.groups)c.has(d.id)||o.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)||o.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)&&o.push({type:"viewport-changed",elementType:"document",previousValue:e.viewport,newValue:t.viewport,description:"Viewport changed"}),JSON.stringify(e.theme)!==JSON.stringify(t.theme)&&o.push({type:"theme-changed",elementType:"document",previousValue:e.theme,newValue:t.theme,description:"Theme changed"}),o}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 Vn(){return`v_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}function qn(r){const e=new Wr(r);return{manager:e,saveVersion:e.saveVersion.bind(e),getVersions:e.getVersions.bind(e),restoreToVersion:e.restoreToVersion.bind(e),diff:e.diff.bind(e)}}class Gn{constructor(e){this.comments=new Map,this.listeners=new Set,this.mentionListeners=new Set,this.config=e}addComment(e,t,o){const i=this.parseMentions(t),a={id:Yn(),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:(o==null?void 0:o.style)??this.config.defaultStyle,tags:o==null?void 0:o.tags,priority:o==null?void 0:o.priority};return this.comments.set(a.id,a),this.notify(),i.forEach(n=>this.notifyMention(a,n.userId)),a}updateComment(e,t){const o=this.comments.get(e);return o?(t.text!==void 0&&(o.text=t.text,o.mentions=this.parseMentions(t.text),o.editedAt=new Date().toISOString()),t.style!==void 0&&(o.style=t.style),t.tags!==void 0&&(o.tags=t.tags),t.priority!==void 0&&(o.priority=t.priority),t.anchor!==void 0&&(o.anchor=t.anchor),this.notify(),o):null}deleteComment(e){const t=this.comments.delete(e);return t&&this.notify(),t}resolveComment(e,t="resolved"){const o=this.comments.get(e);return o?(o.status=t,o.resolvedBy=this.config.userId,o.resolvedAt=new Date().toISOString(),this.notify(),o):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 o=this.comments.get(e);if(!o)return null;const i=this.parseMentions(t),a={id:Hn(),authorId:this.config.userId,authorName:this.config.userName,authorAvatar:this.config.userAvatar,text:t,mentions:i,createdAt:new Date().toISOString()};return o.replies.push(a),this.notify(),i.forEach(n=>this.notifyMention(o,n.userId)),a}editReply(e,t,o){const i=this.comments.get(e);if(!i)return null;const a=i.replies.find(n=>n.id===t);return a?(a.text=o,a.mentions=this.parseMentions(o),a.editedAt=new Date().toISOString(),this.notify(),a):null}deleteReply(e,t){const o=this.comments.get(e);if(!o)return!1;const i=o.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 o=t.mentions.some(a=>a.userId===e),i=t.replies.some(a=>a.mentions.some(n=>n.userId===e));return o||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(o=>t.tags.includes(o)))||e.anchorType&&!e.anchorType.includes(t.anchor.type)||e.elementId&&t.anchor.elementId!==e.elementId)return!1;if(e.searchText){const o=e.searchText.toLowerCase();if(![t.text,...t.replies.map(a=>a.text)].join(" ").toLowerCase().includes(o))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=[],o=/@(\w+)/g;let i;for(;(i=o.exec(e))!==null;){const n=i[1],l=(a=this.config.availableUsers)==null?void 0:a.find(c=>c.name.toLowerCase()===n.toLowerCase()||c.id===n);l&&t.push({userId:l.id,userName:l.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(o=>o(e,t))}exportComments(){return JSON.stringify(Array.from(this.comments.values()))}importComments(e){const t=JSON.parse(e);this.comments.clear(),t.forEach(o=>this.comments.set(o.id,o)),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 Yn(){return`comment_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}function Hn(){return`reply_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}const Un={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 Xn(r){const e=new Date(r),o=new Date().getTime()-e.getTime(),i=Math.floor(o/(1e3*60)),a=Math.floor(i/60),n=Math.floor(a/24);return i<1?"just now":i<60?`${i}m ago`:a<24?`${a}h ago`:n<7?`${n}d ago`:e.toLocaleDateString()}function Kn(r,e){if(e.length===0)return r;const t=[...e].sort((i,a)=>a.startIndex-i.startIndex);let o=r;for(const i of t){const a=o.slice(0,i.startIndex),n=o.slice(i.endIndex);o=`${a}<span class="mention" data-user-id="${i.userId}">@${i.userName}</span>${n}`}return o}class Br{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 o=this.profiles.get(t);o&&(o.rules=o.rules.filter(i=>i.id!==e.id),o.rules.push(e),o.rules.sort((i,a)=>i.priority-a.priority),this.invalidateCache(),this.notify())}removeRule(e,t="default"){const o=this.profiles.get(t);o&&(o.rules=o.rules.filter(i=>i.id!==e),this.invalidateCache(),this.notify())}updateRule(e,t,o="default"){const i=this.profiles.get(o);if(!i)return;const a=i.rules.find(n=>n.id===e);a&&(Object.assign(a,t),i.rules.sort((n,l)=>n.priority-l.priority),this.invalidateCache(),this.notify())}toggleRule(e,t,o="default"){this.updateRule(e,{enabled:t},o)}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)}`,o=this.cache.get(t);if(o)return o;const i=this.getActiveProfile();if(!(i!=null&&i.enabled))return this.emptyStyles(e.id);const a=i.rules.filter(l=>l.enabled&&(l.target==="node"||l.target==="both")&&(!l.elementShapes||l.elementShapes.includes(e.shape))),n=this.processRules(e.id,a,e);return this.cache.set(t,n),n}applyToEdge(e){const t=`edge_${e.id}_${JSON.stringify(e.data)}`,o=this.cache.get(t);if(o)return o;const i=this.getActiveProfile();if(!(i!=null&&i.enabled))return this.emptyStyles(e.id);const a=i.rules.filter(l=>l.enabled&&(l.target==="edge"||l.target==="both")),n=this.processRules(e.id,a,e);return this.cache.set(t,n),n}applyToAll(e,t){const o=new Map;for(const i of e)o.set(i.id,this.applyToNode(i));for(const i of t)o.set(i.id,this.applyToEdge(i));return o}processRules(e,t,o){const i={elementId:e,matchedRules:[],styleOverrides:{},addedClasses:[]};for(const a of t)if(this.evaluateCondition(a.condition,o)&&(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 o=this.getPropertyValue(t,e.property);return this.compareValues(o,e)}getPropertyValue(e,t){const o=t.split(".");let i=e;for(const a of o){if(i==null)return;i=i[a]}return i}compareValues(e,t){const{operator:o,value:i,valueTo:a,caseInsensitive:n}=t;if(o==="is_null")return e==null;if(o==="is_not_null")return e!=null;if(o==="is_empty")return e===""||Array.isArray(e)&&e.length===0;if(o==="is_not_empty")return e!==""&&(!Array.isArray(e)||e.length>0);const l=n&&typeof e=="string"?e.toLowerCase():e,c=n&&typeof i=="string"?i.toLowerCase():i;switch(o){case"equals":return l===c;case"not_equals":return l!==c;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 l=="string"&&typeof c=="string"?l.includes(c):Array.isArray(e)?e.includes(i):!1;case"not_contains":return typeof l=="string"&&typeof c=="string"?!l.includes(c):Array.isArray(e)?!e.includes(i):!0;case"starts_with":return typeof l=="string"&&typeof c=="string"&&l.startsWith(c);case"ends_with":return typeof l=="string"&&typeof c=="string"&&l.endsWith(c);case"regex":if(typeof e!="string"||typeof i!="string")return!1;try{const u=n?"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 o of e)switch(o.type){case"set_fill":t.styleOverrides.backgroundColor=o.value;break;case"set_stroke":t.styleOverrides.borderColor=o.value;break;case"set_stroke_width":t.styleOverrides.borderWidth=o.value;break;case"set_text_color":t.styleOverrides.fontColor=o.value;break;case"set_opacity":t.styleOverrides.opacity=o.value;break;case"set_icon":t.icon=o.value;break;case"set_class":t.addedClasses=[o.value];break;case"add_class":t.addedClasses.includes(o.value)||t.addedClasses.push(o.value);break;case"remove_class":t.addedClasses=t.addedClasses.filter(i=>i!==o.value);break;case"set_shadow":t.styleOverrides.shadow=o.value;break;case"set_border_radius":t.styleOverrides.borderRadius=o.value;break;case"set_dash_array":t.styleOverrides.strokeDash=o.value;break;case"set_animation":t.animation=o.value;break;case"set_badge":t.badge=o.value;break;case"set_tooltip":t.tooltip=o.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 o of t.profiles)this.profiles.set(o.id,o);this.activeProfileId=t.activeProfileId,this.invalidateCache(),this.notify()}}const Yt=[{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 Zn(r){const e=Yt.find(t=>t.id===r);return e?{...e,id:`${e.id}_${Date.now()}`}:null}function Jn(r=!1){const e=new Br;if(r)for(const t of Yt)e.addRule(t);return e}class Qn{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,o){this.nodes=e,this.edges=t,this.groups=o,this.state.isActive&&this.state.query&&this.search(this.state.query)}search(e,t={}){const{scope:o="all",matchType:i="contains",caseSensitive:a=!1,searchData:n=!0,dataProperties:l=[],maxResults:c=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 p=[],b=a?e:e.toLowerCase();if(o==="all"||o==="nodes"||o==="labels")for(const g of this.nodes){if(p.length>=c)break;if(u.length>0&&!u.includes(g.shape)||d.length>0&&g.groupId&&!d.includes(g.groupId))continue;const h=this.matchElement(g,b,i,a,n,l);h&&p.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(o==="all"||o==="edges"||o==="labels")for(const g of this.edges){if(p.length>=c)break;const h=this.matchElement(g,b,i,a,n,l);h&&p.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(o==="all"||o==="groups")for(const g of this.groups){if(p.length>=c)break;if(d.length>0&&!d.includes(g.id))continue;const h=this.matchElement(g,b,i,a,n,l);h&&p.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 p.sort((g,h)=>h.score-g.score),this.state={...this.state,query:e,results:p,selectedIndex:p.length>0?0:-1,isActive:!0,totalCount:p.length},this.notify(),p}matchElement(e,t,o,i,a,n){let l=null;const c=(d,p,b,g)=>{(!l||g>l.score)&&(l={text:d,property:p,positions:b,score:g})},u=this.matchText(e.id,t,o,i);if(u&&c(e.id,"id",u.positions,100+u.positions.length*10),"label"in e&&e.label){const d=this.matchText(e.label,t,o,i);d&&c(e.label,"label",d.positions,150+d.positions.length*10)}if("shape"in e&&e.shape){const d=this.matchText(e.shape,t,o,i);d&&c(e.shape,"shape",d.positions,80+d.positions.length*10)}if(a&&"data"in e&&e.data){const d=this.searchInData(e.data,t,o,i,n);for(const p of d)c(p.text,`data.${p.property}`,p.positions,50+p.positions.length*10)}return l}matchText(e,t,o,i){const a=i?e:e.toLowerCase(),n=i?t:t.toLowerCase(),l=[];switch(o){case"exact":a===n&&l.push({start:0,end:e.length});break;case"starts_with":a.startsWith(n)&&l.push({start:0,end:t.length});break;case"ends_with":a.endsWith(n)&&l.push({start:e.length-t.length,end:e.length});break;case"regex":try{const c=i?"g":"gi",u=new RegExp(t,c);let d;for(;(d=u.exec(e))!==null&&(l.push({start:d.index,end:d.index+d[0].length}),!!u.global););}catch{}break;case"contains":default:{let c=0;for(;(c=a.indexOf(n,c))!==-1;)l.push({start:c,end:c+t.length}),c+=t.length;break}}return l.length>0?{positions:l}:null}searchInData(e,t,o,i,a,n=""){const l=[];for(const[c,u]of Object.entries(e)){const d=n?`${n}.${c}`:c;if(!(a.length>0&&!a.some(p=>d.startsWith(p))))if(typeof u=="string"){const p=this.matchText(u,t,o,i);p&&l.push({text:u,property:d,positions:p.positions})}else if(typeof u=="number"||typeof u=="boolean"){const p=String(u),b=this.matchText(p,t,o,i);b&&l.push({text:p,property:d,positions:b.positions})}else u!=null&&typeof u=="object"&&!Array.isArray(u)&&l.push(...this.searchInData(u,t,o,i,a,d))}return l}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)),o=this.edges.filter(a=>this.matchFilters(a,e)),i=this.groups.filter(a=>this.matchFilters(a,e));return this.notify(),{nodes:t,edges:o,groups:i}}matchFilters(e,t){return t.every(o=>this.matchFilter(e,o))}matchFilter(e,t){const o=this.getPropertyValue(e,t.property);switch(t.operator){case"equals":return o===t.value;case"not_equals":return o!==t.value;case"contains":return typeof o=="string"&&typeof t.value=="string"?o.toLowerCase().includes(t.value.toLowerCase()):Array.isArray(o)?o.includes(t.value):!1;case"greater_than":return typeof o=="number"&&o>t.value;case"less_than":return typeof o=="number"&&o<t.value;case"in":return Array.isArray(t.value)&&t.value.includes(o);case"not_in":return!Array.isArray(t.value)||!t.value.includes(o);case"is_null":return o==null;case"is_not_null":return o!=null;default:return!0}}getPropertyValue(e,t){const o=t.split(".");let i=e;for(const a of o){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 o={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(o.id,o),o}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 o=new Set;if(!t||t==="node")for(const i of this.nodes){const a=this.getPropertyValue(i,e);a!=null&&o.add(a)}if(!t||t==="edge")for(const i of this.edges){const a=this.getPropertyValue(i,e);a!=null&&o.add(a)}if(!t||t==="group")for(const i of this.groups){const a=this.getPropertyValue(i,e);a!=null&&o.add(a)}return Array.from(o)}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(o=>this.presets.set(o.id,o))}}function es(r,e,t="search-highlight"){if(e.length===0)return r;const o=[...e].sort((a,n)=>n.start-a.start);let i=r;for(const a of o){const n=i.slice(0,a.start),l=i.slice(a.start,a.end),c=i.slice(a.end);i=`${n}<span class="${t}">${l}</span>${c}`}return i}function ts(r,e){switch(r){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=Sr;exports.AnimationTimeline=Ct;exports.COMMENT_PRIORITY_STYLES=Un;exports.ConditionalStylingEngine=Br;exports.DIAGRAM_STYLE_PRESETS=kt;exports.DIAGRAM_TEMPLATES=It;exports.DiagramCanvas=Fe;exports.DiagramCellRenderer=ga;exports.DiagramCommentManager=Gn;exports.DiagramMinimap=ft;exports.DiagramModel=vt;exports.DiagramParticleEngine=nr;exports.DiagramPropertyPanel=St;exports.DiagramSearchFilterEngine=Qn;exports.DiagramToolbar=Mt;exports.DiagramVersioningManager=Wr;exports.EDGE_STYLE_CATALOG=yi;exports.NODE_STYLE_CATALOG=mi;exports.NiceAnimationTimeline=Ct;exports.NiceDatabaseSchemaViewer=Ta;exports.NiceDecisionTreeEditor=Cn;exports.NiceDependencyGraph=tn;exports.NiceDiagram=Vt;exports.NiceDiagramCanvas=Fe;exports.NiceDiagramEditor=vr;exports.NiceDiagramMinimap=ft;exports.NiceDiagramPropertyPanel=St;exports.NiceDiagramToolbar=Mt;exports.NiceDiagramViewer=Vt;exports.NiceI18nProvider=Rt;exports.NiceNetworkTopology=gn;exports.NiceOrgChartVisualizer=Va;exports.NiceProcessMiningDiagram=Ua;exports.NiceWorkflowDesigner=Tr;exports.NiceWorkflowVisualizer=Na;exports.PRESET_RULES=Yt;exports.TRANSITION_PRESETS=wr;exports.analyzeDependencyGraph=un;exports.calculateNetworkHealth=xn;exports.calculateOrgStats=Ha;exports.computeGlowRadius=lr;exports.computeLayout=Ot;exports.convertAnimation=Nr;exports.convertEdge=Ir;exports.convertGroup=zr;exports.convertNode=Mr;exports.createConditionalStylingEngine=Jn;exports.createDecisionTree=Dn;exports.createDiagramDocument=rt;exports.createGlowFilterId=sr;exports.createLinearWorkflow=Da;exports.createOrgChartFromEmployees=Ya;exports.createPresetFromTheme=vi;exports.createQuickFilter=ts;exports.createRuleFromPreset=Zn;exports.createVersioningHook=qn;exports.diagramBounds=Wt;exports.diagramEdgeShape=wt;exports.diagramPortPoint=jt;exports.diagramScene=xt;exports.discoverNetworkTopology=wn;exports.exportToMermaid=pr;exports.exportToPdf=hr;exports.exportToPng=ur;exports.exportToSvg=dr;exports.fetchAndGenerateDiagram=ma;exports.fitViewport=Bt;exports.formatCommentDate=Xn;exports.generateDiagramFromData=Dr;exports.getDiagramStylePreset=bi;exports.getDiagramStylePresetsByCategory=wi;exports.getEasing=kr;exports.getPointOnPath=oo;exports.getTemplateById=Ln;exports.getTemplatesByCategory=Wn;exports.highlightMatches=es;exports.mineProcessFromLog=Pr;exports.parseBPMNToWorkflow=_a;exports.parseNddJson=uo;exports.parsePackageJsonToDependencies=dn;exports.parseSQLToSchema=Fa;exports.parseSklearnTree=_n;exports.predictWithTree=jn;exports.presetToThemeOverrides=xi;exports.renderTextWithMentions=Kn;exports.sceneToPdf=fr;exports.sceneToSvg=Et;exports.schemaToSQL=La;exports.searchTemplates=Bn;exports.stringifyNddJson=yr;exports.useDiagramEditor=br;exports.useNiceTranslation=Be;