@nice2dev/ui-diagrams 1.2.0 → 1.2.1
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/CHANGELOG.md +103 -0
- package/dist/index.cjs +4 -4
- package/dist/index.mjs +3497 -3166
- package/dist/ui-diagrams.css +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`)}function Tt(i){const e=[],t=i.diagramType==="orgchart"||i.diagramType==="mindmap"?"graph TB":i.diagramType==="stateMachine"?"stateDiagram-v2":"flowchart TD";e.push(t);for(const r of i.nodes){const
|
|
3
|
-
`)}function ut(i){return i.replace(/[^a-zA-Z0-9_]/g,"_")}function _t(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const Ct={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"},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"},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"},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"},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"}},Pt=v.createContext({locale:"en",t:(i,e)=>e??i});function mt({locale:i="en",overrides:e,children:t}){const r=v.useMemo(()=>{const a={...Ct.en,...Ct[i],...e};return{locale:i,t:(c,n)=>a[c]??n??c}},[i,e]);return v.createElement(Pt.Provider,{value:r},t)}function We(){return v.useContext(Pt)}function hr(i){const e=[];let t;try{t=JSON.parse(i)}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 a=new Set(r.nodes.map(o=>o.id).filter(Boolean));for(const o of r.edges)o.sourceNodeId&&!a.has(o.sourceNodeId)&&e.push(`Edge "${o.id}" references non-existent source node "${o.sourceNodeId}"`),o.targetNodeId&&!a.has(o.targetNodeId)&&e.push(`Edge "${o.id}" references non-existent target node "${o.targetNodeId}"`)}return e.length>0?{ok:!1,errors:e}:{ok:!0,document:t,errors:[]}}function Rt(i,e=!0){return JSON.stringify(i,null,e?2:void 0)}class Ze{constructor(e){this.undoStack=[],this.redoStack=[],this.listeners=new Set,this.maxHistory=100,this.doc=e??Ze.createEmpty()}static createEmpty(e="flowchart"){const t=new Date().toISOString();return{version:"1.0",id:De(),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",a={width:160,height:60}){this.pushUndo("Add node");const o=pr(),c={id:De(),label:e,position:t,size:a,shape:r,style:{},ports:o};return this.doc.nodes.push(c),this.notify(),c}updateNode(e,t){this.pushUndo("Update node");const r=this.doc.nodes.find(a=>a.id===e);r&&Object.assign(r,t),this.notify()}moveNode(e,t){const r=this.doc.nodes.find(a=>a.id===e);r&&(this.pushUndo("Move node"),r.position=t,this.notify())}resizeNode(e,t){const r=this.doc.nodes.find(a=>a.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,a,o){if(e===r||!this.getNodeById(e)||!this.getNodeById(r))return null;this.pushUndo("Add edge");const c={id:De(),sourceNodeId:e,sourcePortId:t,targetNodeId:r,targetPortId:a,label:o,style:{lineType:"bezier",targetArrow:"arrow"}};return this.doc.edges.push(c),this.notify(),c}updateEdge(e,t){this.pushUndo("Update edge");const r=this.doc.edges.find(a=>a.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:De(),label:e,nodeIds:[...t]};return t.forEach(a=>{const o=this.doc.nodes.find(c=>c.id===a);o&&(o.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 a=this.doc.nodes.find(o=>o.id===r);a&&(a.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:De(),...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 a=this.doc.nodes.find(o=>o.id===r);a&&(a.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 a=this.doc.nodes.find(o=>o.id===r);a&&(a.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:De(),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 o;const r=(o=this.doc.animationModes)==null?void 0:o.find(c=>c.id===e);if(!r)return null;this.pushUndo("Add animation to mode");const a={id:De(),...t};return r.animations.push(a),this.notify(),a}removeAnimationFromMode(e,t){var a;const r=(a=this.doc.animationModes)==null?void 0:a.find(o=>o.id===e);r&&(this.pushUndo("Remove animation from mode"),r.animations=r.animations.filter(o=>o.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(a=>a.id===e);r&&Object.assign(r,t),this.notify()}loadDocument(e){this.doc=structuredClone(e),this.undoStack=[],this.redoStack=[],this.notify()}}function De(){return`ndd_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function pr(){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(i,e,t){switch(t.algorithm){case"dagre":return Et(i,e,t);case"grid":return mr(i,t);case"radial":return gr(i,e);case"tree":return yr(i,e,t);case"forceDirected":return br(i,e,t);case"manual":default:return{positions:new Map(i.map(r=>[r.id,{...r.position}]))}}}function Et(i,e,t){const r=t.direction??"TB",a=t.nodeSpacing??60,o=t.rankSpacing??100,c=new Map,n=new Map,l=new Set(i.map(y=>y.id));i.forEach(y=>{c.set(y.id,[]),n.set(y.id,[])}),e.forEach(y=>{l.has(y.sourceNodeId)&&l.has(y.targetNodeId)&&(c.get(y.sourceNodeId).push(y.targetNodeId),n.get(y.targetNodeId).push(y.sourceNodeId))});const f=i.filter(y=>{var M;return(((M=n.get(y.id))==null?void 0:M.length)??0)===0});f.length===0&&i.length>0&&f.push(i[0]);const d=new Map,m=[];for(f.forEach(y=>{d.set(y.id,0),m.push(y.id)});m.length>0;){const y=m.shift(),M=d.get(y)??0;for(const S of c.get(y)??[])d.has(S)||(d.set(S,M+1),m.push(S))}i.forEach(y=>{d.has(y.id)||d.set(y.id,0)});const p=new Map;i.forEach(y=>{const M=d.get(y.id)??0;p.has(M)||p.set(M,[]),p.get(M).push(y)});const g=new Map,h=r==="LR"||r==="RL",b=r==="BT"||r==="RL";return[...p.keys()].sort((y,M)=>y-M).forEach((y,M)=>{const S=p.get(y);let C=-(S.reduce((k,T)=>k+T.size.width,0)+(S.length-1)*a)/2;S.forEach(k=>{const T=M*(o+(h?k.size.width:k.size.height)),A=C+k.size.width/2;let L,F;h?(L=b?-T:T,F=A):(L=A,F=b?-T:T),g.set(k.id,{x:L,y:F}),C+=k.size.width+a})}),t.centerGraph&>(g),{positions:g}}function mr(i,e){const t=e.nodeSpacing??80,r=Math.ceil(Math.sqrt(i.length)),a=new Map;return i.forEach((o,c)=>{const n=c%r,l=Math.floor(c/r);a.set(o.id,{x:n*(o.size.width+t),y:l*(o.size.height+t)})}),e.centerGraph&>(a),{positions:a}}function gr(i,e){const t=new Map;if(i.length===0)return{positions:t};const r=new Map;i.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 a=[...i].sort((l,f)=>(r.get(f.id)??0)-(r.get(l.id)??0)),o=a[0];t.set(o.id,{x:0,y:0});const c=a.slice(1),n=200+c.length*20;return c.forEach((l,f)=>{const d=2*Math.PI*f/c.length;t.set(l.id,{x:Math.cos(d)*n,y:Math.sin(d)*n})}),{positions:t}}function yr(i,e,t){return Et(i,e,{...t,direction:t.direction??"TB",nodeSpacing:t.nodeSpacing??40,rankSpacing:t.rankSpacing??80})}function br(i,e,t){const r=new Map;if(i.length===0)return{positions:r};const a=400,o=new Map;i.forEach(m=>{o.set(m.id,{x:(Math.random()-.5)*a,y:(Math.random()-.5)*a})});const c=e.map(m=>({source:m.sourceNodeId,target:m.targetNodeId})),n=t.nodeSpacing??150,l=80,f=.95;let d=a/2;for(let m=0;m<l;m++){const p=new Map;i.forEach(g=>p.set(g.id,{fx:0,fy:0}));for(let g=0;g<i.length;g++)for(let h=g+1;h<i.length;h++){const b=o.get(i[g].id),w=o.get(i[h].id),y=w.x-b.x,M=w.y-b.y,S=Math.max(Math.sqrt(y*y+M*M),1),D=n*n/S,C=y/S*D,k=M/S*D;p.get(i[g].id).fx-=C,p.get(i[g].id).fy-=k,p.get(i[h].id).fx+=C,p.get(i[h].id).fy+=k}for(const g of c){const h=o.get(g.source),b=o.get(g.target);if(!h||!b)continue;const w=b.x-h.x,y=b.y-h.y,M=Math.max(Math.sqrt(w*w+y*y),1),S=M*M/n,D=w/M*S,C=y/M*S;p.get(g.source).fx+=D,p.get(g.source).fy+=C,p.get(g.target).fx-=D,p.get(g.target).fy-=C}i.forEach(g=>{const h=p.get(g.id),b=o.get(g.id),w=Math.sqrt(h.fx*h.fx+h.fy*h.fy);if(w>0){const y=Math.min(w,d);b.x+=h.fx/w*y,b.y+=h.fy/w*y}}),d*=f}return i.forEach(m=>{r.set(m.id,{...o.get(m.id)})}),t.centerGraph&>(r),{positions:r}}function gt(i){if(i.size===0)return;let e=1/0,t=1/0,r=-1/0,a=-1/0;i.forEach(n=>{e=Math.min(e,n.x),t=Math.min(t,n.y),r=Math.max(r,n.x),a=Math.max(a,n.y)});const o=(e+r)/2,c=(t+a)/2;i.forEach(n=>{n.x-=o,n.y-=c})}function Lt(i){const e=v.useRef(null);e.current||(e.current=new Ze(i));const t=e.current,[,r]=v.useState(0),a=v.useCallback(()=>r(n=>n+1),[]);v.useEffect(()=>t.subscribe(a),[t,a]);const o=t.getDocument(),c=v.useCallback(n=>{Ot(t.getNodes(),t.getEdges(),n).positions.forEach((f,d)=>{t.moveNode(d,f)})},[t]);return v.useMemo(()=>({document:o,nodes:o.nodes,edges:o.edges,groups:o.groups,animations:o.animations,viewport:o.viewport,addNode:(n,l,f,d)=>t.addNode(n,l,f,d),updateNode:(n,l)=>t.updateNode(n,l),moveNode:(n,l)=>t.moveNode(n,l),resizeNode:(n,l)=>t.resizeNode(n,l),removeNode:n=>t.removeNode(n),addEdge:(n,l,f,d,m)=>t.addEdge(n,l,f,d,m),updateEdge:(n,l)=>t.updateEdge(n,l),removeEdge:n=>t.removeEdge(n),createGroup:(n,l)=>t.createGroup(n,l),removeGroup:n=>t.removeGroup(n),toggleGroupCollapse:n=>t.toggleGroupCollapse(n),toggleNodeCollapse:n=>t.toggleNodeCollapse(n),addAnimation:n=>t.addAnimation(n),updateAnimation:(n,l)=>t.updateAnimation(n,l),removeAnimation:n=>t.removeAnimation(n),animationModes:t.getAnimationModes(),activeAnimationMode:t.getActiveAnimationMode(),addAnimationMode:(n,l)=>t.addAnimationMode(n,l),removeAnimationMode:n=>t.removeAnimationMode(n),setActiveAnimationMode:n=>t.setActiveAnimationMode(n),addAnimationToMode:(n,l)=>t.addAnimationToMode(n,l),removeAnimationFromMode:(n,l)=>t.removeAnimationFromMode(n,l),setStylePreset:n=>t.setStylePreset(n),setStyleOverrides:n=>t.setStyleOverrides(n),stylePresetId:o.stylePresetId,playerConfig:t.getPlayerConfig(),setPlayerConfig:n=>t.setPlayerConfig(n),setViewMode:n=>t.setViewMode(n),viewMode:t.getPlayerConfig().mode,applyLayout:c,setViewport:n=>t.setViewport(n),undo:()=>t.undo(),redo:()=>t.redo(),canUndo:t.canUndo(),canRedo:t.canRedo(),loadDocument:n=>t.loadDocument(n),model:t}),[o,t,c])}function le(i){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)",...i}}function xr(i,e={}){return{backgroundColor:i.surface,borderColor:i.primary,borderWidth:2,borderRadius:8,fontColor:i.text,fontSize:14,fontWeight:"normal",opacity:1,shadow:!0,...e}}function vr(i,e={}){return{strokeColor:i.border,strokeWidth:2,lineType:"bezier",targetArrow:"arrow",...e}}function wr(i,e={}){return{backgroundColor:`${i.primaryLight}18`,borderColor:i.primaryLight,borderWidth:1,borderStyle:"dashed",borderRadius:12,labelColor:i.text,padding:16,...e}}function de(i,e,t,r,a,o,c){return{canvas:i,nodeDefaults:xr(e,r),edgeDefaults:vr(e,a),groupDefaults:wr(e,o),fontFamily:t,palette:e,effects:c}}const Ne="'Inter', system-ui, sans-serif",yt="'Fira Code', 'Cascadia Code', monospace",kr="'Merriweather', 'Georgia', serif",_r={id:"default-light",name:"Default Light",category:"corporate",themeSource:"Light",config:de({background:"var(--nice-bg, #fff)",gridColor:"#e2e8f020",gridSize:20,selectionColor:"var(--nice-primary, #3b82f6)"},le({}),Ne)},Cr=le({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)"}),Nr={id:"default-dark",name:"Default Dark",category:"dark",themeSource:"Dark",config:de({background:"var(--nice-bg-primary, #0f172a)",gridColor:"var(--nice-text, #334155)",gridSize:20,selectionColor:"var(--nice-primary-light, #60a5fa)"},Cr,Ne,{shadow:!1},{strokeColor:"var(--nice-text-secondary, #475569)"},{backgroundColor:"#60a5fa10",borderColor:"#3b82f680"})},Mr=le({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)"}),Sr={id:"corporate-blue",name:"Corporate Blue",category:"corporate",themeSource:"Blue",config:de({background:"#f0f5ff",gridColor:"#93c5fd20",gridSize:20,selectionColor:"var(--nice-primary-dark, #1d4ed8)"},Mr,Ne,{borderWidth:2,borderRadius:6},{strokeColor:"var(--nice-primary-light, #93c5fd)",strokeWidth:2})},Ir=le({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)"}),zr={id:"neon-glow",name:"Neon Glow",category:"dark",config:de({background:"#0a0a1a",gridColor:"#00ff8810",gridSize:20,selectionColor:"var(--nice-success, #00ff88)"},Ir,yt,{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)"})},jr=le({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"}),Ar={id:"cyberpunk",name:"Cyberpunk",category:"dark",config:de({background:"#0d001a",gridColor:"#ff2d9510",gridSize:24,selectionColor:"var(--nice-color-accent-pink, #ff2d95)"},jr,yt,{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"})},$r=le({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"}),Dr={id:"blueprint",name:"Technical Blueprint",category:"technical",config:de({background:"#0a1929",gridColor:"#4da6ff30",gridSize:16,selectionColor:"var(--nice-color-white, #fff)"},$r,yt,{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})},Tr=le({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"}),Pr={id:"pastel-dream",name:"Pastel Dream",category:"pastel",config:de({background:"#fefcff",gridColor:"#e2d8f420",gridSize:20,selectionColor:"var(--nice-accent, #a78bfa)"},Tr,"'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})},Rr=le({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"}),Or={id:"nature-forest",name:"Nature Forest",category:"nature",config:de({background:"#f0fdf4",gridColor:"#a7d7c520",gridSize:20,selectionColor:"var(--nice-success, #059669)"},Rr,Ne,{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)"})},Er=le({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"}),Lr={id:"retro-terminal",name:"Retro Terminal",category:"retro",config:de({background:"#000800",gridColor:"#00ff0010",gridSize:16,selectionColor:"var(--nice-success, #00ff00)"},Er,"'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)"})},Wr=le({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)"}),Fr={id:"high-contrast",name:"High Contrast",category:"accessibility",themeSource:"High Contrast",config:de({background:"var(--nice-bg, #fff)",gridColor:"#00000020",gridSize:20,selectionColor:"#0000ff"},Wr,"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})},Br=le({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)"}),qr={id:"material-design",name:"Material Design",category:"theme-based",themeSource:"Material",config:de({background:"var(--nice-bg-secondary, #fafafa)",gridColor:"#e0e0e020",gridSize:20,selectionColor:"var(--nice-primary-hover, #1976d2)"},Br,"'Roboto', 'Noto Sans', sans-serif",{borderRadius:4,borderWidth:0,shadow:!0},{strokeColor:"#bdbdbd",strokeWidth:2},{borderRadius:8})},Gr=le({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"}),Vr={id:"fluent-ui",name:"Fluent UI",category:"theme-based",themeSource:"Fluent",config:de({background:"#faf9f8",gridColor:"#edebe920",gridSize:20,selectionColor:"#0078d4"},Gr,"'Segoe UI', system-ui, sans-serif",{borderRadius:4,borderWidth:1,shadow:!0},{strokeColor:"#c8c6c4",strokeWidth:1})},Yr=le({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)"}),Xr={id:"sunset-warm",name:"Sunset Warm",category:"creative",config:de({background:"#fffde7",gridColor:"#ffccbc20",gridSize:20,selectionColor:"var(--nice-warning-dark, #e65100)"},Yr,Ne,{borderColor:"#ff9e80",gradientColor:"var(--nice-warning-bg, #fff3e0)",gradientDirection:"vertical"},{strokeColor:"#ff9e80"},{},{liquidColor:"var(--nice-warning-dark, #e65100)",liquidColorEnd:"#ffd600",particleColor:"#ffd600"})},Ur=le({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"}),Hr={id:"ocean-deep",name:"Ocean Deep",category:"nature",config:de({background:"#e0f7fa",gridColor:"#b2ebf220",gridSize:20,selectionColor:"#006064"},Ur,Ne,{borderColor:"#00838f",borderRadius:12},{strokeColor:"#4dd0e1"},{},{liquidColor:"#006064",liquidColorEnd:"#4dd0e1",particleColor:"#ffd54f"})},Jr=le({primary:"#5d4037",primaryLight:"#a1887f",secondary:"#795548",accent:"#c6a263",text:"#3e2723",textMuted:"#8d6e63",border:"#bcaaa4",surface:"#fdf6f0",surfaceAlt:"#efebe9"}),Zr={id:"elegant-serif",name:"Elegant Serif",category:"creative",config:de({background:"#fdf6f0",gridColor:"#bcaaa420",gridSize:24,selectionColor:"#5d4037"},Jr,kr,{borderColor:"#a1887f",borderWidth:1,borderRadius:2,fontStyle:"normal"},{strokeColor:"#bcaaa4",strokeWidth:1},{borderRadius:4})},Kr=le({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)"}),Qr={id:"wireframe",name:"Wireframe",category:"technical",config:de({background:"var(--nice-bg, #fff)",gridColor:"#00000008",gridSize:16,selectionColor:"#ff6600"},Kr,"'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=le({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:de({background:"var(--nice-success-bg, #e8f5e9)",gridColor:"#a7ffeb20",gridSize:20,selectionColor:"#00bfa5"},ei,Ne,{borderColor:"#00bfa5",borderRadius:20,borderWidth:2,gradientColor:"#b2dfdb",gradientDirection:"radial"},{strokeColor:"#64ffda",strokeWidth:2},{borderRadius:16},{liquidColor:"#00bfa5",liquidColorEnd:"#64ffda",particleColor:"#ff6e40"})},ri=le({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)"}),ii={id:"monochrome",name:"Monochrome",category:"corporate",config:de({background:"var(--nice-bg-secondary, #fafafa)",gridColor:"#e0e0e020",gridSize:20,selectionColor:"#424242"},ri,Ne,{borderColor:"var(--nice-border-color, #9e9e9e)",borderWidth:1,shadow:!0,borderRadius:4},{strokeColor:"var(--nice-text-secondary, #9e9e9e)",strokeWidth:1.5})},ai=le({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"}),oi={id:"candy-pop",name:"Candy Pop",category:"creative",config:de({background:"#fff0f5",gridColor:"#f8bbd020",gridSize:20,selectionColor:"var(--nice-color-accent-pink, #e91e63)"},ai,"'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)"})},si=le({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)"}),ni={id:"slate-professional",name:"Slate Professional",category:"corporate",config:de({background:"var(--nice-bg-secondary, #f8fafc)",gridColor:"#cbd5e120",gridSize:20,selectionColor:"var(--nice-text-secondary, #475569)"},si,"'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})},ci=le({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"}),li={id:"aurora-borealis",name:"Aurora Borealis",category:"dark",config:de({background:"#0f0b2e",gridColor:"#7c3aed15",gridSize:24,selectionColor:"var(--nice-accent, #a78bfa)"},ci,Ne,{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=le({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:de({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=le({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:de({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=le({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"}),mi={id:"midnight-purple",name:"Midnight Purple",category:"dark",config:de({background:"#0f0720",gridColor:"#9333ea10",gridSize:20,selectionColor:"var(--nice-accent, #c084fc)"},pi,Ne,{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)"})},Ke=[_r,Nr,Sr,qr,Vr,zr,Ar,Dr,Lr,Pr,Xr,Hr,Zr,Or,Qr,Fr,ti,ii,oi,ni,li,ui,hi,mi],gi=[{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}}}],Wt=[{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(i){return Ke.find(e=>e.id===i)}function xi(i){return Ke.filter(e=>e.category===i)}function vi(i){return{canvasBackground:i.canvas.background,gridColor:i.canvas.gridColor,gridSize:i.canvas.gridSize,selectionColor:i.canvas.selectionColor,fontFamily:i.fontFamily,nodeDefaults:i.nodeDefaults,edgeDefaults:i.edgeDefaults,groupDefaults:i.groupDefaults,palette:i.palette,effects:i.effects}}function wi(i,e,t,r,a,o){const c=le({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:a.primary,textMuted:a.muted,border:o.color,surface:r.primary,surfaceAlt:r.secondary}),n=ki(r.primary);return{id:i,name:`${e} Theme`,category:"theme-based",themeSource:e,config:de({background:r.primary,gridColor:n?`${o.color}40`:`${o.color}20`,gridSize:20,selectionColor:t.primary},c,Ne,{shadow:!n,borderWidth:n?1:2},{strokeColor:n?`${o.color}80`:o.color})}}function ki(i){const e=i.replace("#","");if(e.length<6)return!1;const t=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),a=parseInt(e.slice(4,6),16);return(t*299+r*587+a*114)/1e3<128}const _i=["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"],Qe=({animations:i,onAdd:e,onRemove:t,onUpdate:r,onPlay:a,onStop:o,isPlaying:c=!1,availableTargets:n=[],className:l})=>{const{t:f}=We(),[d,m]=v.useState(!1),[p,g]=v.useState(null),h=v.useCallback(()=>{if(!e||n.length===0)return;const y=n[0];e({name:`Animation ${i.length+1}`,targetId:y.id,targetType:y.type,effect:"fadeIn",startMs:i.length*500,durationMs:600,easing:"easeOut"})},[e,i.length,n]),b=v.useCallback(y=>{if(!e||n.length===0)return;const M=n[0];e({name:y.name,targetId:M.id,targetType:M.type,effect:y.effect,startMs:i.length*500,durationMs:y.durationMs,easing:y.easing}),m(!1)},[e,i.length,n]),w=Math.max(2e3,...i.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:f("animation.timeline")}),s.jsxs("div",{className:"nice-diagram-timeline__controls",children:[c?s.jsxs(x.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:o,children:[s.jsx(x.NiceIcon,{name:"stop",size:14})," ",f("animation.stop")]}):s.jsxs(x.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:a,children:[s.jsx(x.NiceIcon,{name:"play",size:14})," ",f("animation.play")]}),s.jsxs(x.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:h,disabled:n.length===0,children:[s.jsx(x.NiceIcon,{name:"plus",size:14})," ",f("animation.add")]}),s.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[s.jsxs(x.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:()=>m(y=>!y),disabled:n.length===0,title:"Add from preset",children:[s.jsx(x.NiceIcon,{name:"video",size:14})," 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:Wt.map(y=>s.jsx(x.NiceButton,{variant:"ghost",size:"sm",onClick:()=>b(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:[i.length===0&&s.jsx("p",{className:"nice-diagram-timeline__empty",children:f("animation.noAnimations")}),i.map(y=>{const M=y.startMs/w*100,S=y.durationMs/w*100,D=p===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",{className:"nice-diagram-timeline__track-name",onClick:()=>g(D?null:y.id),style:{cursor:"pointer"},title:"Click to edit",children:y.name}),s.jsx("span",{className:"nice-diagram-timeline__track-effect",children:y.effect}),s.jsx(x.NiceButton,{className:"nice-diagram-timeline__track-remove",variant:"ghost",size:"sm",onClick:()=>t==null?void 0:t(y.id),title:f("toolbar.delete"),children:"×"})]}),D&&s.jsxs("div",{className:"nice-diagram-timeline__track-editor",style:{display:"flex",gap:4,padding:"4px 0",flexWrap:"wrap",fontSize:11},children:[s.jsx(x.NiceSelect,{value:y.effect,onChange:C=>r==null?void 0:r(y.id,{effect:C}),options:_i.map(C=>({value:C,label:C})),style:{fontSize:11,padding:"1px 4px"}}),s.jsx(x.NiceSelect,{value:y.easing,onChange:C=>r==null?void 0:r(y.id,{easing:C}),options:Ci.map(C=>({value:C,label:C})),style:{fontSize:11,padding:"1px 4px"}}),s.jsx(x.NiceSelect,{value:y.targetId,onChange:C=>{const k=n.find(T=>T.id===C);k&&(r==null||r(y.id,{targetId:k.id,targetType:k.type}))},options:n.map(C=>({value:C.id,label:C.label})),style:{fontSize:11,padding:"1px 4px",maxWidth:100}}),s.jsx(x.NiceNumberInput,{value:y.startMs,min:0,step:100,onChange:C=>r==null?void 0:r(y.id,{startMs:C??0}),style:{width:60,fontSize:11},title:"Start (ms)"}),s.jsx(x.NiceNumberInput,{value:y.durationMs,min:50,step:50,onChange:C=>r==null?void 0:r(y.id,{durationMs:C??50}),style:{width:60,fontSize:11},title:"Duration (ms)"})]}),s.jsx("div",{className:"nice-diagram-timeline__track-bar",children:s.jsx("div",{className:"nice-diagram-timeline__track-segment",style:{left:`${M}%`,width:`${S}%`},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,M)=>{const S=Math.round(w/4*M);return s.jsxs("span",{className:"nice-diagram-timeline__ruler-mark",style:{left:`${M/4*100}%`},children:[S,"ms"]},M)})})]})};Qe.displayName="AnimationTimeline";const Ni=/^[a-z][a-z0-9-]*$/,Mi=.1,Si=5,Ue=8,ft=[{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}],we=({nodes:i,edges:e,groups:t=[],viewport:r,onViewportChange:a,theme:o,selectedId:c,selectedIds:n=[],onSelectElement:l,onMultiSelect:f,onNodeDragStart:d,onNodeDrag:m,onNodeDragEnd:p,onNodeResize:g,onNodeLabelChange:h,animationStates:b,particleState:w,viewMode:y="editor",ghostOpacity:M=.15,onGroupCollapse:S,onNodeCollapse:D,onInteraction:C,onNodeHover:k,onGroupClick:T,interactive:A=!1,showGrid:L=!0,showRulers:F=!1,snapToGrid:Y=!0,gridSnapSize:W=10,className:G})=>{const N=v.useRef(null),[V,P]=v.useState(!1),[q,R]=v.useState({x:0,y:0}),[B,U]=v.useState(null),[K,ue]=v.useState({x:0,y:0}),[ee,E]=v.useState(null),[H,fe]=v.useState(null),[te,ce]=v.useState(null),[ke,je]=v.useState(null),[Re,ye]=v.useState(""),[at,Oe]=v.useState([]),ot=(o==null?void 0:o.canvasBackground)??"var(--nice-bg-secondary, #f8f9fa)",Fe=(o==null?void 0:o.gridColor)??"var(--nice-border, #e0e0e0)",Me=(o==null?void 0:o.gridSize)??20,xe=(o==null?void 0:o.selectionColor)??"var(--nice-primary, #2196f3)",Be=v.useMemo(()=>{const u=new Set(n);return c&&u.add(c),u},[c,n]),me=v.useCallback(u=>Y?Math.round(u/W)*W:u,[Y,W]),qe=v.useCallback((u,_,I)=>{const j=[],z=_.x,$=_.y,Q=z+I.width/2,J=$+I.height/2,Z=z+I.width,ie=$+I.height;for(const he of i){if(he.id===u)continue;const oe=he.position.x,ne=he.position.y,pe=oe+he.size.width/2,_e=ne+he.size.height/2,Se=oe+he.size.width,Ce=ne+he.size.height;Math.abs(z-oe)<5&&j.push({x:oe}),Math.abs(Z-Se)<5&&j.push({x:Se}),Math.abs(Q-pe)<5&&j.push({x:pe}),Math.abs(z-Se)<5&&j.push({x:Se}),Math.abs(Z-oe)<5&&j.push({x:oe}),Math.abs($-ne)<5&&j.push({y:ne}),Math.abs(ie-Ce)<5&&j.push({y:Ce}),Math.abs(J-_e)<5&&j.push({y:_e}),Math.abs($-Ce)<5&&j.push({y:Ce}),Math.abs(ie-ne)<5&&j.push({y:ne})}Oe(j)},[i]),Ae=v.useCallback(u=>{if(u.preventDefault(),!a)return;const _=u.deltaY>0?.9:1.1,I=Math.min(Si,Math.max(Mi,r.zoom*_)),j=N.current;if(!j)return;const O=j.getBoundingClientRect(),z=u.clientX-O.left,$=u.clientY-O.top,Q=I/r.zoom,J=z-(z-r.x)*Q,Z=$-($-r.y)*Q;a({x:J,y:Z,zoom:I})},[r,a]),st=v.useCallback(u=>{if(u.button===1||u.button===0&&u.target.tagName==="svg"){if(u.button===0&&A&&!u.shiftKey&&u.target.tagName==="svg"){const _=N.current;if(_){const I=_.getBoundingClientRect(),j=(u.clientX-I.left-r.x)/r.zoom,O=(u.clientY-I.top-r.y)/r.zoom;fe({x:j,y:O}),E({x1:j,y1:O,x2:j,y2:O})}l&&l(null),f&&f([]);return}P(!0),R({x:u.clientX-r.x,y:u.clientY-r.y}),l&&u.button===0&&l(null)}},[r,l,f,A]),Ge=v.useCallback(u=>{if(H){const _=N.current;if(!_)return;const I=_.getBoundingClientRect(),j=(u.clientX-I.left-r.x)/r.zoom,O=(u.clientY-I.top-r.y)/r.zoom;E({x1:H.x,y1:H.y,x2:j,y2:O});return}if(V&&a){a({...r,x:u.clientX-q.x,y:u.clientY-q.y});return}if(te&&g){const _=N.current;if(!_)return;const I=_.getBoundingClientRect(),j=(u.clientX-I.left-r.x)/r.zoom,O=(u.clientY-I.top-r.y)/r.zoom,z=j-te.startMouse.x,$=O-te.startMouse.y,Q=ft[te.handleIdx];let J=te.startSize.width+z*Q.resizeX,Z=te.startSize.height+$*Q.resizeY,ie=te.startPos.x+(Q.resizeX<0?z:0),he=te.startPos.y+(Q.resizeY<0?$:0);J=Math.max(30,me(J)),Z=Math.max(20,me(Z)),ie=me(ie),he=me(he),g(te.nodeId,{width:J,height:Z},{x:ie,y:he});return}if(B&&m){const _=N.current;if(!_)return;const I=_.getBoundingClientRect(),j=me((u.clientX-I.left-r.x)/r.zoom-K.x),O=me((u.clientY-I.top-r.y)/r.zoom-K.y);m(B,{x:j,y:O});const z=i.find($=>$.id===B);z&&qe(B,{x:j,y:O},z.size)}},[H,V,a,r,q,te,g,B,m,K,me,i,qe]),Ve=v.useCallback(u=>{if(ee&&H){const _=Math.min(ee.x1,ee.x2),I=Math.min(ee.y1,ee.y2),j=Math.max(ee.x1,ee.x2),O=Math.max(ee.y1,ee.y2);if(Math.abs(j-_)>5||Math.abs(O-I)>5){const z=i.filter($=>{const Q=$.position.x,J=$.position.y,Z=Q+$.size.width,ie=J+$.size.height;return Z>_&&Q<j&&ie>I&&J<O}).map($=>$.id);f==null||f(z),z.length===1&&(l==null||l(z[0]))}E(null),fe(null);return}if(V&&P(!1),te){ce(null);return}if(B&&p){const _=N.current;if(!_)return;const I=_.getBoundingClientRect(),j=me((u.clientX-I.left-r.x)/r.zoom-K.x),O=me((u.clientY-I.top-r.y)/r.zoom-K.y);p(B,{x:j,y:O})}U(null),Oe([])},[ee,H,V,te,B,p,r,K,me,i,f,l]),nt=v.useCallback((u,_)=>{if(u.stopPropagation(),!A)return;const I=i.find(Q=>Q.id===_);if(!I||I.locked)return;if(u.shiftKey&&f){const Q=[...n],J=Q.indexOf(_);J>=0?Q.splice(J,1):Q.push(_),f(Q);return}l==null||l(_);const j=N.current;if(!j)return;const O=j.getBoundingClientRect(),z=(u.clientX-O.left-r.x)/r.zoom,$=(u.clientY-O.top-r.y)/r.zoom;ue({x:z-I.position.x,y:$-I.position.y}),U(_),d==null||d(_)},[A,i,r,l,d,f,n]),ct=v.useCallback((u,_,I)=>{if(u.stopPropagation(),!A)return;const j=i.find(J=>J.id===_);if(!j||j.locked)return;const O=N.current;if(!O)return;const z=O.getBoundingClientRect(),$=(u.clientX-z.left-r.x)/r.zoom,Q=(u.clientY-z.top-r.y)/r.zoom;ce({nodeId:_,handleIdx:I,startMouse:{x:$,y:Q},startPos:{...j.position},startSize:{...j.size}}),l==null||l(_)},[A,i,r,l]),X=v.useCallback((u,_)=>{if(u.stopPropagation(),!A||!h)return;const I=i.find(j=>j.id===_);!I||I.locked||(je(_),ye(I.label))},[A,i,h]),$e=v.useCallback(()=>{ke&&h&&h(ke,Re),je(null)},[ke,Re,h]),ve=v.useCallback((u,_)=>{u.stopPropagation(),l==null||l(_)},[l]),lt=v.useCallback(u=>{const _=i.find(I=>I.id===u);return _?{x:_.position.x+_.size.width/2,y:_.position.y+_.size.height/2}:{x:0,y:0}},[i]),Ee=v.useCallback((u,_)=>{const I=i.find($=>$.id===u);if(!I)return{x:0,y:0};const j=I.ports.find($=>$.id===_);if(!j)return lt(u);const{position:O,size:z}=I;switch(j.side){case"top":return{x:O.x+z.width*j.offset,y:O.y};case"bottom":return{x:O.x+z.width*j.offset,y:O.y+z.height};case"left":return{x:O.x,y:O.y+z.height*j.offset};case"right":return{x:O.x+z.width,y:O.y+z.height*j.offset};default:return lt(u)}},[i,lt]),sr=v.useCallback(u=>{const _=Ee(u.sourceNodeId,u.sourcePortId),I=Ee(u.targetNodeId,u.targetPortId);switch(u.style.lineType??"bezier"){case"straight":return`M ${_.x} ${_.y} L ${I.x} ${I.y}`;case"orthogonal":{const O=(_.x+I.x)/2;return`M ${_.x} ${_.y} L ${O} ${_.y} L ${O} ${I.y} L ${I.x} ${I.y}`}case"step":{const O=(_.y+I.y)/2;return`M ${_.x} ${_.y} L ${_.x} ${O} L ${I.x} ${O} L ${I.x} ${I.y}`}case"bezier":default:{const O=Math.abs(I.x-_.x)*.5;return`M ${_.x} ${_.y} C ${_.x+O} ${_.y}, ${I.x-O} ${I.y}, ${I.x} ${I.y}`}}},[Ee]),nr=v.useCallback((u,_)=>{const{size:I,style:j,shape:O}=u,z=I.width,$=I.height,J=!!(j.gradientColor&&j.backgroundColor)?`url(#${_})`:j.backgroundColor??"var(--nice-bg, #fff)",Z=j.borderColor??"var(--nice-text, #333333)",ie=j.borderWidth??1,he=j.borderRadius??(O==="roundedRect"?8:0),oe=j.borderStyle==="dashed"?"8,4":j.borderStyle==="dotted"?"2,4":void 0,ne=j.shadow?"url(#nd-shadow)":void 0;switch(O){case"ellipse":case"circle":return s.jsx("ellipse",{cx:z/2,cy:$/2,rx:z/2,ry:$/2,fill:J,stroke:Z,strokeWidth:ie,strokeDasharray:oe,filter:ne});case"diamond":return s.jsx("polygon",{points:`${z/2},0 ${z},${$/2} ${z/2},${$} 0,${$/2}`,fill:J,stroke:Z,strokeWidth:ie,strokeDasharray:oe,filter:ne});case"hexagon":{const pe=z/4;return s.jsx("polygon",{points:`${pe},0 ${z-pe},0 ${z},${$/2} ${z-pe},${$} ${pe},${$} 0,${$/2}`,fill:J,stroke:Z,strokeWidth:ie,strokeDasharray:oe,filter:ne})}case"parallelogram":{const pe=z*.15;return s.jsx("polygon",{points:`${pe},0 ${z},0 ${z-pe},${$} 0,${$}`,fill:J,stroke:Z,strokeWidth:ie,strokeDasharray:oe,filter:ne})}case"cylinder":return s.jsxs("g",{filter:ne,children:[s.jsx("ellipse",{cx:z/2,cy:$*.1,rx:z/2,ry:$*.1,fill:J,stroke:Z,strokeWidth:ie}),s.jsx("rect",{x:0,y:$*.1,width:z,height:$*.8,fill:J,stroke:"none"}),s.jsx("line",{x1:0,y1:$*.1,x2:0,y2:$*.9,stroke:Z,strokeWidth:ie}),s.jsx("line",{x1:z,y1:$*.1,x2:z,y2:$*.9,stroke:Z,strokeWidth:ie}),s.jsx("ellipse",{cx:z/2,cy:$*.9,rx:z/2,ry:$*.1,fill:J,stroke:Z,strokeWidth:ie})]});case"triangle":return s.jsx("polygon",{points:`${z/2},0 ${z},${$} 0,${$}`,fill:J,stroke:Z,strokeWidth:ie,strokeDasharray:oe,filter:ne});case"cloud":{const pe=`M${z*.25},${$*.8} A${z*.2},${z*.2},0,1,1,${z*.15},${$*.45} A${z*.18},${z*.18},0,1,1,${z*.35},${$*.2} A${z*.2},${z*.2},0,1,1,${z*.65},${$*.2} A${z*.18},${z*.18},0,1,1,${z*.85},${$*.45} A${z*.2},${z*.2},0,1,1,${z*.75},${$*.8} Z`;return s.jsx("path",{d:pe,fill:J,stroke:Z,strokeWidth:ie,filter:ne})}case"document":{const pe=`M 0 0 L ${z} 0 L ${z} ${$*.85} Q ${z*.75} ${$*.7}, ${z*.5} ${$*.85} Q ${z*.25} ${$}, 0 ${$*.85} Z`;return s.jsx("path",{d:pe,fill:J,stroke:Z,strokeWidth:ie,filter:ne})}case"actor":return s.jsxs("g",{stroke:Z,strokeWidth:ie,fill:"none",filter:ne,children:[s.jsx("circle",{cx:z/2,cy:$*.15,r:$*.12,fill:J}),s.jsx("line",{x1:z/2,y1:$*.27,x2:z/2,y2:$*.6}),s.jsx("line",{x1:z*.15,y1:$*.4,x2:z*.85,y2:$*.4}),s.jsx("line",{x1:z/2,y1:$*.6,x2:z*.2,y2:$}),s.jsx("line",{x1:z/2,y1:$*.6,x2:z*.8,y2:$})]});case"rectangle":case"roundedRect":case"custom":default:return s.jsx("rect",{width:z,height:$,rx:he,ry:he,fill:J,stroke:Z,strokeWidth:ie,strokeDasharray:oe,filter:ne})}},[]),kt=v.useCallback(u=>{if(!b)return{};const _=b.get(u);if(!_)return{};const I=_.glow>0?`drop-shadow(0 0 ${_.glow}px gold)`:"",j=_.highlightColor?`drop-shadow(0 0 6px ${_.highlightColor})`:"";return{opacity:_.opacity,transform:`translate(${_.translateX}px, ${_.translateY}px) scale(${_.scale})`,filter:[I,j].filter(Boolean).join(" ")||void 0}},[b]),cr=v.useMemo(()=>{if(!w)return null;const u=[];for(const[,_]of w.glowStates){const I=$t(_.elementId),j=Dt(_.intensity,_.pulse);u.push(s.jsxs("filter",{id:I,x:"-50%",y:"-50%",width:"200%",height:"200%",children:[s.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:j,result:"blur"}),s.jsx("feFlood",{floodColor:_.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"})]})]},I))}return u},[w]),lr=v.useMemo(()=>{if(!w)return null;const u=[];for(const[_,I]of w.liquidFlows){if(!I.active)continue;const j=e.find(J=>J.id===_);if(!(j!=null&&j.style.liquidFlow))continue;const{color:O,colorEnd:z}=j.style.liquidFlow,$=`nd-liquid-${_}`,Q=I.gradientOffset;u.push(s.jsxs("linearGradient",{id:$,x1:"0",y1:"0",x2:"1",y2:"0",children:[s.jsx("stop",{offset:`${Q*100%100}%`,stopColor:O,stopOpacity:.8}),s.jsx("stop",{offset:`${(Q+.3)*100%100}%`,stopColor:z??O,stopOpacity:.4}),s.jsx("stop",{offset:`${(Q+.6)*100%100}%`,stopColor:O,stopOpacity:.8})]},$))}return u},[w,e]),dr=v.useMemo(()=>i.filter(u=>u.style.gradientColor&&u.style.backgroundColor).map(u=>{const _=`nd-grad-${u.id}`,I=u.style.gradientDirection??"vertical";if(I==="radial")return s.jsxs("radialGradient",{id:_,children:[s.jsx("stop",{offset:"0%",stopColor:u.style.backgroundColor}),s.jsx("stop",{offset:"100%",stopColor:u.style.gradientColor})]},_);const j=I==="horizontal"||I==="diagonal"?"1":"0",O=I==="vertical"||I==="diagonal"?"1":"0";return s.jsxs("linearGradient",{id:_,x1:"0",y1:"0",x2:j,y2:O,children:[s.jsx("stop",{offset:"0%",stopColor:u.style.backgroundColor}),s.jsx("stop",{offset:"100%",stopColor:u.style.gradientColor})]},_)}),[i]);return s.jsxs("svg",{ref:N,className:`nice-diagram-canvas ${G??""}`,style:{width:"100%",height:"100%",background:ot,cursor:V?"grabbing":te&&te.nodeId?ft[te.handleIdx].cursor:"default"},onWheel:Ae,onMouseDown:st,onMouseMove:Ge,onMouseUp:Ve,onMouseLeave:Ve,children:[s.jsxs("defs",{children:[s.jsx("marker",{id:"nd-arrow",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:"nd-open-arrow",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:"nd-diamond-marker",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:"nd-circle-marker",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"})}),L&&s.jsx("pattern",{id:"nd-grid",width:Me,height:Me,patternUnits:"userSpaceOnUse",children:s.jsx("path",{d:`M ${Me} 0 L 0 0 0 ${Me}`,fill:"none",stroke:Fe,strokeWidth:"0.5"})}),dr,cr,lr,i.filter(u=>u.style.glowColor).map(u=>{const _=`nd-node-glow-${u.id}`,I=(u.style.glowIntensity??.5)*10;return s.jsxs("filter",{id:_,x:"-50%",y:"-50%",width:"200%",height:"200%",children:[s.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:I,result:"blur"}),s.jsx("feFlood",{floodColor:u.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"})]})]},_)})]}),F&&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},(u,_)=>{const I=_*Me*r.zoom+r.x,j=_*Me;return I>20?s.jsxs("g",{children:[s.jsx("line",{x1:I,y1:"0",x2:I,y2:"20",stroke:"var(--nice-text-muted, #999)",strokeWidth:"0.5"}),s.jsx("text",{x:I+2,y:"14",fontSize:"9",fill:"var(--nice-text-secondary, #666)",children:j})]},`rx${_}`):null}),Array.from({length:100},(u,_)=>{const I=_*Me*r.zoom+r.y,j=_*Me;return I>20?s.jsxs("g",{children:[s.jsx("line",{x1:"0",y1:I,x2:"20",y2:I,stroke:"var(--nice-text-muted, #999)",strokeWidth:"0.5"}),s.jsx("text",{x:"2",y:I-2,fontSize:"9",fill:"var(--nice-text-secondary, #666)",writingMode:"tb",children:j})]},`ry${_}`):null})]}),s.jsxs("g",{transform:`translate(${r.x}, ${r.y}) scale(${r.zoom})`,children:[L&&s.jsx("rect",{x:"-10000",y:"-10000",width:"20000",height:"20000",fill:"url(#nd-grid)"}),t.map(u=>{var Q,J,Z,ie,he,oe,ne,pe,_e,Se,Ce,Ye;const _=i.filter(se=>u.nodeIds.includes(se.id));if(_.length===0&&!u.collapsed)return null;const I=((Q=u.style)==null?void 0:Q.padding)??20;if(u.collapsed){const se=i.find(dt=>u.nodeIds.includes(dt.id)),Te=se?se.position.x:0,Xe=se?se.position.y:0;return s.jsxs("g",{"data-group-id":u.id,style:{cursor:"pointer"},onClick:()=>S==null?void 0:S(u.id),children:[s.jsx("rect",{x:Te,y:Xe,width:160,height:40,fill:((J=u.style)==null?void 0:J.backgroundColor)??"rgba(200,200,255,0.3)",stroke:((Z=u.style)==null?void 0:Z.borderColor)??"var(--nice-text-muted, #aab)",strokeWidth:((ie=u.style)==null?void 0:ie.borderWidth)??1,rx:((he=u.style)==null?void 0:he.borderRadius)??6,strokeDasharray:"6,3"}),s.jsxs("text",{x:Te+24,y:Xe+24,fontSize:"12",fill:((oe=u.style)==null?void 0:oe.labelColor)??"var(--nice-text-secondary, #666)",fontWeight:"bold",children:[u.label," (",u.nodeIds.length,")"]})]},u.id)}const j=Math.min(..._.map(se=>se.position.x))-I,O=Math.min(..._.map(se=>se.position.y))-I,z=Math.max(..._.map(se=>se.position.x+se.size.width))+I,$=Math.max(..._.map(se=>se.position.y+se.size.height))+I;return s.jsxs("g",{"data-group-id":u.id,children:[s.jsx("rect",{x:j,y:O,width:z-j,height:$-O,fill:((ne=u.style)==null?void 0:ne.backgroundColor)??"rgba(200,200,255,0.1)",stroke:((pe=u.style)==null?void 0:pe.borderColor)??"var(--nice-text-muted, #aab)",strokeWidth:((_e=u.style)==null?void 0:_e.borderWidth)??1,rx:((Se=u.style)==null?void 0:Se.borderRadius)??6,strokeDasharray:((Ce=u.style)==null?void 0:Ce.borderStyle)==="dashed"?"6,3":void 0}),s.jsx("text",{x:j+6,y:O-4,fontSize:"12",fill:((Ye=u.style)==null?void 0:Ye.labelColor)??"var(--nice-text-secondary, #666)",fontWeight:"bold",style:T?{cursor:"pointer"}:void 0,onClick:T?se=>{se.stopPropagation(),T(u.id)}:void 0,children:u.label}),(A||y!=="editor")&&S&&s.jsxs("g",{style:{cursor:"pointer"},onClick:se=>{se.stopPropagation(),S(u.id)},children:[s.jsx("rect",{x:z-24,y:O-12,width:20,height:20,rx:4,fill:"white",stroke:"var(--nice-text-muted, #999)",strokeWidth:1}),s.jsx("g",{transform:`translate(${z-20}, ${O-8})`,children:s.jsx(x.NiceIcon,{name:"chevron-down",size:12,color:"var(--nice-text-secondary, #666)"})})]})]},u.id)}),at.map((u,_)=>s.jsx("line",{x1:u.x!=null?u.x:-1e4,y1:u.y!=null?u.y:-1e4,x2:u.x!=null?u.x:1e4,y2:u.y!=null?u.y:1e4,stroke:"#ff4081",strokeWidth:.5,strokeDasharray:"4,4"},`snap-${_}`)),e.map(u=>{var he;const _=sr(u),I=Be.has(u.id),j=u.style.targetArrow==="diamond"?"url(#nd-diamond-marker)":u.style.targetArrow==="circle"?"url(#nd-circle-marker)":u.style.targetArrow==="openArrow"?"url(#nd-open-arrow)":u.style.targetArrow!=="none"?"url(#nd-arrow)":void 0,O=u.style.sourceArrow==="diamond"?"url(#nd-diamond-marker)":u.style.sourceArrow==="circle"?"url(#nd-circle-marker)":u.style.sourceArrow==="openArrow"?"url(#nd-open-arrow)":u.style.sourceArrow==="arrow"?"url(#nd-arrow)":void 0,z=kt(u.id),$=b==null?void 0:b.get(u.id),Q=$==null?void 0:$.strokeProgress,J=Q!=null&&Q>=0&&Q<1?{strokeDasharray:"1000",strokeDashoffset:`${1e3*(1-Q)}`}:void 0,Z=u.style.liquidFlow,ie=w==null?void 0:w.liquidFlows.get(u.id);return s.jsxs("g",{"data-edge-id":u.id,style:z,onClick:oe=>ve(oe,u.id),children:[A&&s.jsx("path",{d:_,fill:"none",stroke:"transparent",strokeWidth:12,style:{cursor:"pointer"}}),(Z==null?void 0:Z.active)&&s.jsx("path",{d:_,fill:"none",stroke:`url(#nd-liquid-${u.id})`,strokeWidth:Z.pipeWidth??(u.style.strokeWidth??1.5)*4,strokeLinecap:"round",opacity:.5}),s.jsx("path",{d:_,fill:"none",stroke:I?xe:u.style.strokeColor??"var(--nice-text, #333)",strokeWidth:u.style.strokeWidth??1.5,strokeDasharray:(J==null?void 0:J.strokeDasharray)??((he=u.style.strokeDash)==null?void 0:he.join(","))??(u.style.animated?"6,4":void 0),strokeDashoffset:J==null?void 0:J.strokeDashoffset,markerEnd:j,markerStart:O,opacity:u.style.opacity??1,style:A?{cursor:"pointer",transition:J?void 0:"stroke-dashoffset 0.1s"}:void 0}),u.style.animated&&s.jsx("circle",{r:3,fill:xe,children:s.jsx("animateMotion",{dur:`${1/(u.style.flowSpeed||1)}s`,repeatCount:"indefinite",path:_})}),(ie==null?void 0:ie.active)&&ie.particles.map((oe,ne)=>s.jsx("circle",{r:oe.size,fill:(Z==null?void 0:Z.color)??"var(--nice-primary, #3b82f6)",opacity:oe.opacity*.6,children:s.jsx("animateMotion",{dur:`${3/(((Z==null?void 0:Z.speed)??1)+.5)}s`,repeatCount:"indefinite",path:_,begin:`${oe.t*3}s`})},`lp-${u.id}-${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:_,begin:`${$.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:_,begin:`${($.particleTrailT+.1)*2}s`})})]}),u.label&&(()=>{const oe=Ee(u.sourceNodeId,u.sourcePortId),ne=Ee(u.targetNodeId,u.targetPortId),pe=(oe.x+ne.x)/2,_e=(oe.y+ne.y)/2;return s.jsxs("g",{children:[s.jsx("rect",{x:pe-4,y:_e-16,width:u.label.length*7+8,height:18,rx:3,fill:"var(--nice-bg-primary, #fff)",fillOpacity:.85}),s.jsx("text",{x:pe,y:_e-2,textAnchor:"start",fontSize:"11",fill:"var(--nice-text-secondary, #555)",children:u.label})]})})()]},u.id)}),i.filter(u=>!u.hidden||y==="editor").map(u=>{const _=Be.has(u.id),I=kt(u.id),j=b==null?void 0:b.get(u.id),O=u.style.fontFamily??(o==null?void 0:o.fontFamily)??"sans-serif",z=u.style.fontSize??14,$=u.style.fontColor??"var(--nice-text, #222)",Q=u.style.fontWeight??"normal",J=u.style.fontStyle??"normal",Z=u.style.textAlign??"center",ie=u.style.rotation??0,he=`nd-grad-${u.id}`,oe=!!u.hidden,ne=oe?M??.3:u.style.opacity??1,pe=u.style.glowColor?`url(#nd-node-glow-${u.id})`:void 0,_e=Z==="left"?"start":Z==="right"?"end":"middle",Se=Z==="left"?8:Z==="right"?u.size.width-8:u.size.width/2,Ce=j==null?void 0:j.typewriterChars,Ye=Ce!=null&&Ce>=0?u.label.slice(0,Ce):u.label,se=j==null?void 0:j.liquidFillProgress,Te=j==null?void 0:j.rippleRadius,Xe=j==null?void 0:j.rippleOpacity,dt=u.childNodeIds&&u.childNodeIds.length>0,ur=!!u.collapsed;return s.jsxs("g",{"data-node-id":u.id,transform:`translate(${u.position.x}, ${u.position.y})${ie?` rotate(${ie}, ${u.size.width/2}, ${u.size.height/2})`:""}`,style:{...I,cursor:oe?"pointer":A&&!u.locked?"grab":"default",opacity:ne,filter:pe},onMouseDown:ge=>nt(ge,u.id),onDoubleClick:ge=>X(ge,u.id),onClick:ge=>{ge.stopPropagation(),l==null||l(u.id),u.interactions&&u.interactions.length>0&&u.interactions.filter(Le=>Le.trigger==="click").forEach(Le=>C==null?void 0:C(u.id,Le.id))},onMouseEnter:()=>{k==null||k(u.id),u.interactions&&u.interactions.filter(Ie=>Ie.trigger==="hover").forEach(Ie=>C==null?void 0:C(u.id,Ie.id))},onMouseLeave:()=>k==null?void 0:k(null),children:[oe&&s.jsx("rect",{x:-1,y:-1,width:u.size.width+2,height:u.size.height+2,fill:"none",stroke:"var(--nice-text-muted, #999)",strokeWidth:1,strokeDasharray:"3,3",rx:4,opacity:.5}),nr(u,he),se!=null&&se>0&&se<1&&s.jsx("clipPath",{id:`nd-liquid-clip-${u.id}`,children:s.jsx("rect",{x:0,y:u.size.height*(1-se),width:u.size.width,height:u.size.height*se})}),se!=null&&se>0&&se<1&&s.jsx("rect",{x:0,y:0,width:u.size.width,height:u.size.height,fill:u.style.glowColor??"var(--nice-primary, #3b82f6)",opacity:.25,rx:u.style.borderRadius??4,clipPath:`url(#nd-liquid-clip-${u.id})`}),Te!=null&&Te>0&&s.jsx("circle",{cx:u.size.width/2,cy:u.size.height/2,r:Te,fill:"none",stroke:u.style.glowColor??xe,strokeWidth:2,opacity:Xe??.5}),_&&s.jsx("rect",{x:-3,y:-3,width:u.size.width+6,height:u.size.height+6,fill:"none",stroke:xe,strokeWidth:2,strokeDasharray:"4,3",rx:6}),_&&A&&!u.locked&&ft.map((ge,Ie)=>s.jsx("rect",{x:ge.dx*u.size.width-Ue/2,y:ge.dy*u.size.height-Ue/2,width:Ue,height:Ue,fill:"white",stroke:xe,strokeWidth:1.5,rx:1,style:{cursor:ge.cursor},onMouseDown:Le=>ct(Le,u.id,Ie)},Ie)),ke===u.id?s.jsx("foreignObject",{x:4,y:4,width:u.size.width-8,height:u.size.height-8,children:s.jsx("input",{xmlns:"http://www.w3.org/1999/xhtml",type:"text",value:Re,onChange:ge=>ye(ge.target.value),onBlur:$e,onKeyDown:ge=>{ge.key==="Enter"&&$e(),ge.key==="Escape"&&je(null)},autoFocus:!0,style:{width:"100%",height:"100%",border:"1px solid "+xe,borderRadius:3,padding:"2px 4px",fontSize:z,fontFamily:O,fontWeight:Q,fontStyle:J,textAlign:Z,background:"var(--nice-overlay-light-95, rgba(255, 255, 255, 0.95))",outline:"none"}})}):s.jsxs(s.Fragment,{children:[s.jsx("text",{x:Se,y:u.size.height/2+(u.description?-4:0),textAnchor:_e,dominantBaseline:"central",fontFamily:O,fontSize:z,fontWeight:Q,fontStyle:J,fill:$,pointerEvents:"none",children:Ye}),u.description&&s.jsx("text",{x:Se,y:u.size.height/2+z*.8,textAnchor:_e,dominantBaseline:"central",fontFamily:O,fontSize:z*.75,fill:"var(--nice-text-secondary, #777)",pointerEvents:"none",children:u.description}),u.icon&&(Ni.test(u.icon)?s.jsx("g",{transform:`translate(${u.size.width/2-8}, 4)`,pointerEvents:"none",children:s.jsx(x.NiceIcon,{name:u.icon,size:16,color:"var(--nice-text-secondary, #666)"})}):s.jsx("text",{x:u.size.width/2,y:14,textAnchor:"middle",fontSize:16,pointerEvents:"none",children:u.icon})),u.style.linkUrl&&s.jsx("g",{transform:`translate(${u.size.width-14}, 3)`,pointerEvents:"none",children:s.jsx(x.NiceIcon,{name:"link",size:10,color:"var(--nice-primary-hover, #1976d2)"})}),dt&&A&&s.jsxs("g",{onClick:ge=>{ge.stopPropagation(),D==null||D(u.id)},style:{cursor:"pointer"},children:[s.jsx("rect",{x:u.size.width-18,y:u.size.height-18,width:16,height:16,rx:3,fill:"white",stroke:"var(--nice-text-muted, #aaa)",strokeWidth:.5}),s.jsx("g",{transform:`translate(${u.size.width-15}, ${u.size.height-15})`,children:s.jsx(x.NiceIcon,{name:ur?"chevron-right":"chevron-down",size:10,color:"var(--nice-text-secondary, #666)"})})]})]}),A&&u.ports.map(ge=>{const Ie=Ii(u,ge.id);return s.jsx("circle",{cx:Ie.x,cy:Ie.y,r:4,fill:"var(--nice-bg, #fff)",stroke:"var(--nice-text-secondary, #666)",strokeWidth:1,style:{cursor:"crosshair"}},ge.id)})]},u.id)}),w&&w.particles.length>0&&s.jsx("g",{className:"nd-particle-overlay",children:w.particles.map((u,_)=>s.jsx("circle",{cx:u.x,cy:u.y,r:u.size,fill:u.color,opacity:u.opacity},`ptcl-${_}`))}),ee&&s.jsx("rect",{x:Math.min(ee.x1,ee.x2),y:Math.min(ee.y1,ee.y2),width:Math.abs(ee.x2-ee.x1),height:Math.abs(ee.y2-ee.y1),fill:"rgba(33,150,243,0.1)",stroke:xe,strokeWidth:1,strokeDasharray:"4,2"})]})]})};function Ii(i,e){const t=i.ports.find(a=>a.id===e);if(!t)return{x:0,y:0};const{size:r}=i;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}}}we.displayName="DiagramCanvas";const zi=180,ji=120,et=({nodes:i,edges:e,viewport:t,onViewportChange:r,canvasWidth:a=800,canvasHeight:o=600,width:c=zi,height:n=ji,className:l})=>{const f=v.useMemo(()=>{if(i.length===0)return{minX:0,minY:0,maxX:400,maxY:300};let b=1/0,w=1/0,y=-1/0,M=-1/0;for(const D of i)b=Math.min(b,D.position.x),w=Math.min(w,D.position.y),y=Math.max(y,D.position.x+D.size.width),M=Math.max(M,D.position.y+D.size.height);const S=50;return{minX:b-S,minY:w-S,maxX:y+S,maxY:M+S}},[i]),d=f.maxX-f.minX,m=f.maxY-f.minY,p=Math.min(c/d,n/m),g=v.useMemo(()=>{const b=(-t.x/t.zoom-f.minX)*p,w=(-t.y/t.zoom-f.minY)*p,y=a/t.zoom*p,M=o/t.zoom*p;return{x:b,y:w,w:y,h:M}},[t,f,p,a,o]),h=v.useCallback(b=>{if(!r)return;const w=b.currentTarget.getBoundingClientRect(),y=b.clientX-w.left,M=b.clientY-w.top,S=y/p+f.minX,D=M/p+f.minY;r({...t,x:-(S*t.zoom-a/2),y:-(D*t.zoom-o/2)})},[r,t,p,f,a,o]);return s.jsxs("svg",{className:`nice-diagram-minimap ${l??""}`,width:c,height:n,style:{border:"1px solid var(--nice-border, #ccc)",background:"var(--nice-bg, #fff)",borderRadius:4,cursor:"pointer"},onClick:h,children:[e.map(b=>{const w=i.find(k=>k.id===b.sourceNodeId),y=i.find(k=>k.id===b.targetNodeId);if(!w||!y)return null;const M=(w.position.x+w.size.width/2-f.minX)*p,S=(w.position.y+w.size.height/2-f.minY)*p,D=(y.position.x+y.size.width/2-f.minX)*p,C=(y.position.y+y.size.height/2-f.minY)*p;return s.jsx("line",{x1:M,y1:S,x2:D,y2:C,stroke:"var(--nice-text-muted, #aaa)",strokeWidth:.5},b.id)}),i.map(b=>s.jsx("rect",{x:(b.position.x-f.minX)*p,y:(b.position.y-f.minY)*p,width:b.size.width*p,height:b.size.height*p,fill:b.style.backgroundColor??"var(--nice-border, #ddd)",stroke:"var(--nice-text-muted, #999)",strokeWidth:.5},b.id)),s.jsx("rect",{x:g.x,y:g.y,width:g.w,height:g.h,fill:"rgba(33,150,243,0.15)",stroke:"var(--nice-primary, #2196f3)",strokeWidth:1})]})};et.displayName="DiagramMinimap";const Ai=["rectangle","roundedRect","ellipse","circle","diamond","hexagon","parallelogram","cylinder","triangle","cloud","document","actor"],tt=({selectedNode:i,selectedEdge:e,onNodeChange:t,onEdgeChange:r,onRemove:a,className:o})=>{var f,d,m,p,g;const{t:c}=We(),n=v.useCallback((h,b)=>{!i||!t||t(i.id,{style:{...i.style,[h]:b}})},[i,t]),l=v.useCallback((h,b)=>{!e||!r||r(e.id,{style:{...e.style,[h]:b}})},[e,r]);return!i&&!e?s.jsx("div",{className:`nice-diagram-property-panel nice-diagram-property-panel--empty ${o??""}`,children:s.jsx("p",{className:"nice-diagram-property-panel__hint",children:c("panel.noSelection")})}):i?s.jsxs("div",{className:`nice-diagram-property-panel ${o??""}`,children:[s.jsx("h3",{className:"nice-diagram-property-panel__title",children:c("panel.nodeProperties")}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[c("node.label"),s.jsx(x.NiceTextInput,{value:i.label,onChange:h=>t==null?void 0:t(i.id,{label:h}),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[c("node.description"),s.jsx(x.NiceTextInput,{value:i.description??"",onChange:h=>t==null?void 0:t(i.id,{description:h||void 0}),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[c("node.shape"),s.jsx(x.NiceSelect,{value:i.shape,onChange:h=>t==null?void 0:t(i.id,{shape:h}),options:Ai.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:[c("node.width"),s.jsx(x.NiceNumberInput,{value:i.size.width,min:20,onChange:h=>t==null?void 0:t(i.id,{size:{...i.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:[c("node.height"),s.jsx(x.NiceNumberInput,{value:i.size.height,min:20,onChange:h=>t==null?void 0:t(i.id,{size:{...i.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:[c("node.bgColor"),s.jsx(x.NiceColorPicker,{value:i.style.backgroundColor??"var(--nice-bg, #fff)",onChange:h=>n("backgroundColor",h),className:"nice-diagram-property-panel__color"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[c("node.borderColor"),s.jsx(x.NiceColorPicker,{value:i.style.borderColor??"var(--nice-text, #333333)",onChange:h=>n("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:[c("node.fontSize"),s.jsx(x.NiceNumberInput,{value:i.style.fontSize??14,min:8,max:72,onChange:h=>n("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:[c("node.fontColor"),s.jsx(x.NiceColorPicker,{value:i.style.fontColor??"#222222",onChange:h=>n("fontColor",h),className:"nice-diagram-property-panel__color"})]})]}),s.jsx(x.NiceCheckbox,{checked:i.locked??!1,onChange:h=>t==null?void 0:t(i.id,{locked:h}),label:c("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:"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:["Glow Color",s.jsx(x.NiceColorPicker,{value:i.style.glowColor??"var(--nice-primary, #3b82f6)",onChange:h=>n("glowColor",h),className:"nice-diagram-property-panel__color"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:["Glow Intensity",s.jsx(x.NiceSlider,{min:0,max:3,step:.1,value:i.style.glowIntensity??0,onChange:h=>n("glowIntensity",h),className:"nice-diagram-property-panel__input"})]})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:["Opacity",s.jsx(x.NiceSlider,{min:0,max:1,step:.05,value:i.style.opacity??1,onChange:h=>n("opacity",h),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:["Border Radius",s.jsx(x.NiceNumberInput,{min:0,max:50,value:i.style.borderRadius??4,onChange:h=>n("borderRadius",h??4),className:"nice-diagram-property-panel__input"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:["Border Width",s.jsx(x.NiceNumberInput,{min:0,max:10,step:.5,value:i.style.borderWidth??1,onChange:h=>n("borderWidth",h??1),className:"nice-diagram-property-panel__input"})]}),s.jsx(x.NiceCheckbox,{checked:i.style.shadow??!1,onChange:h=>n("shadow",h),label:"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:["Gradient End",s.jsx(x.NiceColorPicker,{value:i.style.gradientColor??"var(--nice-bg, #fff)",onChange:h=>n("gradientColor",h),className:"nice-diagram-property-panel__color"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:["Gradient Dir",s.jsx(x.NiceSelect,{value:i.style.gradientDirection??"vertical",onChange:h=>n("gradientDirection",h),options:[{value:"vertical",label:"Vertical"},{value:"horizontal",label:"Horizontal"},{value:"diagonal",label:"Diagonal"},{value:"radial",label:"Radial"}],className:"nice-diagram-property-panel__select"})]})]}),s.jsx(x.NiceCheckbox,{checked:i.hidden??!1,onChange:h=>t==null?void 0:t(i.id,{hidden:h}),label:"Hidden (ghost in editor)",className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),s.jsx(x.NiceButton,{className:"nice-diagram-property-panel__btn nice-diagram-property-panel__btn--danger",variant:"ghost",size:"sm",onClick:()=>a==null?void 0:a(i.id),children:c("toolbar.delete")})]}):e?s.jsxs("div",{className:`nice-diagram-property-panel ${o??""}`,children:[s.jsx("h3",{className:"nice-diagram-property-panel__title",children:c("panel.edgeProperties")}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:[c("edge.label"),s.jsx(x.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:[c("edge.lineType"),s.jsx(x.NiceSelect,{value:e.style.lineType??"bezier",onChange:h=>l("lineType",h),options:[{value:"straight",label:"Straight"},{value:"bezier",label:"Bezier"},{value:"orthogonal",label:"Orthogonal"},{value:"step",label:"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:[c("edge.color"),s.jsx(x.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:[c("edge.width"),s.jsx(x.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(x.NiceCheckbox,{checked:e.style.animated??!1,onChange:h=>l("animated",h),label:c("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:["Flow Speed",s.jsx(x.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:["Dash Style",s.jsx(x.NiceSelect,{value:e.style.strokeDash?e.style.strokeDash.join(","):"solid",onChange:h=>{const b=h;b==="solid"?l("strokeDash",[]):l("strokeDash",b.split(",").map(Number))},options:[{value:"solid",label:"Solid"},{value:"6,4",label:"Dashed"},{value:"2,2",label:"Dotted"},{value:"8,4,2,4",label:"Dash-Dot"},{value:"12,6",label:"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:["Target Arrow",s.jsx(x.NiceSelect,{value:e.style.targetArrow??"arrow",onChange:h=>l("targetArrow",h),options:[{value:"arrow",label:"Arrow"},{value:"openArrow",label:"Open Arrow"},{value:"diamond",label:"Diamond"},{value:"circle",label:"Circle"},{value:"none",label:"None"}],className:"nice-diagram-property-panel__select"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:["Source Arrow",s.jsx(x.NiceSelect,{value:e.style.sourceArrow??"none",onChange:h=>l("sourceArrow",h),options:[{value:"none",label:"None"},{value:"arrow",label:"Arrow"},{value:"openArrow",label:"Open Arrow"},{value:"diamond",label:"Diamond"},{value:"circle",label:"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:"Liquid Flow"}),s.jsx(x.NiceCheckbox,{checked:((f=e.style.liquidFlow)==null?void 0:f.active)??!1,onChange:h=>{const b=e.style.liquidFlow??{active:!1,color:"var(--nice-primary, #3b82f6)",speed:1,pipeWidth:6};r==null||r(e.id,{style:{...e.style,liquidFlow:{...b,active:h}}})},label:"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:["Color",s.jsx(x.NiceColorPicker,{value:((m=e.style.liquidFlow)==null?void 0:m.color)??"var(--nice-primary, #3b82f6)",onChange:h=>{const b=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...b,color:h}}})},className:"nice-diagram-property-panel__color"})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:["Speed",s.jsx(x.NiceSlider,{min:.1,max:5,step:.1,value:((p=e.style.liquidFlow)==null?void 0:p.speed)??1,onChange:h=>{const b=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...b,speed:h}}})},className:"nice-diagram-property-panel__input"})]})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:["Pipe Width",s.jsx(x.NiceNumberInput,{min:2,max:20,value:((g=e.style.liquidFlow)==null?void 0:g.pipeWidth)??6,onChange:h=>{const b=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...b,pipeWidth:h??6}}})},className:"nice-diagram-property-panel__input"})]})]}),s.jsxs("label",{className:"nice-diagram-property-panel__label",children:["Opacity",s.jsx(x.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(x.NiceButton,{className:"nice-diagram-property-panel__btn nice-diagram-property-panel__btn--danger",variant:"ghost",size:"sm",onClick:()=>a==null?void 0:a(e.id),children:c("toolbar.delete")})]}):null};tt.displayName="DiagramPropertyPanel";const Nt={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","forceDirected","grid","radial","tree"],Di=["sans-serif","serif","monospace","Arial","Helvetica","Times New Roman","Courier New","Georgia","Verdana","Tahoma","Trebuchet MS"],Ti=[8,9,10,11,12,14,16,18,20,24,28,32,36,48,72],rt=({activeTool:i,onToolChange:e,diagramType:t,onAddNode:r,onApplyLayout:a,onUndo:o,onRedo:c,canUndo:n=!1,canRedo:l=!1,onExport:f,onZoomIn:d,onZoomOut:m,onZoomReset:p,zoomLevel:g=1,onToggleBold:h,onToggleItalic:b,isBold:w=!1,isItalic:y=!1,onFontFamilyChange:M,currentFontFamily:S="sans-serif",onFontSizeChange:D,currentFontSize:C=14,onAlignLeft:k,onAlignCenterH:T,onAlignRight:A,onAlignTop:L,onAlignCenterV:F,onAlignBottom:Y,onDistributeH:W,onDistributeV:G,onBringToFront:N,onSendToBack:V,onGroupSelected:P,onUngroupSelected:q,onCopy:R,onPaste:B,onDuplicate:U,onSelectAll:K,selectionCount:ue=0,onFind:ee,showFind:E=!1,findQuery:H="",onFindQueryChange:fe,viewMode:te="editor",onViewModeChange:ce,stylePresetId:ke,onStylePresetChange:je,className:Re})=>{const{t:ye}=We(),[at,Oe]=v.useState(!1),[ot,Fe]=v.useState(!1),[Me,xe]=v.useState(!1),[Be,me]=v.useState(!1),[qe,Ae]=v.useState(!1),[st,Ge]=v.useState(!1),Ve=Nt[t]??Nt.custom,nt=v.useCallback(X=>{r==null||r(X),Oe(!1)},[r]),ct=v.useCallback(X=>{a==null||a(X),Fe(!1)},[a]);return s.jsxs("div",{className:`nice-diagram-toolbar ${Re??""}`,children:[s.jsxs("div",{className:"nice-diagram-toolbar__row",children:[s.jsxs("div",{className:"nice-diagram-toolbar__group",children:[s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:i==="select"?"primary":"ghost",size:"sm",onClick:()=>e("select"),title:`${ye("toolbar.select")} (V)`,children:s.jsx(x.NiceIcon,{name:"cursor",size:14})}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:i==="pan"?"primary":"ghost",size:"sm",onClick:()=>e("pan"),title:`${ye("toolbar.pan")} (H)`,children:s.jsx(x.NiceIcon,{name:"move",size:14})}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:i==="addEdge"?"primary":"ghost",size:"sm",onClick:()=>e("addEdge"),title:`${ye("toolbar.addEdge")} (C)`,children:s.jsx(x.NiceIcon,{name:"link",size:14})}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:i==="text"?"primary":"ghost",size:"sm",onClick:()=>e("text"),title:"Text (T)",children:s.jsx(x.NiceIcon,{name:"type",size:14})}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:i==="freehand"?"primary":"ghost",size:"sm",onClick:()=>e("freehand"),title:"Freehand (F)",children:s.jsx(x.NiceIcon,{name:"pen",size:14})}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:i==="delete"?"primary":"ghost",size:"sm",onClick:()=>e("delete"),title:`${ye("toolbar.delete")} (Del)`,children:s.jsx(x.NiceIcon,{name:"trash",size:14})})]}),s.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:i==="addNode"?"primary":"ghost",size:"sm",onClick:()=>Oe(X=>!X),title:ye("toolbar.addNode"),children:[s.jsx(x.NiceIcon,{name:"plus",size:14})," ",ye("toolbar.addNode")]}),at&&s.jsx("div",{className:"nice-diagram-toolbar__dropdown nice-diagram-toolbar__dropdown--shapes",children:Ve.map(X=>s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>nt(X),children:[s.jsx(x.NiceIcon,{name:Pi(X),size:14})," ",X]},X))})]}),s.jsxs("div",{className:"nice-diagram-toolbar__group",children:[s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:R,title:"Copy (Ctrl+C)",children:s.jsx(x.NiceIcon,{name:"copy",size:14})}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:B,title:"Paste (Ctrl+V)",children:s.jsx(x.NiceIcon,{name:"clipboard",size:14})}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:U,title:"Duplicate (Ctrl+D)",children:s.jsx(x.NiceIcon,{name:"layers",size:14})}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:K,title:"Select All (Ctrl+A)",children:s.jsx(x.NiceIcon,{name:"check-square",size:14})})]}),s.jsxs("div",{className:"nice-diagram-toolbar__group",children:[s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:o,disabled:!n,title:`${ye("toolbar.undo")} (Ctrl+Z)`,children:s.jsx(x.NiceIcon,{name:"undo",size:14})}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:c,disabled:!l,title:`${ye("toolbar.redo")} (Ctrl+Y)`,children:s.jsx(x.NiceIcon,{name:"redo",size:14})})]}),s.jsxs("div",{className:"nice-diagram-toolbar__group",children:[s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:m,title:ye("toolbar.zoomOut"),children:s.jsx(x.NiceIcon,{name:"minus",size:14})}),s.jsxs("span",{className:"nice-diagram-toolbar__zoom-label",children:[Math.round(g*100),"%"]}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:d,title:ye("toolbar.zoomIn"),children:s.jsx(x.NiceIcon,{name:"plus",size:14})}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:p,title:ye("toolbar.zoomReset"),children:"1:1"})]}),s.jsxs("div",{className:"nice-diagram-toolbar__group",children:[s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:ee,title:"Find (Ctrl+F)",children:s.jsx(x.NiceIcon,{name:"search",size:14})}),E&&s.jsx(x.NiceTextInput,{className:"nice-diagram-toolbar__search",placeholder:"Search nodes…",value:H,onChange:X=>fe==null?void 0:fe(X),autoFocus:!0})]}),s.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>xe(X=>!X),title:ye("toolbar.export"),children:[s.jsx(x.NiceIcon,{name:"download",size:14})," ",ye("toolbar.export")]}),Me&&s.jsxs("div",{className:"nice-diagram-toolbar__dropdown",children:[s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{f==null||f("ndd"),xe(!1)},children:".ndd.json"}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{f==null||f("svg"),xe(!1)},children:"SVG"}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{f==null||f("mermaid"),xe(!1)},children:"Mermaid"}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{f==null||f("png"),xe(!1)},children:"PNG"})]})]})]}),s.jsxs("div",{className:"nice-diagram-toolbar__row nice-diagram-toolbar__format-bar",children:[s.jsxs("div",{className:"nice-diagram-toolbar__group",children:[s.jsx(x.NiceSelect,{className:"nice-diagram-toolbar__font-select",value:S,onChange:X=>M==null?void 0:M(X),options:Di.map(X=>({value:X,label:X})),title:"Font Family"}),s.jsx(x.NiceSelect,{className:"nice-diagram-toolbar__size-select",value:String(C),onChange:X=>D==null?void 0:D(Number(X)),options:Ti.map(X=>({value:String(X),label:String(X)})),title:"Font Size"})]}),s.jsxs("div",{className:"nice-diagram-toolbar__group",children:[s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:w?"primary":"ghost",size:"sm",onClick:h,title:"Bold (Ctrl+B)",children:s.jsx("strong",{children:"B"})}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:y?"primary":"ghost",size:"sm",onClick:b,title:"Italic (Ctrl+I)",children:s.jsx("em",{children:"I"})})]}),s.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>me(X=>!X),title:"Alignment & Distribution",children:"≡ Align"}),Be&&s.jsxs("div",{className:"nice-diagram-toolbar__dropdown nice-diagram-toolbar__dropdown--align",children:[s.jsx("div",{className:"nice-diagram-toolbar__dropdown-section",children:"Align"}),s.jsxs("div",{className:"nice-diagram-toolbar__dropdown-row",children:[s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{k==null||k(),me(!1)},title:"Align Left",children:[s.jsx(x.NiceIcon,{name:"align-left",size:14})," Left"]}),s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{T==null||T(),me(!1)},title:"Align Center",children:[s.jsx(x.NiceIcon,{name:"align-center",size:14})," Center"]}),s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{A==null||A(),me(!1)},title:"Align Right",children:[s.jsx(x.NiceIcon,{name:"align-right",size:14})," Right"]})]}),s.jsxs("div",{className:"nice-diagram-toolbar__dropdown-row",children:[s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{L==null||L(),me(!1)},title:"Align Top",children:[s.jsx(x.NiceIcon,{name:"align-top",size:14})," Top"]}),s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{F==null||F(),me(!1)},title:"Align Middle",children:[s.jsx(x.NiceIcon,{name:"align-middle",size:14})," Middle"]}),s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{Y==null||Y(),me(!1)},title:"Align Bottom",children:[s.jsx(x.NiceIcon,{name:"align-bottom",size:14})," Bottom"]})]}),s.jsx("div",{className:"nice-diagram-toolbar__dropdown-section",children:"Distribute"}),s.jsxs("div",{className:"nice-diagram-toolbar__dropdown-row",children:[s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{W==null||W(),me(!1)},title:"Distribute Horizontally",children:[s.jsx(x.NiceIcon,{name:"distribute-h",size:14})," H"]}),s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{G==null||G(),me(!1)},title:"Distribute Vertically",children:[s.jsx(x.NiceIcon,{name:"distribute-v",size:14})," V"]})]})]})]}),s.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>Ae(X=>!X),title:"Arrange",children:[s.jsx(x.NiceIcon,{name:"menu",size:14})," Arrange"]}),qe&&s.jsxs("div",{className:"nice-diagram-toolbar__dropdown",children:[s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{N==null||N(),Ae(!1)},children:"↑ Bring to Front"}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{V==null||V(),Ae(!1)},children:"↓ Send to Back"}),s.jsx("div",{className:"nice-diagram-toolbar__dropdown-divider"}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{P==null||P(),Ae(!1)},disabled:ue<2,children:"⊞ Group"}),s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{q==null||q(),Ae(!1)},children:"⊟ Ungroup"})]})]}),s.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>Fe(X=>!X),title:ye("toolbar.layout"),children:["⊞ ",ye("toolbar.layout")]}),ot&&s.jsx("div",{className:"nice-diagram-toolbar__dropdown",children:$i.map(X=>s.jsx(x.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>ct(X),children:ye(`layout.${X}`)},X))})]}),ue>1&&s.jsxs("span",{className:"nice-diagram-toolbar__selection-info",children:[ue," selected"]}),s.jsxs("div",{className:"nice-diagram-toolbar__group",children:[s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:te==="editor"?"primary":"ghost",size:"sm",onClick:()=>ce==null?void 0:ce("editor"),title:"Editor Mode",children:[s.jsx(x.NiceIcon,{name:"edit",size:14})," Editor"]}),s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:te==="player"?"primary":"ghost",size:"sm",onClick:()=>ce==null?void 0:ce("player"),title:"Player Mode",children:[s.jsx(x.NiceIcon,{name:"play",size:14})," Player"]}),s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:te==="playerAnimated"?"primary":"ghost",size:"sm",onClick:()=>ce==null?void 0:ce("playerAnimated"),title:"Animated Player Mode",children:[s.jsx(x.NiceIcon,{name:"zap",size:14})," Animated"]})]}),s.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[s.jsxs(x.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>Ge(X=>!X),title:"Style Presets",children:[s.jsx(x.NiceIcon,{name:"palette",size:14})," Style"]}),st&&s.jsx("div",{className:"nice-diagram-toolbar__dropdown nice-diagram-toolbar__dropdown--presets",style:{maxHeight:320,overflowY:"auto",width:220},children:Object.entries(Ke.reduce((X,$e)=>{const ve=$e.category??"Other";return X[ve]||(X[ve]=[]),X[ve].push($e),X},{})).map(([X,$e])=>s.jsxs("div",{children:[s.jsx("div",{className:"nice-diagram-toolbar__dropdown-section",style:{fontSize:10,color:"var(--nice-text-secondary, #888)",padding:"6px 8px 2px",textTransform:"uppercase"},children:X}),$e.map(ve=>s.jsxs(x.NiceButton,{className:`nice-diagram-toolbar__dropdown-item ${ke===ve.id?"nice-diagram-toolbar__dropdown-item--active":""}`,variant:ke===ve.id?"primary":"ghost",size:"sm",onClick:()=>{je==null||je(ve.id),Ge(!1)},style:{display:"flex",alignItems:"center",gap:8},children:[s.jsx("span",{style:{width:16,height:16,borderRadius:3,background:ve.config.palette.primary,border:"1px solid "+(ve.config.palette.border??"var(--nice-border, #ccc)"),display:"inline-block",flexShrink:0}}),s.jsx("span",{style:{fontSize:12},children:ve.name})]},ve.id))]},X))})]})]})]})};function Pi(i){switch(i){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"}}rt.displayName="DiagramToolbar";const Ri=[{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"}],Ft=({initialDocument:i,diagramType:e="flowchart",onChange:t,onExport:r,lang:a="en",showToolbar:o=!0,showPropertyPanel:c=!0,showMinimap:n=!0,showTimeline:l=!0,className:f,style:d,tutorial:m})=>{var ee;const p=Lt(i),[g,h]=v.useState("select"),[b,w]=v.useState(null),y=v.useRef(null),[M,S]=v.useState("editor"),D=v.useRef(null),[C,k]=v.useState({particles:[],liquidFlows:new Map,glowStates:new Map});v.useEffect(()=>{const E=new At(H=>{k(H)});return D.current=E,E.start(),()=>{E.stop(),D.current=null}},[]),v.useEffect(()=>{var H;const E=D.current;if(E)for(const fe of p.edges)(H=fe.style.liquidFlow)!=null&&H.active?E.startLiquidFlow(fe.id,fe.style.liquidFlow):E.stopLiquidFlow(fe.id)},[p.edges]),v.useEffect(()=>{const E=D.current;if(E)for(const H of p.nodes)H.style.glowColor?E.setGlow(H.id,H.style.glowColor,H.style.glowIntensity??1):E.removeGlow(H.id)},[p.nodes]);const T=v.useCallback(E=>{p.setStylePreset(E)},[p]),A=v.useCallback((E,H)=>{const fe=p.nodes.find(ce=>ce.id===E);if(!(fe!=null&&fe.interactions))return;const te=fe.interactions.find(ce=>ce.id===H);if(te)switch(te.action){case"reveal":{if(te.targetId){const ce=p.nodes.find(ke=>ke.id===te.targetId);ce!=null&&ce.hidden&&p.updateNode(te.targetId,{hidden:!1})}break}case"navigate":{if(te.targetId){const ce=p.nodes.find(ke=>ke.id===te.targetId);ce&&(p.setViewport({x:-ce.position.x+300,y:-ce.position.y+200,zoom:p.viewport.zoom}),w(te.targetId))}break}case"switchAnimationMode":{te.targetId&&p.setActiveAnimationMode(te.targetId);break}case"highlight":{te.targetId&&w(te.targetId);break}case"toggleCollapse":{p.toggleNodeCollapse(E);break}}},[p]),L=v.useRef(p.document);p.document!==L.current&&(L.current=p.document,t==null||t(p.document));const F=v.useMemo(()=>b?p.nodes.find(E=>E.id===b)??null:null,[b,p.nodes]),Y=v.useMemo(()=>b?p.edges.find(E=>E.id===b)??null:null,[b,p.edges]),W=v.useCallback(E=>{const H=p.viewport,fe=(-H.x+400)/H.zoom,te=(-H.y+300)/H.zoom,ce=p.addNode("New Node",{x:fe,y:te},E);w(ce.id),h("select")},[p]),G=v.useCallback(E=>{p.applyLayout({algorithm:E,centerGraph:!0})},[p]),N=v.useCallback((E,H)=>{p.moveNode(E,H)},[p]),V=v.useCallback((E,H)=>{p.moveNode(E,H)},[p]),P=v.useCallback(E=>{p.nodes.find(H=>H.id===E)?p.removeNode(E):p.edges.find(H=>H.id===E)&&p.removeEdge(E),w(null)},[p]),q=v.useCallback(E=>{const H=p.document;let fe;switch(E){case"ndd":fe=Rt(H,!0);break;case"svg":fe=pt(H);break;case"mermaid":fe=Tt(H);break;case"png":fe=pt(H);break}r==null||r(E,fe)},[p,r]),R=v.useCallback(()=>{p.setViewport({...p.viewport,zoom:Math.min(5,p.viewport.zoom*1.2)})},[p]),B=v.useCallback(()=>{p.setViewport({...p.viewport,zoom:Math.max(.1,p.viewport.zoom/1.2)})},[p]),U=v.useCallback(()=>{p.setViewport({x:0,y:0,zoom:1})},[p]),K=v.useMemo(()=>[...p.nodes.map(E=>({id:E.id,label:E.label,type:"node"})),...p.edges.map(E=>({id:E.id,label:E.label??E.id,type:"edge"}))],[p.nodes,p.edges]),ue=o||p.animationModes.length>0?s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,width:"100%"},children:[o&&s.jsx(rt,{activeTool:g,onToolChange:h,diagramType:p.document.diagramType,onAddNode:W,onApplyLayout:G,onUndo:p.undo,onRedo:p.redo,canUndo:p.canUndo,canRedo:p.canRedo,onExport:q,onZoomIn:R,onZoomOut:B,onZoomReset:U,viewMode:M,onViewModeChange:S,stylePresetId:p.stylePresetId,onStylePresetChange:T}),p.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:"Modes:"}),p.animationModes.map(E=>{var H;return s.jsx(x.NiceButton,{variant:((H=p.activeAnimationMode)==null?void 0:H.id)===E.id?"primary":"ghost",size:"sm",onClick:()=>p.setActiveAnimationMode(E.id),style:{padding:"2px 10px",fontSize:11},children:E.name},E.id)}),s.jsx(x.NiceButton,{variant:"ghost",size:"sm",onClick:()=>p.addAnimationMode(`Mode ${p.animationModes.length+1}`),style:{padding:"2px 8px",fontSize:11,color:"var(--nice-text-secondary, #888)"},title:"Add animation mode",children:"+"})]})]}):void 0;return s.jsx(mt,{locale:a,children:s.jsxs(x.NiceAppShell,{ref:y,flush:!0,className:`nice-diagram-editor ${f??""}`,style:{position:"relative",...d},toolbar:ue,rightSidebar:c?s.jsx("div",{className:"nice-diagram-editor__panel",style:{width:260,overflowY:"auto",height:"100%"},children:s.jsx(tt,{selectedNode:F,selectedEdge:Y,onNodeChange:p.updateNode,onEdgeChange:p.updateEdge,onRemove:P})}):void 0,bottomPanel:l?s.jsx("div",{className:"nice-diagram-editor__timeline",children:s.jsx(Qe,{animations:p.animations,onAdd:p.addAnimation,onRemove:p.removeAnimation,availableTargets:K})}):void 0,children:[s.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:s.jsx(x.NiceTutorialButton,{steps:x.resolveTutorial(m,Ri)})}),s.jsxs("div",{className:"nice-diagram-editor__canvas",style:{height:"100%",position:"relative"},children:[s.jsx(we,{nodes:p.nodes,edges:p.edges,groups:p.groups,viewport:p.viewport,onViewportChange:p.setViewport,selectedId:b,onSelectElement:w,onNodeDrag:N,onNodeDragEnd:V,interactive:M==="editor",showGrid:M==="editor",particleState:C,viewMode:M,ghostOpacity:((ee=p.playerConfig)==null?void 0:ee.ghostOpacity)??.3,onGroupCollapse:p.toggleGroupCollapse,onNodeCollapse:p.toggleNodeCollapse,onInteraction:A}),n&&s.jsx("div",{style:{position:"absolute",bottom:8,left:8},children:s.jsx(et,{nodes:p.nodes,edges:p.edges,viewport:p.viewport,onViewportChange:p.setViewport})})]})]})})};Ft.displayName="NiceDiagramEditor";const Mt={linear:i=>i,easeIn:i=>i*i,easeOut:i=>i*(2-i),easeInOut:i=>i<.5?2*i*i:-1+(4-2*i)*i,spring:i=>1-Math.cos(i*Math.PI*.5)*Math.exp(-6*i),bounce:i=>{if(i<1/2.75)return 7.5625*i*i;if(i<2/2.75){const t=i-.5454545454545454;return 7.5625*t*t+.75}if(i<2.5/2.75){const t=i-.8181818181818182;return 7.5625*t*t+.9375}const e=i-2.625/2.75;return 7.5625*e*e+.984375}};function Bt(i){return Mt[i]??Mt.linear}const qt={opacity:1,scale:1,translateX:0,translateY:0,glow:0,highlightColor:"",strokeProgress:1,rippleRadius:0,rippleOpacity:0,typewriterChars:-1,liquidFillProgress:-1,particleTrailT:-1};class Gt{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 a=!1;for(const o of this.animations){const c=o.startMs+(o.delayMs??0);c+o.durationMs;const n=o.repeat??0;let l=r-c;if(l<0){this.stateMap.set(o.targetId,Ei(o)),a=!0;continue}if(n===-1)l=l%o.durationMs,a=!0;else if(n>0){const p=o.durationMs*(n+1);if(l>p)continue;l=l%o.durationMs,a=!0}else{if(l>o.durationMs)continue;a=!0}const f=Math.min(l/o.durationMs,1),d=Bt(o.easing)(f),m=Oi(o,d);this.stateMap.set(o.targetId,m)}this.onFrame(this.stateMap),a?this.rafId=requestAnimationFrame(this.tick):this.playing=!1},this.animations=[...e].sort((r,a)=>r.startMs-a.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 Oi(i,e){const t={...qt};switch(i.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 Ei(i){const e={...qt};switch(i.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 Li(i){return{rectangle:"rectangle",roundedRect:"roundedRect",ellipse:"ellipse",circle:"circle",diamond:"diamond",hexagon:"hexagon",cylinder:"cylinder",cloud:"cloud",triangle:"triangle"}[i||"rectangle"]||"rectangle"}function Wi(i){return i?{backgroundColor:i.fill,borderColor:i.stroke,borderWidth:i.strokeWidth,fontColor:i.fontColor,fontSize:i.fontSize,borderRadius:i.borderRadius,borderStyle:i.strokeDasharray?"dashed":"solid"}:{}}function Fi(i){if(!i)return{};let e="straight";return i.lineType==="orthogonal"?e="orthogonal":i.lineType==="curved"||i.lineType==="bezier"?e="bezier":i.lineType==="step"&&(e="step"),{strokeColor:i.stroke,strokeWidth:i.strokeWidth,strokeDash:i.strokeDasharray?i.strokeDasharray.split(",").map(Number):void 0,lineType:e,sourceArrow:"none",targetArrow:i.arrowHead?"arrow":"none",opacity:i.opacity}}function Bi(i){if(i)return{backgroundColor:i.fill,borderColor:i.stroke,borderWidth:i.strokeWidth}}function Vt(i){return{id:i.id,label:i.label,position:{x:i.x,y:i.y},size:{width:i.width,height:i.height},shape:Li(i.shape),style:Wi(i.style),ports:(i.ports||[]).map((e,t)=>({id:e.id,side:e.position||"right",offset:.5})),data:i.data}}function Yt(i,e){var c,n;const t=e.find(l=>l.id===i.source),r=e.find(l=>l.id===i.target),a=i.sourcePort||((c=t==null?void 0:t.ports[0])==null?void 0:c.id)||`${i.source}-out`,o=i.targetPort||((n=r==null?void 0:r.ports[0])==null?void 0:n.id)||`${i.target}-in`;return{id:i.id,sourceNodeId:i.source,sourcePortId:a,targetNodeId:i.target,targetPortId:o,label:i.label,style:Fi(i.style),data:i.data}}function Xt(i){return{id:i.id,label:i.label,nodeIds:i.nodeIds,style:Bi(i.style)}}function Ut(i){var e;return{id:i.id,name:i.id,targetId:i.targetId||((e=i.targets)==null?void 0:e[0])||"",targetType:"node",effect:i.type==="highlight"?"highlight":"fadeIn",startMs:i.delay,durationMs:i.duration,easing:"easeInOut"}}function ze(i){const e=i.nodes.map(Vt);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:i.id,title:i.title,diagramType:i.diagramType,nodes:e,edges:i.edges.map(t=>Yt(t,e)),groups:(i.groups||[]).map(Xt),animations:(i.animations||[]).map(Ut),viewport:{x:0,y:0,zoom:1},metadata:{createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),...i.metadata}}}const qi=ze({id:"empty",title:"",diagramType:"flowchart",nodes:[],edges:[]}),bt=({document:i=qi,lang:e="en",autoPlay:t=!1,showControls:r,showGrid:a,showWorkspace:o=!1,className:c,style:n})=>{const l=r??o,f=a??o,[d,m]=v.useState({...i.viewport}),[p,g]=v.useState(new Map),[h,b]=v.useState(!1),w=v.useRef(null),y=v.useCallback(()=>{w.current&&w.current.stop();const k=new Gt(i.animations,T=>{g(new Map(T)),k.isPlaying()||b(!1)});w.current=k,k.play(),b(!0)},[i.animations]),M=v.useCallback(()=>{var k;(k=w.current)==null||k.stop(),b(!1),g(new Map)},[]);v.useEffect(()=>(t&&i.animations.length>0&&y(),()=>{var k;(k=w.current)==null||k.stop()}),[t]);const S=v.useCallback(()=>m(k=>({...k,zoom:Math.min(5,k.zoom*1.2)})),[]),D=v.useCallback(()=>m(k=>({...k,zoom:Math.max(.1,k.zoom/1.2)})),[]),C=v.useCallback(()=>m({x:0,y:0,zoom:1}),[]);return s.jsx(mt,{locale:e,children:s.jsxs("div",{className:`nice-diagram-viewer ${c??""}`,style:{display:"flex",flexDirection:"column",height:"100%",...n},children:[l&&s.jsx(Gi,{isPlaying:h,hasAnimations:i.animations.length>0,onPlay:y,onStop:M,onZoomIn:S,onZoomOut:D,onZoomReset:C}),s.jsx("div",{style:{flex:1,position:"relative"},children:s.jsx(we,{nodes:i.nodes,edges:i.edges,groups:i.groups,viewport:d,onViewportChange:m,theme:i.theme,animationStates:p,interactive:!1,showGrid:f})})]})})},Gi=({isPlaying:i,hasAnimations:e,onPlay:t,onStop:r,onZoomIn:a,onZoomOut:o,onZoomReset:c})=>{const{t:n}=We();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&&(i?s.jsxs(x.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:r,children:[s.jsx(x.NiceIcon,{name:"stop",size:14})," ",n("animation.stop")]}):s.jsxs(x.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:t,children:[s.jsx(x.NiceIcon,{name:"play",size:14})," ",n("animation.play")]})),s.jsx("span",{style:{flex:1}}),s.jsx(x.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:a,"aria-label":"Zoom in",children:s.jsx(x.NiceIcon,{name:"plus",size:14})}),s.jsx(x.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:o,"aria-label":"Zoom out",children:s.jsx(x.NiceIcon,{name:"minus",size:14})}),s.jsx(x.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:c,children:"1:1"})]})};bt.displayName="NiceDiagramViewer";const Vi="_cell_95fwm_9",Yi="_expandable_95fwm_29",Xi="_svg_95fwm_57",Ui="_emptyText_95fwm_67",Hi="_badge_95fwm_79",Ji="_expandIcon_95fwm_117",Zi="_modalOverlay_95fwm_169",Ki="_modalContent_95fwm_217",Qi="_modalHeader_95fwm_267",ea="_modalTitle_95fwm_285",ta="_modalClose_95fwm_299",ra="_modalBody_95fwm_337",ia="_modalSvg_95fwm_357",aa="_modalFooter_95fwm_371",oa="_modalInfo_95fwm_389",be={cell:Vi,expandable:Yi,svg:Xi,emptyText:Ui,badge:Hi,expandIcon:Ji,modalOverlay:Zi,modalContent:Ki,modalHeader:Qi,modalTitle:ea,modalClose:ta,modalBody:ra,modalSvg:ia,modalFooter:aa,modalInfo:oa},sa=120,na=48,ca=4,St={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 xt(i){if(i.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,a=-1/0;for(const o of i){const c=o.position.x,n=o.position.y,l=o.position.x+o.size.width,f=o.position.y+o.size.height;c<e&&(e=c),n<t&&(t=n),l>r&&(r=l),f>a&&(a=f)}return{minX:e,minY:t,maxX:r,maxY:a,width:r-e,height:a-t}}function Ht(i){var t;if((t=i.style)!=null&&t.backgroundColor)return i.style.backgroundColor;const e=i.shape??"default";return St[e]??St.default}function Jt(i,e){const t=e.get(i.sourceNodeId),r=e.get(i.targetNodeId);if(!t||!r)return null;const a=t.position.x+t.size.width/2,o=t.position.y+t.size.height/2,c=r.position.x+r.size.width/2,n=r.position.y+r.size.height/2;return`M ${a} ${o} L ${c} ${n}`}function la(i,e){const t=xt(i);return{version:"1.0",id:`mini-diagram-${Date.now()}`,title:"Mini Diagram",diagramType:"flowchart",nodes:i,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 da=({document:i,onClose:e})=>{const t=xt(i.nodes),r=40,a=t.width+r*2,o=t.height+r*2,c=v.useMemo(()=>new Map(i.nodes.map(n=>[n.id,n])),[i.nodes]);return s.jsx("div",{className:be.modalOverlay,onClick:e,children:s.jsxs("div",{className:be.modalContent,onClick:n=>n.stopPropagation(),children:[s.jsxs("div",{className:be.modalHeader,children:[s.jsx("h3",{className:be.modalTitle,children:i.title||"Diagram"}),s.jsx("button",{className:be.modalClose,onClick:e,children:s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",children:s.jsx("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),s.jsx("div",{className:be.modalBody,children:s.jsxs("svg",{viewBox:`${t.minX-r} ${t.minY-r} ${a} ${o}`,className:be.modalSvg,children:[i.edges.map(n=>{var f,d,m;const l=Jt(n,c);return l?s.jsx("path",{d:l,stroke:((f=n.style)==null?void 0:f.strokeColor)??"var(--nice-text-secondary, #64748b)",strokeWidth:((d=n.style)==null?void 0:d.strokeWidth)??1.5,fill:"none",markerEnd:(m=n.style)!=null&&m.targetArrow&&n.style.targetArrow!=="none"?"url(#arrowhead-modal)":void 0},n.id):null}),i.nodes.map(n=>{var l,f;return s.jsxs("g",{children:[s.jsx("rect",{x:n.position.x,y:n.position.y,width:n.size.width,height:n.size.height,rx:((l=n.style)==null?void 0:l.borderRadius)??4,fill:Ht(n),stroke:((f=n.style)==null?void 0:f.borderColor)??"var(--nice-text, #1e293b)",strokeWidth:1}),s.jsx("text",{x:n.position.x+n.size.width/2,y:n.position.y+n.size.height/2,textAnchor:"middle",dominantBaseline:"middle",fill:"var(--nice-color-white, #fff)",fontSize:12,fontFamily:"system-ui, sans-serif",children:n.label.substring(0,30)})]},n.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:be.modalFooter,children:s.jsxs("span",{className:be.modalInfo,children:[i.nodes.length," nodes • ",i.edges.length," edges"]})})]})})},ua=({document:i,nodes:e,edges:t,width:r=sa,height:a=na,showCount:o=!0,expandable:c=!0,onExpand:n,padding:l=ca,backgroundColor:f="transparent",borderRadius:d=4,showLabels:m=!1,edgeColor:p="var(--nice-text-muted, #94a3b8)",tooltip:g})=>{const[h,b]=v.useState(!1),w=v.useMemo(()=>i||(e||t?la(e??[],t??[]):null),[i,e,t]),y=v.useMemo(()=>w?new Map(w.nodes.map(T=>[T.id,T])):new Map,[w]),{bounds:M,scale:S,translateX:D,translateY:C}=v.useMemo(()=>{if(!w||w.nodes.length===0)return{bounds:{minX:0,minY:0,width:100,height:100},scale:1,translateX:0,translateY:0};const T=xt(w.nodes),A=r-l*2,L=a-l*2,F=A/T.width,Y=L/T.height,W=Math.min(F,Y,1),G=T.width*W,N=T.height*W,V=(r-G)/2-T.minX*W,P=(a-N)/2-T.minY*W;return{bounds:T,scale:W,translateX:V,translateY:P}},[w,r,a,l]),k=v.useCallback(()=>{!w||!c||(n?n(w):b(!0))},[w,c,n]);return!w||w.nodes.length===0?s.jsx("div",{className:be.cell,style:{width:r,height:a,backgroundColor:f,borderRadius:d},title:g,children:s.jsx("span",{className:be.emptyText,children:"—"})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`${be.cell} ${c?be.expandable:""}`,style:{width:r,height:a,backgroundColor:f,borderRadius:d},onClick:k,title:g??`${w.nodes.length} nodes, ${w.edges.length} edges`,children:[s.jsx("svg",{width:r,height:a,viewBox:`0 0 ${r} ${a}`,className:be.svg,children:s.jsxs("g",{transform:`translate(${D}, ${C}) scale(${S})`,children:[w.edges.map(T=>{const A=Jt(T,y);return A?s.jsx("path",{d:A,stroke:p,strokeWidth:1/S,fill:"none"},T.id):null}),w.nodes.map(T=>{const A=Ht(T);return s.jsxs("g",{children:[s.jsx("rect",{x:T.position.x,y:T.position.y,width:T.size.width,height:T.size.height,rx:Math.min(4,T.size.width/4),fill:A}),m&&S>.3&&s.jsx("text",{x:T.position.x+T.size.width/2,y:T.position.y+T.size.height/2,textAnchor:"middle",dominantBaseline:"middle",fill:"var(--nice-color-white, #fff)",fontSize:10/S,fontFamily:"system-ui, sans-serif",children:T.label.substring(0,5)})]},T.id)})]})}),o&&s.jsx("span",{className:be.badge,children:w.nodes.length}),c&&s.jsx("span",{className:be.expandIcon,children:s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",children:s.jsx("path",{d:"M2 10V7M2 10h3M2 10l4-4M10 2v3M10 2H7M10 2L6 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})})]}),h&&w&&s.jsx(da,{document:w,onClose:()=>b(!1)})]})};function Zt(i,e,t="roundedRect"){const r=[],a=[],o=new Map;for(const c of i){const n=String(c[e.nodeMapping.idField]??"");if(!n)continue;const l=String(c[e.nodeMapping.labelField]??n),f=e.nodeMapping.descriptionField?String(c[e.nodeMapping.descriptionField]??""):void 0,d=e.nodeMapping.iconField?String(c[e.nodeMapping.iconField]??""):void 0,m=e.nodeMapping.colorField?String(c[e.nodeMapping.colorField]??""):void 0,p={id:`data_${n}`,label:l,description:f,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:c};r.push(p),o.set(n,p)}if(e.nodeMapping.parentField)for(const c of i){const n=String(c[e.nodeMapping.idField]??""),l=String(c[e.nodeMapping.parentField]??"");if(!n||!l)continue;const f=o.get(n),d=o.get(l);!f||!d||a.push({id:`edge_${l}_${n}`,sourceNodeId:d.id,sourcePortId:"bottom",targetNodeId:f.id,targetPortId:"top",style:{lineType:"orthogonal",targetArrow:"arrow"}})}if(e.edgeMapping)for(const c of i){const n=String(c[e.edgeMapping.sourceField]??""),l=String(c[e.edgeMapping.targetField]??"");if(!n||!l)continue;const f=o.get(n),d=o.get(l);if(!f||!d)continue;const m=e.edgeMapping.labelField?String(c[e.edgeMapping.labelField]??""):void 0;a.push({id:`edge_${n}_${l}`,sourceNodeId:f.id,sourcePortId:"right",targetNodeId:d.id,targetPortId:"left",label:m,style:{lineType:"bezier",targetArrow:"arrow"}})}return{nodes:r,edges:a}}async function fa(i,e,t){const r=await fetch(i.sourceUrl,{signal:t});if(!r.ok)throw new Error(`Failed to fetch data: ${r.status} ${r.statusText}`);const a=await r.json(),o=Array.isArray(a)?a:a.value??[];return Zt(o,i,e)}const ha={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)"},pa={start:"ellipse",end:"ellipse",task:"rectangle",decision:"diamond",parallel:"rectangle",join:"rectangle",subprocess:"rectangle",timer:"ellipse",message:"rectangle",error:"rectangle"},ma={start:"play",end:"stop",task:"clipboard",decision:"help",parallel:"columns",join:"git-branch",subprocess:"box",timer:"clock",message:"mail",error:"warning"},ga=({data:i,onStepClick:e,onTransitionClick:t,autoPlay:r=!1,animationDelay:a=1e3,showTooltips:o=!0,showMinimap:c=!0,statusColors:n=ha,typeShapes:l=pa,direction:f="horizontal",className:d,style:m})=>{const[p,g]=v.useState(0),h=v.useMemo(()=>{const M=i.steps.map((C,k)=>{const T=C.id===i.currentStepId,A=C.status||"pending",L=n[A],F=l[C.type],Y=f==="horizontal"?k*200:100,W=f==="horizontal"?100:k*150;return{id:C.id,label:C.name,x:Y,y:W,width:150,height:60,shape:F,style:{fill:L,stroke:T?"var(--nice-text, #1f2937)":L,strokeWidth:T?3:1,fontColor:"var(--nice-color-white, #fff)",fontSize:12},data:{type:C.type,status:C.status,assignee:C.assignee,dueDate:C.dueDate,icon:ma[C.type],...C.metadata},ports:[{id:`${C.id}-in`,position:"left"},{id:`${C.id}-out`,position:"right"}]}}),S=i.transitions.map(C=>{const k=i.steps.find(L=>L.id===C.from),T=i.steps.find(L=>L.id===C.to);let A="var(--nice-text-muted, #9ca3af)";return(k==null?void 0:k.status)==="completed"&&(T==null?void 0:T.status)!=="pending"?A="var(--nice-success, #10b981)":(k==null?void 0:k.status)==="failed"&&(A="var(--nice-danger, #ef4444)"),{id:C.id,source:C.from,target:C.to,sourcePort:`${C.from}-out`,targetPort:`${C.to}-in`,label:C.label||C.condition,style:{stroke:A,strokeWidth:2,arrowHead:"arrow",lineType:"bezier"},data:{condition:C.condition}}}),D=r?ya(i.steps):[];return ze({id:i.id,title:i.name,diagramType:"flowchart",nodes:M,edges:S,animations:D,metadata:{type:"workflow",...i.metadata}})},[i,n,l,f,r]);v.useEffect(()=>{if(!r)return;const M=i.steps.filter(D=>D.status==="completed").length;if(p>=M)return;const S=setTimeout(()=>{g(D=>D+1)},a);return()=>clearTimeout(S)},[r,p,a,i.steps]);const[b,w]=v.useState({x:0,y:0,zoom:1}),y=v.useCallback(M=>{if(M&&e){const S=i.steps.find(D=>D.id===M);S&&e(S)}if(M&&t){const S=i.transitions.find(D=>D.id===M);S&&t(S)}},[i.steps,i.transitions,e,t]);return s.jsx("div",{className:`nice-workflow-visualizer ${d||""}`,style:{position:"relative",width:"100%",height:"100%",...m},children:s.jsx(we,{nodes:h.nodes,edges:h.edges,groups:h.groups,viewport:b,onViewportChange:w,onSelectElement:y,showGrid:!0})})};function ya(i){return i.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 ba(i){var o,c;const t=new DOMParser().parseFromString(i,"text/xml"),r=[],a=[];return t.querySelectorAll("startEvent").forEach(n=>{r.push({id:n.getAttribute("id")||`start-${r.length}`,name:n.getAttribute("name")||"Start",type:"start"})}),t.querySelectorAll("task, userTask, serviceTask").forEach(n=>{r.push({id:n.getAttribute("id")||`task-${r.length}`,name:n.getAttribute("name")||"Task",type:"task"})}),t.querySelectorAll("exclusiveGateway, parallelGateway").forEach(n=>{const l=n.tagName==="parallelGateway";r.push({id:n.getAttribute("id")||`gateway-${r.length}`,name:n.getAttribute("name")||(l?"Parallel":"Decision"),type:l?"parallel":"decision"})}),t.querySelectorAll("endEvent").forEach(n=>{r.push({id:n.getAttribute("id")||`end-${r.length}`,name:n.getAttribute("name")||"End",type:"end"})}),t.querySelectorAll("sequenceFlow").forEach(n=>{a.push({id:n.getAttribute("id")||`flow-${a.length}`,from:n.getAttribute("sourceRef")||"",to:n.getAttribute("targetRef")||"",label:n.getAttribute("name")||void 0})}),{id:((o=t.querySelector("process"))==null?void 0:o.getAttribute("id"))||"workflow",name:((c=t.querySelector("process"))==null?void 0:c.getAttribute("name"))||"Workflow",steps:r,transitions:a}}function xa(i,e){const t=[],r=[];t.push({id:"start",name:"Start",type:"start",status:"completed"}),i.forEach((a,o)=>{t.push({id:`step-${o}`,name:a,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 a=0;a<i.length-1;a++)r.push({id:`step-${a}-to-${a+1}`,from:`step-${a}`,to:`step-${a+1}`});return r.push({id:"last-to-end",from:`step-${i.length-1}`,to:"end"}),{id:"linear-workflow",name:"Linear Workflow",steps:t,transitions:r}}const va={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)"},wa={"one-to-one":{left:"1",right:"1"},"one-to-many":{left:"1",right:"*"},"many-to-one":{left:"*",right:"1"},"many-to-many":{left:"*",right:"*"}},ka=({schema:i,onTableClick:e,onColumnClick:t,onRelationClick:r,showColumnDetails:a=!0,showOnlyKeys:o=!1,highlightTables:c=[],showMinimap:n=!0,schemaColors:l=va,layout:f="auto",maxColumnsDisplay:d=15,className:m,style:p})=>{const[g,h]=v.useState(null),b=v.useMemo(()=>{const S=_a(i.tables,f),D=i.tables.map((k,T)=>{const A=S[k.name]||{x:T%4*300,y:Math.floor(T/4)*400},L=c.includes(k.name),F=g===k.name,Y=l[k.schema||"dbo"]||"var(--nice-text-secondary, #6b7280)";let W=k.columns;o&&(W=W.filter(P=>P.primaryKey||P.foreignKey)),W.length>d&&(W=W.slice(0,d));const G=40,N=a?28:20,V=G+W.length*N+10;return{id:k.name,label:k.schema?`${k.schema}.${k.name}`:k.name,x:A.x,y:A.y,width:250,height:V,shape:"rectangle",style:{fill:L||F?Y:"var(--nice-bg, #fff)",stroke:Y,strokeWidth:F?3:L?2:1,fontColor:L||F?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:14,borderRadius:8},data:{type:"table",schema:k.schema,columns:W.map(P=>({...P,icon:Ca(P)})),totalColumns:k.columns.length,truncated:k.columns.length>d,comment:k.comment,...k.metadata},ports:[...k.columns.filter(P=>P.primaryKey).map(P=>({id:`${k.name}.${P.name}-pk`,position:"left"})),...k.columns.filter(P=>P.foreignKey).map(P=>({id:`${k.name}.${P.name}-fk`,position:"right"}))]}}),C=i.relations.map(k=>{const T=wa[k.type];return{id:k.id,source:k.fromTable,target:k.toTable,sourcePort:`${k.fromTable}.${k.fromColumn}-fk`,targetPort:`${k.toTable}.${k.toColumn}-pk`,label:k.name||`${T.left}─${T.right}`,style:{stroke:"var(--nice-text-secondary, #6b7280)",strokeWidth:1.5,arrowHead:Na(k.type),arrowTail:Ma(k.type),lineType:"orthogonal",strokeDasharray:k.type==="many-to-many"?"5,5":void 0},data:{type:k.type,fromColumn:k.fromColumn,toColumn:k.toColumn}}});return ze({id:`schema-${i.name}`,title:i.name,diagramType:"er",nodes:D,edges:C,metadata:{type:"er-diagram",...i.metadata}})},[i,a,o,c,g,l,f,d]),[w,y]=v.useState({x:0,y:0,zoom:1}),M=v.useCallback(S=>{if(S){if(h(D=>D===S?null:S),e){const D=i.tables.find(C=>C.name===S);D&&e(D)}if(r){const D=i.relations.find(C=>C.id===S);D&&r(D)}}},[i.tables,i.relations,e,r]);return s.jsx("div",{className:`nice-database-schema-viewer ${m||""}`,style:{position:"relative",width:"100%",height:"100%",...p},children:s.jsx(we,{nodes:b.nodes,edges:b.edges,groups:b.groups,viewport:w,onViewportChange:y,onSelectElement:M,showGrid:!0})})};function _a(i,e){const t={};if(e==="grid"){const r=Math.ceil(Math.sqrt(i.length));i.forEach((a,o)=>{t[a.name]={x:o%r*320+50,y:Math.floor(o/r)*450+50}})}else if(e==="hierarchical"){const r={};i.forEach(o=>{const c=o.schema||"default";r[c]||(r[c]=[]),r[c].push(o)});let a=50;Object.entries(r).forEach(([o,c])=>{c.forEach((n,l)=>{t[n.name]={x:l*320+50,y:a}}),a+=500})}else i.forEach((r,a)=>{const o=a/i.length*2*Math.PI,c=300+i.length*20;t[r.name]={x:Math.cos(o)*c+500,y:Math.sin(o)*c+400}});return t}function Ca(i){return i.primaryKey?"lock":i.foreignKey?"link":i.unique?"zap":"file"}function Na(i){switch(i){case"one-to-one":case"many-to-one":return"none";case"one-to-many":case"many-to-many":return"crow"}}function Ma(i){switch(i){case"one-to-one":case"one-to-many":return"none";case"many-to-one":case"many-to-many":return"crow"}}function Sa(i){const e=[],t=[],r=/CREATE\s+TABLE\s+(?:`?(\w+)`?\.)?`?(\w+)`?\s*\(([\s\S]*?)\);/gi;let a;for(;(a=r.exec(i))!==null;){const o=a[1]||"dbo",c=a[2],n=a[3],l=[],f=/`?(\w+)`?\s+(\w+(?:\([^)]+\))?)\s*(NOT\s+NULL|NULL)?/gi;let d;for(;(d=f.exec(n))!==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(n);if(m){const h=l.find(b=>b.name===m[1]);h&&(h.primaryKey=!0)}const p=/FOREIGN\s+KEY\s*\(`?(\w+)`?\)\s*REFERENCES\s+`?(\w+)`?\s*\(`?(\w+)`?\)/gi;let g;for(;(g=p.exec(n))!==null;){const h=g,b=l.find(w=>w.name===h[1]);b&&(b.foreignKey={table:h[2],column:h[3]},t.push({id:`fk-${c}-${h[1]}`,fromTable:c,fromColumn:h[1],toTable:h[2],toColumn:h[3],type:"many-to-one"}))}e.push({name:c,schema:o,columns:l})}return{name:"Parsed Schema",tables:e,relations:t}}function Ia(i,e="postgres"){const t=[];for(const r of i.tables){const a=r.schema?`${r.schema}.${r.name}`:r.name;t.push(`CREATE TABLE ${a} (`);const o=r.columns.map(n=>{let l=` ${n.name} ${n.type}`;return n.nullable||(l+=" NOT NULL"),n.primaryKey&&(l+=" PRIMARY KEY"),n.unique&&(l+=" UNIQUE"),n.defaultValue&&(l+=` DEFAULT ${n.defaultValue}`),l}),c=r.columns.filter(n=>n.foreignKey).map(n=>` FOREIGN KEY (${n.name}) REFERENCES ${n.foreignKey.table}(${n.foreignKey.column})`);t.push([...o,...c].join(`,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),y=require("@nice2dev/ui"),x=require("react");class jt{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[,o]of this.liquidFlows)if(o.active){o.gradientOffset=(o.gradientOffset+r*.5)%1;for(const a of o.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[,o]of this.glowStates)o.pulse=(o.pulse+r*2)%(Math.PI*2);this.particles=this.particles.filter(o=>(o.life-=r/o.maxLife,o.life<=0?!1:(o.x+=o.vx*r,o.y+=o.vy*r,o.opacity=Math.min(1,o.life*2),!0)));for(const o of this.emitters)for(o.accumulator=(o.accumulator??0)+r*o.rate;o.accumulator>=1;){o.accumulator-=1;const a=Math.random()*Math.PI*2,l=o.speed*(.5+Math.random());this.particles.push({x:o.position.x+(Math.random()-.5)*o.spread,y:o.position.y+(Math.random()-.5)*o.spread,vx:Math.cos(a)*l,vy:Math.sin(a)*l,life:1,maxLife:o.particleLife,size:o.particleSize*(.5+Math.random()),color:o.color,opacity:1})}this.onFrame(this.getState()),this.rafId=requestAnimationFrame(this.tick)},this.onFrame=e}startLiquidFlow(e,t){const r=[],o=t.particleDensity??3;for(let a=0;a<o;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 fr(i,e,t){if(!t)return{x:0,y:0};const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",i),t.appendChild(r);try{const o=r.getTotalLength(),a=r.getPointAtLength(e*o);return{x:a.x,y:a.y}}finally{t.removeChild(r)}}function Dt(i){return`nd-glow-${i.replace(/[^a-zA-Z0-9]/g,"_")}`}function $t(i,e){const t=i*12,r=1+Math.sin(e)*.3;return t*r}function pt(i,e){const t=(e==null?void 0:e.scale)??1,r=(e==null?void 0:e.background)??"transparent";let o=1/0,a=1/0,l=-1/0,s=-1/0;for(const p of i.nodes)o=Math.min(o,p.position.x),a=Math.min(a,p.position.y),l=Math.max(l,p.position.x+p.size.width),s=Math.max(s,p.position.y+p.size.height);i.nodes.length===0&&(o=a=0,l=s=100);const c=40,f=(l-o+c*2)*t,d=(s-a+c*2)*t,m=-o+c,w=-a+c,u=[];u.push(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${f} ${d}" width="${f}" height="${d}">`),u.push("<defs>"),u.push('<marker id="arrowhead" markerWidth="10" markerHeight="7" refX="10" refY="3.5" orient="auto">'),u.push(' <polygon points="0 0, 10 3.5, 0 7" fill="#666" />'),u.push("</marker>"),u.push("</defs>"),r!=="transparent"&&u.push(`<rect width="${f}" height="${d}" fill="${r}" />`),u.push(`<g transform="translate(${m*t}, ${w*t}) scale(${t})">`);for(const p of i.edges){const b=i.nodes.find(j=>j.id===p.sourceNodeId),v=i.nodes.find(j=>j.id===p.targetNodeId);if(!b||!v)continue;const g=b.position.x+b.size.width/2,S=b.position.y+b.size.height/2,M=v.position.x+v.size.width/2,$=v.position.y+v.size.height/2,_=p.style.strokeColor??"#666",k=p.style.strokeWidth??2,T=p.style.targetArrow!=="none"?' marker-end="url(#arrowhead)"':"";if(p.style.lineType==="bezier"){const j=(g+M)/2,O=S,B=(g+M)/2,U=$;u.push(`<path d="M${g},${S} C${j},${O} ${B},${U} ${M},${$}" fill="none" stroke="${_}" stroke-width="${k}"${T} />`)}else u.push(`<line x1="${g}" y1="${S}" x2="${M}" y2="${$}" stroke="${_}" stroke-width="${k}"${T} />`);if(p.label){const j=(g+M)/2,O=(S+$)/2;u.push(`<text x="${j}" y="${O-6}" text-anchor="middle" font-size="12" fill="#333">${Ct(p.label)}</text>`)}}for(const p of i.nodes){const{x:b,y:v}=p.position,{width:g,height:S}=p.size,M=p.style.backgroundColor??"#fff",$=p.style.borderColor??"#ccc",_=p.style.borderWidth??1,k=p.style.borderRadius??(p.shape==="roundedRect"?8:0),T=p.style.fontColor??"#333",j=p.style.fontSize??14;switch(p.shape){case"ellipse":case"circle":u.push(`<ellipse cx="${b+g/2}" cy="${v+S/2}" rx="${g/2}" ry="${S/2}" fill="${M}" stroke="${$}" stroke-width="${_}" />`);break;case"diamond":u.push(`<polygon points="${b+g/2},${v} ${b+g},${v+S/2} ${b+g/2},${v+S} ${b},${v+S/2}" fill="${M}" stroke="${$}" stroke-width="${_}" />`);break;default:u.push(`<rect x="${b}" y="${v}" width="${g}" height="${S}" rx="${k}" fill="${M}" stroke="${$}" stroke-width="${_}" />`)}u.push(`<text x="${b+g/2}" y="${v+S/2+j/3}" text-anchor="middle" font-size="${j}" fill="${T}" font-family="sans-serif">${Ct(p.label)}</text>`)}return u.push("</g>"),u.push("</svg>"),u.join(`
|
|
2
|
+
`)}function Tt(i){const e=[],t=i.diagramType==="orgchart"||i.diagramType==="mindmap"?"graph TB":i.diagramType==="stateMachine"?"stateDiagram-v2":"flowchart TD";e.push(t);for(const r of i.nodes){const o=ut(r.id),a=r.label.replace(/"/g,"'");switch(r.shape){case"diamond":e.push(` ${o}{${a}}`);break;case"circle":case"ellipse":e.push(` ${o}((${a}))`);break;case"cylinder":e.push(` ${o}[(${a})]`);break;default:e.push(` ${o}["${a}"]`)}}for(const r of i.edges){const o=ut(r.sourceNodeId),a=ut(r.targetNodeId),l=r.label?`|${r.label}|`:"",s=r.style.targetArrow==="none"?"---":"-->";e.push(` ${o} ${s}${l} ${a}`)}return e.join(`
|
|
3
|
+
`)}function ut(i){return i.replace(/[^a-zA-Z0-9_]/g,"_")}function Ct(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}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","diagramEditor.addAnimationMode":"Add animation mode","animation.zoomIn":"Zoom in","animation.zoomOut":"Zoom out","toolbar.bringToFront":"Bring to Front","toolbar.sendToBack":"Send to Back"},pl:{"toolbar.select":"Zaznacz","toolbar.addNode":"Dodaj węzeł","toolbar.addEdge":"Dodaj połączenie","toolbar.group":"Grupuj","toolbar.ungroup":"Rozgrupuj","toolbar.delete":"Usuń","toolbar.undo":"Cofnij","toolbar.redo":"Ponów","toolbar.zoomIn":"Powiększ","toolbar.zoomOut":"Pomniejsz","toolbar.fitToScreen":"Dopasuj do ekranu","toolbar.export":"Eksportuj","toolbar.import":"Importuj","toolbar.autoLayout":"Auto układ","toolbar.animations":"Animacje","toolbar.dataBinding":"Dane","toolbar.pan":"Przesuń","toolbar.zoomReset":"Przywróć powiększenie","toolbar.layout":"Układ","layout.dagre":"Hierarchiczny","layout.forceDirected":"Siłowy","layout.grid":"Siatka","layout.radial":"Promieniowy","layout.tree":"Drzewo","panel.properties":"Właściwości","panel.style":"Styl","panel.animations":"Animacje","panel.data":"Dane","panel.noSelection":"Zaznacz element, aby edytować jego właściwości","panel.nodeProperties":"Właściwości węzła","panel.edgeProperties":"Właściwości połączenia","node.label":"Etykieta","node.description":"Opis","node.shape":"Kształt","node.color":"Kolor","node.border":"Obramowanie","node.width":"Szerokość","node.height":"Wysokość","node.bgColor":"Tło","node.borderColor":"Kolor obramowania","node.fontSize":"Rozmiar czcionki","node.fontColor":"Kolor czcionki","node.locked":"Zablokowany","edge.label":"Etykieta","edge.lineType":"Typ linii","edge.arrow":"Strzałka","edge.color":"Kolor","edge.width":"Grubość","edge.animated":"Animowane","export.svg":"SVG","export.png":"PNG","export.pdf":"PDF","export.mermaid":"Mermaid","export.ndd":"NDD (Natywny)","viewer.fullscreen":"Pełny ekran","viewer.playAnimations":"Odtwórz animacje","viewer.stopAnimations":"Zatrzymaj","viewer.print":"Drukuj","animation.timeline":"Oś czasu","animation.play":"Odtwórz","animation.stop":"Zatrzymaj","animation.add":"Dodaj","animation.noAnimations":"Brak animacji",untitled:"Diagram bez nazwy","animation.addFromPreset":"Dodaj z gotowych","animation.presets":"Gotowe","animation.clickToEdit":"Kliknij, aby edytować","animation.startMs":"Początek (ms)","animation.durationMs":"Czas trwania (ms)","node.effects":"Efekty","node.glowColor":"Kolor poświaty","node.glowIntensity":"Siła poświaty","node.opacity":"Krycie","node.borderRadius":"Zaokrąglenie rogów","node.borderWidth":"Grubość obramowania","node.shadow":"Cień","node.gradientEnd":"Koniec gradientu","node.gradientDir":"Kierunek gradientu","node.hiddenGhostInEditor":"Ukryty (półprzezroczysty w edytorze)","node.flowSpeed":"Prędkość przepływu","node.dashStyle":"Styl kreski","node.targetArrow":"Grot końcowy","node.sourceArrow":"Grot początkowy","node.liquidFlow":"Przepływ cieczy","node.enableLiquidFlow":"Włącz przepływ cieczy","node.speed":"Prędkość","node.pipeWidth":"Szerokość rury","toolbar.textT":"Tekst (T)","toolbar.freehandF":"Odręcznie (F)","toolbar.copyCtrlC":"Kopiuj (Ctrl+C)","toolbar.pasteCtrlV":"Wklej (Ctrl+V)","toolbar.duplicateCtrlD":"Duplikuj (Ctrl+D)","toolbar.selectAllCtrlA":"Zaznacz wszystko (Ctrl+A)","toolbar.findCtrlF":"Znajdź (Ctrl+F)","toolbar.searchNodes":"Szukaj węzłów…","toolbar.mermaid":"Mermaid","toolbar.fontFamily":"Krój czcionki","toolbar.fontSize":"Rozmiar czcionki","toolbar.boldCtrlB":"Pogrubienie (Ctrl+B)","toolbar.italicCtrlI":"Kursywa (Ctrl+I)","toolbar.alignmentDistribution":"Wyrównanie i rozmieszczenie","toolbar.align":"Wyrównaj","toolbar.alignLeft":"Wyrównaj do lewej","toolbar.left":"Do lewej","toolbar.alignCenter":"Wyśrodkuj w poziomie","toolbar.center":"Środek","toolbar.alignRight":"Wyrównaj do prawej","toolbar.right":"Do prawej","toolbar.alignTop":"Wyrównaj do góry","toolbar.alignMiddle":"Wyśrodkuj w pionie","toolbar.middle":"Środek","toolbar.alignBottom":"Wyrównaj do dołu","toolbar.bottom":"Dół","toolbar.distribute":"Rozmieść","toolbar.distributeHorizontally":"Rozmieść w poziomie","toolbar.distributeVertically":"Rozmieść w pionie","toolbar.arrange":"Ułóż","toolbar.editorMode":"Tryb edycji","toolbar.editor":"Edytor","toolbar.playerMode":"Tryb odtwarzania","toolbar.player":"Odtwarzacz","toolbar.animatedPlayerMode":"Tryb odtwarzania z animacją","toolbar.animated":"Z animacją","toolbar.stylePresets":"Gotowe style","toolbar.style":"Styl","diagramEditor.addAnimationMode":"Dodaj tryb animacji","animation.zoomIn":"Powiększ","animation.zoomOut":"Pomniejsz","toolbar.bringToFront":"Na wierzch","toolbar.sendToBack":"Na spód"},de:{"toolbar.select":"Auswählen","toolbar.addNode":"Knoten hinzufügen","toolbar.addEdge":"Kante hinzufügen","toolbar.group":"Gruppieren","toolbar.ungroup":"Gruppierung aufheben","toolbar.delete":"Löschen","toolbar.undo":"Rückgängig","toolbar.redo":"Wiederholen","toolbar.zoomIn":"Vergrößern","toolbar.zoomOut":"Verkleinern","toolbar.fitToScreen":"An Bildschirm anpassen","toolbar.export":"Exportieren","toolbar.import":"Importieren","toolbar.autoLayout":"Automatisches Layout","toolbar.animations":"Animationen","toolbar.dataBinding":"Datenbindung","toolbar.pan":"Verschieben","toolbar.zoomReset":"Zoom zurücksetzen","toolbar.layout":"Layout","layout.dagre":"Hierarchisch","layout.forceDirected":"Kräftebasiert","layout.grid":"Raster","layout.radial":"Radial","layout.tree":"Baum","panel.properties":"Eigenschaften","panel.style":"Stil","panel.animations":"Animationen","panel.data":"Daten","panel.noSelection":"Wählen Sie ein Element aus, um seine Eigenschaften zu bearbeiten","panel.nodeProperties":"Knoteneigenschaften","panel.edgeProperties":"Kanteneigenschaften","node.label":"Bezeichnung","node.description":"Beschreibung","node.shape":"Form","node.color":"Farbe","node.border":"Rahmen","node.width":"Breite","node.height":"Höhe","node.bgColor":"Hintergrund","node.borderColor":"Rahmenfarbe","node.fontSize":"Schriftgröße","node.fontColor":"Schriftfarbe","node.locked":"Gesperrt","edge.label":"Bezeichnung","edge.lineType":"Linientyp","edge.arrow":"Pfeil","edge.color":"Farbe","edge.width":"Stärke","edge.animated":"Animiert","export.svg":"SVG","export.png":"PNG","export.pdf":"PDF","export.mermaid":"Mermaid","export.ndd":"NDD (Nativ)","viewer.fullscreen":"Vollbild","viewer.playAnimations":"Animationen abspielen","viewer.stopAnimations":"Stopp","viewer.print":"Drucken","animation.timeline":"Zeitleiste","animation.play":"Abspielen","animation.stop":"Stopp","animation.add":"Hinzufügen","animation.noAnimations":"Noch keine Animationen",untitled:"Unbenanntes Diagramm","animation.addFromPreset":"Aus Vorlage hinzufügen","animation.presets":"Vorlagen","animation.clickToEdit":"Zum Bearbeiten klicken","animation.startMs":"Start (ms)","animation.durationMs":"Dauer (ms)","node.effects":"Effekte","node.glowColor":"Leuchtfarbe","node.glowIntensity":"Leuchtstärke","node.opacity":"Deckkraft","node.borderRadius":"Eckenradius","node.borderWidth":"Rahmenbreite","node.shadow":"Schatten","node.gradientEnd":"Verlaufsende","node.gradientDir":"Verlaufsrichtung","node.hiddenGhostInEditor":"Ausgeblendet (im Editor transparent)","node.flowSpeed":"Flussgeschwindigkeit","node.dashStyle":"Strichart","node.targetArrow":"Pfeil am Ziel","node.sourceArrow":"Pfeil an der Quelle","node.liquidFlow":"Flüssigkeitsfluss","node.enableLiquidFlow":"Flüssigkeitsfluss aktivieren","node.speed":"Geschwindigkeit","node.pipeWidth":"Rohrbreite","toolbar.textT":"Text (T)","toolbar.freehandF":"Freihand (F)","toolbar.copyCtrlC":"Kopieren (Strg+C)","toolbar.pasteCtrlV":"Einfügen (Strg+V)","toolbar.duplicateCtrlD":"Duplizieren (Strg+D)","toolbar.selectAllCtrlA":"Alles auswählen (Strg+A)","toolbar.findCtrlF":"Suchen (Strg+F)","toolbar.searchNodes":"Knoten suchen…","toolbar.mermaid":"Mermaid","toolbar.fontFamily":"Schriftart","toolbar.fontSize":"Schriftgröße","toolbar.boldCtrlB":"Fett (Strg+B)","toolbar.italicCtrlI":"Kursiv (Strg+I)","toolbar.alignmentDistribution":"Ausrichten & Verteilen","toolbar.align":"Ausrichten","toolbar.alignLeft":"Links ausrichten","toolbar.left":"Links","toolbar.alignCenter":"Horizontal zentrieren","toolbar.center":"Mitte","toolbar.alignRight":"Rechts ausrichten","toolbar.right":"Rechts","toolbar.alignTop":"Oben ausrichten","toolbar.alignMiddle":"Vertikal zentrieren","toolbar.middle":"Mitte","toolbar.alignBottom":"Unten ausrichten","toolbar.bottom":"Unten","toolbar.distribute":"Verteilen","toolbar.distributeHorizontally":"Horizontal verteilen","toolbar.distributeVertically":"Vertikal verteilen","toolbar.arrange":"Anordnen","toolbar.editorMode":"Bearbeitungsmodus","toolbar.editor":"Editor","toolbar.playerMode":"Wiedergabemodus","toolbar.player":"Player","toolbar.animatedPlayerMode":"Animierter Wiedergabemodus","toolbar.animated":"Animiert","toolbar.stylePresets":"Stilvorlagen","toolbar.style":"Stil","diagramEditor.addAnimationMode":"Animationsmodus hinzufügen","animation.zoomIn":"Vergrößern","animation.zoomOut":"Verkleinern","toolbar.bringToFront":"In den Vordergrund","toolbar.sendToBack":"In den Hintergrund"},fr:{"toolbar.select":"Sélectionner","toolbar.addNode":"Ajouter un nœud","toolbar.addEdge":"Ajouter une arête","toolbar.group":"Grouper","toolbar.ungroup":"Dégrouper","toolbar.delete":"Supprimer","toolbar.undo":"Annuler","toolbar.redo":"Rétablir","toolbar.zoomIn":"Agrandir","toolbar.zoomOut":"Réduire","toolbar.fitToScreen":"Ajuster à l'écran","toolbar.export":"Exporter","toolbar.import":"Importer","toolbar.autoLayout":"Mise en page auto","toolbar.animations":"Animations","toolbar.dataBinding":"Liaison de données","toolbar.pan":"Déplacer","toolbar.zoomReset":"Réinitialiser le zoom","toolbar.layout":"Disposition","layout.dagre":"Hiérarchique","layout.forceDirected":"Force dirigée","layout.grid":"Grille","layout.radial":"Radial","layout.tree":"Arbre","panel.properties":"Propriétés","panel.style":"Style","panel.animations":"Animations","panel.data":"Données","panel.noSelection":"Sélectionnez un élément pour modifier ses propriétés","panel.nodeProperties":"Propriétés du nœud","panel.edgeProperties":"Propriétés de l'arête","node.label":"Étiquette","node.description":"Description","node.shape":"Forme","node.color":"Couleur","node.border":"Bordure","node.width":"Largeur","node.height":"Hauteur","node.bgColor":"Arrière-plan","node.borderColor":"Couleur de bordure","node.fontSize":"Taille de police","node.fontColor":"Couleur de police","node.locked":"Verrouillé","edge.label":"Étiquette","edge.lineType":"Type de ligne","edge.arrow":"Flèche","edge.color":"Couleur","edge.width":"Épaisseur","edge.animated":"Animée","export.svg":"SVG","export.png":"PNG","export.pdf":"PDF","export.mermaid":"Mermaid","export.ndd":"NDD (Natif)","viewer.fullscreen":"Plein écran","viewer.playAnimations":"Lire les animations","viewer.stopAnimations":"Arrêter","viewer.print":"Imprimer","animation.timeline":"Chronologie","animation.play":"Lire","animation.stop":"Arrêter","animation.add":"Ajouter","animation.noAnimations":"Aucune animation",untitled:"Diagramme sans titre","animation.addFromPreset":"Ajouter depuis un préréglage","animation.presets":"Préréglages","animation.clickToEdit":"Cliquer pour modifier","animation.startMs":"Début (ms)","animation.durationMs":"Durée (ms)","node.effects":"Effets","node.glowColor":"Couleur de lueur","node.glowIntensity":"Intensité de la lueur","node.opacity":"Opacité","node.borderRadius":"Rayon des coins","node.borderWidth":"Épaisseur de bordure","node.shadow":"Ombre","node.gradientEnd":"Fin du dégradé","node.gradientDir":"Direction du dégradé","node.hiddenGhostInEditor":"Masqué (fantôme dans l'éditeur)","node.flowSpeed":"Vitesse du flux","node.dashStyle":"Style de tirets","node.targetArrow":"Flèche cible","node.sourceArrow":"Flèche source","node.liquidFlow":"Flux liquide","node.enableLiquidFlow":"Activer le flux liquide","node.speed":"Vitesse","node.pipeWidth":"Largeur du tuyau","toolbar.textT":"Texte (T)","toolbar.freehandF":"Main levée (F)","toolbar.copyCtrlC":"Copier (Ctrl+C)","toolbar.pasteCtrlV":"Coller (Ctrl+V)","toolbar.duplicateCtrlD":"Dupliquer (Ctrl+D)","toolbar.selectAllCtrlA":"Tout sélectionner (Ctrl+A)","toolbar.findCtrlF":"Rechercher (Ctrl+F)","toolbar.searchNodes":"Rechercher des nœuds…","toolbar.mermaid":"Mermaid","toolbar.fontFamily":"Police","toolbar.fontSize":"Taille de police","toolbar.boldCtrlB":"Gras (Ctrl+B)","toolbar.italicCtrlI":"Italique (Ctrl+I)","toolbar.alignmentDistribution":"Alignement et répartition","toolbar.align":"Aligner","toolbar.alignLeft":"Aligner à gauche","toolbar.left":"Gauche","toolbar.alignCenter":"Centrer horizontalement","toolbar.center":"Centre","toolbar.alignRight":"Aligner à droite","toolbar.right":"Droite","toolbar.alignTop":"Aligner en haut","toolbar.alignMiddle":"Centrer verticalement","toolbar.middle":"Milieu","toolbar.alignBottom":"Aligner en bas","toolbar.bottom":"Bas","toolbar.distribute":"Répartir","toolbar.distributeHorizontally":"Répartir horizontalement","toolbar.distributeVertically":"Répartir verticalement","toolbar.arrange":"Organiser","toolbar.editorMode":"Mode édition","toolbar.editor":"Éditeur","toolbar.playerMode":"Mode lecture","toolbar.player":"Lecteur","toolbar.animatedPlayerMode":"Mode lecture animé","toolbar.animated":"Animé","toolbar.stylePresets":"Styles prédéfinis","toolbar.style":"Style","diagramEditor.addAnimationMode":"Ajouter un mode d'animation","animation.zoomIn":"Zoom avant","animation.zoomOut":"Zoom arrière","toolbar.bringToFront":"Mettre au premier plan","toolbar.sendToBack":"Mettre à l'arrière-plan"},es:{"toolbar.select":"Seleccionar","toolbar.addNode":"Añadir nodo","toolbar.addEdge":"Añadir arista","toolbar.group":"Agrupar","toolbar.ungroup":"Desagrupar","toolbar.delete":"Eliminar","toolbar.undo":"Deshacer","toolbar.redo":"Rehacer","toolbar.zoomIn":"Ampliar","toolbar.zoomOut":"Reducir","toolbar.fitToScreen":"Ajustar a pantalla","toolbar.export":"Exportar","toolbar.import":"Importar","toolbar.autoLayout":"Diseño automático","toolbar.animations":"Animaciones","toolbar.dataBinding":"Enlace de datos","toolbar.pan":"Desplazar","toolbar.zoomReset":"Restablecer zoom","toolbar.layout":"Diseño","layout.dagre":"Jerárquico","layout.forceDirected":"Fuerza dirigida","layout.grid":"Cuadrícula","layout.radial":"Radial","layout.tree":"Árbol","panel.properties":"Propiedades","panel.style":"Estilo","panel.animations":"Animaciones","panel.data":"Datos","panel.noSelection":"Selecciona un elemento para editar sus propiedades","panel.nodeProperties":"Propiedades del nodo","panel.edgeProperties":"Propiedades de la arista","node.label":"Etiqueta","node.description":"Descripción","node.shape":"Forma","node.color":"Color","node.border":"Borde","node.width":"Ancho","node.height":"Alto","node.bgColor":"Fondo","node.borderColor":"Color del borde","node.fontSize":"Tamaño de fuente","node.fontColor":"Color de fuente","node.locked":"Bloqueado","edge.label":"Etiqueta","edge.lineType":"Tipo de línea","edge.arrow":"Flecha","edge.color":"Color","edge.width":"Grosor","edge.animated":"Animada","export.svg":"SVG","export.png":"PNG","export.pdf":"PDF","export.mermaid":"Mermaid","export.ndd":"NDD (Nativo)","viewer.fullscreen":"Pantalla completa","viewer.playAnimations":"Reproducir animaciones","viewer.stopAnimations":"Detener","viewer.print":"Imprimir","animation.timeline":"Línea de tiempo","animation.play":"Reproducir","animation.stop":"Detener","animation.add":"Añadir","animation.noAnimations":"Sin animaciones",untitled:"Diagrama sin título","animation.addFromPreset":"Añadir desde un preajuste","animation.presets":"Preajustes","animation.clickToEdit":"Haz clic para editar","animation.startMs":"Inicio (ms)","animation.durationMs":"Duración (ms)","node.effects":"Efectos","node.glowColor":"Color del brillo","node.glowIntensity":"Intensidad del brillo","node.opacity":"Opacidad","node.borderRadius":"Radio del borde","node.borderWidth":"Grosor del borde","node.shadow":"Sombra","node.gradientEnd":"Fin del degradado","node.gradientDir":"Dirección del degradado","node.hiddenGhostInEditor":"Oculto (fantasma en el editor)","node.flowSpeed":"Velocidad del flujo","node.dashStyle":"Estilo de trazo","node.targetArrow":"Flecha de destino","node.sourceArrow":"Flecha de origen","node.liquidFlow":"Flujo de líquido","node.enableLiquidFlow":"Activar flujo de líquido","node.speed":"Velocidad","node.pipeWidth":"Ancho de tubería","toolbar.textT":"Texto (T)","toolbar.freehandF":"A mano alzada (F)","toolbar.copyCtrlC":"Copiar (Ctrl+C)","toolbar.pasteCtrlV":"Pegar (Ctrl+V)","toolbar.duplicateCtrlD":"Duplicar (Ctrl+D)","toolbar.selectAllCtrlA":"Seleccionar todo (Ctrl+A)","toolbar.findCtrlF":"Buscar (Ctrl+F)","toolbar.searchNodes":"Buscar nodos…","toolbar.mermaid":"Mermaid","toolbar.fontFamily":"Fuente","toolbar.fontSize":"Tamaño de fuente","toolbar.boldCtrlB":"Negrita (Ctrl+B)","toolbar.italicCtrlI":"Cursiva (Ctrl+I)","toolbar.alignmentDistribution":"Alineación y distribución","toolbar.align":"Alinear","toolbar.alignLeft":"Alinear a la izquierda","toolbar.left":"Izquierda","toolbar.alignCenter":"Centrar horizontalmente","toolbar.center":"Centro","toolbar.alignRight":"Alinear a la derecha","toolbar.right":"Derecha","toolbar.alignTop":"Alinear arriba","toolbar.alignMiddle":"Centrar verticalmente","toolbar.middle":"Medio","toolbar.alignBottom":"Alinear abajo","toolbar.bottom":"Abajo","toolbar.distribute":"Distribuir","toolbar.distributeHorizontally":"Distribuir horizontalmente","toolbar.distributeVertically":"Distribuir verticalmente","toolbar.arrange":"Organizar","toolbar.editorMode":"Modo de edición","toolbar.editor":"Editor","toolbar.playerMode":"Modo de reproducción","toolbar.player":"Reproductor","toolbar.animatedPlayerMode":"Modo de reproducción animado","toolbar.animated":"Animado","toolbar.stylePresets":"Estilos predefinidos","toolbar.style":"Estilo","diagramEditor.addAnimationMode":"Añadir modo de animación","animation.zoomIn":"Acercar","animation.zoomOut":"Alejar","toolbar.bringToFront":"Traer al frente","toolbar.sendToBack":"Enviar al fondo"}},Pt=x.createContext({locale:"en",t:(i,e)=>e??i});function mt({locale:i="en",overrides:e,children:t}){const r=x.useMemo(()=>{const o={..._t.en,..._t[i],...e};return{locale:i,t:(l,s)=>o[l]??s??l}},[i,e]);return x.createElement(Pt.Provider,{value:r},t)}function Le(){return x.useContext(Pt)}function hr(i){const e=[];let t;try{t=JSON.parse(i)}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 o=new Set(r.nodes.map(a=>a.id).filter(Boolean));for(const a of r.edges)a.sourceNodeId&&!o.has(a.sourceNodeId)&&e.push(`Edge "${a.id}" references non-existent source node "${a.sourceNodeId}"`),a.targetNodeId&&!o.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 Et(i,e=!0){return JSON.stringify(i,null,e?2:void 0)}class Ze{constructor(e){this.undoStack=[],this.redoStack=[],this.listeners=new Set,this.maxHistory=100,this.doc=e??Ze.createEmpty()}static createEmpty(e="flowchart"){const t=new Date().toISOString();return{version:"1.0",id:$e(),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",o={width:160,height:60}){this.pushUndo("Add node");const a=pr(),l={id:$e(),label:e,position:t,size:o,shape:r,style:{},ports:a};return this.doc.nodes.push(l),this.notify(),l}updateNode(e,t){this.pushUndo("Update node");const r=this.doc.nodes.find(o=>o.id===e);r&&Object.assign(r,t),this.notify()}moveNode(e,t){const r=this.doc.nodes.find(o=>o.id===e);r&&(this.pushUndo("Move node"),r.position=t,this.notify())}resizeNode(e,t){const r=this.doc.nodes.find(o=>o.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,o,a){if(e===r||!this.getNodeById(e)||!this.getNodeById(r))return null;this.pushUndo("Add edge");const l={id:$e(),sourceNodeId:e,sourcePortId:t,targetNodeId:r,targetPortId:o,label:a,style:{lineType:"bezier",targetArrow:"arrow"}};return this.doc.edges.push(l),this.notify(),l}updateEdge(e,t){this.pushUndo("Update edge");const r=this.doc.edges.find(o=>o.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:$e(),label:e,nodeIds:[...t]};return t.forEach(o=>{const a=this.doc.nodes.find(l=>l.id===o);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 o=this.doc.nodes.find(a=>a.id===r);o&&(o.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:$e(),...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 o=this.doc.nodes.find(a=>a.id===r);o&&(o.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 o=this.doc.nodes.find(a=>a.id===r);o&&(o.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:$e(),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(l=>l.id===e);if(!r)return null;this.pushUndo("Add animation to mode");const o={id:$e(),...t};return r.animations.push(o),this.notify(),o}removeAnimationFromMode(e,t){var o;const r=(o=this.doc.animationModes)==null?void 0:o.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(o=>o.id===e);r&&Object.assign(r,t),this.notify()}loadDocument(e){this.doc=structuredClone(e),this.undoStack=[],this.redoStack=[],this.notify()}}function $e(){return`ndd_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function pr(){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 Rt(i,e,t){switch(t.algorithm){case"dagre":return Ot(i,e,t);case"grid":return mr(i,t);case"radial":return gr(i,e);case"tree":return yr(i,e,t);case"forceDirected":return br(i,e,t);case"manual":default:return{positions:new Map(i.map(r=>[r.id,{...r.position}]))}}}function Ot(i,e,t){const r=t.direction??"TB",o=t.nodeSpacing??60,a=t.rankSpacing??100,l=new Map,s=new Map,c=new Set(i.map(g=>g.id));i.forEach(g=>{l.set(g.id,[]),s.set(g.id,[])}),e.forEach(g=>{c.has(g.sourceNodeId)&&c.has(g.targetNodeId)&&(l.get(g.sourceNodeId).push(g.targetNodeId),s.get(g.targetNodeId).push(g.sourceNodeId))});const f=i.filter(g=>{var S;return(((S=s.get(g.id))==null?void 0:S.length)??0)===0});f.length===0&&i.length>0&&f.push(i[0]);const d=new Map,m=[];for(f.forEach(g=>{d.set(g.id,0),m.push(g.id)});m.length>0;){const g=m.shift(),S=d.get(g)??0;for(const M of l.get(g)??[])d.has(M)||(d.set(M,S+1),m.push(M))}i.forEach(g=>{d.has(g.id)||d.set(g.id,0)});const w=new Map;i.forEach(g=>{const S=d.get(g.id)??0;w.has(S)||w.set(S,[]),w.get(S).push(g)});const u=new Map,p=r==="LR"||r==="RL",b=r==="BT"||r==="RL";return[...w.keys()].sort((g,S)=>g-S).forEach((g,S)=>{const M=w.get(g);let _=-(M.reduce((k,T)=>k+T.size.width,0)+(M.length-1)*o)/2;M.forEach(k=>{const T=S*(a+(p?k.size.width:k.size.height)),j=_+k.size.width/2;let O,B;p?(O=b?-T:T,B=j):(O=j,B=b?-T:T),u.set(k.id,{x:O,y:B}),_+=k.size.width+o})}),t.centerGraph&>(u),{positions:u}}function mr(i,e){const t=e.nodeSpacing??80,r=Math.ceil(Math.sqrt(i.length)),o=new Map;return i.forEach((a,l)=>{const s=l%r,c=Math.floor(l/r);o.set(a.id,{x:s*(a.size.width+t),y:c*(a.size.height+t)})}),e.centerGraph&>(o),{positions:o}}function gr(i,e){const t=new Map;if(i.length===0)return{positions:t};const r=new Map;i.forEach(c=>r.set(c.id,0)),e.forEach(c=>{r.set(c.sourceNodeId,(r.get(c.sourceNodeId)??0)+1),r.set(c.targetNodeId,(r.get(c.targetNodeId)??0)+1)});const o=[...i].sort((c,f)=>(r.get(f.id)??0)-(r.get(c.id)??0)),a=o[0];t.set(a.id,{x:0,y:0});const l=o.slice(1),s=200+l.length*20;return l.forEach((c,f)=>{const d=2*Math.PI*f/l.length;t.set(c.id,{x:Math.cos(d)*s,y:Math.sin(d)*s})}),{positions:t}}function yr(i,e,t){return Ot(i,e,{...t,direction:t.direction??"TB",nodeSpacing:t.nodeSpacing??40,rankSpacing:t.rankSpacing??80})}function br(i,e,t){const r=new Map;if(i.length===0)return{positions:r};const o=400,a=new Map;i.forEach(m=>{a.set(m.id,{x:(Math.random()-.5)*o,y:(Math.random()-.5)*o})});const l=e.map(m=>({source:m.sourceNodeId,target:m.targetNodeId})),s=t.nodeSpacing??150,c=80,f=.95;let d=o/2;for(let m=0;m<c;m++){const w=new Map;i.forEach(u=>w.set(u.id,{fx:0,fy:0}));for(let u=0;u<i.length;u++)for(let p=u+1;p<i.length;p++){const b=a.get(i[u].id),v=a.get(i[p].id),g=v.x-b.x,S=v.y-b.y,M=Math.max(Math.sqrt(g*g+S*S),1),$=s*s/M,_=g/M*$,k=S/M*$;w.get(i[u].id).fx-=_,w.get(i[u].id).fy-=k,w.get(i[p].id).fx+=_,w.get(i[p].id).fy+=k}for(const u of l){const p=a.get(u.source),b=a.get(u.target);if(!p||!b)continue;const v=b.x-p.x,g=b.y-p.y,S=Math.max(Math.sqrt(v*v+g*g),1),M=S*S/s,$=v/S*M,_=g/S*M;w.get(u.source).fx+=$,w.get(u.source).fy+=_,w.get(u.target).fx-=$,w.get(u.target).fy-=_}i.forEach(u=>{const p=w.get(u.id),b=a.get(u.id),v=Math.sqrt(p.fx*p.fx+p.fy*p.fy);if(v>0){const g=Math.min(v,d);b.x+=p.fx/v*g,b.y+=p.fy/v*g}}),d*=f}return i.forEach(m=>{r.set(m.id,{...a.get(m.id)})}),t.centerGraph&>(r),{positions:r}}function gt(i){if(i.size===0)return;let e=1/0,t=1/0,r=-1/0,o=-1/0;i.forEach(s=>{e=Math.min(e,s.x),t=Math.min(t,s.y),r=Math.max(r,s.x),o=Math.max(o,s.y)});const a=(e+r)/2,l=(t+o)/2;i.forEach(s=>{s.x-=a,s.y-=l})}function Ft(i){const e=x.useRef(null);e.current||(e.current=new Ze(i));const t=e.current,[,r]=x.useState(0),o=x.useCallback(()=>r(s=>s+1),[]);x.useEffect(()=>t.subscribe(o),[t,o]);const a=t.getDocument(),l=x.useCallback(s=>{Rt(t.getNodes(),t.getEdges(),s).positions.forEach((f,d)=>{t.moveNode(d,f)})},[t]);return x.useMemo(()=>({document:a,nodes:a.nodes,edges:a.edges,groups:a.groups,animations:a.animations,viewport:a.viewport,addNode:(s,c,f,d)=>t.addNode(s,c,f,d),updateNode:(s,c)=>t.updateNode(s,c),moveNode:(s,c)=>t.moveNode(s,c),resizeNode:(s,c)=>t.resizeNode(s,c),removeNode:s=>t.removeNode(s),addEdge:(s,c,f,d,m)=>t.addEdge(s,c,f,d,m),updateEdge:(s,c)=>t.updateEdge(s,c),removeEdge:s=>t.removeEdge(s),createGroup:(s,c)=>t.createGroup(s,c),removeGroup:s=>t.removeGroup(s),toggleGroupCollapse:s=>t.toggleGroupCollapse(s),toggleNodeCollapse:s=>t.toggleNodeCollapse(s),addAnimation:s=>t.addAnimation(s),updateAnimation:(s,c)=>t.updateAnimation(s,c),removeAnimation:s=>t.removeAnimation(s),animationModes:t.getAnimationModes(),activeAnimationMode:t.getActiveAnimationMode(),addAnimationMode:(s,c)=>t.addAnimationMode(s,c),removeAnimationMode:s=>t.removeAnimationMode(s),setActiveAnimationMode:s=>t.setActiveAnimationMode(s),addAnimationToMode:(s,c)=>t.addAnimationToMode(s,c),removeAnimationFromMode:(s,c)=>t.removeAnimationFromMode(s,c),setStylePreset:s=>t.setStylePreset(s),setStyleOverrides:s=>t.setStyleOverrides(s),stylePresetId:a.stylePresetId,playerConfig:t.getPlayerConfig(),setPlayerConfig:s=>t.setPlayerConfig(s),setViewMode:s=>t.setViewMode(s),viewMode:t.getPlayerConfig().mode,applyLayout:l,setViewport:s=>t.setViewport(s),undo:()=>t.undo(),redo:()=>t.redo(),canUndo:t.canUndo(),canRedo:t.canRedo(),loadDocument:s=>t.loadDocument(s),model:t}),[a,t,l])}function de(i){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)",...i}}function xr(i,e={}){return{backgroundColor:i.surface,borderColor:i.primary,borderWidth:2,borderRadius:8,fontColor:i.text,fontSize:14,fontWeight:"normal",opacity:1,shadow:!0,...e}}function vr(i,e={}){return{strokeColor:i.border,strokeWidth:2,lineType:"bezier",targetArrow:"arrow",...e}}function wr(i,e={}){return{backgroundColor:`${i.primaryLight}18`,borderColor:i.primaryLight,borderWidth:1,borderStyle:"dashed",borderRadius:12,labelColor:i.text,padding:16,...e}}function ue(i,e,t,r,o,a,l){return{canvas:i,nodeDefaults:xr(e,r),edgeDefaults:vr(e,o),groupDefaults:wr(e,a),fontFamily:t,palette:e,effects:l}}const Me="'Inter', system-ui, sans-serif",yt="'Fira Code', 'Cascadia Code', monospace",kr="'Merriweather', 'Georgia', serif",Cr={id:"default-light",name:"Default Light",category:"corporate",themeSource:"Light",config:ue({background:"var(--nice-bg, #fff)",gridColor:"#e2e8f020",gridSize:20,selectionColor:"var(--nice-primary, #3b82f6)"},de({}),Me)},_r=de({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)"}),Nr={id:"default-dark",name:"Default Dark",category:"dark",themeSource:"Dark",config:ue({background:"var(--nice-bg-primary, #0f172a)",gridColor:"var(--nice-text, #334155)",gridSize:20,selectionColor:"var(--nice-primary-light, #60a5fa)"},_r,Me,{shadow:!1},{strokeColor:"var(--nice-text-secondary, #475569)"},{backgroundColor:"#60a5fa10",borderColor:"#3b82f680"})},Mr=de({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)"}),Sr={id:"corporate-blue",name:"Corporate Blue",category:"corporate",themeSource:"Blue",config:ue({background:"#f0f5ff",gridColor:"#93c5fd20",gridSize:20,selectionColor:"var(--nice-primary-dark, #1d4ed8)"},Mr,Me,{borderWidth:2,borderRadius:6},{strokeColor:"var(--nice-primary-light, #93c5fd)",strokeWidth:2})},zr=de({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)"}),Ir={id:"neon-glow",name:"Neon Glow",category:"dark",config:ue({background:"#0a0a1a",gridColor:"#00ff8810",gridSize:20,selectionColor:"var(--nice-success, #00ff88)"},zr,yt,{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)"})},Ar=de({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"}),jr={id:"cyberpunk",name:"Cyberpunk",category:"dark",config:ue({background:"#0d001a",gridColor:"#ff2d9510",gridSize:24,selectionColor:"var(--nice-color-accent-pink, #ff2d95)"},Ar,yt,{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"})},Dr=de({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"}),$r={id:"blueprint",name:"Technical Blueprint",category:"technical",config:ue({background:"#0a1929",gridColor:"#4da6ff30",gridSize:16,selectionColor:"var(--nice-color-white, #fff)"},Dr,yt,{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})},Tr=de({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"}),Pr={id:"pastel-dream",name:"Pastel Dream",category:"pastel",config:ue({background:"#fefcff",gridColor:"#e2d8f420",gridSize:20,selectionColor:"var(--nice-accent, #a78bfa)"},Tr,"'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})},Er=de({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"}),Rr={id:"nature-forest",name:"Nature Forest",category:"nature",config:ue({background:"#f0fdf4",gridColor:"#a7d7c520",gridSize:20,selectionColor:"var(--nice-success, #059669)"},Er,Me,{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)"})},Or=de({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"}),Fr={id:"retro-terminal",name:"Retro Terminal",category:"retro",config:ue({background:"#000800",gridColor:"#00ff0010",gridSize:16,selectionColor:"var(--nice-success, #00ff00)"},Or,"'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)"})},Lr=de({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)"}),Wr={id:"high-contrast",name:"High Contrast",category:"accessibility",themeSource:"High Contrast",config:ue({background:"var(--nice-bg, #fff)",gridColor:"#00000020",gridSize:20,selectionColor:"#0000ff"},Lr,"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})},Br=de({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)"}),qr={id:"material-design",name:"Material Design",category:"theme-based",themeSource:"Material",config:ue({background:"var(--nice-bg-secondary, #fafafa)",gridColor:"#e0e0e020",gridSize:20,selectionColor:"var(--nice-primary-hover, #1976d2)"},Br,"'Roboto', 'Noto Sans', sans-serif",{borderRadius:4,borderWidth:0,shadow:!0},{strokeColor:"#bdbdbd",strokeWidth:2},{borderRadius:8})},Vr=de({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"}),Gr={id:"fluent-ui",name:"Fluent UI",category:"theme-based",themeSource:"Fluent",config:ue({background:"#faf9f8",gridColor:"#edebe920",gridSize:20,selectionColor:"#0078d4"},Vr,"'Segoe UI', system-ui, sans-serif",{borderRadius:4,borderWidth:1,shadow:!0},{strokeColor:"#c8c6c4",strokeWidth:1})},Yr=de({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)"}),Ur={id:"sunset-warm",name:"Sunset Warm",category:"creative",config:ue({background:"#fffde7",gridColor:"#ffccbc20",gridSize:20,selectionColor:"var(--nice-warning-dark, #e65100)"},Yr,Me,{borderColor:"#ff9e80",gradientColor:"var(--nice-warning-bg, #fff3e0)",gradientDirection:"vertical"},{strokeColor:"#ff9e80"},{},{liquidColor:"var(--nice-warning-dark, #e65100)",liquidColorEnd:"#ffd600",particleColor:"#ffd600"})},Hr=de({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"}),Xr={id:"ocean-deep",name:"Ocean Deep",category:"nature",config:ue({background:"#e0f7fa",gridColor:"#b2ebf220",gridSize:20,selectionColor:"#006064"},Hr,Me,{borderColor:"#00838f",borderRadius:12},{strokeColor:"#4dd0e1"},{},{liquidColor:"#006064",liquidColorEnd:"#4dd0e1",particleColor:"#ffd54f"})},Kr=de({primary:"#5d4037",primaryLight:"#a1887f",secondary:"#795548",accent:"#c6a263",text:"#3e2723",textMuted:"#8d6e63",border:"#bcaaa4",surface:"#fdf6f0",surfaceAlt:"#efebe9"}),Zr={id:"elegant-serif",name:"Elegant Serif",category:"creative",config:ue({background:"#fdf6f0",gridColor:"#bcaaa420",gridSize:24,selectionColor:"#5d4037"},Kr,kr,{borderColor:"#a1887f",borderWidth:1,borderRadius:2,fontStyle:"normal"},{strokeColor:"#bcaaa4",strokeWidth:1},{borderRadius:4})},Jr=de({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)"}),Qr={id:"wireframe",name:"Wireframe",category:"technical",config:ue({background:"var(--nice-bg, #fff)",gridColor:"#00000008",gridSize:16,selectionColor:"#ff6600"},Jr,"'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=de({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:ue({background:"var(--nice-success-bg, #e8f5e9)",gridColor:"#a7ffeb20",gridSize:20,selectionColor:"#00bfa5"},ei,Me,{borderColor:"#00bfa5",borderRadius:20,borderWidth:2,gradientColor:"#b2dfdb",gradientDirection:"radial"},{strokeColor:"#64ffda",strokeWidth:2},{borderRadius:16},{liquidColor:"#00bfa5",liquidColorEnd:"#64ffda",particleColor:"#ff6e40"})},ri=de({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)"}),ii={id:"monochrome",name:"Monochrome",category:"corporate",config:ue({background:"var(--nice-bg-secondary, #fafafa)",gridColor:"#e0e0e020",gridSize:20,selectionColor:"#424242"},ri,Me,{borderColor:"var(--nice-border-color, #9e9e9e)",borderWidth:1,shadow:!0,borderRadius:4},{strokeColor:"var(--nice-text-secondary, #9e9e9e)",strokeWidth:1.5})},oi=de({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:ue({background:"#fff0f5",gridColor:"#f8bbd020",gridSize:20,selectionColor:"var(--nice-color-accent-pink, #e91e63)"},oi,"'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=de({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:ue({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=de({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:ue({background:"#0f0b2e",gridColor:"#7c3aed15",gridSize:24,selectionColor:"var(--nice-accent, #a78bfa)"},li,Me,{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=de({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:ue({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=de({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:ue({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=de({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"}),mi={id:"midnight-purple",name:"Midnight Purple",category:"dark",config:ue({background:"#0f0720",gridColor:"#9333ea10",gridSize:20,selectionColor:"var(--nice-accent, #c084fc)"},pi,Me,{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)"})},Je=[Cr,Nr,Sr,qr,Gr,Ir,jr,$r,Fr,Pr,Ur,Xr,Zr,Rr,Qr,Wr,ti,ii,ai,si,ci,ui,hi,mi],gi=[{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}}}],Lt=[{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(i){return Je.find(e=>e.id===i)}function xi(i){return Je.filter(e=>e.category===i)}function vi(i){return{canvasBackground:i.canvas.background,gridColor:i.canvas.gridColor,gridSize:i.canvas.gridSize,selectionColor:i.canvas.selectionColor,fontFamily:i.fontFamily,nodeDefaults:i.nodeDefaults,edgeDefaults:i.edgeDefaults,groupDefaults:i.groupDefaults,palette:i.palette,effects:i.effects}}function wi(i,e,t,r,o,a){const l=de({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:o.primary,textMuted:o.muted,border:a.color,surface:r.primary,surfaceAlt:r.secondary}),s=ki(r.primary);return{id:i,name:`${e} Theme`,category:"theme-based",themeSource:e,config:ue({background:r.primary,gridColor:s?`${a.color}40`:`${a.color}20`,gridSize:20,selectionColor:t.primary},l,Me,{shadow:!s,borderWidth:s?1:2},{strokeColor:s?`${a.color}80`:a.color})}}function ki(i){const e=i.replace("#","");if(e.length<6)return!1;const t=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),o=parseInt(e.slice(4,6),16);return(t*299+r*587+o*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"],_i=["linear","easeIn","easeOut","easeInOut","spring","bounce"],Qe=({animations:i,onAdd:e,onRemove:t,onUpdate:r,onPlay:o,onStop:a,isPlaying:l=!1,availableTargets:s=[],className:c})=>{const{t:f}=Le(),[d,m]=x.useState(!1),[w,u]=x.useState(null),p=x.useCallback(()=>{if(!e||s.length===0)return;const g=s[0];e({name:`Animation ${i.length+1}`,targetId:g.id,targetType:g.type,effect:"fadeIn",startMs:i.length*500,durationMs:600,easing:"easeOut"})},[e,i.length,s]),b=x.useCallback(g=>{if(!e||s.length===0)return;const S=s[0];e({name:g.name,targetId:S.id,targetType:S.type,effect:g.effect,startMs:i.length*500,durationMs:g.durationMs,easing:g.easing}),m(!1)},[e,i.length,s]),v=Math.max(2e3,...i.map(g=>g.startMs+g.durationMs+(g.delayMs??0)));return n.jsxs("div",{className:`nice-diagram-timeline ${c??""}`,children:[n.jsxs("div",{className:"nice-diagram-timeline__header",children:[n.jsx("h4",{className:"nice-diagram-timeline__title",children:f("animation.timeline")}),n.jsxs("div",{className:"nice-diagram-timeline__controls",children:[l?n.jsxs(y.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:a,children:[n.jsx(y.NiceIcon,{name:"stop",size:14})," ",f("animation.stop")]}):n.jsxs(y.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:o,children:[n.jsx(y.NiceIcon,{name:"play",size:14})," ",f("animation.play")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:p,disabled:s.length===0,children:[n.jsx(y.NiceIcon,{name:"plus",size:14})," ",f("animation.add")]}),n.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[n.jsxs(y.NiceButton,{className:"nice-diagram-timeline__btn",variant:"ghost",size:"sm",onClick:()=>m(g=>!g),disabled:s.length===0,title:f("animation.addFromPreset","Add from preset"),children:[n.jsx(y.NiceIcon,{name:"video",size:14})," ",f("animation.presets","Presets")]}),d&&n.jsx("div",{style:{position:"absolute",bottom:"100%",left:0,background:"var(--nice-bg, #fff)",border:"1px solid var(--nice-border, #ddd)",borderRadius:6,boxShadow:"0 4px 12px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",maxHeight:280,overflowY:"auto",width:200,zIndex:100},children:Lt.map(g=>n.jsx(y.NiceButton,{variant:"ghost",size:"sm",onClick:()=>b(g),style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",fontSize:12,borderBottom:"1px solid var(--nice-bg-secondary, #f0f0f0)"},title:`${g.effect} — ${g.durationMs}ms ${g.easing}`,children:g.name},g.id))})]})]})]}),n.jsxs("div",{className:"nice-diagram-timeline__tracks",children:[i.length===0&&n.jsx("p",{className:"nice-diagram-timeline__empty",children:f("animation.noAnimations")}),i.map(g=>{const S=g.startMs/v*100,M=g.durationMs/v*100,$=w===g.id;return n.jsxs("div",{className:"nice-diagram-timeline__track",children:[n.jsxs("div",{className:"nice-diagram-timeline__track-label",children:[n.jsx("span",{className:"nice-diagram-timeline__track-name",onClick:()=>u($?null:g.id),style:{cursor:"pointer"},title:f("animation.clickToEdit","Click to edit"),children:g.name}),n.jsx("span",{className:"nice-diagram-timeline__track-effect",children:g.effect}),n.jsx(y.NiceButton,{className:"nice-diagram-timeline__track-remove",variant:"ghost",size:"sm",onClick:()=>t==null?void 0:t(g.id),title:f("toolbar.delete"),children:n.jsx(y.NiceIcon,{name:"close",size:14})})]}),$&&n.jsxs("div",{className:"nice-diagram-timeline__track-editor",style:{display:"flex",gap:4,padding:"4px 0",flexWrap:"wrap",fontSize:11},children:[n.jsx(y.NiceSelect,{value:g.effect,onChange:_=>r==null?void 0:r(g.id,{effect:_}),options:Ci.map(_=>({value:_,label:_})),style:{fontSize:11,padding:"1px 4px"}}),n.jsx(y.NiceSelect,{value:g.easing,onChange:_=>r==null?void 0:r(g.id,{easing:_}),options:_i.map(_=>({value:_,label:_})),style:{fontSize:11,padding:"1px 4px"}}),n.jsx(y.NiceSelect,{value:g.targetId,onChange:_=>{const k=s.find(T=>T.id===_);k&&(r==null||r(g.id,{targetId:k.id,targetType:k.type}))},options:s.map(_=>({value:_.id,label:_.label})),style:{fontSize:11,padding:"1px 4px",maxWidth:100}}),n.jsx(y.NiceNumberInput,{value:g.startMs,min:0,step:100,onChange:_=>r==null?void 0:r(g.id,{startMs:_??0}),style:{width:60,fontSize:11},title:f("animation.startMs","Start (ms)")}),n.jsx(y.NiceNumberInput,{value:g.durationMs,min:50,step:50,onChange:_=>r==null?void 0:r(g.id,{durationMs:_??50}),style:{width:60,fontSize:11},title:f("animation.durationMs","Duration (ms)")})]}),n.jsx("div",{className:"nice-diagram-timeline__track-bar",children:n.jsx("div",{className:"nice-diagram-timeline__track-segment",style:{left:`${S}%`,width:`${M}%`},title:`${g.effect} ${g.startMs}ms → ${g.startMs+g.durationMs}ms (${g.easing})`})})]},g.id)})]}),n.jsx("div",{className:"nice-diagram-timeline__ruler",children:Array.from({length:5}).map((g,S)=>{const M=Math.round(v/4*S);return n.jsxs("span",{className:"nice-diagram-timeline__ruler-mark",style:{left:`${S/4*100}%`},children:[M,"ms"]},S)})})]})};process.env.NODE_ENV!=="production"&&(Qe.displayName="AnimationTimeline");const Ni=/^[a-z][a-z0-9-]*$/,Mi=.1,Si=5,He=8,ft=[{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}],ke=({nodes:i,edges:e,groups:t=[],viewport:r,onViewportChange:o,theme:a,selectedId:l,selectedIds:s=[],onSelectElement:c,onMultiSelect:f,onNodeDragStart:d,onNodeDrag:m,onNodeDragEnd:w,onNodeResize:u,onNodeLabelChange:p,animationStates:b,particleState:v,viewMode:g="editor",ghostOpacity:S=.15,onGroupCollapse:M,onNodeCollapse:$,onInteraction:_,onNodeHover:k,onGroupClick:T,interactive:j=!1,showGrid:O=!0,showRulers:B=!1,snapToGrid:U=!0,gridSnapSize:L=10,className:G})=>{const N=x.useRef(null),[Y,P]=x.useState(!1),[V,E]=x.useState({x:0,y:0}),[q,X]=x.useState(null),[J,fe]=x.useState({x:0,y:0}),[re,be]=x.useState(null),[W,Q]=x.useState(null),[ee,le]=x.useState(null),[me,Ce]=x.useState(null),[Ee,F]=x.useState(""),[ot,Re]=x.useState([]),at=(a==null?void 0:a.canvasBackground)??"var(--nice-bg-secondary, #f8f9fa)",We=(a==null?void 0:a.gridColor)??"var(--nice-border, #e0e0e0)",Se=(a==null?void 0:a.gridSize)??20,ve=(a==null?void 0:a.selectionColor)??"var(--nice-primary, #2196f3)",Be=x.useMemo(()=>{const h=new Set(s);return l&&h.add(l),h},[l,s]),ge=x.useCallback(h=>U?Math.round(h/L)*L:h,[U,L]),qe=x.useCallback((h,C,z)=>{const A=[],I=C.x,D=C.y,te=I+z.width/2,K=D+z.height/2,Z=I+z.width,oe=D+z.height;for(const he of i){if(he.id===h)continue;const ne=he.position.x,ce=he.position.y,pe=ne+he.size.width/2,_e=ce+he.size.height/2,ze=ne+he.size.width,Ne=ce+he.size.height;Math.abs(I-ne)<5&&A.push({x:ne}),Math.abs(Z-ze)<5&&A.push({x:ze}),Math.abs(te-pe)<5&&A.push({x:pe}),Math.abs(I-ze)<5&&A.push({x:ze}),Math.abs(Z-ne)<5&&A.push({x:ne}),Math.abs(D-ce)<5&&A.push({y:ce}),Math.abs(oe-Ne)<5&&A.push({y:Ne}),Math.abs(K-_e)<5&&A.push({y:_e}),Math.abs(D-Ne)<5&&A.push({y:Ne}),Math.abs(oe-ce)<5&&A.push({y:ce})}Re(A)},[i]),je=x.useCallback(h=>{if(h.preventDefault(),!o)return;const C=h.deltaY>0?.9:1.1,z=Math.min(Si,Math.max(Mi,r.zoom*C)),A=N.current;if(!A)return;const R=A.getBoundingClientRect(),I=h.clientX-R.left,D=h.clientY-R.top,te=z/r.zoom,K=I-(I-r.x)*te,Z=D-(D-r.y)*te;o({x:K,y:Z,zoom:z})},[r,o]),nt=x.useCallback(h=>{if(h.button===1||h.button===0&&h.target.tagName==="svg"){if(h.button===0&&j&&!h.shiftKey&&h.target.tagName==="svg"){const C=N.current;if(C){const z=C.getBoundingClientRect(),A=(h.clientX-z.left-r.x)/r.zoom,R=(h.clientY-z.top-r.y)/r.zoom;Q({x:A,y:R}),be({x1:A,y1:R,x2:A,y2:R})}c&&c(null),f&&f([]);return}P(!0),E({x:h.clientX-r.x,y:h.clientY-r.y}),c&&h.button===0&&c(null)}},[r,c,f,j]),Ve=x.useCallback(h=>{if(W){const C=N.current;if(!C)return;const z=C.getBoundingClientRect(),A=(h.clientX-z.left-r.x)/r.zoom,R=(h.clientY-z.top-r.y)/r.zoom;be({x1:W.x,y1:W.y,x2:A,y2:R});return}if(Y&&o){o({...r,x:h.clientX-V.x,y:h.clientY-V.y});return}if(ee&&u){const C=N.current;if(!C)return;const z=C.getBoundingClientRect(),A=(h.clientX-z.left-r.x)/r.zoom,R=(h.clientY-z.top-r.y)/r.zoom,I=A-ee.startMouse.x,D=R-ee.startMouse.y,te=ft[ee.handleIdx];let K=ee.startSize.width+I*te.resizeX,Z=ee.startSize.height+D*te.resizeY,oe=ee.startPos.x+(te.resizeX<0?I:0),he=ee.startPos.y+(te.resizeY<0?D:0);K=Math.max(30,ge(K)),Z=Math.max(20,ge(Z)),oe=ge(oe),he=ge(he),u(ee.nodeId,{width:K,height:Z},{x:oe,y:he});return}if(q&&m){const C=N.current;if(!C)return;const z=C.getBoundingClientRect(),A=ge((h.clientX-z.left-r.x)/r.zoom-J.x),R=ge((h.clientY-z.top-r.y)/r.zoom-J.y);m(q,{x:A,y:R});const I=i.find(D=>D.id===q);I&&qe(q,{x:A,y:R},I.size)}},[W,Y,o,r,V,ee,u,q,m,J,ge,i,qe]),Ge=x.useCallback(h=>{if(re&&W){const C=Math.min(re.x1,re.x2),z=Math.min(re.y1,re.y2),A=Math.max(re.x1,re.x2),R=Math.max(re.y1,re.y2);if(Math.abs(A-C)>5||Math.abs(R-z)>5){const I=i.filter(D=>{const te=D.position.x,K=D.position.y,Z=te+D.size.width,oe=K+D.size.height;return Z>C&&te<A&&oe>z&&K<R}).map(D=>D.id);f==null||f(I),I.length===1&&(c==null||c(I[0]))}be(null),Q(null);return}if(Y&&P(!1),ee){le(null);return}if(q&&w){const C=N.current;if(!C)return;const z=C.getBoundingClientRect(),A=ge((h.clientX-z.left-r.x)/r.zoom-J.x),R=ge((h.clientY-z.top-r.y)/r.zoom-J.y);w(q,{x:A,y:R})}X(null),Re([])},[re,W,Y,ee,q,w,r,J,ge,i,f,c]),st=x.useCallback((h,C)=>{if(h.stopPropagation(),!j)return;const z=i.find(te=>te.id===C);if(!z||z.locked)return;if(h.shiftKey&&f){const te=[...s],K=te.indexOf(C);K>=0?te.splice(K,1):te.push(C),f(te);return}c==null||c(C);const A=N.current;if(!A)return;const R=A.getBoundingClientRect(),I=(h.clientX-R.left-r.x)/r.zoom,D=(h.clientY-R.top-r.y)/r.zoom;fe({x:I-z.position.x,y:D-z.position.y}),X(C),d==null||d(C)},[j,i,r,c,d,f,s]),lt=x.useCallback((h,C,z)=>{if(h.stopPropagation(),!j)return;const A=i.find(K=>K.id===C);if(!A||A.locked)return;const R=N.current;if(!R)return;const I=R.getBoundingClientRect(),D=(h.clientX-I.left-r.x)/r.zoom,te=(h.clientY-I.top-r.y)/r.zoom;le({nodeId:C,handleIdx:z,startMouse:{x:D,y:te},startPos:{...A.position},startSize:{...A.size}}),c==null||c(C)},[j,i,r,c]),H=x.useCallback((h,C)=>{if(h.stopPropagation(),!j||!p)return;const z=i.find(A=>A.id===C);!z||z.locked||(Ce(C),F(z.label))},[j,i,p]),De=x.useCallback(()=>{me&&p&&p(me,Ee),Ce(null)},[me,Ee,p]),we=x.useCallback((h,C)=>{h.stopPropagation(),c==null||c(C)},[c]),ct=x.useCallback(h=>{const C=i.find(z=>z.id===h);return C?{x:C.position.x+C.size.width/2,y:C.position.y+C.size.height/2}:{x:0,y:0}},[i]),Oe=x.useCallback((h,C)=>{const z=i.find(D=>D.id===h);if(!z)return{x:0,y:0};const A=z.ports.find(D=>D.id===C);if(!A)return ct(h);const{position:R,size:I}=z;switch(A.side){case"top":return{x:R.x+I.width*A.offset,y:R.y};case"bottom":return{x:R.x+I.width*A.offset,y:R.y+I.height};case"left":return{x:R.x,y:R.y+I.height*A.offset};case"right":return{x:R.x+I.width,y:R.y+I.height*A.offset};default:return ct(h)}},[i,ct]),nr=x.useCallback(h=>{const C=Oe(h.sourceNodeId,h.sourcePortId),z=Oe(h.targetNodeId,h.targetPortId);switch(h.style.lineType??"bezier"){case"straight":return`M ${C.x} ${C.y} L ${z.x} ${z.y}`;case"orthogonal":{const R=(C.x+z.x)/2;return`M ${C.x} ${C.y} L ${R} ${C.y} L ${R} ${z.y} L ${z.x} ${z.y}`}case"step":{const R=(C.y+z.y)/2;return`M ${C.x} ${C.y} L ${C.x} ${R} L ${z.x} ${R} L ${z.x} ${z.y}`}case"bezier":default:{const R=Math.abs(z.x-C.x)*.5;return`M ${C.x} ${C.y} C ${C.x+R} ${C.y}, ${z.x-R} ${z.y}, ${z.x} ${z.y}`}}},[Oe]),sr=x.useCallback((h,C)=>{const{size:z,style:A,shape:R}=h,I=z.width,D=z.height,K=!!(A.gradientColor&&A.backgroundColor)?`url(#${C})`:A.backgroundColor??"var(--nice-bg, #fff)",Z=A.borderColor??"var(--nice-text, #333333)",oe=A.borderWidth??1,he=A.borderRadius??(R==="roundedRect"?8:0),ne=A.borderStyle==="dashed"?"8,4":A.borderStyle==="dotted"?"2,4":void 0,ce=A.shadow?"url(#nd-shadow)":void 0;switch(R){case"ellipse":case"circle":return n.jsx("ellipse",{cx:I/2,cy:D/2,rx:I/2,ry:D/2,fill:K,stroke:Z,strokeWidth:oe,strokeDasharray:ne,filter:ce});case"diamond":return n.jsx("polygon",{points:`${I/2},0 ${I},${D/2} ${I/2},${D} 0,${D/2}`,fill:K,stroke:Z,strokeWidth:oe,strokeDasharray:ne,filter:ce});case"hexagon":{const pe=I/4;return n.jsx("polygon",{points:`${pe},0 ${I-pe},0 ${I},${D/2} ${I-pe},${D} ${pe},${D} 0,${D/2}`,fill:K,stroke:Z,strokeWidth:oe,strokeDasharray:ne,filter:ce})}case"parallelogram":{const pe=I*.15;return n.jsx("polygon",{points:`${pe},0 ${I},0 ${I-pe},${D} 0,${D}`,fill:K,stroke:Z,strokeWidth:oe,strokeDasharray:ne,filter:ce})}case"cylinder":return n.jsxs("g",{filter:ce,children:[n.jsx("ellipse",{cx:I/2,cy:D*.1,rx:I/2,ry:D*.1,fill:K,stroke:Z,strokeWidth:oe}),n.jsx("rect",{x:0,y:D*.1,width:I,height:D*.8,fill:K,stroke:"none"}),n.jsx("line",{x1:0,y1:D*.1,x2:0,y2:D*.9,stroke:Z,strokeWidth:oe}),n.jsx("line",{x1:I,y1:D*.1,x2:I,y2:D*.9,stroke:Z,strokeWidth:oe}),n.jsx("ellipse",{cx:I/2,cy:D*.9,rx:I/2,ry:D*.1,fill:K,stroke:Z,strokeWidth:oe})]});case"triangle":return n.jsx("polygon",{points:`${I/2},0 ${I},${D} 0,${D}`,fill:K,stroke:Z,strokeWidth:oe,strokeDasharray:ne,filter:ce});case"cloud":{const pe=`M${I*.25},${D*.8} A${I*.2},${I*.2},0,1,1,${I*.15},${D*.45} A${I*.18},${I*.18},0,1,1,${I*.35},${D*.2} A${I*.2},${I*.2},0,1,1,${I*.65},${D*.2} A${I*.18},${I*.18},0,1,1,${I*.85},${D*.45} A${I*.2},${I*.2},0,1,1,${I*.75},${D*.8} Z`;return n.jsx("path",{d:pe,fill:K,stroke:Z,strokeWidth:oe,filter:ce})}case"document":{const pe=`M 0 0 L ${I} 0 L ${I} ${D*.85} Q ${I*.75} ${D*.7}, ${I*.5} ${D*.85} Q ${I*.25} ${D}, 0 ${D*.85} Z`;return n.jsx("path",{d:pe,fill:K,stroke:Z,strokeWidth:oe,filter:ce})}case"actor":return n.jsxs("g",{stroke:Z,strokeWidth:oe,fill:"none",filter:ce,children:[n.jsx("circle",{cx:I/2,cy:D*.15,r:D*.12,fill:K}),n.jsx("line",{x1:I/2,y1:D*.27,x2:I/2,y2:D*.6}),n.jsx("line",{x1:I*.15,y1:D*.4,x2:I*.85,y2:D*.4}),n.jsx("line",{x1:I/2,y1:D*.6,x2:I*.2,y2:D}),n.jsx("line",{x1:I/2,y1:D*.6,x2:I*.8,y2:D})]});case"rectangle":case"roundedRect":case"custom":default:return n.jsx("rect",{width:I,height:D,rx:he,ry:he,fill:K,stroke:Z,strokeWidth:oe,strokeDasharray:ne,filter:ce})}},[]),kt=x.useCallback(h=>{if(!b)return{};const C=b.get(h);if(!C)return{};const z=C.glow>0?`drop-shadow(0 0 ${C.glow}px gold)`:"",A=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:[z,A].filter(Boolean).join(" ")||void 0}},[b]),lr=x.useMemo(()=>{if(!v)return null;const h=[];for(const[,C]of v.glowStates){const z=Dt(C.elementId),A=$t(C.intensity,C.pulse);h.push(n.jsxs("filter",{id:z,x:"-50%",y:"-50%",width:"200%",height:"200%",children:[n.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:A,result:"blur"}),n.jsx("feFlood",{floodColor:C.color,floodOpacity:.6,result:"color"}),n.jsx("feComposite",{in:"color",in2:"blur",operator:"in",result:"glowColored"}),n.jsxs("feMerge",{children:[n.jsx("feMergeNode",{in:"glowColored"}),n.jsx("feMergeNode",{in:"SourceGraphic"})]})]},z))}return h},[v]),cr=x.useMemo(()=>{if(!v)return null;const h=[];for(const[C,z]of v.liquidFlows){if(!z.active)continue;const A=e.find(K=>K.id===C);if(!(A!=null&&A.style.liquidFlow))continue;const{color:R,colorEnd:I}=A.style.liquidFlow,D=`nd-liquid-${C}`,te=z.gradientOffset;h.push(n.jsxs("linearGradient",{id:D,x1:"0",y1:"0",x2:"1",y2:"0",children:[n.jsx("stop",{offset:`${te*100%100}%`,stopColor:R,stopOpacity:.8}),n.jsx("stop",{offset:`${(te+.3)*100%100}%`,stopColor:I??R,stopOpacity:.4}),n.jsx("stop",{offset:`${(te+.6)*100%100}%`,stopColor:R,stopOpacity:.8})]},D))}return h},[v,e]),dr=x.useMemo(()=>i.filter(h=>h.style.gradientColor&&h.style.backgroundColor).map(h=>{const C=`nd-grad-${h.id}`,z=h.style.gradientDirection??"vertical";if(z==="radial")return n.jsxs("radialGradient",{id:C,children:[n.jsx("stop",{offset:"0%",stopColor:h.style.backgroundColor}),n.jsx("stop",{offset:"100%",stopColor:h.style.gradientColor})]},C);const A=z==="horizontal"||z==="diagonal"?"1":"0",R=z==="vertical"||z==="diagonal"?"1":"0";return n.jsxs("linearGradient",{id:C,x1:"0",y1:"0",x2:A,y2:R,children:[n.jsx("stop",{offset:"0%",stopColor:h.style.backgroundColor}),n.jsx("stop",{offset:"100%",stopColor:h.style.gradientColor})]},C)}),[i]);return n.jsxs("svg",{ref:N,className:`nice-diagram-canvas ${G??""}`,style:{width:"100%",height:"100%",background:at,cursor:Y?"grabbing":ee&&ee.nodeId?ft[ee.handleIdx].cursor:"default"},onWheel:je,onMouseDown:nt,onMouseMove:Ve,onMouseUp:Ge,onMouseLeave:Ge,children:[n.jsxs("defs",{children:[n.jsx("marker",{id:"nd-arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:n.jsx("path",{d:"M 0 0 L 10 5 L 0 10 Z",fill:"var(--nice-text, #333)"})}),n.jsx("marker",{id:"nd-open-arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:n.jsx("path",{d:"M 0 0 L 10 5 L 0 10",fill:"none",stroke:"var(--nice-text, #333)",strokeWidth:"1.5"})}),n.jsx("marker",{id:"nd-diamond-marker",viewBox:"0 0 10 10",refX:"5",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"15",markerHeight:"15",orient:"auto-start-reverse",children:n.jsx("polygon",{points:"5,0 10,5 5,10 0,5",fill:"var(--nice-text, #333)"})}),n.jsx("marker",{id:"nd-circle-marker",viewBox:"0 0 10 10",refX:"5",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:"12",markerHeight:"12",orient:"auto-start-reverse",children:n.jsx("circle",{cx:"5",cy:"5",r:"4",fill:"var(--nice-text, #333)"})}),n.jsx("filter",{id:"nd-shadow",x:"-10%",y:"-10%",width:"130%",height:"130%",children:n.jsx("feDropShadow",{dx:"2",dy:"2",stdDeviation:"3",floodColor:"#00000033"})}),O&&n.jsx("pattern",{id:"nd-grid",width:Se,height:Se,patternUnits:"userSpaceOnUse",children:n.jsx("path",{d:`M ${Se} 0 L 0 0 0 ${Se}`,fill:"none",stroke:We,strokeWidth:"0.5"})}),dr,lr,cr,i.filter(h=>h.style.glowColor).map(h=>{const C=`nd-node-glow-${h.id}`,z=(h.style.glowIntensity??.5)*10;return n.jsxs("filter",{id:C,x:"-50%",y:"-50%",width:"200%",height:"200%",children:[n.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:z,result:"blur"}),n.jsx("feFlood",{floodColor:h.style.glowColor,floodOpacity:.5,result:"color"}),n.jsx("feComposite",{in:"color",in2:"blur",operator:"in",result:"glowColored"}),n.jsxs("feMerge",{children:[n.jsx("feMergeNode",{in:"glowColored"}),n.jsx("feMergeNode",{in:"SourceGraphic"})]})]},C)})]}),B&&n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"0",y:"0",width:"100%",height:"20",fill:"var(--nice-bg-secondary, #f0f0f0)",stroke:"var(--nice-border, #ccc)",strokeWidth:"0.5"}),n.jsx("rect",{x:"0",y:"0",width:"20",height:"100%",fill:"var(--nice-bg-secondary, #f0f0f0)",stroke:"var(--nice-border, #ccc)",strokeWidth:"0.5"}),Array.from({length:100},(h,C)=>{const z=C*Se*r.zoom+r.x,A=C*Se;return z>20?n.jsxs("g",{children:[n.jsx("line",{x1:z,y1:"0",x2:z,y2:"20",stroke:"var(--nice-text-muted, #999)",strokeWidth:"0.5"}),n.jsx("text",{x:z+2,y:"14",fontSize:"9",fill:"var(--nice-text-secondary, #666)",children:A})]},`rx${C}`):null}),Array.from({length:100},(h,C)=>{const z=C*Se*r.zoom+r.y,A=C*Se;return z>20?n.jsxs("g",{children:[n.jsx("line",{x1:"0",y1:z,x2:"20",y2:z,stroke:"var(--nice-text-muted, #999)",strokeWidth:"0.5"}),n.jsx("text",{x:"2",y:z-2,fontSize:"9",fill:"var(--nice-text-secondary, #666)",writingMode:"tb",children:A})]},`ry${C}`):null})]}),n.jsxs("g",{transform:`translate(${r.x}, ${r.y}) scale(${r.zoom})`,children:[O&&n.jsx("rect",{x:"-10000",y:"-10000",width:"20000",height:"20000",fill:"url(#nd-grid)"}),t.map(h=>{var te,K,Z,oe,he,ne,ce,pe,_e,ze,Ne,Ye;const C=i.filter(se=>h.nodeIds.includes(se.id));if(C.length===0&&!h.collapsed)return null;const z=((te=h.style)==null?void 0:te.padding)??20;if(h.collapsed){const se=i.find(dt=>h.nodeIds.includes(dt.id)),Te=se?se.position.x:0,Ue=se?se.position.y:0;return n.jsxs("g",{"data-group-id":h.id,style:{cursor:"pointer"},onClick:()=>M==null?void 0:M(h.id),children:[n.jsx("rect",{x:Te,y:Ue,width:160,height:40,fill:((K=h.style)==null?void 0:K.backgroundColor)??"rgba(200,200,255,0.3)",stroke:((Z=h.style)==null?void 0:Z.borderColor)??"var(--nice-text-muted, #aab)",strokeWidth:((oe=h.style)==null?void 0:oe.borderWidth)??1,rx:((he=h.style)==null?void 0:he.borderRadius)??6,strokeDasharray:"6,3"}),n.jsxs("text",{x:Te+24,y:Ue+24,fontSize:"12",fill:((ne=h.style)==null?void 0:ne.labelColor)??"var(--nice-text-secondary, #666)",fontWeight:"bold",children:[h.label," (",h.nodeIds.length,")"]})]},h.id)}const A=Math.min(...C.map(se=>se.position.x))-z,R=Math.min(...C.map(se=>se.position.y))-z,I=Math.max(...C.map(se=>se.position.x+se.size.width))+z,D=Math.max(...C.map(se=>se.position.y+se.size.height))+z;return n.jsxs("g",{"data-group-id":h.id,children:[n.jsx("rect",{x:A,y:R,width:I-A,height:D-R,fill:((ce=h.style)==null?void 0:ce.backgroundColor)??"rgba(200,200,255,0.1)",stroke:((pe=h.style)==null?void 0:pe.borderColor)??"var(--nice-text-muted, #aab)",strokeWidth:((_e=h.style)==null?void 0:_e.borderWidth)??1,rx:((ze=h.style)==null?void 0:ze.borderRadius)??6,strokeDasharray:((Ne=h.style)==null?void 0:Ne.borderStyle)==="dashed"?"6,3":void 0}),n.jsx("text",{x:A+6,y:R-4,fontSize:"12",fill:((Ye=h.style)==null?void 0:Ye.labelColor)??"var(--nice-text-secondary, #666)",fontWeight:"bold",style:T?{cursor:"pointer"}:void 0,onClick:T?se=>{se.stopPropagation(),T(h.id)}:void 0,children:h.label}),(j||g!=="editor")&&M&&n.jsxs("g",{style:{cursor:"pointer"},onClick:se=>{se.stopPropagation(),M(h.id)},children:[n.jsx("rect",{x:I-24,y:R-12,width:20,height:20,rx:4,fill:"white",stroke:"var(--nice-text-muted, #999)",strokeWidth:1}),n.jsx("g",{transform:`translate(${I-20}, ${R-8})`,children:n.jsx(y.NiceIcon,{name:"chevron-down",size:12,color:"var(--nice-text-secondary, #666)"})})]})]},h.id)}),ot.map((h,C)=>n.jsx("line",{x1:h.x!=null?h.x:-1e4,y1:h.y!=null?h.y:-1e4,x2:h.x!=null?h.x:1e4,y2:h.y!=null?h.y:1e4,stroke:"#ff4081",strokeWidth:.5,strokeDasharray:"4,4"},`snap-${C}`)),e.map(h=>{var he;const C=nr(h),z=Be.has(h.id),A=h.style.targetArrow==="diamond"?"url(#nd-diamond-marker)":h.style.targetArrow==="circle"?"url(#nd-circle-marker)":h.style.targetArrow==="openArrow"?"url(#nd-open-arrow)":h.style.targetArrow!=="none"?"url(#nd-arrow)":void 0,R=h.style.sourceArrow==="diamond"?"url(#nd-diamond-marker)":h.style.sourceArrow==="circle"?"url(#nd-circle-marker)":h.style.sourceArrow==="openArrow"?"url(#nd-open-arrow)":h.style.sourceArrow==="arrow"?"url(#nd-arrow)":void 0,I=kt(h.id),D=b==null?void 0:b.get(h.id),te=D==null?void 0:D.strokeProgress,K=te!=null&&te>=0&&te<1?{strokeDasharray:"1000",strokeDashoffset:`${1e3*(1-te)}`}:void 0,Z=h.style.liquidFlow,oe=v==null?void 0:v.liquidFlows.get(h.id);return n.jsxs("g",{"data-edge-id":h.id,style:I,onClick:ne=>we(ne,h.id),children:[j&&n.jsx("path",{d:C,fill:"none",stroke:"transparent",strokeWidth:12,style:{cursor:"pointer"}}),(Z==null?void 0:Z.active)&&n.jsx("path",{d:C,fill:"none",stroke:`url(#nd-liquid-${h.id})`,strokeWidth:Z.pipeWidth??(h.style.strokeWidth??1.5)*4,strokeLinecap:"round",opacity:.5}),n.jsx("path",{d:C,fill:"none",stroke:z?ve:h.style.strokeColor??"var(--nice-text, #333)",strokeWidth:h.style.strokeWidth??1.5,strokeDasharray:(K==null?void 0:K.strokeDasharray)??((he=h.style.strokeDash)==null?void 0:he.join(","))??(h.style.animated?"6,4":void 0),strokeDashoffset:K==null?void 0:K.strokeDashoffset,markerEnd:A,markerStart:R,opacity:h.style.opacity??1,style:j?{cursor:"pointer",transition:K?void 0:"stroke-dashoffset 0.1s"}:void 0}),h.style.animated&&n.jsx("circle",{r:3,fill:ve,children:n.jsx("animateMotion",{dur:`${1/(h.style.flowSpeed||1)}s`,repeatCount:"indefinite",path:C})}),(oe==null?void 0:oe.active)&&oe.particles.map((ne,ce)=>n.jsx("circle",{r:ne.size,fill:(Z==null?void 0:Z.color)??"var(--nice-primary, #3b82f6)",opacity:ne.opacity*.6,children:n.jsx("animateMotion",{dur:`${3/(((Z==null?void 0:Z.speed)??1)+.5)}s`,repeatCount:"indefinite",path:C,begin:`${ne.t*3}s`})},`lp-${h.id}-${ce}`)),D&&D.particleTrailT>=0&&n.jsxs(n.Fragment,{children:[n.jsx("circle",{r:4,fill:"var(--nice-warning-light, #fbbf24)",opacity:.8,children:n.jsx("animateMotion",{dur:"2s",repeatCount:"indefinite",path:C,begin:`${D.particleTrailT*2}s`})}),n.jsx("circle",{r:2,fill:"var(--nice-warning-light, #fbbf24)",opacity:.5,children:n.jsx("animateMotion",{dur:"2s",repeatCount:"indefinite",path:C,begin:`${(D.particleTrailT+.1)*2}s`})})]}),h.label&&(()=>{const ne=Oe(h.sourceNodeId,h.sourcePortId),ce=Oe(h.targetNodeId,h.targetPortId),pe=(ne.x+ce.x)/2,_e=(ne.y+ce.y)/2;return n.jsxs("g",{children:[n.jsx("rect",{x:pe-4,y:_e-16,width:h.label.length*7+8,height:18,rx:3,fill:"var(--nice-bg-primary, #fff)",fillOpacity:.85}),n.jsx("text",{x:pe,y:_e-2,textAnchor:"start",fontSize:"11",fill:"var(--nice-text-secondary, #555)",children:h.label})]})})()]},h.id)}),i.filter(h=>!h.hidden||g==="editor").map(h=>{const C=Be.has(h.id),z=kt(h.id),A=b==null?void 0:b.get(h.id),R=h.style.fontFamily??(a==null?void 0:a.fontFamily)??"sans-serif",I=h.style.fontSize??14,D=h.style.fontColor??"var(--nice-text, #222)",te=h.style.fontWeight??"normal",K=h.style.fontStyle??"normal",Z=h.style.textAlign??"center",oe=h.style.rotation??0,he=`nd-grad-${h.id}`,ne=!!h.hidden,ce=ne?S??.3:h.style.opacity??1,pe=h.style.glowColor?`url(#nd-node-glow-${h.id})`:void 0,_e=Z==="left"?"start":Z==="right"?"end":"middle",ze=Z==="left"?8:Z==="right"?h.size.width-8:h.size.width/2,Ne=A==null?void 0:A.typewriterChars,Ye=Ne!=null&&Ne>=0?h.label.slice(0,Ne):h.label,se=A==null?void 0:A.liquidFillProgress,Te=A==null?void 0:A.rippleRadius,Ue=A==null?void 0:A.rippleOpacity,dt=h.childNodeIds&&h.childNodeIds.length>0,ur=!!h.collapsed;return n.jsxs("g",{"data-node-id":h.id,transform:`translate(${h.position.x}, ${h.position.y})${oe?` rotate(${oe}, ${h.size.width/2}, ${h.size.height/2})`:""}`,style:{...z,cursor:ne?"pointer":j&&!h.locked?"grab":"default",opacity:ce,filter:pe},onMouseDown:ye=>st(ye,h.id),onDoubleClick:ye=>H(ye,h.id),onClick:ye=>{ye.stopPropagation(),c==null||c(h.id),h.interactions&&h.interactions.length>0&&h.interactions.filter(Fe=>Fe.trigger==="click").forEach(Fe=>_==null?void 0:_(h.id,Fe.id))},onMouseEnter:()=>{k==null||k(h.id),h.interactions&&h.interactions.filter(Ie=>Ie.trigger==="hover").forEach(Ie=>_==null?void 0:_(h.id,Ie.id))},onMouseLeave:()=>k==null?void 0:k(null),children:[ne&&n.jsx("rect",{x:-1,y:-1,width:h.size.width+2,height:h.size.height+2,fill:"none",stroke:"var(--nice-text-muted, #999)",strokeWidth:1,strokeDasharray:"3,3",rx:4,opacity:.5}),sr(h,he),se!=null&&se>0&&se<1&&n.jsx("clipPath",{id:`nd-liquid-clip-${h.id}`,children:n.jsx("rect",{x:0,y:h.size.height*(1-se),width:h.size.width,height:h.size.height*se})}),se!=null&&se>0&&se<1&&n.jsx("rect",{x:0,y:0,width:h.size.width,height:h.size.height,fill:h.style.glowColor??"var(--nice-primary, #3b82f6)",opacity:.25,rx:h.style.borderRadius??4,clipPath:`url(#nd-liquid-clip-${h.id})`}),Te!=null&&Te>0&&n.jsx("circle",{cx:h.size.width/2,cy:h.size.height/2,r:Te,fill:"none",stroke:h.style.glowColor??ve,strokeWidth:2,opacity:Ue??.5}),C&&n.jsx("rect",{x:-3,y:-3,width:h.size.width+6,height:h.size.height+6,fill:"none",stroke:ve,strokeWidth:2,strokeDasharray:"4,3",rx:6}),C&&j&&!h.locked&&ft.map((ye,Ie)=>n.jsx("rect",{x:ye.dx*h.size.width-He/2,y:ye.dy*h.size.height-He/2,width:He,height:He,fill:"white",stroke:ve,strokeWidth:1.5,rx:1,style:{cursor:ye.cursor},onMouseDown:Fe=>lt(Fe,h.id,Ie)},Ie)),me===h.id?n.jsx("foreignObject",{x:4,y:4,width:h.size.width-8,height:h.size.height-8,children:n.jsx("input",{xmlns:"http://www.w3.org/1999/xhtml",type:"text",value:Ee,onChange:ye=>F(ye.target.value),onBlur:De,onKeyDown:ye=>{ye.key==="Enter"&&De(),ye.key==="Escape"&&Ce(null)},autoFocus:!0,style:{width:"100%",height:"100%",border:"1px solid "+ve,borderRadius:3,padding:"2px 4px",fontSize:I,fontFamily:R,fontWeight:te,fontStyle:K,textAlign:Z,background:"var(--nice-overlay-light-95, rgba(255, 255, 255, 0.95))",outline:"none"}})}):n.jsxs(n.Fragment,{children:[n.jsx("text",{x:ze,y:h.size.height/2+(h.description?-4:0),textAnchor:_e,dominantBaseline:"central",fontFamily:R,fontSize:I,fontWeight:te,fontStyle:K,fill:D,pointerEvents:"none",children:Ye}),h.description&&n.jsx("text",{x:ze,y:h.size.height/2+I*.8,textAnchor:_e,dominantBaseline:"central",fontFamily:R,fontSize:I*.75,fill:"var(--nice-text-secondary, #777)",pointerEvents:"none",children:h.description}),h.icon&&(Ni.test(h.icon)?n.jsx("g",{transform:`translate(${h.size.width/2-8}, 4)`,pointerEvents:"none",children:n.jsx(y.NiceIcon,{name:h.icon,size:16,color:"var(--nice-text-secondary, #666)"})}):n.jsx("text",{x:h.size.width/2,y:14,textAnchor:"middle",fontSize:16,pointerEvents:"none",children:h.icon})),h.style.linkUrl&&n.jsx("g",{transform:`translate(${h.size.width-14}, 3)`,pointerEvents:"none",children:n.jsx(y.NiceIcon,{name:"link",size:10,color:"var(--nice-primary-hover, #1976d2)"})}),dt&&j&&n.jsxs("g",{onClick:ye=>{ye.stopPropagation(),$==null||$(h.id)},style:{cursor:"pointer"},children:[n.jsx("rect",{x:h.size.width-18,y:h.size.height-18,width:16,height:16,rx:3,fill:"white",stroke:"var(--nice-text-muted, #aaa)",strokeWidth:.5}),n.jsx("g",{transform:`translate(${h.size.width-15}, ${h.size.height-15})`,children:n.jsx(y.NiceIcon,{name:ur?"chevron-right":"chevron-down",size:10,color:"var(--nice-text-secondary, #666)"})})]})]}),j&&h.ports.map(ye=>{const Ie=zi(h,ye.id);return n.jsx("circle",{cx:Ie.x,cy:Ie.y,r:4,fill:"var(--nice-bg, #fff)",stroke:"var(--nice-text-secondary, #666)",strokeWidth:1,style:{cursor:"crosshair"}},ye.id)})]},h.id)}),v&&v.particles.length>0&&n.jsx("g",{className:"nd-particle-overlay",children:v.particles.map((h,C)=>n.jsx("circle",{cx:h.x,cy:h.y,r:h.size,fill:h.color,opacity:h.opacity},`ptcl-${C}`))}),re&&n.jsx("rect",{x:Math.min(re.x1,re.x2),y:Math.min(re.y1,re.y2),width:Math.abs(re.x2-re.x1),height:Math.abs(re.y2-re.y1),fill:"rgba(33,150,243,0.1)",stroke:ve,strokeWidth:1,strokeDasharray:"4,2"})]})]})};process.env.NODE_ENV!=="production"&&(ke.displayName="DiagramCanvas");function zi(i,e){const t=i.ports.find(o=>o.id===e);if(!t)return{x:0,y:0};const{size:r}=i;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 Ii=180,Ai=120,et=({nodes:i,edges:e,viewport:t,onViewportChange:r,canvasWidth:o=800,canvasHeight:a=600,width:l=Ii,height:s=Ai,className:c})=>{const f=x.useMemo(()=>{if(i.length===0)return{minX:0,minY:0,maxX:400,maxY:300};let b=1/0,v=1/0,g=-1/0,S=-1/0;for(const $ of i)b=Math.min(b,$.position.x),v=Math.min(v,$.position.y),g=Math.max(g,$.position.x+$.size.width),S=Math.max(S,$.position.y+$.size.height);const M=50;return{minX:b-M,minY:v-M,maxX:g+M,maxY:S+M}},[i]),d=f.maxX-f.minX,m=f.maxY-f.minY,w=Math.min(l/d,s/m),u=x.useMemo(()=>{const b=(-t.x/t.zoom-f.minX)*w,v=(-t.y/t.zoom-f.minY)*w,g=o/t.zoom*w,S=a/t.zoom*w;return{x:b,y:v,w:g,h:S}},[t,f,w,o,a]),p=x.useCallback(b=>{if(!r)return;const v=b.currentTarget.getBoundingClientRect(),g=b.clientX-v.left,S=b.clientY-v.top,M=g/w+f.minX,$=S/w+f.minY;r({...t,x:-(M*t.zoom-o/2),y:-($*t.zoom-a/2)})},[r,t,w,f,o,a]);return n.jsxs("svg",{className:`nice-diagram-minimap ${c??""}`,width:l,height:s,style:{border:"1px solid var(--nice-border, #ccc)",background:"var(--nice-bg, #fff)",borderRadius:4,cursor:"pointer"},onClick:p,children:[e.map(b=>{const v=i.find(k=>k.id===b.sourceNodeId),g=i.find(k=>k.id===b.targetNodeId);if(!v||!g)return null;const S=(v.position.x+v.size.width/2-f.minX)*w,M=(v.position.y+v.size.height/2-f.minY)*w,$=(g.position.x+g.size.width/2-f.minX)*w,_=(g.position.y+g.size.height/2-f.minY)*w;return n.jsx("line",{x1:S,y1:M,x2:$,y2:_,stroke:"var(--nice-text-muted, #aaa)",strokeWidth:.5},b.id)}),i.map(b=>n.jsx("rect",{x:(b.position.x-f.minX)*w,y:(b.position.y-f.minY)*w,width:b.size.width*w,height:b.size.height*w,fill:b.style.backgroundColor??"var(--nice-border, #ddd)",stroke:"var(--nice-text-muted, #999)",strokeWidth:.5},b.id)),n.jsx("rect",{x:u.x,y:u.y,width:u.w,height:u.h,fill:"color-mix(in srgb, var(--nice-primary, #2196f3) 15%, transparent)",stroke:"var(--nice-primary, #2196f3)",strokeWidth:1})]})};process.env.NODE_ENV!=="production"&&(et.displayName="DiagramMinimap");const ji=["rectangle","roundedRect","ellipse","circle","diamond","hexagon","parallelogram","cylinder","triangle","cloud","document","actor"],tt=({selectedNode:i,selectedEdge:e,onNodeChange:t,onEdgeChange:r,onRemove:o,className:a})=>{var f,d,m,w,u;const{t:l}=Le(),s=x.useCallback((p,b)=>{!i||!t||t(i.id,{style:{...i.style,[p]:b}})},[i,t]),c=x.useCallback((p,b)=>{!e||!r||r(e.id,{style:{...e.style,[p]:b}})},[e,r]);return!i&&!e?n.jsx("div",{className:`nice-diagram-property-panel nice-diagram-property-panel--empty ${a??""}`,children:n.jsx("p",{className:"nice-diagram-property-panel__hint",children:l("panel.noSelection")})}):i?n.jsxs("div",{className:`nice-diagram-property-panel ${a??""}`,children:[n.jsx("h3",{className:"nice-diagram-property-panel__title",children:l("panel.nodeProperties")}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[l("node.label"),n.jsx(y.NiceTextInput,{value:i.label,onChange:p=>t==null?void 0:t(i.id,{label:p}),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[l("node.description"),n.jsx(y.NiceTextInput,{value:i.description??"",onChange:p=>t==null?void 0:t(i.id,{description:p||void 0}),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[l("node.shape"),n.jsx(y.NiceSelect,{value:i.shape,onChange:p=>t==null?void 0:t(i.id,{shape:p}),options:ji.map(p=>({value:p,label:p})),className:"nice-diagram-property-panel__select"})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("node.width"),n.jsx(y.NiceNumberInput,{value:i.size.width,min:20,onChange:p=>t==null?void 0:t(i.id,{size:{...i.size,width:p??40}}),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("node.height"),n.jsx(y.NiceNumberInput,{value:i.size.height,min:20,onChange:p=>t==null?void 0:t(i.id,{size:{...i.size,height:p??40}}),className:"nice-diagram-property-panel__input"})]})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("node.bgColor"),n.jsx(y.NiceColorPicker,{value:i.style.backgroundColor??"var(--nice-bg, #fff)",onChange:p=>s("backgroundColor",p),className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("node.borderColor"),n.jsx(y.NiceColorPicker,{value:i.style.borderColor??"var(--nice-text, #333333)",onChange:p=>s("borderColor",p),className:"nice-diagram-property-panel__color"})]})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("node.fontSize"),n.jsx(y.NiceNumberInput,{value:i.style.fontSize??14,min:8,max:72,onChange:p=>s("fontSize",p??14),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("node.fontColor"),n.jsx(y.NiceColorPicker,{value:i.style.fontColor??"#222222",onChange:p=>s("fontColor",p),className:"nice-diagram-property-panel__color"})]})]}),n.jsx(y.NiceCheckbox,{checked:i.locked??!1,onChange:p=>t==null?void 0:t(i.id,{locked:p}),label:l("node.locked"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),n.jsx("h4",{className:"nice-diagram-property-panel__section-title",style:{fontSize:12,marginTop:12,marginBottom:4,color:"var(--nice-text-secondary, #666)"},children:l("node.effects","Effects")}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("node.glowColor","Glow Color"),n.jsx(y.NiceColorPicker,{value:i.style.glowColor??"var(--nice-primary, #3b82f6)",onChange:p=>s("glowColor",p),className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("node.glowIntensity","Glow Intensity"),n.jsx(y.NiceSlider,{min:0,max:3,step:.1,value:i.style.glowIntensity??0,onChange:p=>s("glowIntensity",p),className:"nice-diagram-property-panel__input"})]})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[l("node.opacity","Opacity"),n.jsx(y.NiceSlider,{min:0,max:1,step:.05,value:i.style.opacity??1,onChange:p=>s("opacity",p),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[l("node.borderRadius","Border Radius"),n.jsx(y.NiceNumberInput,{min:0,max:50,value:i.style.borderRadius??4,onChange:p=>s("borderRadius",p??4),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[l("node.borderWidth","Border Width"),n.jsx(y.NiceNumberInput,{min:0,max:10,step:.5,value:i.style.borderWidth??1,onChange:p=>s("borderWidth",p??1),className:"nice-diagram-property-panel__input"})]}),n.jsx(y.NiceCheckbox,{checked:i.style.shadow??!1,onChange:p=>s("shadow",p),label:l("node.shadow","Shadow"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("node.gradientEnd","Gradient End"),n.jsx(y.NiceColorPicker,{value:i.style.gradientColor??"var(--nice-bg, #fff)",onChange:p=>s("gradientColor",p),className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("node.gradientDir","Gradient Dir"),n.jsx(y.NiceSelect,{value:i.style.gradientDirection??"vertical",onChange:p=>s("gradientDirection",p),options:[{value:"vertical",label:"Vertical"},{value:"horizontal",label:"Horizontal"},{value:"diagonal",label:"Diagonal"},{value:"radial",label:"Radial"}],className:"nice-diagram-property-panel__select"})]})]}),n.jsx(y.NiceCheckbox,{checked:i.hidden??!1,onChange:p=>t==null?void 0:t(i.id,{hidden:p}),label:l("node.hiddenGhostInEditor","Hidden (ghost in editor)"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),n.jsx(y.NiceButton,{className:"nice-diagram-property-panel__btn nice-diagram-property-panel__btn--danger",variant:"ghost",size:"sm",onClick:()=>o==null?void 0:o(i.id),children:l("toolbar.delete")})]}):e?n.jsxs("div",{className:`nice-diagram-property-panel ${a??""}`,children:[n.jsx("h3",{className:"nice-diagram-property-panel__title",children:l("panel.edgeProperties")}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[l("edge.label"),n.jsx(y.NiceTextInput,{value:e.label??"",onChange:p=>r==null?void 0:r(e.id,{label:p||void 0}),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[l("edge.lineType"),n.jsx(y.NiceSelect,{value:e.style.lineType??"bezier",onChange:p=>c("lineType",p),options:[{value:"straight",label:"Straight"},{value:"bezier",label:"Bezier"},{value:"orthogonal",label:"Orthogonal"},{value:"step",label:"Step"}],className:"nice-diagram-property-panel__select"})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("edge.color"),n.jsx(y.NiceColorPicker,{value:e.style.strokeColor??"var(--nice-text, #333333)",onChange:p=>c("strokeColor",p),className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("edge.width"),n.jsx(y.NiceNumberInput,{value:e.style.strokeWidth??1.5,min:.5,max:10,step:.5,onChange:p=>c("strokeWidth",p??1.5),className:"nice-diagram-property-panel__input"})]})]}),n.jsx(y.NiceCheckbox,{checked:e.style.animated??!1,onChange:p=>c("animated",p),label:l("edge.animated"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),e.style.animated&&n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[l("node.flowSpeed","Flow Speed"),n.jsx(y.NiceSlider,{min:.1,max:5,step:.1,value:e.style.flowSpeed??1,onChange:p=>c("flowSpeed",p),className:"nice-diagram-property-panel__input"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[l("node.dashStyle","Dash Style"),n.jsx(y.NiceSelect,{value:e.style.strokeDash?e.style.strokeDash.join(","):"solid",onChange:p=>{const b=p;b==="solid"?c("strokeDash",[]):c("strokeDash",b.split(",").map(Number))},options:[{value:"solid",label:"Solid"},{value:"6,4",label:"Dashed"},{value:"2,2",label:"Dotted"},{value:"8,4,2,4",label:"Dash-Dot"},{value:"12,6",label:"Long Dash"}],className:"nice-diagram-property-panel__select"})]}),n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("node.targetArrow","Target Arrow"),n.jsx(y.NiceSelect,{value:e.style.targetArrow??"arrow",onChange:p=>c("targetArrow",p),options:[{value:"arrow",label:"Arrow"},{value:"openArrow",label:"Open Arrow"},{value:"diamond",label:"Diamond"},{value:"circle",label:"Circle"},{value:"none",label:"None"}],className:"nice-diagram-property-panel__select"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("node.sourceArrow","Source Arrow"),n.jsx(y.NiceSelect,{value:e.style.sourceArrow??"none",onChange:p=>c("sourceArrow",p),options:[{value:"none",label:"None"},{value:"arrow",label:"Arrow"},{value:"openArrow",label:"Open Arrow"},{value:"diamond",label:"Diamond"},{value:"circle",label:"Circle"}],className:"nice-diagram-property-panel__select"})]})]}),n.jsx("h4",{className:"nice-diagram-property-panel__section-title",style:{fontSize:12,marginTop:12,marginBottom:4,color:"var(--nice-text-secondary, #666)"},children:l("node.liquidFlow","Liquid Flow")}),n.jsx(y.NiceCheckbox,{checked:((f=e.style.liquidFlow)==null?void 0:f.active)??!1,onChange:p=>{const b=e.style.liquidFlow??{active:!1,color:"var(--nice-primary, #3b82f6)",speed:1,pipeWidth:6};r==null||r(e.id,{style:{...e.style,liquidFlow:{...b,active:p}}})},label:l("node.enableLiquidFlow","Enable Liquid Flow"),className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--check"}),((d=e.style.liquidFlow)==null?void 0:d.active)&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"nice-diagram-property-panel__row",children:[n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("node.color","Color"),n.jsx(y.NiceColorPicker,{value:((m=e.style.liquidFlow)==null?void 0:m.color)??"var(--nice-primary, #3b82f6)",onChange:p=>{const b=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...b,color:p}}})},className:"nice-diagram-property-panel__color"})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label nice-diagram-property-panel__label--half",children:[l("node.speed","Speed"),n.jsx(y.NiceSlider,{min:.1,max:5,step:.1,value:((w=e.style.liquidFlow)==null?void 0:w.speed)??1,onChange:p=>{const b=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...b,speed:p}}})},className:"nice-diagram-property-panel__input"})]})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[l("node.pipeWidth","Pipe Width"),n.jsx(y.NiceNumberInput,{min:2,max:20,value:((u=e.style.liquidFlow)==null?void 0:u.pipeWidth)??6,onChange:p=>{const b=e.style.liquidFlow;r==null||r(e.id,{style:{...e.style,liquidFlow:{...b,pipeWidth:p??6}}})},className:"nice-diagram-property-panel__input"})]})]}),n.jsxs("label",{className:"nice-diagram-property-panel__label",children:[l("node.opacity","Opacity"),n.jsx(y.NiceSlider,{min:0,max:1,step:.05,value:e.style.opacity??1,onChange:p=>c("opacity",p),className:"nice-diagram-property-panel__input"})]}),n.jsx(y.NiceButton,{className:"nice-diagram-property-panel__btn nice-diagram-property-panel__btn--danger",variant:"ghost",size:"sm",onClick:()=>o==null?void 0:o(e.id),children:l("toolbar.delete")})]}):null};process.env.NODE_ENV!=="production"&&(tt.displayName="DiagramPropertyPanel");const Nt={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"]},Di=["dagre","forceDirected","grid","radial","tree"],$i=["sans-serif","serif","monospace","Arial","Helvetica","Times New Roman","Courier New","Georgia","Verdana","Tahoma","Trebuchet MS"],Ti=[8,9,10,11,12,14,16,18,20,24,28,32,36,48,72],rt=({activeTool:i,onToolChange:e,diagramType:t,onAddNode:r,onApplyLayout:o,onUndo:a,onRedo:l,canUndo:s=!1,canRedo:c=!1,onExport:f,onZoomIn:d,onZoomOut:m,onZoomReset:w,zoomLevel:u=1,onToggleBold:p,onToggleItalic:b,isBold:v=!1,isItalic:g=!1,onFontFamilyChange:S,currentFontFamily:M="sans-serif",onFontSizeChange:$,currentFontSize:_=14,onAlignLeft:k,onAlignCenterH:T,onAlignRight:j,onAlignTop:O,onAlignCenterV:B,onAlignBottom:U,onDistributeH:L,onDistributeV:G,onBringToFront:N,onSendToBack:Y,onGroupSelected:P,onUngroupSelected:V,onCopy:E,onPaste:q,onDuplicate:X,onSelectAll:J,selectionCount:fe=0,onFind:re,showFind:be=!1,findQuery:W="",onFindQueryChange:Q,viewMode:ee="editor",onViewModeChange:le,stylePresetId:me,onStylePresetChange:Ce,className:Ee})=>{const{t:F}=Le(),[ot,Re]=x.useState(!1),[at,We]=x.useState(!1),[Se,ve]=x.useState(!1),[Be,ge]=x.useState(!1),[qe,je]=x.useState(!1),[nt,Ve]=x.useState(!1),Ge=Nt[t]??Nt.custom,st=x.useCallback(H=>{r==null||r(H),Re(!1)},[r]),lt=x.useCallback(H=>{o==null||o(H),We(!1)},[o]);return n.jsxs("div",{className:`nice-diagram-toolbar ${Ee??""}`,children:[n.jsxs("div",{className:"nice-diagram-toolbar__row",children:[n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:i==="select"?"primary":"ghost",size:"sm",onClick:()=>e("select"),title:`${F("toolbar.select")} (V)`,children:n.jsx(y.NiceIcon,{name:"cursor",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:i==="pan"?"primary":"ghost",size:"sm",onClick:()=>e("pan"),title:`${F("toolbar.pan")} (H)`,children:n.jsx(y.NiceIcon,{name:"move",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:i==="addEdge"?"primary":"ghost",size:"sm",onClick:()=>e("addEdge"),title:`${F("toolbar.addEdge")} (C)`,children:n.jsx(y.NiceIcon,{name:"link",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:i==="text"?"primary":"ghost",size:"sm",onClick:()=>e("text"),title:F("toolbar.textT","Text (T)"),children:n.jsx(y.NiceIcon,{name:"type",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:i==="freehand"?"primary":"ghost",size:"sm",onClick:()=>e("freehand"),title:F("toolbar.freehandF","Freehand (F)"),children:n.jsx(y.NiceIcon,{name:"pen",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:i==="delete"?"primary":"ghost",size:"sm",onClick:()=>e("delete"),title:`${F("toolbar.delete")} (Del)`,children:n.jsx(y.NiceIcon,{name:"trash",size:14})})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:i==="addNode"?"primary":"ghost",size:"sm",onClick:()=>Re(H=>!H),title:F("toolbar.addNode"),children:[n.jsx(y.NiceIcon,{name:"plus",size:14})," ",F("toolbar.addNode")]}),ot&&n.jsx("div",{className:"nice-diagram-toolbar__dropdown nice-diagram-toolbar__dropdown--shapes",children:Ge.map(H=>n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>st(H),children:[n.jsx(y.NiceIcon,{name:Pi(H),size:14})," ",H]},H))})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:E,title:F("toolbar.copyCtrlC","Copy (Ctrl+C)"),children:n.jsx(y.NiceIcon,{name:"copy",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:q,title:F("toolbar.pasteCtrlV","Paste (Ctrl+V)"),children:n.jsx(y.NiceIcon,{name:"clipboard",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:X,title:F("toolbar.duplicateCtrlD","Duplicate (Ctrl+D)"),children:n.jsx(y.NiceIcon,{name:"layers",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:J,title:F("toolbar.selectAllCtrlA","Select All (Ctrl+A)"),children:n.jsx(y.NiceIcon,{name:"check-square",size:14})})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:a,disabled:!s,title:`${F("toolbar.undo")} (Ctrl+Z)`,children:n.jsx(y.NiceIcon,{name:"undo",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:l,disabled:!c,title:`${F("toolbar.redo")} (Ctrl+Y)`,children:n.jsx(y.NiceIcon,{name:"redo",size:14})})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:m,title:F("toolbar.zoomOut"),children:n.jsx(y.NiceIcon,{name:"minus",size:14})}),n.jsxs("span",{className:"nice-diagram-toolbar__zoom-label",children:[Math.round(u*100),"%"]}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:d,title:F("toolbar.zoomIn"),children:n.jsx(y.NiceIcon,{name:"plus",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:w,title:F("toolbar.zoomReset"),children:"1:1"})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:re,title:F("toolbar.findCtrlF","Find (Ctrl+F)"),children:n.jsx(y.NiceIcon,{name:"search",size:14})}),be&&n.jsx(y.NiceTextInput,{className:"nice-diagram-toolbar__search",placeholder:F("toolbar.searchNodes","Search nodes…"),value:W,onChange:H=>Q==null?void 0:Q(H),autoFocus:!0})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>ve(H=>!H),title:F("toolbar.export"),children:[n.jsx(y.NiceIcon,{name:"download",size:14})," ",F("toolbar.export")]}),Se&&n.jsxs("div",{className:"nice-diagram-toolbar__dropdown",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{f==null||f("ndd"),ve(!1)},children:".ndd.json"}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{f==null||f("svg"),ve(!1)},children:"SVG"}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{f==null||f("mermaid"),ve(!1)},children:F("toolbar.mermaid","Mermaid")}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{f==null||f("png"),ve(!1)},children:"PNG"})]})]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__row nice-diagram-toolbar__format-bar",children:[n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceSelect,{className:"nice-diagram-toolbar__font-select",value:M,onChange:H=>S==null?void 0:S(H),options:$i.map(H=>({value:H,label:H})),title:F("toolbar.fontFamily","Font Family")}),n.jsx(y.NiceSelect,{className:"nice-diagram-toolbar__size-select",value:String(_),onChange:H=>$==null?void 0:$(Number(H)),options:Ti.map(H=>({value:String(H),label:String(H)})),title:F("toolbar.fontSize","Font Size")})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:v?"primary":"ghost",size:"sm",onClick:p,title:F("toolbar.boldCtrlB","Bold (Ctrl+B)"),children:n.jsx("strong",{children:"B"})}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:g?"primary":"ghost",size:"sm",onClick:b,title:F("toolbar.italicCtrlI","Italic (Ctrl+I)"),children:n.jsx("em",{children:"I"})})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>ge(H=>!H),title:F("toolbar.alignmentDistribution","Alignment & Distribution"),children:"≡ Align"}),Be&&n.jsxs("div",{className:"nice-diagram-toolbar__dropdown nice-diagram-toolbar__dropdown--align",children:[n.jsx("div",{className:"nice-diagram-toolbar__dropdown-section",children:F("toolbar.align","Align")}),n.jsxs("div",{className:"nice-diagram-toolbar__dropdown-row",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{k==null||k(),ge(!1)},title:F("toolbar.alignLeft","Align Left"),children:[n.jsx(y.NiceIcon,{name:"align-left",size:14})," ",F("toolbar.left","Left")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{T==null||T(),ge(!1)},title:F("toolbar.alignCenter","Align Center"),children:[n.jsx(y.NiceIcon,{name:"align-center",size:14})," ",F("toolbar.center","Center")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{j==null||j(),ge(!1)},title:F("toolbar.alignRight","Align Right"),children:[n.jsx(y.NiceIcon,{name:"align-right",size:14})," ",F("toolbar.right","Right")]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__dropdown-row",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{O==null||O(),ge(!1)},title:F("toolbar.alignTop","Align Top"),children:[n.jsx(y.NiceIcon,{name:"align-top",size:14})," Top"]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{B==null||B(),ge(!1)},title:F("toolbar.alignMiddle","Align Middle"),children:[n.jsx(y.NiceIcon,{name:"align-middle",size:14})," ",F("toolbar.middle","Middle")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{U==null||U(),ge(!1)},title:F("toolbar.alignBottom","Align Bottom"),children:[n.jsx(y.NiceIcon,{name:"align-bottom",size:14})," ",F("toolbar.bottom","Bottom")]})]}),n.jsx("div",{className:"nice-diagram-toolbar__dropdown-section",children:F("toolbar.distribute","Distribute")}),n.jsxs("div",{className:"nice-diagram-toolbar__dropdown-row",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{L==null||L(),ge(!1)},title:F("toolbar.distributeHorizontally","Distribute Horizontally"),children:[n.jsx(y.NiceIcon,{name:"distribute-h",size:14})," H"]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{G==null||G(),ge(!1)},title:F("toolbar.distributeVertically","Distribute Vertically"),children:[n.jsx(y.NiceIcon,{name:"distribute-v",size:14})," V"]})]})]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>je(H=>!H),title:F("toolbar.arrange","Arrange"),children:[n.jsx(y.NiceIcon,{name:"menu",size:14})," ",F("toolbar.arrange","Arrange")]}),qe&&n.jsxs("div",{className:"nice-diagram-toolbar__dropdown",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{N==null||N(),je(!1)},children:[n.jsx(y.NiceIcon,{name:"arrow-up",size:14})," ",F("toolbar.bringToFront","Bring to Front")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{Y==null||Y(),je(!1)},children:[n.jsx(y.NiceIcon,{name:"arrow-down",size:14})," ",F("toolbar.sendToBack","Send to Back")]}),n.jsx("div",{className:"nice-diagram-toolbar__dropdown-divider"}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{P==null||P(),je(!1)},disabled:fe<2,children:"⊞ Group"}),n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>{V==null||V(),je(!1)},children:"⊟ Ungroup"})]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>We(H=>!H),title:F("toolbar.layout"),children:["⊞ ",F("toolbar.layout")]}),at&&n.jsx("div",{className:"nice-diagram-toolbar__dropdown",children:Di.map(H=>n.jsx(y.NiceButton,{className:"nice-diagram-toolbar__dropdown-item",variant:"ghost",size:"sm",onClick:()=>lt(H),children:F(`layout.${H}`)},H))})]}),fe>1&&n.jsxs("span",{className:"nice-diagram-toolbar__selection-info",children:[fe," selected"]}),n.jsxs("div",{className:"nice-diagram-toolbar__group",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:ee==="editor"?"primary":"ghost",size:"sm",onClick:()=>le==null?void 0:le("editor"),title:F("toolbar.editorMode","Editor Mode"),children:[n.jsx(y.NiceIcon,{name:"edit",size:14})," ",F("toolbar.editor","Editor")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:ee==="player"?"primary":"ghost",size:"sm",onClick:()=>le==null?void 0:le("player"),title:F("toolbar.playerMode","Player Mode"),children:[n.jsx(y.NiceIcon,{name:"play",size:14})," ",F("toolbar.player","Player")]}),n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:ee==="playerAnimated"?"primary":"ghost",size:"sm",onClick:()=>le==null?void 0:le("playerAnimated"),title:F("toolbar.animatedPlayerMode","Animated Player Mode"),children:[n.jsx(y.NiceIcon,{name:"zap",size:14})," ",F("toolbar.animated","Animated")]})]}),n.jsxs("div",{className:"nice-diagram-toolbar__group nice-diagram-toolbar__group--relative",children:[n.jsxs(y.NiceButton,{className:"nice-diagram-toolbar__btn",variant:"ghost",size:"sm",onClick:()=>Ve(H=>!H),title:F("toolbar.stylePresets","Style Presets"),children:[n.jsx(y.NiceIcon,{name:"palette",size:14})," ",F("toolbar.style","Style")]}),nt&&n.jsx("div",{className:"nice-diagram-toolbar__dropdown nice-diagram-toolbar__dropdown--presets",style:{maxHeight:320,overflowY:"auto",width:220},children:Object.entries(Je.reduce((H,De)=>{const we=De.category??"Other";return H[we]||(H[we]=[]),H[we].push(De),H},{})).map(([H,De])=>n.jsxs("div",{children:[n.jsx("div",{className:"nice-diagram-toolbar__dropdown-section",style:{fontSize:10,color:"var(--nice-text-secondary, #888)",padding:"6px 8px 2px",textTransform:"uppercase"},children:H}),De.map(we=>n.jsxs(y.NiceButton,{className:`nice-diagram-toolbar__dropdown-item ${me===we.id?"nice-diagram-toolbar__dropdown-item--active":""}`,variant:me===we.id?"primary":"ghost",size:"sm",onClick:()=>{Ce==null||Ce(we.id),Ve(!1)},style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("span",{style:{width:16,height:16,borderRadius:3,background:we.config.palette.primary,border:"1px solid "+(we.config.palette.border??"var(--nice-border, #ccc)"),display:"inline-block",flexShrink:0}}),n.jsx("span",{style:{fontSize:12},children:we.name})]},we.id))]},H))})]})]})]})};process.env.NODE_ENV!=="production"&&(rt.displayName="DiagramToolbar");function Pi(i){switch(i){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 Ei=[{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"}],Wt=({initialDocument:i,diagramType:e="flowchart",onChange:t,onExport:r,lang:o="en",showToolbar:a=!0,showPropertyPanel:l=!0,showMinimap:s=!0,showTimeline:c=!0,className:f,style:d,tutorial:m})=>{var be;const{t:w}=y.useNiceTranslation(),u=Ft(i),[p,b]=x.useState("select"),[v,g]=x.useState(null),S=x.useRef(null),[M,$]=x.useState("editor"),_=x.useRef(null),[k,T]=x.useState({particles:[],liquidFlows:new Map,glowStates:new Map});x.useEffect(()=>{const W=new jt(Q=>{T(Q)});return _.current=W,W.start(),()=>{W.stop(),_.current=null}},[]),x.useEffect(()=>{var Q;const W=_.current;if(W)for(const ee of u.edges)(Q=ee.style.liquidFlow)!=null&&Q.active?W.startLiquidFlow(ee.id,ee.style.liquidFlow):W.stopLiquidFlow(ee.id)},[u.edges]),x.useEffect(()=>{const W=_.current;if(W)for(const Q of u.nodes)Q.style.glowColor?W.setGlow(Q.id,Q.style.glowColor,Q.style.glowIntensity??1):W.removeGlow(Q.id)},[u.nodes]);const j=x.useCallback(W=>{u.setStylePreset(W)},[u]),O=x.useCallback((W,Q)=>{const ee=u.nodes.find(me=>me.id===W);if(!(ee!=null&&ee.interactions))return;const le=ee.interactions.find(me=>me.id===Q);if(le)switch(le.action){case"reveal":{if(le.targetId){const me=u.nodes.find(Ce=>Ce.id===le.targetId);me!=null&&me.hidden&&u.updateNode(le.targetId,{hidden:!1})}break}case"navigate":{if(le.targetId){const me=u.nodes.find(Ce=>Ce.id===le.targetId);me&&(u.setViewport({x:-me.position.x+300,y:-me.position.y+200,zoom:u.viewport.zoom}),g(le.targetId))}break}case"switchAnimationMode":{le.targetId&&u.setActiveAnimationMode(le.targetId);break}case"highlight":{le.targetId&&g(le.targetId);break}case"toggleCollapse":{u.toggleNodeCollapse(W);break}}},[u]),B=x.useRef(u.document);u.document!==B.current&&(B.current=u.document,t==null||t(u.document));const U=x.useMemo(()=>v?u.nodes.find(W=>W.id===v)??null:null,[v,u.nodes]),L=x.useMemo(()=>v?u.edges.find(W=>W.id===v)??null:null,[v,u.edges]),G=x.useCallback(W=>{const Q=u.viewport,ee=(-Q.x+400)/Q.zoom,le=(-Q.y+300)/Q.zoom,me=u.addNode("New Node",{x:ee,y:le},W);g(me.id),b("select")},[u]),N=x.useCallback(W=>{u.applyLayout({algorithm:W,centerGraph:!0})},[u]),Y=x.useCallback((W,Q)=>{u.moveNode(W,Q)},[u]),P=x.useCallback((W,Q)=>{u.moveNode(W,Q)},[u]),V=x.useCallback(W=>{u.nodes.find(Q=>Q.id===W)?u.removeNode(W):u.edges.find(Q=>Q.id===W)&&u.removeEdge(W),g(null)},[u]),E=x.useCallback(W=>{const Q=u.document;let ee;switch(W){case"ndd":ee=Et(Q,!0);break;case"svg":ee=pt(Q);break;case"mermaid":ee=Tt(Q);break;case"png":ee=pt(Q);break}r==null||r(W,ee)},[u,r]),q=x.useCallback(()=>{u.setViewport({...u.viewport,zoom:Math.min(5,u.viewport.zoom*1.2)})},[u]),X=x.useCallback(()=>{u.setViewport({...u.viewport,zoom:Math.max(.1,u.viewport.zoom/1.2)})},[u]),J=x.useCallback(()=>{u.setViewport({x:0,y:0,zoom:1})},[u]),fe=x.useMemo(()=>[...u.nodes.map(W=>({id:W.id,label:W.label,type:"node"})),...u.edges.map(W=>({id:W.id,label:W.label??W.id,type:"edge"}))],[u.nodes,u.edges]),re=a||u.animationModes.length>0?n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,width:"100%"},children:[a&&n.jsx(rt,{activeTool:p,onToolChange:b,diagramType:u.document.diagramType,onAddNode:G,onApplyLayout:N,onUndo:u.undo,onRedo:u.redo,canUndo:u.canUndo,canRedo:u.canRedo,onExport:E,onZoomIn:q,onZoomOut:X,onZoomReset:J,viewMode:M,onViewModeChange:$,stylePresetId:u.stylePresetId,onStylePresetChange:j}),u.animationModes.length>0&&n.jsxs("div",{className:"nice-diagram-editor__mode-tabs",style:{display:"flex",gap:4,padding:"4px 8px",fontSize:12,alignItems:"center"},children:[n.jsx("span",{style:{color:"var(--nice-text-secondary, #888)",marginRight:4},children:"Modes:"}),u.animationModes.map(W=>{var Q;return n.jsx(y.NiceButton,{variant:((Q=u.activeAnimationMode)==null?void 0:Q.id)===W.id?"primary":"ghost",size:"sm",onClick:()=>u.setActiveAnimationMode(W.id),style:{padding:"2px 10px",fontSize:11},children:W.name},W.id)}),n.jsx(y.NiceButton,{variant:"ghost",size:"sm",onClick:()=>u.addAnimationMode(`Mode ${u.animationModes.length+1}`),style:{padding:"2px 8px",fontSize:11,color:"var(--nice-text-secondary, #888)"},title:w("diagramEditor.addAnimationMode","Add animation mode"),children:"+"})]})]}):void 0;return n.jsx(mt,{locale:o,children:n.jsxs(y.NiceAppShell,{ref:S,flush:!0,className:`nice-diagram-editor ${f??""}`,style:{position:"relative",...d},toolbar:re,rightSidebar:l?n.jsx("div",{className:"nice-diagram-editor__panel",style:{width:260,overflowY:"auto",height:"100%"},children:n.jsx(tt,{selectedNode:U,selectedEdge:L,onNodeChange:u.updateNode,onEdgeChange:u.updateEdge,onRemove:V})}):void 0,bottomPanel:c?n.jsx("div",{className:"nice-diagram-editor__timeline",children:n.jsx(Qe,{animations:u.animations,onAdd:u.addAnimation,onRemove:u.removeAnimation,availableTargets:fe})}):void 0,children:[n.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:n.jsx(y.NiceTutorialButton,{steps:y.resolveTutorial(m,Ei)})}),n.jsxs("div",{className:"nice-diagram-editor__canvas",style:{height:"100%",position:"relative"},children:[n.jsx(ke,{nodes:u.nodes,edges:u.edges,groups:u.groups,viewport:u.viewport,onViewportChange:u.setViewport,selectedId:v,onSelectElement:g,onNodeDrag:Y,onNodeDragEnd:P,interactive:M==="editor",showGrid:M==="editor",particleState:k,viewMode:M,ghostOpacity:((be=u.playerConfig)==null?void 0:be.ghostOpacity)??.3,onGroupCollapse:u.toggleGroupCollapse,onNodeCollapse:u.toggleNodeCollapse,onInteraction:O}),s&&n.jsx("div",{style:{position:"absolute",bottom:8,left:8},children:n.jsx(et,{nodes:u.nodes,edges:u.edges,viewport:u.viewport,onViewportChange:u.setViewport})})]})]})})};process.env.NODE_ENV!=="production"&&(Wt.displayName="NiceDiagramEditor");const Mt={linear:i=>i,easeIn:i=>i*i,easeOut:i=>i*(2-i),easeInOut:i=>i<.5?2*i*i:-1+(4-2*i)*i,spring:i=>1-Math.cos(i*Math.PI*.5)*Math.exp(-6*i),bounce:i=>{if(i<1/2.75)return 7.5625*i*i;if(i<2/2.75){const t=i-.5454545454545454;return 7.5625*t*t+.75}if(i<2.5/2.75){const t=i-.8181818181818182;return 7.5625*t*t+.9375}const e=i-2.625/2.75;return 7.5625*e*e+.984375}};function Bt(i){return Mt[i]??Mt.linear}const qt={opacity:1,scale:1,translateX:0,translateY:0,glow:0,highlightColor:"",strokeProgress:1,rippleRadius:0,rippleOpacity:0,typewriterChars:-1,liquidFillProgress:-1,particleTrailT:-1};class Vt{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 o=!1;for(const a of this.animations){const l=a.startMs+(a.delayMs??0);l+a.durationMs;const s=a.repeat??0;let c=r-l;if(c<0){this.stateMap.set(a.targetId,Oi(a)),o=!0;continue}if(s===-1)c=c%a.durationMs,o=!0;else if(s>0){const w=a.durationMs*(s+1);if(c>w)continue;c=c%a.durationMs,o=!0}else{if(c>a.durationMs)continue;o=!0}const f=Math.min(c/a.durationMs,1),d=Bt(a.easing)(f),m=Ri(a,d);this.stateMap.set(a.targetId,m)}this.onFrame(this.stateMap),o?this.rafId=requestAnimationFrame(this.tick):this.playing=!1},this.animations=[...e].sort((r,o)=>r.startMs-o.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 Ri(i,e){const t={...qt};switch(i.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 Oi(i){const e={...qt};switch(i.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 Fi(i){return{rectangle:"rectangle",roundedRect:"roundedRect",ellipse:"ellipse",circle:"circle",diamond:"diamond",hexagon:"hexagon",cylinder:"cylinder",cloud:"cloud",triangle:"triangle"}[i||"rectangle"]||"rectangle"}function Li(i){return i?{backgroundColor:i.fill,borderColor:i.stroke,borderWidth:i.strokeWidth,fontColor:i.fontColor,fontSize:i.fontSize,borderRadius:i.borderRadius,borderStyle:i.strokeDasharray?"dashed":"solid"}:{}}function Wi(i){if(!i)return{};let e="straight";return i.lineType==="orthogonal"?e="orthogonal":i.lineType==="curved"||i.lineType==="bezier"?e="bezier":i.lineType==="step"&&(e="step"),{strokeColor:i.stroke,strokeWidth:i.strokeWidth,strokeDash:i.strokeDasharray?i.strokeDasharray.split(",").map(Number):void 0,lineType:e,sourceArrow:"none",targetArrow:i.arrowHead?"arrow":"none",opacity:i.opacity}}function Bi(i){if(i)return{backgroundColor:i.fill,borderColor:i.stroke,borderWidth:i.strokeWidth}}function Gt(i){return{id:i.id,label:i.label,position:{x:i.x,y:i.y},size:{width:i.width,height:i.height},shape:Fi(i.shape),style:Li(i.style),ports:(i.ports||[]).map((e,t)=>({id:e.id,side:e.position||"right",offset:.5})),data:i.data}}function Yt(i,e){var l,s;const t=e.find(c=>c.id===i.source),r=e.find(c=>c.id===i.target),o=i.sourcePort||((l=t==null?void 0:t.ports[0])==null?void 0:l.id)||`${i.source}-out`,a=i.targetPort||((s=r==null?void 0:r.ports[0])==null?void 0:s.id)||`${i.target}-in`;return{id:i.id,sourceNodeId:i.source,sourcePortId:o,targetNodeId:i.target,targetPortId:a,label:i.label,style:Wi(i.style),data:i.data}}function Ut(i){return{id:i.id,label:i.label,nodeIds:i.nodeIds,style:Bi(i.style)}}function Ht(i){var e;return{id:i.id,name:i.id,targetId:i.targetId||((e=i.targets)==null?void 0:e[0])||"",targetType:"node",effect:i.type==="highlight"?"highlight":"fadeIn",startMs:i.delay,durationMs:i.duration,easing:"easeInOut"}}function Ae(i){const e=i.nodes.map(Gt);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:i.id,title:i.title,diagramType:i.diagramType,nodes:e,edges:i.edges.map(t=>Yt(t,e)),groups:(i.groups||[]).map(Ut),animations:(i.animations||[]).map(Ht),viewport:{x:0,y:0,zoom:1},metadata:{createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),...i.metadata}}}const qi=Ae({id:"empty",title:"",diagramType:"flowchart",nodes:[],edges:[]}),bt=({document:i=qi,lang:e="en",autoPlay:t=!1,showControls:r,showGrid:o,showWorkspace:a=!1,className:l,style:s})=>{const c=r??a,f=o??a,[d,m]=x.useState({...i.viewport}),[w,u]=x.useState(new Map),[p,b]=x.useState(!1),v=x.useRef(null),g=x.useCallback(()=>{v.current&&v.current.stop();const k=new Vt(i.animations,T=>{u(new Map(T)),k.isPlaying()||b(!1)});v.current=k,k.play(),b(!0)},[i.animations]),S=x.useCallback(()=>{var k;(k=v.current)==null||k.stop(),b(!1),u(new Map)},[]);x.useEffect(()=>(t&&i.animations.length>0&&g(),()=>{var k;(k=v.current)==null||k.stop()}),[t]);const M=x.useCallback(()=>m(k=>({...k,zoom:Math.min(5,k.zoom*1.2)})),[]),$=x.useCallback(()=>m(k=>({...k,zoom:Math.max(.1,k.zoom/1.2)})),[]),_=x.useCallback(()=>m({x:0,y:0,zoom:1}),[]);return n.jsx(mt,{locale:e,children:n.jsxs("div",{className:`nice-diagram-viewer ${l??""}`,style:{display:"flex",flexDirection:"column",height:"100%",...s},children:[c&&n.jsx(Vi,{isPlaying:p,hasAnimations:i.animations.length>0,onPlay:g,onStop:S,onZoomIn:M,onZoomOut:$,onZoomReset:_}),n.jsx("div",{style:{flex:1,position:"relative"},children:n.jsx(ke,{nodes:i.nodes,edges:i.edges,groups:i.groups,viewport:d,onViewportChange:m,theme:i.theme,animationStates:w,interactive:!1,showGrid:f})})]})})};process.env.NODE_ENV!=="production"&&(bt.displayName="NiceDiagramViewer");const Vi=({isPlaying:i,hasAnimations:e,onPlay:t,onStop:r,onZoomIn:o,onZoomOut:a,onZoomReset:l})=>{const{t:s}=Le();return n.jsxs("div",{className:"nice-diagram-viewer__controls",style:{display:"flex",gap:4,padding:"4px 8px",borderBottom:"1px solid var(--nice-border, #ddd)",background:"var(--nice-bg-secondary, #fafafa)"},children:[e&&(i?n.jsxs(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:r,children:[n.jsx(y.NiceIcon,{name:"stop",size:14})," ",s("animation.stop")]}):n.jsxs(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:t,children:[n.jsx(y.NiceIcon,{name:"play",size:14})," ",s("animation.play")]})),n.jsx("span",{style:{flex:1}}),n.jsx(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:o,"aria-label":s("animation.zoomIn","Zoom in"),children:n.jsx(y.NiceIcon,{name:"plus",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:a,"aria-label":s("animation.zoomOut","Zoom out"),children:n.jsx(y.NiceIcon,{name:"minus",size:14})}),n.jsx(y.NiceButton,{className:"nice-diagram-viewer__btn",variant:"ghost",size:"sm",onClick:l,children:"1:1"})]})},Gi="_cell_95fwm_9",Yi="_expandable_95fwm_29",Ui="_svg_95fwm_57",Hi="_emptyText_95fwm_67",Xi="_badge_95fwm_79",Ki="_expandIcon_95fwm_117",Zi="_modalOverlay_95fwm_169",Ji="_modalContent_95fwm_217",Qi="_modalHeader_95fwm_267",eo="_modalTitle_95fwm_285",to="_modalClose_95fwm_299",ro="_modalBody_95fwm_337",io="_modalSvg_95fwm_357",oo="_modalFooter_95fwm_371",ao="_modalInfo_95fwm_389",xe={cell:Gi,expandable:Yi,svg:Ui,emptyText:Hi,badge:Xi,expandIcon:Ki,modalOverlay:Zi,modalContent:Ji,modalHeader:Qi,modalTitle:eo,modalClose:to,modalBody:ro,modalSvg:io,modalFooter:oo,modalInfo:ao},no=120,so=48,lo=4,St={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 xt(i){if(i.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,o=-1/0;for(const a of i){const l=a.position.x,s=a.position.y,c=a.position.x+a.size.width,f=a.position.y+a.size.height;l<e&&(e=l),s<t&&(t=s),c>r&&(r=c),f>o&&(o=f)}return{minX:e,minY:t,maxX:r,maxY:o,width:r-e,height:o-t}}function Xt(i){var t;if((t=i.style)!=null&&t.backgroundColor)return i.style.backgroundColor;const e=i.shape??"default";return St[e]??St.default}function Kt(i,e){const t=e.get(i.sourceNodeId),r=e.get(i.targetNodeId);if(!t||!r)return null;const o=t.position.x+t.size.width/2,a=t.position.y+t.size.height/2,l=r.position.x+r.size.width/2,s=r.position.y+r.size.height/2;return`M ${o} ${a} L ${l} ${s}`}function co(i,e){const t=xt(i);return{version:"1.0",id:`mini-diagram-${Date.now()}`,title:"Mini Diagram",diagramType:"flowchart",nodes:i,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 uo=({document:i,onClose:e})=>{const t=xt(i.nodes),r=40,o=t.width+r*2,a=t.height+r*2,l=x.useMemo(()=>new Map(i.nodes.map(s=>[s.id,s])),[i.nodes]);return n.jsx("div",{className:xe.modalOverlay,onClick:e,children:n.jsxs("div",{className:xe.modalContent,onClick:s=>s.stopPropagation(),children:[n.jsxs("div",{className:xe.modalHeader,children:[n.jsx("h3",{className:xe.modalTitle,children:i.title||"Diagram"}),n.jsx("button",{className:xe.modalClose,onClick:e,children:n.jsx(y.NiceIcon,{name:"close",size:20})})]}),n.jsx("div",{className:xe.modalBody,children:n.jsxs("svg",{viewBox:`${t.minX-r} ${t.minY-r} ${o} ${a}`,className:xe.modalSvg,children:[i.edges.map(s=>{var f,d,m;const c=Kt(s,l);return c?n.jsx("path",{d:c,stroke:((f=s.style)==null?void 0:f.strokeColor)??"var(--nice-text-secondary, #64748b)",strokeWidth:((d=s.style)==null?void 0:d.strokeWidth)??1.5,fill:"none",markerEnd:(m=s.style)!=null&&m.targetArrow&&s.style.targetArrow!=="none"?"url(#arrowhead-modal)":void 0},s.id):null}),i.nodes.map(s=>{var c,f;return n.jsxs("g",{children:[n.jsx("rect",{x:s.position.x,y:s.position.y,width:s.size.width,height:s.size.height,rx:((c=s.style)==null?void 0:c.borderRadius)??4,fill:Xt(s),stroke:((f=s.style)==null?void 0:f.borderColor)??"var(--nice-text, #1e293b)",strokeWidth:1}),n.jsx("text",{x:s.position.x+s.size.width/2,y:s.position.y+s.size.height/2,textAnchor:"middle",dominantBaseline:"middle",fill:"var(--nice-color-white, #fff)",fontSize:12,fontFamily:"system-ui, sans-serif",children:s.label.substring(0,30)})]},s.id)}),n.jsx("defs",{children:n.jsx("marker",{id:"arrowhead-modal",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:n.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"var(--nice-text-secondary, #64748b)"})})})]})}),n.jsx("div",{className:xe.modalFooter,children:n.jsxs("span",{className:xe.modalInfo,children:[i.nodes.length," nodes • ",i.edges.length," edges"]})})]})})},fo=({document:i,nodes:e,edges:t,width:r=no,height:o=so,showCount:a=!0,expandable:l=!0,onExpand:s,padding:c=lo,backgroundColor:f="transparent",borderRadius:d=4,showLabels:m=!1,edgeColor:w="var(--nice-text-muted, #94a3b8)",tooltip:u})=>{const[p,b]=x.useState(!1),v=x.useMemo(()=>i||(e||t?co(e??[],t??[]):null),[i,e,t]),g=x.useMemo(()=>v?new Map(v.nodes.map(T=>[T.id,T])):new Map,[v]),{bounds:S,scale:M,translateX:$,translateY:_}=x.useMemo(()=>{if(!v||v.nodes.length===0)return{bounds:{minX:0,minY:0,width:100,height:100},scale:1,translateX:0,translateY:0};const T=xt(v.nodes),j=r-c*2,O=o-c*2,B=j/T.width,U=O/T.height,L=Math.min(B,U,1),G=T.width*L,N=T.height*L,Y=(r-G)/2-T.minX*L,P=(o-N)/2-T.minY*L;return{bounds:T,scale:L,translateX:Y,translateY:P}},[v,r,o,c]),k=x.useCallback(()=>{!v||!l||(s?s(v):b(!0))},[v,l,s]);return!v||v.nodes.length===0?n.jsx("div",{className:xe.cell,style:{width:r,height:o,backgroundColor:f,borderRadius:d},title:u,children:n.jsx("span",{className:xe.emptyText,children:"—"})}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:`${xe.cell} ${l?xe.expandable:""}`,style:{width:r,height:o,backgroundColor:f,borderRadius:d},onClick:k,title:u??`${v.nodes.length} nodes, ${v.edges.length} edges`,children:[n.jsx("svg",{width:r,height:o,viewBox:`0 0 ${r} ${o}`,className:xe.svg,children:n.jsxs("g",{transform:`translate(${$}, ${_}) scale(${M})`,children:[v.edges.map(T=>{const j=Kt(T,g);return j?n.jsx("path",{d:j,stroke:w,strokeWidth:1/M,fill:"none"},T.id):null}),v.nodes.map(T=>{const j=Xt(T);return n.jsxs("g",{children:[n.jsx("rect",{x:T.position.x,y:T.position.y,width:T.size.width,height:T.size.height,rx:Math.min(4,T.size.width/4),fill:j}),m&&M>.3&&n.jsx("text",{x:T.position.x+T.size.width/2,y:T.position.y+T.size.height/2,textAnchor:"middle",dominantBaseline:"middle",fill:"var(--nice-color-white, #fff)",fontSize:10/M,fontFamily:"system-ui, sans-serif",children:T.label.substring(0,5)})]},T.id)})]})}),a&&n.jsx("span",{className:xe.badge,children:v.nodes.length}),l&&n.jsx("span",{className:xe.expandIcon,children:n.jsx(y.NiceIcon,{name:"expand",size:12})})]}),p&&v&&n.jsx(uo,{document:v,onClose:()=>b(!1)})]})};function Zt(i,e,t="roundedRect"){const r=[],o=[],a=new Map;for(const l of i){const s=String(l[e.nodeMapping.idField]??"");if(!s)continue;const c=String(l[e.nodeMapping.labelField]??s),f=e.nodeMapping.descriptionField?String(l[e.nodeMapping.descriptionField]??""):void 0,d=e.nodeMapping.iconField?String(l[e.nodeMapping.iconField]??""):void 0,m=e.nodeMapping.colorField?String(l[e.nodeMapping.colorField]??""):void 0,w={id:`data_${s}`,label:c,description:f,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:l};r.push(w),a.set(s,w)}if(e.nodeMapping.parentField)for(const l of i){const s=String(l[e.nodeMapping.idField]??""),c=String(l[e.nodeMapping.parentField]??"");if(!s||!c)continue;const f=a.get(s),d=a.get(c);!f||!d||o.push({id:`edge_${c}_${s}`,sourceNodeId:d.id,sourcePortId:"bottom",targetNodeId:f.id,targetPortId:"top",style:{lineType:"orthogonal",targetArrow:"arrow"}})}if(e.edgeMapping)for(const l of i){const s=String(l[e.edgeMapping.sourceField]??""),c=String(l[e.edgeMapping.targetField]??"");if(!s||!c)continue;const f=a.get(s),d=a.get(c);if(!f||!d)continue;const m=e.edgeMapping.labelField?String(l[e.edgeMapping.labelField]??""):void 0;o.push({id:`edge_${s}_${c}`,sourceNodeId:f.id,sourcePortId:"right",targetNodeId:d.id,targetPortId:"left",label:m,style:{lineType:"bezier",targetArrow:"arrow"}})}return{nodes:r,edges:o}}async function ho(i,e,t){const r=await fetch(i.sourceUrl,{signal:t});if(!r.ok)throw new Error(`Failed to fetch data: ${r.status} ${r.statusText}`);const o=await r.json(),a=Array.isArray(o)?o:o.value??[];return Zt(a,i,e)}const po={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)"},mo={start:"ellipse",end:"ellipse",task:"rectangle",decision:"diamond",parallel:"rectangle",join:"rectangle",subprocess:"rectangle",timer:"ellipse",message:"rectangle",error:"rectangle"},go={start:"play",end:"stop",task:"clipboard",decision:"help",parallel:"columns",join:"git-branch",subprocess:"box",timer:"clock",message:"mail",error:"warning"},yo=({data:i,onStepClick:e,onTransitionClick:t,autoPlay:r=!1,animationDelay:o=1e3,showTooltips:a=!0,showMinimap:l=!0,statusColors:s=po,typeShapes:c=mo,direction:f="horizontal",className:d,style:m})=>{const[w,u]=x.useState(0),p=x.useMemo(()=>{const S=i.steps.map((_,k)=>{const T=_.id===i.currentStepId,j=_.status||"pending",O=s[j],B=c[_.type],U=f==="horizontal"?k*200:100,L=f==="horizontal"?100:k*150;return{id:_.id,label:_.name,x:U,y:L,width:150,height:60,shape:B,style:{fill:O,stroke:T?"var(--nice-text, #1f2937)":O,strokeWidth:T?3:1,fontColor:"var(--nice-color-white, #fff)",fontSize:12},data:{type:_.type,status:_.status,assignee:_.assignee,dueDate:_.dueDate,icon:go[_.type],..._.metadata},ports:[{id:`${_.id}-in`,position:"left"},{id:`${_.id}-out`,position:"right"}]}}),M=i.transitions.map(_=>{const k=i.steps.find(O=>O.id===_.from),T=i.steps.find(O=>O.id===_.to);let j="var(--nice-text-muted, #9ca3af)";return(k==null?void 0:k.status)==="completed"&&(T==null?void 0:T.status)!=="pending"?j="var(--nice-success, #10b981)":(k==null?void 0:k.status)==="failed"&&(j="var(--nice-danger, #ef4444)"),{id:_.id,source:_.from,target:_.to,sourcePort:`${_.from}-out`,targetPort:`${_.to}-in`,label:_.label||_.condition,style:{stroke:j,strokeWidth:2,arrowHead:"arrow",lineType:"bezier"},data:{condition:_.condition}}}),$=r?bo(i.steps):[];return Ae({id:i.id,title:i.name,diagramType:"flowchart",nodes:S,edges:M,animations:$,metadata:{type:"workflow",...i.metadata}})},[i,s,c,f,r]);x.useEffect(()=>{if(!r)return;const S=i.steps.filter($=>$.status==="completed").length;if(w>=S)return;const M=setTimeout(()=>{u($=>$+1)},o);return()=>clearTimeout(M)},[r,w,o,i.steps]);const[b,v]=x.useState({x:0,y:0,zoom:1}),g=x.useCallback(S=>{if(S&&e){const M=i.steps.find($=>$.id===S);M&&e(M)}if(S&&t){const M=i.transitions.find($=>$.id===S);M&&t(M)}},[i.steps,i.transitions,e,t]);return n.jsx("div",{className:`nice-workflow-visualizer ${d||""}`,style:{position:"relative",width:"100%",height:"100%",...m},children:n.jsx(ke,{nodes:p.nodes,edges:p.edges,groups:p.groups,viewport:b,onViewportChange:v,onSelectElement:g,showGrid:!0})})};function bo(i){return i.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 xo(i){var a,l;const t=new DOMParser().parseFromString(i,"text/xml"),r=[],o=[];return t.querySelectorAll("startEvent").forEach(s=>{r.push({id:s.getAttribute("id")||`start-${r.length}`,name:s.getAttribute("name")||"Start",type:"start"})}),t.querySelectorAll("task, userTask, serviceTask").forEach(s=>{r.push({id:s.getAttribute("id")||`task-${r.length}`,name:s.getAttribute("name")||"Task",type:"task"})}),t.querySelectorAll("exclusiveGateway, parallelGateway").forEach(s=>{const c=s.tagName==="parallelGateway";r.push({id:s.getAttribute("id")||`gateway-${r.length}`,name:s.getAttribute("name")||(c?"Parallel":"Decision"),type:c?"parallel":"decision"})}),t.querySelectorAll("endEvent").forEach(s=>{r.push({id:s.getAttribute("id")||`end-${r.length}`,name:s.getAttribute("name")||"End",type:"end"})}),t.querySelectorAll("sequenceFlow").forEach(s=>{o.push({id:s.getAttribute("id")||`flow-${o.length}`,from:s.getAttribute("sourceRef")||"",to:s.getAttribute("targetRef")||"",label:s.getAttribute("name")||void 0})}),{id:((a=t.querySelector("process"))==null?void 0:a.getAttribute("id"))||"workflow",name:((l=t.querySelector("process"))==null?void 0:l.getAttribute("name"))||"Workflow",steps:r,transitions:o}}function vo(i,e){const t=[],r=[];t.push({id:"start",name:"Start",type:"start",status:"completed"}),i.forEach((o,a)=>{t.push({id:`step-${a}`,name:o,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 o=0;o<i.length-1;o++)r.push({id:`step-${o}-to-${o+1}`,from:`step-${o}`,to:`step-${o+1}`});return r.push({id:"last-to-end",from:`step-${i.length-1}`,to:"end"}),{id:"linear-workflow",name:"Linear Workflow",steps:t,transitions:r}}const wo={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)"},ko={"one-to-one":{left:"1",right:"1"},"one-to-many":{left:"1",right:"*"},"many-to-one":{left:"*",right:"1"},"many-to-many":{left:"*",right:"*"}},Co=({schema:i,onTableClick:e,onColumnClick:t,onRelationClick:r,showColumnDetails:o=!0,showOnlyKeys:a=!1,highlightTables:l=[],showMinimap:s=!0,schemaColors:c=wo,layout:f="auto",maxColumnsDisplay:d=15,className:m,style:w})=>{const[u,p]=x.useState(null),b=x.useMemo(()=>{const M=_o(i.tables,f),$=i.tables.map((k,T)=>{const j=M[k.name]||{x:T%4*300,y:Math.floor(T/4)*400},O=l.includes(k.name),B=u===k.name,U=c[k.schema||"dbo"]||"var(--nice-text-secondary, #6b7280)";let L=k.columns;a&&(L=L.filter(P=>P.primaryKey||P.foreignKey)),L.length>d&&(L=L.slice(0,d));const G=40,N=o?28:20,Y=G+L.length*N+10;return{id:k.name,label:k.schema?`${k.schema}.${k.name}`:k.name,x:j.x,y:j.y,width:250,height:Y,shape:"rectangle",style:{fill:O||B?U:"var(--nice-bg, #fff)",stroke:U,strokeWidth:B?3:O?2:1,fontColor:O||B?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:14,borderRadius:8},data:{type:"table",schema:k.schema,columns:L.map(P=>({...P,icon:No(P)})),totalColumns:k.columns.length,truncated:k.columns.length>d,comment:k.comment,...k.metadata},ports:[...k.columns.filter(P=>P.primaryKey).map(P=>({id:`${k.name}.${P.name}-pk`,position:"left"})),...k.columns.filter(P=>P.foreignKey).map(P=>({id:`${k.name}.${P.name}-fk`,position:"right"}))]}}),_=i.relations.map(k=>{const T=ko[k.type];return{id:k.id,source:k.fromTable,target:k.toTable,sourcePort:`${k.fromTable}.${k.fromColumn}-fk`,targetPort:`${k.toTable}.${k.toColumn}-pk`,label:k.name||`${T.left}─${T.right}`,style:{stroke:"var(--nice-text-secondary, #6b7280)",strokeWidth:1.5,arrowHead:Mo(k.type),arrowTail:So(k.type),lineType:"orthogonal",strokeDasharray:k.type==="many-to-many"?"5,5":void 0},data:{type:k.type,fromColumn:k.fromColumn,toColumn:k.toColumn}}});return Ae({id:`schema-${i.name}`,title:i.name,diagramType:"er",nodes:$,edges:_,metadata:{type:"er-diagram",...i.metadata}})},[i,o,a,l,u,c,f,d]),[v,g]=x.useState({x:0,y:0,zoom:1}),S=x.useCallback(M=>{if(M){if(p($=>$===M?null:M),e){const $=i.tables.find(_=>_.name===M);$&&e($)}if(r){const $=i.relations.find(_=>_.id===M);$&&r($)}}},[i.tables,i.relations,e,r]);return n.jsx("div",{className:`nice-database-schema-viewer ${m||""}`,style:{position:"relative",width:"100%",height:"100%",...w},children:n.jsx(ke,{nodes:b.nodes,edges:b.edges,groups:b.groups,viewport:v,onViewportChange:g,onSelectElement:S,showGrid:!0})})};function _o(i,e){const t={};if(e==="grid"){const r=Math.ceil(Math.sqrt(i.length));i.forEach((o,a)=>{t[o.name]={x:a%r*320+50,y:Math.floor(a/r)*450+50}})}else if(e==="hierarchical"){const r={};i.forEach(a=>{const l=a.schema||"default";r[l]||(r[l]=[]),r[l].push(a)});let o=50;Object.entries(r).forEach(([a,l])=>{l.forEach((s,c)=>{t[s.name]={x:c*320+50,y:o}}),o+=500})}else i.forEach((r,o)=>{const a=o/i.length*2*Math.PI,l=300+i.length*20;t[r.name]={x:Math.cos(a)*l+500,y:Math.sin(a)*l+400}});return t}function No(i){return i.primaryKey?"lock":i.foreignKey?"link":i.unique?"zap":"file"}function Mo(i){switch(i){case"one-to-one":case"many-to-one":return"none";case"one-to-many":case"many-to-many":return"crow"}}function So(i){switch(i){case"one-to-one":case"one-to-many":return"none";case"many-to-one":case"many-to-many":return"crow"}}function zo(i){const e=[],t=[],r=/CREATE\s+TABLE\s+(?:`?(\w+)`?\.)?`?(\w+)`?\s*\(([\s\S]*?)\);/gi;let o;for(;(o=r.exec(i))!==null;){const a=o[1]||"dbo",l=o[2],s=o[3],c=[],f=/`?(\w+)`?\s+(\w+(?:\([^)]+\))?)\s*(NOT\s+NULL|NULL)?/gi;let d;for(;(d=f.exec(s))!==null;)c.push({name:d[1],type:d[2],nullable:!d[3]||d[3].toUpperCase()!=="NOT NULL"});const m=/PRIMARY\s+KEY\s*\(`?(\w+)`?\)/i.exec(s);if(m){const p=c.find(b=>b.name===m[1]);p&&(p.primaryKey=!0)}const w=/FOREIGN\s+KEY\s*\(`?(\w+)`?\)\s*REFERENCES\s+`?(\w+)`?\s*\(`?(\w+)`?\)/gi;let u;for(;(u=w.exec(s))!==null;){const p=u,b=c.find(v=>v.name===p[1]);b&&(b.foreignKey={table:p[2],column:p[3]},t.push({id:`fk-${l}-${p[1]}`,fromTable:l,fromColumn:p[1],toTable:p[2],toColumn:p[3],type:"many-to-one"}))}e.push({name:l,schema:a,columns:c})}return{name:"Parsed Schema",tables:e,relations:t}}function Io(i,e="postgres"){const t=[];for(const r of i.tables){const o=r.schema?`${r.schema}.${r.name}`:r.name;t.push(`CREATE TABLE ${o} (`);const a=r.columns.map(s=>{let c=` ${s.name} ${s.type}`;return s.nullable||(c+=" NOT NULL"),s.primaryKey&&(c+=" PRIMARY KEY"),s.unique&&(c+=" UNIQUE"),s.defaultValue&&(c+=` DEFAULT ${s.defaultValue}`),c}),l=r.columns.filter(s=>s.foreignKey).map(s=>` FOREIGN KEY (${s.name}) REFERENCES ${s.foreignKey.table}(${s.foreignKey.column})`);t.push([...a,...l].join(`,
|
|
4
4
|
`)),t.push(`);
|
|
5
5
|
`)}return t.join(`
|
|
6
|
-
`)}const za={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)"},He=["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)"],ja={employees:[]},Aa=({data:i=ja,rootEmployeeId:e,onEmployeeClick:t,onDepartmentClick:r,showAvatars:a=!0,showContactInfo:o=!1,groupByDepartment:c=!0,collapsedDepartments:n=[],maxLevels:l=0,orientation:f="vertical",spacing:d={horizontal:200,vertical:150},statusColors:m=za,showMinimap:p=!0,className:g,style:h})=>{const[b,w]=v.useState(null),y=v.useMemo(()=>{var L;if(e)return e;const A=i.employees.find(F=>!F.managerId);return(A==null?void 0:A.id)||((L=i.employees[0])==null?void 0:L.id)},[i.employees,e]),M=v.useMemo(()=>$a(i.employees,y),[i.employees,y]),S=v.useMemo(()=>{const A=Da(M,f,d,l),L=[],F={};c&&i.departments&&i.departments.forEach((N,V)=>{const P=N.color||He[V%He.length];F[N.id]=P;const q=i.employees.filter(R=>R.department===N.id);q.length!==0&&L.push({id:`dept-${N.id}`,label:N.name,nodeIds:q.map(R=>R.id),style:{fill:`${P}15`,stroke:P,strokeWidth:2},data:{department:N}})});const Y=[],W=[],G=(N,V=0)=>{if(l>0&&V>=l||N.employee.department&&n.includes(N.employee.department))return;const P=A[N.employee.id]||{x:0,y:0},q=b===N.employee.id,R=N.employee.status||"active",B=N.employee.department?F[N.employee.department]:"var(--nice-text-secondary, #6b7280)",U=180,K=o?120:a?90:70;Y.push({id:N.employee.id,label:N.employee.name,x:P.x,y:P.y,width:U,height:K,shape:"rectangle",style:{fill:q?B:"var(--nice-bg, #fff)",stroke:B,strokeWidth:q?3:1,fontColor:q?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:13,borderRadius:12},data:{type:"employee",employee:N.employee,statusColor:m[R],hasChildren:N.children.length>0,childrenCount:N.children.length}}),N.employee.managerId&&W.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:f==="vertical"?"orthogonal":"curved"}}),N.children.forEach(ue=>G(ue,V+1))};return M&&G(M),ze({id:"org-chart",title:"Organization Chart",diagramType:"orgchart",nodes:Y,edges:W,groups:L,metadata:{type:"org-chart",...i.metadata}})},[i,M,f,d,l,c,n,a,o,m,b]),[D,C]=v.useState({x:0,y:0,zoom:1}),k=v.useCallback(A=>{if(A&&(w(L=>L===A?null:A),t)){const L=i.employees.find(F=>F.id===A);L&&t(L)}},[i.employees,t]),T=v.useCallback(A=>{var F;const L=(F=i.departments)==null?void 0:F.find(Y=>`dept-${Y.id}`===A);L&&(r==null||r(L))},[i.departments,r]);return s.jsx("div",{className:`nice-org-chart-visualizer ${g||""}`,style:{position:"relative",width:"100%",height:"100%",...h},children:s.jsx(we,{nodes:S.nodes,edges:S.edges,groups:S.groups,viewport:D,onViewportChange:C,onSelectElement:k,onGroupClick:r?T:void 0,showGrid:!1})})};function $a(i,e){const r=new Map(i.map(o=>[o.id,o])).get(e);if(!r)return null;const a=(o,c)=>{const n=i.filter(l=>l.managerId===o.id);return{employee:o,children:n.map(l=>a(l,c+1)),level:c}};return a(r,0)}function Da(i,e,t,r){const a={};if(!i)return a;const o=(l,f)=>r>0&&f>=r?0:l.children.length===0?1:l.children.reduce((d,m)=>d+o(m,f+1),0),c=(l,f,d,m)=>{if(r>0&&f>=r)return;const p=d+m*t.horizontal/2,g=f*t.vertical+50;a[l.employee.id]=e==="vertical"?{x:p,y:g}:{x:g,y:p};let h=d;l.children.forEach(b=>{const w=o(b,f+1);c(b,f+1,h,w),h+=w*t.horizontal})},n=o(i,0);return c(i,0,0,n),a}function Ta(i){const t=[...new Set(i.map(r=>r.department).filter(Boolean))].map((r,a)=>({id:r,name:r,color:He[a%He.length],headcount:i.filter(o=>o.department===r).length}));return{employees:i,departments:t}}function Pa(i){var n;const e=new Set(i.employees.map(l=>l.managerId).filter(Boolean)),t=(l,f=new Set)=>{if(f.has(l))return 0;f.add(l);const d=i.employees.find(m=>m.id===l);return d!=null&&d.managerId?1+t(d.managerId,f):1},r=i.employees.map(l=>t(l.id)),a=Math.max(...r,0),o=Array.from(e).map(l=>i.employees.filter(f=>f.managerId===l).length),c=o.length>0?o.reduce((l,f)=>l+f,0)/o.length:0;return{totalEmployees:i.employees.length,departmentCount:((n=i.departments)==null?void 0:n.length)||0,maxDepth:a,averageSpan:Math.round(c*10)/10,managers:e.size}}const Ra=({data:i,onActivityClick:e,onTransitionClick:t,minEdgeFrequency:r=.05,showFrequency:a=!0,showDuration:o=!0,highlightBottlenecks:c=!0,bottleneckThreshold:n=.9,colorScheme:l="frequency",activityColors:f,layout:d="hierarchical",animationSpeed:m=0,showMinimap:p=!0,className:g,style:h})=>{const[b,w]=v.useState(null),y=v.useMemo(()=>"activities"in i?i:Kt(i),[i]),M=v.useMemo(()=>{if(!c)return new Set;const A=y.activities.filter(F=>F.avgDuration!==void 0).map(F=>F.avgDuration);if(A.length===0)return new Set;A.sort((F,Y)=>F-Y);const L=A[Math.floor(A.length*n)]||0;return new Set(y.activities.filter(F=>(F.avgDuration||0)>=L).map(F=>F.name))},[y.activities,c,n]),S=v.useMemo(()=>{const A=Math.max(...y.activities.map(N=>N.frequency),1),L=Oa(y,d),F=y.transitions.filter(N=>N.frequency/y.totalCases>=r),Y=y.activities.map(N=>{const V=L[N.name]||{x:0,y:0},P=y.startActivities.includes(N.name),q=y.endActivities.includes(N.name),R=M.has(N.name),B=b===N.name,U=La(N,l,A,f,R);return{id:N.name,label:N.name,x:V.x,y:V.y,width:140,height:60,shape:P?"ellipse":q?"roundedRect":"rectangle",style:{fill:B?U:"var(--nice-bg, #fff)",stroke:U,strokeWidth:R?4:B?3:2,fontColor:B?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:12,borderRadius:q?20:8},data:{type:"activity",activity:N,isStart:P,isEnd:q,isBottleneck:R,frequencyPercent:Math.round(N.frequency/y.totalCases*100)}}}),W=F.map(N=>{const V=y.transitions.indexOf(N),P=N.probability||N.frequency/y.totalCases,q=P>.5,R=[];return a&&R.push(`${N.frequency}x`),o&&N.avgDuration&&R.push(Wa(N.avgDuration)),{id:`trans-${V}`,source:N.from,target:N.to,label:R.join(" | "),style:{stroke:q?"var(--nice-primary, #3b82f6)":"var(--nice-text-muted, #9ca3af)",strokeWidth:Math.max(1,Math.min(6,P*8)),arrowHead:"triangle",lineType:"curved",opacity:Math.max(.3,P)},data:{type:"transition",transition:N,probability:P}}}),G=m>0?Fa(y,m):[];return ze({id:"process-mining",title:"Process Mining Diagram",diagramType:"flowchart",nodes:Y,edges:W,animations:G,metadata:{type:"process-mining",totalCases:y.totalCases,avgCaseDuration:y.avgCaseDuration}})},[y,r,a,o,c,M,l,f,d,m,b]),D=v.useCallback(A=>{if(!t)return;const L=parseInt(A.replace("trans-",""),10),F=y.transitions[L];F&&t(F)},[y.transitions,t]),[C,k]=v.useState({x:0,y:0,zoom:1}),T=v.useCallback(A=>{if(A){if(A.startsWith("trans-")){D(A);return}if(w(L=>L===A?null:A),e){const L=y.activities.find(F=>F.name===A);L&&e(L)}}},[y.activities,e,D]);return s.jsx("div",{className:`nice-process-mining-diagram ${g||""}`,style:{position:"relative",width:"100%",height:"100%",...h},children:s.jsx(we,{nodes:S.nodes,edges:S.edges,groups:S.groups,viewport:C,onViewportChange:k,onSelectElement:T,showGrid:!0})})};function Oa(i,e){const t={};if(e==="circular"){const r=i.activities;r.forEach((a,o)=>{const c=o/r.length*2*Math.PI-Math.PI/2,n=200+r.length*15;t[a.name]={x:Math.cos(c)*n+400,y:Math.sin(c)*n+300}})}else{const r=Ea(i),a={};i.activities.forEach(c=>{const n=r[c.name]||0;a[n]=(a[n]||0)+1});const o={};i.activities.forEach(c=>{const n=r[c.name]||0,l=o[n]||0;o[n]=l+1;const f=a[n],d=(l-(f-1)/2)*180;t[c.name]={x:400+d,y:50+n*120}})}return t}function Ea(i){const e={},t=new Set,r=i.startActivities.map(a=>({activity:a,level:0}));for(;r.length>0;){const{activity:a,level:o}=r.shift();if(t.has(a))continue;t.add(a),e[a]=o,i.transitions.filter(n=>n.from===a).forEach(n=>{t.has(n.to)||r.push({activity:n.to,level:o+1})})}return i.activities.forEach(a=>{e[a.name]===void 0&&(e[a.name]=0)}),e}function La(i,e,t,r,a){if(a)return"var(--nice-danger, #ef4444)";if(r!=null&&r[i.name])return r[i.name];const o=i.frequency/t;switch(e){case"frequency":return ht("var(--nice-success, #10b981)","var(--nice-primary, #3b82f6)",o);case"duration":return i.avgDuration?ht("var(--nice-success, #10b981)","var(--nice-warning, #f59e0b)",o):"var(--nice-text-secondary, #6b7280)";case"cost":return i.avgCost?ht("var(--nice-success, #10b981)","var(--nice-danger, #ef4444)",o):"var(--nice-text-secondary, #6b7280)";default:return"var(--nice-primary, #3b82f6)"}}function ht(i,e,t){const r=f=>{const d=/#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})\b/i.exec(f);return d?{r:parseInt(d[1],16),g:parseInt(d[2],16),b:parseInt(d[3],16)}:{r:0,g:0,b:0}},a=r(i),o=r(e),c=Math.round(a.r+(o.r-a.r)*t),n=Math.round(a.g+(o.g-a.g)*t),l=Math.round(a.b+(o.b-a.b)*t);return`#${[c,n,l].map(f=>f.toString(16).padStart(2,"0")).join("")}`}function Wa(i){return i<1e3?`${i}ms`:i<6e4?`${(i/1e3).toFixed(1)}s`:i<36e5?`${(i/6e4).toFixed(1)}m`:i<864e5?`${(i/36e5).toFixed(1)}h`:`${(i/864e5).toFixed(1)}d`}function Fa(i,e){var r;const t=(r=i.variants)==null?void 0:r[0];return t?t.activities.map((a,o)=>({id:`flow-${o}`,type:"highlight",targets:[a],duration:e,delay:o*e})):[]}function Kt(i){const e=i.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,b)=>h.timestamp.getTime()-b.timestamp.getTime())});const r=new Map,a=new Map,o=new Set,c=new Set;t.forEach(g=>{if(g.length!==0){o.add(g[0].activity),c.add(g[g.length-1].activity);for(let h=0;h<g.length;h++){const b=g[h];r.has(b.activity)||r.set(b.activity,{frequency:0,durations:[],resources:new Set,costs:[]});const w=r.get(b.activity);if(w.frequency++,b.resource&&w.resources.add(b.resource),b.cost!==void 0&&w.costs.push(b.cost),h<g.length-1){const y=g[h+1],M=y.timestamp.getTime()-b.timestamp.getTime();w.durations.push(M);const S=`${b.activity}→${y.activity}`;a.has(S)||a.set(S,{frequency:0,durations:[]});const D=a.get(S);D.frequency++,D.durations.push(M)}}}});const n=Array.from(r.entries()).map(([g,h])=>({name:g,frequency:h.frequency,avgDuration:h.durations.length>0?h.durations.reduce((b,w)=>b+w,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((b,w)=>b+w,0)/h.costs.length:void 0})),l=Array.from(a.entries()).map(([g,h])=>{const[b,w]=g.split("→");return{from:b,to:w,frequency:h.frequency,avgDuration:h.durations.length>0?h.durations.reduce((y,M)=>y+M,0)/h.durations.length:void 0,probability:h.frequency/t.size}}),f=new Map;t.forEach((g,h)=>{const b=g.map(y=>y.activity).join("→");f.has(b)||f.set(b,{caseIds:[],durations:[]});const w=f.get(b);if(w.caseIds.push(h),g.length>=2){const y=g[g.length-1].timestamp.getTime()-g[0].timestamp.getTime();w.durations.push(y)}});const d=Array.from(f.entries()).map(([g,h])=>({activities:g.split("→"),frequency:h.caseIds.length,avgDuration:h.durations.length>0?h.durations.reduce((b,w)=>b+w,0)/h.durations.length:0,caseIds:h.caseIds})).sort((g,h)=>h.frequency-g.frequency),m=Array.from(t.values()).filter(g=>g.length>=2).map(g=>g[g.length-1].timestamp.getTime()-g[0].timestamp.getTime()),p=m.length>0?m.reduce((g,h)=>g+h,0)/m.length:void 0;return{activities:n,transitions:l,variants:d,startActivities:Array.from(o),endActivities:Array.from(c),totalCases:t.size,avgCaseDuration:p}}const Qt={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)"},er={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)"},It={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)"}},Ba={module:"box",package:"folder",microservice:"square",library:"book",api:"plug",database:"database",external:"globe",deprecated:"warning"},qa=({data:i,onNodeClick:e,onEdgeClick:t,visibleTypes:r,visibleEdgeTypes:a,highlightCircular:o=!0,showOnlyIssues:c=!1,layout:n="force",groupBy:l="type",nodeSizeBy:f="dependencies",colorScheme:d="type",nodeColors:m,showMetrics:p=!0,interactive:g=!0,showMinimap:h=!0,className:b,style:w})=>{const[y,M]=v.useState(null),[S,D]=v.useState(null),C=v.useMemo(()=>o?tr(i):new Set,[i,o]),k=v.useMemo(()=>{let G=i.nodes;return r&&r.length>0&&(G=G.filter(N=>r.includes(N.type))),c&&(G=G.filter(N=>{var V;return N.status==="critical"||N.status==="warning"||((V=N.metrics)==null?void 0:V.issues)&&N.metrics.issues>0})),G},[i.nodes,r,c]),T=v.useMemo(()=>{const G=new Set(k.map(V=>V.id));let N=i.edges.filter(V=>G.has(V.source)&&G.has(V.target));return a&&a.length>0&&(N=N.filter(V=>a.includes(V.type))),N},[i.edges,k,a]),A=v.useMemo(()=>{const G=Ga(k,T,n),N=Ya(k,f),V=[];if(l!=="none"){const R=new Map;k.forEach(U=>{const K=l==="type"?U.type:U.group||"ungrouped";R.has(K)||R.set(K,[]),R.get(K).push(U.id)});let B=0;R.forEach((U,K)=>{var ee,E;const ue=l==="type"?Qt[K]||"var(--nice-text-secondary, #6b7280)":((E=(ee=i.groups)==null?void 0:ee.find(H=>H.id===K))==null?void 0:E.color)||Je[B%Je.length];V.push({id:`group-${K}`,label:K,nodeIds:U,style:{fill:`${ue}10`,stroke:ue,strokeWidth:1}}),B++})}const P=k.map(R=>{const B=G[R.id]||{x:0,y:0},U=y===R.id,K=S===R.id,ue=C.has(R.id),ee=Xa(R,f,N),E=Ua(R,d,m,ue);return{id:R.id,label:R.name,x:B.x,y:B.y,width:ee.width,height:ee.height,shape:Ha(R.type),style:{fill:U||K?E:"var(--nice-bg, #fff)",stroke:E,strokeWidth:ue?4:U?3:2,fontColor:U||K?"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:Ba[R.type],isCircular:ue,statusColor:er[R.status||"unknown"]}}}),q=T.map((R,B)=>{const U=R.type==="circular"||C.has(R.source)&&C.has(R.target),K=It[R.type]||It.import;return{id:R.id||`edge-${B}`,source:R.source,target:R.target,label:R.optional?"(optional)":void 0,style:{stroke:U?"var(--nice-danger, #ef4444)":K.color,strokeWidth:Math.max(1,Math.min(4,R.weight||1)),strokeDasharray:K.dash,arrowHead:"triangle",lineType:"curved",opacity:R.optional?.5:1},data:{type:R.type,edge:R,isCircular:U}}});return ze({id:"dependency-graph",title:"Dependency Graph",diagramType:"custom",nodes:P,edges:q,groups:V,metadata:{type:"dependency-graph",...i.metadata}})},[k,T,n,l,i.groups,f,d,m,C,y,S]),L=v.useCallback(G=>{D(G)},[]),[F,Y]=v.useState({x:0,y:0,zoom:1}),W=v.useCallback(G=>{if(G){if(M(N=>N===G?null:G),e){const N=i.nodes.find(V=>V.id===G);N&&e(N)}if(t){const N=i.edges.find(V=>V.id===G);N&&t(N)}}},[i.nodes,i.edges,e,t]);return s.jsx("div",{className:`nice-dependency-graph ${b||""}`,style:{position:"relative",width:"100%",height:"100%",...w},children:s.jsx(we,{nodes:A.nodes,edges:A.edges,groups:A.groups,viewport:F,onViewportChange:Y,onSelectElement:W,onNodeHover:L,interactive:g,showGrid:!0})})},Je=["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 tr(i){const e=new Set,t=new Map;i.nodes.forEach(c=>t.set(c.id,[])),i.edges.forEach(c=>{var n;(n=t.get(c.source))==null||n.push(c.target)});const r=new Set,a=new Set,o=(c,n)=>{r.add(c),a.add(c),n.push(c);const l=t.get(c)||[];for(const f of l)if(r.has(f)){if(a.has(f)){const d=n.indexOf(f);n.slice(d).forEach(p=>e.add(p))}}else if(o(f,[...n]))return!0;return a.delete(c),!1};return i.nodes.forEach(c=>{r.has(c.id)||o(c.id,[])}),e}function Ga(i,e,t){const r={};switch(t){case"circular":{i.forEach((a,o)=>{const c=o/i.length*2*Math.PI-Math.PI/2,n=150+i.length*12;r[a.id]={x:Math.cos(c)*n+400,y:Math.sin(c)*n+300}});break}case"grid":{const a=Math.ceil(Math.sqrt(i.length));i.forEach((o,c)=>{r[o.id]={x:c%a*200+100,y:Math.floor(c/a)*150+100}});break}case"hierarchical":{const a=Va(i,e),o={},c={};i.forEach(n=>{const l=a[n.id]||0;o[l]=(o[l]||0)+1}),i.forEach(n=>{const l=a[n.id]||0,f=c[l]||0;c[l]=f+1;const d=o[l],m=(f-(d-1)/2)*200;r[n.id]={x:400+m,y:80+l*130}});break}default:{i.forEach((a,o)=>{const c=o/i.length*2*Math.PI,n=200+i.length*10;r[a.id]={x:Math.cos(c)*n+400,y:Math.sin(c)*n+300}});for(let a=0;a<50;a++){const o={};i.forEach(c=>o[c.id]={x:0,y:0});for(let c=0;c<i.length;c++)for(let n=c+1;n<i.length;n++){const l=i[c].id,f=i[n].id,d=r[f].x-r[l].x,m=r[f].y-r[l].y,p=Math.max(1,Math.sqrt(d*d+m*m)),g=5e3/(p*p);o[l].x-=d/p*g,o[l].y-=m/p*g,o[f].x+=d/p*g,o[f].y+=m/p*g}e.forEach(c=>{const n=r[c.target].x-r[c.source].x,l=r[c.target].y-r[c.source].y,f=Math.sqrt(n*n+l*l),d=f*.01;o[c.source].x+=n/f*d,o[c.source].y+=l/f*d,o[c.target].x-=n/f*d,o[c.target].y-=l/f*d}),i.forEach(c=>{r[c.id].x+=Math.max(-10,Math.min(10,o[c.id].x)),r[c.id].y+=Math.max(-10,Math.min(10,o[c.id].y))})}break}}return r}function Va(i,e){const t={},r={};i.forEach(o=>{t[o.id]=0,r[o.id]=0}),e.forEach(o=>{r[o.target]=(r[o.target]||0)+1});const a=i.filter(o=>r[o.id]===0).map(o=>o.id);for(;a.length>0;){const o=a.shift();e.filter(n=>n.source===o).forEach(n=>{t[n.target]=Math.max(t[n.target],t[o]+1),r[n.target]--,r[n.target]===0&&a.push(n.target)})}return t}function Ya(i,e){const t=i.map(r=>{var a,o,c;switch(e){case"dependencies":return((a=r.metrics)==null?void 0:a.dependencies)||0;case"dependents":return((o=r.metrics)==null?void 0:o.dependents)||0;case"complexity":return((c=r.metrics)==null?void 0:c.complexity)||0;case"size":return r.size||0;default:return 1}});return{min:Math.min(...t,0),max:Math.max(...t,1)}}function Xa(i,e,t){var l,f,d;if(e==="fixed")return{width:140,height:70};let r;switch(e){case"dependencies":r=((l=i.metrics)==null?void 0:l.dependencies)||0;break;case"dependents":r=((f=i.metrics)==null?void 0:f.dependents)||0;break;case"complexity":r=((d=i.metrics)==null?void 0:d.complexity)||0;break;case"size":r=i.size||0;break;default:r=1}const a=t.max>t.min?(r-t.min)/(t.max-t.min):.5,o=100,n=o+a*(180-o);return{width:n,height:n*.5}}function Ua(i,e,t,r){if(r)return"var(--nice-danger, #ef4444)";if(t!=null&&t[i.id])return t[i.id];switch(e){case"status":return er[i.status||"unknown"];case"group":return Je[Ja(i.group||"")%Je.length];default:return Qt[i.type]||"var(--nice-text-secondary, #6b7280)"}}function Ha(i){switch(i){case"database":return"cylinder";case"microservice":return"hexagon";case"api":return"diamond";case"external":return"cloud";default:return"rectangle"}}function Ja(i){let e=0;for(let t=0;t<i.length;t++)e=(e<<5)-e+i.charCodeAt(t),e|=0;return Math.abs(e)}function Za(i){const e=[{id:i.name,name:i.name,version:i.version,type:"package",status:"healthy"}],t=[];let r=0;const a=(o,c)=>{o&&Object.entries(o).forEach(([n,l])=>{e.find(f=>f.id===n)||e.push({id:n,name:n,version:l.replace(/[\^~>=<]/g,""),type:"library",status:"unknown"}),t.push({id:`edge-${r++}`,source:i.name,target:n,type:c})})};return a(i.dependencies,"runtime"),a(i.devDependencies,"dev"),a(i.peerDependencies,"peer"),e.forEach(o=>{o.metrics={dependencies:t.filter(c=>c.source===o.id).length,dependents:t.filter(c=>c.target===o.id).length}}),{nodes:e,edges:t}}function Ka(i){const e=new Map,t=new Map;i.nodes.forEach(d=>{e.set(d.id,0),t.set(d.id,0)}),i.edges.forEach(d=>{e.set(d.target,(e.get(d.target)||0)+1),t.set(d.source,(t.get(d.source)||0)+1)}),tr(i);let r=null,a=0;i.nodes.forEach(d=>{const m=e.get(d.id)||0;m>a&&(a=m,r=d)});let o=null,c=0;i.nodes.forEach(d=>{const m=t.get(d.id)||0;m>c&&(c=m,o=d)});const n=i.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),f=i.nodes.length>0?l/i.nodes.length:0;return{totalNodes:i.nodes.length,totalEdges:i.edges.length,circularDependencies:[],mostDependent:r,mostDependencies:o,orphanNodes:n,avgDependencies:Math.round(f*10)/10}}const Qa={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)"},eo={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"},to={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)"},ro=({data:i,onDeviceClick:e,onConnectionClick:t,onRefresh:r,autoRefreshInterval:a=0,visibleDeviceTypes:o,showOnlyIssues:c=!1,layout:n="hierarchical",groupBy:l="group",showMetrics:f=!0,showBandwidth:d=!0,showLatency:m=!1,animateTraffic:p=!1,statusColors:g=Qa,showMinimap:h=!0,className:b,style:w})=>{const[y,M]=v.useState(null),[S,D]=v.useState(new Date);v.useEffect(()=>{if(a<=0||!r)return;const Y=setInterval(()=>{r(),D(new Date)},a);return()=>clearInterval(Y)},[a,r]);const C=v.useMemo(()=>{let Y=i.devices;return o&&o.length>0&&(Y=Y.filter(W=>o.includes(W.type))),c&&(Y=Y.filter(W=>W.status==="critical"||W.status==="warning"||W.status==="offline")),Y},[i.devices,o,c]),k=v.useMemo(()=>{const Y=new Set(C.map(W=>W.id));return i.connections.filter(W=>Y.has(W.source)&&Y.has(W.target))},[i.connections,C]),T=v.useMemo(()=>{const Y=io(C,k,n,i.groups),W=[];if(l!=="none"){const P=new Map;C.forEach(R=>{let B;switch(l){case"type":B=R.type;break;case"location":B=R.location||"Unknown Location";break;default:B=R.group||"ungrouped"}P.has(B)||P.set(B,[]),P.get(B).push(R.id)});let q=0;P.forEach((R,B)=>{var ue;const U=(ue=i.groups)==null?void 0:ue.find(ee=>ee.id===B||ee.name===B),K=(U==null?void 0:U.color)||zt[q%zt.length];W.push({id:`group-${B}`,label:(U==null?void 0:U.name)||B,nodeIds:R,style:{fill:`${K}15`,stroke:K,strokeWidth:2}}),q++})}const G=C.map(P=>{const q=Y[P.id]||{x:0,y:0},R=y===P.id,B=g[P.status],U=eo[P.type];return{id:P.id,label:P.name,x:q.x,y:q.y,width:120,height:f?90:70,shape:ao(P.type),style:{fill:R?B:"var(--nice-bg, #fff)",stroke:B,strokeWidth:R?3:2,fontColor:R?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:8},data:{type:"network-device",device:P,icon:U,statusColor:B}}}),N=k.map((P,q)=>{const R=to[P.type]||"var(--nice-text-secondary, #6b7280)",B=P.status==="active",U=P.status==="degraded"||P.status==="error",K=[];if(d&&P.bandwidth){const ue=Math.round(P.bandwidth.used/P.bandwidth.total*100);K.push(`${ue}%`)}return m&&P.latency!==void 0&&K.push(`${P.latency}ms`),{id:P.id||`conn-${q}`,source:P.source,target:P.target,sourcePort:P.sourcePort,targetPort:P.targetPort,label:K.join(" | ")||void 0,style:{stroke:U?"var(--nice-danger, #ef4444)":R,strokeWidth:Math.max(1,Math.min(6,(P.speed||1e3)/1e3)),strokeDasharray:B?void 0:"5,5",arrowHead:"none",lineType:P.type==="wireless"?"curved":"orthogonal",opacity:P.status==="inactive"?.3:1},data:{type:P.type,connection:P,isActive:B,isDegraded:U}}}),V=p?oo(k):[];return ze({id:"network-topology",title:"Network Topology",diagramType:"networkTopology",nodes:G,edges:N,groups:W,animations:V,metadata:{type:"network-topology",lastRefresh:S.toISOString(),...i.metadata}})},[C,k,n,l,i.groups,f,d,m,p,g,y,S]),[A,L]=v.useState({x:0,y:0,zoom:1}),F=v.useCallback(Y=>{if(!Y)return;const W=i.connections.find(G=>G.id===Y);if(W){t==null||t(W);return}if(M(G=>G===Y?null:Y),e){const G=i.devices.find(N=>N.id===Y);G&&e(G)}},[i.devices,i.connections,e,t]);return s.jsx("div",{className:`nice-network-topology ${b||""}`,style:{position:"relative",width:"100%",height:"100%",...w},children:s.jsx(we,{nodes:T.nodes,edges:T.edges,groups:T.groups,viewport:A,onViewportChange:L,onSelectElement:F,showGrid:!0})})},zt=["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 io(i,e,t,r){var o;const a={};switch(t){case"star":{const c=new Map;i.forEach(d=>c.set(d.id,0)),e.forEach(d=>{c.set(d.source,(c.get(d.source)||0)+1),c.set(d.target,(c.get(d.target)||0)+1)});let n=(o=i[0])==null?void 0:o.id,l=0;c.forEach((d,m)=>{d>l&&(l=d,n=m)}),a[n]={x:400,y:300};const f=i.filter(d=>d.id!==n);f.forEach((d,m)=>{const p=m/f.length*2*Math.PI-Math.PI/2,g=200;a[d.id]={x:Math.cos(p)*g+400,y:Math.sin(p)*g+300}});break}case"mesh":{const c=Math.ceil(Math.sqrt(i.length));i.forEach((n,l)=>{a[n.id]={x:l%c*150+100,y:Math.floor(l/c)*130+100}});break}case"tree":{const c=i.filter(p=>p.type==="internet"||p.type==="cloud"||p.type==="router"),n=new Map,l=c.map(p=>p.id);l.forEach(p=>n.set(p,0));const f=new Set(l);for(;l.length>0;){const p=l.shift(),g=n.get(p)||0;e.forEach(h=>{let b=null;h.source===p&&!f.has(h.target)&&(b=h.target),h.target===p&&!f.has(h.source)&&(b=h.source),b&&(f.add(b),n.set(b,g+1),l.push(b))})}const d={},m={};i.forEach(p=>{const g=n.get(p.id)||0;d[g]=(d[g]||0)+1}),i.forEach(p=>{const g=n.get(p.id)||0,h=m[g]||0;m[g]=h+1;const b=d[g],w=(h-(b-1)/2)*160;a[p.id]={x:400+w,y:80+g*120}});break}case"hierarchical":default:{const c=["internet","cloud","router","firewall","loadbalancer","switch","server","storage","workstation","laptop","phone","printer","camera","iot","unknown"],n=new Map;i.forEach(f=>{n.has(f.type)||n.set(f.type,[]),n.get(f.type).push(f)});let l=50;c.forEach(f=>{const d=n.get(f);!d||d.length===0||(d.forEach((m,p)=>{const g=(p-(d.length-1)/2)*150;a[m.id]={x:400+g,y:l}}),l+=130)});break}}return a}function ao(i){switch(i){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 oo(i){return i.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 so(i={}){return console.log("Network discovery with options:",i),{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 no(i){const e=i.devices.filter(m=>m.status==="online").length,t=i.devices.filter(m=>m.status==="offline").length,r=i.devices.filter(m=>m.status==="warning").length,a=i.devices.filter(m=>m.status==="critical").length,o=i.connections.filter(m=>m.status==="active").length,c=i.connections.filter(m=>m.status==="degraded"||m.status==="error").length,n=i.devices.length>0?e/i.devices.length*100:0,l=i.connections.length>0?o/i.connections.length*100:0,f=a*10+r*5+c*5;return{score:Math.max(0,Math.min(100,Math.round(n*.5+l*.5-f))),onlineDevices:e,offlineDevices:t,warningDevices:r,criticalDevices:a,activeConnections:o,degradedConnections:c}}const co=[{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"}],lo={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)"},uo=({data:i,onChange:e,onNodeClick:t,editable:r=!1,showMetrics:a=!0,showProbabilities:o=!0,showSamples:c=!0,highlightPath:n,colorScheme:l="outcome",nodeColors:f,orientation:d="vertical",spacing:m={horizontal:180,vertical:120},showMinimap:p=!0,className:g,style:h,tutorial:b})=>{const[w,y]=v.useState(null),[M,S]=v.useState(new Set),D=v.useMemo(()=>n?go(i.root,n):new Set,[i.root,n]),{nodes:C,edges:k}=v.useMemo(()=>fo(i.root,i.edges),[i.root,i.edges]),T=v.useMemo(()=>po(C),[C]),A=v.useMemo(()=>{var V,P;const W=ho(i.root,d,m),G=C.map(q=>{const R=W[q.id]||{x:0,y:0},B=w===q.id,U=D.has(q.id),K=q.type==="leaf"||q.type==="end",ue=mo(q,l,f,T),ee=K?120:160,E=a?80:K?60:70;return{id:q.id,label:q.label,x:R.x,y:R.y,width:ee,height:E,shape:K?"roundedRect":"diamond",style:{fill:B||U?ue:"var(--nice-bg, #fff)",stroke:ue,strokeWidth:U?4:B?3:2,fontColor:B||U?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:K?8:0},data:{type:"decision-tree-node",node:q,isLeaf:K,isHighlighted:U}}}),N=k.map((q,R)=>{const B=D.has(q.source)&&D.has(q.target);let U=q.label||"";return o&&q.probability!==void 0&&(U+=U?` (${(q.probability*100).toFixed(0)}%)`:`${(q.probability*100).toFixed(0)}%`),{id:q.id||`edge-${R}`,source:q.source,target:q.target,label:U||void 0,style:{stroke:B?"var(--nice-primary, #3b82f6)":"var(--nice-text-muted, #9ca3af)",strokeWidth:B?3:2,arrowHead:"triangle",lineType:d==="vertical"?"orthogonal":"curved"},data:{type:"decision-edge",edge:q,isHighlighted:B}}});return ze({id:"decision-tree",title:"Decision Tree",diagramType:"decisionTree",nodes:G,edges:N,animations:n?yo(Array.from(D)):[],metadata:{type:"decision-tree",algorithm:(V=i.metadata)==null?void 0:V.algorithm,accuracy:(P=i.metadata)==null?void 0:P.accuracy}})},[C,k,d,m,a,o,l,f,T,w,D,n,i.metadata]),[L,F]=v.useState({x:0,y:0,zoom:1}),Y=v.useCallback(W=>{if(!W)return;y(N=>N===W?null:W);const G=C.find(N=>N.id===W);G&&G.type!=="leaf"&&G.type!=="end"&&S(N=>{const V=new Set(N);return V.has(W)?V.delete(W):V.add(W),V}),t&&G&&t(G)},[C,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(x.NiceTutorialButton,{steps:x.resolveTutorial(b,co)})}),s.jsx(we,{nodes:A.nodes,edges:A.edges,groups:A.groups,viewport:L,onViewportChange:F,onSelectElement:Y,interactive:!0,showGrid:!1})]})};function fo(i,e){const t=[],r=e?[...e]:[],a=new Set(r.map(c=>`${c.source}-${c.target}`)),o=(c,n)=>{t.push(c),n&&!a.has(`${n}-${c.id}`)&&r.push({id:`e-${n}-${c.id}`,source:n,target:c.id}),c.children&&c.children.forEach((l,f)=>{let d="";c.condition&&(d=f===0?"Yes":"No");const m=`${c.id}-${l.id}`;a.has(m)||(r.push({id:`e-${m}`,source:c.id,target:l.id,label:d,branch:f===0?"yes":"no"}),a.add(m)),o(l,c.id)})};return o(i),{nodes:t,edges:r}}function ho(i,e,t){const r={},a=n=>!n.children||n.children.length===0?1:n.children.reduce((l,f)=>l+a(f),0),o=(n,l,f,d)=>{const m=f+d*t.horizontal/2,p=l*t.vertical+50;if(r[n.id]=e==="vertical"?{x:m,y:p}:{x:p,y:m},n.children){let g=f;n.children.forEach(h=>{const b=a(h);o(h,l+1,g,b),g+=b*t.horizontal})}},c=a(i);return o(i,0,0,c),r}function po(i){const e=i.filter(r=>{var a;return((a=r.metrics)==null?void 0:a.impurity)!==void 0}).map(r=>r.metrics.impurity),t=i.filter(r=>{var a;return((a=r.metrics)==null?void 0:a.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 mo(i,e,t,r){var a,o,c;if(t!=null&&t[i.id])return t[i.id];switch(e){case"impurity":if(((a=i.metrics)==null?void 0:a.impurity)!==void 0&&r){const n=(i.metrics.impurity-r.impurity.min)/(r.impurity.max-r.impurity.min||1);return jt("var(--nice-success, #10b981)","var(--nice-danger, #ef4444)",n)}break;case"samples":if(((o=i.metrics)==null?void 0:o.samples)!==void 0&&r){const n=(i.metrics.samples-r.samples.min)/(r.samples.max-r.samples.min||1);return jt("var(--nice-warning-bg, #fef3c7)","var(--nice-warning, #f59e0b)",n)}break;case"outcome":if(i.type==="leaf"&&((c=i.outcome)!=null&&c.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)"}[i.outcome.class.toLowerCase()]||"var(--nice-primary, #3b82f6)";break}return lo[i.type]||"var(--nice-text-secondary, #6b7280)"}function jt(i,e,t){const r=f=>{var m;const d=((m=/#([a-f\d]{6})\b/i.exec(f))==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)}},a=r(i),o=r(e),c=Math.round(a.r+(o.r-a.r)*t),n=Math.round(a.g+(o.g-a.g)*t),l=Math.round(a.b+(o.b-a.b)*t);return`#${[c,n,l].map(f=>f.toString(16).padStart(2,"0")).join("")}`}function go(i,e){const t=new Set,r=a=>{if(t.add(a.id),a.type==="leaf"||a.type==="end"||!a.children)return!0;if(a.condition){const o=e[a.condition.feature],n=rr(o,a.condition.operator,a.condition.value)?0:1;if(a.children[n])return r(a.children[n])}return a.children[0]?r(a.children[0]):!0};return r(i),t}function rr(i,e,t){switch(e){case"=":return i===t;case"!=":return i!==t;case"<":return Number(i)<Number(t);case"<=":return Number(i)<=Number(t);case">":return Number(i)>Number(t);case">=":return Number(i)>=Number(t);case"in":return Array.isArray(t)&&t.includes(i);case"not_in":return Array.isArray(t)&&!t.includes(i);case"contains":return String(i).includes(String(t));default:return!1}}function yo(i){return i.map((e,t)=>({id:`path-${t}`,type:"highlight",targets:[e],duration:500,delay:t*300}))}function bo(i){const{tree:e,feature_names:t,class_names:r}=i;e.children_left.length;const a=c=>{const n=e.children_left[c]===-1,l=e.n_node_samples[c],f=e.impurity[c],d=e.value[c];if(n){const w=Array.isArray(d)?d:[d],y=Array.isArray(w[0])?w[0]:w,M=y.indexOf(Math.max(...y)),S=(r==null?void 0:r[M])||`Class ${M}`,D=y.reduce((k,T)=>k+T,0),C=D>0?y[M]/D:0;return{id:`node-${c}`,type:"leaf",label:S,outcome:{value:S,class:S,probability:C,samples:l},metrics:{samples:l,impurity:f}}}const m=e.feature[c],p=e.threshold[c],g=t[m]||`feature_${m}`,h=a(e.children_left[c]),b=a(e.children_right[c]);return{id:`node-${c}`,type:c===0?"root":"decision",label:`${g} <= ${p.toFixed(2)}`,condition:{feature:g,operator:"<=",value:p},children:[h,b],metrics:{samples:l,impurity:f,giniIndex:f}}},o=a(0);return{root:o,features:t,classes:r,metadata:{algorithm:"sklearn.DecisionTreeClassifier",maxDepth:ir(o)}}}function ir(i,e=0){return!i.children||i.children.length===0?e:Math.max(...i.children.map(t=>ir(t,e+1)))}function xo(i){const e=(r,a)=>typeof r=="string"?{id:a,type:"leaf",label:r,outcome:{value:r}}:{...r,id:a};return{root:{id:"root",type:"root",label:i.question,condition:{feature:i.feature,operator:typeof i.threshold=="number"?"<=":"=",value:i.threshold},children:[e(i.yesOutcome,"yes-outcome"),e(i.noOutcome,"no-outcome")]}}}function vo(i,e){const t=[],r=o=>{var c,n;if(t.push(o.id),o.type==="leaf"||o.type==="end"||!o.children)return{value:((c=o.outcome)==null?void 0:c.value)??o.label,probability:(n=o.outcome)==null?void 0:n.probability};if(o.condition){const l=e[o.condition.feature],d=rr(l,o.condition.operator,o.condition.value)?0:1;if(o.children[d])return r(o.children[d])}return o.children[0]?r(o.children[0]):{value:null}},a=r(i.root);return{prediction:a.value,probability:a.probability,path:t}}let wo=0;function vt(){return`tmpl-${++wo}-${Date.now().toString(36)}`}function re(i,e,t="roundedRect",r={width:160,height:60},a){return{id:vt(),label:i,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:a}}function ae(i,e,t="bottom",r="top",a){return{id:vt(),sourceNodeId:i.id,sourcePortId:t,targetNodeId:e.id,targetPortId:r,label:a,style:{lineType:"bezier",targetArrow:"arrow"}}}function Pe(i,e,t,r){const a=new Date().toISOString();return{version:"1.0",id:vt(),title:i,diagramType:e,nodes:t,edges:r,groups:[],animations:[],viewport:{x:0,y:0,zoom:1},metadata:{createdAt:a,updatedAt:a}}}function ko(){const i=re("Commit",{x:40,y:200},"circle",{width:80,height:80}),e=re("Build",{x:200,y:200},"roundedRect"),t=re("Test",{x:420,y:200},"roundedRect"),r=re("Deploy",{x:640,y:200},"roundedRect"),a=re("Production",{x:860,y:200},"hexagon",{width:140,height:80});return Pe("CI/CD Pipeline","flowchart",[i,e,t,r,a],[ae(i,e,"right","left"),ae(e,t,"right","left"),ae(t,r,"right","left"),ae(r,a,"right","left")])}function _o(){const i=re("API Gateway",{x:350,y:40},"hexagon",{width:160,height:80}),e=re("Auth Service",{x:80,y:200},"roundedRect"),t=re("User Service",{x:300,y:200},"roundedRect"),r=re("Order Service",{x:520,y:200},"roundedRect"),a=re("Notification",{x:740,y:200},"roundedRect"),o=re("Users DB",{x:180,y:380},"cylinder",{width:120,height:70}),c=re("Orders DB",{x:520,y:380},"cylinder",{width:120,height:70}),n=re("Message Queue",{x:620,y:380},"parallelogram",{width:160,height:60}),l=[i,e,t,r,a,o,c,n],f=[ae(i,e,"bottom","top"),ae(i,t,"bottom","top"),ae(i,r,"bottom","top"),ae(r,a,"right","left"),ae(t,o,"bottom","top"),ae(r,c,"bottom","top"),ae(a,n,"bottom","top")];return Pe("Microservices Architecture","flowchart",l,f)}function Co(){const i=re("Start",{x:350,y:20},"circle",{width:70,height:70}),e=re("Landing Page",{x:310,y:140},"roundedRect"),t=re("Sign Up",{x:140,y:280},"roundedRect"),r=re("Log In",{x:480,y:280},"roundedRect"),a=re("Dashboard",{x:310,y:420},"roundedRect"),o=re("End",{x:350,y:560},"circle",{width:70,height:70});return Pe("User Flow","flowchart",[i,e,t,r,a,o],[ae(i,e,"bottom","top"),ae(e,t,"bottom","top","New user"),ae(e,r,"bottom","top","Returning"),ae(t,a,"bottom","top"),ae(r,a,"bottom","top"),ae(a,o,"bottom","top")])}function No(){const i=re("Users",{x:80,y:100},"rectangle",{width:180,height:100}),e=re("Orders",{x:380,y:100},"rectangle",{width:180,height:100}),t=re("Products",{x:380,y:320},"rectangle",{width:180,height:100}),r=re("Categories",{x:680,y:320},"rectangle",{width:180,height:100});return Pe("Entity Relationship","er",[i,e,t,r],[ae(i,e,"right","left","1:N"),ae(e,t,"bottom","top","N:M"),ae(t,r,"right","left","N:1")])}function Mo(){const i=re("CEO",{x:350,y:40},"roundedRect"),e=re("CTO",{x:150,y:180},"roundedRect"),t=re("CFO",{x:550,y:180},"roundedRect"),r=re("Engineering",{x:50,y:320},"roundedRect"),a=re("DevOps",{x:250,y:320},"roundedRect"),o=re("Accounting",{x:550,y:320},"roundedRect");return Pe("Organization Chart","orgchart",[i,e,t,r,a,o],[ae(i,e,"bottom","top"),ae(i,t,"bottom","top"),ae(e,r,"bottom","top"),ae(e,a,"bottom","top"),ae(t,o,"bottom","top")])}function So(){const i=re("Idle",{x:80,y:200},"circle",{width:90,height:90}),e=re("Loading",{x:300,y:80},"roundedRect"),t=re("Success",{x:520,y:80},"roundedRect"),r=re("Error",{x:520,y:320},"roundedRect"),a=re("Retry",{x:300,y:320},"diamond",{width:100,height:100});return Pe("State Machine","stateMachine",[i,e,t,r,a],[ae(i,e,"right","left","fetch"),ae(e,t,"right","left","ok"),ae(e,r,"bottom","top","fail"),ae(r,a,"left","right"),ae(a,e,"top","bottom","retry"),ae(a,i,"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:ko},{id:"microservices",name:"Microservices Architecture",description:"Microservices with API gateway, databases, and message queue",category:"software",diagramType:"flowchart",tags:["architecture","microservices","api","backend"],create:_o},{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:Co},{id:"er-diagram",name:"Entity Relationship",description:"Database ER diagram with tables and relations",category:"software",diagramType:"er",tags:["database","er","schema","sql"],create:No},{id:"org-chart",name:"Organization Chart",description:"Company organizational hierarchy",category:"business",diagramType:"orgchart",tags:["org","hierarchy","team","management"],create:Mo},{id:"state-machine",name:"State Machine",description:"Finite state machine with transitions",category:"software",diagramType:"stateMachine",tags:["state","fsm","transitions","machine"],create:So}];function Io(i){return it.find(e=>e.id===i)}function zo(i){return it.filter(e=>e.category===i)}function jo(i){const e=i.toLowerCase();return it.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.tags.some(r=>r.includes(e)))}class ar{constructor(e={}){this.versions=[],this.currentVersionIndex=-1,this.autoSaveTimer=null,this.lastDocument=null,this.listeners=new Set,this.config={maxVersions:e.maxVersions??100,autoSaveInterval:e.autoSaveInterval??3e4,compressOldVersions:e.compressOldVersions??!1,userId:e.userId??"",userName:e.userName??"Anonymous"}}startAutoSave(e){this.config.autoSaveInterval<=0||(this.autoSaveTimer=setInterval(()=>{const t=e();this.hasChanges(t)&&this.saveVersion(t,"Auto-save")},this.config.autoSaveInterval))}stopAutoSave(){this.autoSaveTimer&&(clearInterval(this.autoSaveTimer),this.autoSaveTimer=null)}hasChanges(e){return this.lastDocument?JSON.stringify(e)!==JSON.stringify(this.lastDocument):!0}saveVersion(e,t){const r=this.lastDocument?this.calculateChanges(this.lastDocument,e):[{type:"node-added",description:"Initial version"}],a={id:Ao(),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(a),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(),a}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(a=>a.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),a=this.getVersion(t);if(!r||!a)return null;const o=JSON.parse(r.snapshot),c=JSON.parse(a.snapshot),n=this.calculateChanges(o,c),l={nodesAdded:n.filter(f=>f.type==="node-added").length,nodesRemoved:n.filter(f=>f.type==="node-removed").length,nodesMoved:n.filter(f=>f.type==="node-moved").length,nodesRestyled:n.filter(f=>f.type==="node-restyled").length,edgesAdded:n.filter(f=>f.type==="edge-added").length,edgesRemoved:n.filter(f=>f.type==="edge-removed").length,edgesRestyled:n.filter(f=>f.type==="edge-restyled").length,groupsModified:n.filter(f=>f.type.startsWith("group-")).length,totalChanges:n.length};return{fromVersionId:e,toVersionId:t,changes:n,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 a=new Set(e.nodes.map(d=>d.id)),o=new Set(t.nodes.map(d=>d.id));for(const d of t.nodes)a.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)o.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(p=>p.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 c=new Set(e.edges.map(d=>d.id)),n=new Set(t.edges.map(d=>d.id));for(const d of t.edges)c.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)n.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(p=>p.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)),f=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)f.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 Ao(){return`v_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}function $o(i){const e=new ar(i);return{manager:e,saveVersion:e.saveVersion.bind(e),getVersions:e.getVersions.bind(e),restoreToVersion:e.restoreToVersion.bind(e),diff:e.diff.bind(e)}}class Do{constructor(e){this.comments=new Map,this.listeners=new Set,this.mentionListeners=new Set,this.config=e}addComment(e,t,r){const a=this.parseMentions(t),o={id:To(),anchor:e,status:"open",authorId:this.config.userId,authorName:this.config.userName,authorAvatar:this.config.userAvatar,text:t,mentions:a,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(o.id,o),this.notify(),a.forEach(c=>this.notifyMention(o,c.userId)),o}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 a=this.parseMentions(t),o={id:Po(),authorId:this.config.userId,authorName:this.config.userName,authorAvatar:this.config.userAvatar,text:t,mentions:a,createdAt:new Date().toISOString()};return r.replies.push(o),this.notify(),a.forEach(c=>this.notifyMention(r,c.userId)),o}editReply(e,t,r){const a=this.comments.get(e);if(!a)return null;const o=a.replies.find(c=>c.id===t);return o?(o.text=r,o.mentions=this.parseMentions(r),o.editedAt=new Date().toISOString(),this.notify(),o):null}deleteReply(e,t){const r=this.comments.get(e);if(!r)return!1;const a=r.replies.find(o=>o.id===t);return a?(a.deleted=!0,a.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(o=>o.userId===e),a=t.replies.some(o=>o.mentions.some(c=>c.userId===e));return r||a})}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(o=>o.text)].join(" ").toLowerCase().includes(r))return!1}return!(e.mentionedUserId&&!(t.mentions.some(a=>a.userId===e.mentionedUserId)||t.replies.some(a=>a.mentions.some(o=>o.userId===e.mentionedUserId))))})}parseMentions(e){var o;const t=[],r=/@(\w+)/g;let a;for(;(a=r.exec(e))!==null;){const c=a[1],n=(o=this.config.availableUsers)==null?void 0:o.find(l=>l.name.toLowerCase()===c.toLowerCase()||l.id===c);n&&t.push({userId:n.id,userName:n.name,startIndex:a.index,endIndex:a.index+a[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 To(){return`comment_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}function Po(){return`reply_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}const Ro={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:"#880e4f",icon:"flame"}};function Oo(i){const e=new Date(i),r=new Date().getTime()-e.getTime(),a=Math.floor(r/(1e3*60)),o=Math.floor(a/60),c=Math.floor(o/24);return a<1?"just now":a<60?`${a}m ago`:o<24?`${o}h ago`:c<7?`${c}d ago`:e.toLocaleDateString()}function Eo(i,e){if(e.length===0)return i;const t=[...e].sort((a,o)=>o.startIndex-a.startIndex);let r=i;for(const a of t){const o=r.slice(0,a.startIndex),c=r.slice(a.endIndex);r=`${o}<span class="mention" data-user-id="${a.userId}">@${a.userName}</span>${c}`}return r}class or{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(a=>a.id!==e.id),r.rules.push(e),r.rules.sort((a,o)=>a.priority-o.priority),this.invalidateCache(),this.notify())}removeRule(e,t="default"){const r=this.profiles.get(t);r&&(r.rules=r.rules.filter(a=>a.id!==e),this.invalidateCache(),this.notify())}updateRule(e,t,r="default"){const a=this.profiles.get(r);if(!a)return;const o=a.rules.find(c=>c.id===e);o&&(Object.assign(o,t),a.rules.sort((c,n)=>c.priority-n.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 a=this.getActiveProfile();if(!(a!=null&&a.enabled))return this.emptyStyles(e.id);const o=a.rules.filter(n=>n.enabled&&(n.target==="node"||n.target==="both")&&(!n.elementShapes||n.elementShapes.includes(e.shape))),c=this.processRules(e.id,o,e);return this.cache.set(t,c),c}applyToEdge(e){const t=`edge_${e.id}_${JSON.stringify(e.data)}`,r=this.cache.get(t);if(r)return r;const a=this.getActiveProfile();if(!(a!=null&&a.enabled))return this.emptyStyles(e.id);const o=a.rules.filter(n=>n.enabled&&(n.target==="edge"||n.target==="both")),c=this.processRules(e.id,o,e);return this.cache.set(t,c),c}applyToAll(e,t){const r=new Map;for(const a of e)r.set(a.id,this.applyToNode(a));for(const a of t)r.set(a.id,this.applyToEdge(a));return r}processRules(e,t,r){const a={elementId:e,matchedRules:[],styleOverrides:{},addedClasses:[]};for(const o of t)if(this.evaluateCondition(o.condition,r)&&(a.matchedRules.push(o.id),this.applyActions(o.actions,a),o.stopProcessing))break;return a}evaluateCondition(e,t){if("logic"in e)return e.logic==="and"?e.conditions.every(a=>this.evaluateCondition(a,t)):e.conditions.some(a=>this.evaluateCondition(a,t));const r=this.getPropertyValue(t,e.property);return this.compareValues(r,e)}getPropertyValue(e,t){const r=t.split(".");let a=e;for(const o of r){if(a==null)return;a=a[o]}return a}compareValues(e,t){const{operator:r,value:a,valueTo:o,caseInsensitive:c}=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 n=c&&typeof e=="string"?e.toLowerCase():e,l=c&&typeof a=="string"?a.toLowerCase():a;switch(r){case"equals":return n===l;case"not_equals":return n!==l;case"greater_than":return e>a;case"greater_than_or_equals":return e>=a;case"less_than":return e<a;case"less_than_or_equals":return e<=a;case"contains":return typeof n=="string"&&typeof l=="string"?n.includes(l):Array.isArray(e)?e.includes(a):!1;case"not_contains":return typeof n=="string"&&typeof l=="string"?!n.includes(l):Array.isArray(e)?!e.includes(a):!0;case"starts_with":return typeof n=="string"&&typeof l=="string"&&n.startsWith(l);case"ends_with":return typeof n=="string"&&typeof l=="string"&&n.endsWith(l);case"regex":if(typeof e!="string"||typeof a!="string")return!1;try{const f=c?"i":"";return new RegExp(a,f).test(e)}catch{return!1}case"in":return Array.isArray(a)&&a.includes(e);case"not_in":return!Array.isArray(a)||!a.includes(e);case"between":return e>=a&&e<=o;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(a=>a!==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 wt=[{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 Lo(i){const e=wt.find(t=>t.id===i);return e?{...e,id:`${e.id}_${Date.now()}`}:null}function Wo(i=!1){const e=new or;if(i)for(const t of wt)e.addRule(t);return e}class Fo{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:a="contains",caseSensitive:o=!1,searchData:c=!0,dataProperties:n=[],maxResults:l=100,nodeShapes:f=[],groupIds:d=[]}=t;if(!e.trim())return this.state={...this.state,query:"",results:[],selectedIndex:-1,isActive:!1,totalCount:0},this.notify(),[];const m=[],p=o?e:e.toLowerCase();if(r==="all"||r==="nodes"||r==="labels")for(const g of this.nodes){if(m.length>=l)break;if(f.length>0&&!f.includes(g.shape)||d.length>0&&g.groupId&&!d.includes(g.groupId))continue;const h=this.matchElement(g,p,a,o,c,n);h&&m.push({id:g.id,type:"node",label:g.label||g.id,element:g,matchText:h.text,matchProperty:h.property,matchPositions:h.positions,score:h.score})}if(r==="all"||r==="edges"||r==="labels")for(const g of this.edges){if(m.length>=l)break;const h=this.matchElement(g,p,a,o,c,n);h&&m.push({id:g.id,type:"edge",label:g.label||`${g.sourceNodeId} → ${g.targetNodeId}`,element:g,matchText:h.text,matchProperty:h.property,matchPositions:h.positions,score:h.score})}if(r==="all"||r==="groups")for(const g of this.groups){if(m.length>=l)break;if(d.length>0&&!d.includes(g.id))continue;const h=this.matchElement(g,p,a,o,c,n);h&&m.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 m.sort((g,h)=>h.score-g.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,a,o,c){let n=null;const l=(d,m,p,g)=>{(!n||g>n.score)&&(n={text:d,property:m,positions:p,score:g})},f=this.matchText(e.id,t,r,a);if(f&&l(e.id,"id",f.positions,100+f.positions.length*10),"label"in e&&e.label){const d=this.matchText(e.label,t,r,a);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,a);d&&l(e.shape,"shape",d.positions,80+d.positions.length*10)}if(o&&"data"in e&&e.data){const d=this.searchInData(e.data,t,r,a,c);for(const m of d)l(m.text,`data.${m.property}`,m.positions,50+m.positions.length*10)}return n}matchText(e,t,r,a){const o=a?e:e.toLowerCase(),c=a?t:t.toLowerCase(),n=[];switch(r){case"exact":o===c&&n.push({start:0,end:e.length});break;case"starts_with":o.startsWith(c)&&n.push({start:0,end:t.length});break;case"ends_with":o.endsWith(c)&&n.push({start:e.length-t.length,end:e.length});break;case"regex":try{const l=a?"g":"gi",f=new RegExp(t,l);let d;for(;(d=f.exec(e))!==null&&(n.push({start:d.index,end:d.index+d[0].length}),!!f.global););}catch{}break;case"contains":default:{let l=0;for(;(l=o.indexOf(c,l))!==-1;)n.push({start:l,end:l+t.length}),l+=t.length;break}}return n.length>0?{positions:n}:null}searchInData(e,t,r,a,o,c=""){const n=[];for(const[l,f]of Object.entries(e)){const d=c?`${c}.${l}`:l;if(!(o.length>0&&!o.some(m=>d.startsWith(m))))if(typeof f=="string"){const m=this.matchText(f,t,r,a);m&&n.push({text:f,property:d,positions:m.positions})}else if(typeof f=="number"||typeof f=="boolean"){const m=String(f),p=this.matchText(m,t,r,a);p&&n.push({text:m,property:d,positions:p.positions})}else f!=null&&typeof f=="object"&&!Array.isArray(f)&&n.push(...this.searchInData(f,t,r,a,o,d))}return n}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(o=>this.matchFilters(o,e)),r=this.edges.filter(o=>this.matchFilters(o,e)),a=this.groups.filter(o=>this.matchFilters(o,e));return this.notify(),{nodes:t,edges:r,groups:a}}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 a=e;for(const o of r){if(a==null)return;a=a[o]}return a}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 a of this.nodes){const o=this.getPropertyValue(a,e);o!=null&&r.add(o)}if(!t||t==="edge")for(const a of this.edges){const o=this.getPropertyValue(a,e);o!=null&&r.add(o)}if(!t||t==="group")for(const a of this.groups){const o=this.getPropertyValue(a,e);o!=null&&r.add(o)}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 Bo(i,e,t="search-highlight"){if(e.length===0)return i;const r=[...e].sort((o,c)=>c.start-o.start);let a=i;for(const o of r){const c=a.slice(0,o.start),n=a.slice(o.start,o.end),l=a.slice(o.end);a=`${c}<span class="${t}">${n}</span>${l}`}return a}function qo(i,e){switch(i){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=Gt;exports.AnimationTimeline=Qe;exports.COMMENT_PRIORITY_STYLES=Ro;exports.ConditionalStylingEngine=or;exports.DIAGRAM_STYLE_PRESETS=Ke;exports.DIAGRAM_TEMPLATES=it;exports.DiagramCanvas=we;exports.DiagramCellRenderer=ua;exports.DiagramCommentManager=Do;exports.DiagramMinimap=et;exports.DiagramModel=Ze;exports.DiagramParticleEngine=At;exports.DiagramPropertyPanel=tt;exports.DiagramSearchFilterEngine=Fo;exports.DiagramToolbar=rt;exports.DiagramVersioningManager=ar;exports.EDGE_STYLE_CATALOG=yi;exports.NODE_STYLE_CATALOG=gi;exports.NiceAnimationTimeline=Qe;exports.NiceDatabaseSchemaViewer=ka;exports.NiceDecisionTreeEditor=uo;exports.NiceDependencyGraph=qa;exports.NiceDiagram=bt;exports.NiceDiagramCanvas=we;exports.NiceDiagramEditor=Ft;exports.NiceDiagramMinimap=et;exports.NiceDiagramPropertyPanel=tt;exports.NiceDiagramToolbar=rt;exports.NiceDiagramViewer=bt;exports.NiceI18nProvider=mt;exports.NiceNetworkTopology=ro;exports.NiceOrgChartVisualizer=Aa;exports.NiceProcessMiningDiagram=Ra;exports.NiceWorkflowVisualizer=ga;exports.PRESET_RULES=wt;exports.TRANSITION_PRESETS=Wt;exports.analyzeDependencyGraph=Ka;exports.calculateNetworkHealth=no;exports.calculateOrgStats=Pa;exports.computeGlowRadius=Dt;exports.computeLayout=Ot;exports.convertAnimation=Ut;exports.convertEdge=Yt;exports.convertGroup=Xt;exports.convertNode=Vt;exports.createConditionalStylingEngine=Wo;exports.createDecisionTree=xo;exports.createDiagramDocument=ze;exports.createGlowFilterId=$t;exports.createLinearWorkflow=xa;exports.createOrgChartFromEmployees=Ta;exports.createPresetFromTheme=wi;exports.createQuickFilter=qo;exports.createRuleFromPreset=Lo;exports.createVersioningHook=$o;exports.discoverNetworkTopology=so;exports.exportToMermaid=Tt;exports.exportToSvg=pt;exports.fetchAndGenerateDiagram=fa;exports.formatCommentDate=Oo;exports.generateDiagramFromData=Zt;exports.getDiagramStylePreset=bi;exports.getDiagramStylePresetsByCategory=xi;exports.getEasing=Bt;exports.getPointOnPath=fr;exports.getTemplateById=Io;exports.getTemplatesByCategory=zo;exports.highlightMatches=Bo;exports.mineProcessFromLog=Kt;exports.parseBPMNToWorkflow=ba;exports.parseNddJson=hr;exports.parsePackageJsonToDependencies=Za;exports.parseSQLToSchema=Sa;exports.parseSklearnTree=bo;exports.predictWithTree=vo;exports.presetToThemeOverrides=vi;exports.renderTextWithMentions=Eo;exports.schemaToSQL=Ia;exports.searchTemplates=jo;exports.stringifyNddJson=Rt;exports.useDiagramEditor=Lt;exports.useNiceTranslation=We;
|
|
6
|
+
`)}const Ao={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)"},Xe=["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)"],jo={employees:[]},Do=({data:i=jo,rootEmployeeId:e,onEmployeeClick:t,onDepartmentClick:r,showAvatars:o=!0,showContactInfo:a=!1,groupByDepartment:l=!0,collapsedDepartments:s=[],maxLevels:c=0,orientation:f="vertical",spacing:d={horizontal:200,vertical:150},statusColors:m=Ao,showMinimap:w=!0,className:u,style:p})=>{const[b,v]=x.useState(null),g=x.useMemo(()=>{var O;if(e)return e;const j=i.employees.find(B=>!B.managerId);return(j==null?void 0:j.id)||((O=i.employees[0])==null?void 0:O.id)},[i.employees,e]),S=x.useMemo(()=>$o(i.employees,g),[i.employees,g]),M=x.useMemo(()=>{const j=To(S,f,d,c),O=[],B={};l&&i.departments&&i.departments.forEach((N,Y)=>{const P=N.color||Xe[Y%Xe.length];B[N.id]=P;const V=i.employees.filter(E=>E.department===N.id);V.length!==0&&O.push({id:`dept-${N.id}`,label:N.name,nodeIds:V.map(E=>E.id),style:{fill:`${P}15`,stroke:P,strokeWidth:2},data:{department:N}})});const U=[],L=[],G=(N,Y=0)=>{if(c>0&&Y>=c||N.employee.department&&s.includes(N.employee.department))return;const P=j[N.employee.id]||{x:0,y:0},V=b===N.employee.id,E=N.employee.status||"active",q=N.employee.department?B[N.employee.department]:"var(--nice-text-secondary, #6b7280)",X=180,J=a?120:o?90:70;U.push({id:N.employee.id,label:N.employee.name,x:P.x,y:P.y,width:X,height:J,shape:"rectangle",style:{fill:V?q:"var(--nice-bg, #fff)",stroke:q,strokeWidth:V?3:1,fontColor:V?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:13,borderRadius:12},data:{type:"employee",employee:N.employee,statusColor:m[E],hasChildren:N.children.length>0,childrenCount:N.children.length}}),N.employee.managerId&&L.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:f==="vertical"?"orthogonal":"curved"}}),N.children.forEach(fe=>G(fe,Y+1))};return S&&G(S),Ae({id:"org-chart",title:"Organization Chart",diagramType:"orgchart",nodes:U,edges:L,groups:O,metadata:{type:"org-chart",...i.metadata}})},[i,S,f,d,c,l,s,o,a,m,b]),[$,_]=x.useState({x:0,y:0,zoom:1}),k=x.useCallback(j=>{if(j&&(v(O=>O===j?null:j),t)){const O=i.employees.find(B=>B.id===j);O&&t(O)}},[i.employees,t]),T=x.useCallback(j=>{var B;const O=(B=i.departments)==null?void 0:B.find(U=>`dept-${U.id}`===j);O&&(r==null||r(O))},[i.departments,r]);return n.jsx("div",{className:`nice-org-chart-visualizer ${u||""}`,style:{position:"relative",width:"100%",height:"100%",...p},children:n.jsx(ke,{nodes:M.nodes,edges:M.edges,groups:M.groups,viewport:$,onViewportChange:_,onSelectElement:k,onGroupClick:r?T:void 0,showGrid:!1})})};function $o(i,e){const r=new Map(i.map(a=>[a.id,a])).get(e);if(!r)return null;const o=(a,l)=>{const s=i.filter(c=>c.managerId===a.id);return{employee:a,children:s.map(c=>o(c,l+1)),level:l}};return o(r,0)}function To(i,e,t,r){const o={};if(!i)return o;const a=(c,f)=>r>0&&f>=r?0:c.children.length===0?1:c.children.reduce((d,m)=>d+a(m,f+1),0),l=(c,f,d,m)=>{if(r>0&&f>=r)return;const w=d+m*t.horizontal/2,u=f*t.vertical+50;o[c.employee.id]=e==="vertical"?{x:w,y:u}:{x:u,y:w};let p=d;c.children.forEach(b=>{const v=a(b,f+1);l(b,f+1,p,v),p+=v*t.horizontal})},s=a(i,0);return l(i,0,0,s),o}function Po(i){const t=[...new Set(i.map(r=>r.department).filter(Boolean))].map((r,o)=>({id:r,name:r,color:Xe[o%Xe.length],headcount:i.filter(a=>a.department===r).length}));return{employees:i,departments:t}}function Eo(i){var s;const e=new Set(i.employees.map(c=>c.managerId).filter(Boolean)),t=(c,f=new Set)=>{if(f.has(c))return 0;f.add(c);const d=i.employees.find(m=>m.id===c);return d!=null&&d.managerId?1+t(d.managerId,f):1},r=i.employees.map(c=>t(c.id)),o=Math.max(...r,0),a=Array.from(e).map(c=>i.employees.filter(f=>f.managerId===c).length),l=a.length>0?a.reduce((c,f)=>c+f,0)/a.length:0;return{totalEmployees:i.employees.length,departmentCount:((s=i.departments)==null?void 0:s.length)||0,maxDepth:o,averageSpan:Math.round(l*10)/10,managers:e.size}}const Ro=({data:i,onActivityClick:e,onTransitionClick:t,minEdgeFrequency:r=.05,showFrequency:o=!0,showDuration:a=!0,highlightBottlenecks:l=!0,bottleneckThreshold:s=.9,colorScheme:c="frequency",activityColors:f,layout:d="hierarchical",animationSpeed:m=0,showMinimap:w=!0,className:u,style:p})=>{const[b,v]=x.useState(null),g=x.useMemo(()=>"activities"in i?i:Jt(i),[i]),S=x.useMemo(()=>{if(!l)return new Set;const j=g.activities.filter(B=>B.avgDuration!==void 0).map(B=>B.avgDuration);if(j.length===0)return new Set;j.sort((B,U)=>B-U);const O=j[Math.floor(j.length*s)]||0;return new Set(g.activities.filter(B=>(B.avgDuration||0)>=O).map(B=>B.name))},[g.activities,l,s]),M=x.useMemo(()=>{const j=Math.max(...g.activities.map(N=>N.frequency),1),O=Oo(g,d),B=g.transitions.filter(N=>N.frequency/g.totalCases>=r),U=g.activities.map(N=>{const Y=O[N.name]||{x:0,y:0},P=g.startActivities.includes(N.name),V=g.endActivities.includes(N.name),E=S.has(N.name),q=b===N.name,X=Lo(N,c,j,f,E);return{id:N.name,label:N.name,x:Y.x,y:Y.y,width:140,height:60,shape:P?"ellipse":V?"roundedRect":"rectangle",style:{fill:q?X:"var(--nice-bg, #fff)",stroke:X,strokeWidth:E?4:q?3:2,fontColor:q?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:12,borderRadius:V?20:8},data:{type:"activity",activity:N,isStart:P,isEnd:V,isBottleneck:E,frequencyPercent:Math.round(N.frequency/g.totalCases*100)}}}),L=B.map(N=>{const Y=g.transitions.indexOf(N),P=N.probability||N.frequency/g.totalCases,V=P>.5,E=[];return o&&E.push(`${N.frequency}x`),a&&N.avgDuration&&E.push(Wo(N.avgDuration)),{id:`trans-${Y}`,source:N.from,target:N.to,label:E.join(" | "),style:{stroke:V?"var(--nice-primary, #3b82f6)":"var(--nice-text-muted, #9ca3af)",strokeWidth:Math.max(1,Math.min(6,P*8)),arrowHead:"triangle",lineType:"curved",opacity:Math.max(.3,P)},data:{type:"transition",transition:N,probability:P}}}),G=m>0?Bo(g,m):[];return Ae({id:"process-mining",title:"Process Mining Diagram",diagramType:"flowchart",nodes:U,edges:L,animations:G,metadata:{type:"process-mining",totalCases:g.totalCases,avgCaseDuration:g.avgCaseDuration}})},[g,r,o,a,l,S,c,f,d,m,b]),$=x.useCallback(j=>{if(!t)return;const O=parseInt(j.replace("trans-",""),10),B=g.transitions[O];B&&t(B)},[g.transitions,t]),[_,k]=x.useState({x:0,y:0,zoom:1}),T=x.useCallback(j=>{if(j){if(j.startsWith("trans-")){$(j);return}if(v(O=>O===j?null:j),e){const O=g.activities.find(B=>B.name===j);O&&e(O)}}},[g.activities,e,$]);return n.jsx("div",{className:`nice-process-mining-diagram ${u||""}`,style:{position:"relative",width:"100%",height:"100%",...p},children:n.jsx(ke,{nodes:M.nodes,edges:M.edges,groups:M.groups,viewport:_,onViewportChange:k,onSelectElement:T,showGrid:!0})})};function Oo(i,e){const t={};if(e==="circular"){const r=i.activities;r.forEach((o,a)=>{const l=a/r.length*2*Math.PI-Math.PI/2,s=200+r.length*15;t[o.name]={x:Math.cos(l)*s+400,y:Math.sin(l)*s+300}})}else{const r=Fo(i),o={};i.activities.forEach(l=>{const s=r[l.name]||0;o[s]=(o[s]||0)+1});const a={};i.activities.forEach(l=>{const s=r[l.name]||0,c=a[s]||0;a[s]=c+1;const f=o[s],d=(c-(f-1)/2)*180;t[l.name]={x:400+d,y:50+s*120}})}return t}function Fo(i){const e={},t=new Set,r=i.startActivities.map(o=>({activity:o,level:0}));for(;r.length>0;){const{activity:o,level:a}=r.shift();if(t.has(o))continue;t.add(o),e[o]=a,i.transitions.filter(s=>s.from===o).forEach(s=>{t.has(s.to)||r.push({activity:s.to,level:a+1})})}return i.activities.forEach(o=>{e[o.name]===void 0&&(e[o.name]=0)}),e}function Lo(i,e,t,r,o){if(o)return"var(--nice-danger, #ef4444)";if(r!=null&&r[i.name])return r[i.name];const a=i.frequency/t;switch(e){case"frequency":return ht("var(--nice-success, #10b981)","var(--nice-primary, #3b82f6)",a);case"duration":return i.avgDuration?ht("var(--nice-success, #10b981)","var(--nice-warning, #f59e0b)",a):"var(--nice-text-secondary, #6b7280)";case"cost":return i.avgCost?ht("var(--nice-success, #10b981)","var(--nice-danger, #ef4444)",a):"var(--nice-text-secondary, #6b7280)";default:return"var(--nice-primary, #3b82f6)"}}function ht(i,e,t){const r=f=>{const d=/#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})\b/i.exec(f);return d?{r:parseInt(d[1],16),g:parseInt(d[2],16),b:parseInt(d[3],16)}:{r:0,g:0,b:0}},o=r(i),a=r(e),l=Math.round(o.r+(a.r-o.r)*t),s=Math.round(o.g+(a.g-o.g)*t),c=Math.round(o.b+(a.b-o.b)*t);return`#${[l,s,c].map(f=>f.toString(16).padStart(2,"0")).join("")}`}function Wo(i){return i<1e3?`${i}ms`:i<6e4?`${(i/1e3).toFixed(1)}s`:i<36e5?`${(i/6e4).toFixed(1)}m`:i<864e5?`${(i/36e5).toFixed(1)}h`:`${(i/864e5).toFixed(1)}d`}function Bo(i,e){var r;const t=(r=i.variants)==null?void 0:r[0];return t?t.activities.map((o,a)=>({id:`flow-${a}`,type:"highlight",targets:[o],duration:e,delay:a*e})):[]}function Jt(i){const e=i.events.map(u=>({...u,timestamp:u.timestamp instanceof Date?u.timestamp:new Date(u.timestamp)})),t=new Map;e.forEach(u=>{t.has(u.caseId)||t.set(u.caseId,[]),t.get(u.caseId).push(u)}),t.forEach(u=>{u.sort((p,b)=>p.timestamp.getTime()-b.timestamp.getTime())});const r=new Map,o=new Map,a=new Set,l=new Set;t.forEach(u=>{if(u.length!==0){a.add(u[0].activity),l.add(u[u.length-1].activity);for(let p=0;p<u.length;p++){const b=u[p];r.has(b.activity)||r.set(b.activity,{frequency:0,durations:[],resources:new Set,costs:[]});const v=r.get(b.activity);if(v.frequency++,b.resource&&v.resources.add(b.resource),b.cost!==void 0&&v.costs.push(b.cost),p<u.length-1){const g=u[p+1],S=g.timestamp.getTime()-b.timestamp.getTime();v.durations.push(S);const M=`${b.activity}→${g.activity}`;o.has(M)||o.set(M,{frequency:0,durations:[]});const $=o.get(M);$.frequency++,$.durations.push(S)}}}});const s=Array.from(r.entries()).map(([u,p])=>({name:u,frequency:p.frequency,avgDuration:p.durations.length>0?p.durations.reduce((b,v)=>b+v,0)/p.durations.length:void 0,minDuration:p.durations.length>0?Math.min(...p.durations):void 0,maxDuration:p.durations.length>0?Math.max(...p.durations):void 0,resources:Array.from(p.resources),avgCost:p.costs.length>0?p.costs.reduce((b,v)=>b+v,0)/p.costs.length:void 0})),c=Array.from(o.entries()).map(([u,p])=>{const[b,v]=u.split("→");return{from:b,to:v,frequency:p.frequency,avgDuration:p.durations.length>0?p.durations.reduce((g,S)=>g+S,0)/p.durations.length:void 0,probability:p.frequency/t.size}}),f=new Map;t.forEach((u,p)=>{const b=u.map(g=>g.activity).join("→");f.has(b)||f.set(b,{caseIds:[],durations:[]});const v=f.get(b);if(v.caseIds.push(p),u.length>=2){const g=u[u.length-1].timestamp.getTime()-u[0].timestamp.getTime();v.durations.push(g)}});const d=Array.from(f.entries()).map(([u,p])=>({activities:u.split("→"),frequency:p.caseIds.length,avgDuration:p.durations.length>0?p.durations.reduce((b,v)=>b+v,0)/p.durations.length:0,caseIds:p.caseIds})).sort((u,p)=>p.frequency-u.frequency),m=Array.from(t.values()).filter(u=>u.length>=2).map(u=>u[u.length-1].timestamp.getTime()-u[0].timestamp.getTime()),w=m.length>0?m.reduce((u,p)=>u+p,0)/m.length:void 0;return{activities:s,transitions:c,variants:d,startActivities:Array.from(a),endActivities:Array.from(l),totalCases:t.size,avgCaseDuration:w}}const Qt={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)"},er={healthy:"var(--nice-success, #10b981)",warning:"var(--nice-warning, #f59e0b)",critical:"var(--nice-danger, #ef4444)",unknown:"var(--nice-text-secondary, #6b7280)",deprecated:"var(--nice-text-muted, #9ca3af)"},zt={import:{color:"var(--nice-primary, #3b82f6)"},runtime:{color:"var(--nice-success, #10b981)"},dev:{color:"var(--nice-text-secondary, #6b7280)",dash:"5,5"},peer:{color:"var(--nice-warning, #f59e0b)",dash:"10,5"},"api-call":{color:"var(--nice-accent, #8b5cf6)"},database:{color:"var(--nice-info, #14b8a6)"},event:{color:"var(--nice-color-accent-pink, #ec4899)",dash:"2,2"},circular:{color:"var(--nice-danger, #ef4444)"}},qo={module:"box",package:"folder",microservice:"square",library:"book",api:"plug",database:"database",external:"globe",deprecated:"warning"},Vo=({data:i,onNodeClick:e,onEdgeClick:t,visibleTypes:r,visibleEdgeTypes:o,highlightCircular:a=!0,showOnlyIssues:l=!1,layout:s="force",groupBy:c="type",nodeSizeBy:f="dependencies",colorScheme:d="type",nodeColors:m,showMetrics:w=!0,interactive:u=!0,showMinimap:p=!0,className:b,style:v})=>{const[g,S]=x.useState(null),[M,$]=x.useState(null),_=x.useMemo(()=>a?tr(i):new Set,[i,a]),k=x.useMemo(()=>{let G=i.nodes;return r&&r.length>0&&(G=G.filter(N=>r.includes(N.type))),l&&(G=G.filter(N=>{var Y;return N.status==="critical"||N.status==="warning"||((Y=N.metrics)==null?void 0:Y.issues)&&N.metrics.issues>0})),G},[i.nodes,r,l]),T=x.useMemo(()=>{const G=new Set(k.map(Y=>Y.id));let N=i.edges.filter(Y=>G.has(Y.source)&&G.has(Y.target));return o&&o.length>0&&(N=N.filter(Y=>o.includes(Y.type))),N},[i.edges,k,o]),j=x.useMemo(()=>{const G=Go(k,T,s),N=Uo(k,f),Y=[];if(c!=="none"){const E=new Map;k.forEach(X=>{const J=c==="type"?X.type:X.group||"ungrouped";E.has(J)||E.set(J,[]),E.get(J).push(X.id)});let q=0;E.forEach((X,J)=>{var re,be;const fe=c==="type"?Qt[J]||"var(--nice-text-secondary, #6b7280)":((be=(re=i.groups)==null?void 0:re.find(W=>W.id===J))==null?void 0:be.color)||Ke[q%Ke.length];Y.push({id:`group-${J}`,label:J,nodeIds:X,style:{fill:`${fe}10`,stroke:fe,strokeWidth:1}}),q++})}const P=k.map(E=>{const q=G[E.id]||{x:0,y:0},X=g===E.id,J=M===E.id,fe=_.has(E.id),re=Ho(E,f,N),be=Xo(E,d,m,fe);return{id:E.id,label:E.name,x:q.x,y:q.y,width:re.width,height:re.height,shape:Ko(E.type),style:{fill:X||J?be:"var(--nice-bg, #fff)",stroke:be,strokeWidth:fe?4:X?3:2,fontColor:X||J?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:8,strokeDasharray:E.status==="deprecated"?"4,4":void 0},data:{type:"dependency",node:E,icon:qo[E.type],isCircular:fe,statusColor:er[E.status||"unknown"]}}}),V=T.map((E,q)=>{const X=E.type==="circular"||_.has(E.source)&&_.has(E.target),J=zt[E.type]||zt.import;return{id:E.id||`edge-${q}`,source:E.source,target:E.target,label:E.optional?"(optional)":void 0,style:{stroke:X?"var(--nice-danger, #ef4444)":J.color,strokeWidth:Math.max(1,Math.min(4,E.weight||1)),strokeDasharray:J.dash,arrowHead:"triangle",lineType:"curved",opacity:E.optional?.5:1},data:{type:E.type,edge:E,isCircular:X}}});return Ae({id:"dependency-graph",title:"Dependency Graph",diagramType:"custom",nodes:P,edges:V,groups:Y,metadata:{type:"dependency-graph",...i.metadata}})},[k,T,s,c,i.groups,f,d,m,_,g,M]),O=x.useCallback(G=>{$(G)},[]),[B,U]=x.useState({x:0,y:0,zoom:1}),L=x.useCallback(G=>{if(G){if(S(N=>N===G?null:G),e){const N=i.nodes.find(Y=>Y.id===G);N&&e(N)}if(t){const N=i.edges.find(Y=>Y.id===G);N&&t(N)}}},[i.nodes,i.edges,e,t]);return n.jsx("div",{className:`nice-dependency-graph ${b||""}`,style:{position:"relative",width:"100%",height:"100%",...v},children:n.jsx(ke,{nodes:j.nodes,edges:j.edges,groups:j.groups,viewport:B,onViewportChange:U,onSelectElement:L,onNodeHover:O,interactive:u,showGrid:!0})})},Ke=["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 tr(i){const e=new Set,t=new Map;i.nodes.forEach(l=>t.set(l.id,[])),i.edges.forEach(l=>{var s;(s=t.get(l.source))==null||s.push(l.target)});const r=new Set,o=new Set,a=(l,s)=>{r.add(l),o.add(l),s.push(l);const c=t.get(l)||[];for(const f of c)if(r.has(f)){if(o.has(f)){const d=s.indexOf(f);s.slice(d).forEach(w=>e.add(w))}}else if(a(f,[...s]))return!0;return o.delete(l),!1};return i.nodes.forEach(l=>{r.has(l.id)||a(l.id,[])}),e}function Go(i,e,t){const r={};switch(t){case"circular":{i.forEach((o,a)=>{const l=a/i.length*2*Math.PI-Math.PI/2,s=150+i.length*12;r[o.id]={x:Math.cos(l)*s+400,y:Math.sin(l)*s+300}});break}case"grid":{const o=Math.ceil(Math.sqrt(i.length));i.forEach((a,l)=>{r[a.id]={x:l%o*200+100,y:Math.floor(l/o)*150+100}});break}case"hierarchical":{const o=Yo(i,e),a={},l={};i.forEach(s=>{const c=o[s.id]||0;a[c]=(a[c]||0)+1}),i.forEach(s=>{const c=o[s.id]||0,f=l[c]||0;l[c]=f+1;const d=a[c],m=(f-(d-1)/2)*200;r[s.id]={x:400+m,y:80+c*130}});break}default:{i.forEach((o,a)=>{const l=a/i.length*2*Math.PI,s=200+i.length*10;r[o.id]={x:Math.cos(l)*s+400,y:Math.sin(l)*s+300}});for(let o=0;o<50;o++){const a={};i.forEach(l=>a[l.id]={x:0,y:0});for(let l=0;l<i.length;l++)for(let s=l+1;s<i.length;s++){const c=i[l].id,f=i[s].id,d=r[f].x-r[c].x,m=r[f].y-r[c].y,w=Math.max(1,Math.sqrt(d*d+m*m)),u=5e3/(w*w);a[c].x-=d/w*u,a[c].y-=m/w*u,a[f].x+=d/w*u,a[f].y+=m/w*u}e.forEach(l=>{const s=r[l.target].x-r[l.source].x,c=r[l.target].y-r[l.source].y,f=Math.sqrt(s*s+c*c),d=f*.01;a[l.source].x+=s/f*d,a[l.source].y+=c/f*d,a[l.target].x-=s/f*d,a[l.target].y-=c/f*d}),i.forEach(l=>{r[l.id].x+=Math.max(-10,Math.min(10,a[l.id].x)),r[l.id].y+=Math.max(-10,Math.min(10,a[l.id].y))})}break}}return r}function Yo(i,e){const t={},r={};i.forEach(a=>{t[a.id]=0,r[a.id]=0}),e.forEach(a=>{r[a.target]=(r[a.target]||0)+1});const o=i.filter(a=>r[a.id]===0).map(a=>a.id);for(;o.length>0;){const a=o.shift();e.filter(s=>s.source===a).forEach(s=>{t[s.target]=Math.max(t[s.target],t[a]+1),r[s.target]--,r[s.target]===0&&o.push(s.target)})}return t}function Uo(i,e){const t=i.map(r=>{var o,a,l;switch(e){case"dependencies":return((o=r.metrics)==null?void 0:o.dependencies)||0;case"dependents":return((a=r.metrics)==null?void 0:a.dependents)||0;case"complexity":return((l=r.metrics)==null?void 0:l.complexity)||0;case"size":return r.size||0;default:return 1}});return{min:Math.min(...t,0),max:Math.max(...t,1)}}function Ho(i,e,t){var c,f,d;if(e==="fixed")return{width:140,height:70};let r;switch(e){case"dependencies":r=((c=i.metrics)==null?void 0:c.dependencies)||0;break;case"dependents":r=((f=i.metrics)==null?void 0:f.dependents)||0;break;case"complexity":r=((d=i.metrics)==null?void 0:d.complexity)||0;break;case"size":r=i.size||0;break;default:r=1}const o=t.max>t.min?(r-t.min)/(t.max-t.min):.5,a=100,s=a+o*(180-a);return{width:s,height:s*.5}}function Xo(i,e,t,r){if(r)return"var(--nice-danger, #ef4444)";if(t!=null&&t[i.id])return t[i.id];switch(e){case"status":return er[i.status||"unknown"];case"group":return Ke[Zo(i.group||"")%Ke.length];default:return Qt[i.type]||"var(--nice-text-secondary, #6b7280)"}}function Ko(i){switch(i){case"database":return"cylinder";case"microservice":return"hexagon";case"api":return"diamond";case"external":return"cloud";default:return"rectangle"}}function Zo(i){let e=0;for(let t=0;t<i.length;t++)e=(e<<5)-e+i.charCodeAt(t),e|=0;return Math.abs(e)}function Jo(i){const e=[{id:i.name,name:i.name,version:i.version,type:"package",status:"healthy"}],t=[];let r=0;const o=(a,l)=>{a&&Object.entries(a).forEach(([s,c])=>{e.find(f=>f.id===s)||e.push({id:s,name:s,version:c.replace(/[\^~>=<]/g,""),type:"library",status:"unknown"}),t.push({id:`edge-${r++}`,source:i.name,target:s,type:l})})};return o(i.dependencies,"runtime"),o(i.devDependencies,"dev"),o(i.peerDependencies,"peer"),e.forEach(a=>{a.metrics={dependencies:t.filter(l=>l.source===a.id).length,dependents:t.filter(l=>l.target===a.id).length}}),{nodes:e,edges:t}}function Qo(i){const e=new Map,t=new Map;i.nodes.forEach(d=>{e.set(d.id,0),t.set(d.id,0)}),i.edges.forEach(d=>{e.set(d.target,(e.get(d.target)||0)+1),t.set(d.source,(t.get(d.source)||0)+1)}),tr(i);let r=null,o=0;i.nodes.forEach(d=>{const m=e.get(d.id)||0;m>o&&(o=m,r=d)});let a=null,l=0;i.nodes.forEach(d=>{const m=t.get(d.id)||0;m>l&&(l=m,a=d)});const s=i.nodes.filter(d=>(e.get(d.id)||0)===0&&(t.get(d.id)||0)===0),c=Array.from(t.values()).reduce((d,m)=>d+m,0),f=i.nodes.length>0?c/i.nodes.length:0;return{totalNodes:i.nodes.length,totalEdges:i.edges.length,circularDependencies:[],mostDependent:r,mostDependencies:a,orphanNodes:s,avgDependencies:Math.round(f*10)/10}}const ea={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)"},ta={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"},ra={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)"},ia=({data:i,onDeviceClick:e,onConnectionClick:t,onRefresh:r,autoRefreshInterval:o=0,visibleDeviceTypes:a,showOnlyIssues:l=!1,layout:s="hierarchical",groupBy:c="group",showMetrics:f=!0,showBandwidth:d=!0,showLatency:m=!1,animateTraffic:w=!1,statusColors:u=ea,showMinimap:p=!0,className:b,style:v})=>{const[g,S]=x.useState(null),[M,$]=x.useState(new Date);x.useEffect(()=>{if(o<=0||!r)return;const U=setInterval(()=>{r(),$(new Date)},o);return()=>clearInterval(U)},[o,r]);const _=x.useMemo(()=>{let U=i.devices;return a&&a.length>0&&(U=U.filter(L=>a.includes(L.type))),l&&(U=U.filter(L=>L.status==="critical"||L.status==="warning"||L.status==="offline")),U},[i.devices,a,l]),k=x.useMemo(()=>{const U=new Set(_.map(L=>L.id));return i.connections.filter(L=>U.has(L.source)&&U.has(L.target))},[i.connections,_]),T=x.useMemo(()=>{const U=oa(_,k,s,i.groups),L=[];if(c!=="none"){const P=new Map;_.forEach(E=>{let q;switch(c){case"type":q=E.type;break;case"location":q=E.location||"Unknown Location";break;default:q=E.group||"ungrouped"}P.has(q)||P.set(q,[]),P.get(q).push(E.id)});let V=0;P.forEach((E,q)=>{var fe;const X=(fe=i.groups)==null?void 0:fe.find(re=>re.id===q||re.name===q),J=(X==null?void 0:X.color)||It[V%It.length];L.push({id:`group-${q}`,label:(X==null?void 0:X.name)||q,nodeIds:E,style:{fill:`${J}15`,stroke:J,strokeWidth:2}}),V++})}const G=_.map(P=>{const V=U[P.id]||{x:0,y:0},E=g===P.id,q=u[P.status],X=ta[P.type];return{id:P.id,label:P.name,x:V.x,y:V.y,width:120,height:f?90:70,shape:aa(P.type),style:{fill:E?q:"var(--nice-bg, #fff)",stroke:q,strokeWidth:E?3:2,fontColor:E?"var(--nice-color-white, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:8},data:{type:"network-device",device:P,icon:X,statusColor:q}}}),N=k.map((P,V)=>{const E=ra[P.type]||"var(--nice-text-secondary, #6b7280)",q=P.status==="active",X=P.status==="degraded"||P.status==="error",J=[];if(d&&P.bandwidth){const fe=Math.round(P.bandwidth.used/P.bandwidth.total*100);J.push(`${fe}%`)}return m&&P.latency!==void 0&&J.push(`${P.latency}ms`),{id:P.id||`conn-${V}`,source:P.source,target:P.target,sourcePort:P.sourcePort,targetPort:P.targetPort,label:J.join(" | ")||void 0,style:{stroke:X?"var(--nice-danger, #ef4444)":E,strokeWidth:Math.max(1,Math.min(6,(P.speed||1e3)/1e3)),strokeDasharray:q?void 0:"5,5",arrowHead:"none",lineType:P.type==="wireless"?"curved":"orthogonal",opacity:P.status==="inactive"?.3:1},data:{type:P.type,connection:P,isActive:q,isDegraded:X}}}),Y=w?na(k):[];return Ae({id:"network-topology",title:"Network Topology",diagramType:"networkTopology",nodes:G,edges:N,groups:L,animations:Y,metadata:{type:"network-topology",lastRefresh:M.toISOString(),...i.metadata}})},[_,k,s,c,i.groups,f,d,m,w,u,g,M]),[j,O]=x.useState({x:0,y:0,zoom:1}),B=x.useCallback(U=>{if(!U)return;const L=i.connections.find(G=>G.id===U);if(L){t==null||t(L);return}if(S(G=>G===U?null:U),e){const G=i.devices.find(N=>N.id===U);G&&e(G)}},[i.devices,i.connections,e,t]);return n.jsx("div",{className:`nice-network-topology ${b||""}`,style:{position:"relative",width:"100%",height:"100%",...v},children:n.jsx(ke,{nodes:T.nodes,edges:T.edges,groups:T.groups,viewport:j,onViewportChange:O,onSelectElement:B,showGrid:!0})})},It=["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 oa(i,e,t,r){var a;const o={};switch(t){case"star":{const l=new Map;i.forEach(d=>l.set(d.id,0)),e.forEach(d=>{l.set(d.source,(l.get(d.source)||0)+1),l.set(d.target,(l.get(d.target)||0)+1)});let s=(a=i[0])==null?void 0:a.id,c=0;l.forEach((d,m)=>{d>c&&(c=d,s=m)}),o[s]={x:400,y:300};const f=i.filter(d=>d.id!==s);f.forEach((d,m)=>{const w=m/f.length*2*Math.PI-Math.PI/2,u=200;o[d.id]={x:Math.cos(w)*u+400,y:Math.sin(w)*u+300}});break}case"mesh":{const l=Math.ceil(Math.sqrt(i.length));i.forEach((s,c)=>{o[s.id]={x:c%l*150+100,y:Math.floor(c/l)*130+100}});break}case"tree":{const l=i.filter(w=>w.type==="internet"||w.type==="cloud"||w.type==="router"),s=new Map,c=l.map(w=>w.id);c.forEach(w=>s.set(w,0));const f=new Set(c);for(;c.length>0;){const w=c.shift(),u=s.get(w)||0;e.forEach(p=>{let b=null;p.source===w&&!f.has(p.target)&&(b=p.target),p.target===w&&!f.has(p.source)&&(b=p.source),b&&(f.add(b),s.set(b,u+1),c.push(b))})}const d={},m={};i.forEach(w=>{const u=s.get(w.id)||0;d[u]=(d[u]||0)+1}),i.forEach(w=>{const u=s.get(w.id)||0,p=m[u]||0;m[u]=p+1;const b=d[u],v=(p-(b-1)/2)*160;o[w.id]={x:400+v,y:80+u*120}});break}case"hierarchical":default:{const l=["internet","cloud","router","firewall","loadbalancer","switch","server","storage","workstation","laptop","phone","printer","camera","iot","unknown"],s=new Map;i.forEach(f=>{s.has(f.type)||s.set(f.type,[]),s.get(f.type).push(f)});let c=50;l.forEach(f=>{const d=s.get(f);!d||d.length===0||(d.forEach((m,w)=>{const u=(w-(d.length-1)/2)*150;o[m.id]={x:400+u,y:c}}),c+=130)});break}}return o}function aa(i){switch(i){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 na(i){return i.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 sa(i={}){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 la(i){const e=i.devices.filter(m=>m.status==="online").length,t=i.devices.filter(m=>m.status==="offline").length,r=i.devices.filter(m=>m.status==="warning").length,o=i.devices.filter(m=>m.status==="critical").length,a=i.connections.filter(m=>m.status==="active").length,l=i.connections.filter(m=>m.status==="degraded"||m.status==="error").length,s=i.devices.length>0?e/i.devices.length*100:0,c=i.connections.length>0?a/i.connections.length*100:0,f=o*10+r*5+l*5;return{score:Math.max(0,Math.min(100,Math.round(s*.5+c*.5-f))),onlineDevices:e,offlineDevices:t,warningDevices:r,criticalDevices:o,activeConnections:a,degradedConnections:l}}const ca=[{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"}],da={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)"},ua=({data:i,onChange:e,onNodeClick:t,editable:r=!1,showMetrics:o=!0,showProbabilities:a=!0,showSamples:l=!0,highlightPath:s,colorScheme:c="outcome",nodeColors:f,orientation:d="vertical",spacing:m={horizontal:180,vertical:120},showMinimap:w=!0,className:u,style:p,tutorial:b})=>{const[v,g]=x.useState(null),[S,M]=x.useState(new Set),$=x.useMemo(()=>s?ga(i.root,s):new Set,[i.root,s]),{nodes:_,edges:k}=x.useMemo(()=>fa(i.root,i.edges),[i.root,i.edges]),T=x.useMemo(()=>pa(_),[_]),j=x.useMemo(()=>{var Y,P;const L=ha(i.root,d,m),G=_.map(V=>{const E=L[V.id]||{x:0,y:0},q=v===V.id,X=$.has(V.id),J=V.type==="leaf"||V.type==="end",fe=ma(V,c,f,T),re=J?120:160,be=o?80:J?60:70;return{id:V.id,label:V.label,x:E.x,y:E.y,width:re,height:be,shape:J?"roundedRect":"diamond",style:{fill:q||X?fe:"var(--nice-bg, #fff)",stroke:fe,strokeWidth:X?4:q?3:2,fontColor:q||X?"var(--nice-text-primary, #fff)":"var(--nice-text, #1f2937)",fontSize:11,borderRadius:J?8:0},data:{type:"decision-tree-node",node:V,isLeaf:J,isHighlighted:X}}}),N=k.map((V,E)=>{const q=$.has(V.source)&&$.has(V.target);let X=V.label||"";return a&&V.probability!==void 0&&(X+=X?` (${(V.probability*100).toFixed(0)}%)`:`${(V.probability*100).toFixed(0)}%`),{id:V.id||`edge-${E}`,source:V.source,target:V.target,label:X||void 0,style:{stroke:q?"var(--nice-primary, #3b82f6)":"var(--nice-text-muted, #9ca3af)",strokeWidth:q?3:2,arrowHead:"triangle",lineType:d==="vertical"?"orthogonal":"curved"},data:{type:"decision-edge",edge:V,isHighlighted:q}}});return Ae({id:"decision-tree",title:"Decision Tree",diagramType:"decisionTree",nodes:G,edges:N,animations:s?ya(Array.from($)):[],metadata:{type:"decision-tree",algorithm:(Y=i.metadata)==null?void 0:Y.algorithm,accuracy:(P=i.metadata)==null?void 0:P.accuracy}})},[_,k,d,m,o,a,c,f,T,v,$,s,i.metadata]),[O,B]=x.useState({x:0,y:0,zoom:1}),U=x.useCallback(L=>{if(!L)return;g(N=>N===L?null:L);const G=_.find(N=>N.id===L);G&&G.type!=="leaf"&&G.type!=="end"&&M(N=>{const Y=new Set(N);return Y.has(L)?Y.delete(L):Y.add(L),Y}),t&&G&&t(G)},[_,t]);return n.jsxs("div",{className:`nice-decision-tree-editor ${u||""}`,style:{position:"relative",width:"100%",height:"100%",...p},children:[n.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:n.jsx(y.NiceTutorialButton,{steps:y.resolveTutorial(b,ca)})}),n.jsx(ke,{nodes:j.nodes,edges:j.edges,groups:j.groups,viewport:O,onViewportChange:B,onSelectElement:U,interactive:!0,showGrid:!1})]})};function fa(i,e){const t=[],r=e?[...e]:[],o=new Set(r.map(l=>`${l.source}-${l.target}`)),a=(l,s)=>{t.push(l),s&&!o.has(`${s}-${l.id}`)&&r.push({id:`e-${s}-${l.id}`,source:s,target:l.id}),l.children&&l.children.forEach((c,f)=>{let d="";l.condition&&(d=f===0?"Yes":"No");const m=`${l.id}-${c.id}`;o.has(m)||(r.push({id:`e-${m}`,source:l.id,target:c.id,label:d,branch:f===0?"yes":"no"}),o.add(m)),a(c,l.id)})};return a(i),{nodes:t,edges:r}}function ha(i,e,t){const r={},o=s=>!s.children||s.children.length===0?1:s.children.reduce((c,f)=>c+o(f),0),a=(s,c,f,d)=>{const m=f+d*t.horizontal/2,w=c*t.vertical+50;if(r[s.id]=e==="vertical"?{x:m,y:w}:{x:w,y:m},s.children){let u=f;s.children.forEach(p=>{const b=o(p);a(p,c+1,u,b),u+=b*t.horizontal})}},l=o(i);return a(i,0,0,l),r}function pa(i){const e=i.filter(r=>{var o;return((o=r.metrics)==null?void 0:o.impurity)!==void 0}).map(r=>r.metrics.impurity),t=i.filter(r=>{var o;return((o=r.metrics)==null?void 0:o.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 ma(i,e,t,r){var o,a,l;if(t!=null&&t[i.id])return t[i.id];switch(e){case"impurity":if(((o=i.metrics)==null?void 0:o.impurity)!==void 0&&r){const s=(i.metrics.impurity-r.impurity.min)/(r.impurity.max-r.impurity.min||1);return At("var(--nice-success, #10b981)","var(--nice-danger, #ef4444)",s)}break;case"samples":if(((a=i.metrics)==null?void 0:a.samples)!==void 0&&r){const s=(i.metrics.samples-r.samples.min)/(r.samples.max-r.samples.min||1);return At("var(--nice-warning-bg, #fef3c7)","var(--nice-warning, #f59e0b)",s)}break;case"outcome":if(i.type==="leaf"&&((l=i.outcome)!=null&&l.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)"}[i.outcome.class.toLowerCase()]||"var(--nice-primary, #3b82f6)";break}return da[i.type]||"var(--nice-text-secondary, #6b7280)"}function At(i,e,t){const r=f=>{var m;const d=((m=/#([a-f\d]{6})\b/i.exec(f))==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)}},o=r(i),a=r(e),l=Math.round(o.r+(a.r-o.r)*t),s=Math.round(o.g+(a.g-o.g)*t),c=Math.round(o.b+(a.b-o.b)*t);return`#${[l,s,c].map(f=>f.toString(16).padStart(2,"0")).join("")}`}function ga(i,e){const t=new Set,r=o=>{if(t.add(o.id),o.type==="leaf"||o.type==="end"||!o.children)return!0;if(o.condition){const a=e[o.condition.feature],s=rr(a,o.condition.operator,o.condition.value)?0:1;if(o.children[s])return r(o.children[s])}return o.children[0]?r(o.children[0]):!0};return r(i),t}function rr(i,e,t){switch(e){case"=":return i===t;case"!=":return i!==t;case"<":return Number(i)<Number(t);case"<=":return Number(i)<=Number(t);case">":return Number(i)>Number(t);case">=":return Number(i)>=Number(t);case"in":return Array.isArray(t)&&t.includes(i);case"not_in":return Array.isArray(t)&&!t.includes(i);case"contains":return String(i).includes(String(t));default:return!1}}function ya(i){return i.map((e,t)=>({id:`path-${t}`,type:"highlight",targets:[e],duration:500,delay:t*300}))}function ba(i){const{tree:e,feature_names:t,class_names:r}=i;e.children_left.length;const o=l=>{const s=e.children_left[l]===-1,c=e.n_node_samples[l],f=e.impurity[l],d=e.value[l];if(s){const v=Array.isArray(d)?d:[d],g=Array.isArray(v[0])?v[0]:v,S=g.indexOf(Math.max(...g)),M=(r==null?void 0:r[S])||`Class ${S}`,$=g.reduce((k,T)=>k+T,0),_=$>0?g[S]/$:0;return{id:`node-${l}`,type:"leaf",label:M,outcome:{value:M,class:M,probability:_,samples:c},metrics:{samples:c,impurity:f}}}const m=e.feature[l],w=e.threshold[l],u=t[m]||`feature_${m}`,p=o(e.children_left[l]),b=o(e.children_right[l]);return{id:`node-${l}`,type:l===0?"root":"decision",label:`${u} <= ${w.toFixed(2)}`,condition:{feature:u,operator:"<=",value:w},children:[p,b],metrics:{samples:c,impurity:f,giniIndex:f}}},a=o(0);return{root:a,features:t,classes:r,metadata:{algorithm:"sklearn.DecisionTreeClassifier",maxDepth:ir(a)}}}function ir(i,e=0){return!i.children||i.children.length===0?e:Math.max(...i.children.map(t=>ir(t,e+1)))}function xa(i){const e=(r,o)=>typeof r=="string"?{id:o,type:"leaf",label:r,outcome:{value:r}}:{...r,id:o};return{root:{id:"root",type:"root",label:i.question,condition:{feature:i.feature,operator:typeof i.threshold=="number"?"<=":"=",value:i.threshold},children:[e(i.yesOutcome,"yes-outcome"),e(i.noOutcome,"no-outcome")]}}}function va(i,e){const t=[],r=a=>{var l,s;if(t.push(a.id),a.type==="leaf"||a.type==="end"||!a.children)return{value:((l=a.outcome)==null?void 0:l.value)??a.label,probability:(s=a.outcome)==null?void 0:s.probability};if(a.condition){const c=e[a.condition.feature],d=rr(c,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}},o=r(i.root);return{prediction:o.value,probability:o.probability,path:t}}let wa=0;function vt(){return`tmpl-${++wa}-${Date.now().toString(36)}`}function ie(i,e,t="roundedRect",r={width:160,height:60},o){return{id:vt(),label:i,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:o}}function ae(i,e,t="bottom",r="top",o){return{id:vt(),sourceNodeId:i.id,sourcePortId:t,targetNodeId:e.id,targetPortId:r,label:o,style:{lineType:"bezier",targetArrow:"arrow"}}}function Pe(i,e,t,r){const o=new Date().toISOString();return{version:"1.0",id:vt(),title:i,diagramType:e,nodes:t,edges:r,groups:[],animations:[],viewport:{x:0,y:0,zoom:1},metadata:{createdAt:o,updatedAt:o}}}function ka(){const i=ie("Commit",{x:40,y:200},"circle",{width:80,height:80}),e=ie("Build",{x:200,y:200},"roundedRect"),t=ie("Test",{x:420,y:200},"roundedRect"),r=ie("Deploy",{x:640,y:200},"roundedRect"),o=ie("Production",{x:860,y:200},"hexagon",{width:140,height:80});return Pe("CI/CD Pipeline","flowchart",[i,e,t,r,o],[ae(i,e,"right","left"),ae(e,t,"right","left"),ae(t,r,"right","left"),ae(r,o,"right","left")])}function Ca(){const i=ie("API Gateway",{x:350,y:40},"hexagon",{width:160,height:80}),e=ie("Auth Service",{x:80,y:200},"roundedRect"),t=ie("User Service",{x:300,y:200},"roundedRect"),r=ie("Order Service",{x:520,y:200},"roundedRect"),o=ie("Notification",{x:740,y:200},"roundedRect"),a=ie("Users DB",{x:180,y:380},"cylinder",{width:120,height:70}),l=ie("Orders DB",{x:520,y:380},"cylinder",{width:120,height:70}),s=ie("Message Queue",{x:620,y:380},"parallelogram",{width:160,height:60}),c=[i,e,t,r,o,a,l,s],f=[ae(i,e,"bottom","top"),ae(i,t,"bottom","top"),ae(i,r,"bottom","top"),ae(r,o,"right","left"),ae(t,a,"bottom","top"),ae(r,l,"bottom","top"),ae(o,s,"bottom","top")];return Pe("Microservices Architecture","flowchart",c,f)}function _a(){const i=ie("Start",{x:350,y:20},"circle",{width:70,height:70}),e=ie("Landing Page",{x:310,y:140},"roundedRect"),t=ie("Sign Up",{x:140,y:280},"roundedRect"),r=ie("Log In",{x:480,y:280},"roundedRect"),o=ie("Dashboard",{x:310,y:420},"roundedRect"),a=ie("End",{x:350,y:560},"circle",{width:70,height:70});return Pe("User Flow","flowchart",[i,e,t,r,o,a],[ae(i,e,"bottom","top"),ae(e,t,"bottom","top","New user"),ae(e,r,"bottom","top","Returning"),ae(t,o,"bottom","top"),ae(r,o,"bottom","top"),ae(o,a,"bottom","top")])}function Na(){const i=ie("Users",{x:80,y:100},"rectangle",{width:180,height:100}),e=ie("Orders",{x:380,y:100},"rectangle",{width:180,height:100}),t=ie("Products",{x:380,y:320},"rectangle",{width:180,height:100}),r=ie("Categories",{x:680,y:320},"rectangle",{width:180,height:100});return Pe("Entity Relationship","er",[i,e,t,r],[ae(i,e,"right","left","1:N"),ae(e,t,"bottom","top","N:M"),ae(t,r,"right","left","N:1")])}function Ma(){const i=ie("CEO",{x:350,y:40},"roundedRect"),e=ie("CTO",{x:150,y:180},"roundedRect"),t=ie("CFO",{x:550,y:180},"roundedRect"),r=ie("Engineering",{x:50,y:320},"roundedRect"),o=ie("DevOps",{x:250,y:320},"roundedRect"),a=ie("Accounting",{x:550,y:320},"roundedRect");return Pe("Organization Chart","orgchart",[i,e,t,r,o,a],[ae(i,e,"bottom","top"),ae(i,t,"bottom","top"),ae(e,r,"bottom","top"),ae(e,o,"bottom","top"),ae(t,a,"bottom","top")])}function Sa(){const i=ie("Idle",{x:80,y:200},"circle",{width:90,height:90}),e=ie("Loading",{x:300,y:80},"roundedRect"),t=ie("Success",{x:520,y:80},"roundedRect"),r=ie("Error",{x:520,y:320},"roundedRect"),o=ie("Retry",{x:300,y:320},"diamond",{width:100,height:100});return Pe("State Machine","stateMachine",[i,e,t,r,o],[ae(i,e,"right","left","fetch"),ae(e,t,"right","left","ok"),ae(e,r,"bottom","top","fail"),ae(r,o,"left","right"),ae(o,e,"top","bottom","retry"),ae(o,i,"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:ka},{id:"microservices",name:"Microservices Architecture",description:"Microservices with API gateway, databases, and message queue",category:"software",diagramType:"flowchart",tags:["architecture","microservices","api","backend"],create:Ca},{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:_a},{id:"er-diagram",name:"Entity Relationship",description:"Database ER diagram with tables and relations",category:"software",diagramType:"er",tags:["database","er","schema","sql"],create:Na},{id:"org-chart",name:"Organization Chart",description:"Company organizational hierarchy",category:"business",diagramType:"orgchart",tags:["org","hierarchy","team","management"],create:Ma},{id:"state-machine",name:"State Machine",description:"Finite state machine with transitions",category:"software",diagramType:"stateMachine",tags:["state","fsm","transitions","machine"],create:Sa}];function za(i){return it.find(e=>e.id===i)}function Ia(i){return it.filter(e=>e.category===i)}function Aa(i){const e=i.toLowerCase();return it.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.tags.some(r=>r.includes(e)))}class or{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"}],o={id:ja(),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(o),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(),o}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(o=>o.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),o=this.getVersion(t);if(!r||!o)return null;const a=JSON.parse(r.snapshot),l=JSON.parse(o.snapshot),s=this.calculateChanges(a,l),c={nodesAdded:s.filter(f=>f.type==="node-added").length,nodesRemoved:s.filter(f=>f.type==="node-removed").length,nodesMoved:s.filter(f=>f.type==="node-moved").length,nodesRestyled:s.filter(f=>f.type==="node-restyled").length,edgesAdded:s.filter(f=>f.type==="edge-added").length,edgesRemoved:s.filter(f=>f.type==="edge-removed").length,edgesRestyled:s.filter(f=>f.type==="edge-restyled").length,groupsModified:s.filter(f=>f.type.startsWith("group-")).length,totalChanges:s.length};return{fromVersionId:e,toVersionId:t,changes:s,summary:c}}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 o=new Set(e.nodes.map(d=>d.id)),a=new Set(t.nodes.map(d=>d.id));for(const d of t.nodes)o.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 l=new Set(e.edges.map(d=>d.id)),s=new Set(t.edges.map(d=>d.id));for(const d of t.edges)l.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)s.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 c=new Set(e.groups.map(d=>d.id)),f=new Set(t.groups.map(d=>d.id));for(const d of t.groups)c.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)f.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 ja(){return`v_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}function Da(i){const e=new or(i);return{manager:e,saveVersion:e.saveVersion.bind(e),getVersions:e.getVersions.bind(e),restoreToVersion:e.restoreToVersion.bind(e),diff:e.diff.bind(e)}}class $a{constructor(e){this.comments=new Map,this.listeners=new Set,this.mentionListeners=new Set,this.config=e}addComment(e,t,r){const o=this.parseMentions(t),a={id:Ta(),anchor:e,status:"open",authorId:this.config.userId,authorName:this.config.userName,authorAvatar:this.config.userAvatar,text:t,mentions:o,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(),o.forEach(l=>this.notifyMention(a,l.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 o=this.parseMentions(t),a={id:Pa(),authorId:this.config.userId,authorName:this.config.userName,authorAvatar:this.config.userAvatar,text:t,mentions:o,createdAt:new Date().toISOString()};return r.replies.push(a),this.notify(),o.forEach(l=>this.notifyMention(r,l.userId)),a}editReply(e,t,r){const o=this.comments.get(e);if(!o)return null;const a=o.replies.find(l=>l.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 o=r.replies.find(a=>a.id===t);return o?(o.deleted=!0,o.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),o=t.replies.some(a=>a.mentions.some(l=>l.userId===e));return r||o})}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(o=>o.userId===e.mentionedUserId)||t.replies.some(o=>o.mentions.some(a=>a.userId===e.mentionedUserId))))})}parseMentions(e){var a;const t=[],r=/@(\w+)/g;let o;for(;(o=r.exec(e))!==null;){const l=o[1],s=(a=this.config.availableUsers)==null?void 0:a.find(c=>c.name.toLowerCase()===l.toLowerCase()||c.id===l);s&&t.push({userId:s.id,userName:s.name,startIndex:o.index,endIndex:o.index+o[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 Ta(){return`comment_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}function Pa(){return`reply_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}const Ea={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 Ra(i){const e=new Date(i),r=new Date().getTime()-e.getTime(),o=Math.floor(r/(1e3*60)),a=Math.floor(o/60),l=Math.floor(a/24);return o<1?"just now":o<60?`${o}m ago`:a<24?`${a}h ago`:l<7?`${l}d ago`:e.toLocaleDateString()}function Oa(i,e){if(e.length===0)return i;const t=[...e].sort((o,a)=>a.startIndex-o.startIndex);let r=i;for(const o of t){const a=r.slice(0,o.startIndex),l=r.slice(o.endIndex);r=`${a}<span class="mention" data-user-id="${o.userId}">@${o.userName}</span>${l}`}return r}class ar{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(o=>o.id!==e.id),r.rules.push(e),r.rules.sort((o,a)=>o.priority-a.priority),this.invalidateCache(),this.notify())}removeRule(e,t="default"){const r=this.profiles.get(t);r&&(r.rules=r.rules.filter(o=>o.id!==e),this.invalidateCache(),this.notify())}updateRule(e,t,r="default"){const o=this.profiles.get(r);if(!o)return;const a=o.rules.find(l=>l.id===e);a&&(Object.assign(a,t),o.rules.sort((l,s)=>l.priority-s.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 o=this.getActiveProfile();if(!(o!=null&&o.enabled))return this.emptyStyles(e.id);const a=o.rules.filter(s=>s.enabled&&(s.target==="node"||s.target==="both")&&(!s.elementShapes||s.elementShapes.includes(e.shape))),l=this.processRules(e.id,a,e);return this.cache.set(t,l),l}applyToEdge(e){const t=`edge_${e.id}_${JSON.stringify(e.data)}`,r=this.cache.get(t);if(r)return r;const o=this.getActiveProfile();if(!(o!=null&&o.enabled))return this.emptyStyles(e.id);const a=o.rules.filter(s=>s.enabled&&(s.target==="edge"||s.target==="both")),l=this.processRules(e.id,a,e);return this.cache.set(t,l),l}applyToAll(e,t){const r=new Map;for(const o of e)r.set(o.id,this.applyToNode(o));for(const o of t)r.set(o.id,this.applyToEdge(o));return r}processRules(e,t,r){const o={elementId:e,matchedRules:[],styleOverrides:{},addedClasses:[]};for(const a of t)if(this.evaluateCondition(a.condition,r)&&(o.matchedRules.push(a.id),this.applyActions(a.actions,o),a.stopProcessing))break;return o}evaluateCondition(e,t){if("logic"in e)return e.logic==="and"?e.conditions.every(o=>this.evaluateCondition(o,t)):e.conditions.some(o=>this.evaluateCondition(o,t));const r=this.getPropertyValue(t,e.property);return this.compareValues(r,e)}getPropertyValue(e,t){const r=t.split(".");let o=e;for(const a of r){if(o==null)return;o=o[a]}return o}compareValues(e,t){const{operator:r,value:o,valueTo:a,caseInsensitive:l}=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 s=l&&typeof e=="string"?e.toLowerCase():e,c=l&&typeof o=="string"?o.toLowerCase():o;switch(r){case"equals":return s===c;case"not_equals":return s!==c;case"greater_than":return e>o;case"greater_than_or_equals":return e>=o;case"less_than":return e<o;case"less_than_or_equals":return e<=o;case"contains":return typeof s=="string"&&typeof c=="string"?s.includes(c):Array.isArray(e)?e.includes(o):!1;case"not_contains":return typeof s=="string"&&typeof c=="string"?!s.includes(c):Array.isArray(e)?!e.includes(o):!0;case"starts_with":return typeof s=="string"&&typeof c=="string"&&s.startsWith(c);case"ends_with":return typeof s=="string"&&typeof c=="string"&&s.endsWith(c);case"regex":if(typeof e!="string"||typeof o!="string")return!1;try{const f=l?"i":"";return new RegExp(o,f).test(e)}catch{return!1}case"in":return Array.isArray(o)&&o.includes(e);case"not_in":return!Array.isArray(o)||!o.includes(e);case"between":return e>=o&&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(o=>o!==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 wt=[{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 Fa(i){const e=wt.find(t=>t.id===i);return e?{...e,id:`${e.id}_${Date.now()}`}:null}function La(i=!1){const e=new ar;if(i)for(const t of wt)e.addRule(t);return e}class Wa{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:o="contains",caseSensitive:a=!1,searchData:l=!0,dataProperties:s=[],maxResults:c=100,nodeShapes:f=[],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 u of this.nodes){if(m.length>=c)break;if(f.length>0&&!f.includes(u.shape)||d.length>0&&u.groupId&&!d.includes(u.groupId))continue;const p=this.matchElement(u,w,o,a,l,s);p&&m.push({id:u.id,type:"node",label:u.label||u.id,element:u,matchText:p.text,matchProperty:p.property,matchPositions:p.positions,score:p.score})}if(r==="all"||r==="edges"||r==="labels")for(const u of this.edges){if(m.length>=c)break;const p=this.matchElement(u,w,o,a,l,s);p&&m.push({id:u.id,type:"edge",label:u.label||`${u.sourceNodeId} → ${u.targetNodeId}`,element:u,matchText:p.text,matchProperty:p.property,matchPositions:p.positions,score:p.score})}if(r==="all"||r==="groups")for(const u of this.groups){if(m.length>=c)break;if(d.length>0&&!d.includes(u.id))continue;const p=this.matchElement(u,w,o,a,l,s);p&&m.push({id:u.id,type:"group",label:u.label||u.id,element:u,matchText:p.text,matchProperty:p.property,matchPositions:p.positions,score:p.score})}return m.sort((u,p)=>p.score-u.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,o,a,l){let s=null;const c=(d,m,w,u)=>{(!s||u>s.score)&&(s={text:d,property:m,positions:w,score:u})},f=this.matchText(e.id,t,r,o);if(f&&c(e.id,"id",f.positions,100+f.positions.length*10),"label"in e&&e.label){const d=this.matchText(e.label,t,r,o);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,r,o);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,r,o,l);for(const m of d)c(m.text,`data.${m.property}`,m.positions,50+m.positions.length*10)}return s}matchText(e,t,r,o){const a=o?e:e.toLowerCase(),l=o?t:t.toLowerCase(),s=[];switch(r){case"exact":a===l&&s.push({start:0,end:e.length});break;case"starts_with":a.startsWith(l)&&s.push({start:0,end:t.length});break;case"ends_with":a.endsWith(l)&&s.push({start:e.length-t.length,end:e.length});break;case"regex":try{const c=o?"g":"gi",f=new RegExp(t,c);let d;for(;(d=f.exec(e))!==null&&(s.push({start:d.index,end:d.index+d[0].length}),!!f.global););}catch{}break;case"contains":default:{let c=0;for(;(c=a.indexOf(l,c))!==-1;)s.push({start:c,end:c+t.length}),c+=t.length;break}}return s.length>0?{positions:s}:null}searchInData(e,t,r,o,a,l=""){const s=[];for(const[c,f]of Object.entries(e)){const d=l?`${l}.${c}`:c;if(!(a.length>0&&!a.some(m=>d.startsWith(m))))if(typeof f=="string"){const m=this.matchText(f,t,r,o);m&&s.push({text:f,property:d,positions:m.positions})}else if(typeof f=="number"||typeof f=="boolean"){const m=String(f),w=this.matchText(m,t,r,o);w&&s.push({text:m,property:d,positions:w.positions})}else f!=null&&typeof f=="object"&&!Array.isArray(f)&&s.push(...this.searchInData(f,t,r,o,a,d))}return s}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)),o=this.groups.filter(a=>this.matchFilters(a,e));return this.notify(),{nodes:t,edges:r,groups:o}}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 o=e;for(const a of r){if(o==null)return;o=o[a]}return o}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 o of this.nodes){const a=this.getPropertyValue(o,e);a!=null&&r.add(a)}if(!t||t==="edge")for(const o of this.edges){const a=this.getPropertyValue(o,e);a!=null&&r.add(a)}if(!t||t==="group")for(const o of this.groups){const a=this.getPropertyValue(o,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 Ba(i,e,t="search-highlight"){if(e.length===0)return i;const r=[...e].sort((a,l)=>l.start-a.start);let o=i;for(const a of r){const l=o.slice(0,a.start),s=o.slice(a.start,a.end),c=o.slice(a.end);o=`${l}<span class="${t}">${s}</span>${c}`}return o}function qa(i,e){switch(i){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=Vt;exports.AnimationTimeline=Qe;exports.COMMENT_PRIORITY_STYLES=Ea;exports.ConditionalStylingEngine=ar;exports.DIAGRAM_STYLE_PRESETS=Je;exports.DIAGRAM_TEMPLATES=it;exports.DiagramCanvas=ke;exports.DiagramCellRenderer=fo;exports.DiagramCommentManager=$a;exports.DiagramMinimap=et;exports.DiagramModel=Ze;exports.DiagramParticleEngine=jt;exports.DiagramPropertyPanel=tt;exports.DiagramSearchFilterEngine=Wa;exports.DiagramToolbar=rt;exports.DiagramVersioningManager=or;exports.EDGE_STYLE_CATALOG=yi;exports.NODE_STYLE_CATALOG=gi;exports.NiceAnimationTimeline=Qe;exports.NiceDatabaseSchemaViewer=Co;exports.NiceDecisionTreeEditor=ua;exports.NiceDependencyGraph=Vo;exports.NiceDiagram=bt;exports.NiceDiagramCanvas=ke;exports.NiceDiagramEditor=Wt;exports.NiceDiagramMinimap=et;exports.NiceDiagramPropertyPanel=tt;exports.NiceDiagramToolbar=rt;exports.NiceDiagramViewer=bt;exports.NiceI18nProvider=mt;exports.NiceNetworkTopology=ia;exports.NiceOrgChartVisualizer=Do;exports.NiceProcessMiningDiagram=Ro;exports.NiceWorkflowVisualizer=yo;exports.PRESET_RULES=wt;exports.TRANSITION_PRESETS=Lt;exports.analyzeDependencyGraph=Qo;exports.calculateNetworkHealth=la;exports.calculateOrgStats=Eo;exports.computeGlowRadius=$t;exports.computeLayout=Rt;exports.convertAnimation=Ht;exports.convertEdge=Yt;exports.convertGroup=Ut;exports.convertNode=Gt;exports.createConditionalStylingEngine=La;exports.createDecisionTree=xa;exports.createDiagramDocument=Ae;exports.createGlowFilterId=Dt;exports.createLinearWorkflow=vo;exports.createOrgChartFromEmployees=Po;exports.createPresetFromTheme=wi;exports.createQuickFilter=qa;exports.createRuleFromPreset=Fa;exports.createVersioningHook=Da;exports.discoverNetworkTopology=sa;exports.exportToMermaid=Tt;exports.exportToSvg=pt;exports.fetchAndGenerateDiagram=ho;exports.formatCommentDate=Ra;exports.generateDiagramFromData=Zt;exports.getDiagramStylePreset=bi;exports.getDiagramStylePresetsByCategory=xi;exports.getEasing=Bt;exports.getPointOnPath=fr;exports.getTemplateById=za;exports.getTemplatesByCategory=Ia;exports.highlightMatches=Ba;exports.mineProcessFromLog=Jt;exports.parseBPMNToWorkflow=xo;exports.parseNddJson=hr;exports.parsePackageJsonToDependencies=Jo;exports.parseSQLToSchema=zo;exports.parseSklearnTree=ba;exports.predictWithTree=va;exports.presetToThemeOverrides=vi;exports.renderTextWithMentions=Oa;exports.schemaToSQL=Io;exports.searchTemplates=Aa;exports.stringifyNddJson=Et;exports.useDiagramEditor=Ft;exports.useNiceTranslation=Le;
|