vizcraft 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +27 -0
  3. package/dist/animation.d.mts +1 -0
  4. package/dist/animation.d.ts +1 -0
  5. package/dist/animation.js +1 -0
  6. package/dist/animation.mjs +1 -0
  7. package/dist/chunk-5JIM7AZ4.mjs +1 -0
  8. package/dist/chunk-AJYVHPEQ.js +44 -0
  9. package/dist/chunk-CHZYOSWO.mjs +1 -0
  10. package/dist/chunk-E3Z7QMXI.js +1 -0
  11. package/dist/chunk-FXFCCGJT.mjs +1 -0
  12. package/dist/chunk-HPQGTODZ.js +1 -0
  13. package/dist/chunk-I5FQBS5N.mjs +2 -0
  14. package/dist/chunk-L3BMSH63.mjs +1 -0
  15. package/dist/chunk-NHGHIK6R.js +1 -0
  16. package/dist/chunk-OZAFCKI7.js +2 -0
  17. package/dist/chunk-T5O2PDL6.js +1 -0
  18. package/dist/chunk-U4YGYGXC.mjs +44 -0
  19. package/dist/{interaction/hitTest.d.ts → hitTest-Cd_u8975.d.ts} +16 -10
  20. package/dist/hitTest-NSYSXDf9.d.mts +72 -0
  21. package/dist/index-Cw8ug9aU.d.mts +1739 -0
  22. package/dist/index-Cw8ug9aU.d.ts +1739 -0
  23. package/dist/index.d.mts +217 -0
  24. package/dist/index.d.ts +217 -22
  25. package/dist/index.js +118 -22
  26. package/dist/index.mjs +118 -0
  27. package/dist/interaction.d.mts +29 -0
  28. package/dist/interaction.d.ts +29 -0
  29. package/dist/interaction.js +1 -0
  30. package/dist/interaction.mjs +1 -0
  31. package/dist/layout.d.mts +36 -0
  32. package/dist/{layout/algorithms.d.ts → layout.d.ts} +8 -5
  33. package/dist/layout.js +1 -0
  34. package/dist/layout.mjs +1 -0
  35. package/dist/ports.d.mts +81 -0
  36. package/dist/ports.d.ts +81 -0
  37. package/dist/ports.js +1 -0
  38. package/dist/ports.mjs +1 -0
  39. package/dist/serialization.d.mts +31 -0
  40. package/dist/{serialization/scene.d.ts → serialization.d.ts} +7 -4
  41. package/dist/serialization.js +1 -0
  42. package/dist/serialization.mjs +1 -0
  43. package/package.json +36 -2
  44. package/dist/animation/adapter.d.ts +0 -15
  45. package/dist/animation/adapter.js +0 -1
  46. package/dist/animation/builder.d.ts +0 -69
  47. package/dist/animation/builder.js +0 -106
  48. package/dist/animation/extendAdapter.d.ts +0 -2
  49. package/dist/animation/extendAdapter.js +0 -1
  50. package/dist/animation/playback.d.ts +0 -47
  51. package/dist/animation/playback.js +0 -46
  52. package/dist/animation/player.d.ts +0 -14
  53. package/dist/animation/player.js +0 -204
  54. package/dist/animation/registryAdapter.d.ts +0 -14
  55. package/dist/animation/registryAdapter.js +0 -94
  56. package/dist/animation/spec.d.ts +0 -18
  57. package/dist/animation/spec.js +0 -1
  58. package/dist/animation/specExtensions.d.ts +0 -7
  59. package/dist/animation/specExtensions.js +0 -5
  60. package/dist/animation/vizcraftAdapter.d.ts +0 -9
  61. package/dist/animation/vizcraftAdapter.js +0 -146
  62. package/dist/builder.d.ts +0 -401
  63. package/dist/builder.js +0 -2143
  64. package/dist/edges/builder.d.ts +0 -59
  65. package/dist/edges/builder.js +0 -344
  66. package/dist/edges/index.d.ts +0 -5
  67. package/dist/edges/index.js +0 -5
  68. package/dist/edges/labels.d.ts +0 -15
  69. package/dist/edges/labels.js +0 -26
  70. package/dist/edges/paths.d.ts +0 -57
  71. package/dist/edges/paths.js +0 -374
  72. package/dist/edges/resolveEdgeGeometry.d.ts +0 -43
  73. package/dist/edges/resolveEdgeGeometry.js +0 -67
  74. package/dist/edges/styles.d.ts +0 -8
  75. package/dist/edges/styles.js +0 -28
  76. package/dist/interaction/hitTest.js +0 -357
  77. package/dist/interaction/index.d.ts +0 -2
  78. package/dist/interaction/index.js +0 -2
  79. package/dist/interaction/panZoom.d.ts +0 -2
  80. package/dist/interaction/panZoom.js +0 -197
  81. package/dist/layout/algorithms.js +0 -59
  82. package/dist/layout/index.d.ts +0 -1
  83. package/dist/layout/index.js +0 -1
  84. package/dist/nodes/builder.d.ts +0 -111
  85. package/dist/nodes/builder.js +0 -486
  86. package/dist/nodes/index.d.ts +0 -1
  87. package/dist/nodes/index.js +0 -1
  88. package/dist/overlays/builder.d.ts +0 -50
  89. package/dist/overlays/builder.js +0 -80
  90. package/dist/overlays/index.d.ts +0 -2
  91. package/dist/overlays/index.js +0 -2
  92. package/dist/overlays/registry.d.ts +0 -130
  93. package/dist/overlays/registry.js +0 -457
  94. package/dist/ports/equidistant/index.d.ts +0 -2
  95. package/dist/ports/equidistant/index.js +0 -1
  96. package/dist/ports/equidistant/registry.d.ts +0 -37
  97. package/dist/ports/equidistant/registry.js +0 -144
  98. package/dist/ports/equidistant/strategies/circle.d.ts +0 -2
  99. package/dist/ports/equidistant/strategies/circle.js +0 -15
  100. package/dist/ports/equidistant/strategies/cross.d.ts +0 -2
  101. package/dist/ports/equidistant/strategies/cross.js +0 -20
  102. package/dist/ports/equidistant/strategies/cylinder.d.ts +0 -2
  103. package/dist/ports/equidistant/strategies/cylinder.js +0 -30
  104. package/dist/ports/equidistant/strategies/diamond.d.ts +0 -2
  105. package/dist/ports/equidistant/strategies/diamond.js +0 -18
  106. package/dist/ports/equidistant/strategies/ellipse.d.ts +0 -2
  107. package/dist/ports/equidistant/strategies/ellipse.js +0 -10
  108. package/dist/ports/equidistant/strategies/hexagon.d.ts +0 -2
  109. package/dist/ports/equidistant/strategies/hexagon.js +0 -31
  110. package/dist/ports/equidistant/strategies/index.d.ts +0 -2
  111. package/dist/ports/equidistant/strategies/index.js +0 -25
  112. package/dist/ports/equidistant/strategies/parallelogram.d.ts +0 -2
  113. package/dist/ports/equidistant/strategies/parallelogram.js +0 -14
  114. package/dist/ports/equidistant/strategies/rect.d.ts +0 -2
  115. package/dist/ports/equidistant/strategies/rect.js +0 -13
  116. package/dist/ports/equidistant/strategies/star.d.ts +0 -2
  117. package/dist/ports/equidistant/strategies/star.js +0 -11
  118. package/dist/ports/equidistant/strategies/trapezoid.d.ts +0 -2
  119. package/dist/ports/equidistant/strategies/trapezoid.js +0 -14
  120. package/dist/ports/equidistant/strategies/triangle.d.ts +0 -2
  121. package/dist/ports/equidistant/strategies/triangle.js +0 -44
  122. package/dist/ports/equidistant/types.d.ts +0 -42
  123. package/dist/ports/equidistant/types.js +0 -1
  124. package/dist/ports/equidistant/utils.d.ts +0 -48
  125. package/dist/ports/equidistant/utils.js +0 -168
  126. package/dist/ports/index.d.ts +0 -1
  127. package/dist/ports/index.js +0 -1
  128. package/dist/rendering/animations.d.ts +0 -22
  129. package/dist/rendering/animations.js +0 -30
  130. package/dist/rendering/index.d.ts +0 -3
  131. package/dist/rendering/index.js +0 -3
  132. package/dist/rendering/runtimePatcher.d.ts +0 -20
  133. package/dist/rendering/runtimePatcher.js +0 -760
  134. package/dist/rendering/styles.d.ts +0 -1
  135. package/dist/rendering/styles.js +0 -106
  136. package/dist/serialization/index.d.ts +0 -1
  137. package/dist/serialization/index.js +0 -1
  138. package/dist/serialization/scene.js +0 -98
  139. package/dist/shapes/geometry.d.ts +0 -66
  140. package/dist/shapes/geometry.js +0 -1488
  141. package/dist/shapes/icons.d.ts +0 -18
  142. package/dist/shapes/icons.js +0 -49
  143. package/dist/shapes/index.d.ts +0 -2
  144. package/dist/shapes/index.js +0 -2
  145. package/dist/types.d.ts +0 -877
  146. package/dist/types.js +0 -2
  147. package/dist/utils/index.d.ts +0 -1
  148. package/dist/utils/index.js +0 -1
  149. package/dist/utils/text.d.ts +0 -39
  150. package/dist/utils/text.js +0 -215
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # vizcraft
2
2
 
3
+ ## 1.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#110](https://github.com/ChipiKaf/vizcraft/pull/110) [`3ebfa5b`](https://github.com/ChipiKaf/vizcraft/commit/3ebfa5b082a8a6d37fc1bdfce95c0c9ecbedfd6c) Thanks [@ChipiKaf](https://github.com/ChipiKaf)! - Add compartmented node layout (UML-style multi-section nodes). Nodes can be divided into horizontal compartments separated by divider lines using the new `.compartment(id, cb?)` fluent API or the declarative `compartments` array in `NodeOptions`. Compartment heights are auto-sized from label content. Hit-testing returns `compartmentId` when clicking inside a specific section.
8
+
9
+ - [`5d29b3e`](https://github.com/ChipiKaf/vizcraft/commit/5d29b3e04862ef7d99a4196f568d3e44101a4f9e) Thanks [@ChipiKaf](https://github.com/ChipiKaf)! - Add tooltip/hover info API and text badge API; reduce bundle size.
10
+ - **Tooltip API (#109)**: Attach hover info to nodes and edges via `.tooltip(content, opts?)` (fluent) or `tooltip` option (declarative). Supports plain text and structured title/body content, configurable placement and delay.
11
+ - **Text Badge API (#108)**: Pin 1–2 character indicators to node corners via `.badge(text, opts?)` (fluent) or `badges` array (declarative). Four corner positions, customisable fill/background/fontSize.
12
+ - **Bundle size reduction (#106)**: Tree-shaking improvements via `sideEffects: false`, refined `exports` map, dead code removal, and module extraction.
13
+
3
14
  ## 1.8.0
4
15
 
5
16
  ### Minor Changes
package/README.md CHANGED
@@ -22,6 +22,7 @@ VizCraft is designed to make creating beautiful, animated node-link diagrams and
22
22
  - **Framework Agnostic**: The core logic is pure TypeScript and can be used with any framework or Vanilla JS.
23
23
  - **Custom Overlays**: Create complex, custom UI elements that float on top of your visualization.
24
24
  - **Dangling Edges**: Create edges with free endpoints for drag-to-connect interactions.
25
+ - **Text Badges**: Pin 1–2 character indicators (class kind, status, etc.) to any corner of a node.
25
26
 
26
27
  ## 📦 Installation
27
28
 
@@ -213,8 +214,34 @@ b.node('n1')
213
214
  .port('out', { x: 50, y: 0 }) // Named connection port
214
215
  .container(config?) // Mark as container / group node
215
216
  .parent('containerId') // Make child of a container
217
+ .compartment(id, cb?) // Add a UML-style compartment section
216
218
  ```
217
219
 
220
+ ### Compartmented Nodes
221
+
222
+ Divide a node into horizontal sections — ideal for UML class diagrams:
223
+
224
+ ```typescript
225
+ b.node('user')
226
+ .at(250, 110)
227
+ .rect(200, 0, 6)
228
+ .fill('#f5f5f5')
229
+ .stroke('#333')
230
+ .compartment('name', (c) => c.label('User').height(36))
231
+ .compartment('attrs', (c) =>
232
+ c.label('- id: number\n- name: string', {
233
+ fontSize: 12,
234
+ textAnchor: 'start',
235
+ })
236
+ )
237
+ .compartment('methods', (c) =>
238
+ c.label('+ getName()\n+ setName()', { fontSize: 12, textAnchor: 'start' })
239
+ )
240
+ .done();
241
+ ```
242
+
243
+ The node height auto-sizes to fit all compartments. Each section is separated by a divider line in the rendered SVG.
244
+
218
245
  ### Container / Group Nodes
219
246
 
220
247
  Group related nodes into visual containers (swimlanes, sub-processes, etc.).
@@ -0,0 +1 @@
1
+ export { as as AnimProperty, ay as AnimatableProps, az as AnimationBuilder, aJ as AnimationHostAdapter, av as AnimationSpec, aq as AnimationTarget, ar as CoreAnimProperty, ax as CoreAnimatableProps, at as Ease, aB as ExtendAdapter, aC as PlaybackController, aI as PropHandlers, aG as PropReader, aH as PropWriter, aK as RegistrableAdapter, aw as TweenOptions, au as TweenSpec, aA as buildAnimationSpec, aE as createBuilderPlayback, aD as createScenePlayback, aF as playAnimationSpec } from './index-Cw8ug9aU.mjs';
@@ -0,0 +1 @@
1
+ export { as as AnimProperty, ay as AnimatableProps, az as AnimationBuilder, aJ as AnimationHostAdapter, av as AnimationSpec, aq as AnimationTarget, ar as CoreAnimProperty, ax as CoreAnimatableProps, at as Ease, aB as ExtendAdapter, aC as PlaybackController, aI as PropHandlers, aG as PropReader, aH as PropWriter, aK as RegistrableAdapter, aw as TweenOptions, au as TweenSpec, aA as buildAnimationSpec, aE as createBuilderPlayback, aD as createScenePlayback, aF as playAnimationSpec } from './index-Cw8ug9aU.js';
@@ -0,0 +1 @@
1
+ 'use strict';var chunkHPQGTODZ_js=require('./chunk-HPQGTODZ.js');Object.defineProperty(exports,"AnimationBuilder",{enumerable:true,get:function(){return chunkHPQGTODZ_js.c}});Object.defineProperty(exports,"buildAnimationSpec",{enumerable:true,get:function(){return chunkHPQGTODZ_js.d}});Object.defineProperty(exports,"createBuilderPlayback",{enumerable:true,get:function(){return chunkHPQGTODZ_js.f}});Object.defineProperty(exports,"createScenePlayback",{enumerable:true,get:function(){return chunkHPQGTODZ_js.e}});Object.defineProperty(exports,"playAnimationSpec",{enumerable:true,get:function(){return chunkHPQGTODZ_js.g}});
@@ -0,0 +1 @@
1
+ export{c as AnimationBuilder,d as buildAnimationSpec,f as createBuilderPlayback,e as createScenePlayback,g as playAnimationSpec}from'./chunk-CHZYOSWO.mjs';
@@ -0,0 +1 @@
1
+ import {l as l$1}from'./chunk-I5FQBS5N.mjs';var X=180/Math.PI,k=Math.PI/180,l=720;function b(t,o){return Math.hypot(o.x-t.x,o.y-t.y)}function w(t,o,r){return {x:t.x+(o.x-t.x)*r,y:t.y+(o.y-t.y)*r}}function A(t){return Math.atan2(t.y,t.x)*X}function V(t){return (t%360+360)%360}function E(t,o,r){return {id:`p${o}`,angle:V(A(t)),t:r,x:t.x,y:t.y}}function d(t){let o=new Map;return t.map(r=>{let e=Math.floor(V(r.angle)/90)*90,n=o.get(e)??0;return o.set(e,n+1),{...r,id:`${e}-${n}`}})}function M(t,o,r){let e=t.length;if(e===0||o<=0)return [];let n=[0];for(let y=0;y<e;y++){let p=(y+1)%e;n.push(n[y]+b(t[y],t[p]));}let i=n[e];if(i===0)return [];let c=i/o,m=[],s=0,a=r?new Array(e).fill(0):[];for(let y=0;y<o;y++){let p=y*c;for(;s<e-1&&n[s+1]<=p;)s++;let h=n[s],f=n[s+1]-h,T=f>0?(p-h)/f:0,G=t[s],H=t[(s+1)%e],S=w(G,H,T),P;if(r){let U=r[s],N=a[s];a[s]=N+1,P=`${U}-${N}`;}else P=`p${y}`;m.push({id:P,angle:V(A(S)),t:p/i,x:S.x,y:S.y});}return m}function Z(t,o){let r=t.length;if(r<2||o<=0)return [];let e=[0];for(let m=1;m<r;m++)e.push(e[m-1]+b(t[m-1],t[m]));let n=e[r-1]+b(t[r-1],t[0]);if(n===0)return [];let i=[],c=0;for(let m=0;m<o;m++){let s=m/o,a=s*n;for(;c<r-1&&e[c+1]<=a;)c++;let y;if(c>=r-1){let p=e[r-1],h=n-p,g=h>0?(a-p)/h:0;y=w(t[r-1],t[0],g);}else {let p=e[c],g=e[c+1]-p,f=g>0?(a-p)/g:0;y=w(t[c],t[c+1],f);}i.push(E(y,m,s));}return i}function u(t,o,r,e){return {kind:t,defaultCount:o,computePorts:(n,i)=>{let c=r(n),m=e?.(n),s=M(c,i,m);return m?s:d(s)}}}function x(t,o,r){return {kind:t,defaultCount:o,computePorts:(e,n)=>d(Z(r(e),n))}}function j(t,o){let r=[];for(let e=0;e<o;e++){let i=360*e/o*k;r.push(E({x:t*Math.cos(i),y:t*Math.sin(i)},e,e/o));}return d(r)}var q={kind:"circle",defaultCount:8,computePorts:(t,o)=>j(t.r,o)};function J(t,o){let r=[];for(let e=0;e<=l;e++){let n=2*Math.PI*e/l;r.push({x:t*Math.cos(n),y:o*Math.sin(n)});}return r}var C=x("ellipse",8,t=>J(t.rx,t.ry));function Q(t,o,r){let e=t/2,n=r??Math.round(o*.15),i=o/2,c=Math.ceil(l/2),m=Math.max(4,Math.ceil(c/4)),s=[];for(let a=0;a<=c;a++){let y=Math.PI*a/c;s.push({x:e*Math.cos(y),y:-i-n*Math.sin(y)});}for(let a=1;a<=m;a++)s.push({x:-e,y:-i+a/m*o});for(let a=1;a<=c;a++){let y=Math.PI*a/c;s.push({x:-e*Math.cos(y),y:i+n*Math.sin(y)});}for(let a=1;a<m;a++)s.push({x:e,y:i-a/m*o});return s}var D=x("cylinder",10,t=>Q(t.w,t.h,t.arcHeight));function Y(t,o){let r=t/2,e=o/2;return [{x:-r,y:-e},{x:r,y:-e},{x:r,y:e},{x:-r,y:e}]}var tt=["top","right","bottom","left"],R=u("rect",8,t=>Y(t.w,t.h),()=>tt);function et(t,o){let r=t/2,e=o/2;return [{x:0,y:-e},{x:r,y:0},{x:0,y:e},{x:-r,y:0}]}var rt=["top-right","bottom-right","bottom-left","top-left"],L=u("diamond",4,t=>et(t.w,t.h),()=>rt);function ot(t,o){let r=o==="pointy"?-Math.PI/2:0,e=[];for(let n=0;n<6;n++){let i=r+Math.PI/3*n;e.push({x:t*Math.cos(i),y:t*Math.sin(i)});}return e}function nt(t){return t==="pointy"?["top-right","right","bottom-right","bottom-left","left","top-left"]:["bottom-right","bottom","bottom-left","top-left","top","top-right"]}var z=u("hexagon",6,t=>ot(t.r,t.orientation??"pointy"),t=>nt(t.orientation??"pointy"));function it(t,o,r){let e=t/2,n=o/2;switch(r){case "up":return [{x:0,y:-n},{x:e,y:n},{x:-e,y:n}];case "down":return [{x:0,y:n},{x:-e,y:-n},{x:e,y:-n}];case "left":return [{x:-e,y:0},{x:e,y:-n},{x:e,y:n}];case "right":return [{x:e,y:0},{x:-e,y:n},{x:-e,y:-n}]}}function ct(t){switch(t){case "up":return ["right","bottom","left"];case "down":return ["left","top","right"];case "left":return ["top","right","bottom"];case "right":return ["bottom","left","top"]}}var K=u("triangle",6,t=>it(t.w,t.h,t.direction??"up"),t=>ct(t.direction??"up"));function st(t,o,r){let e=t/2,n=o/2,i=r/2;return [{x:-e+i,y:-n},{x:e+i,y:-n},{x:e-i,y:n},{x:-e-i,y:n}]}var at=["top","right","bottom","left"],_=u("parallelogram",8,t=>st(t.w,t.h,t.skew??Math.round(t.w*.2)),()=>at);function mt(t,o,r){let e=t/2,n=o/2,i=r/2;return [{x:-e,y:-i},{x:e,y:-i},{x:n,y:i},{x:-n,y:i}]}var yt=["top","right","bottom","left"],B=u("trapezoid",8,t=>mt(t.topW,t.bottomW,t.h),()=>yt);function ut(t,o,r){let e=[];for(let n=0;n<t*2;n++){let i=n%2===0?o:r,c=Math.PI*n/t-Math.PI/2;e.push({x:i*Math.cos(c),y:i*Math.sin(c)});}return e}var W=u("star",t=>t.points*2,t=>ut(t.points,t.outerR,t.innerR??Math.round(t.outerR*.4)));function pt(t,o){let r=t/2,e=o/2;return [{x:-e,y:-r},{x:e,y:-r},{x:e,y:-e},{x:r,y:-e},{x:r,y:e},{x:e,y:e},{x:e,y:r},{x:-e,y:r},{x:-e,y:e},{x:-r,y:e},{x:-r,y:-e},{x:-e,y:-e}]}var $=u("cross",12,t=>pt(t.size,t.barWidth??Math.round(t.size/3)));var O=[q,C,D,R,L,z,K,_,B,W,$];var ht=8,v=new Map;function F(t){v.set(t.kind,t);}for(let t of O)F(t);function gt(t){switch(t.kind){case "circle":return {hw:t.r,hh:t.r};case "rect":return {hw:t.w/2,hh:t.h/2};case "diamond":return {hw:t.w/2,hh:t.h/2};case "ellipse":return {hw:t.rx,hh:t.ry};case "hexagon":return {hw:t.r,hh:t.r};case "cylinder":return {hw:t.w/2,hh:t.h/2};case "arc":return {hw:t.r,hh:t.r};case "blockArrow":return {hw:t.length/2,hh:t.headWidth/2};case "callout":return {hw:t.w/2,hh:t.h/2};case "cloud":return {hw:t.w/2,hh:t.h/2};case "cross":return {hw:t.size/2,hh:t.size/2};case "cube":return {hw:t.w/2,hh:t.h/2};case "path":return {hw:t.w/2,hh:t.h/2};case "document":return {hw:t.w/2,hh:t.h/2};case "note":return {hw:t.w/2,hh:t.h/2};case "parallelogram":return {hw:t.w/2,hh:t.h/2};case "star":return {hw:t.outerR,hh:t.outerR};case "trapezoid":return {hw:Math.max(t.topW,t.bottomW)/2,hh:t.h/2};case "triangle":return {hw:t.w/2,hh:t.h/2};case "image":return {hw:t.w/2,hh:t.h/2};case "icon":return {hw:t.w/2,hh:t.h/2};case "svg":return {hw:t.w/2,hh:t.h/2};default:return {hw:0,hh:0}}}var lt=["top","right","bottom","left"];function ft(t,o){let{hw:r,hh:e}=gt(t);return M([{x:-r,y:-e},{x:r,y:-e},{x:r,y:e},{x:-r,y:e}],o,lt)}function dt(t,o){let r=v.get(t.kind),e=o??(r?typeof r.defaultCount=="function"?r.defaultCount(t):r.defaultCount:ht);return e<=0?[]:r?r.computePorts(t,e):ft(t,e)}function xt(t){return t.map(o=>({id:o.id,offset:{x:o.x,y:o.y},direction:o.angle}))}function St(t,o,r){let e=l$1(t);if(e.length===0)return;let n,i=1/0;for(let c of e){let m=c.offset.x-o,s=c.offset.y-r,a=m*m+s*s;a<i&&(i=a,n=c);}return n}export{F as a,dt as b,xt as c,St as d};
@@ -0,0 +1,44 @@
1
+ 'use strict';var chunkOZAFCKI7_js=require('./chunk-OZAFCKI7.js');function gt(t,e,o,n={}){let r=n.minZoom??.1,i=n.maxZoom??5,l=n.zoomOnWheel??true,s=n.panOnDrag??true,c=1,u={x:0,y:0},a=false,d={x:0,y:0},v=[],$=()=>{v.forEach(y=>y({zoom:c,pan:u}));},b=()=>{e.setAttribute("transform",`translate(${u.x}, ${u.y}) scale(${c})`),$();},f=(y,x)=>{let P=Math.max(r,Math.min(i,y));if(P!==c){if(x){let L=P/c;u.x=x.x-(x.x-u.x)*L,u.y=x.y-(x.y-u.y)*L;}c=P,b();}},m=y=>{u={...y},b();},h=(y=20)=>{if(!o.viewBox)return null;let x=t.getBoundingClientRect();if(x.width===0||x.height===0)return null;let P=x.width-y*2,L=x.height-y*2,I=P/o.viewBox.w,N=L/o.viewBox.h,T=Math.min(I,N);T=Math.max(r,Math.min(i,T));let K=o.viewBox.w*T,J=o.viewBox.h*T,tt={x:(x.width-K)/2,y:(x.height-J)/2};return {zoom:T,pan:tt}},p=(y=20)=>{let x=h(y);x&&(c=x.zoom,u=x.pan,b());},g=()=>{n.initialZoom==="fit"||n.initialZoom===void 0?p():(f(n.initialZoom),m({x:0,y:0}));},z=y=>{let x=o.nodes.find(T=>T.id===y);if(!x)return;let P=t.getBoundingClientRect();if(P.width===0||P.height===0)return;let L=Math.max(r,Math.min(i,2)),I=P.width/2-x.pos.x*L,N=P.height/2-x.pos.y*L;c=L,u={x:I,y:N},b();},S=y=>{if(!l)return;y.preventDefault();let x=.002,P=-y.deltaY;y.deltaMode===1&&(P*=15);let L=Math.exp(P*x),I=c*L,N=t.getBoundingClientRect(),T={x:y.clientX-N.left,y:y.clientY-N.top};f(I,T);},E=y=>{if(!s)return;let x=y.target;(x.closest("[data-viz-role]")||x.closest(".viz-node")||x.closest(".viz-edge"))&&x!==t&&x!==e||(y.preventDefault(),a=true,d={x:y.clientX,y:y.clientY},t.setPointerCapture(y.pointerId),t.style.cursor="grabbing");},V=y=>{if(!a||!s)return;y.preventDefault();let x=y.clientX-d.x,P=y.clientY-d.y;u.x+=x,u.y+=P,d={x:y.clientX,y:y.clientY},b();},w=y=>{!a||!s||(a=false,t.releasePointerCapture(y.pointerId),t.style.cursor="");},M=y=>{let x=y.target;x.closest("[data-viz-role]")||x.closest(".viz-node")||x.closest(".viz-edge")||p();},R={passive:false};t.addEventListener("wheel",S,R),t.addEventListener("pointerdown",E),t.addEventListener("pointermove",V),t.addEventListener("pointerup",w),t.addEventListener("pointercancel",w),t.addEventListener("dblclick",M);let U=()=>{t.removeEventListener("wheel",S),t.removeEventListener("pointerdown",E),t.removeEventListener("pointermove",V),t.removeEventListener("pointerup",w),t.removeEventListener("pointercancel",w),t.removeEventListener("dblclick",M),v.length=0;};return requestAnimationFrame(()=>{g();}),{get zoom(){return c},get pan(){return {...u}},setZoom:f,setPan:m,fitToContent:p,zoomToNode:z,reset:g,onChange(y){return v.push(y),()=>{let x=v.indexOf(y);x!==-1&&v.splice(x,1);}},destroy:U}}var et=`
2
+ .viz-tooltip {
3
+ position: absolute;
4
+ pointer-events: none;
5
+ z-index: 9999;
6
+ max-width: 320px;
7
+ padding: 8px 12px;
8
+ border-radius: 6px;
9
+ font-size: 13px;
10
+ line-height: 1.4;
11
+ background: var(--viz-tooltip-bg, #1a1a2e);
12
+ color: var(--viz-tooltip-fg, #e2e8f0);
13
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
14
+ opacity: 0;
15
+ transition: opacity 0.15s ease-out;
16
+ white-space: pre-wrap;
17
+ word-break: break-word;
18
+ box-sizing: border-box;
19
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
20
+ }
21
+ .viz-tooltip[data-visible="true"] {
22
+ opacity: 1;
23
+ }
24
+ .viz-tooltip-title {
25
+ font-weight: 600;
26
+ margin-bottom: 4px;
27
+ font-size: 14px;
28
+ }
29
+ .viz-tooltip-section {
30
+ display: flex;
31
+ gap: 6px;
32
+ padding: 2px 0;
33
+ }
34
+ .viz-tooltip-section-label {
35
+ color: var(--viz-tooltip-label, #94a3b8);
36
+ flex-shrink: 0;
37
+ }
38
+ .viz-tooltip-section-label::after {
39
+ content: ':';
40
+ }
41
+ .viz-tooltip-section-value {
42
+ color: var(--viz-tooltip-fg, #e2e8f0);
43
+ }
44
+ `;function B(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function nt(t){if(typeof t=="string")return `<span>${B(t)}</span>`;let e="";t.title&&(e+=`<div class="viz-tooltip-title">${B(t.title)}</div>`);for(let o of t.sections)e+=`<div class="viz-tooltip-section"><span class="viz-tooltip-section-label">${B(o.label)}</span><span class="viz-tooltip-section-value">${B(o.value)}</span></div>`;return e}function ot(t,e,o){let n=e.getBoundingClientRect(),r=o.getBoundingClientRect(),i=8,l=t.offsetWidth,s=t.offsetHeight,c=n.left-r.left+n.width/2-l/2,u=n.top-r.top-s-i;u<0&&(u=n.bottom-r.top+i),c<0&&(c=4),c+l>o.clientWidth&&(c=o.clientWidth-l-4),t.style.left=`${c}px`,t.style.top=`${u}px`;}function bt(t,e,o,n,r){let i=r?.delay??300,l=o,s=n,c=t.querySelector("style[data-viz-tooltip-css]");c||(c=document.createElement("style"),c.setAttribute("data-viz-tooltip-css",""),c.textContent=et,t.appendChild(c));let u=document.createElement("div");u.className="viz-tooltip",u.setAttribute("role","tooltip"),u.setAttribute("aria-hidden","true"),t.appendChild(u),getComputedStyle(t).position==="static"&&(t.style.position="relative");let d=null,v=null;function $(E,V){u.innerHTML=nt(V),u.style.display="block",u.setAttribute("data-visible","false"),requestAnimationFrame(()=>{ot(u,E,t),u.setAttribute("data-visible","true"),u.setAttribute("aria-hidden","false");});}function b(){d!==null&&(clearTimeout(d),d=null),u.setAttribute("data-visible","false"),u.setAttribute("aria-hidden","true"),v=null;}function f(E){let V=E instanceof Element?E:null;for(;V&&V!==e;){let w=V.getAttribute("data-viz-role"),M=V.getAttribute("data-id");if(w==="node-group"&&M){let R=l.get(M);return R?.tooltip?{content:R.tooltip,group:V}:null}if(w==="edge-group"&&M){let R=s.get(M);return R?.tooltip?{content:R.tooltip,group:V}:null}V=V.parentElement;}return null}function m(E){let V=f(E.target);if(!V)return;let{content:w,group:M}=V;M!==v&&(b(),v=M,d=setTimeout(()=>{$(M,w);},i));}function h(E){let V=f(E.target);V&&V.group===v&&b();}function p(E){let V=f(E.target);(!V||V.group!==v)&&b();}function g(E){let V=f(E.target);V&&(b(),v=V.group,$(V.group,V.content));}function z(){b();}function S(E){E.key==="Escape"&&b();}return e.addEventListener("pointerenter",m,true),e.addEventListener("pointerleave",h,true),e.addEventListener("pointermove",p,true),e.addEventListener("focusin",g,true),e.addEventListener("focusout",z,true),e.addEventListener("keydown",S,true),{destroy(){b(),e.removeEventListener("pointerenter",m,true),e.removeEventListener("pointerleave",h,true),e.removeEventListener("pointermove",p,true),e.removeEventListener("focusin",g,true),e.removeEventListener("focusout",z,true),e.removeEventListener("keydown",S,true),u.remove(),c?.remove();},updateData(E,V){l=E,s=V;}}}function G(t,e,o){let n=o.anchor??"boundary",r=o.fromAt,i=o.toAt,l=e?chunkOZAFCKI7_js.d(e):i??{x:0,y:0},s=t?chunkOZAFCKI7_js.d(t):r??{x:0,y:0},c;t?o.fromAngle!==void 0?c=chunkOZAFCKI7_js.j(t,o.fromAngle):c=o.fromPort?chunkOZAFCKI7_js.n(t,o.fromPort)??chunkOZAFCKI7_js.i(t,l,n):chunkOZAFCKI7_js.i(t,l,n):c=r??{x:0,y:0};let u;return e?o.toAngle!==void 0?u=chunkOZAFCKI7_js.j(e,o.toAngle):u=o.toPort?chunkOZAFCKI7_js.n(e,o.toPort)??chunkOZAFCKI7_js.i(e,s,n):chunkOZAFCKI7_js.i(e,s,n):u=i??{x:0,y:0},{start:c,end:u}}function _(t,e,o="straight",n){switch(o){case "curved":return rt(t,e,n);case "orthogonal":return ct(t,e,n);default:return it(t,e,n)}}function it(t,e,o){let n=[t,...o??[],e],r=n.map((l,s)=>s===0?`M ${l.x} ${l.y}`:`L ${l.x} ${l.y}`),i=X(n);return {d:r.join(" "),...i}}function rt(t,e,o){if(o&&o.length>0)return st(t,e,o);let n=j(t,e),r=`M ${t.x} ${t.y} Q ${n.x} ${n.y} ${e.x} ${e.y}`,i=C(t,n,e,.5),l=C(t,n,e,D),s=C(t,n,e,O);return {d:r,mid:i,start:l,end:s}}function j(t,e){let o=(t.x+e.x)/2,n=(t.y+e.y)/2,r=e.x-t.x,i=e.y-t.y,l=Math.sqrt(r*r+i*i)||1,s=l*.2;return {x:o+-i/l*s,y:n+r/l*s}}function C(t,e,o,n){let r=1-n;return {x:r*r*t.x+2*r*n*e.x+n*n*o.x,y:r*r*t.y+2*r*n*e.y+n*n*o.y}}function st(t,e,o){let n=[t,...o,e];if(n.length===2){let s=j(t,e);return {d:`M ${t.x} ${t.y} Q ${s.x} ${s.y} ${e.x} ${e.y}`,mid:C(t,s,e,.5),start:C(t,s,e,D),end:C(t,s,e,O)}}let r=`M ${n[0].x} ${n[0].y}`,i=.3;for(let s=0;s<n.length-1;s++){let c=n[Math.max(s-1,0)],u=n[s],a=n[s+1],d=n[Math.min(s+2,n.length-1)],v=u.x+(a.x-c.x)*i,$=u.y+(a.y-c.y)*i,b=a.x-(d.x-u.x)*i,f=a.y-(d.y-u.y)*i;r+=` C ${v} ${$}, ${b} ${f}, ${a.x} ${a.y}`;}let l=X(n);return {d:r,...l}}function ct(t,e,o){return o&&o.length>0?ut(t,e,o):lt(t,e)}function lt(t,e){let o=Math.abs(e.x-t.x),n=Math.abs(e.y-t.y),r,i,l,s;if(o>=n){let c=(t.x+e.x)/2;r=`M ${t.x} ${t.y} L ${c} ${t.y} L ${c} ${e.y} L ${e.x} ${e.y}`;let u=[t,{x:c,y:t.y},{x:c,y:e.y},e];i=A(u,.5),l=A(u,D),s=A(u,O);}else {let c=(t.y+e.y)/2;r=`M ${t.x} ${t.y} L ${t.x} ${c} L ${e.x} ${c} L ${e.x} ${e.y}`;let u=[t,{x:t.x,y:c},{x:e.x,y:c},e];i=A(u,.5),l=A(u,D),s=A(u,O);}return {d:r,mid:i,start:l,end:s}}function ut(t,e,o){let n=[t,...o,e],r=`M ${n[0].x} ${n[0].y}`,i=[n[0]];for(let s=1;s<n.length;s++){let c=n[s-1],u=n[s];r+=` L ${u.x} ${c.y} L ${u.x} ${u.y}`,i.push({x:u.x,y:c.y}),i.push(u);}let l=X(i);return {d:r,...l}}var D=.15,O=.85;function A(t,e){if(t.length===0)return {x:0,y:0};if(t.length===1)return t[0];let o=0;for(let i=1;i<t.length;i++){let l=t[i].x-t[i-1].x,s=t[i].y-t[i-1].y;o+=Math.sqrt(l*l+s*s);}let n=o*e,r=0;for(let i=1;i<t.length;i++){let l=t[i].x-t[i-1].x,s=t[i].y-t[i-1].y,c=Math.sqrt(l*l+s*s);if(r+c>=n){let u=c===0?0:(n-r)/c;return {x:t[i-1].x+l*u,y:t[i-1].y+s*u}}r+=c;}return t[t.length-1]}function X(t){return {start:A(t,D),mid:A(t,.5),end:A(t,O)}}function at(t){return t?"w"in t&&"h"in t?{w:t.w,h:t.h}:"r"in t?{w:t.r*2,h:t.r*2}:"rx"in t&&"ry"in t?{w:t.rx*2,h:t.ry*2}:"size"in t?{w:t.size,h:t.size}:{w:60,h:60}:{w:60,h:60}}function $t(t,e){let o=chunkOZAFCKI7_js.d(t),n=at(chunkOZAFCKI7_js.e(t)),r=n.w,i=n.h,l=e.loopSide||"top",s=e.loopSize||30,c=Math.min(20,(l==="top"||l==="bottom"?r:i)*.8),u="",a,d,v,$,b;switch(l){case "top":{let f=o.x-c/2,m=o.y-i/2,h=o.x+c/2,p=o.y-i/2,g=m-s*1.5;u=`M ${f} ${m} C ${f-c/2} ${g}, ${h+c/2} ${g}, ${h} ${p}`,$={x:f,y:m},b={x:h,y:p},a={x:f,y:m-s*.2},d={x:o.x,y:m-s},v={x:h,y:p-s*.2};break}case "bottom":{let f=o.x-c/2,m=o.y+i/2,h=o.x+c/2,p=o.y+i/2,g=m+s*1.5;u=`M ${f} ${m} C ${f-c/2} ${g}, ${h+c/2} ${g}, ${h} ${p}`,$={x:f,y:m},b={x:h,y:p},a={x:f,y:m+s*.2},d={x:o.x,y:m+s},v={x:h,y:p+s*.2};break}case "left":{let f=o.x-r/2,m=o.y-c/2,h=o.x-r/2,p=o.y+c/2,g=f-s*1.5;u=`M ${f} ${m} C ${g} ${m-c/2}, ${g} ${p+c/2}, ${h} ${p}`,$={x:f,y:m},b={x:h,y:p},a={x:f-s*.2,y:m},d={x:f-s,y:o.y},v={x:h-s*.2,y:p};break}case "right":{let f=o.x+r/2,m=o.y-c/2,h=o.x+r/2,p=o.y+c/2,g=f+s*1.5;u=`M ${f} ${m} C ${g} ${m-c/2}, ${g} ${p+c/2}, ${h} ${p}`,$={x:f,y:m},b={x:h,y:p},a={x:f+s*.2,y:m},d={x:f+s,y:o.y},v={x:h+s*.2,y:p};break}}return {d:u,start:a,mid:d,end:v,exitPoint:$,entryPoint:b}}function dt(t,e){return t.x>=e.x&&t.x<=e.x+e.w&&t.y>=e.y&&t.y<=e.y+e.h}function Q(t,e,o){let n=t.x-e.x,r=t.y-e.y;return n*n+r*r<=o*o}function Z(t,e){let o=t.x-e.x,n=t.y-e.y;return o*o+n*n}function ft(t,e,o){let n=Z(e,o);if(n===0)return Z(t,e);let r=((t.x-e.x)*(o.x-e.x)+(t.y-e.y)*(o.y-e.y))/n;return r=Math.max(0,Math.min(1,r)),Z(t,{x:e.x+r*(o.x-e.x),y:e.y+r*(o.y-e.y)})}function yt(t,e=10){let o=t.match(/[a-zA-Z][^a-zA-Z]*/g);if(!o)return [];let n=[],r=0,i=0,l=0,s=0;for(let c of o){let u=c[0],a=c.substring(1).trim().split(/[\s,]+/).filter(d=>d!=="").map(parseFloat);switch(u.toUpperCase()){case "M":a.length>=2&&(r=a[0],i=a[1],l=r,s=i,n.push({x:r,y:i}));break;case "L":for(let d=0;d<a.length;d+=2)r=a[d],i=a[d+1],n.push({x:r,y:i});break;case "Q":for(let d=0;d<a.length;d+=4){let v=a[d],$=a[d+1],b=a[d+2],f=a[d+3];for(let m=1;m<=e;m++){let h=m/e,p=1-h,g=p*p*r+2*p*h*v+h*h*b,z=p*p*i+2*p*h*$+h*h*f;n.push({x:g,y:z});}r=b,i=f;}break;case "C":for(let d=0;d<a.length;d+=6){let v=a[d],$=a[d+1],b=a[d+2],f=a[d+3],m=a[d+4],h=a[d+5];for(let p=1;p<=e;p++){let g=p/e,z=1-g,S=z*z*z*r+3*z*z*g*v+3*z*g*g*b+g*g*g*m,E=z*z*z*i+3*z*z*g*$+3*z*g*g*f+g*g*g*h;n.push({x:S,y:E});}r=m,i=h;}break;case "Z":r=l,i=s,n.push({x:r,y:i});break}}return n}function xt(t,e){if(e.length===0)return 1/0;if(e.length===1)return Math.sqrt(Z(t,e[0]));let o=1/0;for(let n=0;n<e.length-1;n++){let r=ft(t,e[n],e[n+1]);r<o&&(o=r);}return Math.sqrt(o)}function W(t){let e=0,o=0,n=t.shape,r=t.runtime?.x??t.pos.x,i=t.runtime?.y??t.pos.y;return t.runtime?.width!==void 0?e=t.runtime.width:"w"in n?e=n.w:"r"in n?e=n.r*2:"rx"in n&&"ry"in n?(e=n.rx*2,o=n.ry*2):"size"in n?e=n.size:"outerR"in n&&(e=n.outerR*2),t.runtime?.height!==void 0?o=t.runtime.height:"h"in n?o=n.h:o===0&&(o=e),{x:r-e/2,y:i-o/2,w:e,h:o}}function pt(t,e){let o=W(t);if(!dt(e,o))return false;let n=t.shape,r={x:t.runtime?.x??t.pos.x,y:t.runtime?.y??t.pos.y};if(n.kind==="circle"){let i=t.runtime?.radius??n.r;return Q(e,r,i)}if(n.kind==="ellipse"){let i=t.runtime?.width!==void 0?t.runtime.width/2:n.rx,l=t.runtime?.height!==void 0?t.runtime.height/2:n.ry,s=e.x-r.x,c=e.y-r.y;return s*s/(i*i)+c*c/(l*l)<=1}return true}function mt(t,e){if(!t.compartments||t.compartments.length===0)return;let o={x:t.runtime?.x??t.pos.x,y:t.runtime?.y??t.pos.y},n=W(t),r=o.y-n.h/2,i=e.y-r;for(let l of t.compartments)if(i>=l.y&&i<l.y+l.height)return l.id}function Mt(t,e,o={}){let{edgeTolerance:n=5,portTolerance:r=10}=o;for(let i of t.nodes){if(!i.ports||i.ports.length===0)continue;let l={x:i.runtime?.x??i.pos.x,y:i.runtime?.y??i.pos.y};for(let s of i.ports){let c={x:l.x+s.offset.x,y:l.y+s.offset.y};if(Q(e,c,r))return {type:"port",nodeId:i.id,portId:s.id,position:c}}}for(let i=t.nodes.length-1;i>=0;i--){let l=t.nodes[i];if(pt(l,e)){let s=mt(l,e);return {type:"node",id:l.id,compartmentId:s}}}for(let i=t.edges.length-1;i>=0;i--){let l=t.edges[i],s=ht(t,l.id,e),c=l.hitArea??n;if(s<=c)return {type:"edge",id:l.id}}return null}function Lt(t,e){let o=[];for(let n of t.nodes){let r=W(n);!(r.x>e.x+e.w||r.x+r.w<e.x||r.y>e.y+e.h||r.y+r.h<e.y)&&o.push({type:"node",id:n.id});}for(let n of t.edges){let r=n.from?t.nodes.find($=>$.id===n.from):void 0,i=n.to?t.nodes.find($=>$.id===n.to):void 0;if(n.from&&!r||n.to&&!i||!r&&!n.fromAt&&!i&&!n.toAt)continue;let l=r?{x:r.runtime?.x??r.pos.x,y:r.runtime?.y??r.pos.y}:n.fromAt??{x:0,y:0},s=i?{x:i.runtime?.x??i.pos.x,y:i.runtime?.y??i.pos.y}:n.toAt??{x:0,y:0},c=Math.min(l.x,s.x)-10,u=Math.max(l.x,s.x)+10,a=Math.min(l.y,s.y)-10,d=Math.max(l.y,s.y)+10;!(c>e.x+e.w||u<e.x||a>e.y+e.h||d<e.y)&&o.push({type:"edge",id:n.id});}return o}function wt(t,e,o){let{maxDistance:n}=o,r=null,i=n*n;for(let l of t.nodes){if(!l.ports)continue;let s={x:l.runtime?.x??l.pos.x,y:l.runtime?.y??l.pos.y};for(let c of l.ports){let u={x:s.x+c.offset.x,y:s.y+c.offset.y},a=Z(e,u);a<=i&&(i=a,r={nodeId:l.id,portId:c.id,position:u,distance:Math.sqrt(a)});}}return r}function ht(t,e,o){let n=t.edges.find(a=>a.id===e);if(!n)return 1/0;let r=n.from?t.nodes.find(a=>a.id===n.from):null,i=n.to?t.nodes.find(a=>a.id===n.to):null;if(n.from&&!r||n.to&&!i||!r&&!n.fromAt&&!i&&!n.toAt)return 1/0;let{start:l,end:s}=G(r??null,i??null,n),c=_(l,s,n.routing,n.waypoints),u=yt(c.d,10);return xt(o,u)}exports.a=gt;exports.b=et;exports.c=bt;exports.d=G;exports.e=_;exports.f=$t;exports.g=dt;exports.h=Z;exports.i=W;exports.j=Mt;exports.k=Lt;exports.l=wt;exports.m=ht;
@@ -0,0 +1 @@
1
+ var E=Symbol("vizcraft.overlay.runtimeDirty");var k=Symbol("vizcraft.adapterExtensions");function V(r){let i=r[k];return Array.isArray(i)?i:[]}function T(r){return typeof r=="number"&&Number.isFinite(r)}function z(r,i){return `${r}:${i}`}var S=class{cursorMs=0;currentTarget=null;tweens=[];adapterExtensions=[];extendAdapter(i){return this.adapterExtensions.push(i),this}node(i){return this.currentTarget=z("node",i),this}overlay(i){return this.currentTarget=z("overlay",i),this}edge(i,g,b){let m=g===void 0?i:b??`${i}->${g}`;return this.currentTarget=z("edge",m),this}at(i){return this.cursorMs=Math.max(0,i),this}wait(i){return this.cursorMs=Math.max(0,this.cursorMs+Math.max(0,i)),this}to(i,g){if(!this.currentTarget)throw new Error("AnimationBuilder.to(): no target selected (call node(...), edge(...), or overlay(...))");let b=Math.max(0,g.duration),m=g.easing,l=g.from;for(let[u,y]of Object.entries(i)){if(!T(y))continue;let h={kind:"tween",target:this.currentTarget,property:u,to:y,duration:b,delay:this.cursorMs,easing:m},x=l?.[u];T(x)&&(h.from=x),this.tweens.push(h);}return this.cursorMs+=b,this}build(){let i={version:"viz-anim/1",tweens:[...this.tweens]};return this.adapterExtensions.length>0&&(i[k]=[...this.adapterExtensions]),i}};function D(r){let i=new S;return r(i),i.build()}function R(r,i=0,g=1){return Math.max(i,Math.min(g,r))}var H={linear:r=>r,easeIn:r=>r*r,easeOut:r=>1-(1-r)*(1-r),easeInOut:r=>r<.5?2*r*r:1-Math.pow(-2*r+2,2)/2};function P(r){let i=null,g=[],b=0,m=0,l=false,u=null,y=0,h=false;function x(o){let e=o.tweens.map((s,f)=>{let d=s.delay??0,v=d+s.duration;return Object.assign({},s,{start:d,end:v,_from:s.from??0,_i:f})}),t=new Map;for(let s of e){let f=`${String(s.target)}|${String(s.property)}`,d=t.get(f);d||(d={key:f,target:s.target,property:s.property,base:0,tweens:[]},t.set(f,d)),d.tweens.push(s);}let n=Array.from(t.values());for(let s of n)s.tweens.sort((f,d)=>f.start!==d.start?f.start-d.start:f._i-d._i);let c=e.reduce((s,f)=>Math.max(s,f.end),0);return {tracks:n,dur:c}}function A(){if(!(h||!i)){for(let o of g){let e=r.get(o.target,o.property);o.base=typeof e=="number"?e:0;let t=null;for(let n of o.tweens)n.from!==void 0?n._from=n.from:t&&t.end<=n.start?n._from=t.to:n._from=o.base,t=n;}h=true;}}function w(o){for(let e of g){let t=e.tweens,n=0,c=t.length-1,s=-1;for(;n<=c;){let d=n+c>>1;t[d].start<=o?(s=d,n=d+1):c=d-1;}let f;if(s===-1)f=e.base;else {let d=t[s],v=o-d.start;if(v<=0)f=d._from;else if(d.duration<=0)f=d.to;else if(v>=d.duration)f=d.to;else {let C=R(v/d.duration,0,1),M=H[d.easing??"linear"],I=M(C);f=d._from+(d.to-d._from)*I;}}r.set(e.target,e.property,f);}r.flush?.();}function a(o){if(!l)return;let e=o-y;if(y=o,m=Math.min(b,m+e),w(m),m>=b){l=false,u=null;return}u=globalThis.requestAnimationFrame(a);}let p={load(o){i=o;let e=x(o);return g=e.tracks,b=e.dur,m=0,h=false,u!=null&&(globalThis.cancelAnimationFrame(u),u=null),l=false,A(),w(0),p},play(){i&&(A(),!l&&(l=true,y=performance.now(),u=globalThis.requestAnimationFrame(a)));},pause(){l&&(l=false,u!=null&&(globalThis.cancelAnimationFrame(u),u=null));},seek(o){i&&(A(),m=R(o,0,b),w(m));},stop(){i&&(u!=null&&(globalThis.cancelAnimationFrame(u),u=null),l=false,m=0,A(),w(0));},isPlaying(){return l},time(){return m},duration(){return b}};return p}function N(r){let{flush:i}=r,g={},b={},m={},l={};function u(a,p){g[a]=p;}function y(a,p,o){o.get&&(m[a]=m[a]??{},m[a][p]=o.get),o.set&&(l[a]=l[a]??{},l[a][p]=o.set);}function h(a,p){let o=g[a];if(o){if(p&&p!==o)throw new Error(`Animation adapter: kind "${a}" already registered with a different resolver`);if(b[a])return b[a];let t={prop(n,c){return y(a,n,c),t}};return b[a]=t,t}if(!p)throw new Error(`Animation adapter: kind "${a}" is not registered yet`);u(a,p);let e={prop(t,n){return y(a,t,n),e}};return b[a]=e,e}function x(a){let p=String(a).indexOf(":");if(p===-1)return;let o=String(a).slice(0,p),e=String(a).slice(p+1),t=g[o];if(!t)return;let n=t(e);if(n!==void 0)return {kind:o,el:n}}function A(a,p){let o=x(a);if(!o)return;let{kind:e,el:t}=o,c=(m[e]??{})[String(p)];if(c)return c(t)}function w(a,p,o){let e=x(a);if(!e)return;let{kind:t,el:n}=e,s=(l[t]??{})[String(p)];s&&s(n,o);}return {get:A,set:w,flush:i,kind:h,register:y}}function O(r,i){let g=new Map(r.nodes.map(e=>[e.id,e])),b=new Map(r.edges.map(e=>[e.id,e])),m=r.overlays??[],l=new Map;for(let e of m){let t=e.key??e.id;l.set(t,e);}let u=N({flush:i}),y=u.kind("node",e=>g.get(e)),h=u.kind("edge",e=>b.get(e)),x=u.kind("overlay",e=>l.get(e));y.prop("x",{get:e=>{let t=e;return t.runtime?.x??t.pos.x},set:(e,t)=>{let n=e;n.runtime=n.runtime??{},n.runtime.x=t;}}).prop("y",{get:e=>{let t=e;return t.runtime?.y??t.pos.y},set:(e,t)=>{let n=e;n.runtime=n.runtime??{},n.runtime.y=t;}}).prop("opacity",{get:e=>{let t=e;return t.runtime?.opacity??t.style?.opacity??1},set:(e,t)=>{let n=e;n.runtime=n.runtime??{},n.runtime.opacity=t;}}).prop("scale",{get:e=>e.runtime?.scale??1,set:(e,t)=>{let n=e;n.runtime=n.runtime??{},n.runtime.scale=t;}}).prop("rotation",{get:e=>e.runtime?.rotation,set:(e,t)=>{let n=e;n.runtime=n.runtime??{},n.runtime.rotation=t;}}),h.prop("opacity",{get:e=>e.runtime?.opacity??1,set:(e,t)=>{let n=e;n.runtime=n.runtime??{},n.runtime.opacity=t;}}).prop("strokeDashoffset",{get:e=>e.runtime?.strokeDashoffset,set:(e,t)=>{let n=e;n.runtime=n.runtime??{},n.runtime.strokeDashoffset=t;}});let A=(e,t)=>{let s=e.params?.[t];return typeof s=="number"&&Number.isFinite(s)?s:void 0},w=(e,t,n)=>{let c=e,s=c.params,f=s&&typeof s=="object"&&!Array.isArray(s)?s:{};f[t]=n,c.params=f,c[E]=true;},a=e=>{let t=String(e);if(!t.startsWith("overlay:"))return;let n=t.slice(8);return l.get(n)};x.prop("progress",{get:e=>A(e,"progress"),set:(e,t)=>w(e,"progress",t)});let p=u.get,o=u.set;return {...u,get(e,t){let n=p(e,t);if(n!==void 0)return n;let c=a(e);if(c)return A(c,String(t))},set(e,t,n){o(e,t,n);let c=a(e);c&&w(c,String(t),n);}}}function L(r){let i=O(r.scene,r.requestRender);return r.extendAdapter?.(i),P(i)}function W(r){let i=r.builder.build();return L({scene:i,requestRender:()=>r.builder.patchRuntime(r.container),extendAdapter:r.extendAdapter})}function Q(r){let i=V(r.spec),g=i.length>0||r.extendAdapter?m=>{for(let l of i)l(m);r.extendAdapter?.(m);}:void 0,b=W({builder:r.builder,container:r.container,extendAdapter:g});return b.load(r.spec),r.autoPlay!==false&&b.play(),b}export{E as a,V as b,S as c,D as d,L as e,W as f,Q as g};
@@ -0,0 +1 @@
1
+ 'use strict';function s(i){if(i==null)return i;if(typeof i!="function"){if(Array.isArray(i))return i.map(e=>s(e)).filter(e=>e!==void 0);if(typeof i=="object"){let e={};for(let[n,o]of Object.entries(i)){let r=s(o);r!==void 0&&(e[n]=r);}return e}return i}}function t(i){let e=s(i.nodes),n=s(i.edges),o=s(i.overlays),r=s(i.animationSpecs),a={version:"vizcraft/1",viewBox:{...i.viewBox},nodes:e,edges:n};return i.grid&&(a.grid={...i.grid}),o&&o.length>0&&(a.overlays=o),r&&r.length>0&&(a.animationSpecs=r),a}function d(i){if(!i||typeof i!="object")throw new Error("deserializeScene: payload must be an object");let e=i;if(e.version!=="vizcraft/1")throw new Error(`deserializeScene: unsupported version ${e.version}`);if(!e.viewBox||typeof e.viewBox!="object")throw new Error("deserializeScene: missing or invalid viewBox");if(!Array.isArray(e.nodes))throw new Error("deserializeScene: missing or invalid nodes array");if(!Array.isArray(e.edges))throw new Error("deserializeScene: missing or invalid edges array");let n={viewBox:{...e.viewBox},nodes:e.nodes,edges:e.edges};return e.grid&&(n.grid={...e.grid}),e.overlays&&(n.overlays=e.overlays),e.animationSpecs&&(n.animationSpecs=e.animationSpecs),n}exports.a=t;exports.b=d;
@@ -0,0 +1 @@
1
+ function s(i){if(i==null)return i;if(typeof i!="function"){if(Array.isArray(i))return i.map(e=>s(e)).filter(e=>e!==void 0);if(typeof i=="object"){let e={};for(let[n,o]of Object.entries(i)){let r=s(o);r!==void 0&&(e[n]=r);}return e}return i}}function t(i){let e=s(i.nodes),n=s(i.edges),o=s(i.overlays),r=s(i.animationSpecs),a={version:"vizcraft/1",viewBox:{...i.viewBox},nodes:e,edges:n};return i.grid&&(a.grid={...i.grid}),o&&o.length>0&&(a.overlays=o),r&&r.length>0&&(a.animationSpecs=r),a}function d(i){if(!i||typeof i!="object")throw new Error("deserializeScene: payload must be an object");let e=i;if(e.version!=="vizcraft/1")throw new Error(`deserializeScene: unsupported version ${e.version}`);if(!e.viewBox||typeof e.viewBox!="object")throw new Error("deserializeScene: missing or invalid viewBox");if(!Array.isArray(e.nodes))throw new Error("deserializeScene: missing or invalid nodes array");if(!Array.isArray(e.edges))throw new Error("deserializeScene: missing or invalid edges array");let n={viewBox:{...e.viewBox},nodes:e.nodes,edges:e.edges};return e.grid&&(n.grid={...e.grid}),e.overlays&&(n.overlays=e.overlays),e.animationSpecs&&(n.animationSpecs=e.animationSpecs),n}export{t as a,d as b};
@@ -0,0 +1 @@
1
+ 'use strict';var E=Symbol("vizcraft.overlay.runtimeDirty");var k=Symbol("vizcraft.adapterExtensions");function V(r){let i=r[k];return Array.isArray(i)?i:[]}function T(r){return typeof r=="number"&&Number.isFinite(r)}function z(r,i){return `${r}:${i}`}var S=class{cursorMs=0;currentTarget=null;tweens=[];adapterExtensions=[];extendAdapter(i){return this.adapterExtensions.push(i),this}node(i){return this.currentTarget=z("node",i),this}overlay(i){return this.currentTarget=z("overlay",i),this}edge(i,g,b){let m=g===void 0?i:b??`${i}->${g}`;return this.currentTarget=z("edge",m),this}at(i){return this.cursorMs=Math.max(0,i),this}wait(i){return this.cursorMs=Math.max(0,this.cursorMs+Math.max(0,i)),this}to(i,g){if(!this.currentTarget)throw new Error("AnimationBuilder.to(): no target selected (call node(...), edge(...), or overlay(...))");let b=Math.max(0,g.duration),m=g.easing,l=g.from;for(let[u,y]of Object.entries(i)){if(!T(y))continue;let h={kind:"tween",target:this.currentTarget,property:u,to:y,duration:b,delay:this.cursorMs,easing:m},x=l?.[u];T(x)&&(h.from=x),this.tweens.push(h);}return this.cursorMs+=b,this}build(){let i={version:"viz-anim/1",tweens:[...this.tweens]};return this.adapterExtensions.length>0&&(i[k]=[...this.adapterExtensions]),i}};function D(r){let i=new S;return r(i),i.build()}function R(r,i=0,g=1){return Math.max(i,Math.min(g,r))}var H={linear:r=>r,easeIn:r=>r*r,easeOut:r=>1-(1-r)*(1-r),easeInOut:r=>r<.5?2*r*r:1-Math.pow(-2*r+2,2)/2};function P(r){let i=null,g=[],b=0,m=0,l=false,u=null,y=0,h=false;function x(o){let e=o.tweens.map((s,f)=>{let d=s.delay??0,v=d+s.duration;return Object.assign({},s,{start:d,end:v,_from:s.from??0,_i:f})}),t=new Map;for(let s of e){let f=`${String(s.target)}|${String(s.property)}`,d=t.get(f);d||(d={key:f,target:s.target,property:s.property,base:0,tweens:[]},t.set(f,d)),d.tweens.push(s);}let n=Array.from(t.values());for(let s of n)s.tweens.sort((f,d)=>f.start!==d.start?f.start-d.start:f._i-d._i);let c=e.reduce((s,f)=>Math.max(s,f.end),0);return {tracks:n,dur:c}}function A(){if(!(h||!i)){for(let o of g){let e=r.get(o.target,o.property);o.base=typeof e=="number"?e:0;let t=null;for(let n of o.tweens)n.from!==void 0?n._from=n.from:t&&t.end<=n.start?n._from=t.to:n._from=o.base,t=n;}h=true;}}function w(o){for(let e of g){let t=e.tweens,n=0,c=t.length-1,s=-1;for(;n<=c;){let d=n+c>>1;t[d].start<=o?(s=d,n=d+1):c=d-1;}let f;if(s===-1)f=e.base;else {let d=t[s],v=o-d.start;if(v<=0)f=d._from;else if(d.duration<=0)f=d.to;else if(v>=d.duration)f=d.to;else {let C=R(v/d.duration,0,1),M=H[d.easing??"linear"],I=M(C);f=d._from+(d.to-d._from)*I;}}r.set(e.target,e.property,f);}r.flush?.();}function a(o){if(!l)return;let e=o-y;if(y=o,m=Math.min(b,m+e),w(m),m>=b){l=false,u=null;return}u=globalThis.requestAnimationFrame(a);}let p={load(o){i=o;let e=x(o);return g=e.tracks,b=e.dur,m=0,h=false,u!=null&&(globalThis.cancelAnimationFrame(u),u=null),l=false,A(),w(0),p},play(){i&&(A(),!l&&(l=true,y=performance.now(),u=globalThis.requestAnimationFrame(a)));},pause(){l&&(l=false,u!=null&&(globalThis.cancelAnimationFrame(u),u=null));},seek(o){i&&(A(),m=R(o,0,b),w(m));},stop(){i&&(u!=null&&(globalThis.cancelAnimationFrame(u),u=null),l=false,m=0,A(),w(0));},isPlaying(){return l},time(){return m},duration(){return b}};return p}function N(r){let{flush:i}=r,g={},b={},m={},l={};function u(a,p){g[a]=p;}function y(a,p,o){o.get&&(m[a]=m[a]??{},m[a][p]=o.get),o.set&&(l[a]=l[a]??{},l[a][p]=o.set);}function h(a,p){let o=g[a];if(o){if(p&&p!==o)throw new Error(`Animation adapter: kind "${a}" already registered with a different resolver`);if(b[a])return b[a];let t={prop(n,c){return y(a,n,c),t}};return b[a]=t,t}if(!p)throw new Error(`Animation adapter: kind "${a}" is not registered yet`);u(a,p);let e={prop(t,n){return y(a,t,n),e}};return b[a]=e,e}function x(a){let p=String(a).indexOf(":");if(p===-1)return;let o=String(a).slice(0,p),e=String(a).slice(p+1),t=g[o];if(!t)return;let n=t(e);if(n!==void 0)return {kind:o,el:n}}function A(a,p){let o=x(a);if(!o)return;let{kind:e,el:t}=o,c=(m[e]??{})[String(p)];if(c)return c(t)}function w(a,p,o){let e=x(a);if(!e)return;let{kind:t,el:n}=e,s=(l[t]??{})[String(p)];s&&s(n,o);}return {get:A,set:w,flush:i,kind:h,register:y}}function O(r,i){let g=new Map(r.nodes.map(e=>[e.id,e])),b=new Map(r.edges.map(e=>[e.id,e])),m=r.overlays??[],l=new Map;for(let e of m){let t=e.key??e.id;l.set(t,e);}let u=N({flush:i}),y=u.kind("node",e=>g.get(e)),h=u.kind("edge",e=>b.get(e)),x=u.kind("overlay",e=>l.get(e));y.prop("x",{get:e=>{let t=e;return t.runtime?.x??t.pos.x},set:(e,t)=>{let n=e;n.runtime=n.runtime??{},n.runtime.x=t;}}).prop("y",{get:e=>{let t=e;return t.runtime?.y??t.pos.y},set:(e,t)=>{let n=e;n.runtime=n.runtime??{},n.runtime.y=t;}}).prop("opacity",{get:e=>{let t=e;return t.runtime?.opacity??t.style?.opacity??1},set:(e,t)=>{let n=e;n.runtime=n.runtime??{},n.runtime.opacity=t;}}).prop("scale",{get:e=>e.runtime?.scale??1,set:(e,t)=>{let n=e;n.runtime=n.runtime??{},n.runtime.scale=t;}}).prop("rotation",{get:e=>e.runtime?.rotation,set:(e,t)=>{let n=e;n.runtime=n.runtime??{},n.runtime.rotation=t;}}),h.prop("opacity",{get:e=>e.runtime?.opacity??1,set:(e,t)=>{let n=e;n.runtime=n.runtime??{},n.runtime.opacity=t;}}).prop("strokeDashoffset",{get:e=>e.runtime?.strokeDashoffset,set:(e,t)=>{let n=e;n.runtime=n.runtime??{},n.runtime.strokeDashoffset=t;}});let A=(e,t)=>{let s=e.params?.[t];return typeof s=="number"&&Number.isFinite(s)?s:void 0},w=(e,t,n)=>{let c=e,s=c.params,f=s&&typeof s=="object"&&!Array.isArray(s)?s:{};f[t]=n,c.params=f,c[E]=true;},a=e=>{let t=String(e);if(!t.startsWith("overlay:"))return;let n=t.slice(8);return l.get(n)};x.prop("progress",{get:e=>A(e,"progress"),set:(e,t)=>w(e,"progress",t)});let p=u.get,o=u.set;return {...u,get(e,t){let n=p(e,t);if(n!==void 0)return n;let c=a(e);if(c)return A(c,String(t))},set(e,t,n){o(e,t,n);let c=a(e);c&&w(c,String(t),n);}}}function L(r){let i=O(r.scene,r.requestRender);return r.extendAdapter?.(i),P(i)}function W(r){let i=r.builder.build();return L({scene:i,requestRender:()=>r.builder.patchRuntime(r.container),extendAdapter:r.extendAdapter})}function Q(r){let i=V(r.spec),g=i.length>0||r.extendAdapter?m=>{for(let l of i)l(m);r.extendAdapter?.(m);}:void 0,b=W({builder:r.builder,container:r.container,extendAdapter:g});return b.load(r.spec),r.autoPlay!==false&&b.play(),b}exports.a=E;exports.b=V;exports.c=S;exports.d=D;exports.e=L;exports.f=W;exports.g=Q;
@@ -0,0 +1,2 @@
1
+ var A=class{icons=new Map;register(n,e){return this.icons.set(n,e),this}get(n){return this.icons.get(n)}},Q='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="12" cy="6" rx="7" ry="3" /><path d="M5 6v12c0 1.66 3.13 3 7 3s7-1.34 7-3V6" /><path d="M5 12c0 1.66 3.13 3 7 3s7-1.34 7-3" /><path d="M5 18c0 1.66 3.13 3 7 3s7-1.34 7-3" /></svg>',U='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="4" width="14" height="6" rx="1" /><rect x="5" y="14" width="14" height="6" rx="1" /><path d="M8 7h0" /><path d="M8 17h0" /></svg>',F='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 18h10.2a3.8 3.8 0 0 0 .7-7.54A5.8 5.8 0 0 0 7.28 8.2 4.6 4.6 0 0 0 7.5 18Z" /></svg>',J='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="3" /><path d="M6 20c0-3.3 2.7-6 6-6s6 2.7 6 6" /></svg>',S=new A().register("database",Q).register("server",U).register("cloud",F).register("person",J);function Bt(t,n){S.register(t,n);}function N(t){return {x:t.runtime?.x??t.pos.x,y:t.runtime?.y??t.pos.y}}function Z(t){let n={...t.shape};return t.runtime?.width!==void 0&&("w"in n&&(n.w=t.runtime.width),"rx"in n&&n.kind==="ellipse"&&(n.rx=t.runtime.width/2)),t.runtime?.height!==void 0&&("h"in n&&(n.h=t.runtime.height),"ry"in n&&n.kind==="ellipse"&&(n.ry=t.runtime.height/2)),t.runtime?.radius!==void 0&&("r"in n&&(n.r=t.runtime.radius),"outerR"in n&&(n.outerR=t.runtime.radius)),n}var m=Math.PI/180;function g(t,n,e,r){let o=n*m,i=Math.cos(o),c=Math.sin(o);if(i===0&&c===0)return {...t};let a=Math.min(e/Math.abs(i||1e-6),r/Math.abs(c||1e-6));return {x:t.x+i*a,y:t.y+c*a}}function V(t,n,e){let r=n/2,o=e/2;return `${t.x},${t.y-o} ${t.x+r},${t.y} ${t.x},${t.y+o} ${t.x-r},${t.y}`}var tt={kind:"circle",tagName:"circle",applyGeometry(t,n,e){t.setAttribute("cx",String(e.x)),t.setAttribute("cy",String(e.y)),t.setAttribute("r",String(n.r));},svgMarkup(t,n,e){return `<circle cx="${n.x}" cy="${n.y}" r="${t.r}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=Math.hypot(r,o)||1,c=e.r/i;return {x:t.x+r*c,y:t.y+o*c}},anchorAtAngle(t,n,e){let r=n*m;return {x:t.x+e.r*Math.cos(r),y:t.y+e.r*Math.sin(r)}}},nt={kind:"rect",tagName:"rect",applyGeometry(t,n,e){t.setAttribute("x",String(e.x-n.w/2)),t.setAttribute("y",String(e.y-n.h/2)),t.setAttribute("width",String(n.w)),t.setAttribute("height",String(n.h)),n.rx!==void 0&&t.setAttribute("rx",String(n.rx));},svgMarkup(t,n,e){return `<rect x="${n.x-t.w/2}" y="${n.y-t.h/2}" width="${t.w}" height="${t.h}" rx="${t.rx||0}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}},et={kind:"diamond",tagName:"polygon",applyGeometry(t,n,e){t.setAttribute("points",V(e,n.w,n.h));},svgMarkup(t,n,e){return `<polygon points="${V(n,t.w,t.h)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.abs(r)/i+Math.abs(o)/c,s=a===0?0:1/a;return {x:t.x+r*s,y:t.y+o*s}},anchorAtAngle(t,n,e){let r=n*m,o=Math.cos(r),i=Math.sin(r);if(o===0&&i===0)return {...t};let c=e.w/2,a=e.h/2,s=Math.abs(o)/c+Math.abs(i)/a,d=s===0?0:1/s;return {x:t.x+o*d,y:t.y+i*d}}};function P(t,n){let e=t.w/2,r=t.arcHeight??Math.round(t.h*.15),o=n.y-t.h/2,i=n.y+t.h/2,c=n.x-e,a=n.x+e,s=`M ${c} ${o} A ${e} ${r} 0 0 1 ${a} ${o} V ${i} A ${e} ${r} 0 0 1 ${c} ${i} V ${o} Z`;return {rx:e,ry:r,topY:o,bottomY:i,x0:c,x1:a,bodyD:s}}var b="http://www.w3.org/2000/svg",rt="http://www.w3.org/1999/xlink";function k(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function z(t,n,e){let r=t.trim();return r.startsWith("<svg")?r.replace(/<svg\b([^>]*)>/,(o,i)=>`<svg${i.replace(/\swidth="[^"]*"/g,"").replace(/\sheight="[^"]*"/g,"")} width="${n}" height="${e}">`):t}function E(t,n,e){let r=t.trim();return r.startsWith("<svg")?z(r,n,e):`<svg width="${n}" height="${e}" viewBox="0 0 ${n} ${e}" xmlns="http://www.w3.org/2000/svg">${t}</svg>`}function G(t){return S.get(t)}var ot={kind:"cylinder",tagName:"g",applyGeometry(t,n,e){let{rx:r,ry:o,topY:i,bodyD:c}=P(n,e),a=t.querySelector('[data-viz-cyl="body"]');a||(a=document.createElementNS(b,"path"),a.setAttribute("data-viz-cyl","body"),t.appendChild(a)),a.setAttribute("d",c);let s=t.querySelector('[data-viz-cyl="cap"]');s||(s=document.createElementNS(b,"ellipse"),s.setAttribute("data-viz-cyl","cap"),t.appendChild(s)),s.setAttribute("cx",String(e.x)),s.setAttribute("cy",String(i)),s.setAttribute("rx",String(r)),s.setAttribute("ry",String(o));},svgMarkup(t,n,e){let{rx:r,ry:o,topY:i,bodyD:c}=P(t,n);return `<g class="viz-node-shape" data-viz-role="node-shape"${e}><path d="${c}" data-viz-cyl="body"/><ellipse cx="${n.x}" cy="${i}" rx="${r}" ry="${o}" data-viz-cyl="cap"/>`+"</g>"},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}};function p(t,n,e){let r=[],o=e==="pointy"?-Math.PI/2:0;for(let i=0;i<6;i++){let c=o+Math.PI/3*i,a=t.x+n*Math.cos(c),s=t.y+n*Math.sin(c);r.push(`${a},${s}`);}return r.join(" ")}var it={kind:"hexagon",tagName:"polygon",applyGeometry(t,n,e){let r=n.orientation??"pointy";t.setAttribute("points",p(e,n.r,r));},svgMarkup(t,n,e){let r=t.orientation??"pointy";return `<polygon points="${p(n,t.r,r)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=Math.hypot(r,o)||1,c=e.r/i;return {x:t.x+r*c,y:t.y+o*c}},anchorAtAngle(t,n,e){let r=n*m;return {x:t.x+e.r*Math.cos(r),y:t.y+e.r*Math.sin(r)}}},ct={kind:"ellipse",tagName:"ellipse",applyGeometry(t,n,e){t.setAttribute("cx",String(e.x)),t.setAttribute("cy",String(e.y)),t.setAttribute("rx",String(n.rx)),t.setAttribute("ry",String(n.ry));},svgMarkup(t,n,e){return `<ellipse cx="${n.x}" cy="${n.y}" rx="${t.rx}" ry="${t.ry}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=Math.sqrt(e.rx*e.rx*o*o+e.ry*e.ry*r*r)||1;return {x:t.x+e.rx*e.ry*r/i,y:t.y+e.rx*e.ry*o/i}},anchorAtAngle(t,n,e){let r=n*m;return {x:t.x+e.rx*Math.cos(r),y:t.y+e.ry*Math.sin(r)}}};function L(t,n){let e=Math.PI/180,r=t.startAngle*e,o=t.endAngle*e,i=t.r,c=n.x+i*Math.cos(r),a=n.y+i*Math.sin(r),s=n.x+i*Math.cos(o),d=n.y+i*Math.sin(o),h=((t.endAngle-t.startAngle)%360+360)%360>180?1:0;return t.closed!==false?`M ${n.x} ${n.y} L ${c} ${a} A ${i} ${i} 0 ${h} 1 ${s} ${d} Z`:`M ${c} ${a} A ${i} ${i} 0 ${h} 1 ${s} ${d}`}var at={kind:"arc",tagName:"path",applyGeometry(t,n,e){t.setAttribute("d",L(n,e));},svgMarkup(t,n,e){return `<path d="${L(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=Math.hypot(r,o)||1,c=e.r/i;return {x:t.x+r*c,y:t.y+o*c}},anchorAtAngle(t,n,e){let r=n*m;return {x:t.x+e.r*Math.cos(r),y:t.y+e.r*Math.sin(r)}}};function R(t,n){let e=t.bodyWidth/2,r=t.headWidth/2,o=t.length/2,i=o-t.headLength,c=t.direction??"right",a=c==="left"?Math.PI:c==="up"?-Math.PI/2:c==="down"?Math.PI/2:0,s=Math.cos(a),d=Math.sin(a);return [[-o,-e],[i,-e],[i,-r],[o,0],[i,r],[i,e],[-o,e]].map(([h,x])=>{let y=h*s-x*d,w=h*d+x*s;return `${n.x+y},${n.y+w}`}).join(" ")}var st={kind:"blockArrow",tagName:"polygon",applyGeometry(t,n,e){t.setAttribute("points",R(n,e));},svgMarkup(t,n,e){return `<polygon points="${R(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.direction??"right",c=i==="up"||i==="down"?e.headWidth/2:e.length/2,a=i==="up"||i==="down"?e.length/2:e.headWidth/2,s=Math.min(c/Math.abs(r||1e-6),a/Math.abs(o||1e-6));return {x:t.x+r*s,y:t.y+o*s}},anchorAtAngle(t,n,e){let r=e.direction??"right",o=r==="up"||r==="down"?e.headWidth/2:e.length/2,i=r==="up"||r==="down"?e.length/2:e.headWidth/2;return g(t,n,o,i)}};function I(t,n){let e=t.w/2,r=t.h/2,o=Math.min(t.rx??0,e,r),i=t.pointerSide??"bottom",c=t.pointerHeight??Math.round(t.h*.25),a=t.pointerWidth??Math.round(t.w*.2),s=t.pointerPosition??.3,d=n.x-e,u=n.x+e,h=n.y-r,x=n.y+r,y=[],w=($,l,f)=>{if(o===0)return "";let B=f+Math.PI/2,Y=$+o*Math.cos(B),X=l+o*Math.sin(B);return `A ${o} ${o} 0 0 1 ${Y} ${X}`};if(y.push(`M ${d+o} ${h}`),i==="top"){let $=t.w-2*o,l=d+o+$*s,f=l+a;y.push(`L ${l} ${h}`),y.push(`L ${(l+f)/2} ${h-c}`),y.push(`L ${Math.min(f,u-o)} ${h}`);}if(y.push(`L ${u-o} ${h}`),y.push(w(u-o,h+o,-Math.PI/2)),i==="right"){let $=t.h-2*o,l=h+o+$*s,f=l+a;y.push(`L ${u} ${l}`),y.push(`L ${u+c} ${(l+f)/2}`),y.push(`L ${u} ${Math.min(f,x-o)}`);}if(y.push(`L ${u} ${x-o}`),y.push(w(u-o,x-o,0)),i==="bottom"){let $=t.w-2*o,l=u-o-$*s,f=l-a;y.push(`L ${l} ${x}`),y.push(`L ${(f+l)/2} ${x+c}`),y.push(`L ${Math.max(f,d+o)} ${x}`);}if(y.push(`L ${d+o} ${x}`),y.push(w(d+o,x-o,Math.PI/2)),i==="left"){let $=t.h-2*o,l=x-o-$*s,f=l-a;y.push(`L ${d} ${l}`),y.push(`L ${d-c} ${(f+l)/2}`),y.push(`L ${d} ${Math.max(f,h+o)}`);}return y.push(`L ${d} ${h+o}`),y.push(w(d+o,h+o,Math.PI)),y.push("Z"),y.filter(Boolean).join(" ")}var dt={kind:"callout",tagName:"path",applyGeometry(t,n,e){t.setAttribute("d",I(n,e));},svgMarkup(t,n,e){return `<path d="${I(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}};function C(t,n){let e=t.w/2,r=t.h/2,o=n.x,i=n.y,c=[[-0.35,-0.85,-0.75,-1.2,-1.1,-0.5,-0.95,-0.2],[-0.95,-0.2,-1.2,.3,-0.9,.9,-0.45,.85],[-0.45,.85,-0.15,1.15,.35,1.15,.55,.8],[.55,.8,.85,.95,1.15,.45,1,.05],[1,.05,1.2,-0.45,.85,-0.95,.4,-0.85],[.4,-0.85,.05,-1.2,-0.45,-1.1,-0.35,-0.85]],a=[`M ${o+c[0][0]*e} ${i+c[0][1]*r}`];for(let[,,s,d,u,h,x,y]of c)a.push(`C ${o+s*e} ${i+d*r} ${o+u*e} ${i+h*r} ${o+x*e} ${i+y*r}`);return a.push("Z"),a.join(" ")}var ht={kind:"cloud",tagName:"path",applyGeometry(t,n,e){t.setAttribute("d",C(n,e));},svgMarkup(t,n,e){return `<path d="${C(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.sqrt(i*i*o*o+c*c*r*r)||1;return {x:t.x+i*c*r/a,y:t.y+i*c*o/a}},anchorAtAngle(t,n,e){let r=n*m,o=e.w/2,i=e.h/2;return {x:t.x+o*Math.cos(r),y:t.y+i*Math.sin(r)}}};function W(t,n){let e=t.size/2,r=(t.barWidth??Math.round(t.size/3))/2;return [`${n.x-r},${n.y-e}`,`${n.x+r},${n.y-e}`,`${n.x+r},${n.y-r}`,`${n.x+e},${n.y-r}`,`${n.x+e},${n.y+r}`,`${n.x+r},${n.y+r}`,`${n.x+r},${n.y+e}`,`${n.x-r},${n.y+e}`,`${n.x-r},${n.y+r}`,`${n.x-e},${n.y+r}`,`${n.x-e},${n.y-r}`,`${n.x-r},${n.y-r}`].join(" ")}var yt={kind:"cross",tagName:"polygon",applyGeometry(t,n,e){t.setAttribute("points",W(n,e));},svgMarkup(t,n,e){return `<polygon points="${W(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.size/2,c=Math.min(i/Math.abs(r||1e-6),i/Math.abs(o||1e-6));return {x:t.x+r*c,y:t.y+o*c}},anchorAtAngle(t,n,e){return g(t,n,e.size/2,e.size/2)}};function j(t,n){let e=t.w/2,r=t.h/2,o=t.depth??Math.round(t.w*.2),i={x:n.x-e,y:n.y-r},c={x:n.x+e,y:n.y-r},a={x:n.x+e,y:n.y+r},s={x:n.x-e,y:n.y+r},d={x:i.x+o,y:i.y-o},u={x:c.x+o,y:c.y-o},h={x:a.x+o,y:a.y-o};return {ftl:i,ftr:c,fbr:a,fbl:s,btl:d,btr:u,bbr:h,d:o}}function v(...t){return t.map(n=>`${n.x},${n.y}`).join(" ")}var ut={kind:"cube",tagName:"g",applyGeometry(t,n,e){let{ftl:r,ftr:o,fbr:i,fbl:c,btl:a,btr:s,bbr:d}=j(n,e),u=t.querySelector('[data-viz-cube="front"]');u||(u=document.createElementNS(b,"polygon"),u.setAttribute("data-viz-cube","front"),t.appendChild(u)),u.setAttribute("points",v(r,o,i,c));let h=t.querySelector('[data-viz-cube="top"]');h||(h=document.createElementNS(b,"polygon"),h.setAttribute("data-viz-cube","top"),t.appendChild(h)),h.setAttribute("points",v(r,o,s,a)),h.style.filter="brightness(0.85)";let x=t.querySelector('[data-viz-cube="right"]');x||(x=document.createElementNS(b,"polygon"),x.setAttribute("data-viz-cube","right"),t.appendChild(x)),x.setAttribute("points",v(o,s,d,i)),x.style.filter="brightness(0.7)";},svgMarkup(t,n,e){let{ftl:r,ftr:o,fbr:i,fbl:c,btl:a,btr:s,bbr:d}=j(t,n);return `<g class="viz-node-shape" data-viz-role="node-shape"${e}><polygon points="${v(r,o,i,c)}" data-viz-cube="front"/><polygon points="${v(r,o,s,a)}" data-viz-cube="top" style="filter:brightness(0.85)"/><polygon points="${v(o,s,d,i)}" data-viz-cube="right" style="filter:brightness(0.7)"/>`+"</g>"},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.depth??Math.round(e.w*.2),c=e.w/2+i/2,a=e.h/2+i/2,s=Math.min(c/Math.abs(r||1e-6),a/Math.abs(o||1e-6));return {x:t.x+r*s,y:t.y+o*s}},anchorAtAngle(t,n,e){let r=e.depth??Math.round(e.w*.2);return g(t,n,e.w/2+r/2,e.h/2+r/2)}},xt={kind:"path",tagName:"path",applyGeometry(t,n,e){t.setAttribute("d",n.d),t.setAttribute("transform",`translate(${e.x-n.w/2},${e.y-n.h/2})`);},svgMarkup(t,n,e){let r=n.x-t.w/2,o=n.y-t.h/2;return `<path d="${t.d}" transform="translate(${r},${o})" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}};function q(t,n){let e=t.w/2,r=t.h/2,o=t.waveHeight??Math.round(t.h*.1),i=n.x-e,c=n.x+e,a=n.y-r,s=n.y+r-o;return `M ${i} ${a} H ${c} V ${s} C ${c-e*.5} ${s+o*2}, ${i+e*.5} ${s-o}, ${i} ${s} Z`}var lt={kind:"document",tagName:"path",applyGeometry(t,n,e){t.setAttribute("d",q(n,e));},svgMarkup(t,n,e){return `<path d="${q(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}};function D(t,n){let e=t.w/2,r=t.h/2,o=t.foldSize??15,i=n.x-e,c=n.x+e,a=n.y-r,s=n.y+r;return {x0:i,x1:c,y0:a,y1:s,f:o}}var gt={kind:"note",tagName:"g",applyGeometry(t,n,e){let{x0:r,x1:o,y0:i,y1:c,f:a}=D(n,e),s=t.querySelector('[data-viz-note="body"]');s||(s=document.createElementNS(b,"polygon"),s.setAttribute("data-viz-note","body"),t.appendChild(s)),s.setAttribute("points",`${r},${i} ${o-a},${i} ${o},${i+a} ${o},${c} ${r},${c}`);let d=t.querySelector('[data-viz-note="fold"]');d||(d=document.createElementNS(b,"polygon"),d.setAttribute("data-viz-note","fold"),t.appendChild(d)),d.setAttribute("points",`${o-a},${i} ${o-a},${i+a} ${o},${i+a}`),d.style.filter="brightness(0.8)";},svgMarkup(t,n,e){let{x0:r,x1:o,y0:i,y1:c,f:a}=D(t,n),s=`${r},${i} ${o-a},${i} ${o},${i+a} ${o},${c} ${r},${c}`,d=`${o-a},${i} ${o-a},${i+a} ${o},${i+a}`;return `<g class="viz-node-shape" data-viz-role="node-shape"${e}><polygon points="${s}" data-viz-note="body"/><polygon points="${d}" data-viz-note="fold" style="filter:brightness(0.8)"/>`+"</g>"},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}};function H(t,n){let e=t.w/2,r=t.h/2,i=(t.skew??Math.round(t.w*.2))/2;return [`${n.x-e-i},${n.y+r}`,`${n.x+e-i},${n.y+r}`,`${n.x+e+i},${n.y-r}`,`${n.x-e+i},${n.y-r}`].join(" ")}var ft={kind:"parallelogram",tagName:"polygon",applyGeometry(t,n,e){t.setAttribute("points",H(n,e));},svgMarkup(t,n,e){return `<polygon points="${H(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.skew??Math.round(e.w*.2),c=e.w/2+i/2,a=e.h/2,s=Math.min(c/Math.abs(r||1e-6),a/Math.abs(o||1e-6));return {x:t.x+r*s,y:t.y+o*s}},anchorAtAngle(t,n,e){let r=e.skew??Math.round(e.w*.2);return g(t,n,e.w/2+r/2,e.h/2)}};function _(t,n){let e=t.points,r=t.outerR,o=t.innerR??Math.round(r*.4),i=[];for(let c=0;c<e*2;c++){let a=c%2===0?r:o,s=Math.PI*c/e-Math.PI/2;i.push(`${n.x+a*Math.cos(s)},${n.y+a*Math.sin(s)}`);}return i.join(" ")}var $t={kind:"star",tagName:"polygon",applyGeometry(t,n,e){t.setAttribute("points",_(n,e));},svgMarkup(t,n,e){return `<polygon points="${_(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let c=e.outerR/Math.sqrt(r*r+o*o);return {x:t.x+r*c,y:t.y+o*c}},anchorAtAngle(t,n,e){let r=n*m;return {x:t.x+e.outerR*Math.cos(r),y:t.y+e.outerR*Math.sin(r)}}};function K(t,n){let e=t.topW/2,r=t.bottomW/2,o=t.h/2;return [`${n.x-e},${n.y-o}`,`${n.x+e},${n.y-o}`,`${n.x+r},${n.y+o}`,`${n.x-r},${n.y+o}`].join(" ")}var bt={kind:"trapezoid",tagName:"polygon",applyGeometry(t,n,e){t.setAttribute("points",K(n,e));},svgMarkup(t,n,e){return `<polygon points="${K(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=Math.max(e.topW,e.bottomW)/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){let r=Math.max(e.topW,e.bottomW)/2;return g(t,n,r,e.h/2)}};function O(t,n){let e=t.w/2,r=t.h/2;switch(t.direction??"up"){case "up":return [`${n.x},${n.y-r}`,`${n.x+e},${n.y+r}`,`${n.x-e},${n.y+r}`].join(" ");case "down":return [`${n.x},${n.y+r}`,`${n.x-e},${n.y-r}`,`${n.x+e},${n.y-r}`].join(" ");case "left":return [`${n.x-e},${n.y}`,`${n.x+e},${n.y-r}`,`${n.x+e},${n.y+r}`].join(" ");case "right":return [`${n.x+e},${n.y}`,`${n.x-e},${n.y+r}`,`${n.x-e},${n.y-r}`].join(" ")}}var mt={kind:"triangle",tagName:"polygon",applyGeometry(t,n,e){t.setAttribute("points",O(n,e));},svgMarkup(t,n,e){return `<polygon points="${O(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}},wt={kind:"image",tagName:"image",applyGeometry(t,n,e){t.setAttribute("x",String(e.x-n.w/2)),t.setAttribute("y",String(e.y-n.h/2)),t.setAttribute("width",String(n.w)),t.setAttribute("height",String(n.h)),t.setAttribute("href",n.href);try{t.setAttributeNS(rt,"href",n.href);}catch{}n.preserveAspectRatio!==void 0?t.setAttribute("preserveAspectRatio",n.preserveAspectRatio):t.removeAttribute("preserveAspectRatio");},svgMarkup(t,n,e){let r=k(t.href),o=t.preserveAspectRatio!==void 0?` preserveAspectRatio="${k(t.preserveAspectRatio)}"`:"";return `<image x="${n.x-t.w/2}" y="${n.y-t.h/2}" width="${t.w}" height="${t.h}" href="${r}"${o} class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}},vt={kind:"icon",tagName:"g",applyGeometry(t,n,e){let r=e.x-n.w/2,o=e.y-n.h/2;t.setAttribute("transform",`translate(${r} ${o})`),n.color?t.setAttribute("style",`color:${n.color}`):t.removeAttribute("style");let i=G(n.id);if(!i)return;let c=t.querySelector('[data-viz-icon="content"]');c||(c=document.createElementNS(b,"g"),c.setAttribute("data-viz-icon","content"),t.appendChild(c)),c.innerHTML=z(i,n.w,n.h);},svgMarkup(t,n,e){let r=n.x-t.w/2,o=n.y-t.h/2,i=G(t.id),c=t.color?` style="color:${k(t.color)}"`:"",a=i?z(i,t.w,t.h):"";return `<g class="viz-node-shape" data-viz-role="node-shape" transform="translate(${r} ${o})"${c}${e}><g data-viz-icon="content">${a}</g></g>`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}},Mt={kind:"svg",tagName:"g",applyGeometry(t,n,e){let r=e.x-n.w/2,o=e.y-n.h/2;t.setAttribute("transform",`translate(${r} ${o})`);let i=t.querySelector('[data-viz-svg="content"]');i||(i=document.createElementNS(b,"g"),i.setAttribute("data-viz-svg","content"),t.appendChild(i)),i.innerHTML=E(n.content,n.w,n.h);},svgMarkup(t,n,e){let r=n.x-t.w/2,o=n.y-t.h/2,i=E(t.content,t.w,t.h);return `<g class="viz-node-shape" data-viz-role="node-shape" transform="translate(${r} ${o})"${e}><g data-viz-svg="content">${i}</g></g>`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}},At={circle:tt,rect:nt,diamond:et,cylinder:ot,hexagon:it,ellipse:ct,arc:at,blockArrow:st,callout:dt,cloud:ht,cross:yt,cube:ut,path:xt,document:lt,note:gt,parallelogram:ft,star:$t,trapezoid:bt,triangle:mt,image:wt,icon:vt,svg:Mt};function M(t){return At[t.kind]}function Et(t,n,e){M(n).applyGeometry(t,n,e);}function Gt(t,n,e){return M(t).svgMarkup(t,n,e)}function pt(t,n,e){let r=N(t);if(e==="center")return {x:r.x,y:r.y};let o=Z(t);return M(o).anchorBoundary(r,n,o)}function Lt(t,n){let e=N(t),r=Z(t);return M(r).anchorAtAngle(e,n,r)}function St(t){switch(t.kind){case "circle":return [{id:"top",offset:{x:0,y:-t.r},direction:270},{id:"right",offset:{x:t.r,y:0},direction:0},{id:"bottom",offset:{x:0,y:t.r},direction:90},{id:"left",offset:{x:-t.r,y:0},direction:180}];case "rect":return [{id:"top",offset:{x:0,y:-t.h/2},direction:270},{id:"right",offset:{x:t.w/2,y:0},direction:0},{id:"bottom",offset:{x:0,y:t.h/2},direction:90},{id:"left",offset:{x:-t.w/2,y:0},direction:180}];case "diamond":return [{id:"top",offset:{x:0,y:-t.h/2},direction:270},{id:"right",offset:{x:t.w/2,y:0},direction:0},{id:"bottom",offset:{x:0,y:t.h/2},direction:90},{id:"left",offset:{x:-t.w/2,y:0},direction:180}];case "ellipse":return [{id:"top",offset:{x:0,y:-t.ry},direction:270},{id:"right",offset:{x:t.rx,y:0},direction:0},{id:"bottom",offset:{x:0,y:t.ry},direction:90},{id:"left",offset:{x:-t.rx,y:0},direction:180}];case "hexagon":{let n=t.r;if((t.orientation??"pointy")==="pointy"){let r=n*Math.sin(Math.PI/3),o=n*Math.cos(Math.PI/3);return [{id:"top",offset:{x:0,y:-n},direction:270},{id:"top-right",offset:{x:r,y:-o},direction:330},{id:"bottom-right",offset:{x:r,y:o},direction:30},{id:"bottom",offset:{x:0,y:n},direction:90},{id:"bottom-left",offset:{x:-r,y:o},direction:150},{id:"top-left",offset:{x:-r,y:-o},direction:210}]}else {let r=n*Math.sin(Math.PI/3),o=n*Math.cos(Math.PI/3);return [{id:"right",offset:{x:n,y:0},direction:0},{id:"bottom-right",offset:{x:o,y:r},direction:60},{id:"bottom-left",offset:{x:-o,y:r},direction:120},{id:"left",offset:{x:-n,y:0},direction:180},{id:"top-left",offset:{x:-o,y:-r},direction:240},{id:"top-right",offset:{x:o,y:-r},direction:300}]}}case "cylinder":return [{id:"top",offset:{x:0,y:-t.h/2},direction:270},{id:"right",offset:{x:t.w/2,y:0},direction:0},{id:"bottom",offset:{x:0,y:t.h/2},direction:90},{id:"left",offset:{x:-t.w/2,y:0},direction:180}];case "triangle":{let n=t.w/2,e=t.h/2;switch(t.direction??"up"){case "up":return [{id:"top",offset:{x:0,y:-e},direction:270},{id:"bottom-right",offset:{x:n,y:e},direction:30},{id:"bottom-left",offset:{x:-n,y:e},direction:150},{id:"bottom",offset:{x:0,y:e},direction:90}];case "down":return [{id:"top-left",offset:{x:-n,y:-e},direction:210},{id:"top-right",offset:{x:n,y:-e},direction:330},{id:"bottom",offset:{x:0,y:e},direction:90},{id:"top",offset:{x:0,y:-e},direction:270}];case "left":return [{id:"left",offset:{x:-n,y:0},direction:180},{id:"top-right",offset:{x:n,y:-e},direction:330},{id:"bottom-right",offset:{x:n,y:e},direction:30},{id:"right",offset:{x:n,y:0},direction:0}];case "right":return [{id:"top-left",offset:{x:-n,y:-e},direction:210},{id:"right",offset:{x:n,y:0},direction:0},{id:"bottom-left",offset:{x:-n,y:e},direction:150},{id:"left",offset:{x:-n,y:0},direction:180}]}break}default:{let n=T(t);return [{id:"top",offset:{x:0,y:-n.hh},direction:270},{id:"right",offset:{x:n.hw,y:0},direction:0},{id:"bottom",offset:{x:0,y:n.hh},direction:90},{id:"left",offset:{x:-n.hw,y:0},direction:180}]}}}function kt(t){return t.ports??St(t.shape)}function zt(t,n){let e=kt(t),r=e.find(i=>i.id===n);if(r)return r;let o=/^p(\d+)$/.exec(n);if(o){let i=Number(o[1]);if(i>=0&&i<e.length)return e[i]}}function Rt(t,n){let e=zt(t,n);if(!e)return;let r=N(t);return {x:r.x+e.offset.x,y:r.y+e.offset.y}}function T(t){switch(t.kind){case "circle":return {hw:t.r,hh:t.r};case "rect":return {hw:t.w/2,hh:t.h/2};case "diamond":return {hw:t.w/2,hh:t.h/2};case "ellipse":return {hw:t.rx,hh:t.ry};case "hexagon":{let n=t.orientation??"pointy",e=Math.sqrt(3)/2;return n==="pointy"?{hw:t.r*e,hh:t.r}:{hw:t.r,hh:t.r*e}}case "cylinder":return {hw:t.w/2,hh:t.h/2};case "arc":return {hw:t.r,hh:t.r};case "blockArrow":{let n=t.direction??"right";return n==="up"||n==="down"?{hw:t.headWidth/2,hh:t.length/2}:{hw:t.length/2,hh:t.headWidth/2}}case "callout":{let n=t.pointerSide??"bottom",e=t.pointerHeight??Math.round(t.h*.25),r=t.w/2+(n==="left"||n==="right"?e:0),o=t.h/2+(n==="top"||n==="bottom"?e:0);return {hw:r,hh:o}}case "cloud":return {hw:t.w/2,hh:t.h/2};case "cross":return {hw:t.size/2,hh:t.size/2};case "cube":return {hw:t.w/2,hh:t.h/2};case "path":return {hw:t.w/2,hh:t.h/2};case "document":return {hw:t.w/2,hh:t.h/2};case "note":return {hw:t.w/2,hh:t.h/2};case "parallelogram":return {hw:t.w/2,hh:t.h/2};case "star":return {hw:t.outerR,hh:t.outerR};case "trapezoid":return {hw:Math.max(t.topW,t.bottomW)/2,hh:t.h/2};case "triangle":return {hw:t.w/2,hh:t.h/2};case "image":return {hw:t.w/2,hh:t.h/2};case "icon":return {hw:t.w/2,hh:t.h/2};case "svg":return {hw:t.w/2,hh:t.h/2};default:return {hw:0,hh:0}}}function It(t){let{hw:n,hh:e}=T(t);return {width:n*2,height:e*2}}
2
+ export{A as a,S as b,Bt as c,N as d,Z as e,M as f,Et as g,Gt as h,pt as i,Lt as j,St as k,kt as l,zt as m,Rt as n,It as o};
@@ -0,0 +1 @@
1
+ var L=(l,t)=>{let{nodes:n}=l,s=t?.cx??0,r=t?.cy??0,a=t?.radius??200,i=t?.startAngle??0,c=t?.sweep??360,o={nodes:{}};if(n.length===0)return o;if(n.length===1){let e=n[0];return e&&(o.nodes[e.id]={x:s,y:r}),o}let y=Math.abs(c)>=360?n.length:Math.max(1,n.length-1),u=c/y;return n.forEach((e,g)=>{let d=(i+g*u)*Math.PI/180;o.nodes[e.id]={x:s+a*Math.cos(d),y:r+a*Math.sin(d)};}),o},m=(l,t)=>{let{nodes:n}=l,s=n.length,r={nodes:{}};if(s===0)return r;let a=t?.cols??Math.ceil(Math.sqrt(s)),i=t?.x??0,c=t?.y??0,o=t?.colSpacing??100,h=t?.rowSpacing??100;return n.forEach((y,u)=>{let e=u%a,g=Math.floor(u/a);r.nodes[y.id]={x:i+e*o,y:c+g*h};}),r};export{L as a,m as b};
@@ -0,0 +1 @@
1
+ 'use strict';var L=(l,t)=>{let{nodes:n}=l,s=t?.cx??0,r=t?.cy??0,a=t?.radius??200,i=t?.startAngle??0,c=t?.sweep??360,o={nodes:{}};if(n.length===0)return o;if(n.length===1){let e=n[0];return e&&(o.nodes[e.id]={x:s,y:r}),o}let y=Math.abs(c)>=360?n.length:Math.max(1,n.length-1),u=c/y;return n.forEach((e,g)=>{let d=(i+g*u)*Math.PI/180;o.nodes[e.id]={x:s+a*Math.cos(d),y:r+a*Math.sin(d)};}),o},m=(l,t)=>{let{nodes:n}=l,s=n.length,r={nodes:{}};if(s===0)return r;let a=t?.cols??Math.ceil(Math.sqrt(s)),i=t?.x??0,c=t?.y??0,o=t?.colSpacing??100,h=t?.rowSpacing??100;return n.forEach((y,u)=>{let e=u%a,g=Math.floor(u/a);r.nodes[y.id]={x:i+e*o,y:c+g*h};}),r};exports.a=L;exports.b=m;
@@ -0,0 +1,2 @@
1
+ 'use strict';var A=class{icons=new Map;register(n,e){return this.icons.set(n,e),this}get(n){return this.icons.get(n)}},Q='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="12" cy="6" rx="7" ry="3" /><path d="M5 6v12c0 1.66 3.13 3 7 3s7-1.34 7-3V6" /><path d="M5 12c0 1.66 3.13 3 7 3s7-1.34 7-3" /><path d="M5 18c0 1.66 3.13 3 7 3s7-1.34 7-3" /></svg>',U='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="4" width="14" height="6" rx="1" /><rect x="5" y="14" width="14" height="6" rx="1" /><path d="M8 7h0" /><path d="M8 17h0" /></svg>',F='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 18h10.2a3.8 3.8 0 0 0 .7-7.54A5.8 5.8 0 0 0 7.28 8.2 4.6 4.6 0 0 0 7.5 18Z" /></svg>',J='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="3" /><path d="M6 20c0-3.3 2.7-6 6-6s6 2.7 6 6" /></svg>',S=new A().register("database",Q).register("server",U).register("cloud",F).register("person",J);function Bt(t,n){S.register(t,n);}function N(t){return {x:t.runtime?.x??t.pos.x,y:t.runtime?.y??t.pos.y}}function Z(t){let n={...t.shape};return t.runtime?.width!==void 0&&("w"in n&&(n.w=t.runtime.width),"rx"in n&&n.kind==="ellipse"&&(n.rx=t.runtime.width/2)),t.runtime?.height!==void 0&&("h"in n&&(n.h=t.runtime.height),"ry"in n&&n.kind==="ellipse"&&(n.ry=t.runtime.height/2)),t.runtime?.radius!==void 0&&("r"in n&&(n.r=t.runtime.radius),"outerR"in n&&(n.outerR=t.runtime.radius)),n}var m=Math.PI/180;function g(t,n,e,r){let o=n*m,i=Math.cos(o),c=Math.sin(o);if(i===0&&c===0)return {...t};let a=Math.min(e/Math.abs(i||1e-6),r/Math.abs(c||1e-6));return {x:t.x+i*a,y:t.y+c*a}}function V(t,n,e){let r=n/2,o=e/2;return `${t.x},${t.y-o} ${t.x+r},${t.y} ${t.x},${t.y+o} ${t.x-r},${t.y}`}var tt={kind:"circle",tagName:"circle",applyGeometry(t,n,e){t.setAttribute("cx",String(e.x)),t.setAttribute("cy",String(e.y)),t.setAttribute("r",String(n.r));},svgMarkup(t,n,e){return `<circle cx="${n.x}" cy="${n.y}" r="${t.r}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=Math.hypot(r,o)||1,c=e.r/i;return {x:t.x+r*c,y:t.y+o*c}},anchorAtAngle(t,n,e){let r=n*m;return {x:t.x+e.r*Math.cos(r),y:t.y+e.r*Math.sin(r)}}},nt={kind:"rect",tagName:"rect",applyGeometry(t,n,e){t.setAttribute("x",String(e.x-n.w/2)),t.setAttribute("y",String(e.y-n.h/2)),t.setAttribute("width",String(n.w)),t.setAttribute("height",String(n.h)),n.rx!==void 0&&t.setAttribute("rx",String(n.rx));},svgMarkup(t,n,e){return `<rect x="${n.x-t.w/2}" y="${n.y-t.h/2}" width="${t.w}" height="${t.h}" rx="${t.rx||0}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}},et={kind:"diamond",tagName:"polygon",applyGeometry(t,n,e){t.setAttribute("points",V(e,n.w,n.h));},svgMarkup(t,n,e){return `<polygon points="${V(n,t.w,t.h)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.abs(r)/i+Math.abs(o)/c,s=a===0?0:1/a;return {x:t.x+r*s,y:t.y+o*s}},anchorAtAngle(t,n,e){let r=n*m,o=Math.cos(r),i=Math.sin(r);if(o===0&&i===0)return {...t};let c=e.w/2,a=e.h/2,s=Math.abs(o)/c+Math.abs(i)/a,d=s===0?0:1/s;return {x:t.x+o*d,y:t.y+i*d}}};function P(t,n){let e=t.w/2,r=t.arcHeight??Math.round(t.h*.15),o=n.y-t.h/2,i=n.y+t.h/2,c=n.x-e,a=n.x+e,s=`M ${c} ${o} A ${e} ${r} 0 0 1 ${a} ${o} V ${i} A ${e} ${r} 0 0 1 ${c} ${i} V ${o} Z`;return {rx:e,ry:r,topY:o,bottomY:i,x0:c,x1:a,bodyD:s}}var b="http://www.w3.org/2000/svg",rt="http://www.w3.org/1999/xlink";function k(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function z(t,n,e){let r=t.trim();return r.startsWith("<svg")?r.replace(/<svg\b([^>]*)>/,(o,i)=>`<svg${i.replace(/\swidth="[^"]*"/g,"").replace(/\sheight="[^"]*"/g,"")} width="${n}" height="${e}">`):t}function E(t,n,e){let r=t.trim();return r.startsWith("<svg")?z(r,n,e):`<svg width="${n}" height="${e}" viewBox="0 0 ${n} ${e}" xmlns="http://www.w3.org/2000/svg">${t}</svg>`}function G(t){return S.get(t)}var ot={kind:"cylinder",tagName:"g",applyGeometry(t,n,e){let{rx:r,ry:o,topY:i,bodyD:c}=P(n,e),a=t.querySelector('[data-viz-cyl="body"]');a||(a=document.createElementNS(b,"path"),a.setAttribute("data-viz-cyl","body"),t.appendChild(a)),a.setAttribute("d",c);let s=t.querySelector('[data-viz-cyl="cap"]');s||(s=document.createElementNS(b,"ellipse"),s.setAttribute("data-viz-cyl","cap"),t.appendChild(s)),s.setAttribute("cx",String(e.x)),s.setAttribute("cy",String(i)),s.setAttribute("rx",String(r)),s.setAttribute("ry",String(o));},svgMarkup(t,n,e){let{rx:r,ry:o,topY:i,bodyD:c}=P(t,n);return `<g class="viz-node-shape" data-viz-role="node-shape"${e}><path d="${c}" data-viz-cyl="body"/><ellipse cx="${n.x}" cy="${i}" rx="${r}" ry="${o}" data-viz-cyl="cap"/>`+"</g>"},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}};function p(t,n,e){let r=[],o=e==="pointy"?-Math.PI/2:0;for(let i=0;i<6;i++){let c=o+Math.PI/3*i,a=t.x+n*Math.cos(c),s=t.y+n*Math.sin(c);r.push(`${a},${s}`);}return r.join(" ")}var it={kind:"hexagon",tagName:"polygon",applyGeometry(t,n,e){let r=n.orientation??"pointy";t.setAttribute("points",p(e,n.r,r));},svgMarkup(t,n,e){let r=t.orientation??"pointy";return `<polygon points="${p(n,t.r,r)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=Math.hypot(r,o)||1,c=e.r/i;return {x:t.x+r*c,y:t.y+o*c}},anchorAtAngle(t,n,e){let r=n*m;return {x:t.x+e.r*Math.cos(r),y:t.y+e.r*Math.sin(r)}}},ct={kind:"ellipse",tagName:"ellipse",applyGeometry(t,n,e){t.setAttribute("cx",String(e.x)),t.setAttribute("cy",String(e.y)),t.setAttribute("rx",String(n.rx)),t.setAttribute("ry",String(n.ry));},svgMarkup(t,n,e){return `<ellipse cx="${n.x}" cy="${n.y}" rx="${t.rx}" ry="${t.ry}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=Math.sqrt(e.rx*e.rx*o*o+e.ry*e.ry*r*r)||1;return {x:t.x+e.rx*e.ry*r/i,y:t.y+e.rx*e.ry*o/i}},anchorAtAngle(t,n,e){let r=n*m;return {x:t.x+e.rx*Math.cos(r),y:t.y+e.ry*Math.sin(r)}}};function L(t,n){let e=Math.PI/180,r=t.startAngle*e,o=t.endAngle*e,i=t.r,c=n.x+i*Math.cos(r),a=n.y+i*Math.sin(r),s=n.x+i*Math.cos(o),d=n.y+i*Math.sin(o),h=((t.endAngle-t.startAngle)%360+360)%360>180?1:0;return t.closed!==false?`M ${n.x} ${n.y} L ${c} ${a} A ${i} ${i} 0 ${h} 1 ${s} ${d} Z`:`M ${c} ${a} A ${i} ${i} 0 ${h} 1 ${s} ${d}`}var at={kind:"arc",tagName:"path",applyGeometry(t,n,e){t.setAttribute("d",L(n,e));},svgMarkup(t,n,e){return `<path d="${L(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=Math.hypot(r,o)||1,c=e.r/i;return {x:t.x+r*c,y:t.y+o*c}},anchorAtAngle(t,n,e){let r=n*m;return {x:t.x+e.r*Math.cos(r),y:t.y+e.r*Math.sin(r)}}};function R(t,n){let e=t.bodyWidth/2,r=t.headWidth/2,o=t.length/2,i=o-t.headLength,c=t.direction??"right",a=c==="left"?Math.PI:c==="up"?-Math.PI/2:c==="down"?Math.PI/2:0,s=Math.cos(a),d=Math.sin(a);return [[-o,-e],[i,-e],[i,-r],[o,0],[i,r],[i,e],[-o,e]].map(([h,x])=>{let y=h*s-x*d,w=h*d+x*s;return `${n.x+y},${n.y+w}`}).join(" ")}var st={kind:"blockArrow",tagName:"polygon",applyGeometry(t,n,e){t.setAttribute("points",R(n,e));},svgMarkup(t,n,e){return `<polygon points="${R(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.direction??"right",c=i==="up"||i==="down"?e.headWidth/2:e.length/2,a=i==="up"||i==="down"?e.length/2:e.headWidth/2,s=Math.min(c/Math.abs(r||1e-6),a/Math.abs(o||1e-6));return {x:t.x+r*s,y:t.y+o*s}},anchorAtAngle(t,n,e){let r=e.direction??"right",o=r==="up"||r==="down"?e.headWidth/2:e.length/2,i=r==="up"||r==="down"?e.length/2:e.headWidth/2;return g(t,n,o,i)}};function I(t,n){let e=t.w/2,r=t.h/2,o=Math.min(t.rx??0,e,r),i=t.pointerSide??"bottom",c=t.pointerHeight??Math.round(t.h*.25),a=t.pointerWidth??Math.round(t.w*.2),s=t.pointerPosition??.3,d=n.x-e,u=n.x+e,h=n.y-r,x=n.y+r,y=[],w=($,l,f)=>{if(o===0)return "";let B=f+Math.PI/2,Y=$+o*Math.cos(B),X=l+o*Math.sin(B);return `A ${o} ${o} 0 0 1 ${Y} ${X}`};if(y.push(`M ${d+o} ${h}`),i==="top"){let $=t.w-2*o,l=d+o+$*s,f=l+a;y.push(`L ${l} ${h}`),y.push(`L ${(l+f)/2} ${h-c}`),y.push(`L ${Math.min(f,u-o)} ${h}`);}if(y.push(`L ${u-o} ${h}`),y.push(w(u-o,h+o,-Math.PI/2)),i==="right"){let $=t.h-2*o,l=h+o+$*s,f=l+a;y.push(`L ${u} ${l}`),y.push(`L ${u+c} ${(l+f)/2}`),y.push(`L ${u} ${Math.min(f,x-o)}`);}if(y.push(`L ${u} ${x-o}`),y.push(w(u-o,x-o,0)),i==="bottom"){let $=t.w-2*o,l=u-o-$*s,f=l-a;y.push(`L ${l} ${x}`),y.push(`L ${(f+l)/2} ${x+c}`),y.push(`L ${Math.max(f,d+o)} ${x}`);}if(y.push(`L ${d+o} ${x}`),y.push(w(d+o,x-o,Math.PI/2)),i==="left"){let $=t.h-2*o,l=x-o-$*s,f=l-a;y.push(`L ${d} ${l}`),y.push(`L ${d-c} ${(f+l)/2}`),y.push(`L ${d} ${Math.max(f,h+o)}`);}return y.push(`L ${d} ${h+o}`),y.push(w(d+o,h+o,Math.PI)),y.push("Z"),y.filter(Boolean).join(" ")}var dt={kind:"callout",tagName:"path",applyGeometry(t,n,e){t.setAttribute("d",I(n,e));},svgMarkup(t,n,e){return `<path d="${I(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}};function C(t,n){let e=t.w/2,r=t.h/2,o=n.x,i=n.y,c=[[-0.35,-0.85,-0.75,-1.2,-1.1,-0.5,-0.95,-0.2],[-0.95,-0.2,-1.2,.3,-0.9,.9,-0.45,.85],[-0.45,.85,-0.15,1.15,.35,1.15,.55,.8],[.55,.8,.85,.95,1.15,.45,1,.05],[1,.05,1.2,-0.45,.85,-0.95,.4,-0.85],[.4,-0.85,.05,-1.2,-0.45,-1.1,-0.35,-0.85]],a=[`M ${o+c[0][0]*e} ${i+c[0][1]*r}`];for(let[,,s,d,u,h,x,y]of c)a.push(`C ${o+s*e} ${i+d*r} ${o+u*e} ${i+h*r} ${o+x*e} ${i+y*r}`);return a.push("Z"),a.join(" ")}var ht={kind:"cloud",tagName:"path",applyGeometry(t,n,e){t.setAttribute("d",C(n,e));},svgMarkup(t,n,e){return `<path d="${C(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.sqrt(i*i*o*o+c*c*r*r)||1;return {x:t.x+i*c*r/a,y:t.y+i*c*o/a}},anchorAtAngle(t,n,e){let r=n*m,o=e.w/2,i=e.h/2;return {x:t.x+o*Math.cos(r),y:t.y+i*Math.sin(r)}}};function W(t,n){let e=t.size/2,r=(t.barWidth??Math.round(t.size/3))/2;return [`${n.x-r},${n.y-e}`,`${n.x+r},${n.y-e}`,`${n.x+r},${n.y-r}`,`${n.x+e},${n.y-r}`,`${n.x+e},${n.y+r}`,`${n.x+r},${n.y+r}`,`${n.x+r},${n.y+e}`,`${n.x-r},${n.y+e}`,`${n.x-r},${n.y+r}`,`${n.x-e},${n.y+r}`,`${n.x-e},${n.y-r}`,`${n.x-r},${n.y-r}`].join(" ")}var yt={kind:"cross",tagName:"polygon",applyGeometry(t,n,e){t.setAttribute("points",W(n,e));},svgMarkup(t,n,e){return `<polygon points="${W(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.size/2,c=Math.min(i/Math.abs(r||1e-6),i/Math.abs(o||1e-6));return {x:t.x+r*c,y:t.y+o*c}},anchorAtAngle(t,n,e){return g(t,n,e.size/2,e.size/2)}};function j(t,n){let e=t.w/2,r=t.h/2,o=t.depth??Math.round(t.w*.2),i={x:n.x-e,y:n.y-r},c={x:n.x+e,y:n.y-r},a={x:n.x+e,y:n.y+r},s={x:n.x-e,y:n.y+r},d={x:i.x+o,y:i.y-o},u={x:c.x+o,y:c.y-o},h={x:a.x+o,y:a.y-o};return {ftl:i,ftr:c,fbr:a,fbl:s,btl:d,btr:u,bbr:h,d:o}}function v(...t){return t.map(n=>`${n.x},${n.y}`).join(" ")}var ut={kind:"cube",tagName:"g",applyGeometry(t,n,e){let{ftl:r,ftr:o,fbr:i,fbl:c,btl:a,btr:s,bbr:d}=j(n,e),u=t.querySelector('[data-viz-cube="front"]');u||(u=document.createElementNS(b,"polygon"),u.setAttribute("data-viz-cube","front"),t.appendChild(u)),u.setAttribute("points",v(r,o,i,c));let h=t.querySelector('[data-viz-cube="top"]');h||(h=document.createElementNS(b,"polygon"),h.setAttribute("data-viz-cube","top"),t.appendChild(h)),h.setAttribute("points",v(r,o,s,a)),h.style.filter="brightness(0.85)";let x=t.querySelector('[data-viz-cube="right"]');x||(x=document.createElementNS(b,"polygon"),x.setAttribute("data-viz-cube","right"),t.appendChild(x)),x.setAttribute("points",v(o,s,d,i)),x.style.filter="brightness(0.7)";},svgMarkup(t,n,e){let{ftl:r,ftr:o,fbr:i,fbl:c,btl:a,btr:s,bbr:d}=j(t,n);return `<g class="viz-node-shape" data-viz-role="node-shape"${e}><polygon points="${v(r,o,i,c)}" data-viz-cube="front"/><polygon points="${v(r,o,s,a)}" data-viz-cube="top" style="filter:brightness(0.85)"/><polygon points="${v(o,s,d,i)}" data-viz-cube="right" style="filter:brightness(0.7)"/>`+"</g>"},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.depth??Math.round(e.w*.2),c=e.w/2+i/2,a=e.h/2+i/2,s=Math.min(c/Math.abs(r||1e-6),a/Math.abs(o||1e-6));return {x:t.x+r*s,y:t.y+o*s}},anchorAtAngle(t,n,e){let r=e.depth??Math.round(e.w*.2);return g(t,n,e.w/2+r/2,e.h/2+r/2)}},xt={kind:"path",tagName:"path",applyGeometry(t,n,e){t.setAttribute("d",n.d),t.setAttribute("transform",`translate(${e.x-n.w/2},${e.y-n.h/2})`);},svgMarkup(t,n,e){let r=n.x-t.w/2,o=n.y-t.h/2;return `<path d="${t.d}" transform="translate(${r},${o})" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}};function q(t,n){let e=t.w/2,r=t.h/2,o=t.waveHeight??Math.round(t.h*.1),i=n.x-e,c=n.x+e,a=n.y-r,s=n.y+r-o;return `M ${i} ${a} H ${c} V ${s} C ${c-e*.5} ${s+o*2}, ${i+e*.5} ${s-o}, ${i} ${s} Z`}var lt={kind:"document",tagName:"path",applyGeometry(t,n,e){t.setAttribute("d",q(n,e));},svgMarkup(t,n,e){return `<path d="${q(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}};function D(t,n){let e=t.w/2,r=t.h/2,o=t.foldSize??15,i=n.x-e,c=n.x+e,a=n.y-r,s=n.y+r;return {x0:i,x1:c,y0:a,y1:s,f:o}}var gt={kind:"note",tagName:"g",applyGeometry(t,n,e){let{x0:r,x1:o,y0:i,y1:c,f:a}=D(n,e),s=t.querySelector('[data-viz-note="body"]');s||(s=document.createElementNS(b,"polygon"),s.setAttribute("data-viz-note","body"),t.appendChild(s)),s.setAttribute("points",`${r},${i} ${o-a},${i} ${o},${i+a} ${o},${c} ${r},${c}`);let d=t.querySelector('[data-viz-note="fold"]');d||(d=document.createElementNS(b,"polygon"),d.setAttribute("data-viz-note","fold"),t.appendChild(d)),d.setAttribute("points",`${o-a},${i} ${o-a},${i+a} ${o},${i+a}`),d.style.filter="brightness(0.8)";},svgMarkup(t,n,e){let{x0:r,x1:o,y0:i,y1:c,f:a}=D(t,n),s=`${r},${i} ${o-a},${i} ${o},${i+a} ${o},${c} ${r},${c}`,d=`${o-a},${i} ${o-a},${i+a} ${o},${i+a}`;return `<g class="viz-node-shape" data-viz-role="node-shape"${e}><polygon points="${s}" data-viz-note="body"/><polygon points="${d}" data-viz-note="fold" style="filter:brightness(0.8)"/>`+"</g>"},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}};function H(t,n){let e=t.w/2,r=t.h/2,i=(t.skew??Math.round(t.w*.2))/2;return [`${n.x-e-i},${n.y+r}`,`${n.x+e-i},${n.y+r}`,`${n.x+e+i},${n.y-r}`,`${n.x-e+i},${n.y-r}`].join(" ")}var ft={kind:"parallelogram",tagName:"polygon",applyGeometry(t,n,e){t.setAttribute("points",H(n,e));},svgMarkup(t,n,e){return `<polygon points="${H(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.skew??Math.round(e.w*.2),c=e.w/2+i/2,a=e.h/2,s=Math.min(c/Math.abs(r||1e-6),a/Math.abs(o||1e-6));return {x:t.x+r*s,y:t.y+o*s}},anchorAtAngle(t,n,e){let r=e.skew??Math.round(e.w*.2);return g(t,n,e.w/2+r/2,e.h/2)}};function _(t,n){let e=t.points,r=t.outerR,o=t.innerR??Math.round(r*.4),i=[];for(let c=0;c<e*2;c++){let a=c%2===0?r:o,s=Math.PI*c/e-Math.PI/2;i.push(`${n.x+a*Math.cos(s)},${n.y+a*Math.sin(s)}`);}return i.join(" ")}var $t={kind:"star",tagName:"polygon",applyGeometry(t,n,e){t.setAttribute("points",_(n,e));},svgMarkup(t,n,e){return `<polygon points="${_(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let c=e.outerR/Math.sqrt(r*r+o*o);return {x:t.x+r*c,y:t.y+o*c}},anchorAtAngle(t,n,e){let r=n*m;return {x:t.x+e.outerR*Math.cos(r),y:t.y+e.outerR*Math.sin(r)}}};function K(t,n){let e=t.topW/2,r=t.bottomW/2,o=t.h/2;return [`${n.x-e},${n.y-o}`,`${n.x+e},${n.y-o}`,`${n.x+r},${n.y+o}`,`${n.x-r},${n.y+o}`].join(" ")}var bt={kind:"trapezoid",tagName:"polygon",applyGeometry(t,n,e){t.setAttribute("points",K(n,e));},svgMarkup(t,n,e){return `<polygon points="${K(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=Math.max(e.topW,e.bottomW)/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){let r=Math.max(e.topW,e.bottomW)/2;return g(t,n,r,e.h/2)}};function O(t,n){let e=t.w/2,r=t.h/2;switch(t.direction??"up"){case "up":return [`${n.x},${n.y-r}`,`${n.x+e},${n.y+r}`,`${n.x-e},${n.y+r}`].join(" ");case "down":return [`${n.x},${n.y+r}`,`${n.x-e},${n.y-r}`,`${n.x+e},${n.y-r}`].join(" ");case "left":return [`${n.x-e},${n.y}`,`${n.x+e},${n.y-r}`,`${n.x+e},${n.y+r}`].join(" ");case "right":return [`${n.x+e},${n.y}`,`${n.x-e},${n.y+r}`,`${n.x-e},${n.y-r}`].join(" ")}}var mt={kind:"triangle",tagName:"polygon",applyGeometry(t,n,e){t.setAttribute("points",O(n,e));},svgMarkup(t,n,e){return `<polygon points="${O(t,n)}" class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}},wt={kind:"image",tagName:"image",applyGeometry(t,n,e){t.setAttribute("x",String(e.x-n.w/2)),t.setAttribute("y",String(e.y-n.h/2)),t.setAttribute("width",String(n.w)),t.setAttribute("height",String(n.h)),t.setAttribute("href",n.href);try{t.setAttributeNS(rt,"href",n.href);}catch{}n.preserveAspectRatio!==void 0?t.setAttribute("preserveAspectRatio",n.preserveAspectRatio):t.removeAttribute("preserveAspectRatio");},svgMarkup(t,n,e){let r=k(t.href),o=t.preserveAspectRatio!==void 0?` preserveAspectRatio="${k(t.preserveAspectRatio)}"`:"";return `<image x="${n.x-t.w/2}" y="${n.y-t.h/2}" width="${t.w}" height="${t.h}" href="${r}"${o} class="viz-node-shape" data-viz-role="node-shape"${e} />`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}},vt={kind:"icon",tagName:"g",applyGeometry(t,n,e){let r=e.x-n.w/2,o=e.y-n.h/2;t.setAttribute("transform",`translate(${r} ${o})`),n.color?t.setAttribute("style",`color:${n.color}`):t.removeAttribute("style");let i=G(n.id);if(!i)return;let c=t.querySelector('[data-viz-icon="content"]');c||(c=document.createElementNS(b,"g"),c.setAttribute("data-viz-icon","content"),t.appendChild(c)),c.innerHTML=z(i,n.w,n.h);},svgMarkup(t,n,e){let r=n.x-t.w/2,o=n.y-t.h/2,i=G(t.id),c=t.color?` style="color:${k(t.color)}"`:"",a=i?z(i,t.w,t.h):"";return `<g class="viz-node-shape" data-viz-role="node-shape" transform="translate(${r} ${o})"${c}${e}><g data-viz-icon="content">${a}</g></g>`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}},Mt={kind:"svg",tagName:"g",applyGeometry(t,n,e){let r=e.x-n.w/2,o=e.y-n.h/2;t.setAttribute("transform",`translate(${r} ${o})`);let i=t.querySelector('[data-viz-svg="content"]');i||(i=document.createElementNS(b,"g"),i.setAttribute("data-viz-svg","content"),t.appendChild(i)),i.innerHTML=E(n.content,n.w,n.h);},svgMarkup(t,n,e){let r=n.x-t.w/2,o=n.y-t.h/2,i=E(t.content,t.w,t.h);return `<g class="viz-node-shape" data-viz-role="node-shape" transform="translate(${r} ${o})"${e}><g data-viz-svg="content">${i}</g></g>`},anchorBoundary(t,n,e){let r=n.x-t.x,o=n.y-t.y;if(r===0&&o===0)return {x:t.x,y:t.y};let i=e.w/2,c=e.h/2,a=Math.min(i/Math.abs(r||1e-6),c/Math.abs(o||1e-6));return {x:t.x+r*a,y:t.y+o*a}},anchorAtAngle(t,n,e){return g(t,n,e.w/2,e.h/2)}},At={circle:tt,rect:nt,diamond:et,cylinder:ot,hexagon:it,ellipse:ct,arc:at,blockArrow:st,callout:dt,cloud:ht,cross:yt,cube:ut,path:xt,document:lt,note:gt,parallelogram:ft,star:$t,trapezoid:bt,triangle:mt,image:wt,icon:vt,svg:Mt};function M(t){return At[t.kind]}function Et(t,n,e){M(n).applyGeometry(t,n,e);}function Gt(t,n,e){return M(t).svgMarkup(t,n,e)}function pt(t,n,e){let r=N(t);if(e==="center")return {x:r.x,y:r.y};let o=Z(t);return M(o).anchorBoundary(r,n,o)}function Lt(t,n){let e=N(t),r=Z(t);return M(r).anchorAtAngle(e,n,r)}function St(t){switch(t.kind){case "circle":return [{id:"top",offset:{x:0,y:-t.r},direction:270},{id:"right",offset:{x:t.r,y:0},direction:0},{id:"bottom",offset:{x:0,y:t.r},direction:90},{id:"left",offset:{x:-t.r,y:0},direction:180}];case "rect":return [{id:"top",offset:{x:0,y:-t.h/2},direction:270},{id:"right",offset:{x:t.w/2,y:0},direction:0},{id:"bottom",offset:{x:0,y:t.h/2},direction:90},{id:"left",offset:{x:-t.w/2,y:0},direction:180}];case "diamond":return [{id:"top",offset:{x:0,y:-t.h/2},direction:270},{id:"right",offset:{x:t.w/2,y:0},direction:0},{id:"bottom",offset:{x:0,y:t.h/2},direction:90},{id:"left",offset:{x:-t.w/2,y:0},direction:180}];case "ellipse":return [{id:"top",offset:{x:0,y:-t.ry},direction:270},{id:"right",offset:{x:t.rx,y:0},direction:0},{id:"bottom",offset:{x:0,y:t.ry},direction:90},{id:"left",offset:{x:-t.rx,y:0},direction:180}];case "hexagon":{let n=t.r;if((t.orientation??"pointy")==="pointy"){let r=n*Math.sin(Math.PI/3),o=n*Math.cos(Math.PI/3);return [{id:"top",offset:{x:0,y:-n},direction:270},{id:"top-right",offset:{x:r,y:-o},direction:330},{id:"bottom-right",offset:{x:r,y:o},direction:30},{id:"bottom",offset:{x:0,y:n},direction:90},{id:"bottom-left",offset:{x:-r,y:o},direction:150},{id:"top-left",offset:{x:-r,y:-o},direction:210}]}else {let r=n*Math.sin(Math.PI/3),o=n*Math.cos(Math.PI/3);return [{id:"right",offset:{x:n,y:0},direction:0},{id:"bottom-right",offset:{x:o,y:r},direction:60},{id:"bottom-left",offset:{x:-o,y:r},direction:120},{id:"left",offset:{x:-n,y:0},direction:180},{id:"top-left",offset:{x:-o,y:-r},direction:240},{id:"top-right",offset:{x:o,y:-r},direction:300}]}}case "cylinder":return [{id:"top",offset:{x:0,y:-t.h/2},direction:270},{id:"right",offset:{x:t.w/2,y:0},direction:0},{id:"bottom",offset:{x:0,y:t.h/2},direction:90},{id:"left",offset:{x:-t.w/2,y:0},direction:180}];case "triangle":{let n=t.w/2,e=t.h/2;switch(t.direction??"up"){case "up":return [{id:"top",offset:{x:0,y:-e},direction:270},{id:"bottom-right",offset:{x:n,y:e},direction:30},{id:"bottom-left",offset:{x:-n,y:e},direction:150},{id:"bottom",offset:{x:0,y:e},direction:90}];case "down":return [{id:"top-left",offset:{x:-n,y:-e},direction:210},{id:"top-right",offset:{x:n,y:-e},direction:330},{id:"bottom",offset:{x:0,y:e},direction:90},{id:"top",offset:{x:0,y:-e},direction:270}];case "left":return [{id:"left",offset:{x:-n,y:0},direction:180},{id:"top-right",offset:{x:n,y:-e},direction:330},{id:"bottom-right",offset:{x:n,y:e},direction:30},{id:"right",offset:{x:n,y:0},direction:0}];case "right":return [{id:"top-left",offset:{x:-n,y:-e},direction:210},{id:"right",offset:{x:n,y:0},direction:0},{id:"bottom-left",offset:{x:-n,y:e},direction:150},{id:"left",offset:{x:-n,y:0},direction:180}]}break}default:{let n=T(t);return [{id:"top",offset:{x:0,y:-n.hh},direction:270},{id:"right",offset:{x:n.hw,y:0},direction:0},{id:"bottom",offset:{x:0,y:n.hh},direction:90},{id:"left",offset:{x:-n.hw,y:0},direction:180}]}}}function kt(t){return t.ports??St(t.shape)}function zt(t,n){let e=kt(t),r=e.find(i=>i.id===n);if(r)return r;let o=/^p(\d+)$/.exec(n);if(o){let i=Number(o[1]);if(i>=0&&i<e.length)return e[i]}}function Rt(t,n){let e=zt(t,n);if(!e)return;let r=N(t);return {x:r.x+e.offset.x,y:r.y+e.offset.y}}function T(t){switch(t.kind){case "circle":return {hw:t.r,hh:t.r};case "rect":return {hw:t.w/2,hh:t.h/2};case "diamond":return {hw:t.w/2,hh:t.h/2};case "ellipse":return {hw:t.rx,hh:t.ry};case "hexagon":{let n=t.orientation??"pointy",e=Math.sqrt(3)/2;return n==="pointy"?{hw:t.r*e,hh:t.r}:{hw:t.r,hh:t.r*e}}case "cylinder":return {hw:t.w/2,hh:t.h/2};case "arc":return {hw:t.r,hh:t.r};case "blockArrow":{let n=t.direction??"right";return n==="up"||n==="down"?{hw:t.headWidth/2,hh:t.length/2}:{hw:t.length/2,hh:t.headWidth/2}}case "callout":{let n=t.pointerSide??"bottom",e=t.pointerHeight??Math.round(t.h*.25),r=t.w/2+(n==="left"||n==="right"?e:0),o=t.h/2+(n==="top"||n==="bottom"?e:0);return {hw:r,hh:o}}case "cloud":return {hw:t.w/2,hh:t.h/2};case "cross":return {hw:t.size/2,hh:t.size/2};case "cube":return {hw:t.w/2,hh:t.h/2};case "path":return {hw:t.w/2,hh:t.h/2};case "document":return {hw:t.w/2,hh:t.h/2};case "note":return {hw:t.w/2,hh:t.h/2};case "parallelogram":return {hw:t.w/2,hh:t.h/2};case "star":return {hw:t.outerR,hh:t.outerR};case "trapezoid":return {hw:Math.max(t.topW,t.bottomW)/2,hh:t.h/2};case "triangle":return {hw:t.w/2,hh:t.h/2};case "image":return {hw:t.w/2,hh:t.h/2};case "icon":return {hw:t.w/2,hh:t.h/2};case "svg":return {hw:t.w/2,hh:t.h/2};default:return {hw:0,hh:0}}}function It(t){let{hw:n,hh:e}=T(t);return {width:n*2,height:e*2}}
2
+ exports.a=A;exports.b=S;exports.c=Bt;exports.d=N;exports.e=Z;exports.f=M;exports.g=Et;exports.h=Gt;exports.i=pt;exports.j=Lt;exports.k=St;exports.l=kt;exports.m=zt;exports.n=Rt;exports.o=It;
@@ -0,0 +1 @@
1
+ 'use strict';var chunkOZAFCKI7_js=require('./chunk-OZAFCKI7.js');var X=180/Math.PI,k=Math.PI/180,l=720;function b(t,o){return Math.hypot(o.x-t.x,o.y-t.y)}function w(t,o,r){return {x:t.x+(o.x-t.x)*r,y:t.y+(o.y-t.y)*r}}function A(t){return Math.atan2(t.y,t.x)*X}function V(t){return (t%360+360)%360}function E(t,o,r){return {id:`p${o}`,angle:V(A(t)),t:r,x:t.x,y:t.y}}function d(t){let o=new Map;return t.map(r=>{let e=Math.floor(V(r.angle)/90)*90,n=o.get(e)??0;return o.set(e,n+1),{...r,id:`${e}-${n}`}})}function M(t,o,r){let e=t.length;if(e===0||o<=0)return [];let n=[0];for(let y=0;y<e;y++){let p=(y+1)%e;n.push(n[y]+b(t[y],t[p]));}let i=n[e];if(i===0)return [];let c=i/o,m=[],s=0,a=r?new Array(e).fill(0):[];for(let y=0;y<o;y++){let p=y*c;for(;s<e-1&&n[s+1]<=p;)s++;let h=n[s],f=n[s+1]-h,T=f>0?(p-h)/f:0,G=t[s],H=t[(s+1)%e],S=w(G,H,T),P;if(r){let U=r[s],N=a[s];a[s]=N+1,P=`${U}-${N}`;}else P=`p${y}`;m.push({id:P,angle:V(A(S)),t:p/i,x:S.x,y:S.y});}return m}function Z(t,o){let r=t.length;if(r<2||o<=0)return [];let e=[0];for(let m=1;m<r;m++)e.push(e[m-1]+b(t[m-1],t[m]));let n=e[r-1]+b(t[r-1],t[0]);if(n===0)return [];let i=[],c=0;for(let m=0;m<o;m++){let s=m/o,a=s*n;for(;c<r-1&&e[c+1]<=a;)c++;let y;if(c>=r-1){let p=e[r-1],h=n-p,g=h>0?(a-p)/h:0;y=w(t[r-1],t[0],g);}else {let p=e[c],g=e[c+1]-p,f=g>0?(a-p)/g:0;y=w(t[c],t[c+1],f);}i.push(E(y,m,s));}return i}function u(t,o,r,e){return {kind:t,defaultCount:o,computePorts:(n,i)=>{let c=r(n),m=e?.(n),s=M(c,i,m);return m?s:d(s)}}}function x(t,o,r){return {kind:t,defaultCount:o,computePorts:(e,n)=>d(Z(r(e),n))}}function j(t,o){let r=[];for(let e=0;e<o;e++){let i=360*e/o*k;r.push(E({x:t*Math.cos(i),y:t*Math.sin(i)},e,e/o));}return d(r)}var q={kind:"circle",defaultCount:8,computePorts:(t,o)=>j(t.r,o)};function J(t,o){let r=[];for(let e=0;e<=l;e++){let n=2*Math.PI*e/l;r.push({x:t*Math.cos(n),y:o*Math.sin(n)});}return r}var C=x("ellipse",8,t=>J(t.rx,t.ry));function Q(t,o,r){let e=t/2,n=r??Math.round(o*.15),i=o/2,c=Math.ceil(l/2),m=Math.max(4,Math.ceil(c/4)),s=[];for(let a=0;a<=c;a++){let y=Math.PI*a/c;s.push({x:e*Math.cos(y),y:-i-n*Math.sin(y)});}for(let a=1;a<=m;a++)s.push({x:-e,y:-i+a/m*o});for(let a=1;a<=c;a++){let y=Math.PI*a/c;s.push({x:-e*Math.cos(y),y:i+n*Math.sin(y)});}for(let a=1;a<m;a++)s.push({x:e,y:i-a/m*o});return s}var D=x("cylinder",10,t=>Q(t.w,t.h,t.arcHeight));function Y(t,o){let r=t/2,e=o/2;return [{x:-r,y:-e},{x:r,y:-e},{x:r,y:e},{x:-r,y:e}]}var tt=["top","right","bottom","left"],R=u("rect",8,t=>Y(t.w,t.h),()=>tt);function et(t,o){let r=t/2,e=o/2;return [{x:0,y:-e},{x:r,y:0},{x:0,y:e},{x:-r,y:0}]}var rt=["top-right","bottom-right","bottom-left","top-left"],L=u("diamond",4,t=>et(t.w,t.h),()=>rt);function ot(t,o){let r=o==="pointy"?-Math.PI/2:0,e=[];for(let n=0;n<6;n++){let i=r+Math.PI/3*n;e.push({x:t*Math.cos(i),y:t*Math.sin(i)});}return e}function nt(t){return t==="pointy"?["top-right","right","bottom-right","bottom-left","left","top-left"]:["bottom-right","bottom","bottom-left","top-left","top","top-right"]}var z=u("hexagon",6,t=>ot(t.r,t.orientation??"pointy"),t=>nt(t.orientation??"pointy"));function it(t,o,r){let e=t/2,n=o/2;switch(r){case "up":return [{x:0,y:-n},{x:e,y:n},{x:-e,y:n}];case "down":return [{x:0,y:n},{x:-e,y:-n},{x:e,y:-n}];case "left":return [{x:-e,y:0},{x:e,y:-n},{x:e,y:n}];case "right":return [{x:e,y:0},{x:-e,y:n},{x:-e,y:-n}]}}function ct(t){switch(t){case "up":return ["right","bottom","left"];case "down":return ["left","top","right"];case "left":return ["top","right","bottom"];case "right":return ["bottom","left","top"]}}var K=u("triangle",6,t=>it(t.w,t.h,t.direction??"up"),t=>ct(t.direction??"up"));function st(t,o,r){let e=t/2,n=o/2,i=r/2;return [{x:-e+i,y:-n},{x:e+i,y:-n},{x:e-i,y:n},{x:-e-i,y:n}]}var at=["top","right","bottom","left"],_=u("parallelogram",8,t=>st(t.w,t.h,t.skew??Math.round(t.w*.2)),()=>at);function mt(t,o,r){let e=t/2,n=o/2,i=r/2;return [{x:-e,y:-i},{x:e,y:-i},{x:n,y:i},{x:-n,y:i}]}var yt=["top","right","bottom","left"],B=u("trapezoid",8,t=>mt(t.topW,t.bottomW,t.h),()=>yt);function ut(t,o,r){let e=[];for(let n=0;n<t*2;n++){let i=n%2===0?o:r,c=Math.PI*n/t-Math.PI/2;e.push({x:i*Math.cos(c),y:i*Math.sin(c)});}return e}var W=u("star",t=>t.points*2,t=>ut(t.points,t.outerR,t.innerR??Math.round(t.outerR*.4)));function pt(t,o){let r=t/2,e=o/2;return [{x:-e,y:-r},{x:e,y:-r},{x:e,y:-e},{x:r,y:-e},{x:r,y:e},{x:e,y:e},{x:e,y:r},{x:-e,y:r},{x:-e,y:e},{x:-r,y:e},{x:-r,y:-e},{x:-e,y:-e}]}var $=u("cross",12,t=>pt(t.size,t.barWidth??Math.round(t.size/3)));var O=[q,C,D,R,L,z,K,_,B,W,$];var ht=8,v=new Map;function F(t){v.set(t.kind,t);}for(let t of O)F(t);function gt(t){switch(t.kind){case "circle":return {hw:t.r,hh:t.r};case "rect":return {hw:t.w/2,hh:t.h/2};case "diamond":return {hw:t.w/2,hh:t.h/2};case "ellipse":return {hw:t.rx,hh:t.ry};case "hexagon":return {hw:t.r,hh:t.r};case "cylinder":return {hw:t.w/2,hh:t.h/2};case "arc":return {hw:t.r,hh:t.r};case "blockArrow":return {hw:t.length/2,hh:t.headWidth/2};case "callout":return {hw:t.w/2,hh:t.h/2};case "cloud":return {hw:t.w/2,hh:t.h/2};case "cross":return {hw:t.size/2,hh:t.size/2};case "cube":return {hw:t.w/2,hh:t.h/2};case "path":return {hw:t.w/2,hh:t.h/2};case "document":return {hw:t.w/2,hh:t.h/2};case "note":return {hw:t.w/2,hh:t.h/2};case "parallelogram":return {hw:t.w/2,hh:t.h/2};case "star":return {hw:t.outerR,hh:t.outerR};case "trapezoid":return {hw:Math.max(t.topW,t.bottomW)/2,hh:t.h/2};case "triangle":return {hw:t.w/2,hh:t.h/2};case "image":return {hw:t.w/2,hh:t.h/2};case "icon":return {hw:t.w/2,hh:t.h/2};case "svg":return {hw:t.w/2,hh:t.h/2};default:return {hw:0,hh:0}}}var lt=["top","right","bottom","left"];function ft(t,o){let{hw:r,hh:e}=gt(t);return M([{x:-r,y:-e},{x:r,y:-e},{x:r,y:e},{x:-r,y:e}],o,lt)}function dt(t,o){let r=v.get(t.kind),e=o??(r?typeof r.defaultCount=="function"?r.defaultCount(t):r.defaultCount:ht);return e<=0?[]:r?r.computePorts(t,e):ft(t,e)}function xt(t){return t.map(o=>({id:o.id,offset:{x:o.x,y:o.y},direction:o.angle}))}function St(t,o,r){let e=chunkOZAFCKI7_js.l(t);if(e.length===0)return;let n,i=1/0;for(let c of e){let m=c.offset.x-o,s=c.offset.y-r,a=m*m+s*s;a<i&&(i=a,n=c);}return n}exports.a=F;exports.b=dt;exports.c=xt;exports.d=St;
@@ -0,0 +1,44 @@
1
+ import {d,j as j$1,n,i,e}from'./chunk-I5FQBS5N.mjs';function gt(t,e,o,n={}){let r=n.minZoom??.1,i=n.maxZoom??5,l=n.zoomOnWheel??true,s=n.panOnDrag??true,c=1,u={x:0,y:0},a=false,d={x:0,y:0},v=[],$=()=>{v.forEach(y=>y({zoom:c,pan:u}));},b=()=>{e.setAttribute("transform",`translate(${u.x}, ${u.y}) scale(${c})`),$();},f=(y,x)=>{let P=Math.max(r,Math.min(i,y));if(P!==c){if(x){let L=P/c;u.x=x.x-(x.x-u.x)*L,u.y=x.y-(x.y-u.y)*L;}c=P,b();}},m=y=>{u={...y},b();},h=(y=20)=>{if(!o.viewBox)return null;let x=t.getBoundingClientRect();if(x.width===0||x.height===0)return null;let P=x.width-y*2,L=x.height-y*2,I=P/o.viewBox.w,N=L/o.viewBox.h,T=Math.min(I,N);T=Math.max(r,Math.min(i,T));let K=o.viewBox.w*T,J=o.viewBox.h*T,tt={x:(x.width-K)/2,y:(x.height-J)/2};return {zoom:T,pan:tt}},p=(y=20)=>{let x=h(y);x&&(c=x.zoom,u=x.pan,b());},g=()=>{n.initialZoom==="fit"||n.initialZoom===void 0?p():(f(n.initialZoom),m({x:0,y:0}));},z=y=>{let x=o.nodes.find(T=>T.id===y);if(!x)return;let P=t.getBoundingClientRect();if(P.width===0||P.height===0)return;let L=Math.max(r,Math.min(i,2)),I=P.width/2-x.pos.x*L,N=P.height/2-x.pos.y*L;c=L,u={x:I,y:N},b();},S=y=>{if(!l)return;y.preventDefault();let x=.002,P=-y.deltaY;y.deltaMode===1&&(P*=15);let L=Math.exp(P*x),I=c*L,N=t.getBoundingClientRect(),T={x:y.clientX-N.left,y:y.clientY-N.top};f(I,T);},E=y=>{if(!s)return;let x=y.target;(x.closest("[data-viz-role]")||x.closest(".viz-node")||x.closest(".viz-edge"))&&x!==t&&x!==e||(y.preventDefault(),a=true,d={x:y.clientX,y:y.clientY},t.setPointerCapture(y.pointerId),t.style.cursor="grabbing");},V=y=>{if(!a||!s)return;y.preventDefault();let x=y.clientX-d.x,P=y.clientY-d.y;u.x+=x,u.y+=P,d={x:y.clientX,y:y.clientY},b();},w=y=>{!a||!s||(a=false,t.releasePointerCapture(y.pointerId),t.style.cursor="");},M=y=>{let x=y.target;x.closest("[data-viz-role]")||x.closest(".viz-node")||x.closest(".viz-edge")||p();},R={passive:false};t.addEventListener("wheel",S,R),t.addEventListener("pointerdown",E),t.addEventListener("pointermove",V),t.addEventListener("pointerup",w),t.addEventListener("pointercancel",w),t.addEventListener("dblclick",M);let U=()=>{t.removeEventListener("wheel",S),t.removeEventListener("pointerdown",E),t.removeEventListener("pointermove",V),t.removeEventListener("pointerup",w),t.removeEventListener("pointercancel",w),t.removeEventListener("dblclick",M),v.length=0;};return requestAnimationFrame(()=>{g();}),{get zoom(){return c},get pan(){return {...u}},setZoom:f,setPan:m,fitToContent:p,zoomToNode:z,reset:g,onChange(y){return v.push(y),()=>{let x=v.indexOf(y);x!==-1&&v.splice(x,1);}},destroy:U}}var et=`
2
+ .viz-tooltip {
3
+ position: absolute;
4
+ pointer-events: none;
5
+ z-index: 9999;
6
+ max-width: 320px;
7
+ padding: 8px 12px;
8
+ border-radius: 6px;
9
+ font-size: 13px;
10
+ line-height: 1.4;
11
+ background: var(--viz-tooltip-bg, #1a1a2e);
12
+ color: var(--viz-tooltip-fg, #e2e8f0);
13
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
14
+ opacity: 0;
15
+ transition: opacity 0.15s ease-out;
16
+ white-space: pre-wrap;
17
+ word-break: break-word;
18
+ box-sizing: border-box;
19
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
20
+ }
21
+ .viz-tooltip[data-visible="true"] {
22
+ opacity: 1;
23
+ }
24
+ .viz-tooltip-title {
25
+ font-weight: 600;
26
+ margin-bottom: 4px;
27
+ font-size: 14px;
28
+ }
29
+ .viz-tooltip-section {
30
+ display: flex;
31
+ gap: 6px;
32
+ padding: 2px 0;
33
+ }
34
+ .viz-tooltip-section-label {
35
+ color: var(--viz-tooltip-label, #94a3b8);
36
+ flex-shrink: 0;
37
+ }
38
+ .viz-tooltip-section-label::after {
39
+ content: ':';
40
+ }
41
+ .viz-tooltip-section-value {
42
+ color: var(--viz-tooltip-fg, #e2e8f0);
43
+ }
44
+ `;function B(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function nt(t){if(typeof t=="string")return `<span>${B(t)}</span>`;let e="";t.title&&(e+=`<div class="viz-tooltip-title">${B(t.title)}</div>`);for(let o of t.sections)e+=`<div class="viz-tooltip-section"><span class="viz-tooltip-section-label">${B(o.label)}</span><span class="viz-tooltip-section-value">${B(o.value)}</span></div>`;return e}function ot(t,e,o){let n=e.getBoundingClientRect(),r=o.getBoundingClientRect(),i=8,l=t.offsetWidth,s=t.offsetHeight,c=n.left-r.left+n.width/2-l/2,u=n.top-r.top-s-i;u<0&&(u=n.bottom-r.top+i),c<0&&(c=4),c+l>o.clientWidth&&(c=o.clientWidth-l-4),t.style.left=`${c}px`,t.style.top=`${u}px`;}function bt(t,e,o,n,r){let i=r?.delay??300,l=o,s=n,c=t.querySelector("style[data-viz-tooltip-css]");c||(c=document.createElement("style"),c.setAttribute("data-viz-tooltip-css",""),c.textContent=et,t.appendChild(c));let u=document.createElement("div");u.className="viz-tooltip",u.setAttribute("role","tooltip"),u.setAttribute("aria-hidden","true"),t.appendChild(u),getComputedStyle(t).position==="static"&&(t.style.position="relative");let d=null,v=null;function $(E,V){u.innerHTML=nt(V),u.style.display="block",u.setAttribute("data-visible","false"),requestAnimationFrame(()=>{ot(u,E,t),u.setAttribute("data-visible","true"),u.setAttribute("aria-hidden","false");});}function b(){d!==null&&(clearTimeout(d),d=null),u.setAttribute("data-visible","false"),u.setAttribute("aria-hidden","true"),v=null;}function f(E){let V=E instanceof Element?E:null;for(;V&&V!==e;){let w=V.getAttribute("data-viz-role"),M=V.getAttribute("data-id");if(w==="node-group"&&M){let R=l.get(M);return R?.tooltip?{content:R.tooltip,group:V}:null}if(w==="edge-group"&&M){let R=s.get(M);return R?.tooltip?{content:R.tooltip,group:V}:null}V=V.parentElement;}return null}function m(E){let V=f(E.target);if(!V)return;let{content:w,group:M}=V;M!==v&&(b(),v=M,d=setTimeout(()=>{$(M,w);},i));}function h(E){let V=f(E.target);V&&V.group===v&&b();}function p(E){let V=f(E.target);(!V||V.group!==v)&&b();}function g(E){let V=f(E.target);V&&(b(),v=V.group,$(V.group,V.content));}function z(){b();}function S(E){E.key==="Escape"&&b();}return e.addEventListener("pointerenter",m,true),e.addEventListener("pointerleave",h,true),e.addEventListener("pointermove",p,true),e.addEventListener("focusin",g,true),e.addEventListener("focusout",z,true),e.addEventListener("keydown",S,true),{destroy(){b(),e.removeEventListener("pointerenter",m,true),e.removeEventListener("pointerleave",h,true),e.removeEventListener("pointermove",p,true),e.removeEventListener("focusin",g,true),e.removeEventListener("focusout",z,true),e.removeEventListener("keydown",S,true),u.remove(),c?.remove();},updateData(E,V){l=E,s=V;}}}function G(t,e,o){let n$1=o.anchor??"boundary",r=o.fromAt,i$1=o.toAt,l=e?d(e):i$1??{x:0,y:0},s=t?d(t):r??{x:0,y:0},c;t?o.fromAngle!==void 0?c=j$1(t,o.fromAngle):c=o.fromPort?n(t,o.fromPort)??i(t,l,n$1):i(t,l,n$1):c=r??{x:0,y:0};let u;return e?o.toAngle!==void 0?u=j$1(e,o.toAngle):u=o.toPort?n(e,o.toPort)??i(e,s,n$1):i(e,s,n$1):u=i$1??{x:0,y:0},{start:c,end:u}}function _(t,e,o="straight",n){switch(o){case "curved":return rt(t,e,n);case "orthogonal":return ct(t,e,n);default:return it(t,e,n)}}function it(t,e,o){let n=[t,...o??[],e],r=n.map((l,s)=>s===0?`M ${l.x} ${l.y}`:`L ${l.x} ${l.y}`),i=X(n);return {d:r.join(" "),...i}}function rt(t,e,o){if(o&&o.length>0)return st(t,e,o);let n=j(t,e),r=`M ${t.x} ${t.y} Q ${n.x} ${n.y} ${e.x} ${e.y}`,i=C(t,n,e,.5),l=C(t,n,e,D),s=C(t,n,e,O);return {d:r,mid:i,start:l,end:s}}function j(t,e){let o=(t.x+e.x)/2,n=(t.y+e.y)/2,r=e.x-t.x,i=e.y-t.y,l=Math.sqrt(r*r+i*i)||1,s=l*.2;return {x:o+-i/l*s,y:n+r/l*s}}function C(t,e,o,n){let r=1-n;return {x:r*r*t.x+2*r*n*e.x+n*n*o.x,y:r*r*t.y+2*r*n*e.y+n*n*o.y}}function st(t,e,o){let n=[t,...o,e];if(n.length===2){let s=j(t,e);return {d:`M ${t.x} ${t.y} Q ${s.x} ${s.y} ${e.x} ${e.y}`,mid:C(t,s,e,.5),start:C(t,s,e,D),end:C(t,s,e,O)}}let r=`M ${n[0].x} ${n[0].y}`,i=.3;for(let s=0;s<n.length-1;s++){let c=n[Math.max(s-1,0)],u=n[s],a=n[s+1],d=n[Math.min(s+2,n.length-1)],v=u.x+(a.x-c.x)*i,$=u.y+(a.y-c.y)*i,b=a.x-(d.x-u.x)*i,f=a.y-(d.y-u.y)*i;r+=` C ${v} ${$}, ${b} ${f}, ${a.x} ${a.y}`;}let l=X(n);return {d:r,...l}}function ct(t,e,o){return o&&o.length>0?ut(t,e,o):lt(t,e)}function lt(t,e){let o=Math.abs(e.x-t.x),n=Math.abs(e.y-t.y),r,i,l,s;if(o>=n){let c=(t.x+e.x)/2;r=`M ${t.x} ${t.y} L ${c} ${t.y} L ${c} ${e.y} L ${e.x} ${e.y}`;let u=[t,{x:c,y:t.y},{x:c,y:e.y},e];i=A(u,.5),l=A(u,D),s=A(u,O);}else {let c=(t.y+e.y)/2;r=`M ${t.x} ${t.y} L ${t.x} ${c} L ${e.x} ${c} L ${e.x} ${e.y}`;let u=[t,{x:t.x,y:c},{x:e.x,y:c},e];i=A(u,.5),l=A(u,D),s=A(u,O);}return {d:r,mid:i,start:l,end:s}}function ut(t,e,o){let n=[t,...o,e],r=`M ${n[0].x} ${n[0].y}`,i=[n[0]];for(let s=1;s<n.length;s++){let c=n[s-1],u=n[s];r+=` L ${u.x} ${c.y} L ${u.x} ${u.y}`,i.push({x:u.x,y:c.y}),i.push(u);}let l=X(i);return {d:r,...l}}var D=.15,O=.85;function A(t,e){if(t.length===0)return {x:0,y:0};if(t.length===1)return t[0];let o=0;for(let i=1;i<t.length;i++){let l=t[i].x-t[i-1].x,s=t[i].y-t[i-1].y;o+=Math.sqrt(l*l+s*s);}let n=o*e,r=0;for(let i=1;i<t.length;i++){let l=t[i].x-t[i-1].x,s=t[i].y-t[i-1].y,c=Math.sqrt(l*l+s*s);if(r+c>=n){let u=c===0?0:(n-r)/c;return {x:t[i-1].x+l*u,y:t[i-1].y+s*u}}r+=c;}return t[t.length-1]}function X(t){return {start:A(t,D),mid:A(t,.5),end:A(t,O)}}function at(t){return t?"w"in t&&"h"in t?{w:t.w,h:t.h}:"r"in t?{w:t.r*2,h:t.r*2}:"rx"in t&&"ry"in t?{w:t.rx*2,h:t.ry*2}:"size"in t?{w:t.size,h:t.size}:{w:60,h:60}:{w:60,h:60}}function $t(t,e$1){let o=d(t),n=at(e(t)),r=n.w,i=n.h,l=e$1.loopSide||"top",s=e$1.loopSize||30,c=Math.min(20,(l==="top"||l==="bottom"?r:i)*.8),u="",a,d$1,v,$,b;switch(l){case "top":{let f=o.x-c/2,m=o.y-i/2,h=o.x+c/2,p=o.y-i/2,g=m-s*1.5;u=`M ${f} ${m} C ${f-c/2} ${g}, ${h+c/2} ${g}, ${h} ${p}`,$={x:f,y:m},b={x:h,y:p},a={x:f,y:m-s*.2},d$1={x:o.x,y:m-s},v={x:h,y:p-s*.2};break}case "bottom":{let f=o.x-c/2,m=o.y+i/2,h=o.x+c/2,p=o.y+i/2,g=m+s*1.5;u=`M ${f} ${m} C ${f-c/2} ${g}, ${h+c/2} ${g}, ${h} ${p}`,$={x:f,y:m},b={x:h,y:p},a={x:f,y:m+s*.2},d$1={x:o.x,y:m+s},v={x:h,y:p+s*.2};break}case "left":{let f=o.x-r/2,m=o.y-c/2,h=o.x-r/2,p=o.y+c/2,g=f-s*1.5;u=`M ${f} ${m} C ${g} ${m-c/2}, ${g} ${p+c/2}, ${h} ${p}`,$={x:f,y:m},b={x:h,y:p},a={x:f-s*.2,y:m},d$1={x:f-s,y:o.y},v={x:h-s*.2,y:p};break}case "right":{let f=o.x+r/2,m=o.y-c/2,h=o.x+r/2,p=o.y+c/2,g=f+s*1.5;u=`M ${f} ${m} C ${g} ${m-c/2}, ${g} ${p+c/2}, ${h} ${p}`,$={x:f,y:m},b={x:h,y:p},a={x:f+s*.2,y:m},d$1={x:f+s,y:o.y},v={x:h+s*.2,y:p};break}}return {d:u,start:a,mid:d$1,end:v,exitPoint:$,entryPoint:b}}function dt(t,e){return t.x>=e.x&&t.x<=e.x+e.w&&t.y>=e.y&&t.y<=e.y+e.h}function Q(t,e,o){let n=t.x-e.x,r=t.y-e.y;return n*n+r*r<=o*o}function Z(t,e){let o=t.x-e.x,n=t.y-e.y;return o*o+n*n}function ft(t,e,o){let n=Z(e,o);if(n===0)return Z(t,e);let r=((t.x-e.x)*(o.x-e.x)+(t.y-e.y)*(o.y-e.y))/n;return r=Math.max(0,Math.min(1,r)),Z(t,{x:e.x+r*(o.x-e.x),y:e.y+r*(o.y-e.y)})}function yt(t,e=10){let o=t.match(/[a-zA-Z][^a-zA-Z]*/g);if(!o)return [];let n=[],r=0,i=0,l=0,s=0;for(let c of o){let u=c[0],a=c.substring(1).trim().split(/[\s,]+/).filter(d=>d!=="").map(parseFloat);switch(u.toUpperCase()){case "M":a.length>=2&&(r=a[0],i=a[1],l=r,s=i,n.push({x:r,y:i}));break;case "L":for(let d=0;d<a.length;d+=2)r=a[d],i=a[d+1],n.push({x:r,y:i});break;case "Q":for(let d=0;d<a.length;d+=4){let v=a[d],$=a[d+1],b=a[d+2],f=a[d+3];for(let m=1;m<=e;m++){let h=m/e,p=1-h,g=p*p*r+2*p*h*v+h*h*b,z=p*p*i+2*p*h*$+h*h*f;n.push({x:g,y:z});}r=b,i=f;}break;case "C":for(let d=0;d<a.length;d+=6){let v=a[d],$=a[d+1],b=a[d+2],f=a[d+3],m=a[d+4],h=a[d+5];for(let p=1;p<=e;p++){let g=p/e,z=1-g,S=z*z*z*r+3*z*z*g*v+3*z*g*g*b+g*g*g*m,E=z*z*z*i+3*z*z*g*$+3*z*g*g*f+g*g*g*h;n.push({x:S,y:E});}r=m,i=h;}break;case "Z":r=l,i=s,n.push({x:r,y:i});break}}return n}function xt(t,e){if(e.length===0)return 1/0;if(e.length===1)return Math.sqrt(Z(t,e[0]));let o=1/0;for(let n=0;n<e.length-1;n++){let r=ft(t,e[n],e[n+1]);r<o&&(o=r);}return Math.sqrt(o)}function W(t){let e=0,o=0,n=t.shape,r=t.runtime?.x??t.pos.x,i=t.runtime?.y??t.pos.y;return t.runtime?.width!==void 0?e=t.runtime.width:"w"in n?e=n.w:"r"in n?e=n.r*2:"rx"in n&&"ry"in n?(e=n.rx*2,o=n.ry*2):"size"in n?e=n.size:"outerR"in n&&(e=n.outerR*2),t.runtime?.height!==void 0?o=t.runtime.height:"h"in n?o=n.h:o===0&&(o=e),{x:r-e/2,y:i-o/2,w:e,h:o}}function pt(t,e){let o=W(t);if(!dt(e,o))return false;let n=t.shape,r={x:t.runtime?.x??t.pos.x,y:t.runtime?.y??t.pos.y};if(n.kind==="circle"){let i=t.runtime?.radius??n.r;return Q(e,r,i)}if(n.kind==="ellipse"){let i=t.runtime?.width!==void 0?t.runtime.width/2:n.rx,l=t.runtime?.height!==void 0?t.runtime.height/2:n.ry,s=e.x-r.x,c=e.y-r.y;return s*s/(i*i)+c*c/(l*l)<=1}return true}function mt(t,e){if(!t.compartments||t.compartments.length===0)return;let o={x:t.runtime?.x??t.pos.x,y:t.runtime?.y??t.pos.y},n=W(t),r=o.y-n.h/2,i=e.y-r;for(let l of t.compartments)if(i>=l.y&&i<l.y+l.height)return l.id}function Mt(t,e,o={}){let{edgeTolerance:n=5,portTolerance:r=10}=o;for(let i of t.nodes){if(!i.ports||i.ports.length===0)continue;let l={x:i.runtime?.x??i.pos.x,y:i.runtime?.y??i.pos.y};for(let s of i.ports){let c={x:l.x+s.offset.x,y:l.y+s.offset.y};if(Q(e,c,r))return {type:"port",nodeId:i.id,portId:s.id,position:c}}}for(let i=t.nodes.length-1;i>=0;i--){let l=t.nodes[i];if(pt(l,e)){let s=mt(l,e);return {type:"node",id:l.id,compartmentId:s}}}for(let i=t.edges.length-1;i>=0;i--){let l=t.edges[i],s=ht(t,l.id,e),c=l.hitArea??n;if(s<=c)return {type:"edge",id:l.id}}return null}function Lt(t,e){let o=[];for(let n of t.nodes){let r=W(n);!(r.x>e.x+e.w||r.x+r.w<e.x||r.y>e.y+e.h||r.y+r.h<e.y)&&o.push({type:"node",id:n.id});}for(let n of t.edges){let r=n.from?t.nodes.find($=>$.id===n.from):void 0,i=n.to?t.nodes.find($=>$.id===n.to):void 0;if(n.from&&!r||n.to&&!i||!r&&!n.fromAt&&!i&&!n.toAt)continue;let l=r?{x:r.runtime?.x??r.pos.x,y:r.runtime?.y??r.pos.y}:n.fromAt??{x:0,y:0},s=i?{x:i.runtime?.x??i.pos.x,y:i.runtime?.y??i.pos.y}:n.toAt??{x:0,y:0},c=Math.min(l.x,s.x)-10,u=Math.max(l.x,s.x)+10,a=Math.min(l.y,s.y)-10,d=Math.max(l.y,s.y)+10;!(c>e.x+e.w||u<e.x||a>e.y+e.h||d<e.y)&&o.push({type:"edge",id:n.id});}return o}function wt(t,e,o){let{maxDistance:n}=o,r=null,i=n*n;for(let l of t.nodes){if(!l.ports)continue;let s={x:l.runtime?.x??l.pos.x,y:l.runtime?.y??l.pos.y};for(let c of l.ports){let u={x:s.x+c.offset.x,y:s.y+c.offset.y},a=Z(e,u);a<=i&&(i=a,r={nodeId:l.id,portId:c.id,position:u,distance:Math.sqrt(a)});}}return r}function ht(t,e,o){let n=t.edges.find(a=>a.id===e);if(!n)return 1/0;let r=n.from?t.nodes.find(a=>a.id===n.from):null,i=n.to?t.nodes.find(a=>a.id===n.to):null;if(n.from&&!r||n.to&&!i||!r&&!n.fromAt&&!i&&!n.toAt)return 1/0;let{start:l,end:s}=G(r??null,i??null,n),c=_(l,s,n.routing,n.waypoints),u=yt(c.d,10);return xt(o,u)}export{gt as a,et as b,bt as c,G as d,_ as e,$t as f,dt as g,Z as h,W as i,Mt as j,Lt as k,wt as l,ht as m};
@@ -1,8 +1,12 @@
1
- import type { VizScene, VizNode, Vec2 } from '../types';
1
+ import { b as VizScene, P as PanZoomOptions, c as PanZoomController, d as Vec2, V as VizNode } from './index-Cw8ug9aU.js';
2
+
3
+ declare function setupPanZoom(svg: SVGSVGElement, viewport: SVGGElement, scene: VizScene, options?: PanZoomOptions): PanZoomController;
4
+
2
5
  /** Result of a point hit test. */
3
- export type HitResult = {
6
+ type HitResult = {
4
7
  type: 'node';
5
8
  id: string;
9
+ compartmentId?: string;
6
10
  } | {
7
11
  type: 'edge';
8
12
  id: string;
@@ -12,20 +16,20 @@ export type HitResult = {
12
16
  portId: string;
13
17
  position: Vec2;
14
18
  } | null;
15
- export interface HitTestOptions {
19
+ interface HitTestOptions {
16
20
  /** Maximum distance away from an edge to still "hit" it. Default: 5. */
17
21
  edgeTolerance?: number;
18
22
  /** Maximum distance to a port center. Default: 10. */
19
23
  portTolerance?: number;
20
24
  }
21
- export declare function pointInRect(p: Vec2, rect: {
25
+ declare function pointInRect(p: Vec2, rect: {
22
26
  x: number;
23
27
  y: number;
24
28
  w: number;
25
29
  h: number;
26
30
  }): boolean;
27
- export declare function distanceSquare(p1: Vec2, p2: Vec2): number;
28
- export declare function getEffectiveNodeBounds(node: VizNode): {
31
+ declare function distanceSquare(p1: Vec2, p2: Vec2): number;
32
+ declare function getEffectiveNodeBounds(node: VizNode): {
29
33
  x: number;
30
34
  y: number;
31
35
  w: number;
@@ -36,11 +40,11 @@ export declare function getEffectiveNodeBounds(node: VizNode): {
36
40
  * Z-index is handled by iterating nodes in reverse order (drawn last = top).
37
41
  * Resolution order: 1. Nodes, 2. Ports (since they sit on nodes), 3. Edges.
38
42
  */
39
- export declare function hitTest(scene: VizScene, point: Vec2, options?: HitTestOptions): HitResult;
43
+ declare function hitTest(scene: VizScene, point: Vec2, options?: HitTestOptions): HitResult;
40
44
  /**
41
45
  * Returns all elements intersecting or contained within a given rectangle.
42
46
  */
43
- export declare function hitTestRect(scene: VizScene, rect: {
47
+ declare function hitTestRect(scene: VizScene, rect: {
44
48
  x: number;
45
49
  y: number;
46
50
  w: number;
@@ -52,7 +56,7 @@ export declare function hitTestRect(scene: VizScene, rect: {
52
56
  /**
53
57
  * Finds the nearest named port in the scene to the given point, within maxDistance.
54
58
  */
55
- export declare function nearestPort(scene: VizScene, point: Vec2, options: {
59
+ declare function nearestPort(scene: VizScene, point: Vec2, options: {
56
60
  maxDistance: number;
57
61
  }): {
58
62
  nodeId: string;
@@ -63,4 +67,6 @@ export declare function nearestPort(scene: VizScene, point: Vec2, options: {
63
67
  /**
64
68
  * Calculates the perpendicular distance from a point to a specific edge's drawn path.
65
69
  */
66
- export declare function edgeDistance(scene: VizScene, edgeId: string, point: Vec2): number;
70
+ declare function edgeDistance(scene: VizScene, edgeId: string, point: Vec2): number;
71
+
72
+ export { type HitResult as H, type HitTestOptions as a, hitTestRect as b, distanceSquare as d, edgeDistance as e, getEffectiveNodeBounds as g, hitTest as h, nearestPort as n, pointInRect as p, setupPanZoom as s };