From 73529a4d57785f84a59fef1bee1c756fda0d9e24 Mon Sep 17 00:00:00 2001 From: Raphael Simon Date: Tue, 10 Nov 2026 12:57:33 -0800 Subject: [PATCH 1/2] Give each diagram its own SVG, listeners and ids The diagram renderer kept one module-level SVG element that every new graph replaced, plus window globals and fixed element ids. When a page drew more than one diagram, one graph's layout, zoom and export could act on another graph's SVG, and ids such as the grid pattern collided. Each GraphData now owns its SVG element, its selection listener and an id prefix for the definitions and references it creates. Helpers that read the shared element take the graph instead. exportSVG restores the existing names on its clone, so exported files and saved layouts are unchanged. The window.graph and window.gdata globals are removed; the browser tests drive the editor through its toolbar instead. --- cmd/mdl/component_boundaries_test.go | 24 +- cmd/mdl/graph_isolation_test.go | 248 ++++++++++++ cmd/mdl/svg_e2e_test.go | 67 +++- cmd/mdl/webapp/dist/286.js | 2 +- cmd/mdl/webapp/dist/286.js.map | 2 +- cmd/mdl/webapp/dist/948.js | 2 +- cmd/mdl/webapp/dist/948.js.map | 2 +- cmd/mdl/webapp/dist/main.js | 2 +- cmd/mdl/webapp/dist/main.js.map | 2 +- cmd/mdl/webapp/src/components/Toolbar.tsx | 14 +- cmd/mdl/webapp/src/graph-view/defs.ts | 14 +- cmd/mdl/webapp/src/graph-view/graph-react.tsx | 11 +- cmd/mdl/webapp/src/graph-view/graph.ts | 379 ++++++++++-------- cmd/mdl/webapp/src/parseModel.test.ts | 9 +- 14 files changed, 544 insertions(+), 234 deletions(-) create mode 100644 cmd/mdl/graph_isolation_test.go diff --git a/cmd/mdl/component_boundaries_test.go b/cmd/mdl/component_boundaries_test.go index 7cbb6913..fef0460d 100644 --- a/cmd/mdl/component_boundaries_test.go +++ b/cmd/mdl/component_boundaries_test.go @@ -11,7 +11,6 @@ import ( "testing" "time" - cdruntime "github.com/chromedp/cdproto/runtime" "github.com/chromedp/chromedp" ) @@ -44,9 +43,11 @@ func TestComponentBoundariesRendered(t *testing.T) { httpServer := &http.Server{ReadHeaderTimeout: 3 * time.Second} mux := http.NewServeMux() mux.Handle("/exports/", http.StripPrefix("/exports/", http.FileServer(http.Dir(outDir)))) + // The editor saves into its own directory so it keeps the CLI files intact. + editorDir := t.TempDir() serverDone := make(chan error, 1) go func() { - serverDone <- server.ServeOnListener(outDir, "", httpServer, mux, listener) + serverDone <- server.ServeOnListener(editorDir, "", httpServer, mux, listener) }() t.Cleanup(func() { if err := httpServer.Close(); err != nil { @@ -76,22 +77,21 @@ func TestComponentBoundariesRendered(t *testing.T) { ctx, cleanup := newChromeContext(t) defer cleanup() pageURL := fmt.Sprintf("http://%s/?id=%s", listener.Addr().String(), url.QueryEscape(test.view)) - var exported string - const exportScript = `(async () => { - await window.gdata.autoLayout(); - return window.gdata.exportSVG(); - })()` + // The editor's toolbar lays out the view and saves its SVG into editorDir. if err := chromedp.Run(ctx, chromedp.Navigate(pageURL), - chromedp.Poll(`window.gdata && window.gdata.nodes().every(node => node.ref?.isConnected)`, nil), - chromedp.Evaluate(exportScript, &exported, func(params *cdruntime.EvaluateParams) *cdruntime.EvaluateParams { - return params.WithAwaitPromise(true) - }), + chromedp.WaitVisible(editorNodeSelector, chromedp.ByQuery), + clickEditorButton(autoLayoutButton), + clickEditorButton(saveButton), ); err != nil { t.Fatalf("render editor component view: %v", err) } + exported, err := os.ReadFile(filepath.Join(editorDir, test.view+".svg")) + if err != nil { + t.Fatalf("read editor export: %v", err) + } editorPath := filepath.Join(outDir, "editor-"+test.view+".svg") - if err := os.WriteFile(editorPath, []byte(exported), 0600); err != nil { + if err := os.WriteFile(editorPath, exported, 0600); err != nil { t.Fatalf("save editor export: %v", err) } // Inspect real SVG rectangles after export. A missing boundary or a diff --git a/cmd/mdl/graph_isolation_test.go b/cmd/mdl/graph_isolation_test.go new file mode 100644 index 00000000..273b7470 --- /dev/null +++ b/cmd/mdl/graph_isolation_test.go @@ -0,0 +1,248 @@ +package main + +import ( + "fmt" + "net" + "net/http" + "os" + "path/filepath" + "reflect" + "testing" + "time" + + cdruntime "github.com/chromedp/cdproto/runtime" + "github.com/chromedp/chromedp" + + "goa.design/model/mdl" +) + +type ( + // twoGraphsResult reports one page after two graphs were laid out together. + twoGraphsResult struct { + // Duplicates lists ids that appear more than once in the page. + Duplicates []string `json:"duplicates"` + // Graphs describes the first and the second view, in that order. + Graphs []graphIsolation `json:"graphs"` + } + + // graphIsolation describes one graph's live svg and its exported file. + graphIsolation struct { + // Nodes lists the model element ids of the graph's nodes. + Nodes []string `json:"nodes"` + // OwnNodes is true when the svg holds exactly this graph's node elements. + OwnNodes bool `json:"ownNodes"` + // Zoom is the transform that fitting the layout set on this svg. + Zoom string `json:"zoom"` + // Grid is true when this svg shows its own grid. + Grid bool `json:"grid"` + // Unresolved lists url(#…) and #… references with no target in this svg. + Unresolved []string `json:"unresolved"` + // Export is the graph's exported SVG file. + Export string `json:"export"` + // ExportRootID is the id of the exported root element. + ExportRootID string `json:"exportRootId"` + // ExportNodes lists the ids of the exported node elements. + ExportNodes []string `json:"exportNodes"` + // ExportLeaks lists exported values that still name the live id prefix. + ExportLeaks []string `json:"exportLeaks"` + // ExportDefs is true when the export has the saved definition ids. + ExportDefs bool `json:"exportDefs"` + // ExportGrid is true when the exported grid uses the saved grid ids. + ExportGrid bool `json:"exportGrid"` + } +) + +// TestTwoGraphsInOneDocument proves that two graphs drawn in one page keep +// their own nodes, ids, fit, grid, and export. The editor shows one view at a +// time, so the test opens the first view, switches to the second view with the +// view selector, puts the first view's svg back in the page, and lays out both +// graphs at the same time. Both graphs use the editor's fixed 25px grid. +func TestTwoGraphsInOneDocument(t *testing.T) { + if !hasChrome() { + t.Skip("skipping: Chrome/Chromium not available in PATH") + } + listener, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatalf("listen: %v", err) + } + server := NewServer(twoViewDesign()) + httpServer := &http.Server{ReadHeaderTimeout: 3 * time.Second} + serverDone := make(chan error, 1) + outDir := t.TempDir() + go func() { + serverDone <- server.ServeOnListener(outDir, "", httpServer, http.NewServeMux(), listener) + }() + t.Cleanup(func() { + if err := httpServer.Close(); err != nil { + t.Errorf("close editor server: %v", err) + } + if err := <-serverDone; err != nil && err != http.ErrServerClosed { + t.Errorf("editor server: %v", err) + } + }) + testContext, cleanup := newChromeContext(t) + defer cleanup() + + const switchScript = `(() => { + window.firstGraph = ` + editorGraphScript + `; + const views = document.querySelector(".toolbar select"); + views.value = "Containers"; + views.dispatchEvent(new Event("change", {bubbles: true})); + return true; + })()` + const secondDrawnScript = `(() => { + const graph = ` + editorGraphScript + `; + return graph !== null && graph !== window.firstGraph && + graph.nodes().every(node => node.ref?.isConnected); + })()` + const layoutScript = `(async () => { + const graphs = [window.firstGraph, ` + editorGraphScript + `]; + const holder = document.createElement("div"); + document.body.append(holder); + holder.append(graphs[0].svg); + graphs.forEach(graph => graph.toggleGrid()); + await Promise.all(graphs.map(graph => graph.autoLayout())); + const ids = [...document.querySelectorAll("[id]")].map(el => el.id); + return { + duplicates: ids.filter((id, index) => ids.indexOf(id) !== index), + graphs: graphs.map(graph => { + const svg = graph.svg; + const refs = graph.nodes().map(node => node.ref); + const drawn = [...svg.querySelectorAll("g.nodes > g.node")]; + const unresolved = []; + for (const el of svg.querySelectorAll("*")) { + for (const attr of el.attributes) { + const target = attr.value.match(/^url\(#(.+)\)$/)?.[1] ?? + (attr.localName === "href" && attr.value.startsWith("#") ? attr.value.slice(1) : null); + if (target && !svg.querySelector('[id="' + target + '"]')) unresolved.push(attr.value); + } + } + const markup = graph.exportSVG(); + const exported = new DOMParser().parseFromString(markup, "image/svg+xml").documentElement; + const leaks = [...exported.querySelectorAll("*")].flatMap(el => [...el.attributes] + .filter(attr => (attr.name === "id" && attr.value.startsWith(graph.idPrefix)) || + attr.value.includes("#" + graph.idPrefix)) + .map(attr => attr.value)); + return { + nodes: graph.nodes().map(node => node.id).sort(), + ownNodes: drawn.length === refs.length && drawn.every(el => refs.includes(el)), + zoom: svg.querySelector("g.zoom").getAttribute("transform") || "", + grid: svg.querySelector("pattern") !== null, + unresolved, + export: markup, + exportRootId: exported.id, + exportNodes: [...exported.querySelectorAll("g.node")].map(node => node.id).sort(), + exportLeaks: leaks, + exportDefs: ["#inter-font-license", "marker#arrow", "#icon-circle", "#icon-cube"] + .every(selector => exported.querySelector(selector) !== null), + exportGrid: exported.querySelector("pattern#grid-pattern") !== null && + exported.querySelector("rect#grid-background")?.getAttribute("fill") === "url(#grid-pattern)", + }; + }), + }; + })()` + var switched bool + var result twoGraphsResult + if err := chromedp.Run(testContext, + chromedp.Navigate(fmt.Sprintf("http://%s/?id=Context", listener.Addr().String())), + chromedp.Poll(editorDrawnScript, nil), + chromedp.Evaluate(switchScript, &switched), + chromedp.Poll(secondDrawnScript, nil), + chromedp.Evaluate(layoutScript, &result, func(params *cdruntime.EvaluateParams) *cdruntime.EvaluateParams { + return params.WithAwaitPromise(true) + }), + ); err != nil { + t.Fatalf("lay out two graphs in one page: %v", err) + } + + if len(result.Duplicates) > 0 { + t.Errorf("ids shared by the two graphs: %v", result.Duplicates) + } + if len(result.Graphs) != 2 { + t.Fatalf("expected two graphs, got %d", len(result.Graphs)) + } + for i, want := range []struct { + view string + nodes []string + orientation string + }{ + {"Context", []string{"shop", "user"}, "horizontal"}, + {"Containers", []string{"db", "user", "web"}, "vertical"}, + } { + got := result.Graphs[i] + if !reflect.DeepEqual(got.Nodes, want.nodes) || !got.OwnNodes { + t.Errorf("%s: svg nodes %v (only its own: %t), want %v", want.view, got.Nodes, got.OwnNodes, want.nodes) + } + if got.Zoom == "" { + t.Errorf("%s: layout fit was not applied to this graph's svg", want.view) + } + if !got.Grid { + t.Errorf("%s: svg has no grid", want.view) + } + if len(got.Unresolved) > 0 { + t.Errorf("%s: references to ids outside this svg: %v", want.view, got.Unresolved) + } + if got.ExportRootID != "graph" || !reflect.DeepEqual(got.ExportNodes, want.nodes) { + t.Errorf("%s: export root %q nodes %v, want graph %v", want.view, got.ExportRootID, got.ExportNodes, want.nodes) + } + if len(got.ExportLeaks) > 0 || !got.ExportDefs || !got.ExportGrid { + t.Errorf("%s: export ids not saved names: leaks %v, defs %t, grid %t", + want.view, got.ExportLeaks, got.ExportDefs, got.ExportGrid) + } + path := filepath.Join(t.TempDir(), want.view+".svg") + if err := os.WriteFile(path, []byte(got.Export), 0600); err != nil { + t.Fatalf("save %s export: %v", want.view, err) + } + if issues := inspectArrowMarkerIssues(t, path); len(issues) > 0 { + t.Errorf("%s: exported arrow markers: %v", want.view, issues) + } + if orientation := inspectNodeOrientation(t, path); orientation != want.orientation { + t.Errorf("%s: exported layout is %s, want %s", want.view, orientation, want.orientation) + } + } +} + +// twoViewDesign returns one model with two views that share the element +// "user" and differ in shapes, colors, and layout direction. +func twoViewDesign() *mdl.Design { + return &mdl.Design{ + Name: "Two views", + Model: &mdl.Model{ + People: []*mdl.Person{{ + ID: "user", Name: "Customer", Tags: "Element,Person,person", + Relationships: []*mdl.Relationship{ + {ID: "browse", SourceID: "user", DestinationID: "shop", Description: "Browses", Tags: "Relationship"}, + {ID: "order", SourceID: "user", DestinationID: "web", Description: "Orders through", Tags: "Relationship"}, + }, + }}, + Systems: []*mdl.SoftwareSystem{{ + ID: "shop", Name: "Shop", Tags: "Element,Software System", + Containers: []*mdl.Container{ + {ID: "web", Name: "Web", Tags: "Element,Container,web", Relationships: []*mdl.Relationship{ + {ID: "save", SourceID: "web", DestinationID: "db", Description: "Saves orders", Tags: "Relationship"}, + }}, + {ID: "db", Name: "Orders", Tags: "Element,Container,store"}, + }, + }}, + }, + Views: &mdl.Views{ + ContextViews: []*mdl.ContextView{{SoftwareSystemID: "shop", ViewProps: &mdl.ViewProps{ + Key: "Context", + AutoLayout: &mdl.AutoLayout{RankDirection: mdl.RankLeftRight}, + ElementViews: []*mdl.ElementView{{ID: "user"}, {ID: "shop"}}, + RelationshipViews: []*mdl.RelationshipView{{ID: "browse"}}, + }}}, + ContainerViews: []*mdl.ContainerView{{SoftwareSystemID: "shop", ViewProps: &mdl.ViewProps{ + Key: "Containers", + AutoLayout: &mdl.AutoLayout{RankDirection: mdl.RankTopBottom}, + ElementViews: []*mdl.ElementView{{ID: "user"}, {ID: "web"}, {ID: "db"}}, + RelationshipViews: []*mdl.RelationshipView{{ID: "order"}, {ID: "save"}}, + }}}, + Styles: &mdl.Styles{Elements: []*mdl.ElementStyle{ + {Tag: "person", Shape: mdl.ShapePerson}, + {Tag: "web", Background: "#e0f2fe", Stroke: "#0369a1"}, + {Tag: "store", Shape: mdl.ShapeCylinder, Background: "#fef3c7"}, + }}, + }, + } +} diff --git a/cmd/mdl/svg_e2e_test.go b/cmd/mdl/svg_e2e_test.go index 1713614d..06837813 100644 --- a/cmd/mdl/svg_e2e_test.go +++ b/cmd/mdl/svg_e2e_test.go @@ -47,6 +47,28 @@ type ( } ) +const ( + // editorNodeSelector matches the nodes the editor page has drawn. + editorNodeSelector = "#root > div.graph svg g.nodes > g.node" + // autoLayoutButton is the editor toolbar button that lays out the view. + autoLayoutButton = "button.auto-arrange" + // saveButton is the editor toolbar button that saves the view's SVG file. + saveButton = `button[data-tooltip^="Save"]` + // editorGraphScript evaluates to the graph object the editor page draws, or + // null before it draws one. The page exposes no handle, so this test-only + // driver reads the Graph component's data prop from React's fiber. + editorGraphScript = `(() => { + const host = document.querySelector("#root > div.graph"); + const key = host && Object.keys(host).find(name => name.startsWith("__reactFiber$")); + for (let fiber = key && host[key]; fiber; fiber = fiber.return) { + if (fiber.memoizedProps?.data) return fiber.memoizedProps.data; + } + return null; + })()` + // editorDrawnScript is true once every node of the editor's graph is in the page. + editorDrawnScript = editorGraphScript + `?.nodes().every(node => node.ref?.isConnected)` +) + func hasChrome() bool { if os.Getenv("CHROME_BIN") != "" { return true @@ -168,7 +190,7 @@ func TestManualEditAfterAutoLayout(t *testing.T) { url.QueryEscape("SystemContext"), ) const script = `(async () => { - const graph = window.gdata; + const graph = ` + editorGraphScript + `; await graph.autoLayout(); const node = graph.nodes()[0]; graph.moveNode(node, node.x + 20, node.y, true); @@ -185,10 +207,7 @@ func TestManualEditAfterAutoLayout(t *testing.T) { if err := chromedp.Run( testContext, chromedp.Navigate(pageURL), - chromedp.Poll( - `window.gdata && window.gdata.nodes().every(node => node.ref?.isConnected)`, - nil, - ), + chromedp.Poll(editorDrawnScript, nil), chromedp.Evaluate( script, &dimensions, @@ -266,25 +285,16 @@ func TestSVGAuthoredPresentation(t *testing.T) { testContext, cleanup := newChromeContext(t) defer cleanup() pageURL := fmt.Sprintf("http://%s/?id=Authored", listener.Addr().String()) - const renderScript = `(async () => { - const graph = window.gdata; - await graph.autoLayout(); - return graph.exportSVG(); - })()` - var exported string + // The editor's toolbar lays out the view and saves its SVG into outDir. if err := chromedp.Run(testContext, chromedp.Navigate(pageURL), - chromedp.Poll(`window.gdata && window.gdata.nodes().every(node => node.ref?.isConnected)`, nil), - chromedp.Evaluate(renderScript, &exported, func(params *cdruntime.EvaluateParams) *cdruntime.EvaluateParams { - return params.WithAwaitPromise(true) - }), + chromedp.WaitVisible(editorNodeSelector, chromedp.ByQuery), + clickEditorButton(autoLayoutButton), + clickEditorButton(saveButton), ); err != nil { t.Fatalf("draw authored styles: %v", err) } - file := filepath.Join(t.TempDir(), "authored.svg") - if err := os.WriteFile(file, []byte(exported), 0600); err != nil { - t.Fatalf("save authored SVG: %v", err) - } + file := filepath.Join(outDir, "Authored.svg") // Another browser proves the exported file carries its own font faces. exportContext, cleanupExport := newChromeContext(t) defer cleanupExport() @@ -756,6 +766,25 @@ func newChromeContext(t *testing.T) (context.Context, func()) { return testContext, cleanup } +// clickEditorButton clicks one editor toolbar button and waits until the editor +// enables it again, which happens once the layout or save it started finishes. +func clickEditorButton(selector string) chromedp.Action { + var finished bool + script := fmt.Sprintf(`new Promise(resolve => { + const button = document.querySelector(%q); + new MutationObserver((records, observer) => { + if (records.some(record => record.oldValue !== null)) { + observer.disconnect(); + resolve(true); + } + }).observe(button, {attributeFilter: ["disabled"], attributeOldValue: true}); + button.click(); + })`, selector) + return chromedp.Evaluate(script, &finished, func(params *cdruntime.EvaluateParams) *cdruntime.EvaluateParams { + return params.WithAwaitPromise(true) + }) +} + func svgLinks(t *testing.T, path string) []string { t.Helper() file, err := os.Open(path) diff --git a/cmd/mdl/webapp/dist/286.js b/cmd/mdl/webapp/dist/286.js index 7ddd8c86..84349f6d 100644 --- a/cmd/mdl/webapp/dist/286.js +++ b/cmd/mdl/webapp/dist/286.js @@ -1,2 +1,2 @@ -"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[286],{628(t,e,n){n.d(e,["AV",0,(t,e)=>{Object.entries(e).forEach(([e,n])=>{t.setAttribute(e,String(n))})},"M5",0,{nodeBorder:{"stroke-width":1.5},nodeText:{"font-family":"Inter, -apple-system, BlinkMacSystemFont, sans-serif",stroke:"none"},edgeText:{"font-family":"Inter, -apple-system, BlinkMacSystemFont, sans-serif",stroke:"none"},edgeRect:{fill:"none",stroke:"none"},groupRect:{fill:"none",stroke:"#8492a6","stroke-width":1.5,"stroke-dasharray":"6 4"},groupText:{fill:"#475569","font-size":20,"font-weight":"600","font-family":"Inter, -apple-system, BlinkMacSystemFont, sans-serif",cursor:"default"}},"Y$",0,{thickness:2,color:"#64748b",opacity:1,fontSize:18,width:200,dashed:!0},"gd",0,(t,e)=>Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)),"nD",0,{width:280,height:180,background:"#ffffff",color:"#334155",opacity:1,stroke:"#8492a6",fontSize:22,shape:"Box",metadata:!0,description:!0}])},977(t,e,n){n.d(e,{IW:()=>r,Zr:()=>s,l:()=>i});var o=n(628);function i(t){const e=t.from,n=t.to;let o=t.vertices?t.vertices.concat():[];o.unshift(e),o.push(n);const i=o.slice(1,-1),r=i.find(t=>!t.label)??n;let s=e;for(let t=i.length-1;t>=0;t--)if(!i[t].label){s=i[t];break}if(!e.intersect||!n.intersect)throw new Error(`edge ${t.id} nodes must be drawn before routing`);return o[0]=e.intersect(r),o[o.length-1]=n.intersect(s),o}function r(t,e,n){let i,r={x:n.x,y:n.y};const s=t.findIndex(t=>t.label);let a=!0;if(s>=0){const e=t[s];r=e,a=!0===e.auto;const n=[];s>0&&n.push({p:t[s-1],q:r}),st?(0,o.gd)(e.p,e.q)>(0,o.gd)(t.p,t.q)?e:t:e,void 0)}else{const n=t.slice(1).reduce((e,n,i)=>e+(0,o.gd)(t[i],n),0)*e;let s=0;for(let e=1;e0&&s+d>=n){const t=(n-s)/d;r={x:a.p.x+(a.q.x-a.p.x)*t,y:a.p.y+(a.q.y-a.p.y)*t},i=a;break}s+=d}}const d=i?Math.abs(i.q.x-i.p.x):0,l=i?Math.abs(i.q.y-i.p.y):0;return{...r,orientation:l>d?"vertical":"horizontal",segment:i,movable:a}}function s(t){if(t.length<2)throw new Error("edge route must contain at least two points");return t.slice(1).reduce((t,e)=>`${t} L${e.x},${e.y}`,`M${t[0].x},${t[0].y}`)}},20(t,e,n){n.d(e,{r:()=>i}),Symbol("ValidatedLayout");class o extends Error{issues;constructor(t){super(t.map(t=>t.message).join("\n")),this.name="GeometryValidationError",this.issues=t}}function i(t,e){const n=[];t.id!==e.diagramId&&n.push(C("missing_element",[t.id,e.diagramId],`layout ${e.diagramId} does not resolve measured diagram ${t.id}`)),r("measured node",t.nodes.map(t=>t.id),n),r("measured group",t.groups.map(t=>t.id),n),r("measured edge",t.edges.map(t=>t.id),n),r("resolved node",e.nodes.map(t=>t.id),n),r("resolved group",e.groups.map(t=>t.id),n),r("resolved edge",e.edges.map(t=>t.id),n),s("node",t.nodes.map(t=>t.id),e.nodes.map(t=>t.id),n),s("group",t.groups.map(t=>t.id),e.groups.map(t=>t.id),n),s("edge",t.edges.map(t=>t.id),e.edges.map(t=>t.id),n);const i=new Map(t.nodes.map(t=>[t.id,t])),b=new Map(t.groups.map(t=>[t.id,t])),y=new Map(e.nodes.map(t=>[t.id,t])),B=new Map(e.groups.map(t=>[t.id,t]));a("diagram",e.diagramId,e.bounds,n);for(const t of e.nodes){a("node",t.id,t.bounds,n);const o=i.get(t.id);!o||w(o.size.width,t.bounds.width)&&w(o.size.height,t.bounds.height)||n.push(C("size_mismatch",[t.id],`node ${t.id} size changed after measurement`)),o&&(o.contentSize.width>t.bounds.width||o.contentSize.height>t.bounds.height)&&n.push(C("content_overflow",[t.id],`node ${t.id} content exceeds its resolved bounds`)),d("node",t.id,t.bounds,e.bounds,n)}for(const t of e.groups){a("group",t.id,t.bounds,n),a("group title",t.id,t.titleBounds,n),d("group",t.id,t.bounds,e.bounds,n),g(t.bounds,t.titleBounds)||n.push(C("false_containment",[t.id],`group ${t.id} does not contain its title`));const o=b.get(t.id);!o||w(o.titleSize.width,t.titleBounds.width)&&w(o.titleSize.height,t.titleBounds.height)||n.push(C("size_mismatch",[t.id],`group ${t.id} title size changed after measurement`))}if(function(t,e){x(t,(t,n)=>{A(t.bounds,n.bounds)&&e.push(C("node_overlap",[t.id,n.id],`nodes ${t.id} and ${n.id} overlap`))})}(e.nodes,n),function(t,e){x(t,(t,n)=>{!A(t.bounds,n.bounds)||g(t.bounds,n.bounds)||g(n.bounds,t.bounds)||e.push(C("group_overlap",[t.id,n.id],`groups ${t.id} and ${n.id} partially overlap`))})}(e.groups,n),function(t,e,n,o,i){for(const e of t){const t=n.get(e.id);if(t&&t.parentId!==e.parentId&&i.push(C("false_containment",[e.id],`node ${e.id} has the wrong parent ID`)),!e.parentId)continue;const r=o.get(e.parentId);t&&r&&!g(r.bounds,t.bounds)&&i.push(C("false_containment",[e.id,e.parentId],`node ${e.id} lies outside owning group ${e.parentId}`))}for(const t of e){const e=o.get(t.id);if(e&&e.parentId!==t.parentId&&i.push(C("false_containment",[t.id],`group ${t.id} has the wrong parent ID`)),!t.parentId)continue;const n=o.get(t.parentId);e&&n&&!g(n.bounds,e.bounds)&&i.push(C("false_containment",[t.id,t.parentId],`group ${t.id} lies outside owning group ${t.parentId}`))}}(t.nodes,t.groups,y,B,n),function(t,e,n,o,i,r,s){const g=new Map(t.edges.map(t=>[t.id,t])),b=[];for(const t of e.edges){const y=g.get(t.id);if(y)if(t.sourceId===y.sourceId&&t.targetId===y.targetId||s.push(C("disconnected_edge",[t.id,t.sourceId,t.targetId],`edge ${t.id} endpoints do not match its measured contract`)),0===t.sections.length||t.sections.some(t=>t.length<2))s.push(C("disconnected_edge",[t.id],`edge ${t.id} has no complete route section`));else{l(t,n,s);for(const n of t.sections)for(const o of n)if(!m(o)||!p(o,e.bounds,!0)){s.push(C("out_of_bounds",[t.id],`edge ${t.id} has a route point outside the resolved view`));break}for(const e of n.values())e.id!==t.sourceId&&e.id!==t.targetId&&u(t.sections,f(e.bounds,.5))&&s.push(C("edge_through_node",[t.id,e.id],`edge ${t.id} crosses unrelated node ${e.id}`));for(const e of o.values()){const n=c(t.sourceId,e.id,i,r);n===c(t.targetId,e.id,i,r)&&h(t.sections,e.bounds,n)&&s.push(C("edge_through_group",[t.id,e.id],`edge ${t.id} violates group ${e.id} boundary`))}if(t.labelBounds){a("edge label",t.id,t.labelBounds,s),d("edge label",t.id,t.labelBounds,e.bounds,s),!y.labelSize||w(y.labelSize.width,t.labelBounds.width)&&w(y.labelSize.height,t.labelBounds.height)||s.push(C("size_mismatch",[t.id],`edge ${t.id} label size changed after measurement`));for(const e of n.values())A(t.labelBounds,e.bounds)&&s.push(C("label_node_overlap",[t.id,e.id],`edge ${t.id} label overlaps node ${e.id}`));for(const e of o.values())A(t.labelBounds,e.titleBounds)&&s.push(C("label_title_overlap",[t.id,e.id],`edge ${t.id} label overlaps group ${e.id} title`));b.push({id:t.id,bounds:t.labelBounds})}else y.labelSize&&s.push(C("missing_element",[t.id],`edge ${t.id} is missing its measured label`))}}x(b,(t,e)=>{A(t.bounds,e.bounds)&&s.push(C("label_label_overlap",[t.id,e.id],`edge labels ${t.id} and ${e.id} overlap`))});for(const t of b)for(const n of e.edges)u(n.sections,f(t.bounds,.5))&&s.push(C("label_edge_overlap",[t.id,n.id],`edge ${n.id} crosses label ${t.id}`))}(t,e,y,B,i,b,n),n.length>0)throw new o(n);return e}function r(t,e,n){const o=new Set;for(const i of e)o.has(i)&&n.push(C("duplicate_id",[i],`${t} ${i} is duplicated`)),o.add(i)}function s(t,e,n,o){const i=new Set(e),r=new Set(n);for(const e of i)r.has(e)||o.push(C("missing_element",[e],`${t} ${e} is missing from resolved layout`));for(const e of r)i.has(e)||o.push(C("unexpected_element",[e],`${t} ${e} is not in the measured diagram`))}function a(t,e,n,o){(!function(t){return m(t)&&Number.isFinite(t.width)&&Number.isFinite(t.height)}(n)||n.width<0||n.height<0)&&o.push(C("non_finite",[e],`${t} ${e} has invalid geometry`))}function d(t,e,n,o,i){g(o,n)||i.push(C("out_of_bounds",[e],`${t} ${e} lies outside the resolved view bounds`))}function l(t,e,n){for(let e=1;et.some((n,o)=>o>0&&function(t,e,n){const o=e.x-t.x,i=e.y-t.y;let r=0,s=1;for(const[e,a,d,l]of[[t.x,o,n.x,n.x+n.width],[t.y,i,n.y,n.y+n.height]]){if(Math.abs(a)=l)return!1;continue}const t=(d-e)/a,n=(l-e)/a;if(r=Math.max(r,Math.min(t,n)),s=Math.min(s,Math.max(t,n)),r>=s)return!1}return s>0&&r<1}(t[o-1],n,e)))}function A(t,e){return t.x=e.x+e.width&&t.y+t.height>=e.y+e.height}function p(t,e,n){return n?t.x>=e.x&&t.y>=e.y&&t.x<=e.x+e.width&&t.y<=e.y+e.height:t.x>e.x&&t.y>e.y&&t.x=e.x-.1&&t.x<=e.x+e.width+.1,o=t.y>=e.y-.1&&t.y<=e.y+e.height+.1,i=w(t.x,e.x)||w(t.x,e.x+e.width),r=w(t.y,e.y)||w(t.y,e.y+e.height);return o&&i||n&&r}function w(t,e){return Math.abs(t-e)<=.1}function x(t,e){for(let n=0;n$,Qy:()=>G,ZG:()=>T,oP:()=>F,IX:()=>Y,F_:()=>J,Kp:()=>Q,a_:()=>P});var o=n(74),i=n(321);const r=`\n\n\t\n\t${i.replace(/&/g,"&").replace(/\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n`;var s=n(718),a=n(628);const d={element(t,e={},n){const o=document.createElementNS("http://www.w3.org/2000/svg",t);return Object.entries(e).forEach(([t,e])=>o.setAttribute(t,String(e))),n&&o.classList.add(n),o},use(t,e={}){const n=this.element("use",e);return n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","#"+t),n},path(t,e={},n){return this.element("path",{...e,d:t},n)},text(t,e={}){const n=this.element("text",e);return t&&(n.textContent=t),n},textArea(t,e,n,o,i=0,r=0,d=""){const l={"font-family":a.M5.edgeText["font-family"],"font-size":`${n}px`,"font-weight":o?"bold":"normal"},{lines:c,maxW:h}=(0,s.U2)(t,e,l),u=this.text("",{x:0,y:r,"text-anchor":d||void 0});return c.forEach((t,e)=>{const o=this.element("tspan",{x:i,dy:`${n+2}px`,...l});o.textContent=t,u.append(o)}),{txt:u,dy:(c.length+1)*(n+2),maxW:h}},rect(t,e,n=0,o=0,i=0,r){return this.element("rect",{x:n,y:o,rx:i,ry:i,width:t,height:e},r)},icon(t,e=0,n=0){return this.use(t,{x:e,y:n})},expand(t,e,n){const o=this.element("g",{transform:`translate(${t},${e})`},"expand");return o.append(this.rect(19,19,0,0,1),this.text(n?"-":"+",{x:10,y:14,"text-anchor":"middle"})),o}};function l(t,e,n){t.setAttribute("transform",`translate(${e},${n})`)}function c(t,e,n=!0){return n?t.x>e.x-e.width/2&&t.xe.y-e.height/2&&t.ye.x&&t.xe.y&&t.yfunction(t,e,n,o){let i,r,s,a,d,l={x:null,y:null,onLine1:!1,onLine2:!1};return i=(o.y-n.y)*(e.x-t.x)-(o.x-n.x)*(e.y-t.y),0==i||(r=t.y-n.y,s=t.x-n.x,a=(o.x-n.x)*r-(o.y-n.y)*s,d=(e.x-t.x)*r-(e.y-t.y)*s,r=a/i,s=d/i,l.x=t.x+r*(e.x-t.x),l.y=t.y+r*(e.y-t.y),r>0&&r<1&&(l.onLine1=!0),s>=0&&s<=1&&(l.onLine2=!0)),l}(t,e,n.p,n.q)).filter(t=>t.onLine1&&t.onLine2)}(t,e,t)[0]||{x:t.x,y:t.y}}function u(t,e,n,o,i){const r={x:i.x-t.x,y:i.y-t.y},s=o.x-t.x,a=o.y-t.y;s==r.x&&(r.x+=1e-7);const d=(a-r.y)/(s-r.x),l=a-d*s,c=n*n+e*e*d*d,h=2*e*e*l*d,u=e*e*l*l-e*e*n*n,A=Math.sqrt(h*h-4*c*u),g=r.x>s?(-h+A)/(2*c):(-h-A)/(2*c),p={x:g,y:d*g+l};return p.x+=t.x,p.y+=t.y,p}function A(t,e,n){let o=n.x-e.x,i=n.y-e.y,r=o*o+i*i,s=(t.x-e.x)*o+(t.y-e.y)*i,a=Math.min(1,Math.max(0,s/r));return{x:e.x+o*a,y:e.y+i*a}}function g(t,e){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function p(t){return t/2/(5.5+t/70)}function f(t,e,n){switch(t.toLowerCase()){case"cylinder":return 2*p(e);case"person":return.4*n;case"folder":return e/10;case"robot":return.35*n;case"webbrowser":return n/8;default:return 0}}class m{_el;constructor(t){this._el=t}node(){return this._el}attr(t,e){return this._el.setAttribute(t,String(e)),this}insert(t,e){const n=document.createElementNS("http://www.w3.org/2000/svg",t),o=this._el.insertBefore(n,this._el.querySelector(e));return new m(o)}}function b(t,e,n,o=!1){const i=t.insert("rect",":first-child").attr("rx",o?n.width/8:3).attr("ry",o?n.width/8:3).attr("x",-e.width/2).attr("y",-e.height/2).attr("width",e.width).attr("height",e.height);return n.intersect=function(t){return h(n,t)},i}function y(t,e,n,o,i){const r=t.insert("ellipse",":first-child").attr("cx",0).attr("cy",0).attr("rx",o).attr("ry",i).attr("width",n.width).attr("height",n.height);return n.intersect=function(t){return u(n,o,i,n,t)},r}function w(t,e,n){const o=n.width/8,i=n.width/14,r=t.insert("g",":first-child");return r.insert("path",":first-child").attr("d",`M${-n.width/2},${-n.height/2} l${n.width},0 M${-n.width/2},${n.height/2} l${n.width},0`),r.insert("circle",":first-child").attr("cx",0).attr("cy",n.height/2+o/2).attr("r",.4*i),r.insert("rect",":first-child").attr("x",-i).attr("y",-n.height/2-o/2-.2*i).attr("width",2*i).attr("height",.4*i),r.insert("rect",":first-child").attr("rx",i).attr("ry",i).attr("x",-e.width/2).attr("y",-e.height/2-o).attr("width",e.width).attr("height",e.height+2*o),n.intersect=function(t){return h({x:n.x,y:n.y,width:n.width,height:n.height+2*o},t)},r}const x={box:(t,e)=>b(new m(t),e,e).node(),roundedbox:(t,e)=>b(new m(t),e,e,!0).node(),component:(t,e)=>function(t,e,n){const o=n.width/10,i=t.insert("g",":first-child");return i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2-o).attr("y",-n.height/2+o).attr("width",2*o).attr("height",o),i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2-o).attr("y",-n.height/2+2.5*o).attr("width",2*o).attr("height",o),i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2).attr("y",-n.height/2).attr("width",n.width).attr("height",n.height),n.intersect=function(t){return h({x:n.x-o/2,y:n.y,width:n.width+o,height:n.height},t)},i}(new m(t),0,e).node(),cylinder:(t,e)=>function(t,e,n){const o=e.width,i=o/2,r=p(o),s=e.height,a=`M 0,${r} a${i},${r} 0,0,0 ${o} 0 a ${i},${r} 0,0,0 ${-o} 0 l 0,${s-2*r} a ${i},${r} 0,0,0 ${o} 0 l 0,${2*r-s}`,d=t.attr("label-offset-y",f("cylinder",o,s)).insert("path",":first-child").attr("d",a).attr("transform","translate("+-o/2+","+-s/2+")");return n.intersect=function(t){const e=h(n,t);let o=n.y+n.height/2-r;return e.y>o?u({x:n.x,y:o},i,r,n,t):(o=n.y-n.height/2+r,e.yfunction(t,e,n){const o=e.width,i=e.height,r=`M ${.38*o},${i/3} A${o/2},${i/2} 0,0,0 0 ${i/2}\n\t\tL${o/11},${i} L${o-o/11},${i} L${o},${i/2}\n\t\tA${o/2},${i/2} 0,0,0 ${o-.38*o} ${i/3} \n\t\tA${o/6},${o/6} 0,1,0 ${.38*o} ${i/3}`,s=t.attr("label-offset-y",f("person",o,i)).insert("path",":first-child").attr("d",r).attr("transform","translate("+-o/2+","+-i/2+")");return n.intersect=function(t){return h(n,t)},s}(new m(t),e,e).node(),circle:(t,e)=>function(t,e,n){return y(t,0,n,n.width/2,n.width/2)}(new m(t),0,e).node(),ellipse:(t,e)=>function(t,e,n){return y(t,0,n,.55*n.width,.45*n.width)}(new m(t),0,e).node(),hexagon:(t,e)=>function(t,e,n){const o=n.width/2,i=t.insert("polygon",":first-child").attr("points",[.5,.866,1,0,.5,-.866,-.5,-.866,-1,-0,-.5,.866,.5,.866].map(t=>t*o).join(",")).attr("width",n.width).attr("height",n.height);return n.intersect=function(t){return u(n,n.width/2,n.width/2,n,t)},i}(new m(t),0,e).node(),folder:(t,e)=>function(t,e,n){const o=n.width/20,i=t.attr("label-offset-y",f("folder",n.width,n.height)).insert("g",":first-child");return i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2).attr("y",-n.height/2+2*o).attr("width",n.width).attr("height",n.height-2*o),i.insert("path",":first-child").attr("d",`M0,${-n.height/2+2*o} l${o},${-2*o} h${n.width/2-2*o} v${2*o}`),n.intersect=function(t){return h({x:n.x,y:n.y+o/2,width:n.width,height:n.height+o},t)},i}(new m(t),0,e).node(),mobiledevicelandscape:(t,e)=>function(t,e,n){const o=n.width/8,i=n.width/14,r=t.insert("g",":first-child");return r.insert("path",":first-child").attr("d",`M${-n.width/2},${-n.height/2} l0,${n.height} M${n.width/2},${-n.height/2} l0,${n.height}`),r.insert("circle",":first-child").attr("cx",-n.width/2-o/2).attr("cy",0).attr("r",.4*i),r.insert("rect",":first-child").attr("x",n.width/2+o/2-.2*i).attr("y",-i).attr("width",.4*i).attr("height",2*i),r.insert("rect",":first-child").attr("rx",i).attr("ry",i).attr("x",-e.width/2-o).attr("y",-e.height/2).attr("width",e.width+2*o).attr("height",e.height),n.intersect=function(t){return h({x:n.x,y:n.y,width:n.width+2*o,height:n.height},t)},r}(new m(t),e,e).node(),mobiledeviceportrait:(t,e)=>w(new m(t),e,e).node(),mobiledevice:(t,e)=>w(new m(t),e,e).node(),pipe:(t,e)=>function(t,e,n){const o=n.width,i=n.height,r=i/2,s=r/(2.5+o/70),a=`M${-s},0\n\t\ta${s},${r} 0,0,1 0,${i}\n\t\ta${s},${r} 0,0,1 0,${-i}\n\t\tl${o},0\n\t\ta${s},${r} 0,0,1 0,${i}\n\t\tl${-o},0`,d=t.insert("path",":first-child").attr("d",a).attr("transform","translate("+-o/2+","+-i/2+")");return n.intersect=function(t){return h({x:n.x-s,y:n.y,width:n.width+2*s,height:n.height},t)},d}(new m(t),0,e).node(),robot:(t,e)=>function(t,e,n){const o=n.width,i=n.height,r=Math.min(.28*o,.25*i),s=.2*r,a=.25*r,d=.08*r,l=.12*r,c=.22*r,u=.12*r,A=.3*r,g=o,p=-i/2+a+r,m=i-a-r,b=t.attr("label-offset-y",f("robot",o,i)).insert("g",":first-child");b.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-g/2).attr("y",p).attr("width",g).attr("height",m);const y=-i/2+a;b.insert("rect",":first-child").attr("rx",s).attr("ry",s).attr("x",-r/2).attr("y",y).attr("width",r).attr("height",r),b.insert("line",":first-child").attr("class","robot-antenna").attr("x1",0).attr("y1",y).attr("x2",0).attr("y2",-i/2+2*d).attr("stroke-width",.6*d).attr("stroke-linecap","round"),b.insert("circle",":first-child").attr("class","robot-antenna-ball").attr("cx",0).attr("cy",-i/2+2*d).attr("r",1.2*d);const w=y+.4*r;b.insert("circle",":first-child").attr("class","robot-eye").attr("cx",-c).attr("cy",w).attr("r",l),b.insert("circle",":first-child").attr("class","robot-eye").attr("cx",c).attr("cy",w).attr("r",l);const x=y+.7*r,C=.28*r;return b.insert("path",":first-child").attr("class","robot-mouth").attr("d",`M${-C/2},${x} Q0,${x+.3*C} ${C/2},${x}`).attr("fill","none").attr("stroke-width",.5*d).attr("stroke-linecap","round"),b.insert("rect",":first-child").attr("rx",.25*u).attr("ry",.25*u).attr("x",-r/2-u-1).attr("y",w-A/2).attr("width",u).attr("height",A),b.insert("rect",":first-child").attr("rx",.25*u).attr("ry",.25*u).attr("x",r/2+1).attr("y",w-A/2).attr("width",u).attr("height",A),n.intersect=function(t){return h(n,t)},b}(new m(t),0,e).node(),webbrowser:(t,e)=>function(t,e,n){const o=n.height/8,i=t.attr("label-offset-y",f("webbrowser",n.width,n.height)).insert("g",":first-child");return i.insert("path",":first-child").attr("d",`\n\t\t\tM${-n.width/2},${-n.height/2+o} h${n.width}\n\t\t\tM${-n.width/2+o/4},${-n.height/2+o/4} h${o/2} v${o/2} h${-o/2} z\n\t\t\tM${-n.width/2+o},${-n.height/2+o/4} h${n.width-o-o/4} v${o/2} h${-n.width+o+o/4} z\n\t\t`),i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2).attr("y",-n.height/2).attr("width",n.width).attr("height",n.height),n.intersect=function(t){return h(n,t)},i}(new m(t),0,e).node()};var C=n(983);class B{versions=[];pos=0;lastSavedPos=0;exportDoc;importDoc;change;tmpPreviousState=null;constructor(t,e,n){this.exportDoc=e,this.importDoc=n,this.change=function(t){let e;return function(){const n=this;clearTimeout(e),e=setTimeout(function(){e=null,t.apply(n)},300)}}(()=>this.saveNow())}beforeChange(){this.tmpPreviousState||(this.tmpPreviousState=this.deepClone(this.exportDoc()))}length(){return this.versions.length}currentState(){return this.deepClone(this.versions[this.pos-1])}saveNow(){if(!this.tmpPreviousState)throw Error("undo.change() was called without previously calling undo.beforeChange()!");this.versions[this.pos]=this.deepClone(this.exportDoc()),this.versions[this.pos-1]=this.tmpPreviousState,this.tmpPreviousState=null,this.pos+=1,this.versions.splice(this.pos)}deepClone(t){return"undefined"!=typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t))}undo(){if(this.pos<2)return;this.pos-=1;const t=this.versions[this.pos-1];this.importDoc(this.deepClone(t))}redo(){if(this.pos>this.versions.length-1)return;const t=this.versions[this.pos];this.importDoc(this.deepClone(t)),this.pos+=1}changed(){return this.pos!==this.lastSavedPos}setSaved(){this.lastSavedPos=this.pos}}var v=n(264),I=n(977);function k(t,e,n,o,i,r){const d={"font-family":String(a.M5.nodeText["font-family"]),"font-size":`${n}px`,"font-weight":o?"bold":"normal"},l=(0,s.U2)(t,e,d);return{lines:l.lines.length>0?l.lines:[""],fontSize:n,lineHeight:n+2,bold:o,field:r,gapAfter:i}}n(20);const E=a.Y$,S=a.nD;class ${id;name;nodesMap;edges;edgeVertices;groupsMap;metadata;layoutDirection;validatedLayout;colorToVarMap=new Map;_undo;_gridVisible=!1;_snapToGrid=!0;_gridSize=25;_skipAutoFit=!1;constructor(t,e){this.id=t,this.name=e,this.edges=[],this.edgeVertices=new Map,this.nodesMap=new Map,this.groupsMap=new Map,this._undo=new B(this.id,()=>this.exportLayout(!0),t=>this.importLayout(t,!0)),window.graph=this}init(t){t&&this.importLayout(t),this._undo=new B(this.id,()=>this.exportLayout(!0),t=>this.importLayout(t,!0)),this._undo.length()&&this.importLayout(this._undo.currentState()),this._undo.beforeChange(),this._undo.change()}addNode(t,e,n,o,i,r){if(this.nodesMap.has(t))throw Error("duplicate node: "+t);const s={...S,...i},a=(s.shape||"Box").toLowerCase(),d="person"===a?240:180,l=Math.max(280,s.width||0),c=function(t,e,n,o,i,r){const s=Math.max(o-36,80),a=[k(t,s,i,!0,6,"name")];!1!==r.metadata&&e&&a.push(k(`[${e}]`,s,.7*i,!1,10)),!1!==r.description&&n&&a.push(k(n,s,Math.min(.8*i,16),!1,0,"description")),a[a.length-1].gapAfter=0;const d=a.reduce((t,e)=>t+e.lines.length*e.lineHeight+e.gapAfter,0);return{blocks:a,textHeight:d,minimumHeight:d+36+(r.icon?44:0),icon:r.icon}}(e,n,o,l,s.fontSize||22,s);let h=Math.max(d,s.height||0,c.minimumHeight);for(let t=0;t<20;t++){const t=c.minimumHeight+Math.abs(f(a,l,h));if(t<=h+.1)break;h=t}const u={id:t,title:e,sub:n,description:o,style:s,x:0,y:0,width:l,height:h,intersect:null,link:r,contentLayout:c};this.nodesMap.set(u.id,u)}nodes(){return Array.from(this.nodesMap.values())}addEdge(t,e,n,o,i,r){i&&i.forEach((e,n)=>{const o=e;o.id=`v-${t}-${n}`,this.edgeVertices.set(o.id,o)});const s={id:t,from:this.nodesMap.get(e),to:this.nodesMap.get(n),label:o,vertices:null,style:{...E,...r},initVertex:t=>{const e=t;return e.id||(e.id=((t,e)=>`v-${t}-a-${(t=>{let e=2166136261;for(let n=0;n>>0).toString(36)})(`${t}:${e.x}:${e.y}`)}`)(s.id,t),this.edgeVertices.set(e.id,e)),e.edge=s,t},userDeletedVertices:!1};this.edges.push(s),i&&(s.vertices=i.map(t=>s.initVertex(t)))}addGroup(t,e,n,o){if(this.groupsMap.has(t))return void console.error(`Group exists: ${t} ${e}`);const i={id:t,name:e,x:null,y:null,width:null,height:null,nodes:n.map(n=>{const o=this.nodesMap.get(n)||this.groupsMap.get(n);return o||console.error(`Node or group ${n} not found for group ${t} "${e}"`),o}).filter(Boolean),style:o};this.groupsMap.set(t,i)}setNodeSelected(t,e){t.selected=e,e?t.ref.classList.add("selected"):t.ref.classList.remove("selected"),this.updateEdgesSel()}updateEdgesSel(){this.edges.forEach(t=>{t.to.selected||t.from.selected?t.ref.classList.add("selected"):t.ref.classList.remove("selected")})}clearResolvedLayout(){this.validatedLayout=void 0,this.edges.forEach(t=>{t.layoutSections=void 0,t.layoutLabelBounds=void 0}),this.groupsMap.forEach(t=>{t.layoutBounds=void 0,t.layoutTitleBounds=void 0})}moveNode(t,e,n,o=!1,i=!1){if(t){if(this._snapToGrid&&!o){const t=this.snapToGrid(e,n);e=t.x,n=t.y}t.x==e&&t.y==n||(i||this._undo.beforeChange(),this.clearResolvedLayout(),t.x=e,t.y=n,l(t.ref,e,n),this.redrawEdges(t),this.redrawGroups(t),i||this._undo.change())}}moveEdgeVertex(t,e,n,o=!1,i=!1){if(this._snapToGrid&&!o){const t=this.snapToGrid(e,n);e=t.x,n=t.y}t.x==e&&t.y==n||(i||this._undo.beforeChange(),this.clearResolvedLayout(),t.x=e,t.y=n,this.redrawEdge(t.edge),i||this._undo.change())}moveSelected(t,e,n=!1){this.nodes().forEach(o=>o.selected&&this.moveNode(o,o.x+t,o.y+e,n,!1)),this.edgeVertices.forEach(o=>o.selected&&this.moveEdgeVertex(o,o.x+t,o.y+e,n,!1))}insertEdgeVertex(t,e,n,o){this._undo.beforeChange(),this.clearResolvedLayout();const i=t.initVertex(e);i.selected=!0,o&&(t.vertices.forEach(t=>t.label=!1),i.label=!0),t.vertices.splice(n-1,0,i),this.redrawEdge(t),this._undo.change()}deleteEdgeVertex(t){this._undo.beforeChange(),this.clearResolvedLayout();const e=t.edge.vertices.indexOf(t);e>=0&&(t.edge.vertices.splice(e,1),this.edgeVertices.delete(t.id),t.edge.userDeletedVertices=!0),this.redrawEdge(t.edge),this._undo.change()}changed(){return this._undo.changed()}undo(){this._undo.undo()}redo(){this._undo.redo()}alignTopLeft(){const t=this.calculateContentBounds(),e=100-t.x,n=100-t.y;this._skipAutoFit=!0,this._undo.beforeChange(),this.nodesMap.forEach(t=>{this.moveNode(t,t.x+e,t.y+n,!0,!0)}),this.edgeVertices.forEach(t=>{this.moveEdgeVertex(t,t.x+e,t.y+n,!0,!0)}),this._undo.change()}resetPanTransform(){const t=Y(),e=D.querySelector("g.zoom");e&&(e.setAttribute("transform",`scale(${t}) translate(0, 0)`),function(t){const e=t.calculateContentBounds(),n=Y(),o=Math.max(D.parentElement.clientWidth/n,e.x+e.width+20),i=Math.max(D.parentElement.clientHeight/n,e.y+e.height+20);D.setAttribute("width",String(o*n)),D.setAttribute("height",String(i*n))}(this)),tt(this.id),this._skipAutoFit=!1}shouldSkipAutoFit(){return this._skipAutoFit}resetView(){const t=D.querySelector("g.zoom");t&&(t.setAttribute("transform","scale(1) translate(0, 0)"),Z()),tt(this.id)}redrawEdges(t){this.edges.forEach(e=>(t==e.from||t==e.to)&&this.redrawEdge(e)),this.updateEdgesSel()}redrawEdge(t){const e=t.ref.parentElement;e.removeChild(t.ref),t.ref=q(t),e.append(t.ref)}redrawGroups(t){this.groupsMap.forEach(t=>{const e=t.ref.parentElement;e.removeChild(t.ref),j(t),e.append(t.ref)})}exportSVG(){this.validatedLayout||(this.validatedLayout=(0,C.U)(this));const t=document.querySelector("svg#graph"),e=(t.querySelector("rect.elastic"),t.cloneNode(!0));e.querySelectorAll("a.nodeLink[data-export-href]").forEach(t=>{t.setAttribute("href",t.getAttribute("data-export-href")||""),t.removeAttribute("data-export-href")});const n=e.querySelector("rect.elastic");n&&n.remove();const o=this.validatedLayout.bounds,i=o.width+100,r=o.height+100,s=50-o.x,a=50-o.y,d=e.querySelector("g.zoom");d&&d.setAttribute("transform",`scale(1) translate(${s}, ${a})`),e.setAttribute("viewBox",`0 0 ${i} ${r}`),e.setAttribute("width",String(i)),e.setAttribute("height",String(r)),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.convertStylesToCustomProperties(e);const l=document.createElement("script");return l.setAttribute("type","application/json"),this.metadata.layout=this.exportLayout(),l.append("/g,"]]]>]>"),e.insertBefore(l,e.firstChild),e.outerHTML}convertStylesToCustomProperties(t){0!==this.colorToVarMap.size&&(t.querySelectorAll("[fill]").forEach(t=>{const e=t.getAttribute("fill");e&&this.colorToVarMap.has(e)&&t.setAttribute("fill",`var(${this.colorToVarMap.get(e)}, ${e})`)}),t.querySelectorAll("[stroke]").forEach(t=>{const e=t.getAttribute("stroke");e&&this.colorToVarMap.has(e)&&t.setAttribute("stroke",`var(${this.colorToVarMap.get(e)}, ${e})`)}))}calculateContentBounds(){let t=1/0,e=1/0,n=-1/0,o=-1/0;return this.nodes().forEach(i=>{const r=i.x-i.width/2,s=i.x+i.width/2,a=i.y-i.height/2,d=i.y+i.height/2;t=Math.min(t,r),n=Math.max(n,s),e=Math.min(e,a),o=Math.max(o,d)}),this.edgeVertices.forEach(i=>{t=Math.min(t,i.x-5),n=Math.max(n,i.x+5),e=Math.min(e,i.y-5),o=Math.max(o,i.y+5)}),this.groupsMap.forEach(i=>{const r=i.x-i.width/2,s=i.x+i.width/2,a=i.y-i.height/2,d=i.y+i.height/2;t=Math.min(t,r),n=Math.max(n,s),e=Math.min(e,a),o=Math.max(o,d)}),this.edges.forEach(i=>{if(t=Math.min(t,i.from.x-10,i.to.x-10),n=Math.max(n,i.from.x+10,i.to.x+10),e=Math.min(e,i.from.y-10,i.to.y-10),o=Math.max(o,i.from.y+10,i.to.y+10),i.vertices&&i.vertices.forEach(i=>{t=Math.min(t,i.x-10),n=Math.max(n,i.x+10),e=Math.min(e,i.y-10),o=Math.max(o,i.y+10)}),i.label&&i.label.trim()){const r=(i.from.x+i.to.x)/2,s=(i.from.y+i.to.y)/2,a=10*i.label.length+50;t=Math.min(t,r-a),n=Math.max(n,r+a),e=Math.min(e,s-25),o=Math.max(o,s+25)}}),t===1/0?{x:0,y:0,width:100,height:100}:{x:t,y:e,width:n-t,height:o-e}}exportLayout(t=!1){const e={};return this.nodes().forEach(t=>e[t.id]={x:t.x,y:t.y}),this.edges.forEach(n=>{if(!n.vertices)return;const o=n.vertices.map(t=>({x:t.x,y:t.y,label:t.label,auto:t.auto}));(o.length||t)&&(e[`e-${n.id}`]=o),n.userDeletedVertices&&(e[`e-${n.id}-deleted`]=!0)}),e}setSaved(){this._undo.setSaved()}importLayout(t,e=!1){this.clearResolvedLayout();for(const[e,n]of Object.entries(t)){const t=this.nodesMap.get(e);if(t){const o=_(e,n);t.x=o.x,t.y=o.y;continue}if(e.endsWith("-deleted")){const t=e.slice(2,-8),o=this.edges.find(e=>e.id===t);if(!o||!0!==n)throw new Error(`invalid deleted-edge layout entry ${e}`);o.userDeletedVertices=!0;continue}if(e.startsWith("e-")){const t=this.edges.find(t=>t.id===e.slice(2));if(!t||!Array.isArray(n))throw new Error(`invalid edge layout entry ${e}`);for(const e of t.vertices??[])this.edgeVertices.delete(e.id);t.vertices=n.map((n,o)=>{const i=_(`${e}[${o}]`,n),r=t.initVertex(i);return r.label=n.label,r.auto=n.auto,r});continue}throw new Error(`layout contains unknown element ${e}`)}for(const e of this.nodes())if(!(e.id in t))throw new Error(`layout is missing node ${e.id}`);e&&(this.nodes().forEach(t=>l(t.ref,t.x,t.y)),this.edges.forEach(t=>this.redrawEdge(t)),this.updateEdgesSel(),this.redrawGroups(null))}async autoLayout(t){const e=await(0,C.k)(this,t);this._undo.beforeChange();for(const t of e.nodes){const e=this.nodesMap.get(t.id);if(!e)throw new Error(`layout contains unknown node ${t.id}`);e.x=t.x,e.y=t.y,l(e.ref,e.x,e.y)}for(const t of e.groups){const e=this.groupsMap.get(t.id);if(!e)throw new Error(`layout contains unknown group ${t.id}`);e.layoutBounds=t.bounds,e.layoutTitleBounds=t.titleBounds,e.x=t.bounds.x+t.bounds.width/2,e.y=t.bounds.y+t.bounds.height/2,e.width=t.bounds.width,e.height=t.bounds.height}for(const t of e.edges){const e=this.edges.find(e=>e.id===t.id);if(!e)throw new Error(`layout contains unknown edge ${t.id}`);for(const t of e.vertices??[])this.edgeVertices.delete(t.id);e.layoutSections=t.sections,e.layoutLabelBounds=t.labelBounds,e.vertices=M(t.sections).map(t=>{const n=e.initVertex(t);return n.auto=!0,n}),e.userDeletedVertices=!1}this.validatedLayout=e.validated,this.edges.forEach(t=>this.redrawEdge(t)),this.redrawGroups(null),this.fitToView(),this._undo.change()}alignSelectionV(){const t=this.nodes().filter(t=>t.selected);t.push(...Array.from(this.edgeVertices.values()).filter(t=>t.selected));let e=Math.min(...t.map(t=>t.y));this.nodesMap.forEach(t=>t.selected&&this.moveNode(t,t.x,e,!1,!1)),this.edgeVertices.forEach(t=>t.selected&&this.moveEdgeVertex(t,t.x,e,!1,!1))}alignSelectionH(){const t=this.nodes().filter(t=>t.selected);t.push(...Array.from(this.edgeVertices.values()).filter(t=>t.selected));let e=Math.min(...t.map(t=>t.x));this.nodesMap.forEach(t=>t.selected&&this.moveNode(t,e,t.y,!1,!1)),this.edgeVertices.forEach(t=>t.selected&&this.moveEdgeVertex(t,e,t.y,!1,!1))}distributeSelectionH(){const t=this.nodes().filter(t=>t.selected),e=Array.from(this.edgeVertices.values()).filter(t=>t.selected);if(t.length+e.length<3)return;this._undo.beforeChange();const n=[...t,...e];n.sort((t,e)=>t.x-e.x);const o=n[0].x,i=(n[n.length-1].x-o)/(n.length-1);n.forEach((t,e)=>{const n=o+e*i;"title"in t?this.moveNode(t,n,t.y,!1,!0):this.moveEdgeVertex(t,n,t.y,!1,!0)}),this._undo.change()}distributeSelectionV(){const t=this.nodes().filter(t=>t.selected),e=Array.from(this.edgeVertices.values()).filter(t=>t.selected);if(t.length+e.length<3)return;this._undo.beforeChange();const n=[...t,...e];n.sort((t,e)=>t.y-e.y);const o=n[0].y,i=(n[n.length-1].y-o)/(n.length-1);n.forEach((t,e)=>{const n=o+e*i;"title"in t?this.moveNode(t,t.x,n,!1,!0):this.moveEdgeVertex(t,t.x,n,!1,!0)}),this._undo.change()}setEdgeSelected(t,e){e&&(this.setNodeSelected(t.from,!0),this.setNodeSelected(t.to,!0)),this.updateEdgesSel()}fitToView(){const t=this.calculateContentBounds();if(0===t.width||0===t.height)return;const e=D.parentElement?.clientWidth||800,n=D.parentElement?.clientHeight||600,o=(e-80)/t.width,i=(n-80)/t.height,r=Math.min(o,i),s=Math.max(Math.min(r,2),.1),a=e/2-(t.x+t.width/2)*s,d=n/2-(t.y+t.height/2)*s,l=D.querySelector("g.zoom");l&&l.setAttribute("transform",`translate(${a}, ${d}) scale(${s})`),Z(),Q(this.id)}saveLayoutState(){return this.exportLayout(!0)}restoreLayoutState(t){this.importLayout(t,!0)}isGridVisible(){return this._gridVisible}isSnapToGrid(){return this._snapToGrid}getGridSize(){return this._gridSize}toggleGrid(){this._gridVisible=!this._gridVisible,this.updateGridDisplay(),window.dispatchEvent(new CustomEvent("gridStateChanged"))}toggleSnapToGrid(){this._snapToGrid=!this._snapToGrid,window.dispatchEvent(new CustomEvent("gridStateChanged"))}snapAllToGrid(){this._snapToGrid&&(this._undo.beforeChange(),this.nodes().forEach(t=>{const e=Math.round(t.x/this._gridSize)*this._gridSize,n=Math.round(t.y/this._gridSize)*this._gridSize;this.moveNode(t,e,n,!1,!0)}),this._undo.change())}snapToGrid(t,e){return{x:Math.round(t/this._gridSize)*this._gridSize,y:Math.round(e/this._gridSize)*this._gridSize}}updateGridDisplay(){if(!D)return;const t=D.querySelector("#grid-pattern");t&&t.remove();const e=D.querySelector("#grid-background");if(e&&e.remove(),!this._gridVisible)return;let n=D.querySelector("defs");n||(n=document.createElementNS("http://www.w3.org/2000/svg","defs"),D.insertBefore(n,D.firstChild));const o=document.createElementNS("http://www.w3.org/2000/svg","pattern");o.id="grid-pattern",o.setAttribute("width",this._gridSize.toString()),o.setAttribute("height",this._gridSize.toString()),o.setAttribute("patternUnits","userSpaceOnUse");const i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",`M ${this._gridSize} 0 L 0 0 0 ${this._gridSize}`),i.setAttribute("fill","none"),i.setAttribute("stroke","#d0d0d0"),i.setAttribute("stroke-width","1"),i.setAttribute("opacity","0.8"),o.appendChild(i),n.appendChild(o);const r=document.createElementNS("http://www.w3.org/2000/svg","rect");r.id="grid-background",r.setAttribute("x","-10000"),r.setAttribute("y","-10000"),r.setAttribute("width","20000"),r.setAttribute("height","20000"),r.setAttribute("fill","url(#grid-pattern)"),r.setAttribute("pointer-events","none");const s=D.querySelector("g.zoom");s&&s.insertBefore(r,s.firstChild)}}function M(t){const e=[];for(const n of t)for(const t of n){const n=e[e.length-1];n&&n.x===t.x&&n.y===t.y||e.push(t)}return e.slice(1,-1)}function _(t,e){if("object"!=typeof e||Array.isArray(e)||!Number.isFinite(e.x)||!Number.isFinite(e.y))throw new Error(`layout entry ${t} must contain valid x and y coordinates`);return e}let L,D=document.querySelector("svg#graph");D||(D=document.createElementNS("http://www.w3.org/2000/svg","svg"),D.setAttribute("id","graph"),D.addEventListener("click",t=>L(t))),D.setAttribute("width","100%"),D.setAttribute("height","100%");let z,V=!1;const T=(t,e,n)=>{document.body.append(D),D.__data=t,z=e,L=t=>{},N(t);const o=d.rect(300,300,50,50,0,"elastic");return D.append(o),t.updateGridDisplay(),G(D,n),{svg:D,setZoom:O}},F=t=>(D=document.createElementNS("http://www.w3.org/2000/svg","svg"),D.setAttribute("id","graph"),N(t),D),N=t=>{D.innerHTML=r;const e=d.element("g",{},"zoom"),n=d.element("g",{},"nodes"),o=d.element("g",{},"edges"),i=d.element("g",{},"groups");e.append(i,o,n),t.nodesMap.forEach(e=>{!function(t,e){window.gdata=e;const n=d.element("g",{},"node");n.setAttribute("id",t.id),t.selected&&n.classList.add("selected"),l(n,t.x,t.y);const o=t.link?d.element("a",{href:t.link.href,"data-export-href":t.link.exportHref,"aria-label":`Open ${t.title}`},"nodeLink"):null,i=o||n;o&&(n.classList.add("linked"),n.append(o));const r=t.style.shape||"Box",s=(x[r.toLowerCase()]||x.box)(i,t);s.classList.add("nodeBorder"),(0,a.AV)(s,a.M5.nodeBorder),s.setAttribute("fill",t.style.background),s.setAttribute("stroke",t.style.stroke),s.setAttribute("opacity",String(t.style.opacity)),X(s,t.style.border);const c=function(t,e){const n=d.element("g"),o=t.icon?44:0;let i=-(t.textHeight+o)/2;return t.icon&&(n.append(d.element("image",{href:t.icon,x:-16,y:i,width:32,height:32,preserveAspectRatio:"xMidYMid meet"},"nodeIcon")),i+=o),t.blocks.forEach(t=>{const o=d.text("",{"text-anchor":"middle"});(0,a.AV)(o,a.M5.nodeText),e&&o.setAttribute("fill",e),t.field&&o.setAttribute("data-field",t.field),t.lines.forEach((e,n)=>{const r=d.element("tspan",{x:0,y:i+t.fontSize+n*t.lineHeight,"font-size":`${t.fontSize}px`,"font-weight":t.bold?"bold":"normal"});r.textContent=e,o.append(r)}),n.append(o),i+=t.lines.length*t.lineHeight+t.gapAfter}),n}(t.contentLayout,t.style.color);l(c,0,(Number(i.getAttribute("label-offset-y"))||0)/2),i.append(c),n.__data=t,t.ref=n}(e,t),n.append(e.ref)}),t.edges.forEach(t=>{t.labelBounds=void 0}),t.edges.forEach(t=>{q(t),o.append(t.ref)}),t.groupsMap.forEach(t=>{j(t),i.append(t.ref)}),D.append(e)};function q(t){const e=t.from,n=d.element("g",{},"edge");n.setAttribute("id",t.id),n.setAttribute("data-from",t.from.id),n.setAttribute("data-to",t.to.id);const o=(t.style.position||50)/100,i=t.layoutSections?function(t){const e=[];for(const n of t)for(const t of n){const n=e[e.length-1];n&&n.x===t.x&&n.y===t.y||e.push(t)}return e}(t.layoutSections):(0,I.l)(t),{bg:r,txt:s}=t.layoutLabelBounds?function(t,e){const n=t.x+t.width/2,{txt:o}=(t.y,t.height,d.textArea(e.label,e.style.width,e.style.fontSize,!1,n,t.y,"middle"));(0,a.AV)(o,a.M5.edgeText),o.setAttribute("stroke","none"),o.setAttribute("font-size",String(e.style.fontSize)),o.setAttribute("fill",e.style.color),o.setAttribute("data-field","label");const i=d.rect(t.width,t.height,t.x,t.y);return(0,a.AV)(i,a.M5.edgeRect),{bg:i,txt:o}}(t.layoutLabelBounds,t):function(t,e){const n=e.style.fontSize;let{txt:o,dy:i,maxW:r}=d.textArea(e.label,e.style.width,n,!1,t.x,t.y,"middle");i-=n/2,r+=n;const s="vertical"===t.orientation?t.x+r/2+12:t.x,l="vertical"===t.orientation?t.y:t.y-i/2-12,c={x:s-r/2,y:l-i/2,width:r,height:i};o.querySelectorAll("tspan").forEach(t=>{t.setAttribute("x",String(s))}),o.setAttribute("y",String(l-i/2)),(0,a.AV)(o,a.M5.edgeText),o.setAttribute("stroke","none"),o.setAttribute("font-size",String(e.style.fontSize)),o.setAttribute("fill",e.style.color);const h=d.rect(c.width,c.height,c.x,c.y);return(0,a.AV)(h,a.M5.edgeRect),o.setAttribute("data-field","label"),e.labelBounds=c,{bg:h,txt:o}}((0,I.IW)(i,o,e),t);n.append(r,s);const l=(0,I.Zr)(i),c=d.path(l,{"marker-end":"url(#arrow)"},"edge");c.setAttribute("fill","none"),c.setAttribute("stroke",t.style.color),c.setAttribute("stroke-width",String(t.style.thickness)),c.setAttribute("stroke-linecap","round"),t.style.dashed&&c.setAttribute("stroke-dasharray","8"),n.append(c);for(const e of t.vertices??[]){const t=e;t.ref=d.element("circle",{id:t.id,cx:e.x,cy:e.y,r:7,fill:"none"},"v-dot"),t.selected&&t.ref.classList.add("selected"),t.auto&&t.ref.classList.add("auto"),n.append(t.ref)}return t.ref=n,n}function j(t){if(0==t.nodes.length)return;const e=d.element("g",{},"group");if(t.layoutBounds&&t.layoutTitleBounds){const n=t.layoutBounds,o=t.layoutTitleBounds,i=d.rect(n.width,n.height,n.x,n.y);(0,a.AV)(i,a.M5.groupRect),t.style.stroke&&i.setAttribute("stroke",t.style.stroke),t.style.background&&i.setAttribute("fill",t.style.background);const r=d.text(t.name,{x:o.x,y:o.y,"dominant-baseline":"hanging"});return(0,a.AV)(r,a.M5.groupText),t.style.color&&r.setAttribute("fill",t.style.color),e.append(i,r),void(t.ref=e)}let n={x:1e100,y:1e100},o={x:0,y:0};t.nodes.forEach(t=>{const e=t.style?.shape?.toLowerCase()||"box";let i=t.height/2,r=t.height/2;if("robot"===e){const e=.12*t.height;i=t.height/2+e,r=t.height/2}else if("hexagon"===e){const e=t.width/2*.866;i=e,r=e}const s={x:t.x-t.width/2,y:t.y-i,width:t.width,height:i+r};n.x=Math.min(n.x,s.x),n.y=Math.min(n.y,s.y),o.x=Math.max(o.x,s.x+s.width),o.y=Math.max(o.y,s.y+s.height)});const i=Math.max(o.x-n.x,200),r=o.y-n.y,s={x:n.x-25,y:n.y-25,width:i+50,height:r+50+30},l=d.rect(s.width,s.height,s.x,s.y);t.x=s.x+s.width/2,t.y=s.y+s.height/2,t.width=s.width,t.height=s.height,(0,a.AV)(l,a.M5.groupRect),t.style.stroke&&l.setAttribute("stroke",t.style.stroke),t.style.background&&l.setAttribute("fill",t.style.background);const c=d.text(t.name,{x:n.x,y:s.y+s.height-a.M5.groupText["font-size"]});(0,a.AV)(c,a.M5.groupText),t.style.color&&c.setAttribute("fill",t.style.color),e.append(l,c),t.ref=e}function R(t,e){let n={dst:Number.POSITIVE_INFINITY,pos:-1,edge:null,prj:null};return t.edges.forEach(t=>{const o=t.vertices||[],i=[t.from,...o,t.to];for(let o=1;o50||s3||Math.abs(a)>3)&&(h=!0,c=null,l)){const t=e.getSelection();t.length=0,t.push(l.node),e.setSelection(t),o=[{x:l.node.x,y:l.node.y,n:l.node}],l=null}if(r)!function(e,n){const o=t.querySelector("g.zoom");if(!o)return;const i=Y();o.setAttribute("transform",`translate(${e}, ${n}) scale(${i})`)}(d.x+s,d.y+a);else if(o.length>0&&h){const t=e.getZoom(),n=s/t,i=a/t;o.forEach(t=>{e.moveNode(t.n,t.x+n,t.y+i)}),e.setDragging(!0)}else i&&(i.update(n),e.setDragging(!0))}(n=f(n),n.clientX-p.ex,n.clientY-p.ey)}function b(n){document.removeEventListener("touchmove",m),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",b),document.removeEventListener("touchend",b),function(n){e.setDragging(!1);const s=h?null:c;if(h&&(u=!0,window.setTimeout(()=>{u=!1},0)),l&&!h){const t=e.getSelection();t.length=0,t.push(l.node),e.setSelection(t)}if(i){const t=i.end();t?e.boxSelection(t,n.shiftKey):o.length||e.setSelection([]),i=null}if(r&&h){const e=t.__data;e&&e.id&&Q(e.id)}l=null,c=null,h=!1,r=!1,e.updatePanning(),s&&(window.location.href=s)}(f(n)),p=null}function y(u){u=f(u),p={ex:u.clientX,ey:u.clientY},function(u){u.preventDefault(),h=!1,l=null;const A=u.target,g=A instanceof Element?A.closest("a.nodeLink"):null;c=u.shiftKey?null:g?.getAttribute("href")||null;const p=e.nodeFromEvent(u),f=u.shiftKey?"pan"===n?"select":"pan":n;if(p)if("pan"===f){r=!1,i=null;const t=e.getSelection();e.isSelected(p)?o=t.map(t=>({x:t.x,y:t.y,n:t})):(e.setSelection([p]),o=[{x:p.x,y:p.y,n:p}])}else{r=!1,i=null;const t=e.getSelection();if(u.shiftKey&&"select"===n){if(e.isSelected(p)){const e=t.findIndex(t=>t.id===p.id);e>=0&&t.splice(e,1)}else t.push(p);e.setSelection(t),o=t.map(t=>({x:t.x,y:t.y,n:t}))}else e.isSelected(p)?(o=t.map(t=>({x:t.x,y:t.y,n:t})),l=null):(l={node:p,shiftKey:u.shiftKey},o=[{x:p.x,y:p.y,n:p}])}else"pan"===f?(r=!0,i=null,s=u.clientX,a=u.clientY,d=function(){const e=t.querySelector("g.zoom");if(!e)return{x:0,y:0};const n=(e.getAttribute("transform")||"").match(/translate\(([^,]+),([^)]+)\)/);return n?{x:parseFloat(n[1])||0,y:parseFloat(n[2])||0}:{x:0,y:0}}(),o=[],e.setSelection([])):(r=!1,i=function(){let e=0,n=0,o=null;return{ini(i){const r=W(i);e=r.x,n=r.y,o=document.createElementNS("http://www.w3.org/2000/svg","rect"),o.setAttribute("fill","rgba(0, 100, 255, 0.1)"),o.setAttribute("stroke","rgba(0, 100, 255, 0.5)"),o.setAttribute("stroke-width","1"),o.setAttribute("stroke-dasharray","3,3"),o.setAttribute("x",String(e)),o.setAttribute("y",String(n)),o.setAttribute("width","0"),o.setAttribute("height","0");const s=t.querySelector("g.zoom");s?s.appendChild(o):t.appendChild(o)},update(t){if(!o)return;const i=W(t),r=i.x,s=i.y,a=Math.min(e,r),d=Math.min(n,s),l=Math.abs(r-e),c=Math.abs(s-n);o.setAttribute("x",String(a)),o.setAttribute("y",String(d)),o.setAttribute("width",String(l)),o.setAttribute("height",String(c))},end(){if(!o)return null;const t=parseFloat(o.getAttribute("x")||"0"),e=parseFloat(o.getAttribute("y")||"0"),n=parseFloat(o.getAttribute("width")||"0"),i=parseFloat(o.getAttribute("height")||"0");return o.remove(),o=null,n>5&&i>5?{x:t,y:e,width:n,height:i,left:t,top:e,right:t+n,bottom:e+i}:null}}}(),i&&i.ini(u),o=[])}(u),document.addEventListener("touchmove",m),document.addEventListener("mousemove",m),document.addEventListener("mouseup",b),document.addEventListener("touchend",b)}g.addEventListener("mousedown",y),g.addEventListener("touchstart",y),A.push({element:g,event:"mousedown",handler:y},{element:g,event:"touchstart",handler:y})}(t),t.addEventListener("click",g),A.push({element:t,event:"click",handler:g}),()=>{A.forEach(({element:t,event:e,handler:n})=>{t.removeEventListener(e,n)})}}function G(t,e){const n=t.__cursorInteractionCleanup;function o(t){return t.__data}n&&n();const i=()=>o(t),r=[],s=t=>{i().changed()&&(t.preventDefault(),t.returnValue="")};function a(e,n){e.selected=n;const o=t.querySelector("#"+e.id);e.selected?o.classList.add("selected"):o.classList.remove("selected")}window.addEventListener("beforeunload",s),r.push({element:window,event:"beforeunload",handler:s});const l=e=>{if(!e.altKey)return;const n=R(i(),W(e));if(n){const{prj:e}=n,o=t.querySelector("g.edges");let i=o.querySelector("#prj");i||(i=d.element("circle",{id:"prj",cx:e.x,cy:e.y,r:7}),o.append(i)),i.setAttribute("cx",String(e.x)),i.setAttribute("cy",String(e.y))}else u()};t.addEventListener("mousemove",l),r.push({element:t,event:"mousemove",handler:l});const h=t=>{const e=(0,v.Yp)(t,!0);e!=v.Zj&&e!=v._s&&u()};function u(){const e=t.querySelector("g.edges #prj");e&&e.parentElement.removeChild(e)}window.addEventListener("keyup",h),r.push({element:window,event:"keyup",handler:h});const A=t=>{const e=(0,v.Yp)(t,!0);if(e!=v._s&&e!=v.Zj)return;const n=R(i(),W(t));if(n){const{edge:t,pos:o,prj:r}=n;i().insertEdgeVertex(t,r,o,e==v._s),u()}};t.addEventListener("click",A),r.push({element:t,event:"click",handler:A});const g=e=>{const n=.1*Math.sign(e.deltaY),o=Y(),i=Math.max(.1,Math.min(5,o-n));if(i!==o){const n=t.getBoundingClientRect();P(i,e.clientX-n.left,e.clientY-n.top),e.preventDefault();const o=t.__data;o&&o.id&&Q(o.id)}};t.addEventListener("wheel",g),r.push({element:t,event:"wheel",handler:g});const p=t=>{const e=(0,v.Yp)(t);switch(e&&t.preventDefault(),e){case v.bl:Array.from(i().edgeVertices.values()).filter(t=>t.selected).forEach(t=>{i().deleteEdgeVertex(t)});break;case"undo":i().undo();break;case"redo":i().redo();break;case v.Ur:P(Math.min(5,1.2*Y())),Q(i().id);break;case v.hU:P(Math.max(.1,Y()/1.2)),Q(i().id);break;case v.i1:P(1),Q(i().id);break;case v.mD:i().fitToView();break;case v.F:i().nodes().forEach(t=>i().setNodeSelected(t,!0)),i().edgeVertices.forEach(t=>a(t,!0));break;case v.Gn:i().nodes().forEach(t=>i().setNodeSelected(t,!1)),i().edgeVertices.forEach(t=>a(t,!1))}};window.addEventListener("keydown",p),r.push({element:window,event:"keydown",handler:p});const f=U(t,{nodeFromEvent(t){t.preventDefault();let e=t.target.closest("g.nodes g.node");return e?o(e):(e=t.target.closest("g.edges g.edge .v-dot"),e?i().edgeVertices.get(e.id):null)},setSelection(t){i().nodes().forEach(e=>i().setNodeSelected(e,t.some(t=>t.id==e.id))),i().edgeVertices.forEach(e=>a(e,t.some(t=>t.id==e.id))),z(i().nodes().find(t=>t.selected))},setDragging(t){V=t},isSelected:t=>t.selected,getSelection(){const t=i().nodes().filter(t=>t.selected);return i().edgeVertices.forEach(e=>e.selected&&t.push(e)),t},getZoom:Y,moveNode(t,e,n){i().nodesMap.has(t.id)?i().moveNode(t,e,n):(t.auto=!1,i().moveEdgeVertex(t,e,n))},boxSelection(t,e){i().nodesMap.forEach(n=>{var o,r,s;(o={x:(s=n).x-s.width/2,y:s.y-s.height/2,width:s.width,height:s.height}).x<(r=t).x+r.width&&o.yr.x&&o.y+o.height>r.y?i().setNodeSelected(n,!n.selected):e||i().setNodeSelected(n,!1)}),i().edgeVertices.forEach(n=>{c(n,t,!1)?a(n,!n.selected):e||a(n,!1)}),z(i().nodes().find(t=>t.selected))},updatePanning:Z},e);t.__cursorInteractionCleanup=()=>{r.forEach(({element:t,event:e,handler:n})=>{t.removeEventListener(e,n)}),f&&f()}}function Y(){if(!D)return 1;const t=D.querySelector("g.zoom");if(!t)return 1;const e=(t.getAttribute("transform")||"").match(/scale\(([^)]+)\)/);return e&&parseFloat(e[1])||1}function O(t){if(!D)return;const e=D.querySelector("g.zoom");if(!e)return;const n=H();e.setAttribute("transform",`translate(${n.x}, ${n.y}) scale(${t})`),Z()}function P(t,e,n){const o=D.querySelector("g.zoom"),i=Y();if(void 0===e||void 0===n){const t=D.parentElement;t?(e=t.clientWidth/2,n=t.clientHeight/2):(e=D.clientWidth/2,n=D.clientHeight/2)}const r=H(),s=e-(e-r.x)/i*t,a=n-(n-r.y)/i*t;o.setAttribute("transform",`translate(${s}, ${a}) scale(${t})`),Z()}function H(){if(!D)return{x:0,y:0};const t=D.querySelector("g.zoom");if(!t)return{x:0,y:0};const e=(t.getAttribute("transform")||"").match(/translate\(([^,]+),([^)]+)\)/);return e?{x:parseFloat(e[1])||0,y:parseFloat(e[2])||0}:{x:0,y:0}}function Z(){if(!D)return;const t=D.querySelector("g.zoom");if(!t)return;const e=t.getBBox(),n=Y();if(!D.parentElement)return;const o=Math.max(D.parentElement.clientWidth/n,e.x+e.width+20),i=Math.max(D.parentElement.clientHeight/n,e.y+e.height+20);D.setAttribute("width",String(o*n)),D.setAttribute("height",String(i*n))}const X=(t,e)=>{"Dashed"==e?t.setAttribute("stroke-dasharray","4"):"Dotted"==e&&t.setAttribute("stroke-dasharray","2")},K=new Map;function Q(t){if(!D)return;const e=Y(),n=H(),o={zoom:e,transform:{x:n.x,y:n.y}};K.set(t,o)}function J(t){if(!D||!K.has(t))return!1;const e=K.get(t);if(!e)return!1;const n=D.querySelector("g.zoom");return n&&(n.setAttribute("transform",`scale(${e.zoom}) translate(${e.transform.x}, ${e.transform.y})`),Z()),!0}function tt(t){K.delete(t)}},983(t,e,n){n.d(e,{k:()=>w,U:()=>x});var o=n(20);const i={direction:"DOWN",nodeSpacing:80,layerSpacing:80};async function r(t,e={}){const o=function(t,e){const n=new Map(t.nodes.map(t=>[t.id,t])),o=new Map(t.groups.map(t=>[t.id,t]));!function(t,e,n){for(const e of t.nodes)if(e.parentId&&!n.has(e.parentId))throw new Error(`node ${e.id} has missing parent group ${e.parentId}`);for(const e of t.groups)if(e.parentId&&!n.has(e.parentId))throw new Error(`group ${e.id} has missing parent group ${e.parentId}`);for(const n of t.edges)if(!e.has(n.sourceId)||!e.has(n.targetId))throw new Error(`edge ${n.id} connects missing node ${n.sourceId} or ${n.targetId}`)}(t,n,o);const i=new Map;for(const e of t.nodes)b(i,e.parentId,e);const r=new Map;for(const e of t.groups)b(r,e.parentId,e);const h=new Map,u=t=>{const n={id:t.id,children:[...(r.get(t.id)??[]).map(u),...(i.get(t.id)??[]).map(s)],edges:[],labels:[{text:t.id,width:t.titleSize.width,height:t.titleSize.height}],layoutOptions:l(e,t.titleSize.height)};return h.set(t.id,n),n},A={id:t.id,children:[...(r.get(void 0)??[]).map(u),...(i.get(void 0)??[]).map(s)],edges:[],layoutOptions:d(e)};for(const e of t.edges){const t=c(e,n,o),i=t?h.get(t):A;if(!i)throw new Error(`edge ${e.id} has missing layout group ${t}`);i.edges?.push(a(e))}return A}(t,{...i,...e}),r=new(await n.e(726).then(n.t.bind(n,862,23)).then(t=>t.default));return function(t,e){if(void 0===e.width||void 0===e.height)throw new Error(`ELK did not size diagram ${t.id}`);const n=[],o=[],i=[];return u(e,0,0,new Map(t.nodes.map(t=>[t.id,t])),new Map(t.groups.map(t=>[t.id,t])),n,o,i),{diagramId:t.id,bounds:{x:0,y:0,width:e.width,height:e.height},nodes:n,groups:o,edges:i}}(t,await r.layout(o))}function s(t){return{id:t.id,width:t.size.width,height:t.size.height,layoutOptions:{"elk.nodeSize.constraints":"FIXED_SIZE","elk.portConstraints":"FREE"}}}function a(t){return{id:t.id,sources:[t.sourceId],targets:[t.targetId],labels:t.labelSize?[{text:t.id,width:t.labelSize.width,height:t.labelSize.height,layoutOptions:{"elk.edgeLabels.inline":"false","elk.edgeLabels.placement":"CENTER"}}]:[]}}function d(t){return{"elk.algorithm":"layered","elk.direction":t.direction,"elk.edgeRouting":"ORTHOGONAL","elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.padding":"[top=40,left=40,bottom=40,right=40]","elk.spacing.nodeNode":String(t.nodeSpacing),"elk.spacing.componentComponent":String(t.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(t.layerSpacing),"elk.layered.spacing.edgeNodeBetweenLayers":"30","elk.layered.spacing.edgeEdgeBetweenLayers":"20","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.nodePlacement.favorStraightEdges":"true","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.unnecessaryBendpoints":"true","elk.edgeLabels.inline":"false","elk.edgeLabels.avoidOverlap":"true","elk.layered.edgeLabels.sideSelection":"SMART_DOWN","elk.spacing.edgeLabel":"12"}}function l(t,e){return{...d(t),"elk.padding":`[top=${e+30},left=30,bottom=30,right=30]`,"elk.nodeLabels.placement":"[H_LEFT,V_TOP,INSIDE]","elk.spacing.labelNode":"10"}}function c(t,e,n){const o=h(e.get(t.sourceId)?.parentId,n),i=new Set(h(e.get(t.targetId)?.parentId,n));return o.find(t=>i.has(t))}function h(t,e){const n=[];let o=t;for(;o;)n.push(o),o=e.get(o)?.parentId;return n}function u(t,e,n,o,i,r,s,a){const d=e+(t.x??0),l=n+(t.y??0);for(const e of t.children??[]){const t=d+p(e.x,e.id,"x"),n=l+p(e.y,e.id,"y"),c=p(e.width,e.id,"width"),h=p(e.height,e.id,"height"),A=o.get(e.id);if(A){r.push({id:e.id,parentId:A.parentId,bounds:{x:t,y:n,width:c,height:h}});continue}const g=i.get(e.id);if(!g)throw new Error(`ELK returned unknown node ${e.id}`);const f=m(e.labels?.[0],e.id);s.push({id:e.id,parentId:g.parentId,bounds:{x:t,y:n,width:c,height:h},titleBounds:{x:t+p(f.x,e.id,"title x"),y:n+p(f.y,e.id,"title y"),width:p(f.width,e.id,"title width"),height:p(f.height,e.id,"title height")}}),u(e,d,l,o,i,r,s,a)}for(const e of t.edges??[])a.push(A(e,d,l))}function A(t,e,n){const o=(t.sections??[]).map(t=>[g(t.startPoint,e,n),...(t.bendPoints??[]).map(t=>g(t,e,n)),g(t.endPoint,e,n)]),i=t.labels?.[0];return{id:t.id,sourceId:f(t.sources,t.id,"source"),targetId:f(t.targets,t.id,"target"),sections:o,labelBounds:i?{x:e+p(i.x,t.id,"label x"),y:n+p(i.y,t.id,"label y"),width:p(i.width,t.id,"label width"),height:p(i.height,t.id,"label height")}:void 0}}function g(t,e,n){return{x:e+t.x,y:n+t.y}}function p(t,e,n){if(void 0===t)throw new Error(`ELK omitted ${n} for ${e}`);return t}function f(t,e,n){if(1!==t.length)throw new Error(`ELK returned ${t.length} ${n}s for edge ${e}`);return t[0]}function m(t,e){if(!t)throw new Error(`ELK omitted title for group ${e}`);return t}function b(t,e,n){const o=t.get(e)??[];o.push(n),t.set(e,o)}n(108);var y=n(977);async function w(t,e={}){await document.fonts.ready;const n=C(t),i=e.compactLayout?56:80,s=await r(n,{direction:e.direction??t.layoutDirection??"DOWN",nodeSpacing:e.nodeSpacing??i,layerSpacing:e.layerSpacing??i}),a=(0,o.r)(n,s),d=new Map(n.nodes.map(t=>[t.id,t]));return{validated:a,nodes:a.nodes.map(t=>{const e=d.get(t.id);if(!e)throw new Error(`validated layout contains unknown node ${t.id}`);return{id:t.id,x:t.bounds.x+e.centerOffset.x,y:t.bounds.y+e.centerOffset.y}}),groups:a.groups.map(t=>({id:t.id,bounds:t.bounds,titleBounds:t.titleBounds})),edges:a.edges.map(t=>({id:t.id,sections:t.sections,labelBounds:t.labelBounds}))}}function x(t){const e=C(t),n=new Map(e.nodes.map(t=>[t.id,t])),i=t.nodes().map(t=>{const e=n.get(t.id);if(!e)throw new Error(`measured diagram omitted node ${t.id}`);return{id:t.id,parentId:e.parentId,bounds:{x:t.x-e.centerOffset.x,y:t.y-e.centerOffset.y,...e.size}}}),r=Array.from(t.groupsMap.values()).map(t=>{if(!t.ref?.isConnected)throw new Error(`group ${t.id} must be drawn before saving`);const n=t.ref.querySelector("rect"),o=t.ref.querySelector("text");if(!(n instanceof SVGGraphicsElement&&o instanceof SVGGraphicsElement))throw new Error(`group ${t.id} is missing its boundary or title`);return{id:t.id,parentId:e.groups.find(e=>e.id===t.id)?.parentId,bounds:k(n.getBBox()),titleBounds:k(o.getBBox())}}),s=t.edges.map(t=>{const e=t.layoutSections??[(0,y.l)(t)],n=t.layoutLabelBounds??t.labelBounds;if(t.label.trim().length>0&&!n)throw new Error(`edge ${t.id} is missing its label position`);return{id:t.id,sourceId:t.from.id,targetId:t.to.id,sections:e,labelBounds:n?{...n}:void 0}}),a={diagramId:t.id,bounds:I(i.map(t=>t.bounds),r,s),nodes:i,groups:r,edges:s};return function(t,e){return(0,o.r)(t,e)}(e,a)}function C(t){const{nodeParents:e,groupParents:n}=function(t){const e=new Map,n=new Map;for(const o of t.groupsMap.values())for(const t of o.nodes){const i=E(t)?n:e,r=i.get(t.id);if(r&&r!==o.id)throw new Error(`${E(t)?"group":"node"} ${t.id} belongs to both ${r} and ${o.id}`);i.set(t.id,o.id)}return{nodeParents:e,groupParents:n}}(t);return{id:t.id,nodes:t.nodes().map(t=>function(t,e){if(!t.ref?.isConnected)throw new Error(`node ${t.id} must be drawn before layout`);const n=t.ref.getBBox();return v(t.id,n),{id:t.id,parentId:e,size:{width:n.width,height:n.height},contentSize:{width:n.width,height:n.height},centerOffset:{x:-n.x,y:-n.y},shape:t.style.shape??"Box"}}(t,e.get(t.id))),groups:Array.from(t.groupsMap.values()).map(t=>function(t,e){if(!t.ref?.isConnected)throw new Error(`group ${t.id} must be drawn before layout`);const n=t.ref.querySelector("text");if(!(n instanceof SVGGraphicsElement))throw new Error(`group ${t.id} is missing its drawn title`);const o=n.getBBox();return v(t.id,o),{id:t.id,parentId:e,titleSize:{width:o.width,height:o.height}}}(t,n.get(t.id))),edges:t.edges.map(B)}}function B(t){const e=t.label.trim().length>0;if(e&&!t.labelBounds)throw new Error(`edge ${t.id} must be drawn before layout`);return{id:t.id,sourceId:t.from.id,targetId:t.to.id,labelSize:e?{width:t.labelBounds?.width??0,height:t.labelBounds?.height??0}:void 0}}function v(t,e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0)throw new Error(`browser returned invalid measured box for ${t}`)}function I(t,e,n){const o=[...t,...e.flatMap(t=>[t.bounds,t.titleBounds]),...n.flatMap(t=>t.labelBounds?[t.labelBounds]:[])],i=n.flatMap(t=>t.sections.flat());if(0===o.length&&0===i.length)return{x:0,y:0,width:0,height:0};const r=Math.min(...o.map(t=>t.x),...i.map(t=>t.x)),s=Math.min(...o.map(t=>t.y),...i.map(t=>t.y));return{x:r,y:s,width:Math.max(...o.map(t=>t.x+t.width),...i.map(t=>t.x))-r,height:Math.max(...o.map(t=>t.y+t.height),...i.map(t=>t.y))-s}}function k(t){return{x:t.x,y:t.y,width:t.width,height:t.height}}function E(t){return"nodes"in t}},718(t,e,n){n.d(e,{Mt:()=>r,U2:()=>a});const o=new Map;let i;async function r(){await Promise.all([400,600,700].map(t=>document.fonts.load(`${t} 22px Inter`))),await document.fonts.ready}function s(t,e){const n=function(t,e){const n=Object.entries(e).sort(([t],[e])=>t.localeCompare(e));return JSON.stringify([t,n])}(t,e),r=o.get(n);if(r)return r;const s=document.createElementNS("http://www.w3.org/2000/svg","text");s.setAttribute("x","0"),s.setAttribute("y","0");for(const[t,n]of Object.entries(e))s.setAttribute(t,n);s.textContent=t,(i?.isConnected||(i=document.createElementNS("http://www.w3.org/2000/svg","svg"),i.setAttribute("aria-hidden","true"),i.style.position="absolute",i.style.visibility="hidden",i.style.pointerEvents="none",document.body.appendChild(i)),i).appendChild(s);const a=s.getBBox();s.remove();const d={width:a.width,height:a.height};return o.set(n,d),d}function a(t,e,n){let o=0;return{lines:t.trim().split("\n").flatMap(t=>{const i=[];let r=[];for(const a of t.trim().split(/\s+/)){if(s(a,n).width>e){r.length>0&&(i.push(r.join(" ")),r=[]);const t=d(a,e,n);for(const e of t.slice(0,-1))i.push(e),o=Math.max(o,s(e,n).width);r=t.slice(-1);continue}const t=[...r,a],l=s(t.join(" "),n);l.width>e&&r.length>0?(i.push(r.join(" ")),r=[a]):(o=Math.max(o,l.width),r=t)}if(r.length>0){const t=r.join(" ");i.push(t),o=Math.max(o,s(t,n).width)}return i}),maxW:o}}function d(t,e,n){const o=[];let i="";for(const r of t){const t=i+r;s(t,n).width>e&&i.length>0?(o.push(i),i=r):i=t}return i.length>0&&o.push(i),o}},71(t,e,n){var o=n(108);const i={TopBottom:"DOWN",BottomTop:"UP",LeftRight:"RIGHT",RightLeft:"LEFT"};n.d(e,["B",0,t=>{const e=[];return Object.keys(t.views).filter(t=>t.endsWith("Views")).forEach(n=>{t.views[n].forEach(t=>{e.push({key:t.key,title:t.title||t.key,section:n})})}),e},"R",0,(t,e,n)=>{const r=new Map,s=new Map,a=t=>{Array.isArray(t.relationships)&&t.relationships.forEach(t=>{s.set(t.id,t)})};if(t.model.people&&t.model.people.forEach(t=>{r.set(t.id,t),Array.isArray(t.relationships)&&t.relationships.forEach(t=>{s.set(t.id,t)})}),t.model.softwareSystems&&t.model.softwareSystems.forEach(t=>{r.set(t.id,t),a(t),Array.isArray(t.containers)&&t.containers.forEach(e=>{e.parent=t,r.set(e.id,e),a(e),Array.isArray(e.components)&&e.components.forEach(t=>{t.parent=e,r.set(t.id,t),a(t)})})}),t.model.deploymentNodes){const e=t=>{t.containerInstances&&t.containerInstances.forEach(e=>{const n={...r.get(e.containerId),id:e.id};r.set(n.id,n),n.parent=t,a(e)})},n=(t,o)=>{t.parent=o,r.set(t.id,t),a(t),e(t),t.children&&t.children.forEach(e=>n(e,t)),t.infrastructureNodes&&t.infrastructureNodes.forEach(e=>n(e,t))};t.model.deploymentNodes.forEach(t=>n(t,null))}const{view:d,section:l}=function(t,e){let n=null,o="";return Object.keys(t.views).filter(t=>t.endsWith("Views")).some(i=>t.views[i].some(t=>{if(t.key==e)return n=t,o=i,!0})),{view:n,section:o}}(t,n);if(!d)return null;const c=new o.jg(d.key,d.title||d.key),h=d.automaticLayout?.rankDirection;c.layoutDirection=h?i[h]:void 0;const u={name:c.name,description:d.description,version:t.version,elements:[]};if(c.metadata=u,!d.elements)return c;const A={};if("deploymentViews"==l||"containerViews"==l)d.elements.forEach(t=>{const e=r.get(t.id);e?.parent&&(A[e.parent.id]=!0)});else if("componentViews"===l)d.elements.forEach(t=>{const e=r.get(t.id)?.parent;e?.components&&(e.id===d.containerId||d.externalContainersBoundariesVisible)&&(d.elements.some(t=>t.id===e.id)||(A[e.id]=!0))});else if(d.softwareSystemId)d.elements.find(t=>t.id==d.softwareSystemId)||(A[d.softwareSystemId]=!0);else if("systemLandscapeViews"==l){const e={id:"__enterprise__",...t.model.enterprise};r.set(e.id,e),t.model.people&&t.model.people.filter(t=>"External"!=t.location).forEach(t=>t.parent=e),t.model.softwareSystems&&t.model.softwareSystems.filter(t=>"External"!=t.location).forEach(t=>t.parent=e),A[e.id]=!0}const g=t.views.styles,p=t=>t.toLowerCase().replace(/[^a-z0-9-]/g,"-");g?.elements&&g.elements.forEach(t=>{if(t.tag){const e=`--mdl-${p(t.tag)}`;t.background&&c.colorToVarMap.set(t.background,`${e}-bg`),t.color&&c.colorToVarMap.set(t.color,`${e}-color`),t.stroke&&c.colorToVarMap.set(t.stroke,`${e}-stroke`)}}),g?.relationships&&g.relationships.forEach(t=>{if(t.tag){const e=`--mdl-rel-${p(t.tag)}`;t.color&&c.colorToVarMap.set(t.color,`${e}-color`)}}),d.elements.forEach(e=>{if(A[e.id])return;const n=r.get(e.id),o=n?function(t,e){const n=t.views.containerViews?.find(t=>t.softwareSystemId==e);return n?.key}(t,n.id):void 0;let i="",s={};if(n){const t=n.tags.split(",");i=t[t.length-1],n.technology&&(i+=": "+n.technology),t.forEach(t=>{const e=g&&g.elements&&g.elements.find(e=>e.tag==t);e&&(s={...s,...e})})}c.addNode(e.id,n&&n.name||e.id,i,n&&n.description?n.description:"",s,function(t,e){if(e){const t=encodeURIComponent(e);return{href:`?id=${t}`,exportHref:`${t}.svg`}}if(t?.url)return{href:t.url,exportHref:t.url}}(n,o)),n&&u.elements.push({id:n.id,tags:n.tags,location:n.location,properties:n.properties,elementViewKey:o,technology:n.technology,url:n.url})}),Array.isArray(d.relationships)&&d.relationships.forEach(t=>{const e=s.get(t.id);if(!e)return;if(!c.nodesMap.has(e.sourceId)){if(r.has(e.sourceId)){const t=r.get(e.sourceId);console.warn("Element not found in this view: ",t.id,t.name)}else console.warn("Element not found: ",e.sourceId);return}if(!c.nodesMap.has(e.destinationId)){if(r.has(e.destinationId)){const t=r.get(e.destinationId);console.warn("Element not found in this view: ",t.id,t.name)}else console.warn("Element not found: ",e.destinationId);return}let n={};e.tags.split(",").forEach(t=>{const e=g&&g.relationships&&g.relationships.find(e=>e.tag==t);e&&(n={...n,...e})}),t.routing&&(n.routing=t.routing);const o=e.technology?`${e.description}\n[${e.technology}]`:e.description;c.addEdge(e.id,e.sourceId,e.destinationId,o,t.vertices,n)});const f=t=>{let e=0;for(let n=t.parent;n;n=n.parent)e++;return e};return Object.keys(A).map(t=>r.get(t)).sort((t,e)=>f(t)>f(e)?-1:1).forEach(t=>{let e={};"deploymentViews"==l&&r.get(t.id).tags.split(",").forEach(t=>{const n=g&&g.elements&&g.elements.find(e=>e.tag==t);n&&(e={...e,...n})});const n=d.elements.map(t=>r.get(t.id)).filter(e=>!(!e||e.parent!==t||"systemLandscapeViews"===l&&"__enterprise__"===t.id&&"External"===e.location)).map(t=>t.id);n.length>0&&c.addGroup(t.id,t.name,n,e)}),c.init(e[c.id]),c}])},264(t,e,n){n(763);var o=n(686),i=n(987);const r="add-vertex",s="add-label-vertex",a="del-vertex",d="zoom-in",l="zoom-out",c="zoom-fit",h="zoom-100",u="select-all",A="deselect",g="move-left",p="move-right",f="move-up",m="move-down",b="move-left-fine",y="move-right-fine",w="move-up-fine",x="move-down-fine",C="toggle_drag_mode",B="align_horizontal",v="align_vertical",I="distribute_horizontal",k="distribute_vertical",E="auto_layout",S="reset_position",$="toggle_grid",M="toggle_snap_to_grid",_="snap_all_to_grid",L=[{name:"Help",list:[{id:"help",help:"Show/hide this help",combinations:[{key:"?",shift:!0},{key:"F1",shift:!0}]}]},{name:"File",list:[{id:"save",help:"Save",combinations:[{key:"s",ctrl:!0}]}]},{name:"History",list:[{id:"undo",help:"Undo",combinations:[{ctrl:!0,key:"z"}]},{id:"redo",help:"Redo",combinations:[{ctrl:!0,shift:!0,key:"z"},{ctrl:!0,key:"y"}]}]},{name:"Relationship editing",list:[{id:r,help:"Add relationship vertex",combinations:[{alt:!0,click:!0}]},{id:s,help:"Add label anchor relationship vertex",combinations:[{alt:!0,shift:!0,click:!0}]},{id:a,help:"Remove relationship vertex",combinations:[{key:"DELETE"},{key:"BACKSPACE"}]}]},{name:"Zoom",list:[{id:d,help:"Zoom in",combinations:[{ctrl:!0,key:"="}]},{id:l,help:"Zoom out",combinations:[{ctrl:!0,key:"-"}]},{id:c,help:"Zoom - fit",combinations:[{ctrl:!0,key:"9"}]},{id:h,help:"Zoom 100%",combinations:[{ctrl:!0,key:"0"}]},{id:"wheel_zoom",help:"Zoom in/out with mouse wheel",combinations:[{wheel:!0}]}]},{name:"Mouse Interactions",list:[{id:"pan-view",help:"Pan view (drag empty space)",combinations:[{click:!0}]},{id:"select-element",help:"Select element",combinations:[{click:!0}]},{id:"multi-select",help:"Add/remove from selection",combinations:[{shift:!0,click:!0}]},{id:"box-select",help:"Box selection (drag empty space)",combinations:[{shift:!0,click:!0}]},{id:"move-elements",help:"Move selected elements",combinations:[{click:!0}]}]},{name:"Select",list:[{id:u,help:"Select All",combinations:[{ctrl:!0,key:"a"}]},{id:A,help:"Deselect",combinations:[{key:"ESC"}]}]},{name:"Move",list:[{id:f,help:"Move up (grid increment)",combinations:[{key:"UP"}]},{id:w,help:"Move up (1 pixel)",combinations:[{key:"UP",shift:!0}]},{id:p,help:"Move right (grid increment)",combinations:[{key:"RIGHT"}]},{id:y,help:"Move right (1 pixel)",combinations:[{key:"RIGHT",shift:!0}]},{id:m,help:"Move down (grid increment)",combinations:[{key:"DOWN"}]},{id:x,help:"Move down (1 pixel)",combinations:[{key:"DOWN",shift:!0}]},{id:g,help:"Move left (grid increment)",combinations:[{key:"LEFT"}]},{id:b,help:"Move left (1 pixel)",combinations:[{key:"LEFT",shift:!0}]}]},{name:"View",list:[{id:C,help:"Toggle between pan and select mode",combinations:[{key:"t"}]},{id:S,help:"Reset position and view",combinations:[{key:"Home",ctrl:!0}]}]},{name:"Alignment",list:[{id:B,help:"Align selected elements horizontally",combinations:[{key:"h",ctrl:!0,shift:!0}]},{id:v,help:"Align selected elements vertically",combinations:[{key:"a",ctrl:!0,shift:!0}]},{id:I,help:"Distribute selected elements horizontally",combinations:[{key:"h",ctrl:!0,alt:!0}]},{id:k,help:"Distribute selected elements vertically",combinations:[{key:"v",ctrl:!0,alt:!0}]}]},{name:"Layout",list:[{id:E,help:"Auto layout all elements",combinations:[{key:"l",ctrl:!0}]}]},{name:"Grid",list:[{id:$,help:"Toggle grid visibility",combinations:[{key:"g",ctrl:!0}]},{id:M,help:"Toggle snap to grid",combinations:[{key:"g",ctrl:!0,shift:!0}]},{id:_,help:"Snap all elements to grid",combinations:[{key:"g",ctrl:!0,alt:!0}]}]}],D=L.reduce((t,e)=>t.concat(e.list),[]).reduce((t,e)=>(t[e.id]=e,t),{}),z=t=>[t.ctrl&&(0,o.sy)().toUpperCase(),t.shift&&"SHIFT",t.alt&&"ALT",t.key&&(t.key.length>1?t.key:`"${t.key.toUpperCase()}"`),t.click&&"CLICK",t.wheel&&"WHEEL"].filter(Boolean).join(" + ");n.d(e,["DE",0,I,"F",0,u,"Gg",0,g,"Gn",0,A,"Hd",0,E,"Help",0,()=>(0,i.jsxs)("div",{className:"popover",children:[(0,i.jsx)("h1",{children:"Shortcuts"}),(0,i.jsx)("table",{children:(0,i.jsx)("tbody",{children:L.map(t=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("tr",{children:(0,i.jsx)("th",{colSpan:2,children:t.name})}),t.list.map(t=>(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{children:t.combinations.map(z).join(", ")}),(0,i.jsx)("td",{children:t.help})]}))]}))})})]}),"J8",0,b,"Jk",0,v,"OE",0,_,"Op",0,$,"Ur",0,d,"Vy",0,k,"Yp",0,(t,e=!1,n=!1)=>{const i=Object.keys(D).filter(i=>((t,e,n,i)=>e.combinations.some(e=>{if(Boolean(e.shift)!=t.shiftKey)return!1;if(e.ctrl&&!(0,o.SA)(t))return!1;if(Boolean(e.alt)!=t.altKey)return!1;if(n)return e.click;if(i)return e.wheel;if(e.key){const n=t;return"DELETE"==e.key?"Delete"==n.key:"BACKSPACE"==e.key?"Backspace"==n.key:"ESC"==e.key?"Escape"==n.key:"UP"==e.key?"ArrowUp"==n.key:"DOWN"==e.key?"ArrowDown"==n.key:"LEFT"==e.key?"ArrowLeft"==n.key:"RIGHT"==e.key?"ArrowRight"==n.key:e.key&&n.key&&e.key.toLowerCase()==n.key.toLowerCase()}return!1}))(t,D[i],e,n));if(0!==i.length)return 1===i.length?i[0]:i.sort((t,e)=>{const n=D[t],o=D[e],i=n.combinations[0],r=o.combinations[0],s=(i.shift?1:0)+(i.ctrl?1:0)+(i.alt?1:0);return(r.shift?1:0)+(r.ctrl?1:0)+(r.alt?1:0)-s})[0]},"Zj",0,r,"_s",0,s,"_t",0,S,"aX",0,C,"b3",0,p,"bl",0,a,"hU",0,l,"hZ",0,M,"i1",0,h,"iD",0,y,"l8",0,w,"mD",0,c,"mt",0,x,"rB",0,m,"t9",0,B,"uK",0,f])},686(t,e,n){const o=()=>{if("undefined"==typeof navigator)return!1;if("userAgentData"in navigator&&navigator.userAgentData){const t=navigator.userAgentData.platform;if(t&&t.toLowerCase().includes("mac"))return!0}const t=navigator.userAgent.toLowerCase();if(t.includes("mac os")||t.includes("macintosh"))return!0;if(navigator.platform){const t=navigator.platform.toLowerCase();if(t.includes("mac")||t.includes("darwin"))return!0}try{if(void 0!==new KeyboardEvent("keydown",{metaKey:!0}).metaKey)return/mac|darwin|os x/i.test(navigator.userAgent)}catch(t){}return!1};n.d(e,["SA",0,t=>o()?t.metaKey:t.ctrlKey,"sy",0,()=>o()?"Cmd":"Ctrl"])},183(t,e,n){var o=n(220),i=n.n(o),r=n(716),s=n.n(r),a=n(247),d=n.n(a),l=new URL(n(390),n.b),c=new URL(n(513),n.b),h=new URL(n(568),n.b),u=new URL(n(483),n.b),A=s()(i()),g=d()(l),p=d()(c),f=d()(h),m=d()(u);A.push([t.id,`/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${g}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${p}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${f}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${m}) format("woff2");\n}\n`,"",{version:3,sources:["webpack://./src/fonts.css"],names:[],mappings:"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF",sourcesContent:['/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url("@fontsource/inter/files/inter-latin-400-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url("@fontsource/inter/files/inter-latin-500-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url("@fontsource/inter/files/inter-latin-600-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url("@fontsource/inter/files/inter-latin-700-normal.woff2") format("woff2");\n}\n'],sourceRoot:""}]);const b=A;n.d(e,["A",0,b])},870(t,e,n){var o=n(220),i=n.n(o),r=n(716),s=n.n(r)()(i());s.push([t.id,"html, body, #root {\n height: 100%;\n}\n\nbody {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n color: #666;\n margin: 0;\n}\n\n#root {\n display: flex;\n flex-direction: column;\n}\n#root > div.graph {\n flex: 1;\n overflow: auto;\n position: relative;\n}\n\n.toolbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 10px;\n background-color: #f0f0f0;\n border-bottom: 1px solid #cccccc;\n}\n\n.toolbar > div {\n display: flex;\n align-items: center;\n}\n\n.toolbar button {\n padding: 5px 8px;\n margin: 0 2px;\n cursor: pointer;\n}\n\n.toolbar button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Drag mode toggle button styles */\n.toolbar button.mode-toggle {\n position: relative;\n border: 1px solid #8f9fc9;\n width: 40px;\n min-height: 28px;\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\n border-color: #8f9fc9;\n color: white;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n}\n\n.toolbar button.mode-toggle:hover {\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\n border-color: #abb8db;\n}\n\n.toolbar button.mode-toggle.select-mode:active {\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\n}\n\n/* Pan mode and active toggle - darker blue */\n.toolbar button.mode-toggle.pan-mode,\n.toolbar button.active-toggle {\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n.toolbar button.mode-toggle.pan-mode:hover,\n.toolbar button.active-toggle:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\n.toolbar button.mode-toggle.pan-mode:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n/* Toggle buttons when inactive - gray styling */\n.toolbar button.inactive-toggle {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n.toolbar button.inactive-toggle:hover {\n background: #b1b1b1;\n}\n\n.toolbar button.inactive-toggle:active {\n background: #a1a1a1;\n}\n\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\n.toolbar button .fas {\n font-size: 1em;\n vertical-align: middle;\n}\n\n/* Zoom percentage display */\n.toolbar button.zoom-display {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n font-size: 11px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\n padding: 6px 8px;\n text-align: center;\n}\n\n.toolbar-group {\n display: flex;\n align-items: center;\n margin-right: 25px; /* Large space between groups */\n}\n\n.toolbar-group:last-child {\n margin-right: 0; /* Remove right margin from the last group (help button) */\n}\n\nbutton {\n border: none;\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n border-radius: 3px;\n padding: 6px 10px;\n color: #fff;\n outline: none;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n margin-right: 5px;\n min-width: 32px;\n min-height: 28px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n line-height: 1;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n position: relative;\n}\n\nbutton:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\nbutton:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n}\n\nbutton:last-child {\n margin-right: 0;\n}\n\n/* Save button when no changes - gray */\nbutton.action {\n background: #c1c1c1;\n color: #999;\n}\n\nbutton.action:active {\n background: #b1b1b1;\n}\n\n/* Save button when there are changes - orange */\nbutton.grp {\n background: linear-gradient(to bottom, #ee9564, #de7d48);\n margin-right: 0;\n}\n\nbutton.grp:active {\n background: #d67540;\n}\n\n/* Auto-arrange button with AI purple to blue gradient */\nbutton.auto-arrange {\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\n border-color: #4a4c93;\n}\n\nbutton.auto-arrange:hover {\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\n border-color: #5a5ca3;\n}\n\nbutton.auto-arrange:active {\n background: linear-gradient(135deg, #593B83, #357abd);\n border-color: #3a3c83;\n}\n\nselect {\n border: 1px solid #ccc;\n background: white;\n border-radius: 3px;\n padding: 3px 7px;\n color: #666;\n outline: none;\n margin-right: 5px;\n font-size: 12px;\n}\n\nselect:disabled {\n background: #f5f5f5;\n color: #999;\n}\n\nbutton:disabled {\n background: #c1c1c1;\n color: #999;\n}\n\n#root > div > svg {\n position: absolute;\n user-select: none;\n}\n\n\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\n stroke: #29c229;\n}\n.edge .v-dot {\n fill: transparent;\n stroke: transparent;\n stroke-width: 3px;\n cursor: pointer;\n transition: stroke 0.15s ease;\n}\n.edge .v-dot:hover {\n stroke: #999;\n fill: rgba(153, 153, 153, 0.1);\n}\n.edge .v-dot.selected {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.1);\n}\n.edge .v-dot.selected:hover {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.2);\n}\n.edge .v-dot.auto.selected {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.1);\n}\n.edge .v-dot.auto.selected:hover {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.2);\n}\ncircle#prj {\n fill: none;\n stroke: #777;\n}\n\n.nodeShadow {\n fill: none;\n stroke-width: 4px;\n stroke: rgba(0, 0, 0, 0.13);\n}\n\ng.node {\n user-select: none;\n cursor: default;\n}\n\ng.node.linked {\n cursor: pointer;\n}\n\ng.node text {\n pointer-events: none;\n}\n\n.icon {\n fill: #aaa;\n stroke: #fff;\n}\n#icon-cube {\n fill: #aaa;\n}\n\n/* Ensure all button icons are uncolored */\nbutton .icon,\nbutton svg,\nbutton path {\n fill: currentColor !important;\n stroke: none !important;\n}\n\n/* Font Awesome icon styling in buttons */\nbutton i {\n font-size: 12px;\n color: inherit;\n}\n\nrect.elastic {\n pointer-events: none;\n stroke: none;\n fill: #3bd8281f;\n display: none;\n}\nrect.elastic.on {\n display: block;\n}\n\n.popover {\n position: absolute;\n top: 50px;\n bottom: 10px;\n overflow: auto;\n right: 10px;\n background: ghostwhite;\n padding: 30px;\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\n border: solid 1px #eee;\n}\n\n.popover th {\n text-align: left;\n padding: 20px 0px 10px;\n}\n.popover td {\n padding-right: 20px;\n font-size: 14px;\n}\n\n/* Simple tooltip system with smart positioning */\n[data-tooltip] {\n position: relative;\n}\n\n[data-tooltip]:hover::after {\n content: attr(data-tooltip);\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(0, 0, 0, 0.9);\n color: white;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 12px !important;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n font-weight: normal !important;\n white-space: nowrap;\n z-index: 1000;\n pointer-events: none;\n margin-top: 5px;\n animation: tooltip-appear 0.1s ease-out;\n min-width: 120px;\n max-width: calc(100vw - 20px);\n box-sizing: border-box;\n}\n\n[data-tooltip]:hover::before {\n content: '';\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-bottom-color: rgba(0, 0, 0, 0.9);\n z-index: 1000;\n pointer-events: none;\n margin-top: 1px;\n animation: tooltip-appear 0.1s ease-out;\n}\n\n/* Special handling for rightmost elements that might overflow */\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 0;\n transform: none;\n}\n\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 16px;\n transform: none;\n}\n\n@keyframes tooltip-appear {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(-5px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\nselect {\n position: relative;\n}\n\n/* Robot shape internal elements - inherit stroke from parent node */\n.node .robot-eye-socket {\n fill: none;\n stroke: inherit;\n stroke-width: 2;\n}\n\n.node .robot-eye {\n fill: currentColor;\n stroke: none;\n}\n\n.node .robot-mouth {\n stroke: inherit;\n}\n\n.node .robot-antenna {\n stroke: inherit;\n}\n\n.node .robot-antenna-ball {\n fill: currentColor;\n stroke: inherit;\n stroke-width: 1.5;\n}\n\n.node .robot-panel {\n stroke: inherit;\n}\n\n.node .robot-indicator {\n fill: currentColor;\n stroke: none;\n}","",{version:3,sources:["webpack://./src/style.css"],names:[],mappings:"AAAA;IACI,YAAY;AAChB;;AAEA;IACI,uFAAuF;IACvF,WAAW;IACX,SAAS;AACb;;AAEA;IACI,aAAa;IACb,sBAAsB;AAC1B;AACA;IACI,OAAO;IACP,cAAc;IACd,kBAAkB;AACtB;;AAEA;IACI,aAAa;IACb,8BAA8B;IAC9B,mBAAmB;IACnB,iBAAiB;IACjB,yBAAyB;IACzB,gCAAgC;AACpC;;AAEA;IACI,aAAa;IACb,mBAAmB;AACvB;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I,kBAAkB;IAClB,YAAY;AAChB",sourcesContent:["html, body, #root {\n height: 100%;\n}\n\nbody {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n color: #666;\n margin: 0;\n}\n\n#root {\n display: flex;\n flex-direction: column;\n}\n#root > div.graph {\n flex: 1;\n overflow: auto;\n position: relative;\n}\n\n.toolbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 10px;\n background-color: #f0f0f0;\n border-bottom: 1px solid #cccccc;\n}\n\n.toolbar > div {\n display: flex;\n align-items: center;\n}\n\n.toolbar button {\n padding: 5px 8px;\n margin: 0 2px;\n cursor: pointer;\n}\n\n.toolbar button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Drag mode toggle button styles */\n.toolbar button.mode-toggle {\n position: relative;\n border: 1px solid #8f9fc9;\n width: 40px;\n min-height: 28px;\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\n border-color: #8f9fc9;\n color: white;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n}\n\n.toolbar button.mode-toggle:hover {\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\n border-color: #abb8db;\n}\n\n.toolbar button.mode-toggle.select-mode:active {\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\n}\n\n/* Pan mode and active toggle - darker blue */\n.toolbar button.mode-toggle.pan-mode,\n.toolbar button.active-toggle {\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n.toolbar button.mode-toggle.pan-mode:hover,\n.toolbar button.active-toggle:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\n.toolbar button.mode-toggle.pan-mode:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n/* Toggle buttons when inactive - gray styling */\n.toolbar button.inactive-toggle {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n.toolbar button.inactive-toggle:hover {\n background: #b1b1b1;\n}\n\n.toolbar button.inactive-toggle:active {\n background: #a1a1a1;\n}\n\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\n.toolbar button .fas {\n font-size: 1em;\n vertical-align: middle;\n}\n\n/* Zoom percentage display */\n.toolbar button.zoom-display {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n font-size: 11px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\n padding: 6px 8px;\n text-align: center;\n}\n\n.toolbar-group {\n display: flex;\n align-items: center;\n margin-right: 25px; /* Large space between groups */\n}\n\n.toolbar-group:last-child {\n margin-right: 0; /* Remove right margin from the last group (help button) */\n}\n\nbutton {\n border: none;\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n border-radius: 3px;\n padding: 6px 10px;\n color: #fff;\n outline: none;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n margin-right: 5px;\n min-width: 32px;\n min-height: 28px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n line-height: 1;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n position: relative;\n}\n\nbutton:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\nbutton:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n}\n\nbutton:last-child {\n margin-right: 0;\n}\n\n/* Save button when no changes - gray */\nbutton.action {\n background: #c1c1c1;\n color: #999;\n}\n\nbutton.action:active {\n background: #b1b1b1;\n}\n\n/* Save button when there are changes - orange */\nbutton.grp {\n background: linear-gradient(to bottom, #ee9564, #de7d48);\n margin-right: 0;\n}\n\nbutton.grp:active {\n background: #d67540;\n}\n\n/* Auto-arrange button with AI purple to blue gradient */\nbutton.auto-arrange {\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\n border-color: #4a4c93;\n}\n\nbutton.auto-arrange:hover {\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\n border-color: #5a5ca3;\n}\n\nbutton.auto-arrange:active {\n background: linear-gradient(135deg, #593B83, #357abd);\n border-color: #3a3c83;\n}\n\nselect {\n border: 1px solid #ccc;\n background: white;\n border-radius: 3px;\n padding: 3px 7px;\n color: #666;\n outline: none;\n margin-right: 5px;\n font-size: 12px;\n}\n\nselect:disabled {\n background: #f5f5f5;\n color: #999;\n}\n\nbutton:disabled {\n background: #c1c1c1;\n color: #999;\n}\n\n#root > div > svg {\n position: absolute;\n user-select: none;\n}\n\n\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\n stroke: #29c229;\n}\n.edge .v-dot {\n fill: transparent;\n stroke: transparent;\n stroke-width: 3px;\n cursor: pointer;\n transition: stroke 0.15s ease;\n}\n.edge .v-dot:hover {\n stroke: #999;\n fill: rgba(153, 153, 153, 0.1);\n}\n.edge .v-dot.selected {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.1);\n}\n.edge .v-dot.selected:hover {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.2);\n}\n.edge .v-dot.auto.selected {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.1);\n}\n.edge .v-dot.auto.selected:hover {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.2);\n}\ncircle#prj {\n fill: none;\n stroke: #777;\n}\n\n.nodeShadow {\n fill: none;\n stroke-width: 4px;\n stroke: rgba(0, 0, 0, 0.13);\n}\n\ng.node {\n user-select: none;\n cursor: default;\n}\n\ng.node.linked {\n cursor: pointer;\n}\n\ng.node text {\n pointer-events: none;\n}\n\n.icon {\n fill: #aaa;\n stroke: #fff;\n}\n#icon-cube {\n fill: #aaa;\n}\n\n/* Ensure all button icons are uncolored */\nbutton .icon,\nbutton svg,\nbutton path {\n fill: currentColor !important;\n stroke: none !important;\n}\n\n/* Font Awesome icon styling in buttons */\nbutton i {\n font-size: 12px;\n color: inherit;\n}\n\nrect.elastic {\n pointer-events: none;\n stroke: none;\n fill: #3bd8281f;\n display: none;\n}\nrect.elastic.on {\n display: block;\n}\n\n.popover {\n position: absolute;\n top: 50px;\n bottom: 10px;\n overflow: auto;\n right: 10px;\n background: ghostwhite;\n padding: 30px;\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\n border: solid 1px #eee;\n}\n\n.popover th {\n text-align: left;\n padding: 20px 0px 10px;\n}\n.popover td {\n padding-right: 20px;\n font-size: 14px;\n}\n\n/* Simple tooltip system with smart positioning */\n[data-tooltip] {\n position: relative;\n}\n\n[data-tooltip]:hover::after {\n content: attr(data-tooltip);\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(0, 0, 0, 0.9);\n color: white;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 12px !important;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n font-weight: normal !important;\n white-space: nowrap;\n z-index: 1000;\n pointer-events: none;\n margin-top: 5px;\n animation: tooltip-appear 0.1s ease-out;\n min-width: 120px;\n max-width: calc(100vw - 20px);\n box-sizing: border-box;\n}\n\n[data-tooltip]:hover::before {\n content: '';\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-bottom-color: rgba(0, 0, 0, 0.9);\n z-index: 1000;\n pointer-events: none;\n margin-top: 1px;\n animation: tooltip-appear 0.1s ease-out;\n}\n\n/* Special handling for rightmost elements that might overflow */\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 0;\n transform: none;\n}\n\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 16px;\n transform: none;\n}\n\n@keyframes tooltip-appear {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(-5px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\nselect {\n position: relative;\n}\n\n/* Robot shape internal elements - inherit stroke from parent node */\n.node .robot-eye-socket {\n fill: none;\n stroke: inherit;\n stroke-width: 2;\n}\n\n.node .robot-eye {\n fill: currentColor;\n stroke: none;\n}\n\n.node .robot-mouth {\n stroke: inherit;\n}\n\n.node .robot-antenna {\n stroke: inherit;\n}\n\n.node .robot-antenna-ball {\n fill: currentColor;\n stroke: inherit;\n stroke-width: 1.5;\n}\n\n.node .robot-panel {\n stroke: inherit;\n}\n\n.node .robot-indicator {\n fill: currentColor;\n stroke: none;\n}"],sourceRoot:""}]);const a=s;n.d(e,["A",0,a])},74(t,e,n){var o=n(220),i=n.n(o),r=n(716),s=n.n(r),a=n(247),d=n.n(a),l=new URL(n(390),n.b),c=new URL(n(513),n.b),h=new URL(n(568),n.b),u=new URL(n(483),n.b),A=s()(i()),g=d()(l),p=d()(c),f=d()(h),m=d()(u);A.push([t.id,`/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${g}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${p}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${f}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${m}) format("woff2");\n}\n`,"",{version:3,sources:["webpack://./src/fonts.css"],names:[],mappings:"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF",sourcesContent:['/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url("@fontsource/inter/files/inter-latin-400-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url("@fontsource/inter/files/inter-latin-500-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url("@fontsource/inter/files/inter-latin-600-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url("@fontsource/inter/files/inter-latin-700-normal.woff2") format("woff2");\n}\n'],sourceRoot:""}]);const b=A.toString();n.d(e,["A",0,b])},574(t,e,n){var o=n(582),i=n.n(o),r=n(991),s=n.n(r),a=n(725),d=n.n(a),l=n(798),c=n.n(l),h=n(754),u=n.n(h),A=n(567),g=n.n(A),p=n(183),f={};f.styleTagTransform=g(),f.setAttributes=c(),f.insert=d().bind(null,"head"),f.domAPI=s(),f.insertStyleElement=u(),i()(p.A,f),p.A&&p.A.locals&&p.A.locals},919(t,e,n){var o=n(582),i=n.n(o),r=n(991),s=n.n(r),a=n(725),d=n.n(a),l=n(798),c=n.n(l),h=n(754),u=n.n(h),A=n(567),g=n.n(A),p=n(870),f={};f.styleTagTransform=g(),f.setAttributes=c(),f.insert=d().bind(null,"head"),f.domAPI=s(),f.insertStyleElement=u(),i()(p.A,f),p.A&&p.A.locals&&p.A.locals}}]); +"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[286],{628(t,e,n){n.d(e,["AV",0,(t,e)=>{Object.entries(e).forEach(([e,n])=>{t.setAttribute(e,String(n))})},"M5",0,{nodeBorder:{"stroke-width":1.5},nodeText:{"font-family":"Inter, -apple-system, BlinkMacSystemFont, sans-serif",stroke:"none"},edgeText:{"font-family":"Inter, -apple-system, BlinkMacSystemFont, sans-serif",stroke:"none"},edgeRect:{fill:"none",stroke:"none"},groupRect:{fill:"none",stroke:"#8492a6","stroke-width":1.5,"stroke-dasharray":"6 4"},groupText:{fill:"#475569","font-size":20,"font-weight":"600","font-family":"Inter, -apple-system, BlinkMacSystemFont, sans-serif",cursor:"default"}},"Y$",0,{thickness:2,color:"#64748b",opacity:1,fontSize:18,width:200,dashed:!0},"gd",0,(t,e)=>Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)),"nD",0,{width:280,height:180,background:"#ffffff",color:"#334155",opacity:1,stroke:"#8492a6",fontSize:22,shape:"Box",metadata:!0,description:!0}])},977(t,e,n){n.d(e,{IW:()=>r,Zr:()=>s,l:()=>i});var o=n(628);function i(t){const e=t.from,n=t.to;let o=t.vertices?t.vertices.concat():[];o.unshift(e),o.push(n);const i=o.slice(1,-1),r=i.find(t=>!t.label)??n;let s=e;for(let t=i.length-1;t>=0;t--)if(!i[t].label){s=i[t];break}if(!e.intersect||!n.intersect)throw new Error(`edge ${t.id} nodes must be drawn before routing`);return o[0]=e.intersect(r),o[o.length-1]=n.intersect(s),o}function r(t,e,n){let i,r={x:n.x,y:n.y};const s=t.findIndex(t=>t.label);let a=!0;if(s>=0){const e=t[s];r=e,a=!0===e.auto;const n=[];s>0&&n.push({p:t[s-1],q:r}),st?(0,o.gd)(e.p,e.q)>(0,o.gd)(t.p,t.q)?e:t:e,void 0)}else{const n=t.slice(1).reduce((e,n,i)=>e+(0,o.gd)(t[i],n),0)*e;let s=0;for(let e=1;e0&&s+d>=n){const t=(n-s)/d;r={x:a.p.x+(a.q.x-a.p.x)*t,y:a.p.y+(a.q.y-a.p.y)*t},i=a;break}s+=d}}const d=i?Math.abs(i.q.x-i.p.x):0,l=i?Math.abs(i.q.y-i.p.y):0;return{...r,orientation:l>d?"vertical":"horizontal",segment:i,movable:a}}function s(t){if(t.length<2)throw new Error("edge route must contain at least two points");return t.slice(1).reduce((t,e)=>`${t} L${e.x},${e.y}`,`M${t[0].x},${t[0].y}`)}},20(t,e,n){n.d(e,{r:()=>i}),Symbol("ValidatedLayout");class o extends Error{issues;constructor(t){super(t.map(t=>t.message).join("\n")),this.name="GeometryValidationError",this.issues=t}}function i(t,e){const n=[];t.id!==e.diagramId&&n.push(C("missing_element",[t.id,e.diagramId],`layout ${e.diagramId} does not resolve measured diagram ${t.id}`)),r("measured node",t.nodes.map(t=>t.id),n),r("measured group",t.groups.map(t=>t.id),n),r("measured edge",t.edges.map(t=>t.id),n),r("resolved node",e.nodes.map(t=>t.id),n),r("resolved group",e.groups.map(t=>t.id),n),r("resolved edge",e.edges.map(t=>t.id),n),s("node",t.nodes.map(t=>t.id),e.nodes.map(t=>t.id),n),s("group",t.groups.map(t=>t.id),e.groups.map(t=>t.id),n),s("edge",t.edges.map(t=>t.id),e.edges.map(t=>t.id),n);const i=new Map(t.nodes.map(t=>[t.id,t])),b=new Map(t.groups.map(t=>[t.id,t])),y=new Map(e.nodes.map(t=>[t.id,t])),B=new Map(e.groups.map(t=>[t.id,t]));a("diagram",e.diagramId,e.bounds,n);for(const t of e.nodes){a("node",t.id,t.bounds,n);const o=i.get(t.id);!o||x(o.size.width,t.bounds.width)&&x(o.size.height,t.bounds.height)||n.push(C("size_mismatch",[t.id],`node ${t.id} size changed after measurement`)),o&&(o.contentSize.width>t.bounds.width||o.contentSize.height>t.bounds.height)&&n.push(C("content_overflow",[t.id],`node ${t.id} content exceeds its resolved bounds`)),d("node",t.id,t.bounds,e.bounds,n)}for(const t of e.groups){a("group",t.id,t.bounds,n),a("group title",t.id,t.titleBounds,n),d("group",t.id,t.bounds,e.bounds,n),g(t.bounds,t.titleBounds)||n.push(C("false_containment",[t.id],`group ${t.id} does not contain its title`));const o=b.get(t.id);!o||x(o.titleSize.width,t.titleBounds.width)&&x(o.titleSize.height,t.titleBounds.height)||n.push(C("size_mismatch",[t.id],`group ${t.id} title size changed after measurement`))}if(function(t,e){w(t,(t,n)=>{A(t.bounds,n.bounds)&&e.push(C("node_overlap",[t.id,n.id],`nodes ${t.id} and ${n.id} overlap`))})}(e.nodes,n),function(t,e){w(t,(t,n)=>{!A(t.bounds,n.bounds)||g(t.bounds,n.bounds)||g(n.bounds,t.bounds)||e.push(C("group_overlap",[t.id,n.id],`groups ${t.id} and ${n.id} partially overlap`))})}(e.groups,n),function(t,e,n,o,i){for(const e of t){const t=n.get(e.id);if(t&&t.parentId!==e.parentId&&i.push(C("false_containment",[e.id],`node ${e.id} has the wrong parent ID`)),!e.parentId)continue;const r=o.get(e.parentId);t&&r&&!g(r.bounds,t.bounds)&&i.push(C("false_containment",[e.id,e.parentId],`node ${e.id} lies outside owning group ${e.parentId}`))}for(const t of e){const e=o.get(t.id);if(e&&e.parentId!==t.parentId&&i.push(C("false_containment",[t.id],`group ${t.id} has the wrong parent ID`)),!t.parentId)continue;const n=o.get(t.parentId);e&&n&&!g(n.bounds,e.bounds)&&i.push(C("false_containment",[t.id,t.parentId],`group ${t.id} lies outside owning group ${t.parentId}`))}}(t.nodes,t.groups,y,B,n),function(t,e,n,o,i,r,s){const g=new Map(t.edges.map(t=>[t.id,t])),b=[];for(const t of e.edges){const y=g.get(t.id);if(y)if(t.sourceId===y.sourceId&&t.targetId===y.targetId||s.push(C("disconnected_edge",[t.id,t.sourceId,t.targetId],`edge ${t.id} endpoints do not match its measured contract`)),0===t.sections.length||t.sections.some(t=>t.length<2))s.push(C("disconnected_edge",[t.id],`edge ${t.id} has no complete route section`));else{l(t,n,s);for(const n of t.sections)for(const o of n)if(!m(o)||!f(o,e.bounds,!0)){s.push(C("out_of_bounds",[t.id],`edge ${t.id} has a route point outside the resolved view`));break}for(const e of n.values())e.id!==t.sourceId&&e.id!==t.targetId&&u(t.sections,p(e.bounds,.5))&&s.push(C("edge_through_node",[t.id,e.id],`edge ${t.id} crosses unrelated node ${e.id}`));for(const e of o.values()){const n=c(t.sourceId,e.id,i,r);n===c(t.targetId,e.id,i,r)&&h(t.sections,e.bounds,n)&&s.push(C("edge_through_group",[t.id,e.id],`edge ${t.id} violates group ${e.id} boundary`))}if(t.labelBounds){a("edge label",t.id,t.labelBounds,s),d("edge label",t.id,t.labelBounds,e.bounds,s),!y.labelSize||x(y.labelSize.width,t.labelBounds.width)&&x(y.labelSize.height,t.labelBounds.height)||s.push(C("size_mismatch",[t.id],`edge ${t.id} label size changed after measurement`));for(const e of n.values())A(t.labelBounds,e.bounds)&&s.push(C("label_node_overlap",[t.id,e.id],`edge ${t.id} label overlaps node ${e.id}`));for(const e of o.values())A(t.labelBounds,e.titleBounds)&&s.push(C("label_title_overlap",[t.id,e.id],`edge ${t.id} label overlaps group ${e.id} title`));b.push({id:t.id,bounds:t.labelBounds})}else y.labelSize&&s.push(C("missing_element",[t.id],`edge ${t.id} is missing its measured label`))}}w(b,(t,e)=>{A(t.bounds,e.bounds)&&s.push(C("label_label_overlap",[t.id,e.id],`edge labels ${t.id} and ${e.id} overlap`))});for(const t of b)for(const n of e.edges)u(n.sections,p(t.bounds,.5))&&s.push(C("label_edge_overlap",[t.id,n.id],`edge ${n.id} crosses label ${t.id}`))}(t,e,y,B,i,b,n),n.length>0)throw new o(n);return e}function r(t,e,n){const o=new Set;for(const i of e)o.has(i)&&n.push(C("duplicate_id",[i],`${t} ${i} is duplicated`)),o.add(i)}function s(t,e,n,o){const i=new Set(e),r=new Set(n);for(const e of i)r.has(e)||o.push(C("missing_element",[e],`${t} ${e} is missing from resolved layout`));for(const e of r)i.has(e)||o.push(C("unexpected_element",[e],`${t} ${e} is not in the measured diagram`))}function a(t,e,n,o){(!function(t){return m(t)&&Number.isFinite(t.width)&&Number.isFinite(t.height)}(n)||n.width<0||n.height<0)&&o.push(C("non_finite",[e],`${t} ${e} has invalid geometry`))}function d(t,e,n,o,i){g(o,n)||i.push(C("out_of_bounds",[e],`${t} ${e} lies outside the resolved view bounds`))}function l(t,e,n){for(let e=1;et.some((n,o)=>o>0&&function(t,e,n){const o=e.x-t.x,i=e.y-t.y;let r=0,s=1;for(const[e,a,d,l]of[[t.x,o,n.x,n.x+n.width],[t.y,i,n.y,n.y+n.height]]){if(Math.abs(a)=l)return!1;continue}const t=(d-e)/a,n=(l-e)/a;if(r=Math.max(r,Math.min(t,n)),s=Math.min(s,Math.max(t,n)),r>=s)return!1}return s>0&&r<1}(t[o-1],n,e)))}function A(t,e){return t.x=e.x+e.width&&t.y+t.height>=e.y+e.height}function f(t,e,n){return n?t.x>=e.x&&t.y>=e.y&&t.x<=e.x+e.width&&t.y<=e.y+e.height:t.x>e.x&&t.y>e.y&&t.x=e.x-.1&&t.x<=e.x+e.width+.1,o=t.y>=e.y-.1&&t.y<=e.y+e.height+.1,i=x(t.x,e.x)||x(t.x,e.x+e.width),r=x(t.y,e.y)||x(t.y,e.y+e.height);return o&&i||n&&r}function x(t,e){return Math.abs(t-e)<=.1}function w(t,e){for(let n=0;n$,Qy:()=>j,ZG:()=>_,oP:()=>D,IX:()=>P,F_:()=>H,Kp:()=>O,a_:()=>R});var o=n(74),i=n(321),r=n(718),s=n(628);const a={element(t,e={},n){const o=document.createElementNS("http://www.w3.org/2000/svg",t);return Object.entries(e).forEach(([t,e])=>o.setAttribute(t,String(e))),n&&o.classList.add(n),o},use(t,e={}){const n=this.element("use",e);return n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","#"+t),n},path(t,e={},n){return this.element("path",{...e,d:t},n)},text(t,e={}){const n=this.element("text",e);return t&&(n.textContent=t),n},textArea(t,e,n,o,i=0,a=0,d=""){const l={"font-family":s.M5.edgeText["font-family"],"font-size":`${n}px`,"font-weight":o?"bold":"normal"},{lines:c,maxW:h}=(0,r.U2)(t,e,l),u=this.text("",{x:0,y:a,"text-anchor":d||void 0});return c.forEach((t,e)=>{const o=this.element("tspan",{x:i,dy:`${n+2}px`,...l});o.textContent=t,u.append(o)}),{txt:u,dy:(c.length+1)*(n+2),maxW:h}},rect(t,e,n=0,o=0,i=0,r){return this.element("rect",{x:n,y:o,rx:i,ry:i,width:t,height:e},r)},icon(t,e=0,n=0){return this.use(t,{x:e,y:n})},expand(t,e,n){const o=this.element("g",{transform:`translate(${t},${e})`},"expand");return o.append(this.rect(19,19,0,0,1),this.text(n?"-":"+",{x:10,y:14,"text-anchor":"middle"})),o}};function d(t,e,n){t.setAttribute("transform",`translate(${e},${n})`)}function l(t,e,n=!0){return n?t.x>e.x-e.width/2&&t.xe.y-e.height/2&&t.ye.x&&t.xe.y&&t.yfunction(t,e,n,o){let i,r,s,a,d,l={x:null,y:null,onLine1:!1,onLine2:!1};return i=(o.y-n.y)*(e.x-t.x)-(o.x-n.x)*(e.y-t.y),0==i||(r=t.y-n.y,s=t.x-n.x,a=(o.x-n.x)*r-(o.y-n.y)*s,d=(e.x-t.x)*r-(e.y-t.y)*s,r=a/i,s=d/i,l.x=t.x+r*(e.x-t.x),l.y=t.y+r*(e.y-t.y),r>0&&r<1&&(l.onLine1=!0),s>=0&&s<=1&&(l.onLine2=!0)),l}(t,e,n.p,n.q)).filter(t=>t.onLine1&&t.onLine2)}(t,e,t)[0]||{x:t.x,y:t.y}}function h(t,e,n,o,i){const r={x:i.x-t.x,y:i.y-t.y},s=o.x-t.x,a=o.y-t.y;s==r.x&&(r.x+=1e-7);const d=(a-r.y)/(s-r.x),l=a-d*s,c=n*n+e*e*d*d,h=2*e*e*l*d,u=e*e*l*l-e*e*n*n,A=Math.sqrt(h*h-4*c*u),g=r.x>s?(-h+A)/(2*c):(-h-A)/(2*c),f={x:g,y:d*g+l};return f.x+=t.x,f.y+=t.y,f}function u(t,e,n){let o=n.x-e.x,i=n.y-e.y,r=o*o+i*i,s=(t.x-e.x)*o+(t.y-e.y)*i,a=Math.min(1,Math.max(0,s/r));return{x:e.x+o*a,y:e.y+i*a}}function A(t,e){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function g(t){return t/2/(5.5+t/70)}function f(t,e,n){switch(t.toLowerCase()){case"cylinder":return 2*g(e);case"person":return.4*n;case"folder":return e/10;case"robot":return.35*n;case"webbrowser":return n/8;default:return 0}}class p{_el;constructor(t){this._el=t}node(){return this._el}attr(t,e){return this._el.setAttribute(t,String(e)),this}insert(t,e){const n=document.createElementNS("http://www.w3.org/2000/svg",t),o=this._el.insertBefore(n,this._el.querySelector(e));return new p(o)}}function m(t,e,n,o=!1){const i=t.insert("rect",":first-child").attr("rx",o?n.width/8:3).attr("ry",o?n.width/8:3).attr("x",-e.width/2).attr("y",-e.height/2).attr("width",e.width).attr("height",e.height);return n.intersect=function(t){return c(n,t)},i}function b(t,e,n,o,i){const r=t.insert("ellipse",":first-child").attr("cx",0).attr("cy",0).attr("rx",o).attr("ry",i).attr("width",n.width).attr("height",n.height);return n.intersect=function(t){return h(n,o,i,n,t)},r}function y(t,e,n){const o=n.width/8,i=n.width/14,r=t.insert("g",":first-child");return r.insert("path",":first-child").attr("d",`M${-n.width/2},${-n.height/2} l${n.width},0 M${-n.width/2},${n.height/2} l${n.width},0`),r.insert("circle",":first-child").attr("cx",0).attr("cy",n.height/2+o/2).attr("r",.4*i),r.insert("rect",":first-child").attr("x",-i).attr("y",-n.height/2-o/2-.2*i).attr("width",2*i).attr("height",.4*i),r.insert("rect",":first-child").attr("rx",i).attr("ry",i).attr("x",-e.width/2).attr("y",-e.height/2-o).attr("width",e.width).attr("height",e.height+2*o),n.intersect=function(t){return c({x:n.x,y:n.y,width:n.width,height:n.height+2*o},t)},r}const x={box:(t,e)=>m(new p(t),e,e).node(),roundedbox:(t,e)=>m(new p(t),e,e,!0).node(),component:(t,e)=>function(t,e,n){const o=n.width/10,i=t.insert("g",":first-child");return i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2-o).attr("y",-n.height/2+o).attr("width",2*o).attr("height",o),i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2-o).attr("y",-n.height/2+2.5*o).attr("width",2*o).attr("height",o),i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2).attr("y",-n.height/2).attr("width",n.width).attr("height",n.height),n.intersect=function(t){return c({x:n.x-o/2,y:n.y,width:n.width+o,height:n.height},t)},i}(new p(t),0,e).node(),cylinder:(t,e)=>function(t,e,n){const o=e.width,i=o/2,r=g(o),s=e.height,a=`M 0,${r} a${i},${r} 0,0,0 ${o} 0 a ${i},${r} 0,0,0 ${-o} 0 l 0,${s-2*r} a ${i},${r} 0,0,0 ${o} 0 l 0,${2*r-s}`,d=t.attr("label-offset-y",f("cylinder",o,s)).insert("path",":first-child").attr("d",a).attr("transform","translate("+-o/2+","+-s/2+")");return n.intersect=function(t){const e=c(n,t);let o=n.y+n.height/2-r;return e.y>o?h({x:n.x,y:o},i,r,n,t):(o=n.y-n.height/2+r,e.yfunction(t,e,n){const o=e.width,i=e.height,r=`M ${.38*o},${i/3} A${o/2},${i/2} 0,0,0 0 ${i/2}\n\t\tL${o/11},${i} L${o-o/11},${i} L${o},${i/2}\n\t\tA${o/2},${i/2} 0,0,0 ${o-.38*o} ${i/3} \n\t\tA${o/6},${o/6} 0,1,0 ${.38*o} ${i/3}`,s=t.attr("label-offset-y",f("person",o,i)).insert("path",":first-child").attr("d",r).attr("transform","translate("+-o/2+","+-i/2+")");return n.intersect=function(t){return c(n,t)},s}(new p(t),e,e).node(),circle:(t,e)=>function(t,e,n){return b(t,0,n,n.width/2,n.width/2)}(new p(t),0,e).node(),ellipse:(t,e)=>function(t,e,n){return b(t,0,n,.55*n.width,.45*n.width)}(new p(t),0,e).node(),hexagon:(t,e)=>function(t,e,n){const o=n.width/2,i=t.insert("polygon",":first-child").attr("points",[.5,.866,1,0,.5,-.866,-.5,-.866,-1,-0,-.5,.866,.5,.866].map(t=>t*o).join(",")).attr("width",n.width).attr("height",n.height);return n.intersect=function(t){return h(n,n.width/2,n.width/2,n,t)},i}(new p(t),0,e).node(),folder:(t,e)=>function(t,e,n){const o=n.width/20,i=t.attr("label-offset-y",f("folder",n.width,n.height)).insert("g",":first-child");return i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2).attr("y",-n.height/2+2*o).attr("width",n.width).attr("height",n.height-2*o),i.insert("path",":first-child").attr("d",`M0,${-n.height/2+2*o} l${o},${-2*o} h${n.width/2-2*o} v${2*o}`),n.intersect=function(t){return c({x:n.x,y:n.y+o/2,width:n.width,height:n.height+o},t)},i}(new p(t),0,e).node(),mobiledevicelandscape:(t,e)=>function(t,e,n){const o=n.width/8,i=n.width/14,r=t.insert("g",":first-child");return r.insert("path",":first-child").attr("d",`M${-n.width/2},${-n.height/2} l0,${n.height} M${n.width/2},${-n.height/2} l0,${n.height}`),r.insert("circle",":first-child").attr("cx",-n.width/2-o/2).attr("cy",0).attr("r",.4*i),r.insert("rect",":first-child").attr("x",n.width/2+o/2-.2*i).attr("y",-i).attr("width",.4*i).attr("height",2*i),r.insert("rect",":first-child").attr("rx",i).attr("ry",i).attr("x",-e.width/2-o).attr("y",-e.height/2).attr("width",e.width+2*o).attr("height",e.height),n.intersect=function(t){return c({x:n.x,y:n.y,width:n.width+2*o,height:n.height},t)},r}(new p(t),e,e).node(),mobiledeviceportrait:(t,e)=>y(new p(t),e,e).node(),mobiledevice:(t,e)=>y(new p(t),e,e).node(),pipe:(t,e)=>function(t,e,n){const o=n.width,i=n.height,r=i/2,s=r/(2.5+o/70),a=`M${-s},0\n\t\ta${s},${r} 0,0,1 0,${i}\n\t\ta${s},${r} 0,0,1 0,${-i}\n\t\tl${o},0\n\t\ta${s},${r} 0,0,1 0,${i}\n\t\tl${-o},0`,d=t.insert("path",":first-child").attr("d",a).attr("transform","translate("+-o/2+","+-i/2+")");return n.intersect=function(t){return c({x:n.x-s,y:n.y,width:n.width+2*s,height:n.height},t)},d}(new p(t),0,e).node(),robot:(t,e)=>function(t,e,n){const o=n.width,i=n.height,r=Math.min(.28*o,.25*i),s=.2*r,a=.25*r,d=.08*r,l=.12*r,h=.22*r,u=.12*r,A=.3*r,g=o,p=-i/2+a+r,m=i-a-r,b=t.attr("label-offset-y",f("robot",o,i)).insert("g",":first-child");b.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-g/2).attr("y",p).attr("width",g).attr("height",m);const y=-i/2+a;b.insert("rect",":first-child").attr("rx",s).attr("ry",s).attr("x",-r/2).attr("y",y).attr("width",r).attr("height",r),b.insert("line",":first-child").attr("class","robot-antenna").attr("x1",0).attr("y1",y).attr("x2",0).attr("y2",-i/2+2*d).attr("stroke-width",.6*d).attr("stroke-linecap","round"),b.insert("circle",":first-child").attr("class","robot-antenna-ball").attr("cx",0).attr("cy",-i/2+2*d).attr("r",1.2*d);const x=y+.4*r;b.insert("circle",":first-child").attr("class","robot-eye").attr("cx",-h).attr("cy",x).attr("r",l),b.insert("circle",":first-child").attr("class","robot-eye").attr("cx",h).attr("cy",x).attr("r",l);const w=y+.7*r,C=.28*r;return b.insert("path",":first-child").attr("class","robot-mouth").attr("d",`M${-C/2},${w} Q0,${w+.3*C} ${C/2},${w}`).attr("fill","none").attr("stroke-width",.5*d).attr("stroke-linecap","round"),b.insert("rect",":first-child").attr("rx",.25*u).attr("ry",.25*u).attr("x",-r/2-u-1).attr("y",x-A/2).attr("width",u).attr("height",A),b.insert("rect",":first-child").attr("rx",.25*u).attr("ry",.25*u).attr("x",r/2+1).attr("y",x-A/2).attr("width",u).attr("height",A),n.intersect=function(t){return c(n,t)},b}(new p(t),0,e).node(),webbrowser:(t,e)=>function(t,e,n){const o=n.height/8,i=t.attr("label-offset-y",f("webbrowser",n.width,n.height)).insert("g",":first-child");return i.insert("path",":first-child").attr("d",`\n\t\t\tM${-n.width/2},${-n.height/2+o} h${n.width}\n\t\t\tM${-n.width/2+o/4},${-n.height/2+o/4} h${o/2} v${o/2} h${-o/2} z\n\t\t\tM${-n.width/2+o},${-n.height/2+o/4} h${n.width-o-o/4} v${o/2} h${-n.width+o+o/4} z\n\t\t`),i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2).attr("y",-n.height/2).attr("width",n.width).attr("height",n.height),n.intersect=function(t){return c(n,t)},i}(new p(t),0,e).node()};var w=n(983);class C{versions=[];pos=0;lastSavedPos=0;exportDoc;importDoc;change;tmpPreviousState=null;constructor(t,e,n){this.exportDoc=e,this.importDoc=n,this.change=function(t){let e;return function(){const n=this;clearTimeout(e),e=setTimeout(function(){e=null,t.apply(n)},300)}}(()=>this.saveNow())}beforeChange(){this.tmpPreviousState||(this.tmpPreviousState=this.deepClone(this.exportDoc()))}length(){return this.versions.length}currentState(){return this.deepClone(this.versions[this.pos-1])}saveNow(){if(!this.tmpPreviousState)throw Error("undo.change() was called without previously calling undo.beforeChange()!");this.versions[this.pos]=this.deepClone(this.exportDoc()),this.versions[this.pos-1]=this.tmpPreviousState,this.tmpPreviousState=null,this.pos+=1,this.versions.splice(this.pos)}deepClone(t){return"undefined"!=typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t))}undo(){if(this.pos<2)return;this.pos-=1;const t=this.versions[this.pos-1];this.importDoc(this.deepClone(t))}redo(){if(this.pos>this.versions.length-1)return;const t=this.versions[this.pos];this.importDoc(this.deepClone(t)),this.pos+=1}changed(){return this.pos!==this.lastSavedPos}setSaved(){this.lastSavedPos=this.pos}}var B=n(264),v=n(977);function I(t,e,n,o,i,a){const d={"font-family":String(s.M5.nodeText["font-family"]),"font-size":`${n}px`,"font-weight":o?"bold":"normal"},l=(0,r.U2)(t,e,d);return{lines:l.lines.length>0?l.lines:[""],fontSize:n,lineHeight:n+2,bold:o,field:a,gapAfter:i}}n(20);const k=s.Y$,E=s.nD;let S=0;class ${id;name;nodesMap;edges;edgeVertices;groupsMap;metadata;layoutDirection;validatedLayout;colorToVarMap=new Map;svg;idPrefix;selectListener;dragging=!1;_undo;_gridVisible=!1;_snapToGrid=!0;_gridSize=25;_skipAutoFit=!1;constructor(t,e){this.id=t,this.name=e,this.edges=[],this.edgeVertices=new Map,this.nodesMap=new Map,this.groupsMap=new Map,this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.idPrefix=`g${++S}-`,this._undo=new C(this.id,()=>this.exportLayout(!0),t=>this.importLayout(t,!0))}init(t){t&&this.importLayout(t),this._undo=new C(this.id,()=>this.exportLayout(!0),t=>this.importLayout(t,!0)),this._undo.length()&&this.importLayout(this._undo.currentState()),this._undo.beforeChange(),this._undo.change()}addNode(t,e,n,o,i,r){if(this.nodesMap.has(t))throw Error("duplicate node: "+t);const s={...E,...i},a=(s.shape||"Box").toLowerCase(),d="person"===a?240:180,l=Math.max(280,s.width||0),c=function(t,e,n,o,i,r){const s=Math.max(o-36,80),a=[I(t,s,i,!0,6,"name")];!1!==r.metadata&&e&&a.push(I(`[${e}]`,s,.7*i,!1,10)),!1!==r.description&&n&&a.push(I(n,s,Math.min(.8*i,16),!1,0,"description")),a[a.length-1].gapAfter=0;const d=a.reduce((t,e)=>t+e.lines.length*e.lineHeight+e.gapAfter,0);return{blocks:a,textHeight:d,minimumHeight:d+36+(r.icon?44:0),icon:r.icon}}(e,n,o,l,s.fontSize||22,s);let h=Math.max(d,s.height||0,c.minimumHeight);for(let t=0;t<20;t++){const t=c.minimumHeight+Math.abs(f(a,l,h));if(t<=h+.1)break;h=t}const u={id:t,title:e,sub:n,description:o,style:s,x:0,y:0,width:l,height:h,intersect:null,link:r,contentLayout:c};this.nodesMap.set(u.id,u)}nodes(){return Array.from(this.nodesMap.values())}addEdge(t,e,n,o,i,r){i&&i.forEach((e,n)=>{const o=e;o.id=`v-${t}-${n}`,this.edgeVertices.set(o.id,o)});const s={id:t,from:this.nodesMap.get(e),to:this.nodesMap.get(n),label:o,vertices:null,style:{...k,...r},initVertex:t=>{const e=t;return e.id||(e.id=((t,e)=>`v-${t}-a-${(t=>{let e=2166136261;for(let n=0;n>>0).toString(36)})(`${t}:${e.x}:${e.y}`)}`)(s.id,t),this.edgeVertices.set(e.id,e)),e.edge=s,t},userDeletedVertices:!1};this.edges.push(s),i&&(s.vertices=i.map(t=>s.initVertex(t)))}addGroup(t,e,n,o){if(this.groupsMap.has(t))return void console.error(`Group exists: ${t} ${e}`);const i={id:t,name:e,x:null,y:null,width:null,height:null,nodes:n.map(n=>{const o=this.nodesMap.get(n)||this.groupsMap.get(n);return o||console.error(`Node or group ${n} not found for group ${t} "${e}"`),o}).filter(Boolean),style:o};this.groupsMap.set(t,i)}setNodeSelected(t,e){t.selected=e,e?t.ref.classList.add("selected"):t.ref.classList.remove("selected"),this.updateEdgesSel()}updateEdgesSel(){this.edges.forEach(t=>{t.to.selected||t.from.selected?t.ref.classList.add("selected"):t.ref.classList.remove("selected")})}clearResolvedLayout(){this.validatedLayout=void 0,this.edges.forEach(t=>{t.layoutSections=void 0,t.layoutLabelBounds=void 0}),this.groupsMap.forEach(t=>{t.layoutBounds=void 0,t.layoutTitleBounds=void 0})}moveNode(t,e,n,o=!1,i=!1){if(t){if(this._snapToGrid&&!o){const t=this.snapToGrid(e,n);e=t.x,n=t.y}t.x==e&&t.y==n||(i||this._undo.beforeChange(),this.clearResolvedLayout(),t.x=e,t.y=n,d(t.ref,e,n),this.redrawEdges(t),this.redrawGroups(t),i||this._undo.change())}}moveEdgeVertex(t,e,n,o=!1,i=!1){if(this._snapToGrid&&!o){const t=this.snapToGrid(e,n);e=t.x,n=t.y}t.x==e&&t.y==n||(i||this._undo.beforeChange(),this.clearResolvedLayout(),t.x=e,t.y=n,this.redrawEdge(t.edge),i||this._undo.change())}moveSelected(t,e,n=!1){this.nodes().forEach(o=>o.selected&&this.moveNode(o,o.x+t,o.y+e,n,!1)),this.edgeVertices.forEach(o=>o.selected&&this.moveEdgeVertex(o,o.x+t,o.y+e,n,!1))}insertEdgeVertex(t,e,n,o){this._undo.beforeChange(),this.clearResolvedLayout();const i=t.initVertex(e);i.selected=!0,o&&(t.vertices.forEach(t=>t.label=!1),i.label=!0),t.vertices.splice(n-1,0,i),this.redrawEdge(t),this._undo.change()}deleteEdgeVertex(t){this._undo.beforeChange(),this.clearResolvedLayout();const e=t.edge.vertices.indexOf(t);e>=0&&(t.edge.vertices.splice(e,1),this.edgeVertices.delete(t.id),t.edge.userDeletedVertices=!0),this.redrawEdge(t.edge),this._undo.change()}changed(){return this._undo.changed()}undo(){this._undo.undo()}redo(){this._undo.redo()}alignTopLeft(){const t=this.calculateContentBounds(),e=100-t.x,n=100-t.y;this._skipAutoFit=!0,this._undo.beforeChange(),this.nodesMap.forEach(t=>{this.moveNode(t,t.x+e,t.y+n,!0,!0)}),this.edgeVertices.forEach(t=>{this.moveEdgeVertex(t,t.x+e,t.y+n,!0,!0)}),this._undo.change()}resetPanTransform(){const t=P(this),e=this.svg.querySelector("g.zoom");e&&(e.setAttribute("transform",`scale(${t}) translate(0, 0)`),function(t){const e=t.svg,n=t.calculateContentBounds(),o=P(t),i=Math.max(e.parentElement.clientWidth/o,n.x+n.width+20),r=Math.max(e.parentElement.clientHeight/o,n.y+n.height+20);e.setAttribute("width",String(i*o)),e.setAttribute("height",String(r*o))}(this)),Z(this),this._skipAutoFit=!1}shouldSkipAutoFit(){return this._skipAutoFit}resetView(){const t=this.svg.querySelector("g.zoom");t&&(t.setAttribute("transform","scale(1) translate(0, 0)"),U(this)),Z(this)}redrawEdges(t){this.edges.forEach(e=>(t==e.from||t==e.to)&&this.redrawEdge(e)),this.updateEdgesSel()}redrawEdge(t){const e=t.ref.parentElement;e.removeChild(t.ref),t.ref=V(t,this),e.append(t.ref)}redrawGroups(t){this.groupsMap.forEach(t=>{const e=t.ref.parentElement;e.removeChild(t.ref),T(t),e.append(t.ref)})}exportSVG(){this.validatedLayout||(this.validatedLayout=(0,w.U)(this));const t=this.svg,e=(t.querySelector("rect.elastic"),t.cloneNode(!0)),n=Array.from(e.attributes);n.forEach(t=>e.removeAttributeNode(t)),e.setAttribute("id","graph"),n.forEach(t=>e.setAttributeNode(t)),this.removeIdPrefix(e),e.querySelectorAll("a.nodeLink[data-export-href]").forEach(t=>{t.setAttribute("href",t.getAttribute("data-export-href")||""),t.removeAttribute("data-export-href")});const o=e.querySelector("rect.elastic");o&&o.remove();const i=this.validatedLayout.bounds,r=i.width+100,s=i.height+100,a=50-i.x,d=50-i.y,l=e.querySelector("g.zoom");l&&l.setAttribute("transform",`scale(1) translate(${a}, ${d})`),e.setAttribute("viewBox",`0 0 ${r} ${s}`),e.setAttribute("width",String(r)),e.setAttribute("height",String(s)),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.convertStylesToCustomProperties(e);const c=document.createElement("script");return c.setAttribute("type","application/json"),this.metadata.layout=this.exportLayout(),c.append("/g,"]]]>]>"),e.insertBefore(c,e.firstChild),e.outerHTML}removeIdPrefix(t){const e=this.idPrefix;t.querySelectorAll("*").forEach(t=>{for(const n of Array.from(t.attributes))"id"===n.name&&n.value.startsWith(e)?n.value=n.value.slice(e.length):n.value.includes(`url(#${e}`)?n.value=n.value.split(`url(#${e}`).join("url(#"):"href"===n.localName&&n.value.startsWith(`#${e}`)&&(n.value="#"+n.value.slice(e.length+1))})}convertStylesToCustomProperties(t){0!==this.colorToVarMap.size&&(t.querySelectorAll("[fill]").forEach(t=>{const e=t.getAttribute("fill");e&&this.colorToVarMap.has(e)&&t.setAttribute("fill",`var(${this.colorToVarMap.get(e)}, ${e})`)}),t.querySelectorAll("[stroke]").forEach(t=>{const e=t.getAttribute("stroke");e&&this.colorToVarMap.has(e)&&t.setAttribute("stroke",`var(${this.colorToVarMap.get(e)}, ${e})`)}))}calculateContentBounds(){let t=1/0,e=1/0,n=-1/0,o=-1/0;return this.nodes().forEach(i=>{const r=i.x-i.width/2,s=i.x+i.width/2,a=i.y-i.height/2,d=i.y+i.height/2;t=Math.min(t,r),n=Math.max(n,s),e=Math.min(e,a),o=Math.max(o,d)}),this.edgeVertices.forEach(i=>{t=Math.min(t,i.x-5),n=Math.max(n,i.x+5),e=Math.min(e,i.y-5),o=Math.max(o,i.y+5)}),this.groupsMap.forEach(i=>{const r=i.x-i.width/2,s=i.x+i.width/2,a=i.y-i.height/2,d=i.y+i.height/2;t=Math.min(t,r),n=Math.max(n,s),e=Math.min(e,a),o=Math.max(o,d)}),this.edges.forEach(i=>{if(t=Math.min(t,i.from.x-10,i.to.x-10),n=Math.max(n,i.from.x+10,i.to.x+10),e=Math.min(e,i.from.y-10,i.to.y-10),o=Math.max(o,i.from.y+10,i.to.y+10),i.vertices&&i.vertices.forEach(i=>{t=Math.min(t,i.x-10),n=Math.max(n,i.x+10),e=Math.min(e,i.y-10),o=Math.max(o,i.y+10)}),i.label&&i.label.trim()){const r=(i.from.x+i.to.x)/2,s=(i.from.y+i.to.y)/2,a=10*i.label.length+50;t=Math.min(t,r-a),n=Math.max(n,r+a),e=Math.min(e,s-25),o=Math.max(o,s+25)}}),t===1/0?{x:0,y:0,width:100,height:100}:{x:t,y:e,width:n-t,height:o-e}}exportLayout(t=!1){const e={};return this.nodes().forEach(t=>e[t.id]={x:t.x,y:t.y}),this.edges.forEach(n=>{if(!n.vertices)return;const o=n.vertices.map(t=>({x:t.x,y:t.y,label:t.label,auto:t.auto}));(o.length||t)&&(e[`e-${n.id}`]=o),n.userDeletedVertices&&(e[`e-${n.id}-deleted`]=!0)}),e}setSaved(){this._undo.setSaved()}importLayout(t,e=!1){this.clearResolvedLayout();for(const[e,n]of Object.entries(t)){const t=this.nodesMap.get(e);if(t){const o=L(e,n);t.x=o.x,t.y=o.y;continue}if(e.endsWith("-deleted")){const t=e.slice(2,-8),o=this.edges.find(e=>e.id===t);if(!o||!0!==n)throw new Error(`invalid deleted-edge layout entry ${e}`);o.userDeletedVertices=!0;continue}if(e.startsWith("e-")){const t=this.edges.find(t=>t.id===e.slice(2));if(!t||!Array.isArray(n))throw new Error(`invalid edge layout entry ${e}`);for(const e of t.vertices??[])this.edgeVertices.delete(e.id);t.vertices=n.map((n,o)=>{const i=L(`${e}[${o}]`,n),r=t.initVertex(i);return r.label=n.label,r.auto=n.auto,r});continue}throw new Error(`layout contains unknown element ${e}`)}for(const e of this.nodes())if(!(e.id in t))throw new Error(`layout is missing node ${e.id}`);e&&(this.nodes().forEach(t=>d(t.ref,t.x,t.y)),this.edges.forEach(t=>this.redrawEdge(t)),this.updateEdgesSel(),this.redrawGroups(null))}async autoLayout(t){const e=await(0,w.k)(this,t);this._undo.beforeChange();for(const t of e.nodes){const e=this.nodesMap.get(t.id);if(!e)throw new Error(`layout contains unknown node ${t.id}`);e.x=t.x,e.y=t.y,d(e.ref,e.x,e.y)}for(const t of e.groups){const e=this.groupsMap.get(t.id);if(!e)throw new Error(`layout contains unknown group ${t.id}`);e.layoutBounds=t.bounds,e.layoutTitleBounds=t.titleBounds,e.x=t.bounds.x+t.bounds.width/2,e.y=t.bounds.y+t.bounds.height/2,e.width=t.bounds.width,e.height=t.bounds.height}for(const t of e.edges){const e=this.edges.find(e=>e.id===t.id);if(!e)throw new Error(`layout contains unknown edge ${t.id}`);for(const t of e.vertices??[])this.edgeVertices.delete(t.id);e.layoutSections=t.sections,e.layoutLabelBounds=t.labelBounds,e.vertices=M(t.sections).map(t=>{const n=e.initVertex(t);return n.auto=!0,n}),e.userDeletedVertices=!1}this.validatedLayout=e.validated,this.edges.forEach(t=>this.redrawEdge(t)),this.redrawGroups(null),this.fitToView(),this._undo.change()}alignSelectionV(){const t=this.nodes().filter(t=>t.selected);t.push(...Array.from(this.edgeVertices.values()).filter(t=>t.selected));let e=Math.min(...t.map(t=>t.y));this.nodesMap.forEach(t=>t.selected&&this.moveNode(t,t.x,e,!1,!1)),this.edgeVertices.forEach(t=>t.selected&&this.moveEdgeVertex(t,t.x,e,!1,!1))}alignSelectionH(){const t=this.nodes().filter(t=>t.selected);t.push(...Array.from(this.edgeVertices.values()).filter(t=>t.selected));let e=Math.min(...t.map(t=>t.x));this.nodesMap.forEach(t=>t.selected&&this.moveNode(t,e,t.y,!1,!1)),this.edgeVertices.forEach(t=>t.selected&&this.moveEdgeVertex(t,e,t.y,!1,!1))}distributeSelectionH(){const t=this.nodes().filter(t=>t.selected),e=Array.from(this.edgeVertices.values()).filter(t=>t.selected);if(t.length+e.length<3)return;this._undo.beforeChange();const n=[...t,...e];n.sort((t,e)=>t.x-e.x);const o=n[0].x,i=(n[n.length-1].x-o)/(n.length-1);n.forEach((t,e)=>{const n=o+e*i;"title"in t?this.moveNode(t,n,t.y,!1,!0):this.moveEdgeVertex(t,n,t.y,!1,!0)}),this._undo.change()}distributeSelectionV(){const t=this.nodes().filter(t=>t.selected),e=Array.from(this.edgeVertices.values()).filter(t=>t.selected);if(t.length+e.length<3)return;this._undo.beforeChange();const n=[...t,...e];n.sort((t,e)=>t.y-e.y);const o=n[0].y,i=(n[n.length-1].y-o)/(n.length-1);n.forEach((t,e)=>{const n=o+e*i;"title"in t?this.moveNode(t,t.x,n,!1,!0):this.moveEdgeVertex(t,t.x,n,!1,!0)}),this._undo.change()}setEdgeSelected(t,e){e&&(this.setNodeSelected(t.from,!0),this.setNodeSelected(t.to,!0)),this.updateEdgesSel()}fitToView(){const t=this.calculateContentBounds();if(0===t.width||0===t.height)return;const e=this.svg.parentElement?.clientWidth||800,n=this.svg.parentElement?.clientHeight||600,o=(e-80)/t.width,i=(n-80)/t.height,r=Math.min(o,i),s=Math.max(Math.min(r,2),.1),a=e/2-(t.x+t.width/2)*s,d=n/2-(t.y+t.height/2)*s,l=this.svg.querySelector("g.zoom");l&&l.setAttribute("transform",`translate(${a}, ${d}) scale(${s})`),U(this),O(this)}saveLayoutState(){return this.exportLayout(!0)}restoreLayoutState(t){this.importLayout(t,!0)}isGridVisible(){return this._gridVisible}isSnapToGrid(){return this._snapToGrid}getGridSize(){return this._gridSize}toggleGrid(){this._gridVisible=!this._gridVisible,this.updateGridDisplay(),window.dispatchEvent(new CustomEvent("gridStateChanged"))}toggleSnapToGrid(){this._snapToGrid=!this._snapToGrid,window.dispatchEvent(new CustomEvent("gridStateChanged"))}snapAllToGrid(){this._snapToGrid&&(this._undo.beforeChange(),this.nodes().forEach(t=>{const e=Math.round(t.x/this._gridSize)*this._gridSize,n=Math.round(t.y/this._gridSize)*this._gridSize;this.moveNode(t,e,n,!1,!0)}),this._undo.change())}snapToGrid(t,e){return{x:Math.round(t/this._gridSize)*this._gridSize,y:Math.round(e/this._gridSize)*this._gridSize}}updateGridDisplay(){const t=this.svg,e=t.querySelector(`#${this.idPrefix}grid-pattern`);e&&e.remove();const n=t.querySelector(`#${this.idPrefix}grid-background`);if(n&&n.remove(),!this._gridVisible)return;let o=t.querySelector("defs");o||(o=document.createElementNS("http://www.w3.org/2000/svg","defs"),t.insertBefore(o,t.firstChild));const i=document.createElementNS("http://www.w3.org/2000/svg","pattern");i.id=`${this.idPrefix}grid-pattern`,i.setAttribute("width",this._gridSize.toString()),i.setAttribute("height",this._gridSize.toString()),i.setAttribute("patternUnits","userSpaceOnUse");const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",`M ${this._gridSize} 0 L 0 0 0 ${this._gridSize}`),r.setAttribute("fill","none"),r.setAttribute("stroke","#d0d0d0"),r.setAttribute("stroke-width","1"),r.setAttribute("opacity","0.8"),i.appendChild(r),o.appendChild(i);const s=document.createElementNS("http://www.w3.org/2000/svg","rect");s.id=`${this.idPrefix}grid-background`,s.setAttribute("x","-10000"),s.setAttribute("y","-10000"),s.setAttribute("width","20000"),s.setAttribute("height","20000"),s.setAttribute("fill",`url(#${this.idPrefix}grid-pattern)`),s.setAttribute("pointer-events","none");const a=t.querySelector("g.zoom");a&&a.insertBefore(s,a.firstChild)}}function M(t){const e=[];for(const n of t)for(const t of n){const n=e[e.length-1];n&&n.x===t.x&&n.y===t.y||e.push(t)}return e.slice(1,-1)}function L(t,e){if("object"!=typeof e||Array.isArray(e)||!Number.isFinite(e.x)||!Number.isFinite(e.y))throw new Error(`layout entry ${t} must contain valid x and y coordinates`);return e}const _=(t,e,n)=>{const o=t.svg;o.setAttribute("width","100%"),o.setAttribute("height","100%"),document.body.append(o),t.selectListener=e,z(t);const i=a.rect(300,300,50,50,0,"elastic");return o.append(i),t.updateGridDisplay(),j(t,n),{svg:o,setZoom:e=>function(t,e){const n=t.svg.querySelector("g.zoom");if(!n)return;const o=W(t);n.setAttribute("transform",`translate(${o.x}, ${o.y}) scale(${e})`),U(t)}(t,e)}},D=t=>(z(t),t.svg),z=t=>{var e;t.svg.innerHTML=(e=t.idPrefix,`\n\n\t\n\t${i.replace(/&/g,"&").replace(/\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n`);const n=a.element("g",{},"zoom"),r=a.element("g",{},"nodes"),l=a.element("g",{},"edges"),c=a.element("g",{},"groups");n.append(c,l,r),t.nodesMap.forEach(e=>{!function(t,e){const n=a.element("g",{},"node");n.setAttribute("id",e.idPrefix+t.id),t.selected&&n.classList.add("selected"),d(n,t.x,t.y);const o=t.link?a.element("a",{href:t.link.href,"data-export-href":t.link.exportHref,"aria-label":`Open ${t.title}`},"nodeLink"):null,i=o||n;o&&(n.classList.add("linked"),n.append(o));const r=t.style.shape||"Box",l=(x[r.toLowerCase()]||x.box)(i,t);l.classList.add("nodeBorder"),(0,s.AV)(l,s.M5.nodeBorder),l.setAttribute("fill",t.style.background),l.setAttribute("stroke",t.style.stroke),l.setAttribute("opacity",String(t.style.opacity)),G(l,t.style.border);const c=function(t,e){const n=a.element("g"),o=t.icon?44:0;let i=-(t.textHeight+o)/2;return t.icon&&(n.append(a.element("image",{href:t.icon,x:-16,y:i,width:32,height:32,preserveAspectRatio:"xMidYMid meet"},"nodeIcon")),i+=o),t.blocks.forEach(t=>{const o=a.text("",{"text-anchor":"middle"});(0,s.AV)(o,s.M5.nodeText),e&&o.setAttribute("fill",e),t.field&&o.setAttribute("data-field",t.field),t.lines.forEach((e,n)=>{const r=a.element("tspan",{x:0,y:i+t.fontSize+n*t.lineHeight,"font-size":`${t.fontSize}px`,"font-weight":t.bold?"bold":"normal"});r.textContent=e,o.append(r)}),n.append(o),i+=t.lines.length*t.lineHeight+t.gapAfter}),n}(t.contentLayout,t.style.color);d(c,0,(Number(i.getAttribute("label-offset-y"))||0)/2),i.append(c),n.__data=t,t.ref=n}(e,t),r.append(e.ref)}),t.edges.forEach(t=>{t.labelBounds=void 0}),t.edges.forEach(e=>{V(e,t),l.append(e.ref)}),t.groupsMap.forEach(t=>{T(t),c.append(t.ref)}),t.svg.append(n)};function V(t,e){const n=t.from,o=a.element("g",{},"edge");o.setAttribute("id",e.idPrefix+t.id),o.setAttribute("data-from",t.from.id),o.setAttribute("data-to",t.to.id);const i=(t.style.position||50)/100,r=t.layoutSections?function(t){const e=[];for(const n of t)for(const t of n){const n=e[e.length-1];n&&n.x===t.x&&n.y===t.y||e.push(t)}return e}(t.layoutSections):(0,v.l)(t),{bg:d,txt:l}=t.layoutLabelBounds?function(t,e){const n=t.x+t.width/2,{txt:o}=(t.y,t.height,a.textArea(e.label,e.style.width,e.style.fontSize,!1,n,t.y,"middle"));(0,s.AV)(o,s.M5.edgeText),o.setAttribute("stroke","none"),o.setAttribute("font-size",String(e.style.fontSize)),o.setAttribute("fill",e.style.color),o.setAttribute("data-field","label");const i=a.rect(t.width,t.height,t.x,t.y);return(0,s.AV)(i,s.M5.edgeRect),{bg:i,txt:o}}(t.layoutLabelBounds,t):function(t,e){const n=e.style.fontSize;let{txt:o,dy:i,maxW:r}=a.textArea(e.label,e.style.width,n,!1,t.x,t.y,"middle");i-=n/2,r+=n;const d="vertical"===t.orientation?t.x+r/2+12:t.x,l="vertical"===t.orientation?t.y:t.y-i/2-12,c={x:d-r/2,y:l-i/2,width:r,height:i};o.querySelectorAll("tspan").forEach(t=>{t.setAttribute("x",String(d))}),o.setAttribute("y",String(l-i/2)),(0,s.AV)(o,s.M5.edgeText),o.setAttribute("stroke","none"),o.setAttribute("font-size",String(e.style.fontSize)),o.setAttribute("fill",e.style.color);const h=a.rect(c.width,c.height,c.x,c.y);return(0,s.AV)(h,s.M5.edgeRect),o.setAttribute("data-field","label"),e.labelBounds=c,{bg:h,txt:o}}((0,v.IW)(r,i,n),t);o.append(d,l);const c=(0,v.Zr)(r),h=a.path(c,{"marker-end":`url(#${e.idPrefix}arrow)`},"edge");h.setAttribute("fill","none"),h.setAttribute("stroke",t.style.color),h.setAttribute("stroke-width",String(t.style.thickness)),h.setAttribute("stroke-linecap","round"),t.style.dashed&&h.setAttribute("stroke-dasharray","8"),o.append(h);for(const n of t.vertices??[]){const t=n;t.ref=a.element("circle",{id:e.idPrefix+t.id,cx:n.x,cy:n.y,r:7,fill:"none"},"v-dot"),t.selected&&t.ref.classList.add("selected"),t.auto&&t.ref.classList.add("auto"),o.append(t.ref)}return t.ref=o,o}function T(t){if(0==t.nodes.length)return;const e=a.element("g",{},"group");if(t.layoutBounds&&t.layoutTitleBounds){const n=t.layoutBounds,o=t.layoutTitleBounds,i=a.rect(n.width,n.height,n.x,n.y);(0,s.AV)(i,s.M5.groupRect),t.style.stroke&&i.setAttribute("stroke",t.style.stroke),t.style.background&&i.setAttribute("fill",t.style.background);const r=a.text(t.name,{x:o.x,y:o.y,"dominant-baseline":"hanging"});return(0,s.AV)(r,s.M5.groupText),t.style.color&&r.setAttribute("fill",t.style.color),e.append(i,r),void(t.ref=e)}let n={x:1e100,y:1e100},o={x:0,y:0};t.nodes.forEach(t=>{const e=t.style?.shape?.toLowerCase()||"box";let i=t.height/2,r=t.height/2;if("robot"===e){const e=.12*t.height;i=t.height/2+e,r=t.height/2}else if("hexagon"===e){const e=t.width/2*.866;i=e,r=e}const s={x:t.x-t.width/2,y:t.y-i,width:t.width,height:i+r};n.x=Math.min(n.x,s.x),n.y=Math.min(n.y,s.y),o.x=Math.max(o.x,s.x+s.width),o.y=Math.max(o.y,s.y+s.height)});const i=Math.max(o.x-n.x,200),r=o.y-n.y,d={x:n.x-25,y:n.y-25,width:i+50,height:r+50+30},l=a.rect(d.width,d.height,d.x,d.y);t.x=d.x+d.width/2,t.y=d.y+d.height/2,t.width=d.width,t.height=d.height,(0,s.AV)(l,s.M5.groupRect),t.style.stroke&&l.setAttribute("stroke",t.style.stroke),t.style.background&&l.setAttribute("fill",t.style.background);const c=a.text(t.name,{x:n.x,y:d.y+d.height-s.M5.groupText["font-size"]});(0,s.AV)(c,s.M5.groupText),t.style.color&&c.setAttribute("fill",t.style.color),e.append(l,c),t.ref=e}function F(t,e){let n={dst:Number.POSITIVE_INFINITY,pos:-1,edge:null,prj:null};return t.edges.forEach(t=>{const o=t.vertices||[],i=[t.from,...o,t.to];for(let o=1;o50||s3||Math.abs(d)>3)&&(u=!0,h=null,c)){const t=e.getSelection();t.length=0,t.push(c.node),e.setSelection(t),i=[{x:c.node.x,y:c.node.y,n:c.node}],c=null}if(s)!function(e,n){const i=o.querySelector("g.zoom");if(!i)return;const r=P(t);i.setAttribute("transform",`translate(${e}, ${n}) scale(${r})`)}(l.x+a,l.y+d);else if(i.length>0&&u){const t=e.getZoom(),n=a/t,o=d/t;i.forEach(t=>{e.moveNode(t.n,t.x+n,t.y+o)}),e.setDragging(!0)}else r&&(r.update(n),e.setDragging(!0))}(n=m(n),n.clientX-p.ex,n.clientY-p.ey)}function y(n){document.removeEventListener("touchmove",b),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",y),document.removeEventListener("touchend",y),function(n){e.setDragging(!1);const o=u?null:h;if(u&&(A=!0,window.setTimeout(()=>{A=!1},0)),c&&!u){const t=e.getSelection();t.length=0,t.push(c.node),e.setSelection(t)}if(r){const t=r.end();t?e.boxSelection(t,n.shiftKey):i.length||e.setSelection([]),r=null}s&&u&&O(t),c=null,h=null,u=!1,s=!1,e.updatePanning(),o&&(window.location.href=o)}(m(n)),p=null}function x(A){A=m(A),p={ex:A.clientX,ey:A.clientY},function(A){A.preventDefault(),u=!1,c=null;const g=A.target,f=g instanceof Element?g.closest("a.nodeLink"):null;h=A.shiftKey?null:f?.getAttribute("href")||null;const p=e.nodeFromEvent(A),m=A.shiftKey?"pan"===n?"select":"pan":n;if(p)if("pan"===m){s=!1,r=null;const t=e.getSelection();e.isSelected(p)?i=t.map(t=>({x:t.x,y:t.y,n:t})):(e.setSelection([p]),i=[{x:p.x,y:p.y,n:p}])}else{s=!1,r=null;const t=e.getSelection();if(A.shiftKey&&"select"===n){if(e.isSelected(p)){const e=t.findIndex(t=>t.id===p.id);e>=0&&t.splice(e,1)}else t.push(p);e.setSelection(t),i=t.map(t=>({x:t.x,y:t.y,n:t}))}else e.isSelected(p)?(i=t.map(t=>({x:t.x,y:t.y,n:t})),c=null):(c={node:p,shiftKey:A.shiftKey},i=[{x:p.x,y:p.y,n:p}])}else"pan"===m?(s=!0,r=null,a=A.clientX,d=A.clientY,l=function(){const t=o.querySelector("g.zoom");if(!t)return{x:0,y:0};const e=(t.getAttribute("transform")||"").match(/translate\(([^,]+),([^)]+)\)/);return e?{x:parseFloat(e[1])||0,y:parseFloat(e[2])||0}:{x:0,y:0}}(),i=[],e.setSelection([])):(s=!1,r=function(){let e=0,n=0,i=null;return{ini(r){const s=N(t,r);e=s.x,n=s.y,i=document.createElementNS("http://www.w3.org/2000/svg","rect"),i.setAttribute("fill","rgba(0, 100, 255, 0.1)"),i.setAttribute("stroke","rgba(0, 100, 255, 0.5)"),i.setAttribute("stroke-width","1"),i.setAttribute("stroke-dasharray","3,3"),i.setAttribute("x",String(e)),i.setAttribute("y",String(n)),i.setAttribute("width","0"),i.setAttribute("height","0");const a=o.querySelector("g.zoom");a?a.appendChild(i):o.appendChild(i)},update(o){if(!i)return;const r=N(t,o),s=r.x,a=r.y,d=Math.min(e,s),l=Math.min(n,a),c=Math.abs(s-e),h=Math.abs(a-n);i.setAttribute("x",String(d)),i.setAttribute("y",String(l)),i.setAttribute("width",String(c)),i.setAttribute("height",String(h))},end(){if(!i)return null;const t=parseFloat(i.getAttribute("x")||"0"),e=parseFloat(i.getAttribute("y")||"0"),n=parseFloat(i.getAttribute("width")||"0"),o=parseFloat(i.getAttribute("height")||"0");return i.remove(),i=null,n>5&&o>5?{x:t,y:e,width:n,height:o,left:t,top:e,right:t+n,bottom:e+o}:null}}}(),r&&r.ini(A),i=[])}(A),document.addEventListener("touchmove",b),document.addEventListener("mousemove",b),document.addEventListener("mouseup",y),document.addEventListener("touchend",y)}f.addEventListener("mousedown",x),f.addEventListener("touchstart",x),g.push({element:f,event:"mousedown",handler:x},{element:f,event:"touchstart",handler:x})}(o),o.addEventListener("click",f),g.push({element:o,event:"click",handler:f}),()=>{g.forEach(({element:t,event:e,handler:n})=>{t.removeEventListener(e,n)})}}function j(t,e){const n=t.svg,o=n.__cursorInteractionCleanup;o&&o();const i=[],r=e=>{t.changed()&&(e.preventDefault(),e.returnValue="")};function s(e,o){e.selected=o;const i=n.querySelector("#"+t.idPrefix+e.id);e.selected?i.classList.add("selected"):i.classList.remove("selected")}window.addEventListener("beforeunload",r),i.push({element:window,event:"beforeunload",handler:r});const d=e=>{if(!e.altKey)return;const o=F(t,N(t,e));if(o){const{prj:e}=o,i=n.querySelector("g.edges");let r=i.querySelector(`#${t.idPrefix}prj`);r||(r=a.element("circle",{id:`${t.idPrefix}prj`,cx:e.x,cy:e.y,r:7}),i.append(r)),r.setAttribute("cx",String(e.x)),r.setAttribute("cy",String(e.y))}else h()};n.addEventListener("mousemove",d),i.push({element:n,event:"mousemove",handler:d});const c=t=>{const e=(0,B.Yp)(t,!0);e!=B.Zj&&e!=B._s&&h()};function h(){const e=n.querySelector(`g.edges #${t.idPrefix}prj`);e&&e.parentElement.removeChild(e)}window.addEventListener("keyup",c),i.push({element:window,event:"keyup",handler:c});const u=e=>{const n=(0,B.Yp)(e,!0);if(n!=B._s&&n!=B.Zj)return;const o=F(t,N(t,e));if(o){const{edge:e,pos:i,prj:r}=o;t.insertEdgeVertex(e,r,i,n==B._s),h()}};n.addEventListener("click",u),i.push({element:n,event:"click",handler:u});const A=e=>{const o=.1*Math.sign(e.deltaY),i=P(t),r=Math.max(.1,Math.min(5,i-o));if(r!==i){const o=n.getBoundingClientRect(),i=e.clientX-o.left,s=e.clientY-o.top;R(t,r,i,s),e.preventDefault(),O(t)}};n.addEventListener("wheel",A),i.push({element:n,event:"wheel",handler:A});const g=e=>{const n=(0,B.Yp)(e);switch(n&&e.preventDefault(),n){case B.bl:Array.from(t.edgeVertices.values()).filter(t=>t.selected).forEach(e=>{t.deleteEdgeVertex(e)});break;case"undo":t.undo();break;case"redo":t.redo();break;case B.Ur:const e=Math.min(5,1.2*P(t));R(t,e),O(t);break;case B.hU:const n=Math.max(.1,P(t)/1.2);R(t,n),O(t);break;case B.i1:R(t,1),O(t);break;case B.mD:t.fitToView();break;case B.F:t.nodes().forEach(e=>t.setNodeSelected(e,!0)),t.edgeVertices.forEach(t=>s(t,!0));break;case B.Gn:t.nodes().forEach(e=>t.setNodeSelected(e,!1)),t.edgeVertices.forEach(t=>s(t,!1))}};window.addEventListener("keydown",g),i.push({element:window,event:"keydown",handler:g});const f=q(t,{nodeFromEvent(e){e.preventDefault();let n=e.target.closest("g.nodes g.node");return n?function(t){return t.__data}(n):(n=e.target.closest("g.edges g.edge .v-dot"),n?t.edgeVertices.get(n.id.slice(t.idPrefix.length)):null)},setSelection(e){t.nodes().forEach(n=>t.setNodeSelected(n,e.some(t=>t.id==n.id))),t.edgeVertices.forEach(t=>s(t,e.some(e=>e.id==t.id))),t.selectListener(t.nodes().find(t=>t.selected))},setDragging(e){t.dragging=e},isSelected:t=>t.selected,getSelection(){const e=t.nodes().filter(t=>t.selected);return t.edgeVertices.forEach(t=>t.selected&&e.push(t)),e},getZoom:()=>P(t),moveNode(e,n,o){t.nodesMap.has(e.id)?t.moveNode(e,n,o):(e.auto=!1,t.moveEdgeVertex(e,n,o))},boxSelection(e,n){t.nodesMap.forEach(o=>{var i,r,s;(i={x:(s=o).x-s.width/2,y:s.y-s.height/2,width:s.width,height:s.height}).x<(r=e).x+r.width&&i.yr.x&&i.y+i.height>r.y?t.setNodeSelected(o,!o.selected):n||t.setNodeSelected(o,!1)}),t.edgeVertices.forEach(t=>{l(t,e,!1)?s(t,!t.selected):n||s(t,!1)}),t.selectListener(t.nodes().find(t=>t.selected))},updatePanning:()=>U(t)},e);n.__cursorInteractionCleanup=()=>{i.forEach(({element:t,event:e,handler:n})=>{t.removeEventListener(e,n)}),f&&f()}}function P(t){const e=t.svg.querySelector("g.zoom");if(!e)return 1;const n=(e.getAttribute("transform")||"").match(/scale\(([^)]+)\)/);return n&&parseFloat(n[1])||1}function R(t,e,n,o){const i=t.svg,r=i.querySelector("g.zoom"),s=P(t);if(void 0===n||void 0===o){const t=i.parentElement;t?(n=t.clientWidth/2,o=t.clientHeight/2):(n=i.clientWidth/2,o=i.clientHeight/2)}const a=W(t),d=n-(n-a.x)/s*e,l=o-(o-a.y)/s*e;r.setAttribute("transform",`translate(${d}, ${l}) scale(${e})`),U(t)}function W(t){const e=t.svg.querySelector("g.zoom");if(!e)return{x:0,y:0};const n=(e.getAttribute("transform")||"").match(/translate\(([^,]+),([^)]+)\)/);return n?{x:parseFloat(n[1])||0,y:parseFloat(n[2])||0}:{x:0,y:0}}function U(t){const e=t.svg,n=e.querySelector("g.zoom");if(!n)return;const o=n.getBBox(),i=P(t);if(!e.parentElement)return;const r=Math.max(e.parentElement.clientWidth/i,o.x+o.width+20),s=Math.max(e.parentElement.clientHeight/i,o.y+o.height+20);e.setAttribute("width",String(r*i)),e.setAttribute("height",String(s*i))}const G=(t,e)=>{"Dashed"==e?t.setAttribute("stroke-dasharray","4"):"Dotted"==e&&t.setAttribute("stroke-dasharray","2")},Y=new Map;function O(t){const e=P(t),n=W(t),o={zoom:e,transform:{x:n.x,y:n.y}};Y.set(t.id,o)}function H(t){if(!Y.has(t.id))return!1;const e=Y.get(t.id);if(!e)return!1;const n=t.svg.querySelector("g.zoom");return n&&(n.setAttribute("transform",`scale(${e.zoom}) translate(${e.transform.x}, ${e.transform.y})`),U(t)),!0}function Z(t){Y.delete(t.id)}},983(t,e,n){n.d(e,{k:()=>x,U:()=>w});var o=n(20);const i={direction:"DOWN",nodeSpacing:80,layerSpacing:80};async function r(t,e={}){const o=function(t,e){const n=new Map(t.nodes.map(t=>[t.id,t])),o=new Map(t.groups.map(t=>[t.id,t]));!function(t,e,n){for(const e of t.nodes)if(e.parentId&&!n.has(e.parentId))throw new Error(`node ${e.id} has missing parent group ${e.parentId}`);for(const e of t.groups)if(e.parentId&&!n.has(e.parentId))throw new Error(`group ${e.id} has missing parent group ${e.parentId}`);for(const n of t.edges)if(!e.has(n.sourceId)||!e.has(n.targetId))throw new Error(`edge ${n.id} connects missing node ${n.sourceId} or ${n.targetId}`)}(t,n,o);const i=new Map;for(const e of t.nodes)b(i,e.parentId,e);const r=new Map;for(const e of t.groups)b(r,e.parentId,e);const h=new Map,u=t=>{const n={id:t.id,children:[...(r.get(t.id)??[]).map(u),...(i.get(t.id)??[]).map(s)],edges:[],labels:[{text:t.id,width:t.titleSize.width,height:t.titleSize.height}],layoutOptions:l(e,t.titleSize.height)};return h.set(t.id,n),n},A={id:t.id,children:[...(r.get(void 0)??[]).map(u),...(i.get(void 0)??[]).map(s)],edges:[],layoutOptions:d(e)};for(const e of t.edges){const t=c(e,n,o),i=t?h.get(t):A;if(!i)throw new Error(`edge ${e.id} has missing layout group ${t}`);i.edges?.push(a(e))}return A}(t,{...i,...e}),r=new(await n.e(726).then(n.t.bind(n,862,23)).then(t=>t.default));return function(t,e){if(void 0===e.width||void 0===e.height)throw new Error(`ELK did not size diagram ${t.id}`);const n=[],o=[],i=[];return u(e,0,0,new Map(t.nodes.map(t=>[t.id,t])),new Map(t.groups.map(t=>[t.id,t])),n,o,i),{diagramId:t.id,bounds:{x:0,y:0,width:e.width,height:e.height},nodes:n,groups:o,edges:i}}(t,await r.layout(o))}function s(t){return{id:t.id,width:t.size.width,height:t.size.height,layoutOptions:{"elk.nodeSize.constraints":"FIXED_SIZE","elk.portConstraints":"FREE"}}}function a(t){return{id:t.id,sources:[t.sourceId],targets:[t.targetId],labels:t.labelSize?[{text:t.id,width:t.labelSize.width,height:t.labelSize.height,layoutOptions:{"elk.edgeLabels.inline":"false","elk.edgeLabels.placement":"CENTER"}}]:[]}}function d(t){return{"elk.algorithm":"layered","elk.direction":t.direction,"elk.edgeRouting":"ORTHOGONAL","elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.padding":"[top=40,left=40,bottom=40,right=40]","elk.spacing.nodeNode":String(t.nodeSpacing),"elk.spacing.componentComponent":String(t.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(t.layerSpacing),"elk.layered.spacing.edgeNodeBetweenLayers":"30","elk.layered.spacing.edgeEdgeBetweenLayers":"20","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.nodePlacement.favorStraightEdges":"true","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.unnecessaryBendpoints":"true","elk.edgeLabels.inline":"false","elk.edgeLabels.avoidOverlap":"true","elk.layered.edgeLabels.sideSelection":"SMART_DOWN","elk.spacing.edgeLabel":"12"}}function l(t,e){return{...d(t),"elk.padding":`[top=${e+30},left=30,bottom=30,right=30]`,"elk.nodeLabels.placement":"[H_LEFT,V_TOP,INSIDE]","elk.spacing.labelNode":"10"}}function c(t,e,n){const o=h(e.get(t.sourceId)?.parentId,n),i=new Set(h(e.get(t.targetId)?.parentId,n));return o.find(t=>i.has(t))}function h(t,e){const n=[];let o=t;for(;o;)n.push(o),o=e.get(o)?.parentId;return n}function u(t,e,n,o,i,r,s,a){const d=e+(t.x??0),l=n+(t.y??0);for(const e of t.children??[]){const t=d+f(e.x,e.id,"x"),n=l+f(e.y,e.id,"y"),c=f(e.width,e.id,"width"),h=f(e.height,e.id,"height"),A=o.get(e.id);if(A){r.push({id:e.id,parentId:A.parentId,bounds:{x:t,y:n,width:c,height:h}});continue}const g=i.get(e.id);if(!g)throw new Error(`ELK returned unknown node ${e.id}`);const p=m(e.labels?.[0],e.id);s.push({id:e.id,parentId:g.parentId,bounds:{x:t,y:n,width:c,height:h},titleBounds:{x:t+f(p.x,e.id,"title x"),y:n+f(p.y,e.id,"title y"),width:f(p.width,e.id,"title width"),height:f(p.height,e.id,"title height")}}),u(e,d,l,o,i,r,s,a)}for(const e of t.edges??[])a.push(A(e,d,l))}function A(t,e,n){const o=(t.sections??[]).map(t=>[g(t.startPoint,e,n),...(t.bendPoints??[]).map(t=>g(t,e,n)),g(t.endPoint,e,n)]),i=t.labels?.[0];return{id:t.id,sourceId:p(t.sources,t.id,"source"),targetId:p(t.targets,t.id,"target"),sections:o,labelBounds:i?{x:e+f(i.x,t.id,"label x"),y:n+f(i.y,t.id,"label y"),width:f(i.width,t.id,"label width"),height:f(i.height,t.id,"label height")}:void 0}}function g(t,e,n){return{x:e+t.x,y:n+t.y}}function f(t,e,n){if(void 0===t)throw new Error(`ELK omitted ${n} for ${e}`);return t}function p(t,e,n){if(1!==t.length)throw new Error(`ELK returned ${t.length} ${n}s for edge ${e}`);return t[0]}function m(t,e){if(!t)throw new Error(`ELK omitted title for group ${e}`);return t}function b(t,e,n){const o=t.get(e)??[];o.push(n),t.set(e,o)}n(108);var y=n(977);async function x(t,e={}){await document.fonts.ready;const n=C(t),i=e.compactLayout?56:80,s=await r(n,{direction:e.direction??t.layoutDirection??"DOWN",nodeSpacing:e.nodeSpacing??i,layerSpacing:e.layerSpacing??i}),a=(0,o.r)(n,s),d=new Map(n.nodes.map(t=>[t.id,t]));return{validated:a,nodes:a.nodes.map(t=>{const e=d.get(t.id);if(!e)throw new Error(`validated layout contains unknown node ${t.id}`);return{id:t.id,x:t.bounds.x+e.centerOffset.x,y:t.bounds.y+e.centerOffset.y}}),groups:a.groups.map(t=>({id:t.id,bounds:t.bounds,titleBounds:t.titleBounds})),edges:a.edges.map(t=>({id:t.id,sections:t.sections,labelBounds:t.labelBounds}))}}function w(t){const e=C(t),n=new Map(e.nodes.map(t=>[t.id,t])),i=t.nodes().map(t=>{const e=n.get(t.id);if(!e)throw new Error(`measured diagram omitted node ${t.id}`);return{id:t.id,parentId:e.parentId,bounds:{x:t.x-e.centerOffset.x,y:t.y-e.centerOffset.y,...e.size}}}),r=Array.from(t.groupsMap.values()).map(t=>{if(!t.ref?.isConnected)throw new Error(`group ${t.id} must be drawn before saving`);const n=t.ref.querySelector("rect"),o=t.ref.querySelector("text");if(!(n instanceof SVGGraphicsElement&&o instanceof SVGGraphicsElement))throw new Error(`group ${t.id} is missing its boundary or title`);return{id:t.id,parentId:e.groups.find(e=>e.id===t.id)?.parentId,bounds:k(n.getBBox()),titleBounds:k(o.getBBox())}}),s=t.edges.map(t=>{const e=t.layoutSections??[(0,y.l)(t)],n=t.layoutLabelBounds??t.labelBounds;if(t.label.trim().length>0&&!n)throw new Error(`edge ${t.id} is missing its label position`);return{id:t.id,sourceId:t.from.id,targetId:t.to.id,sections:e,labelBounds:n?{...n}:void 0}}),a={diagramId:t.id,bounds:I(i.map(t=>t.bounds),r,s),nodes:i,groups:r,edges:s};return function(t,e){return(0,o.r)(t,e)}(e,a)}function C(t){const{nodeParents:e,groupParents:n}=function(t){const e=new Map,n=new Map;for(const o of t.groupsMap.values())for(const t of o.nodes){const i=E(t)?n:e,r=i.get(t.id);if(r&&r!==o.id)throw new Error(`${E(t)?"group":"node"} ${t.id} belongs to both ${r} and ${o.id}`);i.set(t.id,o.id)}return{nodeParents:e,groupParents:n}}(t);return{id:t.id,nodes:t.nodes().map(t=>function(t,e){if(!t.ref?.isConnected)throw new Error(`node ${t.id} must be drawn before layout`);const n=t.ref.getBBox();return v(t.id,n),{id:t.id,parentId:e,size:{width:n.width,height:n.height},contentSize:{width:n.width,height:n.height},centerOffset:{x:-n.x,y:-n.y},shape:t.style.shape??"Box"}}(t,e.get(t.id))),groups:Array.from(t.groupsMap.values()).map(t=>function(t,e){if(!t.ref?.isConnected)throw new Error(`group ${t.id} must be drawn before layout`);const n=t.ref.querySelector("text");if(!(n instanceof SVGGraphicsElement))throw new Error(`group ${t.id} is missing its drawn title`);const o=n.getBBox();return v(t.id,o),{id:t.id,parentId:e,titleSize:{width:o.width,height:o.height}}}(t,n.get(t.id))),edges:t.edges.map(B)}}function B(t){const e=t.label.trim().length>0;if(e&&!t.labelBounds)throw new Error(`edge ${t.id} must be drawn before layout`);return{id:t.id,sourceId:t.from.id,targetId:t.to.id,labelSize:e?{width:t.labelBounds?.width??0,height:t.labelBounds?.height??0}:void 0}}function v(t,e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0)throw new Error(`browser returned invalid measured box for ${t}`)}function I(t,e,n){const o=[...t,...e.flatMap(t=>[t.bounds,t.titleBounds]),...n.flatMap(t=>t.labelBounds?[t.labelBounds]:[])],i=n.flatMap(t=>t.sections.flat());if(0===o.length&&0===i.length)return{x:0,y:0,width:0,height:0};const r=Math.min(...o.map(t=>t.x),...i.map(t=>t.x)),s=Math.min(...o.map(t=>t.y),...i.map(t=>t.y));return{x:r,y:s,width:Math.max(...o.map(t=>t.x+t.width),...i.map(t=>t.x))-r,height:Math.max(...o.map(t=>t.y+t.height),...i.map(t=>t.y))-s}}function k(t){return{x:t.x,y:t.y,width:t.width,height:t.height}}function E(t){return"nodes"in t}},718(t,e,n){n.d(e,{Mt:()=>r,U2:()=>a});const o=new Map;let i;async function r(){await Promise.all([400,600,700].map(t=>document.fonts.load(`${t} 22px Inter`))),await document.fonts.ready}function s(t,e){const n=function(t,e){const n=Object.entries(e).sort(([t],[e])=>t.localeCompare(e));return JSON.stringify([t,n])}(t,e),r=o.get(n);if(r)return r;const s=document.createElementNS("http://www.w3.org/2000/svg","text");s.setAttribute("x","0"),s.setAttribute("y","0");for(const[t,n]of Object.entries(e))s.setAttribute(t,n);s.textContent=t,(i?.isConnected||(i=document.createElementNS("http://www.w3.org/2000/svg","svg"),i.setAttribute("aria-hidden","true"),i.style.position="absolute",i.style.visibility="hidden",i.style.pointerEvents="none",document.body.appendChild(i)),i).appendChild(s);const a=s.getBBox();s.remove();const d={width:a.width,height:a.height};return o.set(n,d),d}function a(t,e,n){let o=0;return{lines:t.trim().split("\n").flatMap(t=>{const i=[];let r=[];for(const a of t.trim().split(/\s+/)){if(s(a,n).width>e){r.length>0&&(i.push(r.join(" ")),r=[]);const t=d(a,e,n);for(const e of t.slice(0,-1))i.push(e),o=Math.max(o,s(e,n).width);r=t.slice(-1);continue}const t=[...r,a],l=s(t.join(" "),n);l.width>e&&r.length>0?(i.push(r.join(" ")),r=[a]):(o=Math.max(o,l.width),r=t)}if(r.length>0){const t=r.join(" ");i.push(t),o=Math.max(o,s(t,n).width)}return i}),maxW:o}}function d(t,e,n){const o=[];let i="";for(const r of t){const t=i+r;s(t,n).width>e&&i.length>0?(o.push(i),i=r):i=t}return i.length>0&&o.push(i),o}},71(t,e,n){var o=n(108);const i={TopBottom:"DOWN",BottomTop:"UP",LeftRight:"RIGHT",RightLeft:"LEFT"};n.d(e,["B",0,t=>{const e=[];return Object.keys(t.views).filter(t=>t.endsWith("Views")).forEach(n=>{t.views[n].forEach(t=>{e.push({key:t.key,title:t.title||t.key,section:n})})}),e},"R",0,(t,e,n)=>{const r=new Map,s=new Map,a=t=>{Array.isArray(t.relationships)&&t.relationships.forEach(t=>{s.set(t.id,t)})};if(t.model.people&&t.model.people.forEach(t=>{r.set(t.id,t),Array.isArray(t.relationships)&&t.relationships.forEach(t=>{s.set(t.id,t)})}),t.model.softwareSystems&&t.model.softwareSystems.forEach(t=>{r.set(t.id,t),a(t),Array.isArray(t.containers)&&t.containers.forEach(e=>{e.parent=t,r.set(e.id,e),a(e),Array.isArray(e.components)&&e.components.forEach(t=>{t.parent=e,r.set(t.id,t),a(t)})})}),t.model.deploymentNodes){const e=t=>{t.containerInstances&&t.containerInstances.forEach(e=>{const n={...r.get(e.containerId),id:e.id};r.set(n.id,n),n.parent=t,a(e)})},n=(t,o)=>{t.parent=o,r.set(t.id,t),a(t),e(t),t.children&&t.children.forEach(e=>n(e,t)),t.infrastructureNodes&&t.infrastructureNodes.forEach(e=>n(e,t))};t.model.deploymentNodes.forEach(t=>n(t,null))}const{view:d,section:l}=function(t,e){let n=null,o="";return Object.keys(t.views).filter(t=>t.endsWith("Views")).some(i=>t.views[i].some(t=>{if(t.key==e)return n=t,o=i,!0})),{view:n,section:o}}(t,n);if(!d)return null;const c=new o.jg(d.key,d.title||d.key),h=d.automaticLayout?.rankDirection;c.layoutDirection=h?i[h]:void 0;const u={name:c.name,description:d.description,version:t.version,elements:[]};if(c.metadata=u,!d.elements)return c;const A={};if("deploymentViews"==l||"containerViews"==l)d.elements.forEach(t=>{const e=r.get(t.id);e?.parent&&(A[e.parent.id]=!0)});else if("componentViews"===l)d.elements.forEach(t=>{const e=r.get(t.id)?.parent;e?.components&&(e.id===d.containerId||d.externalContainersBoundariesVisible)&&(d.elements.some(t=>t.id===e.id)||(A[e.id]=!0))});else if(d.softwareSystemId)d.elements.find(t=>t.id==d.softwareSystemId)||(A[d.softwareSystemId]=!0);else if("systemLandscapeViews"==l){const e={id:"__enterprise__",...t.model.enterprise};r.set(e.id,e),t.model.people&&t.model.people.filter(t=>"External"!=t.location).forEach(t=>t.parent=e),t.model.softwareSystems&&t.model.softwareSystems.filter(t=>"External"!=t.location).forEach(t=>t.parent=e),A[e.id]=!0}const g=t.views.styles,f=t=>t.toLowerCase().replace(/[^a-z0-9-]/g,"-");g?.elements&&g.elements.forEach(t=>{if(t.tag){const e=`--mdl-${f(t.tag)}`;t.background&&c.colorToVarMap.set(t.background,`${e}-bg`),t.color&&c.colorToVarMap.set(t.color,`${e}-color`),t.stroke&&c.colorToVarMap.set(t.stroke,`${e}-stroke`)}}),g?.relationships&&g.relationships.forEach(t=>{if(t.tag){const e=`--mdl-rel-${f(t.tag)}`;t.color&&c.colorToVarMap.set(t.color,`${e}-color`)}}),d.elements.forEach(e=>{if(A[e.id])return;const n=r.get(e.id),o=n?function(t,e){const n=t.views.containerViews?.find(t=>t.softwareSystemId==e);return n?.key}(t,n.id):void 0;let i="",s={};if(n){const t=n.tags.split(",");i=t[t.length-1],n.technology&&(i+=": "+n.technology),t.forEach(t=>{const e=g&&g.elements&&g.elements.find(e=>e.tag==t);e&&(s={...s,...e})})}c.addNode(e.id,n&&n.name||e.id,i,n&&n.description?n.description:"",s,function(t,e){if(e){const t=encodeURIComponent(e);return{href:`?id=${t}`,exportHref:`${t}.svg`}}if(t?.url)return{href:t.url,exportHref:t.url}}(n,o)),n&&u.elements.push({id:n.id,tags:n.tags,location:n.location,properties:n.properties,elementViewKey:o,technology:n.technology,url:n.url})}),Array.isArray(d.relationships)&&d.relationships.forEach(t=>{const e=s.get(t.id);if(!e)return;if(!c.nodesMap.has(e.sourceId)){if(r.has(e.sourceId)){const t=r.get(e.sourceId);console.warn("Element not found in this view: ",t.id,t.name)}else console.warn("Element not found: ",e.sourceId);return}if(!c.nodesMap.has(e.destinationId)){if(r.has(e.destinationId)){const t=r.get(e.destinationId);console.warn("Element not found in this view: ",t.id,t.name)}else console.warn("Element not found: ",e.destinationId);return}let n={};e.tags.split(",").forEach(t=>{const e=g&&g.relationships&&g.relationships.find(e=>e.tag==t);e&&(n={...n,...e})}),t.routing&&(n.routing=t.routing);const o=e.technology?`${e.description}\n[${e.technology}]`:e.description;c.addEdge(e.id,e.sourceId,e.destinationId,o,t.vertices,n)});const p=t=>{let e=0;for(let n=t.parent;n;n=n.parent)e++;return e};return Object.keys(A).map(t=>r.get(t)).sort((t,e)=>p(t)>p(e)?-1:1).forEach(t=>{let e={};"deploymentViews"==l&&r.get(t.id).tags.split(",").forEach(t=>{const n=g&&g.elements&&g.elements.find(e=>e.tag==t);n&&(e={...e,...n})});const n=d.elements.map(t=>r.get(t.id)).filter(e=>!(!e||e.parent!==t||"systemLandscapeViews"===l&&"__enterprise__"===t.id&&"External"===e.location)).map(t=>t.id);n.length>0&&c.addGroup(t.id,t.name,n,e)}),c.init(e[c.id]),c}])},264(t,e,n){n(763);var o=n(686),i=n(987);const r="add-vertex",s="add-label-vertex",a="del-vertex",d="zoom-in",l="zoom-out",c="zoom-fit",h="zoom-100",u="select-all",A="deselect",g="move-left",f="move-right",p="move-up",m="move-down",b="move-left-fine",y="move-right-fine",x="move-up-fine",w="move-down-fine",C="toggle_drag_mode",B="align_horizontal",v="align_vertical",I="distribute_horizontal",k="distribute_vertical",E="auto_layout",S="reset_position",$="toggle_grid",M="toggle_snap_to_grid",L="snap_all_to_grid",_=[{name:"Help",list:[{id:"help",help:"Show/hide this help",combinations:[{key:"?",shift:!0},{key:"F1",shift:!0}]}]},{name:"File",list:[{id:"save",help:"Save",combinations:[{key:"s",ctrl:!0}]}]},{name:"History",list:[{id:"undo",help:"Undo",combinations:[{ctrl:!0,key:"z"}]},{id:"redo",help:"Redo",combinations:[{ctrl:!0,shift:!0,key:"z"},{ctrl:!0,key:"y"}]}]},{name:"Relationship editing",list:[{id:r,help:"Add relationship vertex",combinations:[{alt:!0,click:!0}]},{id:s,help:"Add label anchor relationship vertex",combinations:[{alt:!0,shift:!0,click:!0}]},{id:a,help:"Remove relationship vertex",combinations:[{key:"DELETE"},{key:"BACKSPACE"}]}]},{name:"Zoom",list:[{id:d,help:"Zoom in",combinations:[{ctrl:!0,key:"="}]},{id:l,help:"Zoom out",combinations:[{ctrl:!0,key:"-"}]},{id:c,help:"Zoom - fit",combinations:[{ctrl:!0,key:"9"}]},{id:h,help:"Zoom 100%",combinations:[{ctrl:!0,key:"0"}]},{id:"wheel_zoom",help:"Zoom in/out with mouse wheel",combinations:[{wheel:!0}]}]},{name:"Mouse Interactions",list:[{id:"pan-view",help:"Pan view (drag empty space)",combinations:[{click:!0}]},{id:"select-element",help:"Select element",combinations:[{click:!0}]},{id:"multi-select",help:"Add/remove from selection",combinations:[{shift:!0,click:!0}]},{id:"box-select",help:"Box selection (drag empty space)",combinations:[{shift:!0,click:!0}]},{id:"move-elements",help:"Move selected elements",combinations:[{click:!0}]}]},{name:"Select",list:[{id:u,help:"Select All",combinations:[{ctrl:!0,key:"a"}]},{id:A,help:"Deselect",combinations:[{key:"ESC"}]}]},{name:"Move",list:[{id:p,help:"Move up (grid increment)",combinations:[{key:"UP"}]},{id:x,help:"Move up (1 pixel)",combinations:[{key:"UP",shift:!0}]},{id:f,help:"Move right (grid increment)",combinations:[{key:"RIGHT"}]},{id:y,help:"Move right (1 pixel)",combinations:[{key:"RIGHT",shift:!0}]},{id:m,help:"Move down (grid increment)",combinations:[{key:"DOWN"}]},{id:w,help:"Move down (1 pixel)",combinations:[{key:"DOWN",shift:!0}]},{id:g,help:"Move left (grid increment)",combinations:[{key:"LEFT"}]},{id:b,help:"Move left (1 pixel)",combinations:[{key:"LEFT",shift:!0}]}]},{name:"View",list:[{id:C,help:"Toggle between pan and select mode",combinations:[{key:"t"}]},{id:S,help:"Reset position and view",combinations:[{key:"Home",ctrl:!0}]}]},{name:"Alignment",list:[{id:B,help:"Align selected elements horizontally",combinations:[{key:"h",ctrl:!0,shift:!0}]},{id:v,help:"Align selected elements vertically",combinations:[{key:"a",ctrl:!0,shift:!0}]},{id:I,help:"Distribute selected elements horizontally",combinations:[{key:"h",ctrl:!0,alt:!0}]},{id:k,help:"Distribute selected elements vertically",combinations:[{key:"v",ctrl:!0,alt:!0}]}]},{name:"Layout",list:[{id:E,help:"Auto layout all elements",combinations:[{key:"l",ctrl:!0}]}]},{name:"Grid",list:[{id:$,help:"Toggle grid visibility",combinations:[{key:"g",ctrl:!0}]},{id:M,help:"Toggle snap to grid",combinations:[{key:"g",ctrl:!0,shift:!0}]},{id:L,help:"Snap all elements to grid",combinations:[{key:"g",ctrl:!0,alt:!0}]}]}],D=_.reduce((t,e)=>t.concat(e.list),[]).reduce((t,e)=>(t[e.id]=e,t),{}),z=t=>[t.ctrl&&(0,o.sy)().toUpperCase(),t.shift&&"SHIFT",t.alt&&"ALT",t.key&&(t.key.length>1?t.key:`"${t.key.toUpperCase()}"`),t.click&&"CLICK",t.wheel&&"WHEEL"].filter(Boolean).join(" + ");n.d(e,["DE",0,I,"F",0,u,"Gg",0,g,"Gn",0,A,"Hd",0,E,"Help",0,()=>(0,i.jsxs)("div",{className:"popover",children:[(0,i.jsx)("h1",{children:"Shortcuts"}),(0,i.jsx)("table",{children:(0,i.jsx)("tbody",{children:_.map(t=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("tr",{children:(0,i.jsx)("th",{colSpan:2,children:t.name})}),t.list.map(t=>(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{children:t.combinations.map(z).join(", ")}),(0,i.jsx)("td",{children:t.help})]}))]}))})})]}),"J8",0,b,"Jk",0,v,"OE",0,L,"Op",0,$,"Ur",0,d,"Vy",0,k,"Yp",0,(t,e=!1,n=!1)=>{const i=Object.keys(D).filter(i=>((t,e,n,i)=>e.combinations.some(e=>{if(Boolean(e.shift)!=t.shiftKey)return!1;if(e.ctrl&&!(0,o.SA)(t))return!1;if(Boolean(e.alt)!=t.altKey)return!1;if(n)return e.click;if(i)return e.wheel;if(e.key){const n=t;return"DELETE"==e.key?"Delete"==n.key:"BACKSPACE"==e.key?"Backspace"==n.key:"ESC"==e.key?"Escape"==n.key:"UP"==e.key?"ArrowUp"==n.key:"DOWN"==e.key?"ArrowDown"==n.key:"LEFT"==e.key?"ArrowLeft"==n.key:"RIGHT"==e.key?"ArrowRight"==n.key:e.key&&n.key&&e.key.toLowerCase()==n.key.toLowerCase()}return!1}))(t,D[i],e,n));if(0!==i.length)return 1===i.length?i[0]:i.sort((t,e)=>{const n=D[t],o=D[e],i=n.combinations[0],r=o.combinations[0],s=(i.shift?1:0)+(i.ctrl?1:0)+(i.alt?1:0);return(r.shift?1:0)+(r.ctrl?1:0)+(r.alt?1:0)-s})[0]},"Zj",0,r,"_s",0,s,"_t",0,S,"aX",0,C,"b3",0,f,"bl",0,a,"hU",0,l,"hZ",0,M,"i1",0,h,"iD",0,y,"l8",0,x,"mD",0,c,"mt",0,w,"rB",0,m,"t9",0,B,"uK",0,p])},686(t,e,n){const o=()=>{if("undefined"==typeof navigator)return!1;if("userAgentData"in navigator&&navigator.userAgentData){const t=navigator.userAgentData.platform;if(t&&t.toLowerCase().includes("mac"))return!0}const t=navigator.userAgent.toLowerCase();if(t.includes("mac os")||t.includes("macintosh"))return!0;if(navigator.platform){const t=navigator.platform.toLowerCase();if(t.includes("mac")||t.includes("darwin"))return!0}try{if(void 0!==new KeyboardEvent("keydown",{metaKey:!0}).metaKey)return/mac|darwin|os x/i.test(navigator.userAgent)}catch(t){}return!1};n.d(e,["SA",0,t=>o()?t.metaKey:t.ctrlKey,"sy",0,()=>o()?"Cmd":"Ctrl"])},183(t,e,n){var o=n(220),i=n.n(o),r=n(716),s=n.n(r),a=n(247),d=n.n(a),l=new URL(n(390),n.b),c=new URL(n(513),n.b),h=new URL(n(568),n.b),u=new URL(n(483),n.b),A=s()(i()),g=d()(l),f=d()(c),p=d()(h),m=d()(u);A.push([t.id,`/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${g}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${f}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${p}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${m}) format("woff2");\n}\n`,"",{version:3,sources:["webpack://./src/fonts.css"],names:[],mappings:"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF",sourcesContent:['/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url("@fontsource/inter/files/inter-latin-400-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url("@fontsource/inter/files/inter-latin-500-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url("@fontsource/inter/files/inter-latin-600-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url("@fontsource/inter/files/inter-latin-700-normal.woff2") format("woff2");\n}\n'],sourceRoot:""}]);const b=A;n.d(e,["A",0,b])},870(t,e,n){var o=n(220),i=n.n(o),r=n(716),s=n.n(r)()(i());s.push([t.id,"html, body, #root {\n height: 100%;\n}\n\nbody {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n color: #666;\n margin: 0;\n}\n\n#root {\n display: flex;\n flex-direction: column;\n}\n#root > div.graph {\n flex: 1;\n overflow: auto;\n position: relative;\n}\n\n.toolbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 10px;\n background-color: #f0f0f0;\n border-bottom: 1px solid #cccccc;\n}\n\n.toolbar > div {\n display: flex;\n align-items: center;\n}\n\n.toolbar button {\n padding: 5px 8px;\n margin: 0 2px;\n cursor: pointer;\n}\n\n.toolbar button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Drag mode toggle button styles */\n.toolbar button.mode-toggle {\n position: relative;\n border: 1px solid #8f9fc9;\n width: 40px;\n min-height: 28px;\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\n border-color: #8f9fc9;\n color: white;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n}\n\n.toolbar button.mode-toggle:hover {\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\n border-color: #abb8db;\n}\n\n.toolbar button.mode-toggle.select-mode:active {\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\n}\n\n/* Pan mode and active toggle - darker blue */\n.toolbar button.mode-toggle.pan-mode,\n.toolbar button.active-toggle {\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n.toolbar button.mode-toggle.pan-mode:hover,\n.toolbar button.active-toggle:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\n.toolbar button.mode-toggle.pan-mode:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n/* Toggle buttons when inactive - gray styling */\n.toolbar button.inactive-toggle {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n.toolbar button.inactive-toggle:hover {\n background: #b1b1b1;\n}\n\n.toolbar button.inactive-toggle:active {\n background: #a1a1a1;\n}\n\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\n.toolbar button .fas {\n font-size: 1em;\n vertical-align: middle;\n}\n\n/* Zoom percentage display */\n.toolbar button.zoom-display {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n font-size: 11px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\n padding: 6px 8px;\n text-align: center;\n}\n\n.toolbar-group {\n display: flex;\n align-items: center;\n margin-right: 25px; /* Large space between groups */\n}\n\n.toolbar-group:last-child {\n margin-right: 0; /* Remove right margin from the last group (help button) */\n}\n\nbutton {\n border: none;\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n border-radius: 3px;\n padding: 6px 10px;\n color: #fff;\n outline: none;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n margin-right: 5px;\n min-width: 32px;\n min-height: 28px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n line-height: 1;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n position: relative;\n}\n\nbutton:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\nbutton:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n}\n\nbutton:last-child {\n margin-right: 0;\n}\n\n/* Save button when no changes - gray */\nbutton.action {\n background: #c1c1c1;\n color: #999;\n}\n\nbutton.action:active {\n background: #b1b1b1;\n}\n\n/* Save button when there are changes - orange */\nbutton.grp {\n background: linear-gradient(to bottom, #ee9564, #de7d48);\n margin-right: 0;\n}\n\nbutton.grp:active {\n background: #d67540;\n}\n\n/* Auto-arrange button with AI purple to blue gradient */\nbutton.auto-arrange {\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\n border-color: #4a4c93;\n}\n\nbutton.auto-arrange:hover {\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\n border-color: #5a5ca3;\n}\n\nbutton.auto-arrange:active {\n background: linear-gradient(135deg, #593B83, #357abd);\n border-color: #3a3c83;\n}\n\nselect {\n border: 1px solid #ccc;\n background: white;\n border-radius: 3px;\n padding: 3px 7px;\n color: #666;\n outline: none;\n margin-right: 5px;\n font-size: 12px;\n}\n\nselect:disabled {\n background: #f5f5f5;\n color: #999;\n}\n\nbutton:disabled {\n background: #c1c1c1;\n color: #999;\n}\n\n#root > div > svg {\n position: absolute;\n user-select: none;\n}\n\n\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\n stroke: #29c229;\n}\n.edge .v-dot {\n fill: transparent;\n stroke: transparent;\n stroke-width: 3px;\n cursor: pointer;\n transition: stroke 0.15s ease;\n}\n.edge .v-dot:hover {\n stroke: #999;\n fill: rgba(153, 153, 153, 0.1);\n}\n.edge .v-dot.selected {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.1);\n}\n.edge .v-dot.selected:hover {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.2);\n}\n.edge .v-dot.auto.selected {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.1);\n}\n.edge .v-dot.auto.selected:hover {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.2);\n}\ncircle#prj {\n fill: none;\n stroke: #777;\n}\n\n.nodeShadow {\n fill: none;\n stroke-width: 4px;\n stroke: rgba(0, 0, 0, 0.13);\n}\n\ng.node {\n user-select: none;\n cursor: default;\n}\n\ng.node.linked {\n cursor: pointer;\n}\n\ng.node text {\n pointer-events: none;\n}\n\n.icon {\n fill: #aaa;\n stroke: #fff;\n}\n#icon-cube {\n fill: #aaa;\n}\n\n/* Ensure all button icons are uncolored */\nbutton .icon,\nbutton svg,\nbutton path {\n fill: currentColor !important;\n stroke: none !important;\n}\n\n/* Font Awesome icon styling in buttons */\nbutton i {\n font-size: 12px;\n color: inherit;\n}\n\nrect.elastic {\n pointer-events: none;\n stroke: none;\n fill: #3bd8281f;\n display: none;\n}\nrect.elastic.on {\n display: block;\n}\n\n.popover {\n position: absolute;\n top: 50px;\n bottom: 10px;\n overflow: auto;\n right: 10px;\n background: ghostwhite;\n padding: 30px;\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\n border: solid 1px #eee;\n}\n\n.popover th {\n text-align: left;\n padding: 20px 0px 10px;\n}\n.popover td {\n padding-right: 20px;\n font-size: 14px;\n}\n\n/* Simple tooltip system with smart positioning */\n[data-tooltip] {\n position: relative;\n}\n\n[data-tooltip]:hover::after {\n content: attr(data-tooltip);\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(0, 0, 0, 0.9);\n color: white;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 12px !important;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n font-weight: normal !important;\n white-space: nowrap;\n z-index: 1000;\n pointer-events: none;\n margin-top: 5px;\n animation: tooltip-appear 0.1s ease-out;\n min-width: 120px;\n max-width: calc(100vw - 20px);\n box-sizing: border-box;\n}\n\n[data-tooltip]:hover::before {\n content: '';\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-bottom-color: rgba(0, 0, 0, 0.9);\n z-index: 1000;\n pointer-events: none;\n margin-top: 1px;\n animation: tooltip-appear 0.1s ease-out;\n}\n\n/* Special handling for rightmost elements that might overflow */\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 0;\n transform: none;\n}\n\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 16px;\n transform: none;\n}\n\n@keyframes tooltip-appear {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(-5px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\nselect {\n position: relative;\n}\n\n/* Robot shape internal elements - inherit stroke from parent node */\n.node .robot-eye-socket {\n fill: none;\n stroke: inherit;\n stroke-width: 2;\n}\n\n.node .robot-eye {\n fill: currentColor;\n stroke: none;\n}\n\n.node .robot-mouth {\n stroke: inherit;\n}\n\n.node .robot-antenna {\n stroke: inherit;\n}\n\n.node .robot-antenna-ball {\n fill: currentColor;\n stroke: inherit;\n stroke-width: 1.5;\n}\n\n.node .robot-panel {\n stroke: inherit;\n}\n\n.node .robot-indicator {\n fill: currentColor;\n stroke: none;\n}","",{version:3,sources:["webpack://./src/style.css"],names:[],mappings:"AAAA;IACI,YAAY;AAChB;;AAEA;IACI,uFAAuF;IACvF,WAAW;IACX,SAAS;AACb;;AAEA;IACI,aAAa;IACb,sBAAsB;AAC1B;AACA;IACI,OAAO;IACP,cAAc;IACd,kBAAkB;AACtB;;AAEA;IACI,aAAa;IACb,8BAA8B;IAC9B,mBAAmB;IACnB,iBAAiB;IACjB,yBAAyB;IACzB,gCAAgC;AACpC;;AAEA;IACI,aAAa;IACb,mBAAmB;AACvB;;AAEA;IACI,gBAAgB;IAChB,aAAa;IACb,eAAe;AACnB;;AAEA;IACI,YAAY;IACZ,mBAAmB;AACvB;;AAEA,mCAAmC;AACnC;IACI,kBAAkB;IAClB,yBAAyB;IACzB,WAAW;IACX,gBAAgB;IAChB,wDAAwD;IACxD,qBAAqB;IACrB,YAAY;IACZ,yCAAyC;AAC7C;;AAEA;IACI,wDAAwD;IACxD,qBAAqB;AACzB;;AAEA;IACI,wDAAwD;AAC5D;;AAEA,6CAA6C;AAC7C;;IAEI,wDAAwD;IACxD,qBAAqB;IACrB,2CAA2C;AAC/C;;AAEA;;IAEI,wDAAwD;AAC5D;;AAEA;IACI,wDAAwD;IACxD,2CAA2C;AAC/C;;AAEA,gDAAgD;AAChD;IACI,mBAAmB;IACnB,WAAW;IACX,qBAAqB;IACrB,gBAAgB;AACpB;;AAEA;IACI,mBAAmB;AACvB;;AAEA;IACI,mBAAmB;AACvB;;AAEA,mFAAmF;AACnF;;IAEI,mBAAmB;IACnB,WAAW;IACX,qBAAqB;IACrB,gBAAgB;AACpB;;AAEA,6EAA6E;AAC7E;IACI,cAAc;IACd,sBAAsB;AAC1B;;AAEA,4BAA4B;AAC5B;IACI,mEAAmE;IACnE,eAAe;IACf,gBA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AChE;IACI,2DAA2D;IAC3D,UAAU;IACV,QAAQ;IACR,eAAe;AACnB;;AAEA;IACI,2DAA2D;IAC3D,UAAU;IACV,WAAW;IACX,eAAe;AACnB;;AAEA;IACI;QACI,UAAU;QACV,4CAA4C;IAChD;IACA;QACI,UAAU;QACV,yCAAyC;IAC7C;AACJ;;AAEA;IACI,kBAAkB;AACtB;;AAEA,oEAAoE;AACpE;IACI,UAAU;IACV,eAAe;IACf,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,YAAY;AAChB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,eAAe;IACf,iBAAiB;AACrB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,YAAY;AAChB",sourcesContent:["html, body, #root {\n height: 100%;\n}\n\nbody {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n color: #666;\n margin: 0;\n}\n\n#root {\n display: flex;\n flex-direction: column;\n}\n#root > div.graph {\n flex: 1;\n overflow: auto;\n position: relative;\n}\n\n.toolbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 10px;\n background-color: #f0f0f0;\n border-bottom: 1px solid #cccccc;\n}\n\n.toolbar > div {\n display: flex;\n align-items: center;\n}\n\n.toolbar button {\n padding: 5px 8px;\n margin: 0 2px;\n cursor: pointer;\n}\n\n.toolbar button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Drag mode toggle button styles */\n.toolbar button.mode-toggle {\n position: relative;\n border: 1px solid #8f9fc9;\n width: 40px;\n min-height: 28px;\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\n border-color: #8f9fc9;\n color: white;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n}\n\n.toolbar button.mode-toggle:hover {\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\n border-color: #abb8db;\n}\n\n.toolbar button.mode-toggle.select-mode:active {\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\n}\n\n/* Pan mode and active toggle - darker blue */\n.toolbar button.mode-toggle.pan-mode,\n.toolbar button.active-toggle {\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n.toolbar button.mode-toggle.pan-mode:hover,\n.toolbar button.active-toggle:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\n.toolbar button.mode-toggle.pan-mode:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n/* Toggle buttons when inactive - gray styling */\n.toolbar button.inactive-toggle {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n.toolbar button.inactive-toggle:hover {\n background: #b1b1b1;\n}\n\n.toolbar button.inactive-toggle:active {\n background: #a1a1a1;\n}\n\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\n.toolbar button .fas {\n font-size: 1em;\n vertical-align: middle;\n}\n\n/* Zoom percentage display */\n.toolbar button.zoom-display {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n font-size: 11px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\n padding: 6px 8px;\n text-align: center;\n}\n\n.toolbar-group {\n display: flex;\n align-items: center;\n margin-right: 25px; /* Large space between groups */\n}\n\n.toolbar-group:last-child {\n margin-right: 0; /* Remove right margin from the last group (help button) */\n}\n\nbutton {\n border: none;\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n border-radius: 3px;\n padding: 6px 10px;\n color: #fff;\n outline: none;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n margin-right: 5px;\n min-width: 32px;\n min-height: 28px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n line-height: 1;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n position: relative;\n}\n\nbutton:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\nbutton:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n}\n\nbutton:last-child {\n margin-right: 0;\n}\n\n/* Save button when no changes - gray */\nbutton.action {\n background: #c1c1c1;\n color: #999;\n}\n\nbutton.action:active {\n background: #b1b1b1;\n}\n\n/* Save button when there are changes - orange */\nbutton.grp {\n background: linear-gradient(to bottom, #ee9564, #de7d48);\n margin-right: 0;\n}\n\nbutton.grp:active {\n background: #d67540;\n}\n\n/* Auto-arrange button with AI purple to blue gradient */\nbutton.auto-arrange {\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\n border-color: #4a4c93;\n}\n\nbutton.auto-arrange:hover {\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\n border-color: #5a5ca3;\n}\n\nbutton.auto-arrange:active {\n background: linear-gradient(135deg, #593B83, #357abd);\n border-color: #3a3c83;\n}\n\nselect {\n border: 1px solid #ccc;\n background: white;\n border-radius: 3px;\n padding: 3px 7px;\n color: #666;\n outline: none;\n margin-right: 5px;\n font-size: 12px;\n}\n\nselect:disabled {\n background: #f5f5f5;\n color: #999;\n}\n\nbutton:disabled {\n background: #c1c1c1;\n color: #999;\n}\n\n#root > div > svg {\n position: absolute;\n user-select: none;\n}\n\n\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\n stroke: #29c229;\n}\n.edge .v-dot {\n fill: transparent;\n stroke: transparent;\n stroke-width: 3px;\n cursor: pointer;\n transition: stroke 0.15s ease;\n}\n.edge .v-dot:hover {\n stroke: #999;\n fill: rgba(153, 153, 153, 0.1);\n}\n.edge .v-dot.selected {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.1);\n}\n.edge .v-dot.selected:hover {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.2);\n}\n.edge .v-dot.auto.selected {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.1);\n}\n.edge .v-dot.auto.selected:hover {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.2);\n}\ncircle#prj {\n fill: none;\n stroke: #777;\n}\n\n.nodeShadow {\n fill: none;\n stroke-width: 4px;\n stroke: rgba(0, 0, 0, 0.13);\n}\n\ng.node {\n user-select: none;\n cursor: default;\n}\n\ng.node.linked {\n cursor: pointer;\n}\n\ng.node text {\n pointer-events: none;\n}\n\n.icon {\n fill: #aaa;\n stroke: #fff;\n}\n#icon-cube {\n fill: #aaa;\n}\n\n/* Ensure all button icons are uncolored */\nbutton .icon,\nbutton svg,\nbutton path {\n fill: currentColor !important;\n stroke: none !important;\n}\n\n/* Font Awesome icon styling in buttons */\nbutton i {\n font-size: 12px;\n color: inherit;\n}\n\nrect.elastic {\n pointer-events: none;\n stroke: none;\n fill: #3bd8281f;\n display: none;\n}\nrect.elastic.on {\n display: block;\n}\n\n.popover {\n position: absolute;\n top: 50px;\n bottom: 10px;\n overflow: auto;\n right: 10px;\n background: ghostwhite;\n padding: 30px;\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\n border: solid 1px #eee;\n}\n\n.popover th {\n text-align: left;\n padding: 20px 0px 10px;\n}\n.popover td {\n padding-right: 20px;\n font-size: 14px;\n}\n\n/* Simple tooltip system with smart positioning */\n[data-tooltip] {\n position: relative;\n}\n\n[data-tooltip]:hover::after {\n content: attr(data-tooltip);\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(0, 0, 0, 0.9);\n color: white;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 12px !important;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n font-weight: normal !important;\n white-space: nowrap;\n z-index: 1000;\n pointer-events: none;\n margin-top: 5px;\n animation: tooltip-appear 0.1s ease-out;\n min-width: 120px;\n max-width: calc(100vw - 20px);\n box-sizing: border-box;\n}\n\n[data-tooltip]:hover::before {\n content: '';\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-bottom-color: rgba(0, 0, 0, 0.9);\n z-index: 1000;\n pointer-events: none;\n margin-top: 1px;\n animation: tooltip-appear 0.1s ease-out;\n}\n\n/* Special handling for rightmost elements that might overflow */\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 0;\n transform: none;\n}\n\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 16px;\n transform: none;\n}\n\n@keyframes tooltip-appear {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(-5px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\nselect {\n position: relative;\n}\n\n/* Robot shape internal elements - inherit stroke from parent node */\n.node .robot-eye-socket {\n fill: none;\n stroke: inherit;\n stroke-width: 2;\n}\n\n.node .robot-eye {\n fill: currentColor;\n stroke: none;\n}\n\n.node .robot-mouth {\n stroke: inherit;\n}\n\n.node .robot-antenna {\n stroke: inherit;\n}\n\n.node .robot-antenna-ball {\n fill: currentColor;\n stroke: inherit;\n stroke-width: 1.5;\n}\n\n.node .robot-panel {\n stroke: inherit;\n}\n\n.node .robot-indicator {\n fill: currentColor;\n stroke: none;\n}"],sourceRoot:""}]);const a=s;n.d(e,["A",0,a])},74(t,e,n){var o=n(220),i=n.n(o),r=n(716),s=n.n(r),a=n(247),d=n.n(a),l=new URL(n(390),n.b),c=new URL(n(513),n.b),h=new URL(n(568),n.b),u=new URL(n(483),n.b),A=s()(i()),g=d()(l),f=d()(c),p=d()(h),m=d()(u);A.push([t.id,`/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${g}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${f}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${p}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${m}) format("woff2");\n}\n`,"",{version:3,sources:["webpack://./src/fonts.css"],names:[],mappings:"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF",sourcesContent:['/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url("@fontsource/inter/files/inter-latin-400-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url("@fontsource/inter/files/inter-latin-500-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url("@fontsource/inter/files/inter-latin-600-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url("@fontsource/inter/files/inter-latin-700-normal.woff2") format("woff2");\n}\n'],sourceRoot:""}]);const b=A.toString();n.d(e,["A",0,b])},574(t,e,n){var o=n(582),i=n.n(o),r=n(991),s=n.n(r),a=n(725),d=n.n(a),l=n(798),c=n.n(l),h=n(754),u=n.n(h),A=n(567),g=n.n(A),f=n(183),p={};p.styleTagTransform=g(),p.setAttributes=c(),p.insert=d().bind(null,"head"),p.domAPI=s(),p.insertStyleElement=u(),i()(f.A,p),f.A&&f.A.locals&&f.A.locals},919(t,e,n){var o=n(582),i=n.n(o),r=n(991),s=n.n(r),a=n(725),d=n.n(a),l=n(798),c=n.n(l),h=n(754),u=n.n(h),A=n(567),g=n.n(A),f=n(870),p={};p.styleTagTransform=g(),p.setAttributes=c(),p.insert=d().bind(null,"head"),p.domAPI=s(),p.insertStyleElement=u(),i()(f.A,p),f.A&&f.A.locals&&f.A.locals}}]); //# sourceMappingURL=286.js.map \ No newline at end of file diff --git a/cmd/mdl/webapp/dist/286.js.map b/cmd/mdl/webapp/dist/286.js.map index ae12529f..230738f3 100644 --- a/cmd/mdl/webapp/dist/286.js.map +++ b/cmd/mdl/webapp/dist/286.js.map @@ -1 +1 @@ -{"version":3,"file":"286.js","mappings":"mGAwH0B,CAACA,EAAgBC,KAC1CC,OAAOC,QAAQF,GAAOG,QAAQ,EAAEC,EAAKC,MACpCN,EAAGO,aAAaF,EAAKG,OAAOF,cAxCJ,CACzBG,WAAY,CACX,eAAgB,KAEjBC,SAAU,CACT,cAAe,uDACfC,OAAQ,QAETC,SAAU,CACT,cAAe,uDACfD,OAAQ,QAETE,SAAU,CACTC,KAAM,OACNH,OAAQ,QAETI,UAAW,CACVD,KAAM,OACNH,OAAQ,UACR,eAAgB,IAChB,mBAAoB,OAErBK,UAAW,CACVF,KAAM,UACN,YAAa,GACb,c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IAEhBC,IAAIG,EAAA5wB,EAAOkT,GAKF0d,EAAA5wB,GAAW4wB,EAAA5wB,EAAO2wB,QAAUC,EAAA5wB,EAAO2wB","sources":["webpack://app/./src/graph-view/constants.ts","webpack://app/./src/graph-view/edge-utils.ts","webpack://app/./src/graph-view/geometry.ts","webpack://app/./src/graph-view/defs.ts","webpack://app/./src/graph-view/svg-create.ts","webpack://app/./src/graph-view/intersect.ts","webpack://app/./src/graph-view/shapes.ts","webpack://app/./src/graph-view/undo.ts","webpack://app/./src/graph-view/node-content.ts","webpack://app/./src/graph-view/graph.ts","webpack://app/./src/graph-view/automatic-layout.ts","webpack://app/./src/graph-view/layout.ts","webpack://app/./src/graph-view/manual-layout.ts","webpack://app/./src/graph-view/svg-text.ts","webpack://app/./src/parseModel.ts","webpack://app/./src/shortcuts.tsx","webpack://app/./src/utils/platform.ts","webpack://app/./src/fonts.css","webpack://app/./src/style.css","webpack://app/./src/fonts.css?0e2c","webpack://app/./src/fonts.css?a158","webpack://app/./src/style.css?dd02"],"sourcesContent":["// Constants and default configurations for the graph view\n\nexport interface Point {\n\tx: number;\n\ty: number;\n}\n\nexport interface BBox extends Point {\n\twidth: number;\n\theight: number;\n}\n\nexport interface NodeStyle {\n\t// Width of element, in pixels.\n\twidth?: number\n\t// Height of element, in pixels.\n\theight?: number\n\t// Background color of element as HTML RGB hex string (e.g. \"#ffffff\")\n\tbackground?: string\n\t// Stroke color of element as HTML RGB hex string (e.g. \"#000000\")\n\tstroke?: string\n\t// Foreground (text) color of element as HTML RGB hex string (e.g. \"#ffffff\")\n\tcolor?: string\n\t// Standard font size used to render text, in pixels.\n\tfontSize?: number\n\t// Shape used to render element.\n\tshape?: string\n\t// URL of PNG/JPG/GIF file or Base64 data URI representation.\n\ticon?: string\n\t// Type of border used to render element.\n\tborder?: string\n\t// Opacity used to render element; 0-100.\n\topacity?: number\n\t// Whether element metadata should be shown.\n\tmetadata?: boolean\n\t// Whether element description should be shown.\n\tdescription?: boolean\n}\n\nexport interface EdgeStyle {\n\t// Thickness of line, in pixels.\n\tthickness?: number\n\t// Color of line as HTML RGB hex string (e.g. \"#ffffff\").\n\tcolor?: string\n\t// Standard font size used to render relationship annotation, in pixels.\n\tfontSize?: number\n\t// Width of relationship annotation, in pixels.\n\twidth?: number\n\t// Whether line is dashed.\n\tdashed?: boolean\n\t// Position of label along edge (0-100).\n\tposition?: number\n\t// Opacity used to render relationship; 0-100.\n\topacity?: number\n\t// Arrow style for the edge.\n\tarrowStyle?: 'normal' | 'large' | 'small' | 'none'\n}\n\n// Default styles\nexport const DEFAULT_EDGE_STYLE: EdgeStyle = {\n\tthickness: 2,\n\tcolor: '#64748b',\n\topacity: 1,\n\tfontSize: 18,\n\twidth: 200,\n\tdashed: true,\n};\n\nexport const DEFAULT_NODE_STYLE: NodeStyle = {\n\twidth: 280,\n\theight: 180,\n\tbackground: '#ffffff',\n\tcolor: '#334155',\n\topacity: 1,\n\tstroke: '#8492a6',\n\tfontSize: 22,\n\tshape: 'Box',\n\tmetadata: true,\n\tdescription: true,\n};\n\n// SVG styles\nexport const SVG_STYLES = {\n\tnodeBorder: {\n\t\t'stroke-width': 1.5,\n\t},\n\tnodeText: {\n\t\t'font-family': 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',\n\t\tstroke: \"none\"\n\t},\n\tedgeText: {\n\t\t'font-family': 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',\n\t\tstroke: \"none\"\n\t},\n\tedgeRect: {\n\t\tfill: \"none\",\n\t\tstroke: \"none\",\n\t},\n\tgroupRect: {\n\t\tfill: \"none\",\n\t\tstroke: \"#8492a6\",\n\t\t'stroke-width': 1.5,\n\t\t\"stroke-dasharray\": \"6 4\",\n\t},\n\tgroupText: {\n\t\tfill: \"#475569\",\n\t\t\"font-size\": 20,\n\t\t\"font-weight\": \"600\",\n\t\t'font-family': 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',\n\t\tcursor: \"default\"\n\t}\n};\n\n// Configuration constants\nexport const SVG_PADDING = 20;\nexport const DEFAULT_GRID_SIZE = 25;\nexport const EDGE_SPREAD_DISTANCE = 70;\nexport const EDGE_SPREAD_DISTANCE_X = 200;\n\n// Set presentation attributes so an author's later attributes override defaults.\nexport const applyStyle = (el: SVGElement, style: { [key: string]: string | number }) => {\n\tObject.entries(style).forEach(([key, value]) => {\n\t\tel.setAttribute(key, String(value));\n\t});\n};\n\n// Utility function to calculate distance between two points\nexport const calculateDistance = (p1: Point, p2: Point): number => {\n\treturn Math.sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));\n};\n","import { Point, calculateDistance } from './constants';\nimport { Segment } from './intersect';\n\n// Define interfaces locally since they're not exported from graph.ts\ninterface NodeStyle {\n\tbackground?: string;\n\tstroke?: string;\n\topacity?: number;\n\tfontSize?: number;\n\tshape?: string;\n\tborder?: string;\n}\n\ninterface Node extends Point {\n\tid: string;\n\ttitle: string;\n\tsub: string;\n\tdescription: string;\n\twidth: number;\n\theight: number;\n\tref?: SVGGElement;\n\tselected?: boolean;\n\tintersect: (p: Point) => Point;\n\tstyle: NodeStyle;\n}\n\ninterface EdgeVertex extends Point {\n\tid: string;\n\tselected?: boolean;\n\tref?: SVGElement;\n\tlabel?: boolean;\n\tauto?: boolean;\n}\n\ninterface EdgeStyle {\n\tcolor?: string;\n\tthickness?: number;\n\tfontSize?: number;\n\tposition?: number;\n\tdashed?: boolean;\n}\n\ninterface Edge {\n\tid: string;\n\tlabel: string;\n\tfrom: Node;\n\tto: Node;\n\tvertices?: EdgeVertex[];\n\tref?: SVGGElement;\n\tstyle: EdgeStyle;\n\tinitVertex: (p: Point) => EdgeVertex;\n\tuserDeletedVertices?: boolean; // Track if user explicitly deleted vertices\n}\n\nexport interface EdgeLabelPlacement extends Point {\n\torientation: 'horizontal' | 'vertical';\n\tsegment?: Segment;\n\tmovable: boolean;\n}\n\n/**\n * Calculate edge vertices, handling multi-edge scenarios and auto-vertices\n */\nexport function calculateEdgeVertices(edge: Edge): Point[] {\n\tconst n1 = edge.from, n2 = edge.to;\n\t\n\t\n\t// if vertices exists, follow them\n\tlet vertices: Point[] = edge.vertices ? edge.vertices.concat() : [];\n\t// Don't remove label vertices - they should be preserved for rendering\n\t// (The autoLayout process handles replacing old ones with new ones)\n\n\tvertices.unshift(n1)\n\tvertices.push(n2)\n\n\tconst interior = vertices.slice(1, -1) as EdgeVertex[];\n\tconst firstRoutingVertex = interior.find(vertex => !vertex.label) ?? n2;\n\tlet lastRoutingVertex: Point = n1;\n\tfor (let index = interior.length - 1; index >= 0; index--) {\n\t\tif (!interior[index].label) {\n\t\t\tlastRoutingVertex = interior[index];\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!n1.intersect || !n2.intersect) {\n\t\tthrow new Error(`edge ${edge.id} nodes must be drawn before routing`);\n\t}\n\tvertices[0] = n1.intersect(firstRoutingVertex);\n\tvertices[vertices.length - 1] = n2.intersect(lastRoutingVertex);\n\t\n\treturn vertices;\n}\n\n/**\n * Calculate the label anchor and the orientation of the path segment that owns\n * it. Renderers use the orientation to place text beside the relationship line\n * instead of centering text over vertical segments.\n */\nexport function calculateLabelPlacement(\n\tvertices: Point[],\n\tposition: number,\n\tdefaultPoint: Point,\n): EdgeLabelPlacement {\n\tlet point = {x: defaultPoint.x, y: defaultPoint.y};\n\tlet segment: Segment | undefined;\n\tconst labelIndex = vertices.findIndex(vertex => (vertex as EdgeVertex).label);\n\tlet movable = true;\n\n\tif (labelIndex >= 0) {\n\t\tconst labelVertex = vertices[labelIndex] as EdgeVertex;\n\t\tpoint = labelVertex;\n\t\tmovable = labelVertex.auto === true;\n\t\tconst adjacentSegments: Segment[] = [];\n\t\tif (labelIndex > 0) {\n\t\t\tadjacentSegments.push({p: vertices[labelIndex - 1], q: point});\n\t\t}\n\t\tif (labelIndex < vertices.length - 1) {\n\t\t\tadjacentSegments.push({p: point, q: vertices[labelIndex + 1]});\n\t\t}\n\t\tsegment = adjacentSegments.reduce((longest, candidate) => {\n\t\t\tif (!longest) {\n\t\t\t\treturn candidate;\n\t\t\t}\n\t\t\treturn calculateDistance(candidate.p, candidate.q) >\n\t\t\t\tcalculateDistance(longest.p, longest.q)\n\t\t\t\t? candidate\n\t\t\t\t: longest;\n\t\t}, undefined);\n\t} else {\n\t\tconst totalLength = vertices.slice(1).reduce(\n\t\t\t(sum, vertex, index) => sum + calculateDistance(vertices[index], vertex),\n\t\t\t0,\n\t\t);\n\t\tconst targetLength = totalLength * position;\n\t\tlet traversed = 0;\n\t\tfor (let index = 1; index < vertices.length; index++) {\n\t\t\tconst candidate = {p: vertices[index - 1], q: vertices[index]};\n\t\t\tconst length = calculateDistance(candidate.p, candidate.q);\n\t\t\tif (length > 0 && traversed + length >= targetLength) {\n\t\t\t\tconst segmentPosition = (targetLength - traversed) / length;\n\t\t\t\tpoint = {\n\t\t\t\t\tx: candidate.p.x + (candidate.q.x - candidate.p.x) * segmentPosition,\n\t\t\t\t\ty: candidate.p.y + (candidate.q.y - candidate.p.y) * segmentPosition,\n\t\t\t\t};\n\t\t\t\tsegment = candidate;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ttraversed += length;\n\t\t}\n\t}\n\n\tconst horizontalDistance = segment ? Math.abs(segment.q.x - segment.p.x) : 0;\n\tconst verticalDistance = segment ? Math.abs(segment.q.y - segment.p.y) : 0;\n\treturn {\n\t\t...point,\n\t\torientation: verticalDistance > horizontalDistance ? 'vertical' : 'horizontal',\n\t\tsegment,\n\t\tmovable,\n\t};\n}\n\n/** createEdgePath draws the given points without cutting or moving the route. */\nexport function createEdgePath(vertices: Point[]): string {\n\tif (vertices.length < 2) {\n\t\tthrow new Error(\"edge route must contain at least two points\");\n\t}\n\treturn vertices.slice(1).reduce(\n\t\t(path, point) => `${path} L${point.x},${point.y}`,\n\t\t`M${vertices[0].x},${vertices[0].y}`,\n\t);\n}","// This file defines the diagram sizes and positions shared by layout and SVG\n// drawing. Automatic and manual layout both produce ResolvedLayout. The SVG\n// drawing code accepts a layout only after this file has checked it.\n\n/** Point is one position in the diagram. */\nexport interface Point {\n\tx: number;\n\ty: number;\n}\n\n/** Size is a width and height. Both values must be zero or greater. */\nexport interface Size {\n\twidth: number;\n\theight: number;\n}\n\n/** Rect is a box that does not rotate. */\nexport interface Rect extends Point, Size {}\n\n/** MeasuredNode holds the exact box and text sizes needed before layout. */\nexport interface MeasuredNode {\n\tid: string;\n\tparentId?: string;\n\tsize: Size;\n\tcontentSize: Size;\n\tcenterOffset: Point;\n\tshape: string;\n}\n\n/** MeasuredGroup describes a boundary that must contain its children and title. */\nexport interface MeasuredGroup {\n\tid: string;\n\tparentId?: string;\n\ttitleSize: Size;\n}\n\n/** MeasuredEdge names the two connected nodes and the exact label size. */\nexport interface MeasuredEdge {\n\tid: string;\n\tsourceId: string;\n\ttargetId: string;\n\tlabelSize?: Size;\n}\n\n/**\n * MeasuredDiagram is the complete input to automatic or manual layout.\n * It contains sizes, but no positions.\n */\nexport interface MeasuredDiagram {\n\tid: string;\n\tnodes: MeasuredNode[];\n\tgroups: MeasuredGroup[];\n\tedges: MeasuredEdge[];\n}\n\n/** ResolvedNode is one measured node placed in the diagram. */\nexport interface ResolvedNode {\n\tid: string;\n\tparentId?: string;\n\tbounds: Rect;\n}\n\n/** ResolvedGroup is one placed boundary and its title box. */\nexport interface ResolvedGroup {\n\tid: string;\n\tparentId?: string;\n\tbounds: Rect;\n\ttitleBounds: Rect;\n}\n\n/**\n * ResolvedEdge contains a complete route. Each section is an ordered list of\n * points. labelBounds is the final label box chosen by layout.\n */\nexport interface ResolvedEdge {\n\tid: string;\n\tsourceId: string;\n\ttargetId: string;\n\tsections: Point[][];\n\tlabelBounds?: Rect;\n}\n\n/**\n * ResolvedLayout is the unchecked result of automatic or manual layout.\n * Drawing code must not use it directly.\n */\nexport interface ResolvedLayout {\n\tdiagramId: string;\n\tbounds: Rect;\n\tnodes: ResolvedNode[];\n\tgroups: ResolvedGroup[];\n\tedges: ResolvedEdge[];\n}\n\n/** GeometryIssueCode names one rule that the layout broke. */\nexport type GeometryIssueCode =\n\t| \"duplicate_id\"\n\t| \"missing_element\"\n\t| \"unexpected_element\"\n\t| \"non_finite\"\n\t| \"size_mismatch\"\n\t| \"content_overflow\"\n\t| \"node_overlap\"\n\t| \"group_overlap\"\n\t| \"false_containment\"\n\t| \"edge_through_node\"\n\t| \"edge_through_group\"\n\t| \"label_node_overlap\"\n\t| \"label_label_overlap\"\n\t| \"label_edge_overlap\"\n\t| \"label_title_overlap\"\n\t| \"out_of_bounds\"\n\t| \"disconnected_edge\";\n\n/** GeometryIssue reports the stable IDs of the affected diagram elements. */\nexport interface GeometryIssue {\n\tcode: GeometryIssueCode;\n\telementIds: string[];\n\tmessage: string;\n}\n\nconst validatedLayoutBrand: unique symbol = Symbol(\"ValidatedLayout\");\n\n/**\n * ValidatedLayout is the only layout the SVG drawing code accepts. The private\n * marker prevents other code from creating one without running the checks.\n */\nexport type ValidatedLayout = ResolvedLayout & {\n\treadonly [validatedLayoutBrand]: true;\n};\n\n/** GeometryValidationError reports every layout problem found in one check. */\nexport class GeometryValidationError extends Error {\n\treadonly issues: GeometryIssue[];\n\n\tconstructor(issues: GeometryIssue[]) {\n\t\tsuper(issues.map(issue => issue.message).join(\"\\n\"));\n\t\tthis.name = \"GeometryValidationError\";\n\t\tthis.issues = issues;\n\t}\n}\n\n/**\n * validateResolvedLayout checks that every element is present, every number is\n * valid, boundaries show true ownership, elements do not collide, and all\n * content stays inside the diagram.\n */\nexport function validateResolvedLayout(\n\tmeasured: MeasuredDiagram,\n\tresolved: ResolvedLayout,\n): ValidatedLayout {\n\tconst issues: GeometryIssue[] = [];\n\tif (measured.id !== resolved.diagramId) {\n\t\tissues.push(issue(\n\t\t\t\"missing_element\",\n\t\t\t[measured.id, resolved.diagramId],\n\t\t\t`layout ${resolved.diagramId} does not resolve measured diagram ${measured.id}`,\n\t\t));\n\t}\n\n\tcheckUniqueIDs(\"measured node\", measured.nodes.map(node => node.id), issues);\n\tcheckUniqueIDs(\"measured group\", measured.groups.map(group => group.id), issues);\n\tcheckUniqueIDs(\"measured edge\", measured.edges.map(edge => edge.id), issues);\n\tcheckUniqueIDs(\"resolved node\", resolved.nodes.map(node => node.id), issues);\n\tcheckUniqueIDs(\"resolved group\", resolved.groups.map(group => group.id), issues);\n\tcheckUniqueIDs(\"resolved edge\", resolved.edges.map(edge => edge.id), issues);\n\n\tcheckCoverage(\n\t\t\"node\",\n\t\tmeasured.nodes.map(node => node.id),\n\t\tresolved.nodes.map(node => node.id),\n\t\tissues,\n\t);\n\tcheckCoverage(\n\t\t\"group\",\n\t\tmeasured.groups.map(group => group.id),\n\t\tresolved.groups.map(group => group.id),\n\t\tissues,\n\t);\n\tcheckCoverage(\n\t\t\"edge\",\n\t\tmeasured.edges.map(edge => edge.id),\n\t\tresolved.edges.map(edge => edge.id),\n\t\tissues,\n\t);\n\n\tconst measuredNodes = new Map(measured.nodes.map(node => [node.id, node]));\n\tconst measuredGroups = new Map(measured.groups.map(group => [group.id, group]));\n\tconst resolvedNodes = new Map(resolved.nodes.map(node => [node.id, node]));\n\tconst resolvedGroups = new Map(resolved.groups.map(group => [group.id, group]));\n\n\tcheckFiniteRect(\"diagram\", resolved.diagramId, resolved.bounds, issues);\n\tfor (const node of resolved.nodes) {\n\t\tcheckFiniteRect(\"node\", node.id, node.bounds, issues);\n\t\tconst expected = measuredNodes.get(node.id);\n\t\tif (expected && (\n\t\t\t!nearlyEqual(expected.size.width, node.bounds.width) ||\n\t\t\t!nearlyEqual(expected.size.height, node.bounds.height)\n\t\t)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"size_mismatch\",\n\t\t\t\t[node.id],\n\t\t\t\t`node ${node.id} size changed after measurement`,\n\t\t\t));\n\t\t}\n\t\tif (expected && (\n\t\t\texpected.contentSize.width > node.bounds.width ||\n\t\t\texpected.contentSize.height > node.bounds.height\n\t\t)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"content_overflow\",\n\t\t\t\t[node.id],\n\t\t\t\t`node ${node.id} content exceeds its resolved bounds`,\n\t\t\t));\n\t\t}\n\t\tcheckRectInBounds(\"node\", node.id, node.bounds, resolved.bounds, issues);\n\t}\n\tfor (const group of resolved.groups) {\n\t\tcheckFiniteRect(\"group\", group.id, group.bounds, issues);\n\t\tcheckFiniteRect(\"group title\", group.id, group.titleBounds, issues);\n\t\tcheckRectInBounds(\"group\", group.id, group.bounds, resolved.bounds, issues);\n\t\tif (!contains(group.bounds, group.titleBounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[group.id],\n\t\t\t\t`group ${group.id} does not contain its title`,\n\t\t\t));\n\t\t}\n\t\tconst expected = measuredGroups.get(group.id);\n\t\tif (expected && (\n\t\t\t!nearlyEqual(expected.titleSize.width, group.titleBounds.width) ||\n\t\t\t!nearlyEqual(expected.titleSize.height, group.titleBounds.height)\n\t\t)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"size_mismatch\",\n\t\t\t\t[group.id],\n\t\t\t\t`group ${group.id} title size changed after measurement`,\n\t\t\t));\n\t\t}\n\t}\n\n\tcheckNodeOverlaps(resolved.nodes, issues);\n\tcheckGroupOverlaps(resolved.groups, issues);\n\tcheckOwnership(\n\t\tmeasured.nodes,\n\t\tmeasured.groups,\n\t\tresolvedNodes,\n\t\tresolvedGroups,\n\t\tissues,\n\t);\n\tcheckEdges(\n\t\tmeasured,\n\t\tresolved,\n\t\tresolvedNodes,\n\t\tresolvedGroups,\n\t\tmeasuredNodes,\n\t\tmeasuredGroups,\n\t\tissues,\n\t);\n\n\tif (issues.length > 0) {\n\t\tthrow new GeometryValidationError(issues);\n\t}\n\treturn resolved as ValidatedLayout;\n}\n\n/** checkUniqueIDs requires each model ID to appear only once. */\nfunction checkUniqueIDs(label: string, ids: string[], issues: GeometryIssue[]): void {\n\tconst seen = new Set();\n\tfor (const id of ids) {\n\t\tif (seen.has(id)) {\n\t\t\tissues.push(issue(\"duplicate_id\", [id], `${label} ${id} is duplicated`));\n\t\t}\n\t\tseen.add(id);\n\t}\n}\n\n/** checkCoverage rejects missing elements and old elements left in a layout. */\nfunction checkCoverage(\n\tlabel: string,\n\texpected: string[],\n\tactual: string[],\n\tissues: GeometryIssue[],\n): void {\n\tconst expectedIDs = new Set(expected);\n\tconst actualIDs = new Set(actual);\n\tfor (const id of expectedIDs) {\n\t\tif (!actualIDs.has(id)) {\n\t\t\tissues.push(issue(\"missing_element\", [id], `${label} ${id} is missing from resolved layout`));\n\t\t}\n\t}\n\tfor (const id of actualIDs) {\n\t\tif (!expectedIDs.has(id)) {\n\t\t\tissues.push(issue(\"unexpected_element\", [id], `${label} ${id} is not in the measured diagram`));\n\t\t}\n\t}\n}\n\n/** checkFiniteRect rejects invalid numbers and negative sizes. */\nfunction checkFiniteRect(\n\tlabel: string,\n\tid: string,\n\trect: Rect,\n\tissues: GeometryIssue[],\n): void {\n\tif (!isFiniteRect(rect) || rect.width < 0 || rect.height < 0) {\n\t\tissues.push(issue(\"non_finite\", [id], `${label} ${id} has invalid geometry`));\n\t}\n}\n\n/** checkRectInBounds requires the whole box to fit inside the diagram. */\nfunction checkRectInBounds(\n\tlabel: string,\n\tid: string,\n\trect: Rect,\n\tbounds: Rect,\n\tissues: GeometryIssue[],\n): void {\n\tif (!contains(bounds, rect)) {\n\t\tissues.push(issue(\"out_of_bounds\", [id], `${label} ${id} lies outside the resolved view bounds`));\n\t}\n}\n\n/** checkNodeOverlaps prevents two nodes from sharing the same area. */\nfunction checkNodeOverlaps(nodes: ResolvedNode[], issues: GeometryIssue[]): void {\n\tforEachPair(nodes, (first, second) => {\n\t\tif (overlaps(first.bounds, second.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"node_overlap\",\n\t\t\t\t[first.id, second.id],\n\t\t\t\t`nodes ${first.id} and ${second.id} overlap`,\n\t\t\t));\n\t\t}\n\t});\n}\n\n/**\n * checkGroupOverlaps allows one real boundary inside another, but rejects\n * boundaries that partly cover each other and suggest false ownership.\n */\nfunction checkGroupOverlaps(groups: ResolvedGroup[], issues: GeometryIssue[]): void {\n\tforEachPair(groups, (first, second) => {\n\t\tif (\n\t\t\toverlaps(first.bounds, second.bounds) &&\n\t\t\t!contains(first.bounds, second.bounds) &&\n\t\t\t!contains(second.bounds, first.bounds)\n\t\t) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"group_overlap\",\n\t\t\t\t[first.id, second.id],\n\t\t\t\t`groups ${first.id} and ${second.id} partially overlap`,\n\t\t\t));\n\t\t}\n\t});\n}\n\n/**\n * checkOwnership requires each child to be inside the parent named by the\n * model. Visual overlap never creates ownership.\n */\nfunction checkOwnership(\n\tnodes: MeasuredNode[],\n\tgroups: MeasuredGroup[],\n\tresolvedNodes: Map,\n\tresolvedGroups: Map,\n\tissues: GeometryIssue[],\n): void {\n\tfor (const node of nodes) {\n\t\tconst child = resolvedNodes.get(node.id);\n\t\tif (child && child.parentId !== node.parentId) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[node.id],\n\t\t\t\t`node ${node.id} has the wrong parent ID`,\n\t\t\t));\n\t\t}\n\t\tif (!node.parentId) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst parent = resolvedGroups.get(node.parentId);\n\t\tif (child && parent && !contains(parent.bounds, child.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[node.id, node.parentId],\n\t\t\t\t`node ${node.id} lies outside owning group ${node.parentId}`,\n\t\t\t));\n\t\t}\n\t}\n\tfor (const group of groups) {\n\t\tconst child = resolvedGroups.get(group.id);\n\t\tif (child && child.parentId !== group.parentId) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[group.id],\n\t\t\t\t`group ${group.id} has the wrong parent ID`,\n\t\t\t));\n\t\t}\n\t\tif (!group.parentId) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst parent = resolvedGroups.get(group.parentId);\n\t\tif (child && parent && !contains(parent.bounds, child.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[group.id, group.parentId],\n\t\t\t\t`group ${group.id} lies outside owning group ${group.parentId}`,\n\t\t\t));\n\t\t}\n\t}\n}\n\n/**\n * checkEdges checks connected node IDs, complete routes, crossings, labels,\n * and boundary crossings for every relationship.\n */\nfunction checkEdges(\n\tmeasured: MeasuredDiagram,\n\tresolved: ResolvedLayout,\n\tnodes: Map,\n\tgroups: Map,\n\tmeasuredNodes: Map,\n\tmeasuredGroups: Map,\n\tissues: GeometryIssue[],\n): void {\n\tconst measuredEdges = new Map(measured.edges.map(edge => [edge.id, edge]));\n\tconst labels: Array<{id: string; bounds: Rect}> = [];\n\tfor (const edge of resolved.edges) {\n\t\tconst expected = measuredEdges.get(edge.id);\n\t\tif (!expected) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\tedge.sourceId !== expected.sourceId ||\n\t\t\tedge.targetId !== expected.targetId\n\t\t) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"disconnected_edge\",\n\t\t\t\t[edge.id, edge.sourceId, edge.targetId],\n\t\t\t\t`edge ${edge.id} endpoints do not match its measured contract`,\n\t\t\t));\n\t\t}\n\t\tif (edge.sections.length === 0 || edge.sections.some(section => section.length < 2)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"disconnected_edge\",\n\t\t\t\t[edge.id],\n\t\t\t\t`edge ${edge.id} has no complete route section`,\n\t\t\t));\n\t\t\tcontinue;\n\t\t}\n\t\tcheckSectionConnections(edge, nodes, issues);\n\t\tfor (const section of edge.sections) {\n\t\t\tfor (const point of section) {\n\t\t\t\tif (!isFinitePoint(point) || !pointInRect(point, resolved.bounds, true)) {\n\t\t\t\t\tissues.push(issue(\n\t\t\t\t\t\t\"out_of_bounds\",\n\t\t\t\t\t\t[edge.id],\n\t\t\t\t\t\t`edge ${edge.id} has a route point outside the resolved view`,\n\t\t\t\t\t));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const node of nodes.values()) {\n\t\t\tif (node.id === edge.sourceId || node.id === edge.targetId) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (routeIntersectsRect(edge.sections, inset(node.bounds, 0.5))) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"edge_through_node\",\n\t\t\t\t\t[edge.id, node.id],\n\t\t\t\t\t`edge ${edge.id} crosses unrelated node ${node.id}`,\n\t\t\t\t));\n\t\t\t}\n\t\t}\n\t\tfor (const group of groups.values()) {\n\t\t\tconst sourceInside = belongsToGroup(\n\t\t\t\tedge.sourceId,\n\t\t\t\tgroup.id,\n\t\t\t\tmeasuredNodes,\n\t\t\t\tmeasuredGroups,\n\t\t\t);\n\t\t\tconst targetInside = belongsToGroup(\n\t\t\t\tedge.targetId,\n\t\t\t\tgroup.id,\n\t\t\t\tmeasuredNodes,\n\t\t\t\tmeasuredGroups,\n\t\t\t);\n\t\t\tif (\n\t\t\t\tsourceInside === targetInside &&\n\t\t\t\trouteViolatesGroup(edge.sections, group.bounds, sourceInside)\n\t\t\t) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"edge_through_group\",\n\t\t\t\t\t[edge.id, group.id],\n\t\t\t\t\t`edge ${edge.id} violates group ${group.id} boundary`,\n\t\t\t\t));\n\t\t\t}\n\t\t}\n\t\tif (edge.labelBounds) {\n\t\t\tcheckFiniteRect(\"edge label\", edge.id, edge.labelBounds, issues);\n\t\t\tcheckRectInBounds(\"edge label\", edge.id, edge.labelBounds, resolved.bounds, issues);\n\t\t\tif (expected.labelSize && (\n\t\t\t\t!nearlyEqual(expected.labelSize.width, edge.labelBounds.width) ||\n\t\t\t\t!nearlyEqual(expected.labelSize.height, edge.labelBounds.height)\n\t\t\t)) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"size_mismatch\",\n\t\t\t\t\t[edge.id],\n\t\t\t\t\t`edge ${edge.id} label size changed after measurement`,\n\t\t\t\t));\n\t\t\t}\n\t\t\tfor (const node of nodes.values()) {\n\t\t\t\tif (overlaps(edge.labelBounds, node.bounds)) {\n\t\t\t\t\tissues.push(issue(\n\t\t\t\t\t\t\"label_node_overlap\",\n\t\t\t\t\t\t[edge.id, node.id],\n\t\t\t\t\t\t`edge ${edge.id} label overlaps node ${node.id}`,\n\t\t\t\t\t));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const group of groups.values()) {\n\t\t\t\tif (overlaps(edge.labelBounds, group.titleBounds)) {\n\t\t\t\t\tissues.push(issue(\n\t\t\t\t\t\t\"label_title_overlap\",\n\t\t\t\t\t\t[edge.id, group.id],\n\t\t\t\t\t\t`edge ${edge.id} label overlaps group ${group.id} title`,\n\t\t\t\t\t));\n\t\t\t\t}\n\t\t\t}\n\t\t\tlabels.push({id: edge.id, bounds: edge.labelBounds});\n\t\t} else if (expected.labelSize) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"missing_element\",\n\t\t\t\t[edge.id],\n\t\t\t\t`edge ${edge.id} is missing its measured label`,\n\t\t\t));\n\t\t}\n\t}\n\tforEachPair(labels, (first, second) => {\n\t\tif (overlaps(first.bounds, second.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"label_label_overlap\",\n\t\t\t\t[first.id, second.id],\n\t\t\t\t`edge labels ${first.id} and ${second.id} overlap`,\n\t\t\t));\n\t\t}\n\t});\n\tfor (const label of labels) {\n\t\tfor (const edge of resolved.edges) {\n\t\t\tif (routeIntersectsRect(edge.sections, inset(label.bounds, 0.5))) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"label_edge_overlap\",\n\t\t\t\t\t[label.id, edge.id],\n\t\t\t\t\t`edge ${edge.id} crosses label ${label.id}`,\n\t\t\t\t));\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * checkSectionConnections requires one ordered route from the source border to\n * the target border. Separate or reversed sections are not a complete route.\n */\nfunction checkSectionConnections(\n\tedge: ResolvedEdge,\n\tnodes: Map,\n\tissues: GeometryIssue[],\n): void {\n\tfor (let index = 1; index < edge.sections.length; index++) {\n\t\tconst previous = edge.sections[index - 1].slice(-1)[0];\n\t\tconst current = edge.sections[index][0];\n\t\tif (!samePoint(previous, current)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"disconnected_edge\",\n\t\t\t\t[edge.id],\n\t\t\t\t`edge ${edge.id} has disconnected route sections`,\n\t\t\t));\n\t\t\treturn;\n\t\t}\n\t}\n\tconst source = nodes.get(edge.sourceId);\n\tconst target = nodes.get(edge.targetId);\n\tconst start = edge.sections[0][0];\n\tconst end = edge.sections.slice(-1)[0].slice(-1)[0];\n\tif (\n\t\t!source ||\n\t\t!target ||\n\t\t!pointOnBorder(start, source.bounds) ||\n\t\t!pointOnBorder(end, target.bounds)\n\t) {\n\t\tissues.push(issue(\n\t\t\t\"disconnected_edge\",\n\t\t\t[edge.id, edge.sourceId, edge.targetId],\n\t\t\t`edge ${edge.id} does not connect both node borders`,\n\t\t));\n\t}\n}\n\n/** belongsToGroup follows parent IDs to decide whether a node belongs to a group. */\nfunction belongsToGroup(\n\tnodeId: string,\n\tgroupId: string,\n\tnodes: Map,\n\tgroups: Map,\n): boolean {\n\tlet parent = nodes.get(nodeId)?.parentId;\n\twhile (parent) {\n\t\tif (parent === groupId) {\n\t\t\treturn true;\n\t\t}\n\t\tparent = groups.get(parent)?.parentId;\n\t}\n\treturn false;\n}\n\n/**\n * routeViolatesGroup checks the middle of each line. When both connected nodes\n * are inside a group, the line must stay inside it. When both are outside, the\n * line must stay outside it.\n */\nfunction routeViolatesGroup(\n\tsections: Point[][],\n\tgroup: Rect,\n\tshouldBeInside: boolean,\n): boolean {\n\tfor (const section of sections) {\n\t\tfor (let index = 1; index < section.length; index++) {\n\t\t\tconst midpoint = {\n\t\t\t\tx: (section[index - 1].x + section[index].x) / 2,\n\t\t\t\ty: (section[index - 1].y + section[index].y) / 2,\n\t\t\t};\n\t\t\tif (pointInRect(midpoint, group, false) !== shouldBeInside) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\n/** routeIntersectsRect reports whether any part of a route enters a box. */\nfunction routeIntersectsRect(sections: Point[][], rect: Rect): boolean {\n\treturn sections.some(section => section.some((point, index) =>\n\t\tindex > 0 && segmentIntersectsRect(section[index - 1], point, rect),\n\t));\n}\n\n/**\n * segmentIntersectsRect checks both straight and diagonal lines. A line may\n * touch the box border, but it may not enter the box.\n */\nfunction segmentIntersectsRect(start: Point, end: Point, rect: Rect): boolean {\n\tconst dx = end.x - start.x;\n\tconst dy = end.y - start.y;\n\tlet minimum = 0;\n\tlet maximum = 1;\n\tfor (const [origin, delta, lower, upper] of [\n\t\t[start.x, dx, rect.x, rect.x + rect.width],\n\t\t[start.y, dy, rect.y, rect.y + rect.height],\n\t] as const) {\n\t\tif (Math.abs(delta) < Number.EPSILON) {\n\t\t\tif (origin <= lower || origin >= upper) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst first = (lower - origin) / delta;\n\t\tconst second = (upper - origin) / delta;\n\t\tminimum = Math.max(minimum, Math.min(first, second));\n\t\tmaximum = Math.min(maximum, Math.max(first, second));\n\t\tif (minimum >= maximum) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn maximum > 0 && minimum < 1;\n}\n\n/** overlaps treats touching borders as contact, not shared area. */\nfunction overlaps(first: Rect, second: Rect): boolean {\n\treturn (\n\t\tfirst.x < second.x + second.width &&\n\t\tsecond.x < first.x + first.width &&\n\t\tfirst.y < second.y + second.height &&\n\t\tsecond.y < first.y + first.height\n\t);\n}\n\n/** contains requires the whole inner box to be inside the outer box. */\nfunction contains(outer: Rect, inner: Rect): boolean {\n\treturn (\n\t\touter.x <= inner.x &&\n\t\touter.y <= inner.y &&\n\t\touter.x + outer.width >= inner.x + inner.width &&\n\t\touter.y + outer.height >= inner.y + inner.height\n\t);\n}\n\n/** pointInRect can include or exclude points that only touch the border. */\nfunction pointInRect(point: Point, rect: Rect, inclusive: boolean): boolean {\n\tif (inclusive) {\n\t\treturn (\n\t\t\tpoint.x >= rect.x &&\n\t\t\tpoint.y >= rect.y &&\n\t\t\tpoint.x <= rect.x + rect.width &&\n\t\t\tpoint.y <= rect.y + rect.height\n\t\t);\n\t}\n\treturn (\n\t\tpoint.x > rect.x &&\n\t\tpoint.y > rect.y &&\n\t\tpoint.x < rect.x + rect.width &&\n\t\tpoint.y < rect.y + rect.height\n\t);\n}\n\n/** inset makes a box smaller so touching its border does not count as crossing it. */\nfunction inset(rect: Rect, amount: number): Rect {\n\treturn {\n\t\tx: rect.x + amount,\n\t\ty: rect.y + amount,\n\t\twidth: Math.max(0, rect.width - amount * 2),\n\t\theight: Math.max(0, rect.height - amount * 2),\n\t};\n}\n\n/** isFinitePoint accepts only real numbers that SVG can draw. */\nfunction isFinitePoint(point: Point): boolean {\n\treturn Number.isFinite(point.x) && Number.isFinite(point.y);\n}\n\n/** isFiniteRect checks all four numbers in a box. */\nfunction isFiniteRect(rect: Rect): boolean {\n\treturn isFinitePoint(rect) && Number.isFinite(rect.width) && Number.isFinite(rect.height);\n}\n\n/** samePoint compares route points while allowing tiny browser number changes. */\nfunction samePoint(first: Point, second: Point): boolean {\n\treturn nearlyEqual(first.x, second.x) && nearlyEqual(first.y, second.y);\n}\n\n/** pointOnBorder checks that a route endpoint touches one side of a node box. */\nfunction pointOnBorder(point: Point, rect: Rect): boolean {\n\tconst withinX = point.x >= rect.x - 0.1 && point.x <= rect.x + rect.width + 0.1;\n\tconst withinY = point.y >= rect.y - 0.1 && point.y <= rect.y + rect.height + 0.1;\n\tconst onVertical = nearlyEqual(point.x, rect.x) ||\n\t\tnearlyEqual(point.x, rect.x + rect.width);\n\tconst onHorizontal = nearlyEqual(point.y, rect.y) ||\n\t\tnearlyEqual(point.y, rect.y + rect.height);\n\treturn (withinY && onVertical) || (withinX && onHorizontal);\n}\n\n/** nearlyEqual hides only browser rounding smaller than one tenth of a unit. */\nfunction nearlyEqual(first: number, second: number): boolean {\n\treturn Math.abs(first - second) <= 0.1;\n}\n\n/** forEachPair compares each pair once. */\nfunction forEachPair(items: T[], visit: (first: T, second: T) => void): void {\n\tfor (let first = 0; first < items.length; first++) {\n\t\tfor (let second = first + 1; second < items.length; second++) {\n\t\t\tvisit(items[first], items[second]);\n\t\t}\n\t}\n}\n\n/** issue creates one layout problem report. */\nfunction issue(\n\tcode: GeometryIssueCode,\n\telementIds: string[],\n\tmessage: string,\n): GeometryIssue {\n\treturn {code, elementIds, message};\n}\n","import fontFaces from \"../fonts.css?inline\";\nimport fontLicense from \"@fontsource/inter/LICENSE?raw\";\n\nexport const defs = `\n\n\t\n\t${fontLicense.replace(/&/g, \"&\").replace(/\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n`\n","import {svgTextWrap} from \"./svg-text\";\nimport {SVG_STYLES} from \"./constants\";\n\nexport const create = {\n\telement(type: string, attrs: Record = {}, className?: string) {\n\t\tconst el = document.createElementNS('http://www.w3.org/2000/svg', type);\n\t\tObject.entries(attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n\t\tif (className) el.classList.add(className);\n\t\treturn el;\n\t},\n\n\tuse(id: string, attrs: Record = {}) {\n\t\tconst el = this.element('use', attrs);\n\t\tel.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#' + id);\n\t\treturn el;\n\t},\n\n\tpath(path: string, attrs: Record = {}, className?: string) {\n\t\tconst p = this.element(\"path\", {...attrs, d: path}, className);\n\t\treturn p;\n\t},\n\n\ttext(text: string, attrs: Record = {}) {\n\t\tconst t = this.element('text', attrs) as SVGTextElement;\n\t\tif (text) t.textContent = text;\n\t\treturn t;\n\t},\n\n\ttextArea(text: string, width: number, fontSize: number, bold: boolean, x = 0, y = 0, anchor = '') {\n\t\tconst attrs: Record = {\n\t\t\t'font-family': SVG_STYLES.edgeText['font-family'],\n\t\t\t'font-size': `${fontSize}px`,\n\t\t\t'font-weight': bold ? 'bold' : 'normal'\n\t\t};\n\t\tconst {lines, maxW} = svgTextWrap(text, width, attrs);\n\t\tconst txt = this.text('', {x: 0, y, 'text-anchor': anchor || undefined});\n\t\t\n\t\tlines.forEach((line, i) => {\n\t\t\tconst span = this.element('tspan', {x, dy: `${fontSize + 2}px`, ...attrs});\n\t\t\tspan.textContent = line;\n\t\t\ttxt.append(span);\n\t\t});\n\t\t\n\t\treturn {txt, dy: (lines.length + 1) * (fontSize + 2), maxW};\n\t},\n\n\trect(width: number, height: number, x = 0, y = 0, r = 0, className?: string) {\n\t\treturn this.element('rect', {x, y, rx: r, ry: r, width, height}, className) as SVGRectElement;\n\t},\n\n\ticon(icon: string, x = 0, y = 0) {\n\t\treturn this.use(icon, {x, y});\n\t},\n\n\texpand(x: number, y: number, expanded: boolean) {\n\t\tconst g = this.element('g', {transform: `translate(${x},${y})`}, 'expand') as SVGGElement;\n\t\tg.append(\n\t\t\tthis.rect(19, 19, 0, 0, 1),\n\t\t\tthis.text(expanded ? '-' : '+', {x: 10, y: 14, 'text-anchor': 'middle'})\n\t\t);\n\t\treturn g;\n\t}\n};\n\nexport function setPosition(g: SVGGElement, x: number, y: number) {\n\tg.setAttribute('transform', `translate(${x},${y})`);\n}\n","interface Point {\n\tx: number;\n\ty: number;\n}\n\ninterface BBox extends Point {\n\twidth: number;\n\theight: number;\n}\n\n\nexport function insideBox(p: Point, b: BBox, centeredBox = true): boolean {\n\treturn centeredBox ?\n\t\t(p.x > b.x - b.width / 2 && p.x < b.x + b.width / 2 && p.y > b.y - b.height / 2 && p.y < b.y + b.height / 2) :\n\t\t(p.x > b.x && p.x < b.x + b.width && p.y > b.y && p.y < b.y + b.height)\n}\n\nexport function boxesOverlap(b1: BBox, b2: BBox): boolean {\n\treturn b1.x < b2.x + b2.width && b1.y < b2.y + b2.height && b1.x + b1.width > b2.x && b1.y + b1.height > b2.y\n}\n\nexport function uncenterBox(b: BBox): BBox {\n\treturn {x: b.x - b.width / 2, y: b.y - b.height / 2, width: b.width, height: b.height}\n}\n\nexport function scaleBox(b: BBox, sc: number): BBox {\n\treturn {x: b.x * sc, y: b.y * sc, width: b.width * sc, height: b.height * sc}\n}\n\n// intersect 2 segments (p1->q1) with (p2, q2)\n// if the lines intersect, the result contains the x and y of the intersection (treating the lines as infinite)\n// and booleans for whether line segment 1 or line segment 2 contain the point\nfunction segmentIntersection(p1: Point, q1: Point, p2: Point, q2: Point) {\n\tlet denominator, a, b, numerator1, numerator2,\n\t\tresult: { x: number, y: number, onLine1: boolean, onLine2: boolean } = {\n\t\t\tx: null,\n\t\t\ty: null,\n\t\t\tonLine1: false,\n\t\t\tonLine2: false\n\t\t};\n\tdenominator = (q2.y - p2.y) * (q1.x - p1.x) - (q2.x - p2.x) * (q1.y - p1.y);\n\tif (denominator == 0) {\n\t\treturn result;\n\t}\n\ta = p1.y - p2.y;\n\tb = p1.x - p2.x;\n\tnumerator1 = ((q2.x - p2.x) * a) - ((q2.y - p2.y) * b);\n\tnumerator2 = ((q1.x - p1.x) * a) - ((q1.y - p1.y) * b);\n\ta = numerator1 / denominator;\n\tb = numerator2 / denominator;\n\n\t// if we cast these lines infinitely in both directions, they intersect here:\n\tresult.x = p1.x + (a * (q1.x - p1.x));\n\tresult.y = p1.y + (a * (q1.y - p1.y));\n\n\t// if line1 is a segment and line2 is infinite, they intersect if:\n\tif (a > 0 && a < 1) {\n\t\tresult.onLine1 = true;\n\t}\n\t// if line2 is a segment and line1 is infinite, they intersect if:\n\tif (b >= 0 && b <= 1) {\n\t\tresult.onLine2 = true;\n\t}\n\t// if line1 and line2 are segments, they intersect if both of the above are true\n\treturn result;\n}\n\n// intersects a segment (p1->p2) with a box\nexport function intersectRectFull(p1: Point, p2: Point, box: BBox): Point[] {\n\tconst w = box.width / 2\n\tconst h = box.height / 2\n\tconst segs: { p: Point; q: Point }[] = [\n\t\t{p: {x: box.x - w, y: box.y - h}, q: {x: box.x - w, y: box.y + h}},\n\t\t{p: {x: box.x - w, y: box.y - h}, q: {x: box.x + w, y: box.y - h}},\n\t\t{p: {x: box.x + w, y: box.y - h}, q: {x: box.x + w, y: box.y + h}},\n\t\t{p: {x: box.x - w, y: box.y + h}, q: {x: box.x + w, y: box.y + h}},\n\t]\n\treturn segs.map(s => segmentIntersection(p1, p2, s.p, s.q)).filter(ret => ret.onLine1 && ret.onLine2)\n}\n\n// intersects a line that goes from p to the center of the box\nexport function intersectRect(box: BBox, p: Point): Point {\n\tif (insideBox(p, box)) return {x: box.x, y: box.y}\n\treturn intersectRectFull(box, p, box)[0] || {x: box.x, y: box.y}\n}\n\nexport function intersectEllipse(ellCenter: Point, rx: number, ry: number, nodeCenter: Point, point: Point) {\n\n\t//translate all to center ellipse\n\tconst p1 = {x: point.x - ellCenter.x, y: point.y - ellCenter.y}\n\tconst p2 = {x: nodeCenter.x - ellCenter.x, y: nodeCenter.y - ellCenter.y}\n\n\tif (p2.x == p1.x) { //hack to avoid singularity\n\t\tp1.x += .0000001\n\t}\n\n\tconst s = (p2.y - p1.y) / (p2.x - p1.x);\n\tconst si = p2.y - (s * p2.x);\n\tconst a = (ry * ry) + (rx * rx * s * s);\n\tconst b = 2 * rx * rx * si * s;\n\tconst c = rx * rx * si * si - rx * rx * ry * ry;\n\n\tconst radicand_sqrt = Math.sqrt((b * b) - (4 * a * c));\n\tconst x = p1.x > p2.x ?\n\t\t(-b + radicand_sqrt) / (2 * a) :\n\t\t(-b - radicand_sqrt) / (2 * a)\n\tconst pos = {\n\t\tx: x,\n\t\ty: s * x + si\n\t}\n\t//translate back\n\tpos.x += ellCenter.x;\n\tpos.y += ellCenter.y\n\n\treturn pos;\n}\n\nexport interface Segment {\n\tp: Point;\n\tq: Point;\n}\n\n// given a polyline as a list of segments, interrupt it over the box so no line is inside the box\nexport function intersectPolylineBox(segments: Segment[], box: BBox) {\n\tfor (let i = 0; i < segments.length; i++) {\n\t\tconst s = segments[i]\n\t\tif (insideBox(s.p, box)) {\n\t\t\tif (insideBox(s.q, box)) { // segment both ends inside box\n\t\t\t\tsegments.splice(i, 1)\n\t\t\t\ti -= 1\n\t\t\t} else { // segment start inside box\n\t\t\t\ts.p = intersectRectFull(s.p, s.q, box)[0]\n\t\t\t}\n\t\t} else {\n\t\t\tif (insideBox(s.q, box)) { // segment end inside box\n\t\t\t\ts.q = intersectRectFull(s.p, s.q, box)[0]\n\t\t\t} else { // both ends outside\n\t\t\t\tconst ret = intersectRectFull(s.p, s.q, box)\n\t\t\t\tif (ret.length == 2) { // intersects the box, splice segment\n\t\t\t\t\t// order the intersection points, closest first\n\t\t\t\t\tconst dst1 = Math.abs(ret[0].x - s.p.x) + Math.abs(ret[0].y - s.p.y)\n\t\t\t\t\tconst dst2 = Math.abs(ret[1].x - s.p.x) + Math.abs(ret[1].y - s.p.y)\n\t\t\t\t\tif (dst1 > dst2) ret.reverse()\n\t\t\t\t\t// split the segment in 2\n\t\t\t\t\tconst s2 = {p: ret[1], q: s.q}\n\t\t\t\t\ts.q = ret[0]\n\t\t\t\t\tsegments.splice(i + 1, 0, s2)\n\t\t\t\t\ti += 1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function project(p: Point, a: Point, b: Point): Point {\n\tlet atob = {x: b.x - a.x, y: b.y - a.y};\n\tlet atop = {x: p.x - a.x, y: p.y - a.y};\n\tlet len = atob.x * atob.x + atob.y * atob.y;\n\tlet dot = atop.x * atob.x + atop.y * atob.y;\n\tlet t = Math.min(1, Math.max(0, dot / len));\n\treturn {\n\t\tx: a.x + atob.x * t,\n\t\ty: a.y + atob.y * t\n\t};\n}\n\nexport function cabDistance(p1: Point, p2: Point): number {\n\treturn Math.abs(p2.x - p1.x) + Math.abs(p2.y - p1.y)\n}","import {intersectEllipse, intersectRect} from \"./intersect\";\n\ninterface Point {\n\tx: number;\n\ty: number;\n}\n\ninterface BBox extends Point {\n\twidth: number;\n\theight: number;\n}\n\ninterface D3Node extends BBox {\n\tintersect: (p: Point) => Point\n}\n\nfunction cylinderRadiusY(width: number) {\n\treturn width / 2 / (5.5 + width / 70);\n}\n\nexport function shapeLabelOffsetY(shape: string, width: number, height: number) {\n\tswitch (shape.toLowerCase()) {\n\t\tcase \"cylinder\":\n\t\t\treturn 2 * cylinderRadiusY(width);\n\t\tcase \"person\":\n\t\t\treturn height * 0.4;\n\t\tcase \"folder\":\n\t\t\treturn width / 10;\n\t\tcase \"robot\":\n\t\t\treturn height * 0.35;\n\t\tcase \"webbrowser\":\n\t\t\treturn height / 8;\n\t\tdefault:\n\t\t\treturn 0;\n\t}\n}\n\nclass D3Element {\n\tprivate readonly _el: SVGElement\n\n\tconstructor(el: SVGElement) {\n\t\tthis._el = el;\n\t}\n\n\tnode() {\n\t\treturn this._el;\n\t}\n\n\tattr(name: string, value: string | number) {\n\t\tthis._el.setAttribute(name, String(value))\n\t\treturn this;\n\t}\n\n\tinsert(type: string, pos: string) {\n\t\tconst el = document.createElementNS('http://www.w3.org/2000/svg', type)\n\t\tconst el2 = this._el.insertBefore(el, this._el.querySelector(pos))\n\t\treturn new D3Element(el2)\n\t}\n}\n\n\nfunction rect(parent: D3Element, bbox: BBox, node: D3Node, rounded = false) {\n\tconst shapeSvg = parent.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", rounded ? node.width / 8 : 3)\n\t\t.attr(\"ry\", rounded ? node.width / 8 : 3)\n\t\t.attr(\"x\", -bbox.width / 2)\n\t\t.attr(\"y\", -bbox.height / 2)\n\t\t.attr(\"width\", bbox.width)\n\t\t.attr(\"height\", bbox.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect(node, point);\n\t};\n\n\treturn shapeSvg;\n}\n\n\nfunction cylinder(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = bbox.width;\n\tconst rx = w / 2;\n\tconst ry = cylinderRadiusY(w);\n\tconst h = bbox.height;\n\n\tconst shape =\n\t\t`M 0,${ry} a${rx},${ry} 0,0,0 ${w} 0 a ${rx},${ry} 0,0,0 ${-w} 0 l 0,${h - 2 * ry} a ${rx},${ry} 0,0,0 ${w} 0 l 0,${-h + 2 * ry}`;\n\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"cylinder\", w, h))\n\t\t.insert('path', ':first-child')\n\t\t.attr('d', shape)\n\t\t.attr('transform', 'translate(' + -w / 2 + ',' + -(h / 2) + ')');\n\n\tnode.intersect = function (point: Point) {\n\t\tconst pos = intersectRect(node, point)\n\t\tlet cy = node.y + node.height / 2 - ry\n\t\tif (pos.y > cy)\n\t\t\treturn intersectEllipse({x: node.x, y: cy}, rx, ry, node, point)\n\n\t\tcy = node.y - node.height / 2 + ry\n\t\tif (pos.y < cy)\n\t\t\treturn intersectEllipse({x: node.x, y: cy}, rx, ry, node, point)\n\n\t\treturn pos;\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction person(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = bbox.width;\n\tconst h = bbox.height;\n\n\tconst shape =\n\t\t`M ${.38 * w},${h / 3} A${w / 2},${h / 2} 0,0,0 0 ${h / 2}\n\t\tL${w / 11},${h} L${w - w / 11},${h} L${w},${h / 2}\n\t\tA${w / 2},${h / 2} 0,0,0 ${w - .38 * w} ${h / 3} \n\t\tA${w / 6},${w / 6} 0,1,0 ${.38 * w} ${h / 3}`;\n\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"person\", w, h))\n\t\t.insert('path', ':first-child')\n\t\t.attr('d', shape)\n\t\t.attr('transform', 'translate(' + -w / 2 + ',' + -(h / 2) + ')');\n\n\tnode.intersect = function (point: Point) {\n\t\tconst pos = intersectRect(node, point)\n\t\treturn pos;\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction _ellipse(parent: D3Element, bbox: BBox, node: D3Node, rx: number, ry: number) {\n\tconst shapeSvg = parent.insert(\"ellipse\", \":first-child\")\n\t\t.attr(\"cx\", 0)\n\t\t.attr(\"cy\", 0)\n\t\t.attr('rx', rx)\n\t\t.attr('ry', ry)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectEllipse(node, rx, ry, node, point)\n\t};\n\treturn shapeSvg;\n}\n\nfunction circle(parent: D3Element, bbox: BBox, node: D3Node) {\n\treturn _ellipse(parent, bbox, node, node.width / 2, node.width / 2)\n}\n\nfunction ellipse(parent: D3Element, bbox: BBox, node: D3Node) {\n\treturn _ellipse(parent, bbox, node, node.width * .55, node.width * .45)\n}\n\nfunction hexagon(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst sz = node.width / 2\n\t// drawing a hexagon from polar coords\n\t// [0,1,2,3,4,5,6].map(i=>`${Math.sin(Math.PI/3*i+Math.PI/6).toFixed(4)},${Math.cos(Math.PI/3*i+Math.PI/6).toFixed(4)}`).join(',')\n\tconst shapeSvg = parent.insert(\"polygon\", \":first-child\")\n\t\t.attr(\"points\",\n\t\t\t[0.5000, 0.8660, 1.0000, 0.0000, 0.5000, -0.8660, -0.5000, -0.8660, -1.0000, -0.0000, -0.5000, 0.8660, 0.5000, 0.8660].map(n => n * sz).join(','))\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectEllipse(node, node.width / 2, node.width / 2, node, point)\n\t};\n\treturn shapeSvg;\n}\n\nfunction component(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dx = node.width / 10\n\tconst shapeSvg = parent.insert('g', ':first-child')\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2 - dx)\n\t\t.attr(\"y\", -node.height / 2 + dx)\n\t\t.attr(\"width\", dx * 2)\n\t\t.attr(\"height\", dx);\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2 - dx)\n\t\t.attr(\"y\", -node.height / 2 + dx * 2.5)\n\t\t.attr(\"width\", dx * 2)\n\t\t.attr(\"height\", dx);\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2)\n\t\t.attr(\"y\", -node.height / 2)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x - dx / 2, y: node.y, width: node.width + dx, height: node.height}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction folder(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dy = node.width / 20\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"folder\", node.width, node.height))\n\t\t.insert('g', ':first-child')\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2)\n\t\t.attr(\"y\", -node.height / 2 + dy * 2)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height - dy * 2);\n\tshapeSvg.insert(\"path\", \":first-child\")\n\t\t.attr('d', `M0,${-node.height / 2 + 2 * dy} l${dy},${-2 * dy} h${node.width / 2 - dy * 2} v${dy * 2}`)\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x, y: node.y + dy / 2, width: node.width, height: node.height + dy}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction mobiledevicelandscape(parent: D3Element, bbox: BBox, node: D3Node, rounded = false) {\n\tconst dx = node.width / 8\n\tconst r = node.width / 14\n\tconst shapeSvg = parent.insert('g', ':first-child')\n\tshapeSvg.insert('path', ':first-child')\n\t\t.attr('d', `M${-node.width / 2},${-node.height / 2} l0,${node.height} M${node.width / 2},${-node.height / 2} l0,${node.height}`)\n\tshapeSvg.insert('circle', ':first-child')\n\t\t.attr('cx', -node.width / 2 - dx / 2)\n\t\t.attr('cy', 0)\n\t\t.attr('r', r * .4)\n\tshapeSvg.insert('rect', ':first-child')\n\t\t.attr('x', node.width / 2 + dx / 2 - r * .2)\n\t\t.attr('y', -r)\n\t\t.attr('width', r * .4)\n\t\t.attr('height', r * 2)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", r)\n\t\t.attr(\"ry\", r)\n\t\t.attr(\"x\", -bbox.width / 2 - dx)\n\t\t.attr(\"y\", -bbox.height / 2)\n\t\t.attr(\"width\", bbox.width + 2 * dx)\n\t\t.attr(\"height\", bbox.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x, y: node.y, width: node.width + 2 * dx, height: node.height}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction mobiledeviceportrait(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dy = node.width / 8\n\tconst r = node.width / 14\n\tconst shapeSvg = parent.insert('g', ':first-child')\n\tshapeSvg.insert('path', ':first-child')\n\t\t.attr('d', `M${-node.width / 2},${-node.height / 2} l${node.width},0 M${-node.width / 2},${node.height / 2} l${node.width},0`)\n\tshapeSvg.insert('circle', ':first-child')\n\t\t.attr('cx', 0)\n\t\t.attr('cy', node.height / 2 + dy / 2)\n\t\t.attr('r', r * .4)\n\tshapeSvg.insert('rect', ':first-child')\n\t\t.attr('x', -r)\n\t\t.attr('y', -node.height / 2 - dy / 2 - r * .2)\n\t\t.attr('width', r * 2)\n\t\t.attr('height', r * .4)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", r)\n\t\t.attr(\"ry\", r)\n\t\t.attr(\"x\", -bbox.width / 2)\n\t\t.attr(\"y\", -bbox.height / 2 - dy)\n\t\t.attr(\"width\", bbox.width)\n\t\t.attr(\"height\", bbox.height + 2 * dy);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x, y: node.y, width: node.width, height: node.height + 2 * dy}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction pipe(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = node.width;\n\tconst h = node.height;\n\tconst ry = h / 2;\n\tconst rx = ry / (2.5 + w / 70);\n\n\tconst shape =\n\t\t`M${-rx},0\n\t\ta${rx},${ry} 0,0,1 0,${h}\n\t\ta${rx},${ry} 0,0,1 0,${-h}\n\t\tl${w},0\n\t\ta${rx},${ry} 0,0,1 0,${h}\n\t\tl${-w},0`;\n\n\tconst shapeSvg = parent\n\t\t.insert('path', ':first-child')\n\t\t.attr('d', shape)\n\t\t.attr('transform', 'translate(' + -w / 2 + ',' + -(h / 2) + ')');\n\n\tnode.intersect = function (point: Point) {\n\t\treturn intersectRect({x: node.x - rx, y: node.y, width: node.width + 2 * rx, height: node.height}, point)\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction robot(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = node.width\n\tconst h = node.height\n\t\n\t// Small head at top (like person shape but robot-styled)\n\tconst headSize = Math.min(w * 0.28, h * 0.25)\n\tconst headR = headSize * 0.2\n\tconst antennaH = headSize * 0.25\n\tconst antennaR = headSize * 0.08\n\t\n\t// Eye dimensions\n\tconst eyeR = headSize * 0.12\n\tconst eyeSpacing = headSize * 0.22\n\t\n\t// Ear dimensions \n\tconst earW = headSize * 0.12\n\tconst earH = headSize * 0.3\n\t\n\t// Body fills most of the space for text\n\tconst bodyW = w\n\tconst bodyTop = -h / 2 + antennaH + headSize\n\tconst bodyH = h - antennaH - headSize\n\tconst bodyR = 3\n\t\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"robot\", w, h))\n\t\t.insert('g', ':first-child')\n\t\n\t// Body - main rectangle for text (draw first so it's behind)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", bodyR)\n\t\t.attr(\"ry\", bodyR)\n\t\t.attr('x', -bodyW / 2)\n\t\t.attr('y', bodyTop)\n\t\t.attr('width', bodyW)\n\t\t.attr('height', bodyH)\n\t\n\t// Head\n\tconst headTop = -h / 2 + antennaH\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", headR)\n\t\t.attr(\"ry\", headR)\n\t\t.attr('x', -headSize / 2)\n\t\t.attr('y', headTop)\n\t\t.attr('width', headSize)\n\t\t.attr('height', headSize)\n\t\n\t// Antenna\n\tshapeSvg.insert(\"line\", \":first-child\")\n\t\t.attr('class', 'robot-antenna')\n\t\t.attr('x1', 0)\n\t\t.attr('y1', headTop)\n\t\t.attr('x2', 0)\n\t\t.attr('y2', -h / 2 + antennaR * 2)\n\t\t.attr('stroke-width', antennaR * 0.6)\n\t\t.attr('stroke-linecap', 'round')\n\t\n\t// Antenna ball\n\tshapeSvg.insert(\"circle\", \":first-child\")\n\t\t.attr('class', 'robot-antenna-ball')\n\t\t.attr('cx', 0)\n\t\t.attr('cy', -h / 2 + antennaR * 2)\n\t\t.attr('r', antennaR * 1.2)\n\t\n\t// Eyes\n\tconst eyeY = headTop + headSize * 0.4\n\tshapeSvg.insert(\"circle\", \":first-child\")\n\t\t.attr('class', 'robot-eye')\n\t\t.attr('cx', -eyeSpacing)\n\t\t.attr('cy', eyeY)\n\t\t.attr('r', eyeR)\n\tshapeSvg.insert(\"circle\", \":first-child\")\n\t\t.attr('class', 'robot-eye')\n\t\t.attr('cx', eyeSpacing)\n\t\t.attr('cy', eyeY)\n\t\t.attr('r', eyeR)\n\t\n\t// Mouth - simple smile\n\tconst mouthY = headTop + headSize * 0.7\n\tconst mouthW = headSize * 0.28\n\tshapeSvg.insert(\"path\", \":first-child\")\n\t\t.attr('class', 'robot-mouth')\n\t\t.attr('d', `M${-mouthW / 2},${mouthY} Q0,${mouthY + mouthW * 0.3} ${mouthW / 2},${mouthY}`)\n\t\t.attr('fill', 'none')\n\t\t.attr('stroke-width', antennaR * 0.5)\n\t\t.attr('stroke-linecap', 'round')\n\t\n\t// Ears\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", earW * 0.25)\n\t\t.attr(\"ry\", earW * 0.25)\n\t\t.attr('x', -headSize / 2 - earW - 1)\n\t\t.attr('y', eyeY - earH / 2)\n\t\t.attr('width', earW)\n\t\t.attr('height', earH)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", earW * 0.25)\n\t\t.attr(\"ry\", earW * 0.25)\n\t\t.attr('x', headSize / 2 + 1)\n\t\t.attr('y', eyeY - earH / 2)\n\t\t.attr('width', earW)\n\t\t.attr('height', earH)\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect(node, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction webbrowser(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dy = node.height / 8\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"webbrowser\", node.width, node.height))\n\t\t.insert('g', ':first-child')\n\tshapeSvg.insert(\"path\", \":first-child\")\n\t\t.attr('d', `\n\t\t\tM${-node.width / 2},${-node.height / 2 + dy} h${node.width}\n\t\t\tM${-node.width / 2 + dy / 4},${-node.height / 2 + dy / 4} h${dy / 2} v${dy / 2} h${-dy / 2} z\n\t\t\tM${-node.width / 2 + dy},${-node.height / 2 + dy / 4} h${node.width - dy - dy / 4} v${dy / 2} h${-node.width + dy + dy / 4} z\n\t\t`)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2)\n\t\t.attr(\"y\", -node.height / 2)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect(node, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nexport const shapes: { [key: string]: (parent: SVGElement, node: D3Node) => SVGElement } = {\n\tbox: (parent: SVGElement, node: D3Node) => rect(new D3Element(parent), node, node).node(),\n\troundedbox: (parent: SVGElement, node: D3Node) => rect(new D3Element(parent), node, node, true).node(),\n\tcomponent: (parent: SVGElement, node: D3Node) => component(new D3Element(parent), node, node).node(),\n\tcylinder: (parent: SVGElement, node: D3Node) => cylinder(new D3Element(parent), node, node).node(),\n\tperson: (parent: SVGElement, node: D3Node) => person(new D3Element(parent), node, node).node(),\n\tcircle: (parent: SVGElement, node: D3Node) => circle(new D3Element(parent), node, node).node(),\n\tellipse: (parent: SVGElement, node: D3Node) => ellipse(new D3Element(parent), node, node).node(),\n\thexagon: (parent: SVGElement, node: D3Node) => hexagon(new D3Element(parent), node, node).node(),\n\tfolder: (parent: SVGElement, node: D3Node) => folder(new D3Element(parent), node, node).node(),\n\tmobiledevicelandscape: (parent: SVGElement, node: D3Node) => mobiledevicelandscape(new D3Element(parent), node, node).node(),\n\tmobiledeviceportrait: (parent: SVGElement, node: D3Node) => mobiledeviceportrait(new D3Element(parent), node, node).node(),\n\tmobiledevice: (parent: SVGElement, node: D3Node) => mobiledeviceportrait(new D3Element(parent), node, node).node(),\n\tpipe: (parent: SVGElement, node: D3Node) => pipe(new D3Element(parent), node, node).node(),\n\trobot: (parent: SVGElement, node: D3Node) => robot(new D3Element(parent), node, node).node(),\n\twebbrowser: (parent: SVGElement, node: D3Node) => webbrowser(new D3Element(parent), node, node).node(),\n}\n","/**\n * Undo functionality\n * at every change in the document, Undo can save a new version\n * so the user can \"undo\" and \"redo\" changes by reverting to an\n * older version of the document\n */\n\nexport class Undo {\n\tprivate readonly versions: Doc[] = [];\n\tprivate pos: number = 0;\n\tprivate lastSavedPos: number = 0;\n\tprivate readonly exportDoc: () => Doc;\n\tprivate readonly importDoc: (d: Doc) => void;\n\tchange: () => void;\n\tprivate tmpPreviousState: Doc | null = null;\n\n\tconstructor(id: string, exportDoc: () => Doc, importDoc: (d: Doc) => void) {\n\t\tthis.exportDoc = exportDoc;\n\t\tthis.importDoc = importDoc;\n\t\tthis.change = debounce(() => this.saveNow(), 300);\n\t}\n\n\t// Store the state previous to the changes collected in the debounce period\n\tbeforeChange() {\n\t\tif (!this.tmpPreviousState) {\n\t\t\tthis.tmpPreviousState = this.deepClone(this.exportDoc());\n\t\t}\n\t}\n\n\tlength() {\n\t\treturn this.versions.length;\n\t}\n\n\tcurrentState() {\n\t\treturn this.deepClone(this.versions[this.pos - 1]);\n\t}\n\n\tprivate saveNow() {\n\t\tif (!this.tmpPreviousState) {\n\t\t\tthrow Error(\"undo.change() was called without previously calling undo.beforeChange()!\");\n\t\t}\n\t\t\n\t\tthis.versions[this.pos] = this.deepClone(this.exportDoc());\n\t\tthis.versions[this.pos - 1] = this.tmpPreviousState;\n\t\tthis.tmpPreviousState = null;\n\t\tthis.pos += 1;\n\t\t\n\t\t// Remove anything that might be on top of this version\n\t\tthis.versions.splice(this.pos);\n\t}\n\n\tprivate deepClone(doc: Doc): Doc {\n\t\t// Use modern structuredClone if available, fallback to JSON\n\t\tif (typeof structuredClone !== 'undefined') {\n\t\t\treturn structuredClone(doc);\n\t\t}\n\t\treturn JSON.parse(JSON.stringify(doc));\n\t}\n\n\tundo() {\n\t\tif (this.pos < 2) return;\n\t\tthis.pos -= 1;\n\t\tconst doc = this.versions[this.pos - 1];\n\t\tthis.importDoc(this.deepClone(doc));\n\t}\n\n\tredo() {\n\t\tif (this.pos > this.versions.length - 1) return;\n\t\tconst doc = this.versions[this.pos];\n\t\tthis.importDoc(this.deepClone(doc));\n\t\tthis.pos += 1;\n\t}\n\n\tchanged() {\n\t\treturn this.pos !== this.lastSavedPos;\n\t}\n\n\tsetSaved() {\n\t\tthis.lastSavedPos = this.pos;\n\t}\n}\n\nfunction debounce(func: () => void, wait: number) {\n\tlet timeout: ReturnType;\n\treturn function () {\n\t\tconst context = this;\n\t\tconst later = function () {\n\t\t\ttimeout = null;\n\t\t\tfunc.apply(context);\n\t\t};\n\t\tclearTimeout(timeout);\n\t\ttimeout = setTimeout(later, wait);\n\t};\n}","import {applyStyle, NodeStyle, SVG_STYLES} from \"./constants\";\nimport {create} from \"./svg-create\";\nimport {svgTextWrap} from \"./svg-text\";\n\ninterface TextBlockLayout {\n\tlines: string[];\n\tfontSize: number;\n\tlineHeight: number;\n\tbold: boolean;\n\tfield?: string;\n\tgapAfter: number;\n}\n\nexport interface NodeContentLayout {\n\tblocks: TextBlockLayout[];\n\ttextHeight: number;\n\tminimumHeight: number;\n\t// The icon shares the content stack so text never draws over it.\n\ticon?: string;\n}\n\nconst HORIZONTAL_PADDING = 18;\nconst VERTICAL_PADDING = 18;\nconst TITLE_GAP = 6;\nconst METADATA_GAP = 10;\nconst ICON_SIZE = 32;\nconst ICON_GAP = 12;\n\nfunction textBlock(\n\ttext: string,\n\twidth: number,\n\tfontSize: number,\n\tbold: boolean,\n\tgapAfter: number,\n\tfield?: string,\n): TextBlockLayout {\n\tconst attrs = {\n\t\t\"font-family\": String(SVG_STYLES.nodeText[\"font-family\"]),\n\t\t\"font-size\": `${fontSize}px`,\n\t\t\"font-weight\": bold ? \"bold\" : \"normal\",\n\t};\n\tconst wrapped = svgTextWrap(text, width, attrs);\n\tconst lines = wrapped.lines.length > 0 ? wrapped.lines : [\"\"];\n\n\treturn {\n\t\tlines,\n\t\tfontSize,\n\t\tlineHeight: fontSize + 2,\n\t\tbold,\n\t\tfield,\n\t\tgapAfter,\n\t};\n}\n\nexport function layoutNodeContent(\n\ttitle: string,\n\tsubtitle: string,\n\tdescription: string,\n\tnodeWidth: number,\n\tfontSize: number,\n\tstyle: NodeStyle,\n): NodeContentLayout {\n\tconst textWidth = Math.max(nodeWidth - HORIZONTAL_PADDING * 2, 80);\n\tconst blocks = [textBlock(title, textWidth, fontSize, true, TITLE_GAP, \"name\")];\n\tif (style.metadata !== false && subtitle) {\n\t\tblocks.push(textBlock(`[${subtitle}]`, textWidth, fontSize * 0.7, false, METADATA_GAP));\n\t}\n\tif (style.description !== false && description) {\n\t\tblocks.push(textBlock(description, textWidth, Math.min(fontSize * 0.8, 16), false, 0, \"description\"));\n\t}\n\tblocks[blocks.length - 1].gapAfter = 0;\n\tconst textHeight = blocks.reduce(\n\t\t(height, block) => height + block.lines.length * block.lineHeight + block.gapAfter,\n\t\t0,\n\t);\n\n\treturn {\n\t\tblocks,\n\t\ttextHeight,\n\t\tminimumHeight: textHeight + VERTICAL_PADDING * 2 + (style.icon ? ICON_SIZE + ICON_GAP : 0),\n\t\ticon: style.icon,\n\t};\n}\n\nexport function buildNodeContent(layout: NodeContentLayout, color?: string): SVGGElement {\n\tconst group = create.element(\"g\") as SVGGElement;\n\tconst iconHeight = layout.icon ? ICON_SIZE + ICON_GAP : 0;\n\tlet top = -(layout.textHeight + iconHeight) / 2;\n\tif (layout.icon) {\n\t\tgroup.append(create.element(\"image\", {\n\t\t\thref: layout.icon,\n\t\t\tx: -ICON_SIZE / 2,\n\t\t\ty: top,\n\t\t\twidth: ICON_SIZE,\n\t\t\theight: ICON_SIZE,\n\t\t\tpreserveAspectRatio: \"xMidYMid meet\",\n\t\t}, \"nodeIcon\"));\n\t\ttop += iconHeight;\n\t}\n\n\tlayout.blocks.forEach((block) => {\n\t\tconst text = create.text(\"\", {\"text-anchor\": \"middle\"});\n\t\tapplyStyle(text, SVG_STYLES.nodeText);\n\t\tif (color) {\n\t\t\ttext.setAttribute(\"fill\", color);\n\t\t}\n\t\tif (block.field) {\n\t\t\ttext.setAttribute(\"data-field\", block.field);\n\t\t}\n\n\t\tblock.lines.forEach((line, index) => {\n\t\t\tconst span = create.element(\"tspan\", {\n\t\t\t\tx: 0,\n\t\t\t\ty: top + block.fontSize + index * block.lineHeight,\n\t\t\t\t\"font-size\": `${block.fontSize}px`,\n\t\t\t\t\"font-weight\": block.bold ? \"bold\" : \"normal\",\n\t\t\t});\n\t\t\tspan.textContent = line;\n\t\t\ttext.append(span);\n\t\t});\n\n\t\tgroup.append(text);\n\t\ttop += block.lines.length * block.lineHeight + block.gapAfter;\n\t});\n\n\treturn group;\n}\n","import {defs} from \"./defs\";\nimport {create, setPosition} from \"./svg-create\";\nimport {cursorInteraction} from \"svg-editor-tools/lib/cursor-interaction\";\nimport {shapeLabelOffsetY, shapes} from \"./shapes\";\nimport {\n\tboxesOverlap,\n\tcabDistance,\n\tinsideBox,\n\tintersectPolylineBox,\n\tproject,\n\tscaleBox,\n\tSegment,\n\tuncenterBox\n} from \"./intersect\";\nimport {autoLayout, LayoutOptions, validateCurrentLayout} from \"./layout\";\nimport {Undo} from \"./undo\";\nimport {\n\tADD_LABEL_VERTEX,\n\tADD_VERTEX,\n\tDEL_VERTEX,\n\tDESELECT,\n\tfindShortcut,\n\tREDO,\n\tSELECT_ALL,\n\tUNDO,\n\tZOOM_100,\n\tZOOM_FIT,\n\tZOOM_IN,\n\tZOOM_OUT\n} from \"../shortcuts\";\nimport {\n\tPoint,\n\tBBox,\n\tNodeStyle,\n\tEdgeStyle,\n\tDEFAULT_EDGE_STYLE,\n\tDEFAULT_NODE_STYLE,\n\tSVG_STYLES,\n\tSVG_PADDING,\n\tDEFAULT_GRID_SIZE,\n\tapplyStyle\n} from \"./constants\";\nimport {\n\tcalculateEdgeVertices,\n\tcalculateLabelPlacement,\n\tcreateEdgePath,\n\tEdgeLabelPlacement\n} from \"./edge-utils\";\nimport {\n\tbuildNodeContent,\n\tlayoutNodeContent,\n\tNodeContentLayout\n} from \"./node-content\";\nimport {ValidatedLayout} from \"./geometry\";\n\n\n// Point and BBox interfaces are now imported from constants\n\nexport interface Group extends BBox {\n\tid: string;\n\tname: string;\n\tnodes: (Node | Group)[];\n\tref?: SVGGElement;\n\tstyle: NodeStyle;\n\tlayoutBounds?: BBox;\n\tlayoutTitleBounds?: BBox;\n}\n\nexport interface NodeLink {\n\thref: string;\n\texportHref: string;\n}\n\nexport type LayoutDirection = 'UP' | 'DOWN' | 'LEFT' | 'RIGHT';\n\nexport interface Node extends BBox {\n\tid: string;\n\ttitle: string;\n\tsub: string;\n\tdescription: string;\n\n\tref?: SVGGElement;\n\tselected?: boolean;\n\n\tintersect: (p: Point) => Point\n\n\tstyle: NodeStyle\n\tlink?: NodeLink\n\tcontentLayout: NodeContentLayout\n}\n\n// NodeStyle interface is now imported from constants\n\n// EdgeStyle interface is now imported from constants\n\n// Default styles are now imported from constants\nconst defaultEdgeStyle = DEFAULT_EDGE_STYLE;\nconst defaultNodeStyle = DEFAULT_NODE_STYLE;\n\n// Edge and EdgeVertex interfaces are now defined in edge-utils.ts\n// Using local interfaces for compatibility with existing code\nexport interface Edge {\n\tid: string;\n\tlabel: string;\n\tfrom: Node;\n\tto: Node;\n\tvertices?: EdgeVertex[];\n\tref?: SVGGElement;\n\tstyle: EdgeStyle;\n\tinitVertex: (p: Point) => EdgeVertex;\n\tuserDeletedVertices?: boolean; // Track if user explicitly deleted vertices\n\tlabelVertex?: EdgeVertex; // ELK-calculated label position (separate from routing vertices)\n\tlabelBounds?: BBox;\n\tlayoutSections?: Point[][];\n\tlayoutLabelBounds?: BBox;\n}\n\ninterface EdgeVertex extends Point {\n\tid: string\n\tselected?: boolean\n\tedge: Edge\n\tref?: SVGElement\n\tlabel?: boolean\n\tauto?: boolean\n}\n\ninterface SavedEdgePoint extends Point {\n\tlabel?: boolean;\n\tauto?: boolean;\n}\n\ninterface Layout {\n\t[k: string]: Point | SavedEdgePoint[] | boolean\n}\n\nexport class GraphData {\n\tid: string;\n\tname: string;\n\tnodesMap: Map;\n\tedges: Edge[];\n\tedgeVertices: Map\n\tgroupsMap: Map;\n\tmetadata: any;\n\tlayoutDirection?: LayoutDirection;\n\tvalidatedLayout?: ValidatedLayout;\n\tcolorToVarMap: Map = new Map(); // For CSS custom properties theming\n\tprivate _undo: Undo;\n\tprivate _gridVisible: boolean = false;\n\tprivate _snapToGrid: boolean = true;\n\tprivate _gridSize: number = 25;\n\tprivate _skipAutoFit: boolean = false;\n\n\tconstructor(id?: string, name?: string) {\n\t\tthis.id = id;\n\t\tthis.name = name;\n\n\t\tthis.edges = [];\n\t\tthis.edgeVertices = new Map;\n\t\tthis.nodesMap = new Map;\n\t\tthis.groupsMap = new Map;\n\n\t\tthis._undo = new Undo(\n\t\t\tthis.id,\n\t\t\t() => this.exportLayout(true),\n\t\t\t(lo) => this.importLayout(lo, true)\n\t\t)\n\n\t\t// @ts-ignore\n\t\twindow.graph = this\n\t}\n\n\t// after the graph model is build using addNode, addEdge etc, initialize\n\tinit(layout?: Layout) {\n\t\tlayout && this.importLayout(layout)\n\t\tthis._undo = new Undo(\n\t\t\tthis.id,\n\t\t\t() => this.exportLayout(true),\n\t\t\t(lo) => this.importLayout(lo, true)\n\t\t)\n\t\tif (this._undo.length()) {\n\t\t\tthis.importLayout(this._undo.currentState())\n\t\t}\n\t\t\n\t\t// Save initial state so first action is undoable\n\t\tthis._undo.beforeChange()\n\t\tthis._undo.change()\n\t}\n\n\taddNode(id: string, label: string, sub: string, description: string, style: NodeStyle, link?: NodeLink) {\n\t\tif (this.nodesMap.has(id)) throw Error('duplicate node: ' + id)\n\t\tconst nodeStyle = {...defaultNodeStyle, ...style};\n\t\tconst shape = (nodeStyle.shape || 'Box').toLowerCase();\n\t\tconst minimumWidth = 280;\n\t\tconst minimumHeight = shape === 'person' ? 240 : 180;\n\t\tconst width = Math.max(minimumWidth, nodeStyle.width || 0);\n\t\tconst fontSize = nodeStyle.fontSize || 22;\n\t\tconst contentLayout = layoutNodeContent(label, sub, description, width, fontSize, nodeStyle);\n\t\tlet height = Math.max(minimumHeight, nodeStyle.height || 0, contentLayout.minimumHeight);\n\n\t\t// Some shapes shift labels down to reserve visual space for an icon,\n\t\t// header, or curved edge. Grow until the shifted content also fits.\n\t\tfor (let i = 0; i < 20; i++) {\n\t\t\tconst requiredHeight = contentLayout.minimumHeight +\n\t\t\t\tMath.abs(shapeLabelOffsetY(shape, width, height));\n\t\t\tif (requiredHeight <= height + 0.1) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\theight = requiredHeight;\n\t\t}\n\n\t\tconst n: Node = {\n\t\t\tid, title: label, sub, description, style: nodeStyle,\n\t\t\tx: 0, y: 0, width, height, intersect: null, link, contentLayout\n\t\t}\n\t\tthis.nodesMap.set(n.id, n)\n\t}\n\n\tnodes() {\n\t\treturn Array.from(this.nodesMap.values())\n\t}\n\n\taddEdge(id: string, fromNode: string, toNode: string, label: string, vertices: Point[], style: EdgeStyle) {\n\t\tvertices && vertices.forEach((p, i) => {\n\t\t\tconst v = p as EdgeVertex\n\t\t\tv.id = `v-${id}-${i}`\n\t\t\tthis.edgeVertices.set(v.id, v)\n\t\t})\n\t\t// Deterministic vertex IDs.\n\t\t//\n\t\t// `mdl svg` renders diagrams headlessly and saves the resulting SVG. If we\n\t\t// generate random vertex IDs, the SVG changes on every run even when the\n\t\t// underlying model and layout are unchanged. Use a stable hash instead.\n\t\tconst fnv1a36 = (input: string) => {\n\t\t\tlet h = 0x811c9dc5\n\t\t\tfor (let i = 0; i < input.length; i++) {\n\t\t\t\th ^= input.charCodeAt(i)\n\t\t\t\th = Math.imul(h, 0x01000193)\n\t\t\t}\n\t\t\treturn (h >>> 0).toString(36)\n\t\t}\n\t\tconst stableVertexID = (edgeID: string, p: Point) => {\n\t\t\tconst x = (p as any).x\n\t\t\tconst y = (p as any).y\n\t\t\treturn `v-${edgeID}-a-${fnv1a36(`${edgeID}:${x}:${y}`)}`\n\t\t}\n\t\tconst initVertex = (p: Point) => {\n\t\t\tconst v = p as EdgeVertex\n\t\t\tif (!v.id) {\n\t\t\t\tv.id = stableVertexID(edge.id, p)\n\t\t\t\tthis.edgeVertices.set(v.id, v)\n\t\t\t}\n\t\t\tv.edge = edge\n\t\t\treturn p as EdgeVertex\n\t\t}\n\t\tconst edge = {\n\t\t\tid,\n\t\t\tfrom: this.nodesMap.get(fromNode),\n\t\t\tto: this.nodesMap.get(toNode),\n\t\t\tlabel,\n\t\t\tvertices: null as EdgeVertex[],\n\t\t\tstyle: {...defaultEdgeStyle, ...style},\n\t\t\tinitVertex,\n\t\t\tuserDeletedVertices: false\n\t\t}\n\t\tthis.edges.push(edge)\n\t\tif (vertices) {\n\t\t\tedge.vertices = vertices.map(p => edge.initVertex(p))\n\t\t}\n\t}\n\n\taddGroup(id: string, name: string, nodesOrGroups: string[], style: NodeStyle) {\n\t\tif (this.groupsMap.has(id)) {\n\t\t\tconsole.error(`Group exists: ${id} ${name}`)\n\t\t\treturn\n\t\t}\n\t\tconst group: Group = {\n\t\t\tid, name, x: null, y: null, width: null, height: null,\n\t\t\tnodes: nodesOrGroups.map(k => {\n\t\t\t\tconst n = this.nodesMap.get(k) || this.groupsMap.get(k)\n\t\t\t\tif (!n) console.error(`Node or group ${k} not found for group ${id} \"${name}\"`)\n\t\t\t\treturn n\n\t\t\t}).filter(Boolean),\n\t\t\tstyle\n\t\t}\n\t\tthis.groupsMap.set(id, group)\n\t}\n\n\t// private rebuildNode(node: Node) {\n\t// \tconst p = node.ref.parentElement;\n\t// \tp.removeChild(node.ref)\n\t// \tnode.ref = buildNode(node, this)\n\t// \tp.appendChild(node.ref)\n\t// \tthis.redrawEdges(node)\n\t// \tthis.redrawGroups(node)\n\t// }\n\n\tsetNodeSelected(node: Node, selected: boolean) {\n\t\tnode.selected = selected\n\t\tselected ?\n\t\t\tnode.ref.classList.add('selected') :\n\t\t\tnode.ref.classList.remove('selected')\n\t\tthis.updateEdgesSel()\n\t}\n\n\tprivate updateEdgesSel() {\n\t\tthis.edges.forEach(e => {\n\t\t\tif (e.to.selected || e.from.selected) {\n\t\t\t\te.ref.classList.add('selected')\n\t\t\t} else {\n\t\t\t\te.ref.classList.remove('selected')\n\t\t\t}\n\t\t})\n\t}\n\n\t/** clearResolvedLayout returns drawing to manual mode after any user edit. */\n\tprivate clearResolvedLayout() {\n\t\tthis.validatedLayout = undefined\n\t\tthis.edges.forEach(edge => {\n\t\t\tedge.layoutSections = undefined\n\t\t\tedge.layoutLabelBounds = undefined\n\t\t})\n\t\tthis.groupsMap.forEach(group => {\n\t\t\tgroup.layoutBounds = undefined\n\t\t\tgroup.layoutTitleBounds = undefined\n\t\t})\n\t}\n\n\tmoveNode(n: Node, x: number, y: number, disableSnap: boolean = false, skipUndo: boolean = false) {\n\t\tif (!n) return\n\t\t\n\t\t// Apply snap-to-grid if enabled and not explicitly disabled\n\t\tif (this._snapToGrid && !disableSnap) {\n\t\t\tconst snapped = this.snapToGrid(x, y);\n\t\t\tx = snapped.x;\n\t\t\ty = snapped.y;\n\t\t}\n\t\t\n\t\tif (n.x == x && n.y == y) return\n\t\t\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.beforeChange()\n\t\t}\n\t\tthis.clearResolvedLayout()\n\t\tn.x = x;\n\t\tn.y = y;\n\t\tsetPosition(n.ref, x, y)\n\t\tthis.redrawEdges(n);\n\t\tthis.redrawGroups(n)\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.change()\n\t\t}\n\t}\n\n\tmoveEdgeVertex(v: EdgeVertex, x: number, y: number, disableSnap: boolean = false, skipUndo: boolean = false) {\n\t\t\n\t\tif (this._snapToGrid && !disableSnap) {\n\t\t\tconst snapped = this.snapToGrid(x, y);\n\t\t\tx = snapped.x;\n\t\t\ty = snapped.y;\n\t\t}\n\t\t// Use exact coordinates (no rounding needed with modern grid system)\n\t\t\n\t\tif (v.x == x && v.y == y) return\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.beforeChange()\n\t\t}\n\t\tthis.clearResolvedLayout()\n\t\tv.x = x;\n\t\tv.y = y;\n\t\tthis.redrawEdge(v.edge)\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.change()\n\t\t}\n\t}\n\n\tmoveSelected(dx: number, dy: number, disableSnap: boolean = false) {\n\t\tthis.nodes().forEach(n => n.selected && this.moveNode(n, n.x + dx, n.y + dy, disableSnap, false))\n\t\tthis.edgeVertices.forEach(v => v.selected && this.moveEdgeVertex(v, v.x + dx, v.y + dy, disableSnap, false))\n\t}\n\n\tinsertEdgeVertex(edge: Edge, p: Point, pos: number, isLabel: boolean) {\n\t\tthis._undo.beforeChange()\n\t\tthis.clearResolvedLayout()\n\t\tconst v = edge.initVertex(p)\n\t\tv.selected = true\n\t\tif (isLabel) { // when shift down, make it label position\n\t\t\tedge.vertices.forEach(v => v.label = false)\n\t\t\tv.label = true\n\t\t}\n\t\tedge.vertices.splice(pos - 1, 0, v)\n\t\tthis.redrawEdge(edge)\n\t\tthis._undo.change()\n\t}\n\n\tdeleteEdgeVertex(v: EdgeVertex) {\n\t\tthis._undo.beforeChange()\n\t\tthis.clearResolvedLayout()\n\t\t\n\t\tconst index = v.edge.vertices.indexOf(v)\n\t\tif (index >= 0) {\n\t\t\tv.edge.vertices.splice(index, 1)\n\t\t\tthis.edgeVertices.delete(v.id)\n\t\t\t\n\t\t\t// Mark that user explicitly deleted vertices from this edge\n\t\t\tv.edge.userDeletedVertices = true\n\t\t}\n\t\t\n\t\tthis.redrawEdge(v.edge)\n\t\tthis._undo.change()\n\t}\n\n\tchanged() {\n\t\treturn this._undo.changed()\n\t}\n\n\tundo() {\n\t\tthis._undo.undo()\n\t}\n\n\tredo() {\n\t\tthis._undo.redo()\n\t}\n\n\t// moves the entire graph to be aligned top-left of the drawing area\n\t// used to bring back to visible the nodes that end up at negative coordinates\n\talignTopLeft() {\n\t\tconst contentBounds = this.calculateContentBounds()\n\t\tconst padding = 100 // Reasonable padding for viewport\n\t\t\n\t\tconst offsetX = -contentBounds.x + padding\n\t\tconst offsetY = -contentBounds.y + padding\n\t\t\n\t\t// Set flag to prevent React useEffect from calling fitToView during this operation\n\t\tthis._skipAutoFit = true\n\t\t\n\t\tthis._undo.beforeChange()\n\t\t\n\t\tthis.nodesMap.forEach(node => {\n\t\t\tthis.moveNode(node, node.x + offsetX, node.y + offsetY, true, true) // Disable snap and undo during reset\n\t\t})\n\t\t\n\t\tthis.edgeVertices.forEach(vertex => {\n\t\t\tthis.moveEdgeVertex(vertex, vertex.x + offsetX, vertex.y + offsetY, true, true) // Disable snap and undo during reset\n\t\t})\n\t\t\n\t\tthis._undo.change()\n\t\t\n\t\t// DON'T clear view state here - let resetPanTransform handle it to avoid React useEffect recursion\n\t}\n\t\n\t// Reset pan transform to (0,0) while preserving zoom\n\tresetPanTransform() {\n\t\tconst currentZoom = getZoom()\n\t\tconst zoomGroup = svg.querySelector('g.zoom') as SVGGElement\n\t\tif (zoomGroup) {\n\t\t\tzoomGroup.setAttribute('transform', `scale(${currentZoom}) translate(0, 0)`)\n\t\t\tupdatePanningOptimized(this)\n\t\t}\n\t\t\n\t\t// Clear view state so this reset is not overridden\n\t\tclearViewState(this.id)\n\t\t\n\t\t// Reset the skip auto fit flag after reset is complete\n\t\tthis._skipAutoFit = false\n\t}\n\t\n\t// Check if auto-fit should be skipped (used by React useEffect)\n\tshouldSkipAutoFit(): boolean {\n\t\treturn this._skipAutoFit\n\t}\n\n\t// Reset view to default state: 100% zoom, centered at origin\n\tresetView() {\n\t\tconst zoomGroup = svg.querySelector('g.zoom') as SVGGElement\n\t\tif (zoomGroup) {\n\t\t\t// Reset to 100% zoom, centered at origin\n\t\t\tzoomGroup.setAttribute('transform', 'scale(1) translate(0, 0)')\n\t\t\tupdatePanning()\n\t\t}\n\t\t\n\t\t// Clear any saved view state so this reset position is not overridden\n\t\tclearViewState(this.id)\n\t}\n\n\t//redraw connected edges\n\tprivate redrawEdges(n: Node) {\n\t\tthis.edges.forEach(e => (n == e.from || n == e.to) && this.redrawEdge(e))\n\t\tthis.updateEdgesSel()\n\t}\n\n\tredrawEdge(e: Edge) {\n\t\tconst p = e.ref.parentElement;\n\t\tp.removeChild(e.ref)\n\t\te.ref = buildEdge(e)\n\t\tp.append(e.ref)\n\t}\n\n\tprivate redrawGroups(node: Node) {\n\t\tthis.groupsMap.forEach(group => {\n\t\t\t//if (group.nodes.indexOf(node) == -1) return\n\t\t\tconst p = group.ref.parentElement\n\t\t\tp.removeChild(group.ref)\n\t\t\tbuildGroup(group)\n\t\t\tp.append(group.ref)\n\t\t})\n\t}\n\n\texportSVG() {\n\t\tif (!this.validatedLayout) {\n\t\t\tthis.validatedLayout = validateCurrentLayout(this)\n\t\t}\n\t\t// Get the original SVG\n\t\tconst originalSvg: SVGSVGElement = document.querySelector('svg#graph')\n\t\tconst elastic = originalSvg.querySelector('rect.elastic')\n\t\t\n\t\t// Clone the SVG for export (completely separate from the live one)\n\t\tconst exportSvg = originalSvg.cloneNode(true) as SVGSVGElement\n\n\t\t// Standalone SVGs navigate to sibling view files instead of editor routes.\n\t\texportSvg.querySelectorAll('a.nodeLink[data-export-href]').forEach(link => {\n\t\t\tlink.setAttribute('href', link.getAttribute('data-export-href') || '')\n\t\t\tlink.removeAttribute('data-export-href')\n\t\t})\n\t\t\n\t\t// Remove elastic element from export\n\t\tconst exportElastic = exportSvg.querySelector('rect.elastic')\n\t\tif (exportElastic) {\n\t\t\texportElastic.remove()\n\t\t}\n\t\t\n\t\t// Export the exact bounds that passed geometry validation. Recomputing\n\t\t// them here can omit routed relationship labels from the SVG canvas.\n\t\tconst contentBounds = this.validatedLayout.bounds\n\t\t\n\t\t// Add padding around content\n\t\tconst padding = 50\n\t\t\n\t\t// Calculate final export dimensions (always positive)\n\t\tconst exportWidth = contentBounds.width + (padding * 2)\n\t\tconst exportHeight = contentBounds.height + (padding * 2)\n\t\t\n\t\t// Calculate offset to move content to start at (padding, padding) within the export area\n\t\tconst offsetX = -contentBounds.x + padding\n\t\tconst offsetY = -contentBounds.y + padding\n\t\t\n\t\t// Apply export positioning to the cloned SVG elements\n\t\tconst exportZoomGroup = exportSvg.querySelector('g.zoom') as SVGGElement\n\t\tif (exportZoomGroup) {\n\t\t\t// Reset zoom to 1 and apply offset transform to position content properly\n\t\t\texportZoomGroup.setAttribute('transform', `scale(1) translate(${offsetX}, ${offsetY})`)\n\t\t}\n\t\t\n\t\t// Set proper viewBox and dimensions for export - viewBox always starts at (0,0)\n\t\texportSvg.setAttribute('viewBox', `0 0 ${exportWidth} ${exportHeight}`)\n\t\texportSvg.setAttribute('width', String(exportWidth))\n\t\texportSvg.setAttribute('height', String(exportHeight))\n\t\t\n\t\t// Add required SVG namespace for browser compatibility\n\t\texportSvg.setAttribute('xmlns', 'http://www.w3.org/2000/svg')\n\t\t\n\t\t// Convert inline styles to CSS custom properties for theming support\n\t\tthis.convertStylesToCustomProperties(exportSvg)\n\t\t\n\t\t// Inject metadata with current layout\n\t\tconst script = document.createElement('script')\n\t\tscript.setAttribute('type', 'application/json')\n\t\tthis.metadata.layout = this.exportLayout()\n\t\tscript.append('')\n\t\texportSvg.insertBefore(script, exportSvg.firstChild)\n\t\t\n\t\t// Get the export SVG as string\n\t\tconst src = exportSvg.outerHTML\n\t\t\n\t\t// No restoration needed since we never touched the original SVG!\n\t\treturn src\n\t}\n\n\t// Convert inline fill/stroke attributes to CSS custom properties with fallbacks.\n\t// This enables theming: container pages can override colors via CSS variables.\n\tprivate convertStylesToCustomProperties(svg: SVGSVGElement) {\n\t\tif (this.colorToVarMap.size === 0) return\n\n\t\t// Process all elements with fill attribute\n\t\tsvg.querySelectorAll('[fill]').forEach(el => {\n\t\t\tconst fill = el.getAttribute('fill')\n\t\t\tif (fill && this.colorToVarMap.has(fill)) {\n\t\t\t\tel.setAttribute('fill', `var(${this.colorToVarMap.get(fill)}, ${fill})`)\n\t\t\t}\n\t\t})\n\n\t\t// Process all elements with stroke attribute\n\t\tsvg.querySelectorAll('[stroke]').forEach(el => {\n\t\t\tconst stroke = el.getAttribute('stroke')\n\t\t\tif (stroke && this.colorToVarMap.has(stroke)) {\n\t\t\t\tel.setAttribute('stroke', `var(${this.colorToVarMap.get(stroke)}, ${stroke})`)\n\t\t\t}\n\t\t})\n\t}\n\n\t// Calculate the actual bounds of all content including nodes, edges, and groups\n\tcalculateContentBounds(): BBox {\n\t\tlet minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity\n\t\t\n\t\t// Process nodes (including their actual dimensions)\n\t\tthis.nodes().forEach(node => {\n\t\t\tconst left = node.x - node.width / 2\n\t\t\tconst right = node.x + node.width / 2\n\t\t\tconst top = node.y - node.height / 2\n\t\t\tconst bottom = node.y + node.height / 2\n\t\t\t\n\t\t\tminX = Math.min(minX, left)\n\t\t\tmaxX = Math.max(maxX, right)\n\t\t\tminY = Math.min(minY, top)\n\t\t\tmaxY = Math.max(maxY, bottom)\n\t\t})\n\t\t\n\t\t// Process edge vertices (much faster than complex label calculations)\n\t\tthis.edgeVertices.forEach(vertex => {\n\t\t\tminX = Math.min(minX, vertex.x - 5)\n\t\t\tmaxX = Math.max(maxX, vertex.x + 5)\n\t\t\tminY = Math.min(minY, vertex.y - 5)\n\t\t\tmaxY = Math.max(maxY, vertex.y + 5)\n\t\t})\n\t\t\n\t\t// Process groups\n\t\tthis.groupsMap.forEach(group => {\n\t\t\tconst left = group.x - group.width / 2\n\t\t\tconst right = group.x + group.width / 2\n\t\t\tconst top = group.y - group.height / 2\n\t\t\tconst bottom = group.y + group.height / 2\n\t\t\t\n\t\t\tminX = Math.min(minX, left)\n\t\t\tmaxX = Math.max(maxX, right)\n\t\t\tminY = Math.min(minY, top)\n\t\t\tmaxY = Math.max(maxY, bottom)\n\t\t})\n\t\t\n\t\t// Process edges (simplified - just endpoints and vertices, skip complex label calculations)\n\t\tthis.edges.forEach(edge => {\n\t\t\t// Edge endpoints\n\t\t\tminX = Math.min(minX, edge.from.x - 10, edge.to.x - 10)\n\t\t\tmaxX = Math.max(maxX, edge.from.x + 10, edge.to.x + 10)\n\t\t\tminY = Math.min(minY, edge.from.y - 10, edge.to.y - 10)\n\t\t\tmaxY = Math.max(maxY, edge.from.y + 10, edge.to.y + 10)\n\t\t\t\n\t\t\t// Edge vertices (if any)\n\t\t\tif (edge.vertices) {\n\t\t\t\tedge.vertices.forEach(vertex => {\n\t\t\t\t\tminX = Math.min(minX, vertex.x - 10)\n\t\t\t\t\tmaxX = Math.max(maxX, vertex.x + 10)\n\t\t\t\t\tminY = Math.min(minY, vertex.y - 10)\n\t\t\t\t\tmaxY = Math.max(maxY, vertex.y + 10)\n\t\t\t\t})\n\t\t\t}\n\t\t\t\n\t\t\t// Simplified label bounds (avoid expensive path calculations)\n\t\t\tif (edge.label && edge.label.trim()) {\n\t\t\t\t// Just use approximate center between from and to nodes\n\t\t\t\tconst centerX = (edge.from.x + edge.to.x) / 2\n\t\t\t\tconst centerY = (edge.from.y + edge.to.y) / 2\n\t\t\t\tconst approxLabelSize = edge.label.length * 10 + 50 // Rough estimate\n\t\t\t\t\n\t\t\t\tminX = Math.min(minX, centerX - approxLabelSize)\n\t\t\t\tmaxX = Math.max(maxX, centerX + approxLabelSize)\n\t\t\t\tminY = Math.min(minY, centerY - 25)\n\t\t\t\tmaxY = Math.max(maxY, centerY + 25)\n\t\t\t}\n\t\t})\n\t\t\n\t\t// Handle empty graph\n\t\tif (minX === Infinity) {\n\t\t\treturn { x: 0, y: 0, width: 100, height: 100 }\n\t\t}\n\t\t\n\t\treturn {\n\t\t\tx: minX,\n\t\t\ty: minY,\n\t\t\twidth: maxX - minX,\n\t\t\theight: maxY - minY\n\t\t}\n\t}\n\n\n\n\t/**\n\t * @param full when true, the edges without vertices are saved too, used for undo buffer\n\t * for saving, full is false\n\t */\n\texportLayout(full = false) {\n\t\tconst ret: Layout = {}\n\t\tthis.nodes().forEach(n => ret[n.id] = {x: n.x, y: n.y})\n\t\tthis.edges.forEach(e => {\n\t\t\tif (!e.vertices) return\n\t\t\t// Save all vertices (both user and auto-generated), preserving their properties\n\t\t\tconst lst = e.vertices.map(v => ({\n\t\t\t\tx: v.x, \n\t\t\t\ty: v.y, \n\t\t\t\tlabel: v.label,\n\t\t\t\tauto: v.auto // Preserve auto flag so we know which are ELK-generated\n\t\t\t}));\n\t\t\tif (lst.length || full) {\n\t\t\t\tret[`e-${e.id}`] = lst\n\t\t\t}\n\t\t\t// Also save the userDeletedVertices flag as metadata\n\t\t\tif (e.userDeletedVertices) {\n\t\t\t\tret[`e-${e.id}-deleted`] = true\n\t\t\t}\n\t\t})\n\t\treturn ret\n\t}\n\n\tsetSaved() {\n\t\tthis._undo.setSaved()\n\t}\n\n\timportLayout(layout: Layout, rerender = false) {\n\t\tthis.clearResolvedLayout()\n\t\tfor (const [k, v] of Object.entries(layout)) {\n\t\t\tconst n = this.nodesMap.get(k)\n\t\t\tif (n) {\n\t\t\t\tconst point = requiredSavedPoint(k, v)\n\t\t\t\tn.x = point.x\n\t\t\t\tn.y = point.y\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (k.endsWith('-deleted')) {\n\t\t\t\tconst edgeId = k.slice(2, -8); // Remove 'e-' prefix and '-deleted' suffix\n\t\t\t\tconst edge = this.edges.find(candidate => candidate.id === edgeId)\n\t\t\t\tif (!edge || v !== true) {\n\t\t\t\t\tthrow new Error(`invalid deleted-edge layout entry ${k}`)\n\t\t\t\t}\n\t\t\t\tedge.userDeletedVertices = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (k.startsWith('e-')) {\n\t\t\t\tconst edge = this.edges.find(candidate => candidate.id === k.slice(2))\n\t\t\t\tif (!edge || !Array.isArray(v)) {\n\t\t\t\t\tthrow new Error(`invalid edge layout entry ${k}`)\n\t\t\t\t}\n\t\t\t\tfor (const vertex of edge.vertices ?? []) {\n\t\t\t\t\tthis.edgeVertices.delete(vertex.id)\n\t\t\t\t}\n\t\t\t\tedge.vertices = v.map((saved, index) => {\n\t\t\t\t\tconst point = requiredSavedPoint(`${k}[${index}]`, saved)\n\t\t\t\t\tconst vertex = edge.initVertex(point)\n\t\t\t\t\tvertex.label = saved.label\n\t\t\t\t\tvertex.auto = saved.auto\n\t\t\t\t\treturn vertex\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tthrow new Error(`layout contains unknown element ${k}`)\n\t\t}\n\t\tfor (const node of this.nodes()) {\n\t\t\tif (!(node.id in layout)) {\n\t\t\t\tthrow new Error(`layout is missing node ${node.id}`)\n\t\t\t}\n\t\t}\n\t\tif (rerender) {\n\t\t\tthis.nodes().forEach(n => setPosition(n.ref, n.x, n.y))\n\t\t\tthis.edges.forEach(e => this.redrawEdge(e))\n\t\t\tthis.updateEdgesSel()\n\t\t\tthis.redrawGroups(null)\n\t\t}\n\t}\n\n\tasync autoLayout(options?: LayoutOptions) {\n\t\tconst auto = await autoLayout(this, options)\n\t\tthis._undo.beforeChange()\n\n\t\tfor (const placedNode of auto.nodes) {\n\t\t\tconst node = this.nodesMap.get(placedNode.id)\n\t\t\tif (!node) {\n\t\t\t\tthrow new Error(`layout contains unknown node ${placedNode.id}`)\n\t\t\t}\n\t\t\tnode.x = placedNode.x\n\t\t\tnode.y = placedNode.y\n\t\t\tsetPosition(node.ref, node.x, node.y)\n\t\t}\n\n\t\tfor (const placedGroup of auto.groups) {\n\t\t\tconst group = this.groupsMap.get(placedGroup.id)\n\t\t\tif (!group) {\n\t\t\t\tthrow new Error(`layout contains unknown group ${placedGroup.id}`)\n\t\t\t}\n\t\t\tgroup.layoutBounds = placedGroup.bounds\n\t\t\tgroup.layoutTitleBounds = placedGroup.titleBounds\n\t\t\tgroup.x = placedGroup.bounds.x + placedGroup.bounds.width / 2\n\t\t\tgroup.y = placedGroup.bounds.y + placedGroup.bounds.height / 2\n\t\t\tgroup.width = placedGroup.bounds.width\n\t\t\tgroup.height = placedGroup.bounds.height\n\t\t}\n\n\t\tfor (const placedEdge of auto.edges) {\n\t\t\tconst edge = this.edges.find(candidate => candidate.id === placedEdge.id)\n\t\t\tif (!edge) {\n\t\t\t\tthrow new Error(`layout contains unknown edge ${placedEdge.id}`)\n\t\t\t}\n\t\t\tfor (const vertex of edge.vertices ?? []) {\n\t\t\t\tthis.edgeVertices.delete(vertex.id)\n\t\t\t}\n\t\t\tedge.layoutSections = placedEdge.sections\n\t\t\tedge.layoutLabelBounds = placedEdge.labelBounds\n\t\t\tedge.vertices = interiorRoutePoints(placedEdge.sections).map(point => {\n\t\t\t\tconst vertex = edge.initVertex(point)\n\t\t\t\tvertex.auto = true\n\t\t\t\treturn vertex\n\t\t\t})\n\t\t\tedge.userDeletedVertices = false\n\t\t}\n\n\t\tthis.validatedLayout = auto.validated\n\t\tthis.edges.forEach(edge => this.redrawEdge(edge))\n\t\tthis.redrawGroups(null)\n\t\tthis.fitToView()\n\t\tthis._undo.change()\n\t}\n\n\talignSelectionV() {\n\t\tconst lst: Point[] = this.nodes().filter(n => n.selected)\n\t\tlst.push(...Array.from(this.edgeVertices.values()).filter(v => v.selected))\n\t\tlet minY = Math.min(...lst.map(p => p.y))\n\t\tthis.nodesMap.forEach(n => n.selected && this.moveNode(n, n.x, minY, false, false))\n\t\tthis.edgeVertices.forEach(v => v.selected && this.moveEdgeVertex(v, v.x, minY, false, false))\n\t}\n\n\talignSelectionH() {\n\t\tconst lst: Point[] = this.nodes().filter(n => n.selected)\n\t\tlst.push(...Array.from(this.edgeVertices.values()).filter(v => v.selected))\n\t\tlet minX = Math.min(...lst.map(p => p.x))\n\t\tthis.nodesMap.forEach(n => n.selected && this.moveNode(n, minX, n.y, false, false))\n\t\tthis.edgeVertices.forEach(v => v.selected && this.moveEdgeVertex(v, minX, v.y, false, false))\n\t}\n\n\tdistributeSelectionH() {\n\t\tconst selectedNodes = this.nodes().filter(n => n.selected)\n\t\tconst selectedVertices = Array.from(this.edgeVertices.values()).filter(v => v.selected)\n\t\t\n\t\tif (selectedNodes.length + selectedVertices.length < 3) return // Need at least 3 elements to distribute\n\t\t\n\t\tthis._undo.beforeChange()\n\t\t\n\t\t// Combine and sort by X coordinate\n\t\tconst allElements = [...selectedNodes, ...selectedVertices]\n\t\tallElements.sort((a, b) => a.x - b.x)\n\t\t\n\t\tconst minX = allElements[0].x\n\t\tconst maxX = allElements[allElements.length - 1].x\n\t\tconst spacing = (maxX - minX) / (allElements.length - 1)\n\t\t\n\t\t// Distribute elements evenly between leftmost and rightmost\n\t\tallElements.forEach((element, index) => {\n\t\t\tconst newX = minX + (index * spacing)\n\t\t\tif ('title' in element) {\n\t\t\t\t// It's a Node\n\t\t\t\tthis.moveNode(element as Node, newX, element.y, false, true)\n\t\t\t} else {\n\t\t\t\t// It's an EdgeVertex\n\t\t\t\tthis.moveEdgeVertex(element as EdgeVertex, newX, element.y, false, true)\n\t\t\t}\n\t\t})\n\t\t\n\t\tthis._undo.change()\n\t}\n\n\tdistributeSelectionV() {\n\t\tconst selectedNodes = this.nodes().filter(n => n.selected)\n\t\tconst selectedVertices = Array.from(this.edgeVertices.values()).filter(v => v.selected)\n\t\t\n\t\tif (selectedNodes.length + selectedVertices.length < 3) return // Need at least 3 elements to distribute\n\t\t\n\t\tthis._undo.beforeChange()\n\t\t\n\t\t// Combine and sort by Y coordinate\n\t\tconst allElements = [...selectedNodes, ...selectedVertices]\n\t\tallElements.sort((a, b) => a.y - b.y)\n\t\t\n\t\tconst minY = allElements[0].y\n\t\tconst maxY = allElements[allElements.length - 1].y\n\t\tconst spacing = (maxY - minY) / (allElements.length - 1)\n\t\t\n\t\t// Distribute elements evenly between topmost and bottommost\n\t\tallElements.forEach((element, index) => {\n\t\t\tconst newY = minY + (index * spacing)\n\t\t\tif ('title' in element) {\n\t\t\t\t// It's a Node\n\t\t\t\tthis.moveNode(element as Node, element.x, newY, false, true)\n\t\t\t} else {\n\t\t\t\t// It's an EdgeVertex\n\t\t\t\tthis.moveEdgeVertex(element as EdgeVertex, element.x, newY, false, true)\n\t\t\t}\n\t\t})\n\t\t\n\t\tthis._undo.change()\n\t}\n\n\t// Set edge selection state\n\tsetEdgeSelected(edge: Edge, selected: boolean) {\n\t\t// Mark the edge as selected by selecting its connected nodes\n\t\tif (selected) {\n\t\t\tthis.setNodeSelected(edge.from, true)\n\t\t\tthis.setNodeSelected(edge.to, true)\n\t\t}\n\t\t// Update visual selection\n\t\tthis.updateEdgesSel()\n\t}\n\n\t// Fit the entire graph to the current viewport\n\tfitToView() {\n\t\tconst contentBounds = this.calculateContentBounds()\n\t\t\n\t\t// Handle edge case where there's no content\n\t\tif (contentBounds.width === 0 || contentBounds.height === 0) {\n\t\t\treturn\n\t\t}\n\t\t\n\t\t// Get viewport dimensions\n\t\tconst viewportWidth = svg.parentElement?.clientWidth || 800\n\t\tconst viewportHeight = svg.parentElement?.clientHeight || 600\n\t\t\n\t\t// Add padding around content\n\t\tconst padding = 40\n\t\t\n\t\t// Calculate zoom to fit content with padding\n\t\tconst zoomX = (viewportWidth - padding * 2) / contentBounds.width\n\t\tconst zoomY = (viewportHeight - padding * 2) / contentBounds.height\n\t\tconst optimalZoom = Math.min(zoomX, zoomY)\n\t\t\n\t\t// Clamp zoom between reasonable bounds\n\t\tconst finalZoom = Math.max(Math.min(optimalZoom, 2), 0.1)\n\t\t\n\t\t// Calculate content center in drawing coordinates\n\t\tconst contentCenterX = contentBounds.x + contentBounds.width / 2\n\t\tconst contentCenterY = contentBounds.y + contentBounds.height / 2\n\t\t\n\t\t// Calculate viewport center in screen coordinates\n\t\tconst viewportCenterX = viewportWidth / 2\n\t\tconst viewportCenterY = viewportHeight / 2\n\t\t\n\t\t// Calculate translation needed to center content in viewport\n\t\t// With translate(x,y) scale(zoom), translation is in screen coordinates\n\t\tconst translateX = viewportCenterX - (contentCenterX * finalZoom)\n\t\tconst translateY = viewportCenterY - (contentCenterY * finalZoom)\n\t\t\n\t\t// Apply zoom and translation transform\n\t\tconst zoomGroup = svg.querySelector('g.zoom') as SVGGElement\n\t\tif (zoomGroup) {\n\t\t\tzoomGroup.setAttribute('transform', `translate(${translateX}, ${translateY}) scale(${finalZoom})`)\n\t\t}\n\t\t\n\t\t// Update panning\n\t\tupdatePanning()\n\t\t\n\t\t// Save view state so this fit position is preserved after reload\n\t\tsaveViewState(this.id)\n\t}\n\n\t// Save current layout state for restoration\n\tprivate saveLayoutState(): Layout {\n\t\treturn this.exportLayout(true) // Include all vertices for complete state\n\t}\n\n\t// Restore layout state\n\tprivate restoreLayoutState(state: Layout) {\n\t\tthis.importLayout(state, true) // Rerender after restoring\n\t}\n\n\t// Grid functionality\n\tisGridVisible(): boolean {\n\t\treturn this._gridVisible;\n\t}\n\n\tisSnapToGrid(): boolean {\n\t\treturn this._snapToGrid;\n\t}\n\n\tgetGridSize(): number {\n\t\treturn this._gridSize;\n\t}\n\n\ttoggleGrid() {\n\t\tthis._gridVisible = !this._gridVisible;\n\t\tthis.updateGridDisplay();\n\t\t// Force toolbar update by dispatching a custom event\n\t\twindow.dispatchEvent(new CustomEvent('gridStateChanged'));\n\t}\n\n\ttoggleSnapToGrid() {\n\t\tthis._snapToGrid = !this._snapToGrid;\n\t\t// Force toolbar update by dispatching a custom event\n\t\twindow.dispatchEvent(new CustomEvent('gridStateChanged'));\n\t}\n\n\tsnapAllToGrid() {\n\t\tif (!this._snapToGrid) return;\n\t\t\n\t\tthis._undo.beforeChange();\n\t\tthis.nodes().forEach(node => {\n\t\t\tconst snappedX = Math.round(node.x / this._gridSize) * this._gridSize;\n\t\t\tconst snappedY = Math.round(node.y / this._gridSize) * this._gridSize;\n\t\t\tthis.moveNode(node, snappedX, snappedY, false, true);\n\t\t});\n\t\tthis._undo.change();\n\t}\n\n\t// Helper method to snap a point to grid\n\tprivate snapToGrid(x: number, y: number): { x: number, y: number } {\n\t\treturn {\n\t\t\tx: Math.round(x / this._gridSize) * this._gridSize,\n\t\t\ty: Math.round(y / this._gridSize) * this._gridSize\n\t\t};\n\t}\n\n\tupdateGridDisplay() {\n\t\tif (!svg) return;\n\n\t\t// Remove existing grid pattern and background\n\t\tconst existingGrid = svg.querySelector('#grid-pattern');\n\t\tif (existingGrid) {\n\t\t\texistingGrid.remove();\n\t\t}\n\n\t\tconst existingGridRect = svg.querySelector('#grid-background');\n\t\tif (existingGridRect) {\n\t\t\texistingGridRect.remove();\n\t\t}\n\n\t\tif (!this._gridVisible) return;\n\n\t\t// Create grid pattern in defs\n\t\tlet defs = svg.querySelector('defs');\n\t\tif (!defs) {\n\t\t\tdefs = document.createElementNS('http://www.w3.org/2000/svg', 'defs');\n\t\t\tsvg.insertBefore(defs, svg.firstChild);\n\t\t}\n\n\t\tconst pattern = document.createElementNS('http://www.w3.org/2000/svg', 'pattern');\n\t\tpattern.id = 'grid-pattern';\n\t\tpattern.setAttribute('width', this._gridSize.toString());\n\t\tpattern.setAttribute('height', this._gridSize.toString());\n\t\tpattern.setAttribute('patternUnits', 'userSpaceOnUse');\n\n\t\tconst path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n\t\tpath.setAttribute('d', `M ${this._gridSize} 0 L 0 0 0 ${this._gridSize}`);\n\t\tpath.setAttribute('fill', 'none');\n\t\tpath.setAttribute('stroke', '#d0d0d0');\n\t\tpath.setAttribute('stroke-width', '1');\n\t\tpath.setAttribute('opacity', '0.8');\n\n\t\tpattern.appendChild(path);\n\t\tdefs.appendChild(pattern);\n\n\t\t// Create grid background rectangle\n\t\tconst rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\n\t\trect.id = 'grid-background';\n\t\trect.setAttribute('x', '-10000');\n\t\trect.setAttribute('y', '-10000');\n\t\trect.setAttribute('width', '20000');\n\t\trect.setAttribute('height', '20000');\n\t\trect.setAttribute('fill', 'url(#grid-pattern)');\n\t\trect.setAttribute('pointer-events', 'none');\n\n\t\t// Insert grid as first child of zoom group so it transforms with content\n\t\tconst zoomGroup = svg.querySelector('g.zoom');\n\t\tif (zoomGroup) {\n\t\t\tzoomGroup.insertBefore(rect, zoomGroup.firstChild);\n\t\t}\n\t}\n}\n\n/** interiorRoutePoints returns only the editable points between edge endpoints. */\nfunction interiorRoutePoints(sections: Point[][]): Point[] {\n\tconst route: Point[] = []\n\tfor (const section of sections) {\n\t\tfor (const point of section) {\n\t\t\tconst previous = route[route.length - 1]\n\t\t\tif (!previous || previous.x !== point.x || previous.y !== point.y) {\n\t\t\t\troute.push(point)\n\t\t\t}\n\t\t}\n\t}\n\treturn route.slice(1, -1)\n}\n\n/** requiredSavedPoint checks coordinates when reading saved editor layout data. */\nfunction requiredSavedPoint(\n\tid: string,\n\tvalue: Point | SavedEdgePoint | SavedEdgePoint[] | boolean,\n): SavedEdgePoint {\n\tif (\n\t\ttypeof value !== 'object' ||\n\t\tArray.isArray(value) ||\n\t\t!Number.isFinite(value.x) ||\n\t\t!Number.isFinite(value.y)\n\t) {\n\t\tthrow new Error(`layout entry ${id} must contain valid x and y coordinates`)\n\t}\n\treturn value\n}\n\nfunction escapeCdata(code: string) {\n\treturn code.replace(/]]>/g, ']]]>]> clickListener(e))\n\t// addCursorInteraction(svg) // Call will be updated in buildGraph\n}\nsvg.setAttribute('width', '100%')\nsvg.setAttribute('height', '100%')\n\nlet clickListener: (e: MouseEvent) => void\nlet dragging = false;\nlet selectListener: (n: Node) => void\n\n\nexport const buildGraph = (data: GraphData, onNodeSelect: (n: Node) => void, dragMode: 'pan' | 'select') => {\n\tdocument.body.append(svg) // make sure svg element is connected, we will measure texts sizes\n\t// @ts-ignore\n\tsvg.__data = data\n\n\tselectListener = onNodeSelect\n\n\t//use event delegation\n\tclickListener = e => {\n\t\tif (dragging) {\n\t\t\treturn;\n\t\t}\n\t\t// const el = (e.target as any).closest('.node > .expand');\n\t}\n\n\t_buildGraph(data)\n\tconst elasticEl = create.rect(300, 300, 50, 50, 0, 'elastic')\n\tsvg.append(elasticEl)\n\n\t// Initialize grid display now that the zoom group exists\n\tdata.updateGridDisplay()\n\n\t// Call addCursorInteraction with dragMode\n\taddCursorInteraction(svg, dragMode)\n\n\treturn {\n\t\tsvg,\n\t\tsetZoom,\n\t}\n}\n\nexport const buildGraphView = (data: GraphData) => {\n\tsvg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n\tsvg.setAttribute('id', 'graph')\n\t_buildGraph(data)\n\treturn svg\n}\n\nconst _buildGraph = (data: GraphData) => {\n\t// Every graph owns the reusable SVG definitions referenced by its drawn\n\t// elements, including relationship arrowheads, icons, and filters.\n\tsvg.innerHTML = defs\n\n\t//toplevel groups\n\tconst zoomG = create.element('g', {}, 'zoom') as SVGGElement\n\tconst nodesG = create.element('g', {}, 'nodes') as SVGGElement\n\tconst edgesG = create.element('g', {}, 'edges') as SVGGElement\n\tconst groupsG = create.element('g', {}, 'groups') as SVGGElement\n\tzoomG.append(groupsG, edgesG, nodesG)\n\n\n\tdata.nodesMap.forEach((n) => {\n\t\tbuildNode(n, data)\n\t\tnodesG.append(n.ref)\n\t})\n\n\tdata.edges.forEach(edge => {\n\t\tedge.labelBounds = undefined\n\t})\n\tdata.edges.forEach(e => {\n\t\tbuildEdge(e)\n\t\tedgesG.append(e.ref)\n\t})\n\n\tdata.groupsMap.forEach((group) => {\n\t\tbuildGroup(group)\n\t\tgroupsG.append(group.ref)\n\t})\n\n\tsvg.append(zoomG)\n}\n\nfunction buildEdge(edge: Edge) {\n\tconst n1 = edge.from;\n\n\tconst g = create.element('g', {}, 'edge') as SVGGElement\n\tg.setAttribute('id', edge.id)\n\tg.setAttribute('data-from', edge.from.id)\n\tg.setAttribute('data-to', edge.to.id)\n\n\tconst position = (edge.style.position || 50) / 100\n\n\tconst vertices = edge.layoutSections\n\t\t? completeRoutePoints(edge.layoutSections)\n\t\t: calculateEdgeVertices(edge)\n\tconst {bg, txt} = edge.layoutLabelBounds\n\t\t? buildPlacedEdgeLabel(edge.layoutLabelBounds, edge)\n\t\t: buildEdgeLabel(calculateLabelPlacement(vertices, position, n1), edge)\n\tg.append(bg, txt)\n\n\tconst path = createEdgePath(vertices)\n\n\tconst p = create.path(path, {'marker-end': 'url(#arrow)'}, 'edge')\n\tp.setAttribute('fill', 'none')\n\tp.setAttribute('stroke', edge.style.color)\n\tp.setAttribute('stroke-width', String(edge.style.thickness))\n\tp.setAttribute('stroke-linecap', 'round')\n\tedge.style.dashed && p.setAttribute('stroke-dasharray', '8')\n\tg.append(p)\n\t\n\t// Debug visualization removed - arrow issue fixed\n\n\t// drag handlers\n\tfor (const p of edge.vertices ?? []) {\n\t\tconst v = p as EdgeVertex\n\t\tv.ref = create.element('circle', {id: v.id, cx: p.x, cy: p.y, r: 7, fill: 'none'}, 'v-dot')\n\t\tv.selected && v.ref.classList.add('selected')\n\t\tv.auto && v.ref.classList.add('auto')\n\t\tg.append(v.ref)\n\t}\n\n\tedge.ref = g\n\treturn g\n}\n\n/** completeRoutePoints joins connected layout sections without duplicate points. */\nfunction completeRoutePoints(sections: Point[][]): Point[] {\n\tconst route: Point[] = []\n\tfor (const section of sections) {\n\t\tfor (const point of section) {\n\t\t\tconst previous = route[route.length - 1]\n\t\t\tif (!previous || previous.x !== point.x || previous.y !== point.y) {\n\t\t\t\troute.push(point)\n\t\t\t}\n\t\t}\n\t}\n\treturn route\n}\n\n/** buildPlacedEdgeLabel draws one label in the box chosen by layout. */\nfunction buildPlacedEdgeLabel(bounds: BBox, edge: Edge) {\n\tconst centerX = bounds.x + bounds.width / 2\n\tconst centerY = bounds.y + bounds.height / 2\n\tconst {txt} = create.textArea(\n\t\tedge.label,\n\t\tedge.style.width,\n\t\tedge.style.fontSize,\n\t\tfalse,\n\t\tcenterX,\n\t\tbounds.y,\n\t\t'middle',\n\t)\n\tapplyStyle(txt, SVG_STYLES.edgeText)\n\ttxt.setAttribute('stroke', 'none')\n\ttxt.setAttribute('font-size', String(edge.style.fontSize))\n\ttxt.setAttribute('fill', edge.style.color)\n\ttxt.setAttribute('data-field', 'label')\n\tconst bg = create.rect(bounds.width, bounds.height, bounds.x, bounds.y)\n\tapplyStyle(bg, SVG_STYLES.edgeRect)\n\treturn {\n\t\tbg,\n\t\ttxt,\n\t}\n}\n\n/**\n * buildEdgeLabel adapts an older saved label anchor into a complete label box.\n * It uses one fixed side and lets validation reject any resulting collision.\n */\nfunction buildEdgeLabel(placement: EdgeLabelPlacement, edge: Edge) {\n\tconst labelGap = 12;\n\tconst fontSize = edge.style.fontSize\n\tlet {txt, dy, maxW} = create.textArea(edge.label, edge.style.width, fontSize, false, placement.x, placement.y, 'middle')\n\tdy -= fontSize / 2\n\tmaxW += fontSize\n\tconst centerX = placement.orientation === 'vertical'\n\t\t? placement.x + maxW / 2 + labelGap\n\t\t: placement.x\n\tconst centerY = placement.orientation === 'vertical'\n\t\t? placement.y\n\t\t: placement.y - dy / 2 - labelGap\n\tconst bounds = {\n\t\tx: centerX - maxW / 2,\n\t\ty: centerY - dy / 2,\n\t\twidth: maxW,\n\t\theight: dy,\n\t}\n\ttxt.querySelectorAll('tspan').forEach((span: SVGTSpanElement) => {\n\t\tspan.setAttribute('x', String(centerX))\n\t})\n\ttxt.setAttribute('y', String(centerY - dy / 2))\n\n\tapplyStyle(txt, SVG_STYLES.edgeText)\n\ttxt.setAttribute('stroke', 'none')\n\ttxt.setAttribute('font-size', String(edge.style.fontSize))\n\ttxt.setAttribute('fill', edge.style.color)\n\n\tconst bg = create.rect(bounds.width, bounds.height, bounds.x, bounds.y)\n\tapplyStyle(bg, SVG_STYLES.edgeRect)\n\ttxt.setAttribute('data-field', 'label')\n\tedge.labelBounds = bounds\n\treturn {bg, txt}\n}\n\n\nfunction buildNode(n: Node, data: GraphData) {\n\t// @ts-ignore\n\twindow.gdata = data\n\n\tconst g = create.element('g', {}, 'node') as SVGGElement\n\tg.setAttribute('id', n.id)\n\tn.selected && g.classList.add('selected')\n\tsetPosition(g, n.x, n.y)\n\tconst link = n.link\n\t\t? create.element('a', {\n\t\t\thref: n.link.href,\n\t\t\t'data-export-href': n.link.exportHref,\n\t\t\t'aria-label': `Open ${n.title}`,\n\t\t}, 'nodeLink') as SVGAElement\n\t\t: null\n\tconst content = link || g\n\tif (link) {\n\t\tg.classList.add('linked')\n\t\tg.append(link)\n\t}\n\n\t// Ensure we use the correct shape from style, defaulting to Box\n\tconst shapeType = n.style.shape || 'Box';\n\tconst shapeFn = shapes[shapeType.toLowerCase()] || shapes.box\n\tconst shape: SVGElement = shapeFn(content, n);\n\n\tshape.classList.add('nodeBorder')\n\n\t// Apply generic styles first\n\tapplyStyle(shape, SVG_STYLES.nodeBorder)\n\t// Then apply tag-specific styles to override generic ones\n\tshape.setAttribute('fill', n.style.background)\n\tshape.setAttribute('stroke', n.style.stroke)\n\tshape.setAttribute('opacity', String(n.style.opacity))\n\tsetBorderStyle(shape, n.style.border)\n\n\tconst tg = buildNodeContent(n.contentLayout, n.style.color)\n\tconst labelOffsetY = Number(content.getAttribute('label-offset-y')) || 0\n\tsetPosition(tg, 0, labelOffsetY / 2)\n\tcontent.append(tg)\n\n\t// @ts-ignore\n\tg.__data = n;\n\tn.ref = g;\n\n\treturn g\n}\n\n\nfunction buildGroup(group: Group) {\n\tif (group.nodes.length == 0) {\n\t\treturn\n\t}\n\tconst g = create.element('g', {}, 'group') as SVGGElement\n\tif (group.layoutBounds && group.layoutTitleBounds) {\n\t\tconst bounds = group.layoutBounds\n\t\tconst title = group.layoutTitleBounds\n\t\tconst rect = create.rect(bounds.width, bounds.height, bounds.x, bounds.y)\n\t\tapplyStyle(rect, SVG_STYLES.groupRect)\n\t\tgroup.style.stroke && rect.setAttribute('stroke', group.style.stroke)\n\t\tgroup.style.background && rect.setAttribute('fill', group.style.background)\n\t\tconst text = create.text(group.name, {\n\t\t\tx: title.x,\n\t\t\ty: title.y,\n\t\t\t'dominant-baseline': 'hanging',\n\t\t})\n\t\tapplyStyle(text, SVG_STYLES.groupText)\n\t\tgroup.style.color && text.setAttribute('fill', group.style.color)\n\t\tg.append(rect, text)\n\t\tgroup.ref = g\n\t\treturn\n\t}\n\n\tlet p0: Point = {x: 1e100, y: 1e100}, p1: Point = {x: 0, y: 0}\n\tgroup.nodes.forEach(n => {\n\t\t// Calculate visual bounds accounting for shapes that extend beyond center\n\t\tconst shape = (n as Node).style?.shape?.toLowerCase() || 'box'\n\t\t\n\t\tlet topExtension = n.height / 2\n\t\tlet bottomExtension = n.height / 2\n\t\t\n\t\tif (shape === 'robot') {\n\t\t\t// Robot shape extends above with antenna\n\t\t\t// Account for antenna height (h * 0.08) plus some margin\n\t\t\tconst antennaH = n.height * 0.12\n\t\t\ttopExtension = n.height / 2 + antennaH\n\t\t\tbottomExtension = n.height / 2\n\t\t} else if (shape === 'hexagon') {\n\t\t\t// Hexagon extends to ±0.866 * (width/2) vertically\n\t\t\t// For width=280, that's ±121.24px from center\n\t\t\tconst hexHeight = n.width / 2 * 0.866\n\t\t\ttopExtension = hexHeight\n\t\t\tbottomExtension = hexHeight\n\t\t}\n\t\t\n\t\tconst b = {\n\t\t\tx: n.x - n.width / 2,\n\t\t\ty: n.y - topExtension,\n\t\t\twidth: n.width,\n\t\t\theight: topExtension + bottomExtension\n\t\t}\n\t\tp0.x = Math.min(p0.x, b.x)\n\t\tp0.y = Math.min(p0.y, b.y)\n\t\tp1.x = Math.max(p1.x, b.x + b.width)\n\t\tp1.y = Math.max(p1.y, b.y + b.height)\n\t})\n\tconst pad = 25 // Padding around content\n\tconst labelHeight = 30 // Space for the group label at bottom\n\tconst w = Math.max(p1.x - p0.x, 200)\n\tconst h = p1.y - p0.y\n\tconst bb = {\n\t\tx: p0.x - pad,\n\t\ty: p0.y - pad,\n\t\twidth: w + pad * 2,\n\t\theight: h + pad * 2 + labelHeight,\n\t}\n\tconst r = create.rect(bb.width, bb.height, bb.x, bb.y)\n\tgroup.x = bb.x + bb.width / 2\n\tgroup.y = bb.y + bb.height / 2\n\tgroup.width = bb.width\n\tgroup.height = bb.height\n\tapplyStyle(r, SVG_STYLES.groupRect)\n\tgroup.style.stroke && r.setAttribute('stroke', group.style.stroke)\n\tgroup.style.background && r.setAttribute('fill', group.style.background)\n\n\tconst txt = create.text(group.name, {x: p0.x, y: bb.y + bb.height - SVG_STYLES.groupText[\"font-size\"]})\n\tapplyStyle(txt, SVG_STYLES.groupText)\n\tgroup.style.color && txt.setAttribute('fill', group.style.color)\n\n\tg.append(r, txt)\n\tgroup.ref = g\n}\n\nfunction findClosestSegment(graph: GraphData, p: Point) {\n\t// find the closest point on a segment\n\tlet fnd = {dst: Number.POSITIVE_INFINITY, pos: -1, edge: null as Edge, prj: null as Point}\n\tgraph.edges.forEach(edge => {\n\t\tconst vertices = edge.vertices || []\n\t\tconst pts = [edge.from, ...vertices, edge.to]\n\t\tfor (let i = 1; i < pts.length; i++) {\n\t\t\tconst prj = project(p, pts[i - 1], pts[i])\n\t\t\tconst dst = cabDistance(p, prj)\n\t\t\tif (dst > 50) continue\n\t\t\tif (dst < fnd.dst) {\n\t\t\t\tfnd = {dst, pos: i, prj, edge}\n\t\t\t}\n\t\t}\n\t})\n\treturn fnd.edge ? fnd : null\n}\n\nfunction mouseToDrawing(e: MouseEvent): Point {\n\t// transform event coords to drawing coords\n\tconst b = svg.getBoundingClientRect()\n\tconst z = getZoom()\n\t\n\t// Get current pan transform\n\tconst currentTransform = getCurrentTransform()\n\t\n\t// Convert screen coordinates to drawing coordinates accounting for zoom and pan\n\t// The transform values are in screen coordinates, so we need to divide by zoom and subtract\n\treturn {\n\t\tx: (e.clientX - b.x - currentTransform.x) / z,\n\t\ty: (e.clientY - b.y - currentTransform.y) / z\n\t}\n}\n\ninterface Handle extends Point {\n\tid: string\n\tselected?: boolean\n\tref?: SVGElement\n}\n\n// Custom cursor interaction that prioritizes panning over selection\nfunction addCustomCursorInteraction(svg: SVGSVGElement, conn: {\n\tnodeFromEvent(e: MouseEvent): Handle | null;\n\tsetSelection(handles: Handle[]): void;\n\tsetDragging(dragging: boolean): void;\n\tisSelected(handle: Handle): boolean;\n\tgetSelection(): Handle[];\n\tgetZoom(): number;\n\tmoveNode(h: Handle, x: number, y: number): void;\n\tboxSelection(box: DOMRect, add: boolean): void;\n\tupdatePanning(): void;\n}, dragMode: 'pan' | 'select') {\n\tlet ini: { x: number; y: number; n: Handle }[] = []\n\tlet elastic: any = null\n\tlet isPanning = false\n\tlet panStartX = 0\n\tlet panStartY = 0\n\tlet initialTransform = { x: 0, y: 0 }\n\tlet pendingSelectionChange: { node: Handle; shiftKey: boolean } | null = null\n\tlet pendingNavigation: string | null = null\n\tlet hasDragged = false\n\tlet suppressLinkClick = false\n\t\n\t// Store event listeners for cleanup\n\tconst eventListeners: Array<{ element: Element | Window, event: string, handler: EventListener }> = []\n\n\t// Simple elastic selection box implementation - use mouseToDrawing for proper coordinate conversion\n\tfunction createElastic() {\n\t\tlet startDrawingX = 0, startDrawingY = 0, rect: SVGRectElement | null = null\n\t\t\n\t\treturn {\n\t\t\tini(e: MouseEvent) {\n\t\t\t\t// Use mouseToDrawing to get proper drawing coordinates (accounts for zoom and pan)\n\t\t\t\tconst pt = mouseToDrawing(e)\n\t\t\t\tstartDrawingX = pt.x\n\t\t\t\tstartDrawingY = pt.y\n\t\t\t\t\n\t\t\t\trect = document.createElementNS(\"http://www.w3.org/2000/svg\", \"rect\")\n\t\t\t\trect.setAttribute('fill', 'rgba(0, 100, 255, 0.1)')\n\t\t\t\trect.setAttribute('stroke', 'rgba(0, 100, 255, 0.5)')\n\t\t\t\trect.setAttribute('stroke-width', '1')\n\t\t\t\trect.setAttribute('stroke-dasharray', '3,3')\n\t\t\t\trect.setAttribute('x', String(startDrawingX))\n\t\t\t\trect.setAttribute('y', String(startDrawingY))\n\t\t\t\trect.setAttribute('width', '0')\n\t\t\t\trect.setAttribute('height', '0')\n\t\t\t\t\n\t\t\t\t// Add to the zoom group so it transforms with the content\n\t\t\t\tconst zoomGroup = svg.querySelector('g.zoom')\n\t\t\t\tif (zoomGroup) {\n\t\t\t\t\tzoomGroup.appendChild(rect)\n\t\t\t\t} else {\n\t\t\t\t\tsvg.appendChild(rect)\n\t\t\t\t}\n\t\t\t},\n\t\t\tupdate(e: MouseEvent) {\n\t\t\t\tif (!rect) return\n\t\t\t\t\n\t\t\t\t// Convert current mouse position to drawing coordinates (accounts for zoom and pan)\n\t\t\t\tconst currentPt = mouseToDrawing(e)\n\t\t\t\tconst currentDrawingX = currentPt.x\n\t\t\t\tconst currentDrawingY = currentPt.y\n\t\t\t\t\n\t\t\t\t// Calculate rectangle bounds in drawing coordinates\n\t\t\t\tconst x = Math.min(startDrawingX, currentDrawingX)\n\t\t\t\tconst y = Math.min(startDrawingY, currentDrawingY)\n\t\t\t\tconst width = Math.abs(currentDrawingX - startDrawingX)\n\t\t\t\tconst height = Math.abs(currentDrawingY - startDrawingY)\n\t\t\t\t\n\t\t\t\trect.setAttribute('x', String(x))\n\t\t\t\trect.setAttribute('y', String(y))\n\t\t\t\trect.setAttribute('width', String(width))\n\t\t\t\trect.setAttribute('height', String(height))\n\t\t\t},\n\t\t\tend(): DOMRect | null {\n\t\t\t\tif (!rect) return null\n\t\t\t\t\n\t\t\t\t// Get final rectangle bounds in drawing coordinates\n\t\t\t\tconst x = parseFloat(rect.getAttribute('x') || '0')\n\t\t\t\tconst y = parseFloat(rect.getAttribute('y') || '0')\n\t\t\t\tconst width = parseFloat(rect.getAttribute('width') || '0')\n\t\t\t\tconst height = parseFloat(rect.getAttribute('height') || '0')\n\t\t\t\t\n\t\t\t\trect.remove()\n\t\t\t\trect = null\n\t\t\t\t\n\t\t\t\t// Return drawing coordinates directly for boxSelection since we're now working in the same coordinate system\n\t\t\t\tif (width > 5 && height > 5) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tx: x, y: y, width: width, height: height,\n\t\t\t\t\t\tleft: x, top: y, right: x + width, bottom: y + height\n\t\t\t\t\t} as DOMRect\n\t\t\t\t}\n\t\t\t\treturn null\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction getCurrentTransformLocal() {\n\t\tconst zoomGroup = svg.querySelector('g.zoom') as SVGGElement\n\t\tif (!zoomGroup) return { x: 0, y: 0 }\n\t\t\n\t\tconst transform = zoomGroup.getAttribute('transform') || ''\n\t\tconst translateMatch = transform.match(/translate\\(([^,]+),([^)]+)\\)/)\n\t\tif (translateMatch) {\n\t\t\treturn {\n\t\t\t\tx: parseFloat(translateMatch[1]) || 0,\n\t\t\t\ty: parseFloat(translateMatch[2]) || 0\n\t\t\t}\n\t\t}\n\t\treturn { x: 0, y: 0 }\n\t}\n\n\tfunction setTransform(x: number, y: number) {\n\t\tconst zoomGroup = svg.querySelector('g.zoom') as SVGGElement\n\t\tif (!zoomGroup) return\n\t\t\n\t\tconst zoom = getZoom()\n\t\tzoomGroup.setAttribute('transform', `translate(${x}, ${y}) scale(${zoom})`)\n\t}\n\n\tfunction onMouseDown(e: MouseEvent) {\n\t\te.preventDefault();\n\t\thasDragged = false\n\t\tpendingSelectionChange = null\n\t\tconst target = e.target\n\t\tconst link = target instanceof Element ? target.closest('a.nodeLink') : null\n\t\tpendingNavigation = e.shiftKey ? null : link?.getAttribute('href') || null\n\n\t\tconst node = conn.nodeFromEvent(e)\n\t\t\n\t\t// Determine effective mode: invert if shift is held\n\t\tconst effectiveMode = e.shiftKey ? (dragMode === 'pan' ? 'select' : 'pan') : dragMode\n\t\t\n\t\tif (!node) { // Clicked on empty space\n\t\t\tif (effectiveMode === 'pan') {\n\t\t\t\t// Pan mode: pan and deselect\n\t\t\t\tisPanning = true;\n\t\t\t\telastic = null;\n\t\t\t\tpanStartX = e.clientX;\n\t\t\t\tpanStartY = e.clientY;\n\t\t\t\tinitialTransform = getCurrentTransformLocal();\n\t\t\t\tini = [];\n\t\t\t\t// Deselect all elements when clicking empty space in pan mode\n\t\t\t\tconn.setSelection([]);\n\t\t\t} else {\n\t\t\t\t// Select mode: ONLY select, no panning\n\t\t\t\tisPanning = false;\n\t\t\t\telastic = createElastic();\n\t\t\t\tif (elastic) elastic.ini(e);\n\t\t\t\tini = [];\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Clicked on a node/vertex - behavior depends on effective mode\n\t\tif (effectiveMode === 'pan') {\n\t\t\t// Pan mode: select the element, don't pan\n\t\t\tisPanning = false;\n\t\t\telastic = null;\n\t\t\t\n\t\t\tconst nodes = conn.getSelection()\n\t\t\tif (conn.isSelected(node)) {\n\t\t\t\t// Clicking on a selected node - prepare to drag all selected elements\n\t\t\t\tini = nodes.map(n => ({ x: n.x, y: n.y, n }))\n\t\t\t\t// No selection change needed since we're clicking on already selected element\n\t\t\t} else {\n\t\t\t\t// Clicking on an unselected node - select only this element\n\t\t\t\tconn.setSelection([node]);\n\t\t\t\tini = [{ x: node.x, y: node.y, n: node }];\n\t\t\t}\n\t\t} else {\n\t\t\t// Select mode: selection/drag logic\n\t\t\tisPanning = false; // Ensure no panning if a node is clicked\n\t\t\telastic = null; // Ensure no selection box if a node is clicked\n\t\t\tconst nodes = conn.getSelection()\n\t\t\t\n\t\t\tif (e.shiftKey && dragMode === 'select') {\n\t\t\t\t// Shift+click in select mode: immediately change selection (no dragging expected)\n\t\t\t\tif (conn.isSelected(node)) {\n\t\t\t\t\tconst index = nodes.findIndex(n => n.id === node.id)\n\t\t\t\t\tif (index >= 0) nodes.splice(index, 1)\n\t\t\t\t} else {\n\t\t\t\t\tnodes.push(node)\n\t\t\t\t}\n\t\t\t\tconn.setSelection(nodes)\n\t\t\t\tini = nodes.map(n => ({ x: n.x, y: n.y, n }))\n\t\t\t} else {\n\t\t\t\t// Regular click: defer selection change until we know if it's a drag or click\n\t\t\t\tif (conn.isSelected(node)) {\n\t\t\t\t\t// Clicking on a selected node - prepare to drag all selected elements\n\t\t\t\t\tini = nodes.map(n => ({ x: n.x, y: n.y, n }))\n\t\t\t\t\t// No pending selection change needed since we're clicking on already selected element\n\t\t\t\t\tpendingSelectionChange = null\n\t\t\t\t} else {\n\t\t\t\t\t// Clicking on an unselected node - defer selection change until we determine if it's a click or drag\n\t\t\t\t\tpendingSelectionChange = { node, shiftKey: e.shiftKey }\n\t\t\t\t\t// For now, prepare to drag just the clicked node (we'll update selection when drag starts)\n\t\t\t\t\tini = [{ x: node.x, y: node.y, n: node }]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onMouseMove(e: MouseEvent, dx: number, dy: number) {\n\t\t// Check if we've moved enough to consider this a drag\n\t\tconst dragThreshold = 3 // pixels\n\t\tif (!hasDragged && (Math.abs(dx) > dragThreshold || Math.abs(dy) > dragThreshold)) {\n\t\t\thasDragged = true\n\t\t\tpendingNavigation = null\n\t\t\t\n\t\t\t// If we have a pending selection change and we're now dragging, apply it\n\t\t\tif (pendingSelectionChange) {\n\t\t\t\tconst nodes = conn.getSelection()\n\t\t\t\tnodes.length = 0\n\t\t\t\tnodes.push(pendingSelectionChange.node)\n\t\t\t\tconn.setSelection(nodes)\n\t\t\t\t// Update ini to drag only the newly selected node\n\t\t\t\tini = [{ x: pendingSelectionChange.node.x, y: pendingSelectionChange.node.y, n: pendingSelectionChange.node }]\n\t\t\t\tpendingSelectionChange = null\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (isPanning) {\n\t\t\t// Pan the view - apply mouse delta directly (no zoom division needed)\n\t\t\t// setTransform expects screen coordinates, dx/dy are already screen pixel deltas\n\t\t\tconst newX = initialTransform.x + dx\n\t\t\tconst newY = initialTransform.y + dy\n\t\t\tsetTransform(newX, newY)\n\t\t} else if (ini.length > 0 && hasDragged) {\n\t\t\t// Move selected nodes/vertices (only if we've actually started dragging)\n\t\t\t// dx, dy are screen pixel deltas, convert to drawing coordinate deltas\n\t\t\tconst zoom = conn.getZoom()\n\t\t\tconst drawingDx = dx / zoom\n\t\t\tconst drawingDy = dy / zoom\n\t\t\tini.forEach(item => {\n\t\t\t\t// item.x, item.y are initial drawing coordinates\n\t\t\t\t// Add the drawing coordinate delta to get new position\n\t\t\t\tconn.moveNode(item.n, item.x + drawingDx, item.y + drawingDy)\n\t\t\t})\n\t\t\tconn.setDragging(true)\n\t\t} else if (elastic) {\n\t\t\t// Update selection box\n\t\t\telastic.update(e)\n\t\t\tconn.setDragging(true)\n\t\t}\n\t}\n\n\tfunction onMouseUp(e: MouseEvent) {\n\t\tconn.setDragging(false)\n\t\tconst navigation = hasDragged ? null : pendingNavigation\n\t\tif (hasDragged) {\n\t\t\tsuppressLinkClick = true\n\t\t\twindow.setTimeout(() => {\n\t\t\t\tsuppressLinkClick = false\n\t\t\t}, 0)\n\t\t}\n\t\t\n\t\t// If we have a pending selection change and didn't drag, apply it now (it was just a click)\n\t\tif (pendingSelectionChange && !hasDragged) {\n\t\t\tconst nodes = conn.getSelection()\n\t\t\tnodes.length = 0\n\t\t\tnodes.push(pendingSelectionChange.node)\n\t\t\tconn.setSelection(nodes)\n\t\t}\n\t\t\n\t\tif (elastic) {\n\t\t\tconst box = elastic.end()\n\t\t\tif (box) {\n\t\t\t\tconn.boxSelection(box, e.shiftKey)\n\t\t\t} else if (!ini.length) {\n\t\t\t\t// Deselect if no box was drawn\n\t\t\t\tconn.setSelection([])\n\t\t\t}\n\t\t\telastic = null\n\t\t}\n\t\t\n\t\t// Save view state if user was panning (user-initiated view change)\n\t\tif (isPanning && hasDragged) {\n\t\t\tconst graphData = (svg as any).__data as GraphData\n\t\t\tif (graphData && graphData.id) {\n\t\t\t\tsaveViewState(graphData.id)\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Reset state\n\t\tpendingSelectionChange = null\n\t\tpendingNavigation = null\n\t\thasDragged = false\n\t\tisPanning = false\n\t\tconn.updatePanning()\n\t\tif (navigation) {\n\t\t\twindow.location.href = navigation\n\t\t}\n\t}\n\n\tfunction onClick(e: MouseEvent) {\n\t\tconst target = e.target\n\t\tif (!(target instanceof Element) || !target.closest('a.nodeLink')) return\n\t\te.preventDefault()\n\t\tif (!suppressLinkClick) return\n\t\te.stopPropagation()\n\t\tsuppressLinkClick = false\n\t}\n\n\t// Add drag and drop functionality\n\tfunction addDnd(element: SVGSVGElement) {\n\t\tlet md: { ex: number; ey: number } | null = null\n\n\t\tfunction convertEvent(e: MouseEvent | TouchEvent): MouseEvent {\n\t\t\tif ('changedTouches' in e && e.changedTouches) {\n\t\t\t\treturn e.changedTouches[0] as any\n\t\t\t}\n\t\t\treturn e as MouseEvent\n\t\t}\n\n\t\tfunction onMouseMoveHandler(e: MouseEvent | TouchEvent) {\n\t\t\tif (!md) return\n\t\t\te = convertEvent(e)\n\t\t\tonMouseMove(e, e.clientX - md.ex, e.clientY - md.ey)\n\t\t}\n\n\t\tfunction removeListeners() {\n\t\t\tdocument.removeEventListener('touchmove', onMouseMoveHandler as any)\n\t\t\tdocument.removeEventListener('mousemove', onMouseMoveHandler as any)\n\t\t\tdocument.removeEventListener('mouseup', onMouseUpHandler)\n\t\t\tdocument.removeEventListener('touchend', onMouseUpHandler)\n\t\t}\n\n\t\tfunction onMouseUpHandler(e: MouseEvent | TouchEvent) {\n\t\t\tremoveListeners()\n\t\t\tonMouseUp(convertEvent(e))\n\t\t\tmd = null\n\t\t}\n\n\t\tfunction onMouseDownHandler(e: MouseEvent | TouchEvent) {\n\t\t\te = convertEvent(e)\n\t\t\tmd = { ex: e.clientX, ey: e.clientY }\n\t\t\tonMouseDown(e)\n\t\t\tdocument.addEventListener('touchmove', onMouseMoveHandler as any)\n\t\t\tdocument.addEventListener('mousemove', onMouseMoveHandler as any)\n\t\t\tdocument.addEventListener('mouseup', onMouseUpHandler)\n\t\t\tdocument.addEventListener('touchend', onMouseUpHandler)\n\t\t}\n\n\t\telement.addEventListener('mousedown', onMouseDownHandler as any)\n\t\telement.addEventListener('touchstart', onMouseDownHandler as any)\n\t\t\n\t\t// Track these listeners for cleanup\n\t\teventListeners.push(\n\t\t\t{ element, event: 'mousedown', handler: onMouseDownHandler as any },\n\t\t\t{ element, event: 'touchstart', handler: onMouseDownHandler as any }\n\t\t)\n\t}\n\n\taddDnd(svg)\n\tsvg.addEventListener('click', onClick)\n\teventListeners.push({ element: svg, event: 'click', handler: onClick })\n\t\n\t// Return cleanup function\n\treturn () => {\n\t\teventListeners.forEach(({ element, event, handler }) => {\n\t\t\telement.removeEventListener(event, handler)\n\t\t})\n\t}\n}\n\nexport function addCursorInteraction(svg: SVGSVGElement, dragMode: 'pan' | 'select') {\n\t// Clean up any existing event listeners to prevent conflicts\n\tconst existingCleanup = (svg as any).__cursorInteractionCleanup\n\tif (existingCleanup) {\n\t\texistingCleanup()\n\t}\n\n\tfunction getData(el: SVGElement) {\n\t\t// @ts-ignore\n\t\treturn el.__data\n\t}\n\n\tconst gd = () => (getData(svg) as GraphData)\n\t\n\t// Store event listeners for cleanup\n\tconst eventListeners: Array<{ element: Element | Window, event: string, handler: EventListener }> = []\n\n\tconst beforeUnloadHandler = (e: BeforeUnloadEvent) => {\n\t\tif (!gd().changed()) return\n\t\te.preventDefault()\n\t\te.returnValue = ''\n\t}\n\twindow.addEventListener(\"beforeunload\", beforeUnloadHandler)\n\teventListeners.push({ element: window, event: 'beforeunload', handler: beforeUnloadHandler })\n\n\tfunction setDotSelected(d: Handle, selected: boolean) {\n\t\td.selected = selected\n\t\tconst dotEl = svg.querySelector('#' + d.id)\n\t\td.selected ? dotEl.classList.add('selected') : dotEl.classList.remove('selected')\n\t}\n\n\t// show moving dot along edge when ALT is pressed\n\tconst mouseMoveHandler = (e: MouseEvent) => {\n\t\tif (!e.altKey) return\n\t\tconst fnd = findClosestSegment(gd(), mouseToDrawing(e))\n\t\tif (fnd) {\n\t\t\tconst {prj} = fnd\n\t\t\tconst parent = svg.querySelector('g.edges')\n\t\t\tlet dot = parent.querySelector('#prj')\n\t\t\tif (!dot) {\n\t\t\t\tdot = create.element('circle', {id: 'prj', cx: prj.x, cy: prj.y, r: 7})\n\t\t\t\tparent.append(dot)\n\t\t\t}\n\t\t\tdot.setAttribute('cx', String(prj.x))\n\t\t\tdot.setAttribute('cy', String(prj.y))\n\t\t} else {\n\t\t\tremovePrjDot()\n\t\t}\n\t}\n\tsvg.addEventListener('mousemove', mouseMoveHandler)\n\teventListeners.push({ element: svg, event: 'mousemove', handler: mouseMoveHandler })\n\n\tconst keyUpHandler = (e: KeyboardEvent) => {\n\t\tconst key = findShortcut(e, true)\n\t\tif (key == ADD_VERTEX || key == ADD_LABEL_VERTEX) return\n\t\tremovePrjDot()\n\t}\n\twindow.addEventListener('keyup', keyUpHandler)\n\teventListeners.push({ element: window, event: 'keyup', handler: keyUpHandler })\n\n\tfunction removePrjDot() {\n\t\tconst el = svg.querySelector('g.edges #prj')\n\t\tel && el.parentElement.removeChild(el)\n\t}\n\n\tconst clickHandler = (e: MouseEvent) => {\n\t\tconst key = findShortcut(e, true)\n\t\tif (key != ADD_LABEL_VERTEX && key != ADD_VERTEX) return\n\t\tconst fnd = findClosestSegment(gd(), mouseToDrawing(e))\n\t\tif (fnd) {\n\t\t\tconst {edge, pos, prj} = fnd\n\t\t\t// depending on keyboard modifier, make it label position\n\t\t\tgd().insertEdgeVertex(edge, prj, pos, key == ADD_LABEL_VERTEX)\n\t\t\tremovePrjDot()\n\t\t}\n\t}\n\tsvg.addEventListener('click', clickHandler)\n\teventListeners.push({ element: svg, event: 'click', handler: clickHandler })\n\n\tconst wheelHandler = (e: WheelEvent) => {\n\t\t// Handle wheel zoom directly without relying on shortcuts\n\t\t// deltaY > 0 means scrolling down (zoom out), deltaY < 0 means scrolling up (zoom in)\n\t\tconst delta = Math.sign(e.deltaY) * 0.1 // Normalize to 0.1 zoom steps\n\t\tconst currentZoom = getZoom()\n\t\tconst newZoom = Math.max(0.1, Math.min(5, currentZoom - delta)) // Clamp zoom between 0.1 and 5\n\t\t\n\t\tif (newZoom !== currentZoom) {\n\t\t\t// Convert absolute screen coordinates to SVG-relative coordinates\n\t\t\tconst rect = svg.getBoundingClientRect()\n\t\t\tconst svgX = e.clientX - rect.left\n\t\t\tconst svgY = e.clientY - rect.top\n\t\t\tsetZoomCentered(newZoom, svgX, svgY)\n\t\t\te.preventDefault()\n\t\t\t\n\t\t\t// Save view state after user wheel zoom\n\t\t\tconst graphData = (svg as any).__data as GraphData\n\t\t\tif (graphData && graphData.id) {\n\t\t\t\tsaveViewState(graphData.id)\n\t\t\t}\n\t\t}\n\t}\n\tsvg.addEventListener('wheel', wheelHandler)\n\teventListeners.push({ element: svg, event: 'wheel', handler: wheelHandler })\n\n\tconst keyDownHandler = (e: KeyboardEvent) => {\n\t\tconst shortcut = findShortcut(e)\n\t\t\n\t\t\n\t\tif (shortcut) {\n\t\t\te.preventDefault() // Prevent browser default for all recognized shortcuts\n\t\t}\n\t\t\n\t\tswitch (shortcut) {\n\t\t\tcase DEL_VERTEX:\n\t\t\t\tconst selectedVertices = Array.from(gd().edgeVertices.values()).filter(v => v.selected);\n\t\t\t\tselectedVertices.forEach(v => {\n\t\t\t\t\tgd().deleteEdgeVertex(v)\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\tcase UNDO:\n\t\t\t\tgd().undo()\n\t\t\t\tbreak\n\t\t\tcase REDO:\n\t\t\t\tgd().redo()\n\t\t\t\tbreak\n\t\t\tcase ZOOM_IN:\n\t\t\t\tconst newZoomIn = Math.min(5, getZoom() * 1.2)\n\t\t\t\t// Center zoom on viewport center like mouse wheel\n\t\t\t\tsetZoomCentered(newZoomIn)\n\t\t\t\tsaveViewState(gd().id) // Save after user keyboard zoom\n\t\t\t\tbreak\n\t\t\tcase ZOOM_OUT:\n\t\t\t\tconst newZoomOut = Math.max(0.1, getZoom() / 1.2)\n\t\t\t\t// Center zoom on viewport center like mouse wheel\n\t\t\t\tsetZoomCentered(newZoomOut)\n\t\t\t\tsaveViewState(gd().id) // Save after user keyboard zoom\n\t\t\t\tbreak\n\t\t\tcase ZOOM_100:\n\t\t\t\t// Center zoom on viewport center like mouse wheel\n\t\t\t\tsetZoomCentered(1)\n\t\t\t\tsaveViewState(gd().id) // Save after user keyboard zoom\n\t\t\t\tbreak\n\t\t\tcase ZOOM_FIT:\n\t\t\t\tgd().fitToView()\n\t\t\t\t// Don't save view state here - fitToView should not be persisted\n\t\t\t\tbreak\n\t\t\tcase SELECT_ALL:\n\t\t\t\tgd().nodes().forEach(n => gd().setNodeSelected(n, true))\n\t\t\t\tgd().edgeVertices.forEach(v => setDotSelected(v, true))\n\t\t\t\tbreak\n\t\t\tcase DESELECT:\n\t\t\t\tgd().nodes().forEach(n => gd().setNodeSelected(n, false))\n\t\t\t\tgd().edgeVertices.forEach(v => setDotSelected(v, false))\n\t\t\t\tbreak\n\t\t}\n\t}\n\twindow.addEventListener('keydown', keyDownHandler)\n\teventListeners.push({ element: window, event: 'keydown', handler: keyDownHandler })\n\n\t// Custom cursor interaction with pan-first behavior\n\tconst customInteractionCleanup = addCustomCursorInteraction(svg, {\n\t\tnodeFromEvent(e: MouseEvent): Handle {\n\t\t\te.preventDefault()\n\t\t\t// node clicked\n\t\t\tlet el = (e.target as SVGElement).closest('g.nodes g.node') as SVGElement\n\t\t\tif (el) return getData(el)\n\t\t\t// vertex dot clicked\n\t\t\tel = (e.target as SVGElement).closest('g.edges g.edge .v-dot') as SVGElement\n\t\t\tif (el) {\n\t\t\t\treturn gd().edgeVertices.get(el.id)\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\t\tsetSelection(handles: Handle[]) {\n\t\t\t// nodes\n\t\t\tgd().nodes().forEach(n => gd().setNodeSelected(n, handles.some(h => h.id == n.id)))\n\t\t\t// dots\n\t\t\tgd().edgeVertices.forEach(d => setDotSelected(d, handles.some(h => h.id == d.id)))\n\t\t\tselectListener(gd().nodes().find(n => n.selected))\n\t\t},\n\t\tsetDragging(d: boolean) {\n\t\t\tdragging = d\n\t\t},\n\t\tisSelected(handle: Handle): boolean {\n\t\t\treturn handle.selected\n\t\t},\n\t\tgetSelection(): Handle[] {\n\t\t\tconst ret: Handle[] = gd().nodes().filter(n => n.selected)\n\t\t\tgd().edgeVertices.forEach(d => d.selected && ret.push(d))\n\t\t\treturn ret\n\t\t},\n\t\tgetZoom: getZoom,\n\t\tmoveNode(h: Handle, x: number, y: number) {\n\t\t\tif (gd().nodesMap.has(h.id))\n\t\t\t\tgd().moveNode(h as Node, x, y)\n\t\t\telse {\n\t\t\t\t(h as EdgeVertex).auto = false\n\t\t\t\tgd().moveEdgeVertex(h as EdgeVertex, x, y)\n\t\t\t}\n\t\t},\n\t\tboxSelection(box: DOMRect, add) {\n\t\t\t// Box is now already in drawing coordinates, no need to scale\n\t\t\t// nodes\n\t\t\tgd().nodesMap.forEach(n => {\n\t\t\t\tconst inBox = boxesOverlap(uncenterBox(n), box)\n\t\t\t\tif (inBox) {\n\t\t\t\t\t// Toggle selection for elements in the box\n\t\t\t\t\tgd().setNodeSelected(n, !n.selected)\n\t\t\t\t} else if (!add) {\n\t\t\t\t\t// If not holding shift and element is outside box, deselect it\n\t\t\t\t\tgd().setNodeSelected(n, false)\n\t\t\t\t}\n\t\t\t})\n\t\t\t// dots\n\t\t\tgd().edgeVertices.forEach(d => {\n\t\t\t\tconst inBox = insideBox(d, box, false)\n\t\t\t\tif (inBox) {\n\t\t\t\t\t// Toggle selection for elements in the box\n\t\t\t\t\tsetDotSelected(d, !d.selected)\n\t\t\t\t} else if (!add) {\n\t\t\t\t\t// If not holding shift and element is outside box, deselect it\n\t\t\t\t\tsetDotSelected(d, false)\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tselectListener(gd().nodes().find(n => n.selected))\n\t\t},\n\t\tupdatePanning: updatePanning,\n\t}, dragMode)\n\t\n\t// Store cleanup function on the SVG element for later use\n\tconst cleanup = () => {\n\t\teventListeners.forEach(({ element, event, handler }) => {\n\t\t\telement.removeEventListener(event, handler)\n\t\t})\n\t\tif (customInteractionCleanup) {\n\t\t\tcustomInteractionCleanup()\n\t\t}\n\t}\n\t\n\t// Store cleanup function on SVG element\n\t;(svg as any).__cursorInteractionCleanup = cleanup\n}\n\nexport function getZoom() {\n\tif (!svg) return 1\n\tconst el = svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return 1\n\t\n\t// Parse zoom from transform attribute to match how we set it\n\tconst transform = el.getAttribute('transform') || ''\n\tconst scaleMatch = transform.match(/scale\\(([^)]+)\\)/)\n\tif (scaleMatch) {\n\t\treturn parseFloat(scaleMatch[1]) || 1\n\t}\n\treturn 1\n}\n\n// svgPadding is now imported as SVG_PADDING from constants.ts\n\nexport function setZoom(zoom: number) {\n\tif (!svg) return\n\tconst el = svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return\n\t\n\t// Preserve existing translation when setting zoom\n\tconst currentTransform = getCurrentTransform()\n\tel.setAttribute('transform', `translate(${currentTransform.x}, ${currentTransform.y}) scale(${zoom})`)\n\t\n\t// also set panning size\n\tupdatePanning()\n}\n\nexport function setZoomCentered(newZoom: number, centerX?: number, centerY?: number) {\n\tconst el = svg.querySelector('g.zoom') as SVGGElement\n\tconst oldZoom = getZoom()\n\t\n\t// If no center point provided, use viewport center\n\tif (centerX === undefined || centerY === undefined) {\n\t\t// Use the parent container's dimensions for the visible viewport\n\t\t// The SVG might be larger than the visible area due to overflow\n\t\tconst container = svg.parentElement\n\t\tif (container) {\n\t\t\tcenterX = container.clientWidth / 2\n\t\t\tcenterY = container.clientHeight / 2\n\t\t} else {\n\t\t\t// Fallback to SVG dimensions if no parent\n\t\t\tcenterX = svg.clientWidth / 2\n\t\t\tcenterY = svg.clientHeight / 2\n\t\t}\n\t}\n\t\n\t// Get current transform\n\tconst currentTransform = getCurrentTransform()\n\t\n\t// Convert screen coordinates to drawing coordinates\n\t// For transform order translate(tx, ty) scale(s):\n\t// screen_point = (drawing_point * scale) + translation\n\t// So: drawing_point = (screen_point - translation) / scale\n\tconst drawingX = (centerX - currentTransform.x) / oldZoom\n\tconst drawingY = (centerY - currentTransform.y) / oldZoom\n\t\n\t// Calculate new translation to keep the same drawing point at the same screen position\n\t// screen_point = (drawing_point * new_scale) + new_translation\n\t// So: new_translation = screen_point - (drawing_point * new_scale)\n\tconst newTranslateX = centerX - (drawingX * newZoom)\n\tconst newTranslateY = centerY - (drawingY * newZoom)\n\t\n\t// Apply the new transform\n\tel.setAttribute('transform', `translate(${newTranslateX}, ${newTranslateY}) scale(${newZoom})`)\n\t\n\t// Update panning\n\tupdatePanning()\n}\n\nfunction getCurrentTransform() {\n\tif (!svg) return { x: 0, y: 0 }\n\tconst el = svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return { x: 0, y: 0 }\n\t\n\tconst transform = el.getAttribute('transform') || ''\n\tconst translateMatch = transform.match(/translate\\(([^,]+),([^)]+)\\)/)\n\tif (translateMatch) {\n\t\treturn {\n\t\t\tx: parseFloat(translateMatch[1]) || 0,\n\t\t\ty: parseFloat(translateMatch[2]) || 0\n\t\t}\n\t}\n\treturn { x: 0, y: 0 }\n}\n\nfunction updatePanning() {\n\tif (!svg) return\n\tconst el = svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return\n\tconst bb = el.getBBox()\n\tconst zoom = getZoom()\n\tif (!svg.parentElement) return\n\tconst w = Math.max(svg.parentElement.clientWidth / zoom, bb.x + bb.width + SVG_PADDING)\n\tconst h = Math.max(svg.parentElement.clientHeight / zoom, bb.y + bb.height + SVG_PADDING)\n\tsvg.setAttribute('width', String(w * zoom))\n\tsvg.setAttribute('height', String(h * zoom))\n\t\n\t// Note: View state saving removed from here to prevent interference with reset/fit functions\n\t// View state is now only saved on user interactions and page unload\n}\n\n// Optimized version that uses pre-calculated content bounds instead of expensive getBBox()\nfunction updatePanningOptimized(graphData: GraphData) {\n\tconst bb = graphData.calculateContentBounds() // Use already calculated bounds\n\tconst zoom = getZoom()\n\tconst w = Math.max(svg.parentElement.clientWidth / zoom, bb.x + bb.width + SVG_PADDING)\n\tconst h = Math.max(svg.parentElement.clientHeight / zoom, bb.y + bb.height + SVG_PADDING)\n\tsvg.setAttribute('width', String(w * zoom))\n\tsvg.setAttribute('height', String(h * zoom))\n}\n\nexport const getZoomAuto = () => {\n\t// Get the graph data to calculate proper content bounds\n\tconst graphData = (svg as any).__data as GraphData\n\tif (!graphData) {\n\t\treturn 1 // Default zoom if no graph data\n\t}\n\t\n\t// Use proper content bounds calculation\n\tconst contentBounds = graphData.calculateContentBounds()\n\tconst viewportWidth = svg.parentElement?.clientWidth || 800\n\tconst viewportHeight = svg.parentElement?.clientHeight || 600\n\t\n\t// Add padding around content\n\tconst padding = 40\n\t\n\t// Calculate zoom to fit content with padding\n\tconst zoomX = (viewportWidth - padding * 2) / contentBounds.width\n\tconst zoomY = (viewportHeight - padding * 2) / contentBounds.height\n\tconst zoom = Math.min(zoomX, zoomY)\n\t\n\t// Clamp zoom between reasonable bounds\n\treturn Math.max(Math.min(zoom, 2), 0.1)\n}\n\nconst setBorderStyle = (el: SVGElement, style: string) => {\n\tif (style == 'Dashed') el.setAttribute('stroke-dasharray', '4')\n\telse if (style == 'Dotted') el.setAttribute('stroke-dasharray', '2')\n}\n\n// View state persistence - similar to undo cache but for zoom/pan\nconst viewStateCache = new Map();\n\n// Save current view state (zoom and pan)\nexport function saveViewState(graphId: string) {\n\tif (!svg) return;\n\t\n\tconst zoom = getZoom();\n\tconst transform = getCurrentTransform();\n\t\n\tconst state = {\n\t\tzoom,\n\t\ttransform: { x: transform.x, y: transform.y }\n\t};\n\t\n\tviewStateCache.set(graphId, state);\n}\n\n// Restore view state if it exists\nexport function restoreViewState(graphId: string): boolean {\n\tif (!svg || !viewStateCache.has(graphId)) {\n\t\treturn false;\n\t}\n\t\n\tconst state = viewStateCache.get(graphId);\n\tif (!state) {\n\t\treturn false;\n\t}\n\t\n\t// Restore zoom and transform\n\tconst zoomGroup = svg.querySelector('g.zoom') as SVGGElement;\n\tif (zoomGroup) {\n\t\tzoomGroup.setAttribute('transform', `scale(${state.zoom}) translate(${state.transform.x}, ${state.transform.y})`);\n\t\tupdatePanning();\n\t}\n\t\n\treturn true;\n}\n\n// Clear view state for a graph\nexport function clearViewState(graphId: string) {\n\tviewStateCache.delete(graphId);\n}\n","// This file is the only owner of automatic positions. It gives ELK the exact\n// measured sizes, reads ELK's complete result, and does not repair that result.\n\nimport type {\n\tElkExtendedEdge,\n\tElkLabel,\n\tElkNode,\n\tElkPoint,\n} from \"elkjs/lib/elk-api\";\n\nimport {\n\tMeasuredDiagram,\n\tMeasuredEdge,\n\tMeasuredGroup,\n\tMeasuredNode,\n\tPoint,\n\tResolvedEdge,\n\tResolvedGroup,\n\tResolvedLayout,\n\tResolvedNode,\n} from \"./geometry\";\n\n/** AutomaticLayoutOptions are the choices a caller may make before layout. */\nexport interface AutomaticLayoutOptions {\n\tdirection: \"UP\" | \"DOWN\" | \"LEFT\" | \"RIGHT\";\n\tnodeSpacing: number;\n\tlayerSpacing: number;\n}\n\nconst defaultOptions: AutomaticLayoutOptions = {\n\tdirection: \"DOWN\",\n\tnodeSpacing: 80,\n\tlayerSpacing: 80,\n};\n\n/**\n * resolveAutomatic runs one compound ELK layout with exact measured sizes.\n * ELK errors and incomplete results are returned to the caller unchanged.\n */\nexport async function resolveAutomatic(\n\tdiagram: MeasuredDiagram,\n\toptions: Partial = {},\n): Promise {\n\tconst settings = {...defaultOptions, ...options};\n\tconst graph = buildLayoutTree(diagram, settings);\n\tconst ELK = await import(\"elkjs/lib/elk.bundled.js\").then(module => module.default);\n\tconst elk = new ELK();\n\tconst result = await elk.layout(graph);\n\treturn readResolvedLayout(diagram, result);\n}\n\n/**\n * buildLayoutTree creates one ELK tree. Nodes belong to their declared group,\n * groups belong to their declared parent, and each edge belongs to the nearest\n * group shared by both connected nodes.\n */\nfunction buildLayoutTree(\n\tdiagram: MeasuredDiagram,\n\toptions: AutomaticLayoutOptions,\n): ElkNode {\n\tconst nodes = new Map(diagram.nodes.map(node => [node.id, node]));\n\tconst groups = new Map(diagram.groups.map(group => [group.id, group]));\n\tcheckMeasuredLinks(diagram, nodes, groups);\n\n\tconst childrenByParent = new Map();\n\tfor (const node of diagram.nodes) {\n\t\tappend(childrenByParent, node.parentId, node);\n\t}\n\tconst groupsByParent = new Map();\n\tfor (const group of diagram.groups) {\n\t\tappend(groupsByParent, group.parentId, group);\n\t}\n\n\tconst elkGroups = new Map();\n\tconst buildGroup = (group: MeasuredGroup): ElkNode => {\n\t\tconst child: ElkNode = {\n\t\t\tid: group.id,\n\t\t\tchildren: [\n\t\t\t\t...(groupsByParent.get(group.id) ?? []).map(buildGroup),\n\t\t\t\t...(childrenByParent.get(group.id) ?? []).map(buildNode),\n\t\t\t],\n\t\t\tedges: [],\n\t\t\tlabels: [{\n\t\t\t\ttext: group.id,\n\t\t\t\twidth: group.titleSize.width,\n\t\t\t\theight: group.titleSize.height,\n\t\t\t}],\n\t\t\tlayoutOptions: groupLayoutOptions(options, group.titleSize.height),\n\t\t};\n\t\telkGroups.set(group.id, child);\n\t\treturn child;\n\t};\n\n\tconst root: ElkNode = {\n\t\tid: diagram.id,\n\t\tchildren: [\n\t\t\t...(groupsByParent.get(undefined) ?? []).map(buildGroup),\n\t\t\t...(childrenByParent.get(undefined) ?? []).map(buildNode),\n\t\t],\n\t\tedges: [],\n\t\tlayoutOptions: rootLayoutOptions(options),\n\t};\n\n\tfor (const edge of diagram.edges) {\n\t\tconst owner = lowestCommonGroup(edge, nodes, groups);\n\t\tconst container = owner ? elkGroups.get(owner) : root;\n\t\tif (!container) {\n\t\t\tthrow new Error(`edge ${edge.id} has missing layout group ${owner}`);\n\t\t}\n\t\tcontainer.edges?.push(buildEdge(edge));\n\t}\n\treturn root;\n}\n\n/** buildNode passes the measured node size to ELK without padding or guesses. */\nfunction buildNode(node: MeasuredNode): ElkNode {\n\treturn {\n\t\tid: node.id,\n\t\twidth: node.size.width,\n\t\theight: node.size.height,\n\t\tlayoutOptions: {\n\t\t\t\"elk.nodeSize.constraints\": \"FIXED_SIZE\",\n\t\t\t\"elk.portConstraints\": \"FREE\",\n\t\t},\n\t};\n}\n\n/** buildEdge passes the exact label size and stable endpoint IDs to ELK. */\nfunction buildEdge(edge: MeasuredEdge): ElkExtendedEdge {\n\treturn {\n\t\tid: edge.id,\n\t\tsources: [edge.sourceId],\n\t\ttargets: [edge.targetId],\n\t\tlabels: edge.labelSize ? [{\n\t\t\ttext: edge.id,\n\t\t\twidth: edge.labelSize.width,\n\t\t\theight: edge.labelSize.height,\n\t\t\tlayoutOptions: {\n\t\t\t\t\"elk.edgeLabels.inline\": \"false\",\n\t\t\t\t\"elk.edgeLabels.placement\": \"CENTER\",\n\t\t\t},\n\t\t}] : [],\n\t};\n}\n\n/** rootLayoutOptions set the rules shared by the full compound layout. */\nfunction rootLayoutOptions(options: AutomaticLayoutOptions): Record {\n\treturn {\n\t\t\"elk.algorithm\": \"layered\",\n\t\t\"elk.direction\": options.direction,\n\t\t\"elk.edgeRouting\": \"ORTHOGONAL\",\n\t\t\"elk.hierarchyHandling\": \"INCLUDE_CHILDREN\",\n\t\t\"elk.padding\": \"[top=40,left=40,bottom=40,right=40]\",\n\t\t\"elk.spacing.nodeNode\": String(options.nodeSpacing),\n\t\t\"elk.spacing.componentComponent\": String(options.nodeSpacing),\n\t\t\"elk.layered.spacing.nodeNodeBetweenLayers\": String(options.layerSpacing),\n\t\t\"elk.layered.spacing.edgeNodeBetweenLayers\": \"30\",\n\t\t\"elk.layered.spacing.edgeEdgeBetweenLayers\": \"20\",\n\t\t\"elk.layered.nodePlacement.strategy\": \"NETWORK_SIMPLEX\",\n\t\t\"elk.layered.nodePlacement.favorStraightEdges\": \"true\",\n\t\t\"elk.layered.crossingMinimization.strategy\": \"LAYER_SWEEP\",\n\t\t\"elk.layered.unnecessaryBendpoints\": \"true\",\n\t\t\"elk.edgeLabels.inline\": \"false\",\n\t\t\"elk.edgeLabels.avoidOverlap\": \"true\",\n\t\t\"elk.layered.edgeLabels.sideSelection\": \"SMART_DOWN\",\n\t\t\"elk.spacing.edgeLabel\": \"12\",\n\t};\n}\n\n/** groupLayoutOptions reserve title space and keep each group's children together. */\nfunction groupLayoutOptions(\n\toptions: AutomaticLayoutOptions,\n\ttitleHeight: number,\n): Record {\n\treturn {\n\t\t...rootLayoutOptions(options),\n\t\t\"elk.padding\": `[top=${titleHeight + 30},left=30,bottom=30,right=30]`,\n\t\t\"elk.nodeLabels.placement\": \"[H_LEFT,V_TOP,INSIDE]\",\n\t\t\"elk.spacing.labelNode\": \"10\",\n\t};\n}\n\n/**\n * checkMeasuredLinks rejects broken ownership and endpoints before calling ELK,\n * so ELK never has to guess what the model meant.\n */\nfunction checkMeasuredLinks(\n\tdiagram: MeasuredDiagram,\n\tnodes: Map,\n\tgroups: Map,\n): void {\n\tfor (const node of diagram.nodes) {\n\t\tif (node.parentId && !groups.has(node.parentId)) {\n\t\t\tthrow new Error(`node ${node.id} has missing parent group ${node.parentId}`);\n\t\t}\n\t}\n\tfor (const group of diagram.groups) {\n\t\tif (group.parentId && !groups.has(group.parentId)) {\n\t\t\tthrow new Error(`group ${group.id} has missing parent group ${group.parentId}`);\n\t\t}\n\t}\n\tfor (const edge of diagram.edges) {\n\t\tif (!nodes.has(edge.sourceId) || !nodes.has(edge.targetId)) {\n\t\t\tthrow new Error(\n\t\t\t\t`edge ${edge.id} connects missing node ${edge.sourceId} or ${edge.targetId}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** lowestCommonGroup finds the nearest boundary that contains both endpoints. */\nfunction lowestCommonGroup(\n\tedge: MeasuredEdge,\n\tnodes: Map,\n\tgroups: Map,\n): string | undefined {\n\tconst sourceGroups = parentGroups(nodes.get(edge.sourceId)?.parentId, groups);\n\tconst targetGroups = new Set(parentGroups(nodes.get(edge.targetId)?.parentId, groups));\n\treturn sourceGroups.find(group => targetGroups.has(group));\n}\n\n/** parentGroups returns parent IDs from nearest to farthest. */\nfunction parentGroups(\n\tparentId: string | undefined,\n\tgroups: Map,\n): string[] {\n\tconst result: string[] = [];\n\tlet current = parentId;\n\twhile (current) {\n\t\tresult.push(current);\n\t\tcurrent = groups.get(current)?.parentId;\n\t}\n\treturn result;\n}\n\n/** readResolvedLayout changes ELK's parent-relative values into diagram positions. */\nfunction readResolvedLayout(\n\tdiagram: MeasuredDiagram,\n\troot: ElkNode,\n): ResolvedLayout {\n\tif (root.width === undefined || root.height === undefined) {\n\t\tthrow new Error(`ELK did not size diagram ${diagram.id}`);\n\t}\n\tconst nodes: ResolvedNode[] = [];\n\tconst groups: ResolvedGroup[] = [];\n\tconst edges: ResolvedEdge[] = [];\n\tconst measuredNodes = new Map(diagram.nodes.map(node => [node.id, node]));\n\tconst measuredGroups = new Map(diagram.groups.map(group => [group.id, group]));\n\n\treadContainer(\n\t\troot,\n\t\t0,\n\t\t0,\n\t\tmeasuredNodes,\n\t\tmeasuredGroups,\n\t\tnodes,\n\t\tgroups,\n\t\tedges,\n\t);\n\treturn {\n\t\tdiagramId: diagram.id,\n\t\tbounds: {x: 0, y: 0, width: root.width, height: root.height},\n\t\tnodes,\n\t\tgroups,\n\t\tedges,\n\t};\n}\n\n/**\n * readContainer walks one ELK group, adding its parent's position exactly once\n * to each child, edge point, and label box.\n */\nfunction readContainer(\n\tcontainer: ElkNode,\n\tparentX: number,\n\tparentY: number,\n\tmeasuredNodes: Map,\n\tmeasuredGroups: Map,\n\tnodes: ResolvedNode[],\n\tgroups: ResolvedGroup[],\n\tedges: ResolvedEdge[],\n): void {\n\tconst containerX = parentX + (container.x ?? 0);\n\tconst containerY = parentY + (container.y ?? 0);\n\tfor (const child of container.children ?? []) {\n\t\tconst childX = containerX + requiredNumber(child.x, child.id, \"x\");\n\t\tconst childY = containerY + requiredNumber(child.y, child.id, \"y\");\n\t\tconst width = requiredNumber(child.width, child.id, \"width\");\n\t\tconst height = requiredNumber(child.height, child.id, \"height\");\n\t\tconst measuredNode = measuredNodes.get(child.id);\n\t\tif (measuredNode) {\n\t\t\tnodes.push({\n\t\t\t\tid: child.id,\n\t\t\t\tparentId: measuredNode.parentId,\n\t\t\t\tbounds: {x: childX, y: childY, width, height},\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst measuredGroup = measuredGroups.get(child.id);\n\t\tif (!measuredGroup) {\n\t\t\tthrow new Error(`ELK returned unknown node ${child.id}`);\n\t\t}\n\t\tconst label = requiredLabel(child.labels?.[0], child.id);\n\t\tgroups.push({\n\t\t\tid: child.id,\n\t\t\tparentId: measuredGroup.parentId,\n\t\t\tbounds: {x: childX, y: childY, width, height},\n\t\t\ttitleBounds: {\n\t\t\t\tx: childX + requiredNumber(label.x, child.id, \"title x\"),\n\t\t\t\ty: childY + requiredNumber(label.y, child.id, \"title y\"),\n\t\t\t\twidth: requiredNumber(label.width, child.id, \"title width\"),\n\t\t\t\theight: requiredNumber(label.height, child.id, \"title height\"),\n\t\t\t},\n\t\t});\n\t\treadContainer(\n\t\t\tchild,\n\t\t\tcontainerX,\n\t\t\tcontainerY,\n\t\t\tmeasuredNodes,\n\t\t\tmeasuredGroups,\n\t\t\tnodes,\n\t\t\tgroups,\n\t\t\tedges,\n\t\t);\n\t}\n\tfor (const edge of container.edges ?? []) {\n\t\tedges.push(readEdge(edge, containerX, containerY));\n\t}\n}\n\n/** readEdge copies every ELK section and label without choosing new positions. */\nfunction readEdge(edge: ElkExtendedEdge, offsetX: number, offsetY: number): ResolvedEdge {\n\tconst sections = (edge.sections ?? []).map(section => [\n\t\taddOffset(section.startPoint, offsetX, offsetY),\n\t\t...(section.bendPoints ?? []).map(point => addOffset(point, offsetX, offsetY)),\n\t\taddOffset(section.endPoint, offsetX, offsetY),\n\t]);\n\tconst label = edge.labels?.[0];\n\treturn {\n\t\tid: edge.id,\n\t\tsourceId: requiredEndpoint(edge.sources, edge.id, \"source\"),\n\t\ttargetId: requiredEndpoint(edge.targets, edge.id, \"target\"),\n\t\tsections,\n\t\tlabelBounds: label ? {\n\t\t\tx: offsetX + requiredNumber(label.x, edge.id, \"label x\"),\n\t\t\ty: offsetY + requiredNumber(label.y, edge.id, \"label y\"),\n\t\t\twidth: requiredNumber(label.width, edge.id, \"label width\"),\n\t\t\theight: requiredNumber(label.height, edge.id, \"label height\"),\n\t\t} : undefined,\n\t};\n}\n\n/** addOffset changes one parent-relative ELK point into a diagram point. */\nfunction addOffset(point: ElkPoint, offsetX: number, offsetY: number): Point {\n\treturn {x: offsetX + point.x, y: offsetY + point.y};\n}\n\n/** requiredNumber rejects incomplete ELK output instead of filling in zero. */\nfunction requiredNumber(\n\tvalue: number | undefined,\n\telementId: string,\n\tfield: string,\n): number {\n\tif (value === undefined) {\n\t\tthrow new Error(`ELK omitted ${field} for ${elementId}`);\n\t}\n\treturn value;\n}\n\n/** requiredEndpoint requires each MDL relationship to have exactly one endpoint. */\nfunction requiredEndpoint(\n\tendpoints: string[],\n\tedgeId: string,\n\tfield: string,\n): string {\n\tif (endpoints.length !== 1) {\n\t\tthrow new Error(`ELK returned ${endpoints.length} ${field}s for edge ${edgeId}`);\n\t}\n\treturn endpoints[0];\n}\n\n/** requiredLabel rejects a group whose measured title was not placed by ELK. */\nfunction requiredLabel(label: ElkLabel | undefined, groupId: string): ElkLabel {\n\tif (!label) {\n\t\tthrow new Error(`ELK omitted title for group ${groupId}`);\n\t}\n\treturn label;\n}\n\n/** append adds a child to one parent entry while keeping model order. */\nfunction append(\n\titems: Map,\n\tparentId: string | undefined,\n\titem: T,\n): void {\n\tconst siblings = items.get(parentId) ?? [];\n\tsiblings.push(item);\n\titems.set(parentId, siblings);\n}\n","// This file connects the editable graph to the layout pipeline. It measures\n// the current SVG once, asks ELK for one complete answer, validates that answer,\n// and returns positions without changing them.\n\nimport {resolveAutomatic} from \"./automatic-layout\";\nimport {\n\tMeasuredDiagram,\n\tMeasuredEdge,\n\tMeasuredGroup,\n\tMeasuredNode,\n\tRect,\n\tResolvedLayout,\n\tValidatedLayout,\n\tvalidateResolvedLayout,\n} from \"./geometry\";\nimport {Edge, GraphData, Group, LayoutDirection, Node} from \"./graph\";\nimport {calculateEdgeVertices} from \"./edge-utils\";\nimport {resolveManual} from \"./manual-layout\";\n\n/** LayoutOptions are the explicit choices available to editor and CLI callers. */\nexport interface LayoutOptions {\n\tdirection?: LayoutDirection;\n\tnodeSpacing?: number;\n\tlayerSpacing?: number;\n\tcompactLayout?: boolean;\n}\n\n/** GraphLayout carries checked positions back to the editable graph. */\nexport interface GraphLayout {\n\tvalidated: ValidatedLayout;\n\tnodes: Array<{id: string; x: number; y: number}>;\n\tgroups: Array<{id: string; bounds: Rect; titleBounds: Rect}>;\n\tedges: Array<{\n\t\tid: string;\n\t\tsections: Array>;\n\t\tlabelBounds?: Rect;\n\t}>;\n}\n\n/**\n * autoLayout measures, lays out, and validates a graph. It does not catch\n * errors because callers must not save a diagram after any failed step.\n */\nexport async function autoLayout(\n\tgraph: GraphData,\n\toptions: LayoutOptions = {},\n): Promise {\n\tawait document.fonts.ready;\n\tconst measured = measureGraph(graph);\n\tconst spacing = options.compactLayout ? 56 : 80;\n\tconst resolved = await resolveAutomatic(measured, {\n\t\tdirection: options.direction ?? graph.layoutDirection ?? \"DOWN\",\n\t\tnodeSpacing: options.nodeSpacing ?? spacing,\n\t\tlayerSpacing: options.layerSpacing ?? spacing,\n\t});\n\tconst validated = validateResolvedLayout(measured, resolved);\n\tconst measuredNodes = new Map(measured.nodes.map(node => [node.id, node]));\n\treturn {\n\t\tvalidated,\n\t\tnodes: validated.nodes.map(node => {\n\t\t\tconst measuredNode = measuredNodes.get(node.id);\n\t\t\tif (!measuredNode) {\n\t\t\t\tthrow new Error(`validated layout contains unknown node ${node.id}`);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tid: node.id,\n\t\t\t\tx: node.bounds.x + measuredNode.centerOffset.x,\n\t\t\t\ty: node.bounds.y + measuredNode.centerOffset.y,\n\t\t\t};\n\t\t}),\n\t\tgroups: validated.groups.map(group => ({\n\t\t\tid: group.id,\n\t\t\tbounds: group.bounds,\n\t\t\ttitleBounds: group.titleBounds,\n\t\t})),\n\t\tedges: validated.edges.map(edge => ({\n\t\t\tid: edge.id,\n\t\t\tsections: edge.sections,\n\t\t\tlabelBounds: edge.labelBounds,\n\t\t})),\n\t};\n}\n\n/**\n * validateCurrentLayout adapts the fully drawn editor state into the manual\n * layout contract. It never reads automatic positions to fill missing data.\n */\nexport function validateCurrentLayout(graph: GraphData): ValidatedLayout {\n\tconst measured = measureGraph(graph);\n\tconst measuredNodes = new Map(measured.nodes.map(node => [node.id, node]));\n\tconst nodes = graph.nodes().map(node => {\n\t\tconst measuredNode = measuredNodes.get(node.id);\n\t\tif (!measuredNode) {\n\t\t\tthrow new Error(`measured diagram omitted node ${node.id}`);\n\t\t}\n\t\treturn {\n\t\t\tid: node.id,\n\t\t\tparentId: measuredNode.parentId,\n\t\t\tbounds: {\n\t\t\t\tx: node.x - measuredNode.centerOffset.x,\n\t\t\t\ty: node.y - measuredNode.centerOffset.y,\n\t\t\t\t...measuredNode.size,\n\t\t\t},\n\t\t};\n\t});\n\tconst groups = Array.from(graph.groupsMap.values()).map(group => {\n\t\tif (!group.ref?.isConnected) {\n\t\t\tthrow new Error(`group ${group.id} must be drawn before saving`);\n\t\t}\n\t\tconst boundary = group.ref.querySelector(\"rect\");\n\t\tconst title = group.ref.querySelector(\"text\");\n\t\tif (!(boundary instanceof SVGGraphicsElement) || !(title instanceof SVGGraphicsElement)) {\n\t\t\tthrow new Error(`group ${group.id} is missing its boundary or title`);\n\t\t}\n\t\treturn {\n\t\t\tid: group.id,\n\t\t\tparentId: measured.groups.find(candidate => candidate.id === group.id)?.parentId,\n\t\t\tbounds: copyBox(boundary.getBBox()),\n\t\t\ttitleBounds: copyBox(title.getBBox()),\n\t\t};\n\t});\n\tconst edges = graph.edges.map(edge => {\n\t\tconst sections = edge.layoutSections ?? [calculateEdgeVertices(edge)];\n\t\tconst labelBounds = edge.layoutLabelBounds ?? edge.labelBounds;\n\t\tif (edge.label.trim().length > 0 && !labelBounds) {\n\t\t\tthrow new Error(`edge ${edge.id} is missing its label position`);\n\t\t}\n\t\treturn {\n\t\t\tid: edge.id,\n\t\t\tsourceId: edge.from.id,\n\t\t\ttargetId: edge.to.id,\n\t\t\tsections,\n\t\t\tlabelBounds: labelBounds ? {...labelBounds} : undefined,\n\t\t};\n\t});\n\tconst snapshot: ResolvedLayout = {\n\t\tdiagramId: graph.id,\n\t\tbounds: contentBounds(nodes.map(node => node.bounds), groups, edges),\n\t\tnodes,\n\t\tgroups,\n\t\tedges,\n\t};\n\treturn resolveManual(measured, snapshot);\n}\n\n/**\n * measureGraph reads the exact node and label boxes already drawn by the\n * browser. Parent IDs come only from the model's declared groups.\n */\nfunction measureGraph(graph: GraphData): MeasuredDiagram {\n\tconst {nodeParents, groupParents} = declaredParents(graph);\n\treturn {\n\t\tid: graph.id,\n\t\tnodes: graph.nodes().map(node => measureNode(node, nodeParents.get(node.id))),\n\t\tgroups: Array.from(graph.groupsMap.values()).map(group =>\n\t\t\tmeasureGroup(group, groupParents.get(group.id)),\n\t\t),\n\t\tedges: graph.edges.map(measureEdge),\n\t};\n}\n\n/** measureNode returns the complete box drawn for one node and its center. */\nfunction measureNode(node: Node, parentId: string | undefined): MeasuredNode {\n\tif (!node.ref?.isConnected) {\n\t\tthrow new Error(`node ${node.id} must be drawn before layout`);\n\t}\n\tconst bounds = node.ref.getBBox();\n\tcheckMeasuredBox(node.id, bounds);\n\treturn {\n\t\tid: node.id,\n\t\tparentId,\n\t\tsize: {width: bounds.width, height: bounds.height},\n\t\tcontentSize: {width: bounds.width, height: bounds.height},\n\t\tcenterOffset: {x: -bounds.x, y: -bounds.y},\n\t\tshape: node.style.shape ?? \"Box\",\n\t};\n}\n\n/** measureGroup reads the title box already drawn by the browser. */\nfunction measureGroup(group: Group, parentId: string | undefined): MeasuredGroup {\n\tif (!group.ref?.isConnected) {\n\t\tthrow new Error(`group ${group.id} must be drawn before layout`);\n\t}\n\tconst title = group.ref.querySelector(\"text\");\n\tif (!(title instanceof SVGGraphicsElement)) {\n\t\tthrow new Error(`group ${group.id} is missing its drawn title`);\n\t}\n\tconst bounds = title.getBBox();\n\tcheckMeasuredBox(group.id, bounds);\n\treturn {\n\t\tid: group.id,\n\t\tparentId,\n\t\ttitleSize: {width: bounds.width, height: bounds.height},\n\t};\n}\n\n/** measureEdge uses the label background that the current SVG already drew. */\nfunction measureEdge(edge: Edge): MeasuredEdge {\n\tconst hasLabel = edge.label.trim().length > 0;\n\tif (hasLabel && !edge.labelBounds) {\n\t\tthrow new Error(`edge ${edge.id} must be drawn before layout`);\n\t}\n\treturn {\n\t\tid: edge.id,\n\t\tsourceId: edge.from.id,\n\t\ttargetId: edge.to.id,\n\t\tlabelSize: hasLabel ? {\n\t\t\twidth: edge.labelBounds?.width ?? 0,\n\t\t\theight: edge.labelBounds?.height ?? 0,\n\t\t} : undefined,\n\t};\n}\n\n/**\n * declaredParents records model ownership and rejects elements that appear in\n * more than one group. Visual position never decides ownership.\n */\nfunction declaredParents(graph: GraphData): {\n\tnodeParents: Map;\n\tgroupParents: Map;\n} {\n\tconst nodeParents = new Map();\n\tconst groupParents = new Map();\n\tfor (const group of graph.groupsMap.values()) {\n\t\tfor (const member of group.nodes) {\n\t\t\tconst parents = isGroup(member) ? groupParents : nodeParents;\n\t\t\tconst existing = parents.get(member.id);\n\t\t\tif (existing && existing !== group.id) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${isGroup(member) ? \"group\" : \"node\"} ${member.id} belongs to both ` +\n\t\t\t\t\t`${existing} and ${group.id}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tparents.set(member.id, group.id);\n\t\t}\n\t}\n\treturn {nodeParents, groupParents};\n}\n\n/** checkMeasuredBox rejects missing or invalid browser measurements. */\nfunction checkMeasuredBox(id: string, box: Rect): void {\n\tif (\n\t\t!Number.isFinite(box.x) ||\n\t\t!Number.isFinite(box.y) ||\n\t\t!Number.isFinite(box.width) ||\n\t\t!Number.isFinite(box.height) ||\n\t\tbox.width <= 0 ||\n\t\tbox.height <= 0\n\t) {\n\t\tthrow new Error(`browser returned invalid measured box for ${id}`);\n\t}\n}\n\n/** contentBounds returns the smallest box that contains all drawn geometry. */\nfunction contentBounds(\n\tnodes: Rect[],\n\tgroups: Array<{bounds: Rect; titleBounds: Rect}>,\n\tedges: Array<{sections: Array>; labelBounds?: Rect}>,\n): Rect {\n\tconst boxes = [\n\t\t...nodes,\n\t\t...groups.flatMap(group => [group.bounds, group.titleBounds]),\n\t\t...edges.flatMap(edge => edge.labelBounds ? [edge.labelBounds] : []),\n\t];\n\tconst points = edges.flatMap(edge => edge.sections.flat());\n\tif (boxes.length === 0 && points.length === 0) {\n\t\treturn {x: 0, y: 0, width: 0, height: 0};\n\t}\n\tconst left = Math.min(\n\t\t...boxes.map(box => box.x),\n\t\t...points.map(point => point.x),\n\t);\n\tconst top = Math.min(\n\t\t...boxes.map(box => box.y),\n\t\t...points.map(point => point.y),\n\t);\n\tconst right = Math.max(\n\t\t...boxes.map(box => box.x + box.width),\n\t\t...points.map(point => point.x),\n\t);\n\tconst bottom = Math.max(\n\t\t...boxes.map(box => box.y + box.height),\n\t\t...points.map(point => point.y),\n\t);\n\treturn {x: left, y: top, width: right - left, height: bottom - top};\n}\n\n/** copyBox copies the browser's read-only SVG box into the layout contract. */\nfunction copyBox(box: DOMRect): Rect {\n\treturn {x: box.x, y: box.y, width: box.width, height: box.height};\n}\n\n/** isGroup tells group boundaries from nodes without using display names. */\nfunction isGroup(member: Node | Group): member is Group {\n\treturn \"nodes\" in member;\n}\n","// Manual layout has its own entry point. It never fills missing positions from\n// automatic layout and never changes the positions a user authored.\n\nimport {\n\tMeasuredDiagram,\n\tResolvedLayout,\n\tValidatedLayout,\n\tvalidateResolvedLayout,\n} from \"./geometry\";\n\n/**\n * resolveManual checks one complete saved layout against the current measured\n * diagram. Missing or old IDs, incomplete routes, and collisions are errors.\n */\nexport function resolveManual(\n\tmeasured: MeasuredDiagram,\n\tcompleteSnapshot: ResolvedLayout,\n): ValidatedLayout {\n\treturn validateResolvedLayout(measured, completeSnapshot);\n}\n","type TextAttributes = Record;\n\ninterface TextSize {\n\twidth: number;\n\theight: number;\n}\n\n/** WrappedText contains the exact lines and widest rendered line. */\nexport interface WrappedText {\n\tlines: string[];\n\tmaxW: number;\n}\n\nconst measuredText = new Map();\nlet measurementSVG: SVGSVGElement | undefined;\n\n/** loadDiagramFonts completes local font loading before text is wrapped or measured. */\nexport async function loadDiagramFonts(): Promise {\n\tawait Promise.all([400, 600, 700].map(weight => document.fonts.load(`${weight} 22px Inter`)));\n\tawait document.fonts.ready;\n}\n\n/**\n * measureSVGText returns the browser's rendered text size. Results are cached\n * because node and edge layout often measures the same words many times.\n */\nexport function measureSVGText(text: string, attrs: TextAttributes): TextSize {\n\tconst key = measurementKey(text, attrs);\n\tconst cached = measuredText.get(key);\n\tif (cached) {\n\t\treturn cached;\n\t}\n\n\tconst node = document.createElementNS(\"http://www.w3.org/2000/svg\", \"text\");\n\tnode.setAttribute(\"x\", \"0\");\n\tnode.setAttribute(\"y\", \"0\");\n\tfor (const [name, value] of Object.entries(attrs)) {\n\t\tnode.setAttribute(name, value);\n\t}\n\tnode.textContent = text;\n\n\tconst svg = getMeasurementSVG();\n\tsvg.appendChild(node);\n\tconst bounds = node.getBBox();\n\tnode.remove();\n\tconst size = {width: bounds.width, height: bounds.height};\n\tmeasuredText.set(key, size);\n\treturn size;\n}\n\n/**\n * svgTextWrap splits text into lines that fit the given width. It uses the\n * same browser text sizes that SVG drawing uses.\n */\nexport function svgTextWrap(\n\ttext: string,\n\twidth: number,\n\tattrs: TextAttributes,\n): WrappedText {\n\tlet maxW = 0;\n\tconst lines = text.trim().split(\"\\n\").flatMap(paragraph => {\n\t\tconst paragraphLines: string[] = [];\n\t\tlet currentLine: string[] = [];\n\t\tfor (const word of paragraph.trim().split(/\\s+/)) {\n\t\t\tif (measureSVGText(word, attrs).width > width) {\n\t\t\t\tif (currentLine.length > 0) {\n\t\t\t\t\tparagraphLines.push(currentLine.join(\" \"));\n\t\t\t\t\tcurrentLine = [];\n\t\t\t\t}\n\t\t\t\tconst parts = breakLongWord(word, width, attrs);\n\t\t\t\tfor (const part of parts.slice(0, -1)) {\n\t\t\t\t\tparagraphLines.push(part);\n\t\t\t\t\tmaxW = Math.max(maxW, measureSVGText(part, attrs).width);\n\t\t\t\t}\n\t\t\t\tcurrentLine = parts.slice(-1);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst nextLine = [...currentLine, word];\n\t\t\tconst size = measureSVGText(nextLine.join(\" \"), attrs);\n\t\t\tif (size.width > width && currentLine.length > 0) {\n\t\t\t\tparagraphLines.push(currentLine.join(\" \"));\n\t\t\t\tcurrentLine = [word];\n\t\t\t} else {\n\t\t\t\tmaxW = Math.max(maxW, size.width);\n\t\t\t\tcurrentLine = nextLine;\n\t\t\t}\n\t\t}\n\t\tif (currentLine.length > 0) {\n\t\t\tconst line = currentLine.join(\" \");\n\t\t\tparagraphLines.push(line);\n\t\t\tmaxW = Math.max(maxW, measureSVGText(line, attrs).width);\n\t\t}\n\t\treturn paragraphLines;\n\t});\n\treturn {lines, maxW};\n}\n\n/** getMeasurementSVG creates the single hidden SVG used for text measurement. */\nfunction getMeasurementSVG(): SVGSVGElement {\n\tif (measurementSVG?.isConnected) {\n\t\treturn measurementSVG;\n\t}\n\tmeasurementSVG = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n\tmeasurementSVG.setAttribute(\"aria-hidden\", \"true\");\n\tmeasurementSVG.style.position = \"absolute\";\n\tmeasurementSVG.style.visibility = \"hidden\";\n\tmeasurementSVG.style.pointerEvents = \"none\";\n\tdocument.body.appendChild(measurementSVG);\n\treturn measurementSVG;\n}\n\n/** measurementKey gives equal text and font settings the same cache entry. */\nfunction measurementKey(text: string, attrs: TextAttributes): string {\n\tconst attributes = Object.entries(attrs).sort(([first], [second]) =>\n\t\tfirst.localeCompare(second),\n\t);\n\treturn JSON.stringify([text, attributes]);\n}\n\n/** breakLongWord splits one word only when it cannot fit on an empty line. */\nfunction breakLongWord(\n\tword: string,\n\tmaxWidth: number,\n\tattrs: TextAttributes,\n): string[] {\n\tconst parts: string[] = [];\n\tlet currentPart = \"\";\n\tfor (const character of word) {\n\t\tconst nextPart = currentPart + character;\n\t\tif (measureSVGText(nextPart, attrs).width > maxWidth && currentPart.length > 0) {\n\t\t\tparts.push(currentPart);\n\t\t\tcurrentPart = character;\n\t\t} else {\n\t\t\tcurrentPart = nextPart;\n\t\t}\n\t}\n\tif (currentPart.length > 0) {\n\t\tparts.push(currentPart);\n\t}\n\treturn parts;\n}\n\n\n","import {GraphData, LayoutDirection, NodeLink} from \"./graph-view/graph\";\nimport {EdgeStyle, NodeStyle} from \"./graph-view/constants\";\n\n\ninterface Model {\n\tname: string\n\tdescription: string\n\tversion: string\n\tmodel: {\n\t\tenterprise: {\n\t\t\tname: string\n\t\t}\n\t\tpeople: Element[]\n\t\tsoftwareSystems: Element[]\n\t\tdeploymentNodes: Element[]\n\t}\n\tviews: {\n\t\tsystemLandscapeViews: View[]\n\t\tcontainerViews: View[]\n\t\tcomponentViews: View[]\n\t\tdynamicViews: View[]\n\t\tdeploymentViews: View[]\n\t\tstyles: {\n\t\t\telements: (NodeStyle & {tag: string})[];\n\t\t\trelationships: (EdgeStyle & {tag: string})[];\n\t\t}\n\t}\n}\n\ninterface Layouts {\n\t[key: string]: { // keyed by view key\n\t\t[key: string]: { x: number; y: number } // keyed by element id\n\t}\n}\n\ninterface Element {\n\tid: string;\n\tname: string;\n\ttechnology?: string;\n\tdescription?: string;\n\turl?: string;\n\tparent?: Element;\n\ttags?: string;\n\tlocation?: string;\n\tcontainers?: Element[];\n\tcomponents?: Element[];\n\trelationships?: Relation[];\n\tproperties?: { [key: string]: string }\n\tchildren?: Element[];\n\tinfrastructureNodes?: Element[];\n}\n\ninterface Relation {\n\tid: string;\n\tdescription: string;\n\ttags: string;\n\tsourceId: string;\n\tdestinationId: string;\n\ttechnology: string;\n\tinteractionStyle: string;\n}\n\ntype RankDirection = 'TopBottom' | 'BottomTop' | 'LeftRight' | 'RightLeft';\n\ninterface View {\n\tkey: string;\n\ttitle: string;\n\tdescription: string\n\tautomaticLayout?: {\n\t\trankDirection?: RankDirection;\n\t};\n\telements: {\n\t\tid: string\n\t}[];\n\trelationships: {\n\t\tid: string;\n\t\tvertices: { x: number; y: number }[];\n\t\trouting: string; // takes priority over style\n\t}[];\n\tsoftwareSystemId?: string;\n\tcontainerId?: string;\n\texternalContainersBoundariesVisible?: boolean;\n}\n\nconst layoutDirections: Record = {\n\tTopBottom: 'DOWN',\n\tBottomTop: 'UP',\n\tLeftRight: 'RIGHT',\n\tRightLeft: 'LEFT',\n};\n\ninterface Metadata {\n\tname: string\n\tdescription: string\n\tversion: string\n\telements: {\n\t\tid: string\n\t\ttags?: string;\n\t\tlocation?: string;\n\t\tproperties?: { [key: string]: string };\n\t\telementViewKey?: string;\n\t\ttechnology?: string;\n\t\turl?: string;\n\t}[]\n}\n\nexport type ViewsList = {\n\tkey: string;\n\ttitle: string;\n\tsection: string;\n}[]\n\nexport const parseView = (model: Model, layouts: Layouts, viewKey: string) => {\n\n\tconst elements = new Map();\n\tconst relations = new Map();\n\n\tconst collectRels = (el: Element) => {\n\t\tif (Array.isArray(el.relationships)) {\n\t\t\tel.relationships.forEach(rel => {\n\t\t\t\trelations.set(rel.id, rel)\n\t\t\t})\n\t\t}\n\t}\n\n\t// People\n\tmodel.model.people && model.model.people.forEach((el: Element) => {\n\t\telements.set(el.id, el)\n\t\tif (Array.isArray(el.relationships)) {\n\t\t\tel.relationships.forEach(rel => {\n\t\t\t\trelations.set(rel.id, rel)\n\t\t\t})\n\t\t}\n\t})\n\t// Software Systems\n\tmodel.model.softwareSystems && model.model.softwareSystems.forEach((el: Element) => {\n\t\telements.set(el.id, el)\n\t\tcollectRels(el)\n\n\t\tif (Array.isArray(el.containers)) {\n\t\t\tel.containers.forEach((el1: Element) => {\n\t\t\t\tel1.parent = el;\n\t\t\t\telements.set(el1.id, el1)\n\t\t\t\tcollectRels(el1)\n\t\t\t\tif (Array.isArray(el1.components)) {\n\t\t\t\t\tel1.components.forEach((el2: Element) => {\n\t\t\t\t\t\tel2.parent = el1;\n\t\t\t\t\t\telements.set(el2.id, el2)\n\t\t\t\t\t\tcollectRels(el2)\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t})\n\n\t// Deployment Nodes\n\tif (model.model.deploymentNodes) {\n\t\tconst containerInstances = (el: any) => {\n\t\t\tel.containerInstances && el.containerInstances.forEach((item: any) => {\n\t\t\t\tconst el1 = {...elements.get(item.containerId), id: item.id}\n\t\t\t\telements.set(el1.id, el1)\n\t\t\t\tel1.parent = el\n\t\t\t\tcollectRels(item)\n\t\t\t})\n\t\t}\n\n\t\tconst recAddNodes = (el: Element, parent: Element) => {\n\t\t\tel.parent = parent;\n\t\t\telements.set(el.id, el)\n\t\t\tcollectRels(el)\n\t\t\tcontainerInstances(el)\n\t\t\tel.children && el.children.forEach((el1: Element) => recAddNodes(el1, el))\n\t\t\tel.infrastructureNodes && el.infrastructureNodes.forEach((el1: Element) => recAddNodes(el1, el))\n\t\t}\n\n\t\tmodel.model.deploymentNodes.forEach((el: Element) => recAddNodes(el, null))\n\t}\n\n\t// Create graph from selected view\n\tconst {view, section} = getView(model, viewKey)\n\n\tif (!view) return null\n\n\tconst graph = new GraphData(view.key, view.title || view.key)\n\tconst rankDirection = view.automaticLayout?.rankDirection\n\tgraph.layoutDirection = rankDirection ? layoutDirections[rankDirection] : undefined\n\tconst metadata: Metadata = {name: graph.name, description: view.description, version: model.version, elements: []}\n\tgraph.metadata = metadata\n\n\tif (!view.elements) return graph\n\n\t//grouping rules - elements that are groups will not be nodes\n\tconst groupingIDs: { [key: string]: boolean } = {}\n\tif (section == 'deploymentViews' || section == 'containerViews') {\n\t\tview.elements.forEach(ref => {\n\t\t\tconst el = elements.get(ref.id)\n\t\t\tif (el?.parent) {\n\t\t\t\tgroupingIDs[el.parent.id] = true\n\t\t\t}\n\t\t})\n\t} else if (section === 'componentViews') {\n\t\t// Selected components belong to the view's container. Other containers\n\t\t// receive boundaries only when the view requests them.\n\t\tview.elements.forEach(ref => {\n\t\t\tconst parent = elements.get(ref.id)?.parent;\n\t\t\tif (!parent?.components) return;\n\t\t\tif (parent.id !== view.containerId && !view.externalContainersBoundariesVisible) return;\n\t\t\t// A container listed as a node keeps its own relationships; it cannot\n\t\t\t// also be replaced by a group with the same identifier.\n\t\t\tif (!view.elements.some(candidate => candidate.id === parent.id)) {\n\t\t\t\tgroupingIDs[parent.id] = true;\n\t\t\t}\n\t\t});\n\t} else if (view.softwareSystemId) {\n\t\t//don't show grouping if the element is listed in the view\n\t\tif (!view.elements.find(ref => ref.id == view.softwareSystemId))\n\t\t\tgroupingIDs[view.softwareSystemId] = true\n\t} else if (section == 'systemLandscapeViews') {\n\t\t// create a virtual parent element from enterprise\n\t\tconst p: Element = {id: '__enterprise__', ...model.model.enterprise}\n\t\telements.set(p.id, p)\n\t\tif (model.model.people) model.model.people.filter(el => el.location != 'External').forEach(el => el.parent = p)\n\t\tif (model.model.softwareSystems) model.model.softwareSystems.filter(el => el.location != 'External').forEach(el => el.parent = p)\n\t\tgroupingIDs[p.id] = true\n\t}\n\n\tconst styles = model.views.styles\n\n\t// Build color-to-variable mapping for CSS custom properties theming\n\tconst cssClassName = (tag: string) => tag.toLowerCase().replace(/[^a-z0-9-]/g, '-')\n\t\n\tif (styles?.elements) {\n\t\tstyles.elements.forEach(s => {\n\t\t\tif (s.tag) {\n\t\t\t\tconst varPrefix = `--mdl-${cssClassName(s.tag)}`\n\t\t\t\tif (s.background) graph.colorToVarMap.set(s.background as string, `${varPrefix}-bg`)\n\t\t\t\tif (s.color) graph.colorToVarMap.set(s.color as string, `${varPrefix}-color`)\n\t\t\t\tif (s.stroke) graph.colorToVarMap.set(s.stroke as string, `${varPrefix}-stroke`)\n\t\t\t}\n\t\t})\n\t}\n\n\tif (styles?.relationships) {\n\t\tstyles.relationships.forEach(s => {\n\t\t\tif (s.tag) {\n\t\t\t\tconst varPrefix = `--mdl-rel-${cssClassName(s.tag)}`\n\t\t\t\tif (s.color) graph.colorToVarMap.set(s.color as string, `${varPrefix}-color`)\n\t\t\t}\n\t\t})\n\t}\n\n\t//nodes\n\tview.elements.forEach((ref) => {\n\t\t// except grouping elements\n\t\tif (groupingIDs[ref.id]) return\n\n\t\tconst el = elements.get(ref.id)\n\t\tconst elementViewKey = el ? lookupContainerViewKey(model, el.id) : undefined\n\n\t\tlet sub = ''\n\t\tlet style = {}\n\t\tif (el) {\n\t\t\tconst tags = el.tags.split(',')\n\t\t\tsub = tags[tags.length - 1] // subtitle is []\n\t\t\tif (el.technology)\n\t\t\t\tsub += ': ' + el.technology // or [: ]\n\n\t\t\ttags.forEach(tag => {\n\t\t\t\tconst s = styles && styles.elements && styles.elements.find(s => s.tag == tag)\n\t\t\t\ts && (style = {...style, ...s})\n\t\t\t})\n\t\t}\n\n\t\tgraph.addNode(\n\t\t\tref.id,\n\t\t\tel ? (el.name || ref.id) : ref.id,\n\t\t\tsub,\n\t\t\t(el && el.description) ? el.description : '',\n\t\t\tstyle,\n\t\t\tnodeLink(el, elementViewKey)\n\t\t)\n\t\tel && metadata.elements.push({\n\t\t\tid: el.id,\n\t\t\ttags: el.tags,\n\t\t\tlocation: el.location,\n\t\t\tproperties: el.properties,\n\t\t\telementViewKey,\n\t\t\ttechnology: el.technology,\n\t\t\turl: el.url\n\t\t})\n\t})\n\t//edges\n\tif (Array.isArray(view.relationships)) {\n\t\tview.relationships.forEach(ref => {\n\t\t\tconst rel = relations.get(ref.id)\n\t\t\tif (!rel) return;\n\n\t\t\tif (!graph.nodesMap.has(rel.sourceId)) {\n\t\t\t\tif (elements.has(rel.sourceId)) {\n\t\t\t\t\tconst el = elements.get(rel.sourceId)\n\t\t\t\t\tconsole.warn('Element not found in this view: ', el.id, el.name)\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('Element not found: ', rel.sourceId)\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!graph.nodesMap.has(rel.destinationId)) {\n\t\t\t\tif (elements.has(rel.destinationId)) {\n\t\t\t\t\tconst el = elements.get(rel.destinationId)\n\t\t\t\t\tconsole.warn('Element not found in this view: ', el.id, el.name)\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('Element not found: ', rel.destinationId)\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet style: any = {}\n\t\t\trel.tags.split(',').forEach(tag => {\n\t\t\t\tconst s = styles && styles.relationships && styles.relationships.find(s => s.tag == tag)\n\t\t\t\ts && (style = {...style, ...s})\n\t\t\t})\n\t\t\tif (ref.routing) style.routing = ref.routing\n\n\t\t\tconst label = rel.technology ? `${rel.description}\\n[${rel.technology}]` : rel.description\n\t\t\tgraph.addEdge(rel.id, rel.sourceId, rel.destinationId, label, ref.vertices, style)\n\t\t})\n\t}\n\n\t//groups\n\t//sort by depth to solve dependency\n\tconst level = (el: Element) => {\n\t\tlet i = 0\n\t\tfor (let p = el.parent; p; p = p.parent) i++;\n\t\treturn i\n\t}\n\tconst gElements = Object.keys(groupingIDs)\n\t\t.map(id => elements.get(id))\n\t\t.sort((a, b) => level(a) > level(b) ? -1 : 1)\n\n\tgElements.forEach(parent => {\n\t\tlet style = {}\n\t\tif (section == 'deploymentViews') {\n\t\t\tconst el = elements.get(parent.id)\n\t\t\tconst tags = el.tags.split(',')\n\t\t\ttags.forEach(tag => {\n\t\t\t\tconst s = styles && styles.elements && styles.elements.find(s => s.tag == tag)\n\t\t\t\ts && (style = {...style, ...s})\n\t\t\t})\n\t\t}\n\t\t\n\t\t// Filter group members more carefully to respect boundaries\n\t\tconst groupMembers = view.elements\n\t\t\t.map(ref => elements.get(ref.id))\n\t\t\t.filter(el => {\n\t\t\t\tif (!el || el.parent !== parent) return false;\n\t\t\t\t\n\t\t\t\t// For system landscape views, respect the location-based grouping\n\t\t\t\tif (section === 'systemLandscapeViews' && parent.id === '__enterprise__') {\n\t\t\t\t\t// Only include elements that are explicitly non-external\n\t\t\t\t\treturn el.location !== 'External';\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// For other view types, include if parent matches\n\t\t\t\treturn true;\n\t\t\t})\n\t\t\t.map(el => el.id);\n\t\t\n\t\t// Only create group if it has members\n\t\tif (groupMembers.length > 0) {\n\t\t\tgraph.addGroup(\n\t\t\t\tparent.id,\n\t\t\t\tparent.name,\n\t\t\t\tgroupMembers,\n\t\t\t\tstyle\n\t\t\t)\n\t\t}\n\t})\n\n\t//layout if any and init graph\n\tgraph.init(layouts[graph.id])\n\treturn graph\n}\n\nfunction nodeLink(element: Element | undefined, elementViewKey: string | undefined): NodeLink | undefined {\n\tif (elementViewKey) {\n\t\tconst encodedViewKey = encodeURIComponent(elementViewKey)\n\t\treturn {\n\t\t\thref: `?id=${encodedViewKey}`,\n\t\t\texportHref: `${encodedViewKey}.svg`,\n\t\t}\n\t}\n\tif (element?.url) {\n\t\treturn {\n\t\t\thref: element.url,\n\t\t\texportHref: element.url,\n\t\t}\n\t}\n\treturn undefined\n}\n\n// lookup the view in all Views sections in the model. return the view and the section\nfunction getView(model: Model, viewKey: string) {\n\tlet view: View = null, section: string = ''\n\tObject.keys(model.views).filter(s => s.endsWith('Views')).some((s: string) => {\n\t\treturn ((model.views as any)[s]).some((v: View) => {\n\t\t\tif (v.key == viewKey) {\n\t\t\t\tview = v\n\t\t\t\tsection = s\n\t\t\t\treturn true\n\t\t\t}\n\t\t})\n\t})\n\treturn {view, section}\n}\n\n\nfunction lookupContainerViewKey(model: Model, softwareSystemId: string) {\n\tconst view = model.views.containerViews?.find(candidate => candidate.softwareSystemId == softwareSystemId)\n\treturn view?.key\n}\n\nexport const listViews = (model: any) => {\n\tconst viewsList: ViewsList = []\n\tconst sections = Object.keys(model.views).filter(section => section.endsWith('Views'))\n\tsections.forEach(s => {\n\t\tmodel.views[s].forEach((v: View) => {\n\t\t\tviewsList.push({key: v.key, title: v.title || v.key, section: s})\n\t\t})\n\t})\n\treturn viewsList;\n}\n","import React, {FC} from \"react\";\nimport { isMac, getModifierKeyName, getModifierKeyProperty } from './utils/platform';\n\ninterface Combination {\n\tctrl?: boolean;\n\tshift?: boolean;\n\talt?: boolean;\n\twheel?: boolean\n\tkey?: string;\n\tclick?: boolean;\n}\n\ninterface Shortcut {\n\tid: string,\n\thelp: string,\n\tcombinations: Combination[]\n}\n\nexport const SAVE = 'save'\n\nexport const UNDO = 'undo'\nexport const REDO = 'redo'\nexport const ADD_VERTEX = 'add-vertex'\nexport const ADD_LABEL_VERTEX = 'add-label-vertex'\nexport const DEL_VERTEX = 'del-vertex'\n\nexport const ZOOM_IN = 'zoom-in'\nexport const ZOOM_OUT = 'zoom-out'\nexport const ZOOM_FIT = 'zoom-fit'\nexport const ZOOM_100 = 'zoom-100'\n\nexport const SELECT_ALL = 'select-all'\nexport const DESELECT = 'deselect'\n\nexport const MOVE_LEFT = 'move-left'\nexport const MOVE_RIGHT = 'move-right'\nexport const MOVE_UP = 'move-up'\nexport const MOVE_DOWN = 'move-down'\nexport const MOVE_LEFT_FINE = 'move-left-fine'\nexport const MOVE_RIGHT_FINE = 'move-right-fine'\nexport const MOVE_UP_FINE = 'move-up-fine'\nexport const MOVE_DOWN_FINE = 'move-down-fine'\n\nexport const PAN_VIEW = 'pan-view'\nexport const SELECT_ELEMENT = 'select-element'\nexport const MULTI_SELECT = 'multi-select'\nexport const BOX_SELECT = 'box-select'\nexport const MOVE_ELEMENTS = 'move-elements'\n\nexport const HELP = 'help'\n\n// New shortcuts for toolbar buttons\nexport const TOGGLE_DRAG_MODE = 'toggle_drag_mode'\nexport const ALIGN_HORIZONTAL = 'align_horizontal'\nexport const ALIGN_VERTICAL = 'align_vertical'\nexport const DISTRIBUTE_HORIZONTAL = 'distribute_horizontal'\nexport const DISTRIBUTE_VERTICAL = 'distribute_vertical'\nexport const AUTO_LAYOUT = 'auto_layout'\nexport const RESET_POSITION = 'reset_position'\nexport const TOGGLE_GRID = 'toggle_grid'\nexport const TOGGLE_SNAP_TO_GRID = 'toggle_snap_to_grid'\nexport const SNAP_ALL_TO_GRID = 'snap_all_to_grid'\n\nconst shortcuts: { name: string; list: Shortcut[] }[] = [\n\t{\n\t\tname: 'Help',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: HELP,\n\t\t\t\thelp: 'Show/hide this help',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{key: '?', shift: true},\n\t\t\t\t\t{key: 'F1', shift: true}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'File',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: SAVE,\n\t\t\t\thelp: 'Save',\n\t\t\t\tcombinations: [{key: 's', ctrl: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'History',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: UNDO,\n\t\t\t\thelp: 'Undo',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, key: 'z'},\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: REDO,\n\t\t\t\thelp: 'Redo',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, shift: true, key: 'z'},\n\t\t\t\t\t{ctrl: true, key: 'y'},\n\t\t\t\t]\n\t\t\t}\n\n\t\t],\n\t},\n\t{\n\t\tname: 'Relationship editing',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: ADD_VERTEX,\n\t\t\t\thelp: 'Add relationship vertex',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{alt: true, click: true},\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ADD_LABEL_VERTEX,\n\t\t\t\thelp: 'Add label anchor relationship vertex',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{alt: true, shift: true, click: true},\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DEL_VERTEX,\n\t\t\t\thelp: 'Remove relationship vertex',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{key: 'DELETE'},\n\t\t\t\t\t{key: 'BACKSPACE'}\n\t\t\t\t]\n\t\t\t},\n\t\t]\n\t},\n\t{\n\t\tname: 'Zoom',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: ZOOM_IN,\n\t\t\t\thelp: 'Zoom in',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, key: '='}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ZOOM_OUT,\n\t\t\t\thelp: 'Zoom out',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, key: '-'}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ZOOM_FIT,\n\t\t\t\thelp: 'Zoom - fit',\n\t\t\t\tcombinations: [{ctrl: true, key: '9'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ZOOM_100,\n\t\t\t\thelp: 'Zoom 100%',\n\t\t\t\tcombinations: [{ctrl: true, key: '0'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'wheel_zoom',\n\t\t\t\thelp: 'Zoom in/out with mouse wheel',\n\t\t\t\tcombinations: [{wheel: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Mouse Interactions',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: PAN_VIEW,\n\t\t\t\thelp: 'Pan view (drag empty space)',\n\t\t\t\tcombinations: [{click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: SELECT_ELEMENT,\n\t\t\t\thelp: 'Select element',\n\t\t\t\tcombinations: [{click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MULTI_SELECT,\n\t\t\t\thelp: 'Add/remove from selection',\n\t\t\t\tcombinations: [{shift: true, click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: BOX_SELECT,\n\t\t\t\thelp: 'Box selection (drag empty space)',\n\t\t\t\tcombinations: [{shift: true, click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_ELEMENTS,\n\t\t\t\thelp: 'Move selected elements',\n\t\t\t\tcombinations: [{click: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Select',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: SELECT_ALL,\n\t\t\t\thelp: 'Select All',\n\t\t\t\tcombinations: [{ctrl: true, key: 'a'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DESELECT,\n\t\t\t\thelp: 'Deselect',\n\t\t\t\tcombinations: [{key: 'ESC'}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Move',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: MOVE_UP,\n\t\t\t\thelp: 'Move up (grid increment)',\n\t\t\t\tcombinations: [{key: 'UP'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_UP_FINE,\n\t\t\t\thelp: 'Move up (1 pixel)',\n\t\t\t\tcombinations: [{key: 'UP', shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_RIGHT,\n\t\t\t\thelp: 'Move right (grid increment)',\n\t\t\t\tcombinations: [{key: 'RIGHT'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_RIGHT_FINE,\n\t\t\t\thelp: 'Move right (1 pixel)',\n\t\t\t\tcombinations: [{key: 'RIGHT', shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_DOWN,\n\t\t\t\thelp: 'Move down (grid increment)',\n\t\t\t\tcombinations: [{key: 'DOWN'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_DOWN_FINE,\n\t\t\t\thelp: 'Move down (1 pixel)',\n\t\t\t\tcombinations: [{key: 'DOWN', shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_LEFT,\n\t\t\t\thelp: 'Move left (grid increment)',\n\t\t\t\tcombinations: [{key: 'LEFT'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_LEFT_FINE,\n\t\t\t\thelp: 'Move left (1 pixel)',\n\t\t\t\tcombinations: [{key: 'LEFT', shift: true}]\n\t\t\t},\n\t\t]\n\t},\n\t\t\t{\n\t\t\tname: 'View',\n\t\t\tlist: [\n\t\t\t\t{\n\t\t\t\t\tid: TOGGLE_DRAG_MODE,\n\t\t\t\t\thelp: 'Toggle between pan and select mode',\n\t\t\t\t\tcombinations: [{key: 't'}]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: RESET_POSITION,\n\t\t\t\t\thelp: 'Reset position and view',\n\t\t\t\t\tcombinations: [{key: 'Home', ctrl: true}]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t{\n\t\tname: 'Alignment',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: ALIGN_HORIZONTAL,\n\t\t\t\thelp: 'Align selected elements horizontally',\n\t\t\t\tcombinations: [{key: 'h', ctrl: true, shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ALIGN_VERTICAL,\n\t\t\t\thelp: 'Align selected elements vertically',\n\t\t\t\tcombinations: [{key: 'a', ctrl: true, shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DISTRIBUTE_HORIZONTAL,\n\t\t\t\thelp: 'Distribute selected elements horizontally',\n\t\t\t\tcombinations: [{key: 'h', ctrl: true, alt: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DISTRIBUTE_VERTICAL,\n\t\t\t\thelp: 'Distribute selected elements vertically',\n\t\t\t\tcombinations: [{key: 'v', ctrl: true, alt: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Layout',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: AUTO_LAYOUT,\n\t\t\t\thelp: 'Auto layout all elements',\n\t\t\t\tcombinations: [{key: 'l', ctrl: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Grid',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: TOGGLE_GRID,\n\t\t\t\thelp: 'Toggle grid visibility',\n\t\t\t\tcombinations: [{key: 'g', ctrl: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: TOGGLE_SNAP_TO_GRID,\n\t\t\t\thelp: 'Toggle snap to grid',\n\t\t\t\tcombinations: [{key: 'g', ctrl: true, shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: SNAP_ALL_TO_GRID,\n\t\t\t\thelp: 'Snap all elements to grid',\n\t\t\t\tcombinations: [{key: 'g', ctrl: true, alt: true}]\n\t\t\t}\n\t\t]\n\t}\n]\n\nconst shortcutMap = shortcuts\n\t.reduce((lst, s) => lst.concat(s.list), [] as Shortcut[])\n\t.reduce<{ [k: string]: Shortcut }>((map, s) => {\n\t\tmap[s.id] = s;\n\t\treturn map\n\t}, {})\n\nconst checkKey = (e: KeyboardEvent | MouseEvent, shortcut: Shortcut, click: boolean, wheel: boolean) => {\n\treturn shortcut.combinations.some(c => {\n\t\tif (Boolean(c.shift) != e.shiftKey) return false\n\t\t// Use platform-appropriate modifier key\n\t\tif (c.ctrl) {\n\t\t\tconst modifierKey = getModifierKeyProperty(e as KeyboardEvent);\n\t\t\tif (!modifierKey) return false;\n\t\t}\n\t\tif (Boolean(c.alt) != e.altKey) return false\n\t\tif (click) return c.click\n\t\tif (wheel) return c.wheel\n\t\tif (c.key) {\n\t\t\tconst ke = e as KeyboardEvent\n\t\t\tif (c.key == 'DELETE') return ke.key == 'Delete'\n\t\t\tif (c.key == 'BACKSPACE') return ke.key == 'Backspace'\n\t\t\tif (c.key == 'ESC') return ke.key == 'Escape'\n\t\t\tif (c.key == 'UP') return ke.key == 'ArrowUp'\n\t\t\tif (c.key == 'DOWN') return ke.key == 'ArrowDown'\n\t\t\tif (c.key == 'LEFT') return ke.key == 'ArrowLeft'\n\t\t\tif (c.key == 'RIGHT') return ke.key == 'ArrowRight'\n\t\t\treturn c.key && ke.key && c.key.toLowerCase() == ke.key.toLowerCase()\n\t\t}\n\t\treturn false\n\t})\n}\n\nexport const findShortcut = (e: KeyboardEvent | MouseEvent, click = false, wheel = false) => {\n\t// Find all matching shortcuts\n\tconst matches = Object.keys(shortcutMap).filter(k => checkKey(e, shortcutMap[k], click, wheel))\n\t\n\tif (matches.length === 0) return undefined\n\tif (matches.length === 1) return matches[0]\n\t\n\t// If multiple matches, prefer the one with more specific modifiers\n\t// Sort by number of modifiers (shift, ctrl, alt) in descending order\n\tconst sortedMatches = matches.sort((a, b) => {\n\t\tconst aShortcut = shortcutMap[a]\n\t\tconst bShortcut = shortcutMap[b]\n\t\t\n\t\tconst aModifiers = aShortcut.combinations[0]\n\t\tconst bModifiers = bShortcut.combinations[0]\n\t\t\n\t\tconst aCount = (aModifiers.shift ? 1 : 0) + (aModifiers.ctrl ? 1 : 0) + (aModifiers.alt ? 1 : 0)\n\t\tconst bCount = (bModifiers.shift ? 1 : 0) + (bModifiers.ctrl ? 1 : 0) + (bModifiers.alt ? 1 : 0)\n\t\t\n\t\treturn bCount - aCount // Descending order (more modifiers first)\n\t})\n\t\n\treturn sortedMatches[0]\n}\n\nconst comboText = (c: Combination) => {\n\treturn [\n\t\tc.ctrl && getModifierKeyName().toUpperCase(),\n\t\tc.shift && 'SHIFT',\n\t\tc.alt && 'ALT',\n\t\tc.key && (c.key.length > 1 ? c.key : `\"${c.key.toUpperCase()}\"`),\n\t\tc.click && 'CLICK',\n\t\tc.wheel && 'WHEEL'\n\t].filter(Boolean).join(' + ')\n}\n\nexport const Help: FC = () => {\n\treturn
\n\t\t

Shortcuts

\n\t\t\n\t\t\t\n\t\t\t{\n\t\t\t\tshortcuts.map(section => <>\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t{section.list.map(item => \n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t)\n\t\t\t}\n\t\t\t\n\t\t
{section.name}
{item.combinations.map(comboText).join(', ')}{item.help}
\n\t
\n}\n","/**\n * Robust platform detection utilities\n */\n\n/**\n * Detects if the user is on a Mac platform using multiple detection methods\n * for maximum compatibility across browsers and future-proofing.\n */\nexport const isMac = (): boolean => {\n if (typeof navigator === 'undefined') return false;\n \n // Method 1: Check userAgentData (modern browsers, most reliable)\n if ('userAgentData' in navigator && (navigator as any).userAgentData) {\n const platform = (navigator as any).userAgentData.platform;\n if (platform && platform.toLowerCase().includes('mac')) {\n return true;\n }\n }\n \n // Method 2: Check userAgent string (widely supported)\n const userAgent = navigator.userAgent.toLowerCase();\n if (userAgent.includes('mac os') || userAgent.includes('macintosh')) {\n return true;\n }\n \n // Method 3: Check platform (fallback, deprecated but still widely supported)\n if (navigator.platform) {\n const platform = navigator.platform.toLowerCase();\n if (platform.includes('mac') || platform.includes('darwin')) {\n return true;\n }\n }\n \n // Method 4: Check for Mac-specific features as additional validation\n try {\n const testEvent = new KeyboardEvent('keydown', { metaKey: true });\n if (testEvent.metaKey !== undefined) {\n // Additional heuristic: Mac typically has different key layouts\n return /mac|darwin|os x/i.test(navigator.userAgent);\n }\n } catch (e) {\n // Ignore errors in older browsers\n }\n \n return false;\n};\n\n/**\n * Gets the appropriate modifier key name for the current platform\n */\nexport const getModifierKeyName = (): string => {\n return isMac() ? 'Cmd' : 'Ctrl';\n};\n\n/**\n * Gets the appropriate modifier key property for keyboard events\n */\nexport const getModifierKeyProperty = (event: KeyboardEvent): boolean => {\n return isMac() ? event.metaKey : event.ctrlKey;\n};\n\n/**\n * Gets the appropriate Alt key name for the current platform\n */\nexport const getAltKeyName = (): string => {\n return isMac() ? 'Option' : 'Alt';\n}; ","// Imports\nimport ___CSS_LOADER_API_SOURCEMAP_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/sourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/api.js\";\nimport ___CSS_LOADER_GET_URL_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/getUrl.js\";\nvar ___CSS_LOADER_URL_IMPORT_0___ = new URL(\"@fontsource/inter/files/inter-latin-400-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_1___ = new URL(\"@fontsource/inter/files/inter-latin-500-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_2___ = new URL(\"@fontsource/inter/files/inter-latin-600-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_3___ = new URL(\"@fontsource/inter/files/inter-latin-700-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_SOURCEMAP_IMPORT___);\nvar ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___);\nvar ___CSS_LOADER_URL_REPLACEMENT_1___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_1___);\nvar ___CSS_LOADER_URL_REPLACEMENT_2___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_2___);\nvar ___CSS_LOADER_URL_REPLACEMENT_3___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_3___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_0___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_1___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_2___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_3___}) format(\"woff2\");\n}\n`, \"\",{\"version\":3,\"sources\":[\"webpack://./src/fonts.css\"],\"names\":[],\"mappings\":\"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF\",\"sourcesContent\":[\"/* Local Inter files keep browser text measurement identical without internet access. */\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 400;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-400-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 500;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-500-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 600;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-600-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 700;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-700-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\"],\"sourceRoot\":\"\"}]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___;\n","// Imports\nimport ___CSS_LOADER_API_SOURCEMAP_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/sourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/api.js\";\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_SOURCEMAP_IMPORT___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `html, body, #root {\n height: 100%;\n}\n\nbody {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n color: #666;\n margin: 0;\n}\n\n#root {\n display: flex;\n flex-direction: column;\n}\n#root > div.graph {\n flex: 1;\n overflow: auto;\n position: relative;\n}\n\n.toolbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 10px;\n background-color: #f0f0f0;\n border-bottom: 1px solid #cccccc;\n}\n\n.toolbar > div {\n display: flex;\n align-items: center;\n}\n\n.toolbar button {\n padding: 5px 8px;\n margin: 0 2px;\n cursor: pointer;\n}\n\n.toolbar button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Drag mode toggle button styles */\n.toolbar button.mode-toggle {\n position: relative;\n border: 1px solid #8f9fc9;\n width: 40px;\n min-height: 28px;\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\n border-color: #8f9fc9;\n color: white;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n}\n\n.toolbar button.mode-toggle:hover {\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\n border-color: #abb8db;\n}\n\n.toolbar button.mode-toggle.select-mode:active {\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\n}\n\n/* Pan mode and active toggle - darker blue */\n.toolbar button.mode-toggle.pan-mode,\n.toolbar button.active-toggle {\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n.toolbar button.mode-toggle.pan-mode:hover,\n.toolbar button.active-toggle:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\n.toolbar button.mode-toggle.pan-mode:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n/* Toggle buttons when inactive - gray styling */\n.toolbar button.inactive-toggle {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n.toolbar button.inactive-toggle:hover {\n background: #b1b1b1;\n}\n\n.toolbar button.inactive-toggle:active {\n background: #a1a1a1;\n}\n\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\n.toolbar button .fas {\n font-size: 1em;\n vertical-align: middle;\n}\n\n/* Zoom percentage display */\n.toolbar button.zoom-display {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n font-size: 11px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\n padding: 6px 8px;\n text-align: center;\n}\n\n.toolbar-group {\n display: flex;\n align-items: center;\n margin-right: 25px; /* Large space between groups */\n}\n\n.toolbar-group:last-child {\n margin-right: 0; /* Remove right margin from the last group (help button) */\n}\n\nbutton {\n border: none;\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n border-radius: 3px;\n padding: 6px 10px;\n color: #fff;\n outline: none;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n margin-right: 5px;\n min-width: 32px;\n min-height: 28px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n line-height: 1;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n position: relative;\n}\n\nbutton:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\nbutton:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n}\n\nbutton:last-child {\n margin-right: 0;\n}\n\n/* Save button when no changes - gray */\nbutton.action {\n background: #c1c1c1;\n color: #999;\n}\n\nbutton.action:active {\n background: #b1b1b1;\n}\n\n/* Save button when there are changes - orange */\nbutton.grp {\n background: linear-gradient(to bottom, #ee9564, #de7d48);\n margin-right: 0;\n}\n\nbutton.grp:active {\n background: #d67540;\n}\n\n/* Auto-arrange button with AI purple to blue gradient */\nbutton.auto-arrange {\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\n border-color: #4a4c93;\n}\n\nbutton.auto-arrange:hover {\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\n border-color: #5a5ca3;\n}\n\nbutton.auto-arrange:active {\n background: linear-gradient(135deg, #593B83, #357abd);\n border-color: #3a3c83;\n}\n\nselect {\n border: 1px solid #ccc;\n background: white;\n border-radius: 3px;\n padding: 3px 7px;\n color: #666;\n outline: none;\n margin-right: 5px;\n font-size: 12px;\n}\n\nselect:disabled {\n background: #f5f5f5;\n color: #999;\n}\n\nbutton:disabled {\n background: #c1c1c1;\n color: #999;\n}\n\n#root > div > svg {\n position: absolute;\n user-select: none;\n}\n\n\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\n stroke: #29c229;\n}\n.edge .v-dot {\n fill: transparent;\n stroke: transparent;\n stroke-width: 3px;\n cursor: pointer;\n transition: stroke 0.15s ease;\n}\n.edge .v-dot:hover {\n stroke: #999;\n fill: rgba(153, 153, 153, 0.1);\n}\n.edge .v-dot.selected {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.1);\n}\n.edge .v-dot.selected:hover {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.2);\n}\n.edge .v-dot.auto.selected {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.1);\n}\n.edge .v-dot.auto.selected:hover {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.2);\n}\ncircle#prj {\n fill: none;\n stroke: #777;\n}\n\n.nodeShadow {\n fill: none;\n stroke-width: 4px;\n stroke: rgba(0, 0, 0, 0.13);\n}\n\ng.node {\n user-select: none;\n cursor: default;\n}\n\ng.node.linked {\n cursor: pointer;\n}\n\ng.node text {\n pointer-events: none;\n}\n\n.icon {\n fill: #aaa;\n stroke: #fff;\n}\n#icon-cube {\n fill: #aaa;\n}\n\n/* Ensure all button icons are uncolored */\nbutton .icon,\nbutton svg,\nbutton path {\n fill: currentColor !important;\n stroke: none !important;\n}\n\n/* Font Awesome icon styling in buttons */\nbutton i {\n font-size: 12px;\n color: inherit;\n}\n\nrect.elastic {\n pointer-events: none;\n stroke: none;\n fill: #3bd8281f;\n display: none;\n}\nrect.elastic.on {\n display: block;\n}\n\n.popover {\n position: absolute;\n top: 50px;\n bottom: 10px;\n overflow: auto;\n right: 10px;\n background: ghostwhite;\n padding: 30px;\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\n border: solid 1px #eee;\n}\n\n.popover th {\n text-align: left;\n padding: 20px 0px 10px;\n}\n.popover td {\n padding-right: 20px;\n font-size: 14px;\n}\n\n/* Simple tooltip system with smart positioning */\n[data-tooltip] {\n position: relative;\n}\n\n[data-tooltip]:hover::after {\n content: attr(data-tooltip);\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(0, 0, 0, 0.9);\n color: white;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 12px !important;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n font-weight: normal !important;\n white-space: nowrap;\n z-index: 1000;\n pointer-events: none;\n margin-top: 5px;\n animation: tooltip-appear 0.1s ease-out;\n min-width: 120px;\n max-width: calc(100vw - 20px);\n box-sizing: border-box;\n}\n\n[data-tooltip]:hover::before {\n content: '';\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-bottom-color: rgba(0, 0, 0, 0.9);\n z-index: 1000;\n pointer-events: none;\n margin-top: 1px;\n animation: tooltip-appear 0.1s ease-out;\n}\n\n/* Special handling for rightmost elements that might overflow */\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 0;\n transform: none;\n}\n\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 16px;\n transform: none;\n}\n\n@keyframes tooltip-appear {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(-5px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\nselect {\n position: relative;\n}\n\n/* Robot shape internal elements - inherit stroke from parent node */\n.node .robot-eye-socket {\n fill: none;\n stroke: inherit;\n stroke-width: 2;\n}\n\n.node .robot-eye {\n fill: currentColor;\n stroke: none;\n}\n\n.node .robot-mouth {\n stroke: inherit;\n}\n\n.node .robot-antenna {\n stroke: inherit;\n}\n\n.node .robot-antenna-ball {\n fill: currentColor;\n stroke: inherit;\n stroke-width: 1.5;\n}\n\n.node .robot-panel {\n stroke: inherit;\n}\n\n.node .robot-indicator {\n fill: currentColor;\n stroke: none;\n}`, \"\",{\"version\":3,\"sources\":[\"webpack://./src/style.css\"],\"names\":[],\"mappings\":\"AAAA;IACI,YAAY;AAChB;;AAEA;IACI,uFAAuF;IACvF,WAAW;IACX,SAAS;AACb;;AAEA;IACI,aAAa;IACb,sBAAsB;AAC1B;AAC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ACnB;;AAEA;IACI,kBAAkB;IAClB,YAAY;AAChB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,eAAe;IACf,iBAAiB;AACrB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,YAAY;AAChB\",\"sourcesContent\":[\"html, body, #root {\\n height: 100%;\\n}\\n\\nbody {\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n color: #666;\\n margin: 0;\\n}\\n\\n#root {\\n display: flex;\\n flex-direction: column;\\n}\\n#root > div.graph {\\n flex: 1;\\n overflow: auto;\\n position: relative;\\n}\\n\\n.toolbar {\\n display: flex;\\n justify-content: space-between;\\n align-items: center;\\n padding: 4px 10px;\\n background-color: #f0f0f0;\\n border-bottom: 1px solid #cccccc;\\n}\\n\\n.toolbar > div {\\n display: flex;\\n align-items: center;\\n}\\n\\n.toolbar button {\\n padding: 5px 8px;\\n margin: 0 2px;\\n cursor: pointer;\\n}\\n\\n.toolbar button:disabled {\\n opacity: 0.5;\\n cursor: not-allowed;\\n}\\n\\n/* Drag mode toggle button styles */\\n.toolbar button.mode-toggle {\\n position: relative;\\n border: 1px solid #8f9fc9;\\n width: 40px;\\n min-height: 28px;\\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\\n border-color: #8f9fc9;\\n color: white;\\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\\n}\\n\\n.toolbar button.mode-toggle:hover {\\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\\n border-color: #abb8db;\\n}\\n\\n.toolbar button.mode-toggle.select-mode:active {\\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\\n}\\n\\n/* Pan mode and active toggle - darker blue */\\n.toolbar button.mode-toggle.pan-mode,\\n.toolbar button.active-toggle {\\n background: linear-gradient(to bottom, #4a90e2, #357abd);\\n border-color: #2968a3;\\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\\n}\\n\\n.toolbar button.mode-toggle.pan-mode:hover,\\n.toolbar button.active-toggle:hover {\\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\\n}\\n\\n.toolbar button.mode-toggle.pan-mode:active {\\n background: linear-gradient(to bottom, #357abd, #2968a3);\\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\\n}\\n\\n/* Toggle buttons when inactive - gray styling */\\n.toolbar button.inactive-toggle {\\n background: #c1c1c1;\\n color: #999;\\n border-color: #c1c1c1;\\n box-shadow: none;\\n}\\n\\n.toolbar button.inactive-toggle:hover {\\n background: #b1b1b1;\\n}\\n\\n.toolbar button.inactive-toggle:active {\\n background: #a1a1a1;\\n}\\n\\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\\n background: #c1c1c1;\\n color: #999;\\n border-color: #c1c1c1;\\n box-shadow: none;\\n}\\n\\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\\n.toolbar button .fas {\\n font-size: 1em;\\n vertical-align: middle;\\n}\\n\\n/* Zoom percentage display */\\n.toolbar button.zoom-display {\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\\n font-size: 11px;\\n font-weight: 600;\\n font-variant-numeric: tabular-nums;\\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\\n padding: 6px 8px;\\n text-align: center;\\n}\\n\\n.toolbar-group {\\n display: flex;\\n align-items: center;\\n margin-right: 25px; /* Large space between groups */\\n}\\n\\n.toolbar-group:last-child {\\n margin-right: 0; /* Remove right margin from the last group (help button) */\\n}\\n\\nbutton {\\n border: none;\\n background: linear-gradient(to bottom, #4a90e2, #357abd);\\n border-color: #2968a3;\\n border-radius: 3px;\\n padding: 6px 10px;\\n color: #fff;\\n outline: none;\\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\\n margin-right: 5px;\\n min-width: 32px;\\n min-height: 28px;\\n display: inline-flex;\\n align-items: center;\\n justify-content: center;\\n font-size: 14px;\\n line-height: 1;\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n position: relative;\\n}\\n\\nbutton:hover {\\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\\n}\\n\\nbutton:active {\\n background: linear-gradient(to bottom, #357abd, #2968a3);\\n}\\n\\nbutton:last-child {\\n margin-right: 0;\\n}\\n\\n/* Save button when no changes - gray */\\nbutton.action {\\n background: #c1c1c1;\\n color: #999;\\n}\\n\\nbutton.action:active {\\n background: #b1b1b1;\\n}\\n\\n/* Save button when there are changes - orange */\\nbutton.grp {\\n background: linear-gradient(to bottom, #ee9564, #de7d48);\\n margin-right: 0;\\n}\\n\\nbutton.grp:active {\\n background: #d67540;\\n}\\n\\n/* Auto-arrange button with AI purple to blue gradient */\\nbutton.auto-arrange {\\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\\n border-color: #4a4c93;\\n}\\n\\nbutton.auto-arrange:hover {\\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\\n border-color: #5a5ca3;\\n}\\n\\nbutton.auto-arrange:active {\\n background: linear-gradient(135deg, #593B83, #357abd);\\n border-color: #3a3c83;\\n}\\n\\nselect {\\n border: 1px solid #ccc;\\n background: white;\\n border-radius: 3px;\\n padding: 3px 7px;\\n color: #666;\\n outline: none;\\n margin-right: 5px;\\n font-size: 12px;\\n}\\n\\nselect:disabled {\\n background: #f5f5f5;\\n color: #999;\\n}\\n\\nbutton:disabled {\\n background: #c1c1c1;\\n color: #999;\\n}\\n\\n#root > div > svg {\\n position: absolute;\\n user-select: none;\\n}\\n\\n\\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\\n stroke: #29c229;\\n}\\n.edge .v-dot {\\n fill: transparent;\\n stroke: transparent;\\n stroke-width: 3px;\\n cursor: pointer;\\n transition: stroke 0.15s ease;\\n}\\n.edge .v-dot:hover {\\n stroke: #999;\\n fill: rgba(153, 153, 153, 0.1);\\n}\\n.edge .v-dot.selected {\\n stroke: #29c229;\\n fill: rgba(41, 194, 41, 0.1);\\n}\\n.edge .v-dot.selected:hover {\\n stroke: #29c229;\\n fill: rgba(41, 194, 41, 0.2);\\n}\\n.edge .v-dot.auto.selected {\\n stroke: #777;\\n fill: rgba(119, 119, 119, 0.1);\\n}\\n.edge .v-dot.auto.selected:hover {\\n stroke: #777;\\n fill: rgba(119, 119, 119, 0.2);\\n}\\ncircle#prj {\\n fill: none;\\n stroke: #777;\\n}\\n\\n.nodeShadow {\\n fill: none;\\n stroke-width: 4px;\\n stroke: rgba(0, 0, 0, 0.13);\\n}\\n\\ng.node {\\n user-select: none;\\n cursor: default;\\n}\\n\\ng.node.linked {\\n cursor: pointer;\\n}\\n\\ng.node text {\\n pointer-events: none;\\n}\\n\\n.icon {\\n fill: #aaa;\\n stroke: #fff;\\n}\\n#icon-cube {\\n fill: #aaa;\\n}\\n\\n/* Ensure all button icons are uncolored */\\nbutton .icon,\\nbutton svg,\\nbutton path {\\n fill: currentColor !important;\\n stroke: none !important;\\n}\\n\\n/* Font Awesome icon styling in buttons */\\nbutton i {\\n font-size: 12px;\\n color: inherit;\\n}\\n\\nrect.elastic {\\n pointer-events: none;\\n stroke: none;\\n fill: #3bd8281f;\\n display: none;\\n}\\nrect.elastic.on {\\n display: block;\\n}\\n\\n.popover {\\n position: absolute;\\n top: 50px;\\n bottom: 10px;\\n overflow: auto;\\n right: 10px;\\n background: ghostwhite;\\n padding: 30px;\\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\\n border: solid 1px #eee;\\n}\\n\\n.popover th {\\n text-align: left;\\n padding: 20px 0px 10px;\\n}\\n.popover td {\\n padding-right: 20px;\\n font-size: 14px;\\n}\\n\\n/* Simple tooltip system with smart positioning */\\n[data-tooltip] {\\n position: relative;\\n}\\n\\n[data-tooltip]:hover::after {\\n content: attr(data-tooltip);\\n position: absolute;\\n top: 100%;\\n left: 50%;\\n transform: translateX(-50%);\\n background: rgba(0, 0, 0, 0.9);\\n color: white;\\n padding: 6px 12px;\\n border-radius: 4px;\\n font-size: 12px !important;\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\\n font-weight: normal !important;\\n white-space: nowrap;\\n z-index: 1000;\\n pointer-events: none;\\n margin-top: 5px;\\n animation: tooltip-appear 0.1s ease-out;\\n min-width: 120px;\\n max-width: calc(100vw - 20px);\\n box-sizing: border-box;\\n}\\n\\n[data-tooltip]:hover::before {\\n content: '';\\n position: absolute;\\n top: 100%;\\n left: 50%;\\n transform: translateX(-50%);\\n border: 4px solid transparent;\\n border-bottom-color: rgba(0, 0, 0, 0.9);\\n z-index: 1000;\\n pointer-events: none;\\n margin-top: 1px;\\n animation: tooltip-appear 0.1s ease-out;\\n}\\n\\n/* Special handling for rightmost elements that might overflow */\\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\\n /* Apply to last 2 toolbar groups (save and help buttons) */\\n left: auto;\\n right: 0;\\n transform: none;\\n}\\n\\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\\n /* Apply to last 2 toolbar groups (save and help buttons) */\\n left: auto;\\n right: 16px;\\n transform: none;\\n}\\n\\n@keyframes tooltip-appear {\\n from {\\n opacity: 0;\\n transform: translateX(-50%) translateY(-5px);\\n }\\n to {\\n opacity: 1;\\n transform: translateX(-50%) translateY(0);\\n }\\n}\\n\\nselect {\\n position: relative;\\n}\\n\\n/* Robot shape internal elements - inherit stroke from parent node */\\n.node .robot-eye-socket {\\n fill: none;\\n stroke: inherit;\\n stroke-width: 2;\\n}\\n\\n.node .robot-eye {\\n fill: currentColor;\\n stroke: none;\\n}\\n\\n.node .robot-mouth {\\n stroke: inherit;\\n}\\n\\n.node .robot-antenna {\\n stroke: inherit;\\n}\\n\\n.node .robot-antenna-ball {\\n fill: currentColor;\\n stroke: inherit;\\n stroke-width: 1.5;\\n}\\n\\n.node .robot-panel {\\n stroke: inherit;\\n}\\n\\n.node .robot-indicator {\\n fill: currentColor;\\n stroke: none;\\n}\"],\"sourceRoot\":\"\"}]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___;\n","// Imports\nimport ___CSS_LOADER_API_SOURCEMAP_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/sourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/api.js\";\nimport ___CSS_LOADER_GET_URL_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/getUrl.js\";\nvar ___CSS_LOADER_URL_IMPORT_0___ = new URL(\"@fontsource/inter/files/inter-latin-400-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_1___ = new URL(\"@fontsource/inter/files/inter-latin-500-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_2___ = new URL(\"@fontsource/inter/files/inter-latin-600-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_3___ = new URL(\"@fontsource/inter/files/inter-latin-700-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_SOURCEMAP_IMPORT___);\nvar ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___);\nvar ___CSS_LOADER_URL_REPLACEMENT_1___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_1___);\nvar ___CSS_LOADER_URL_REPLACEMENT_2___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_2___);\nvar ___CSS_LOADER_URL_REPLACEMENT_3___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_3___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_0___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_1___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_2___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_3___}) format(\"woff2\");\n}\n`, \"\",{\"version\":3,\"sources\":[\"webpack://./src/fonts.css\"],\"names\":[],\"mappings\":\"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF\",\"sourcesContent\":[\"/* Local Inter files keep browser text measurement identical without internet access. */\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 400;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-400-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 500;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-500-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 600;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-600-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 700;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-700-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\"],\"sourceRoot\":\"\"}]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___.toString();\n","\n import API from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\";\n import domAPI from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleDomAPI.js\";\n import insertFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertBySelector.js\";\n import setAttributes from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js\";\n import insertStyleElement from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertStyleElement.js\";\n import styleTagTransformFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleTagTransform.js\";\n import content, * as namedExport from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./fonts.css\";\n \n \n\nvar options = {};\n\noptions.styleTagTransform = styleTagTransformFn;\noptions.setAttributes = setAttributes;\noptions.insert = insertFn.bind(null, \"head\");\noptions.domAPI = domAPI;\noptions.insertStyleElement = insertStyleElement;\n\nvar update = API(content, options);\n\n\n\nexport * from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./fonts.css\";\n export default content && content.locals ? content.locals : undefined;\n","\n import API from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\";\n import domAPI from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleDomAPI.js\";\n import insertFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertBySelector.js\";\n import setAttributes from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js\";\n import insertStyleElement from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertStyleElement.js\";\n import styleTagTransformFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleTagTransform.js\";\n import content, * as namedExport from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./style.css\";\n \n \n\nvar options = {};\n\noptions.styleTagTransform = styleTagTransformFn;\noptions.setAttributes = setAttributes;\noptions.insert = insertFn.bind(null, \"head\");\noptions.domAPI = domAPI;\noptions.insertStyleElement = insertStyleElement;\n\nvar update = API(content, options);\n\n\n\nexport * from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./style.css\";\n export default content && content.locals ? content.locals : undefined;\n"],"names":["el","style","Object","entries","forEach","key","value","setAttribute","String","nodeBorder","nodeText","stroke","edgeText","edgeRect","fill","groupRect","groupText","cursor","thickness","color","opacity","fontSize","width","dashed","p1","p2","Math","sqrt","x","y","height","background","shape","metadata","description","calculateEdgeVertices","edge","n1","from","n2","to","vertices","concat","unshift","push","interior","slice","firstRoutingVertex","find","vertex","label","lastRoutingVertex","index","length","intersect","Error","id","calculateLabelPlacement","position","defaultPoint","segment","point","labelIndex","findIndex","movable","labelVertex","auto","adjacentSegments","p","q","reduce","longest","candidate","_constants__WEBPACK_IMPORTED_MODULE_0__","gd","undefined","targetLength","sum","traversed","segmentPosition","horizontalDistance","abs","verticalDistance","orientation","createEdgePath","path","Symbol","GeometryValidationError","issues","constructor","super","map","issue","message","join","this","name","validateResolvedLayout","measured","resolved","diagramId","checkUniqueIDs","nodes","node","groups","group","edges","checkCoverage","measuredNodes","Map","measuredGroups","resolvedNodes","resolvedGroups","checkFiniteRect","bounds","expected","get","nearlyEqual","size","contentSize","checkRectInBounds","titleBounds","contains","titleSize","forEachPair","first","second","overlaps","checkNodeOverlaps","checkGroupOverlaps","child","parentId","parent","checkOwnership","measuredEdges","labels","sourceId","targetId","sections","some","section","checkSectionConnections","isFinitePoint","pointInRect","values","routeIntersectsRect","inset","sourceInside","belongsToGroup","routeViolatesGroup","labelBounds","labelSize","checkEdges","ids","seen","Set","has","add","actual","expectedIDs","actualIDs","rect","Number","isFinite","isFiniteRect","samePoint","source","target","start","end","pointOnBorder","nodeId","groupId","shouldBeInside","dx","dy","minimum","maximum","origin","delta","lower","upper","EPSILON","max","min","segmentIntersectsRect","outer","inner","inclusive","amount","withinX","withinY","onVertical","onHorizontal","items","visit","code","elementIds","defs","fontsinline","A","LICENSE_raw","replace","create","element","type","attrs","className","document","createElementNS","k","v","classList","use","setAttributeNS","d","text","t","textContent","textArea","bold","anchor","constants","M5","lines","maxW","svg_text","U2","txt","line","i","span","append","r","rx","ry","icon","expand","expanded","g","transform","setPosition","insideBox","b","centeredBox","intersectRect","box","w","h","s","q1","q2","denominator","a","numerator1","numerator2","result","onLine1","onLine2","segmentIntersection","filter","ret","intersectRectFull","intersectEllipse","ellCenter","nodeCenter","si","c","radicand_sqrt","pos","project","atob","len","dot","cabDistance","cylinderRadiusY","shapeLabelOffsetY","toLowerCase","D3Element","_el","attr","insert","el2","insertBefore","querySelector","bbox","rounded","shapeSvg","_ellipse","mobiledeviceportrait","shapes","roundedbox","component","cylinder","cy","person","circle","ellipse","hexagon","sz","n","folder","mobiledevicelandscape","mobiledevice","pipe","robot","headSize","headR","antennaH","antennaR","eyeR","eyeSpacing","earW","earH","bodyW","bodyTop","bodyH","headTop","eyeY","mouthY","mouthW","webbrowser","Undo","versions","lastSavedPos","exportDoc","importDoc","change","tmpPreviousState","func","timeout","context","clearTimeout","setTimeout","apply","debounce","saveNow","beforeChange","deepClone","currentState","splice","doc","structuredClone","JSON","parse","stringify","undo","redo","changed","setSaved","textBlock","gapAfter","field","wrapped","lineHeight","defaultEdgeStyle","Y$","defaultNodeStyle","nD","GraphData","nodesMap","edgeVertices","groupsMap","layoutDirection","validatedLayout","colorToVarMap","_undo","_gridVisible","_snapToGrid","_gridSize","_skipAutoFit","exportLayout","lo","importLayout","window","graph","init","layout","addNode","sub","link","nodeStyle","minimumHeight","contentLayout","title","subtitle","nodeWidth","textWidth","HORIZONTAL_PADDING","blocks","textHeight","block","VERTICAL_PADDING","ICON_SIZE","layoutNodeContent","requiredHeight","set","Array","addEdge","fromNode","toNode","initVertex","edgeID","input","charCodeAt","imul","toString","fnv1a36","stableVertexID","userDeletedVertices","addGroup","nodesOrGroups","console","error","Boolean","setNodeSelected","selected","ref","remove","updateEdgesSel","e","clearResolvedLayout","layoutSections","layoutLabelBounds","layoutBounds","layoutTitleBounds","moveNode","disableSnap","skipUndo","snapped","snapToGrid","redrawEdges","redrawGroups","moveEdgeVertex","redrawEdge","moveSelected","insertEdgeVertex","isLabel","deleteEdgeVertex","indexOf","delete","alignTopLeft","contentBounds","calculateContentBounds","offsetX","offsetY","resetPanTransform","currentZoom","getZoom","zoomGroup","svg","graphData","bb","zoom","parentElement","clientWidth","clientHeight","updatePanningOptimized","clearViewState","shouldSkipAutoFit","resetView","updatePanning","removeChild","buildEdge","buildGroup","exportSVG","U","originalSvg","exportSvg","cloneNode","querySelectorAll","getAttribute","removeAttribute","exportElastic","exportWidth","padding","exportHeight","exportZoomGroup","convertStylesToCustomProperties","script","createElement","firstChild","outerHTML","minX","Infinity","minY","maxX","maxY","left","right","top","bottom","trim","centerX","centerY","approxLabelSize","full","lst","rerender","requiredSavedPoint","endsWith","edgeId","startsWith","isArray","saved","autoLayout","options","placedNode","placedGroup","placedEdge","interiorRoutePoints","validated","fitToView","alignSelectionV","alignSelectionH","distributeSelectionH","selectedNodes","selectedVertices","allElements","sort","spacing","newX","distributeSelectionV","newY","setEdgeSelected","viewportWidth","viewportHeight","zoomX","zoomY","optimalZoom","finalZoom","translateX","translateY","saveViewState","saveLayoutState","restoreLayoutState","state","isGridVisible","isSnapToGrid","getGridSize","toggleGrid","updateGridDisplay","dispatchEvent","CustomEvent","toggleSnapToGrid","snapAllToGrid","snappedX","round","snappedY","existingGrid","existingGridRect","pattern","appendChild","route","previous","clickListener","addEventListener","selectListener","dragging","buildGraph","data","onNodeSelect","dragMode","body","__data","_buildGraph","elasticEl","addCursorInteraction","setZoom","buildGraphView","innerHTML","zoomG","nodesG","edgesG","groupsG","gdata","href","exportHref","content","shapeType","AV","setBorderStyle","border","tg","iconHeight","preserveAspectRatio","buildNodeContent","buildNode","completeRoutePoints","edge_utils","l","bg","buildPlacedEdgeLabel","placement","buildEdgeLabel","IW","Zr","cx","p0","topExtension","bottomExtension","hexHeight","pad","findClosestSegment","fnd","dst","POSITIVE_INFINITY","prj","pts","mouseToDrawing","getBoundingClientRect","z","currentTransform","getCurrentTransform","clientX","clientY","addCustomCursorInteraction","conn","ini","elastic","isPanning","panStartX","panStartY","initialTransform","pendingSelectionChange","pendingNavigation","hasDragged","suppressLinkClick","eventListeners","onClick","Element","closest","preventDefault","stopPropagation","md","convertEvent","changedTouches","onMouseMoveHandler","getSelection","setSelection","setTransform","drawingDx","drawingDy","item","setDragging","update","onMouseMove","ex","ey","onMouseUpHandler","removeEventListener","navigation","boxSelection","shiftKey","location","onMouseUp","onMouseDownHandler","nodeFromEvent","effectiveMode","isSelected","translateMatch","match","parseFloat","getCurrentTransformLocal","startDrawingX","startDrawingY","pt","currentPt","currentDrawingX","currentDrawingY","createElastic","onMouseDown","event","handler","addDnd","existingCleanup","__cursorInteractionCleanup","getData","beforeUnloadHandler","returnValue","setDotSelected","dotEl","mouseMoveHandler","altKey","removePrjDot","keyUpHandler","shortcuts","Yp","Zj","_s","clickHandler","wheelHandler","sign","deltaY","newZoom","setZoomCentered","keyDownHandler","shortcut","bl","Ur","hU","i1","mD","F","Gn","customInteractionCleanup","handles","handle","b1","b2","scaleMatch","oldZoom","container","newTranslateX","newTranslateY","getBBox","viewStateCache","graphId","restoreViewState","defaultOptions","direction","nodeSpacing","layerSpacing","async","resolveAutomatic","diagram","checkMeasuredLinks","childrenByParent","groupsByParent","elkGroups","children","layoutOptions","groupLayoutOptions","root","rootLayoutOptions","owner","lowestCommonGroup","buildLayoutTree","elk","__webpack_require__","then","bind","module","default","readContainer","readResolvedLayout","sources","targets","titleHeight","sourceGroups","parentGroups","targetGroups","current","parentX","parentY","containerX","containerY","childX","requiredNumber","childY","measuredNode","measuredGroup","requiredLabel","readEdge","addOffset","startPoint","bendPoints","endPoint","requiredEndpoint","elementId","endpoints","siblings","fonts","ready","measureGraph","compactLayout","geometry","centerOffset","validateCurrentLayout","isConnected","boundary","SVGGraphicsElement","copyBox","snapshot","completeSnapshot","resolveManual","nodeParents","groupParents","member","parents","isGroup","existing","declaredParents","checkMeasuredBox","measureNode","measureGroup","measureEdge","hasLabel","boxes","flatMap","points","flat","measuredText","measurementSVG","loadDiagramFonts","Promise","all","weight","load","measureSVGText","attributes","localeCompare","measurementKey","cached","visibility","pointerEvents","svgTextWrap","split","paragraph","paragraphLines","currentLine","word","parts","breakLongWord","part","nextLine","maxWidth","currentPart","character","nextPart","layoutDirections","TopBottom","BottomTop","LeftRight","RightLeft","model","viewsList","keys","views","layouts","viewKey","elements","relations","collectRels","relationships","rel","people","softwareSystems","containers","el1","components","deploymentNodes","containerInstances","containerId","recAddNodes","infrastructureNodes","view","getView","_graph_view_graph__WEBPACK_IMPORTED_MODULE_0__","jg","rankDirection","automaticLayout","version","groupingIDs","externalContainersBoundariesVisible","softwareSystemId","enterprise","styles","cssClassName","tag","varPrefix","elementViewKey","containerViews","lookupContainerViewKey","tags","technology","encodedViewKey","encodeURIComponent","url","nodeLink","properties","warn","destinationId","routing","level","groupMembers","ADD_VERTEX","ADD_LABEL_VERTEX","DEL_VERTEX","ZOOM_IN","ZOOM_OUT","ZOOM_FIT","ZOOM_100","SELECT_ALL","DESELECT","MOVE_LEFT","MOVE_RIGHT","MOVE_UP","MOVE_DOWN","MOVE_LEFT_FINE","MOVE_RIGHT_FINE","MOVE_UP_FINE","MOVE_DOWN_FINE","TOGGLE_DRAG_MODE","ALIGN_HORIZONTAL","ALIGN_VERTICAL","DISTRIBUTE_HORIZONTAL","DISTRIBUTE_VERTICAL","AUTO_LAYOUT","RESET_POSITION","TOGGLE_GRID","TOGGLE_SNAP_TO_GRID","SNAP_ALL_TO_GRID","list","help","combinations","shift","ctrl","alt","click","wheel","shortcutMap","comboText","_utils_platform__WEBPACK_IMPORTED_MODULE_1__","sy","toUpperCase","react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__","jsxs","jsx","Fragment","colSpan","matches","SA","ke","checkKey","aShortcut","bShortcut","aModifiers","bModifiers","aCount","isMac","navigator","userAgentData","platform","includes","userAgent","KeyboardEvent","metaKey","test","ctrlKey","___CSS_LOADER_URL_IMPORT_0___","URL","___CSS_LOADER_URL_IMPORT_1___","___CSS_LOADER_URL_IMPORT_2___","___CSS_LOADER_URL_IMPORT_3___","___CSS_LOADER_EXPORT___","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default","___CSS_LOADER_URL_REPLACEMENT_0___","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default","___CSS_LOADER_URL_REPLACEMENT_1___","___CSS_LOADER_URL_REPLACEMENT_2___","___CSS_LOADER_URL_REPLACEMENT_3___","names","mappings","sourcesContent","sourceRoot","__WEBPACK_DEFAULT_EXPORT__","styleTagTransform","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default","setAttributes","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default","domAPI","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default","insertStyleElement","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_cjs_js_fonts_css__WEBPACK_IMPORTED_MODULE_6__","locals","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_cjs_js_style_css__WEBPACK_IMPORTED_MODULE_6__"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"286.js","mappings":"mGAw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C,IACxBnd,EAAA7O,OAAiBisB,IAAApO,KAAa,aAC9BhP,EAAAqd,OAAiBC,IACjBtd,EAAAud,mBAA6BC,IAEhBC,IAAIC,EAAAzZ,EAAOjE,GAKF0d,EAAAzZ,GAAWyZ,EAAAzZ,EAAO0Z,QAAUD,EAAAzZ,EAAO0Z,4ICbzD3d,EAAA,GAEAA,EAAAgd,kBAA4BC,IAC5Bjd,EAAAkd,cAAwBC,IACxBnd,EAAA7O,OAAiBisB,IAAApO,KAAa,aAC9BhP,EAAAqd,OAAiBC,IACjBtd,EAAAud,mBAA6BC,IAEhBC,IAAIG,EAAA3Z,EAAOjE,GAKF4d,EAAA3Z,GAAW2Z,EAAA3Z,EAAO0Z,QAAUC,EAAA3Z,EAAO0Z","sources":["webpack://app/./src/graph-view/constants.ts","webpack://app/./src/graph-view/edge-utils.ts","webpack://app/./src/graph-view/geometry.ts","webpack://app/./src/graph-view/svg-create.ts","webpack://app/./src/graph-view/intersect.ts","webpack://app/./src/graph-view/shapes.ts","webpack://app/./src/graph-view/undo.ts","webpack://app/./src/graph-view/node-content.ts","webpack://app/./src/graph-view/graph.ts","webpack://app/./src/graph-view/defs.ts","webpack://app/./src/graph-view/automatic-layout.ts","webpack://app/./src/graph-view/layout.ts","webpack://app/./src/graph-view/manual-layout.ts","webpack://app/./src/graph-view/svg-text.ts","webpack://app/./src/parseModel.ts","webpack://app/./src/shortcuts.tsx","webpack://app/./src/utils/platform.ts","webpack://app/./src/fonts.css","webpack://app/./src/style.css","webpack://app/./src/fonts.css?0e2c","webpack://app/./src/fonts.css?a158","webpack://app/./src/style.css?dd02"],"sourcesContent":["// Constants and default configurations for the graph view\n\nexport interface Point {\n\tx: number;\n\ty: number;\n}\n\nexport interface BBox extends Point {\n\twidth: number;\n\theight: number;\n}\n\nexport interface NodeStyle {\n\t// Width of element, in pixels.\n\twidth?: number\n\t// Height of element, in pixels.\n\theight?: number\n\t// Background color of element as HTML RGB hex string (e.g. \"#ffffff\")\n\tbackground?: string\n\t// Stroke color of element as HTML RGB hex string (e.g. \"#000000\")\n\tstroke?: string\n\t// Foreground (text) color of element as HTML RGB hex string (e.g. \"#ffffff\")\n\tcolor?: string\n\t// Standard font size used to render text, in pixels.\n\tfontSize?: number\n\t// Shape used to render element.\n\tshape?: string\n\t// URL of PNG/JPG/GIF file or Base64 data URI representation.\n\ticon?: string\n\t// Type of border used to render element.\n\tborder?: string\n\t// Opacity used to render element; 0-100.\n\topacity?: number\n\t// Whether element metadata should be shown.\n\tmetadata?: boolean\n\t// Whether element description should be shown.\n\tdescription?: boolean\n}\n\nexport interface EdgeStyle {\n\t// Thickness of line, in pixels.\n\tthickness?: number\n\t// Color of line as HTML RGB hex string (e.g. \"#ffffff\").\n\tcolor?: string\n\t// Standard font size used to render relationship annotation, in pixels.\n\tfontSize?: number\n\t// Width of relationship annotation, in pixels.\n\twidth?: number\n\t// Whether line is dashed.\n\tdashed?: boolean\n\t// Position of label along edge (0-100).\n\tposition?: number\n\t// Opacity used to render relationship; 0-100.\n\topacity?: number\n\t// Arrow style for the edge.\n\tarrowStyle?: 'normal' | 'large' | 'small' | 'none'\n}\n\n// Default styles\nexport const DEFAULT_EDGE_STYLE: EdgeStyle = {\n\tthickness: 2,\n\tcolor: '#64748b',\n\topacity: 1,\n\tfontSize: 18,\n\twidth: 200,\n\tdashed: true,\n};\n\nexport const DEFAULT_NODE_STYLE: NodeStyle = {\n\twidth: 280,\n\theight: 180,\n\tbackground: '#ffffff',\n\tcolor: '#334155',\n\topacity: 1,\n\tstroke: '#8492a6',\n\tfontSize: 22,\n\tshape: 'Box',\n\tmetadata: true,\n\tdescription: true,\n};\n\n// SVG styles\nexport const SVG_STYLES = {\n\tnodeBorder: {\n\t\t'stroke-width': 1.5,\n\t},\n\tnodeText: {\n\t\t'font-family': 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',\n\t\tstroke: \"none\"\n\t},\n\tedgeText: {\n\t\t'font-family': 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',\n\t\tstroke: \"none\"\n\t},\n\tedgeRect: {\n\t\tfill: \"none\",\n\t\tstroke: \"none\",\n\t},\n\tgroupRect: {\n\t\tfill: \"none\",\n\t\tstroke: \"#8492a6\",\n\t\t'stroke-width': 1.5,\n\t\t\"stroke-dasharray\": \"6 4\",\n\t},\n\tgroupText: {\n\t\tfill: \"#475569\",\n\t\t\"font-size\": 20,\n\t\t\"font-weight\": \"600\",\n\t\t'font-family': 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',\n\t\tcursor: \"default\"\n\t}\n};\n\n// Configuration constants\nexport const SVG_PADDING = 20;\nexport const DEFAULT_GRID_SIZE = 25;\nexport const EDGE_SPREAD_DISTANCE = 70;\nexport const EDGE_SPREAD_DISTANCE_X = 200;\n\n// Set presentation attributes so an author's later attributes override defaults.\nexport const applyStyle = (el: SVGElement, style: { [key: string]: string | number }) => {\n\tObject.entries(style).forEach(([key, value]) => {\n\t\tel.setAttribute(key, String(value));\n\t});\n};\n\n// Utility function to calculate distance between two points\nexport const calculateDistance = (p1: Point, p2: Point): number => {\n\treturn Math.sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));\n};\n","import { Point, calculateDistance } from './constants';\nimport { Segment } from './intersect';\n\n// Define interfaces locally since they're not exported from graph.ts\ninterface NodeStyle {\n\tbackground?: string;\n\tstroke?: string;\n\topacity?: number;\n\tfontSize?: number;\n\tshape?: string;\n\tborder?: string;\n}\n\ninterface Node extends Point {\n\tid: string;\n\ttitle: string;\n\tsub: string;\n\tdescription: string;\n\twidth: number;\n\theight: number;\n\tref?: SVGGElement;\n\tselected?: boolean;\n\tintersect: (p: Point) => Point;\n\tstyle: NodeStyle;\n}\n\ninterface EdgeVertex extends Point {\n\tid: string;\n\tselected?: boolean;\n\tref?: SVGElement;\n\tlabel?: boolean;\n\tauto?: boolean;\n}\n\ninterface EdgeStyle {\n\tcolor?: string;\n\tthickness?: number;\n\tfontSize?: number;\n\tposition?: number;\n\tdashed?: boolean;\n}\n\ninterface Edge {\n\tid: string;\n\tlabel: string;\n\tfrom: Node;\n\tto: Node;\n\tvertices?: EdgeVertex[];\n\tref?: SVGGElement;\n\tstyle: EdgeStyle;\n\tinitVertex: (p: Point) => EdgeVertex;\n\tuserDeletedVertices?: boolean; // Track if user explicitly deleted vertices\n}\n\nexport interface EdgeLabelPlacement extends Point {\n\torientation: 'horizontal' | 'vertical';\n\tsegment?: Segment;\n\tmovable: boolean;\n}\n\n/**\n * Calculate edge vertices, handling multi-edge scenarios and auto-vertices\n */\nexport function calculateEdgeVertices(edge: Edge): Point[] {\n\tconst n1 = edge.from, n2 = edge.to;\n\t\n\t\n\t// if vertices exists, follow them\n\tlet vertices: Point[] = edge.vertices ? edge.vertices.concat() : [];\n\t// Don't remove label vertices - they should be preserved for rendering\n\t// (The autoLayout process handles replacing old ones with new ones)\n\n\tvertices.unshift(n1)\n\tvertices.push(n2)\n\n\tconst interior = vertices.slice(1, -1) as EdgeVertex[];\n\tconst firstRoutingVertex = interior.find(vertex => !vertex.label) ?? n2;\n\tlet lastRoutingVertex: Point = n1;\n\tfor (let index = interior.length - 1; index >= 0; index--) {\n\t\tif (!interior[index].label) {\n\t\t\tlastRoutingVertex = interior[index];\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!n1.intersect || !n2.intersect) {\n\t\tthrow new Error(`edge ${edge.id} nodes must be drawn before routing`);\n\t}\n\tvertices[0] = n1.intersect(firstRoutingVertex);\n\tvertices[vertices.length - 1] = n2.intersect(lastRoutingVertex);\n\t\n\treturn vertices;\n}\n\n/**\n * Calculate the label anchor and the orientation of the path segment that owns\n * it. Renderers use the orientation to place text beside the relationship line\n * instead of centering text over vertical segments.\n */\nexport function calculateLabelPlacement(\n\tvertices: Point[],\n\tposition: number,\n\tdefaultPoint: Point,\n): EdgeLabelPlacement {\n\tlet point = {x: defaultPoint.x, y: defaultPoint.y};\n\tlet segment: Segment | undefined;\n\tconst labelIndex = vertices.findIndex(vertex => (vertex as EdgeVertex).label);\n\tlet movable = true;\n\n\tif (labelIndex >= 0) {\n\t\tconst labelVertex = vertices[labelIndex] as EdgeVertex;\n\t\tpoint = labelVertex;\n\t\tmovable = labelVertex.auto === true;\n\t\tconst adjacentSegments: Segment[] = [];\n\t\tif (labelIndex > 0) {\n\t\t\tadjacentSegments.push({p: vertices[labelIndex - 1], q: point});\n\t\t}\n\t\tif (labelIndex < vertices.length - 1) {\n\t\t\tadjacentSegments.push({p: point, q: vertices[labelIndex + 1]});\n\t\t}\n\t\tsegment = adjacentSegments.reduce((longest, candidate) => {\n\t\t\tif (!longest) {\n\t\t\t\treturn candidate;\n\t\t\t}\n\t\t\treturn calculateDistance(candidate.p, candidate.q) >\n\t\t\t\tcalculateDistance(longest.p, longest.q)\n\t\t\t\t? candidate\n\t\t\t\t: longest;\n\t\t}, undefined);\n\t} else {\n\t\tconst totalLength = vertices.slice(1).reduce(\n\t\t\t(sum, vertex, index) => sum + calculateDistance(vertices[index], vertex),\n\t\t\t0,\n\t\t);\n\t\tconst targetLength = totalLength * position;\n\t\tlet traversed = 0;\n\t\tfor (let index = 1; index < vertices.length; index++) {\n\t\t\tconst candidate = {p: vertices[index - 1], q: vertices[index]};\n\t\t\tconst length = calculateDistance(candidate.p, candidate.q);\n\t\t\tif (length > 0 && traversed + length >= targetLength) {\n\t\t\t\tconst segmentPosition = (targetLength - traversed) / length;\n\t\t\t\tpoint = {\n\t\t\t\t\tx: candidate.p.x + (candidate.q.x - candidate.p.x) * segmentPosition,\n\t\t\t\t\ty: candidate.p.y + (candidate.q.y - candidate.p.y) * segmentPosition,\n\t\t\t\t};\n\t\t\t\tsegment = candidate;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ttraversed += length;\n\t\t}\n\t}\n\n\tconst horizontalDistance = segment ? Math.abs(segment.q.x - segment.p.x) : 0;\n\tconst verticalDistance = segment ? Math.abs(segment.q.y - segment.p.y) : 0;\n\treturn {\n\t\t...point,\n\t\torientation: verticalDistance > horizontalDistance ? 'vertical' : 'horizontal',\n\t\tsegment,\n\t\tmovable,\n\t};\n}\n\n/** createEdgePath draws the given points without cutting or moving the route. */\nexport function createEdgePath(vertices: Point[]): string {\n\tif (vertices.length < 2) {\n\t\tthrow new Error(\"edge route must contain at least two points\");\n\t}\n\treturn vertices.slice(1).reduce(\n\t\t(path, point) => `${path} L${point.x},${point.y}`,\n\t\t`M${vertices[0].x},${vertices[0].y}`,\n\t);\n}","// This file defines the diagram sizes and positions shared by layout and SVG\n// drawing. Automatic and manual layout both produce ResolvedLayout. The SVG\n// drawing code accepts a layout only after this file has checked it.\n\n/** Point is one position in the diagram. */\nexport interface Point {\n\tx: number;\n\ty: number;\n}\n\n/** Size is a width and height. Both values must be zero or greater. */\nexport interface Size {\n\twidth: number;\n\theight: number;\n}\n\n/** Rect is a box that does not rotate. */\nexport interface Rect extends Point, Size {}\n\n/** MeasuredNode holds the exact box and text sizes needed before layout. */\nexport interface MeasuredNode {\n\tid: string;\n\tparentId?: string;\n\tsize: Size;\n\tcontentSize: Size;\n\tcenterOffset: Point;\n\tshape: string;\n}\n\n/** MeasuredGroup describes a boundary that must contain its children and title. */\nexport interface MeasuredGroup {\n\tid: string;\n\tparentId?: string;\n\ttitleSize: Size;\n}\n\n/** MeasuredEdge names the two connected nodes and the exact label size. */\nexport interface MeasuredEdge {\n\tid: string;\n\tsourceId: string;\n\ttargetId: string;\n\tlabelSize?: Size;\n}\n\n/**\n * MeasuredDiagram is the complete input to automatic or manual layout.\n * It contains sizes, but no positions.\n */\nexport interface MeasuredDiagram {\n\tid: string;\n\tnodes: MeasuredNode[];\n\tgroups: MeasuredGroup[];\n\tedges: MeasuredEdge[];\n}\n\n/** ResolvedNode is one measured node placed in the diagram. */\nexport interface ResolvedNode {\n\tid: string;\n\tparentId?: string;\n\tbounds: Rect;\n}\n\n/** ResolvedGroup is one placed boundary and its title box. */\nexport interface ResolvedGroup {\n\tid: string;\n\tparentId?: string;\n\tbounds: Rect;\n\ttitleBounds: Rect;\n}\n\n/**\n * ResolvedEdge contains a complete route. Each section is an ordered list of\n * points. labelBounds is the final label box chosen by layout.\n */\nexport interface ResolvedEdge {\n\tid: string;\n\tsourceId: string;\n\ttargetId: string;\n\tsections: Point[][];\n\tlabelBounds?: Rect;\n}\n\n/**\n * ResolvedLayout is the unchecked result of automatic or manual layout.\n * Drawing code must not use it directly.\n */\nexport interface ResolvedLayout {\n\tdiagramId: string;\n\tbounds: Rect;\n\tnodes: ResolvedNode[];\n\tgroups: ResolvedGroup[];\n\tedges: ResolvedEdge[];\n}\n\n/** GeometryIssueCode names one rule that the layout broke. */\nexport type GeometryIssueCode =\n\t| \"duplicate_id\"\n\t| \"missing_element\"\n\t| \"unexpected_element\"\n\t| \"non_finite\"\n\t| \"size_mismatch\"\n\t| \"content_overflow\"\n\t| \"node_overlap\"\n\t| \"group_overlap\"\n\t| \"false_containment\"\n\t| \"edge_through_node\"\n\t| \"edge_through_group\"\n\t| \"label_node_overlap\"\n\t| \"label_label_overlap\"\n\t| \"label_edge_overlap\"\n\t| \"label_title_overlap\"\n\t| \"out_of_bounds\"\n\t| \"disconnected_edge\";\n\n/** GeometryIssue reports the stable IDs of the affected diagram elements. */\nexport interface GeometryIssue {\n\tcode: GeometryIssueCode;\n\telementIds: string[];\n\tmessage: string;\n}\n\nconst validatedLayoutBrand: unique symbol = Symbol(\"ValidatedLayout\");\n\n/**\n * ValidatedLayout is the only layout the SVG drawing code accepts. The private\n * marker prevents other code from creating one without running the checks.\n */\nexport type ValidatedLayout = ResolvedLayout & {\n\treadonly [validatedLayoutBrand]: true;\n};\n\n/** GeometryValidationError reports every layout problem found in one check. */\nexport class GeometryValidationError extends Error {\n\treadonly issues: GeometryIssue[];\n\n\tconstructor(issues: GeometryIssue[]) {\n\t\tsuper(issues.map(issue => issue.message).join(\"\\n\"));\n\t\tthis.name = \"GeometryValidationError\";\n\t\tthis.issues = issues;\n\t}\n}\n\n/**\n * validateResolvedLayout checks that every element is present, every number is\n * valid, boundaries show true ownership, elements do not collide, and all\n * content stays inside the diagram.\n */\nexport function validateResolvedLayout(\n\tmeasured: MeasuredDiagram,\n\tresolved: ResolvedLayout,\n): ValidatedLayout {\n\tconst issues: GeometryIssue[] = [];\n\tif (measured.id !== resolved.diagramId) {\n\t\tissues.push(issue(\n\t\t\t\"missing_element\",\n\t\t\t[measured.id, resolved.diagramId],\n\t\t\t`layout ${resolved.diagramId} does not resolve measured diagram ${measured.id}`,\n\t\t));\n\t}\n\n\tcheckUniqueIDs(\"measured node\", measured.nodes.map(node => node.id), issues);\n\tcheckUniqueIDs(\"measured group\", measured.groups.map(group => group.id), issues);\n\tcheckUniqueIDs(\"measured edge\", measured.edges.map(edge => edge.id), issues);\n\tcheckUniqueIDs(\"resolved node\", resolved.nodes.map(node => node.id), issues);\n\tcheckUniqueIDs(\"resolved group\", resolved.groups.map(group => group.id), issues);\n\tcheckUniqueIDs(\"resolved edge\", resolved.edges.map(edge => edge.id), issues);\n\n\tcheckCoverage(\n\t\t\"node\",\n\t\tmeasured.nodes.map(node => node.id),\n\t\tresolved.nodes.map(node => node.id),\n\t\tissues,\n\t);\n\tcheckCoverage(\n\t\t\"group\",\n\t\tmeasured.groups.map(group => group.id),\n\t\tresolved.groups.map(group => group.id),\n\t\tissues,\n\t);\n\tcheckCoverage(\n\t\t\"edge\",\n\t\tmeasured.edges.map(edge => edge.id),\n\t\tresolved.edges.map(edge => edge.id),\n\t\tissues,\n\t);\n\n\tconst measuredNodes = new Map(measured.nodes.map(node => [node.id, node]));\n\tconst measuredGroups = new Map(measured.groups.map(group => [group.id, group]));\n\tconst resolvedNodes = new Map(resolved.nodes.map(node => [node.id, node]));\n\tconst resolvedGroups = new Map(resolved.groups.map(group => [group.id, group]));\n\n\tcheckFiniteRect(\"diagram\", resolved.diagramId, resolved.bounds, issues);\n\tfor (const node of resolved.nodes) {\n\t\tcheckFiniteRect(\"node\", node.id, node.bounds, issues);\n\t\tconst expected = measuredNodes.get(node.id);\n\t\tif (expected && (\n\t\t\t!nearlyEqual(expected.size.width, node.bounds.width) ||\n\t\t\t!nearlyEqual(expected.size.height, node.bounds.height)\n\t\t)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"size_mismatch\",\n\t\t\t\t[node.id],\n\t\t\t\t`node ${node.id} size changed after measurement`,\n\t\t\t));\n\t\t}\n\t\tif (expected && (\n\t\t\texpected.contentSize.width > node.bounds.width ||\n\t\t\texpected.contentSize.height > node.bounds.height\n\t\t)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"content_overflow\",\n\t\t\t\t[node.id],\n\t\t\t\t`node ${node.id} content exceeds its resolved bounds`,\n\t\t\t));\n\t\t}\n\t\tcheckRectInBounds(\"node\", node.id, node.bounds, resolved.bounds, issues);\n\t}\n\tfor (const group of resolved.groups) {\n\t\tcheckFiniteRect(\"group\", group.id, group.bounds, issues);\n\t\tcheckFiniteRect(\"group title\", group.id, group.titleBounds, issues);\n\t\tcheckRectInBounds(\"group\", group.id, group.bounds, resolved.bounds, issues);\n\t\tif (!contains(group.bounds, group.titleBounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[group.id],\n\t\t\t\t`group ${group.id} does not contain its title`,\n\t\t\t));\n\t\t}\n\t\tconst expected = measuredGroups.get(group.id);\n\t\tif (expected && (\n\t\t\t!nearlyEqual(expected.titleSize.width, group.titleBounds.width) ||\n\t\t\t!nearlyEqual(expected.titleSize.height, group.titleBounds.height)\n\t\t)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"size_mismatch\",\n\t\t\t\t[group.id],\n\t\t\t\t`group ${group.id} title size changed after measurement`,\n\t\t\t));\n\t\t}\n\t}\n\n\tcheckNodeOverlaps(resolved.nodes, issues);\n\tcheckGroupOverlaps(resolved.groups, issues);\n\tcheckOwnership(\n\t\tmeasured.nodes,\n\t\tmeasured.groups,\n\t\tresolvedNodes,\n\t\tresolvedGroups,\n\t\tissues,\n\t);\n\tcheckEdges(\n\t\tmeasured,\n\t\tresolved,\n\t\tresolvedNodes,\n\t\tresolvedGroups,\n\t\tmeasuredNodes,\n\t\tmeasuredGroups,\n\t\tissues,\n\t);\n\n\tif (issues.length > 0) {\n\t\tthrow new GeometryValidationError(issues);\n\t}\n\treturn resolved as ValidatedLayout;\n}\n\n/** checkUniqueIDs requires each model ID to appear only once. */\nfunction checkUniqueIDs(label: string, ids: string[], issues: GeometryIssue[]): void {\n\tconst seen = new Set();\n\tfor (const id of ids) {\n\t\tif (seen.has(id)) {\n\t\t\tissues.push(issue(\"duplicate_id\", [id], `${label} ${id} is duplicated`));\n\t\t}\n\t\tseen.add(id);\n\t}\n}\n\n/** checkCoverage rejects missing elements and old elements left in a layout. */\nfunction checkCoverage(\n\tlabel: string,\n\texpected: string[],\n\tactual: string[],\n\tissues: GeometryIssue[],\n): void {\n\tconst expectedIDs = new Set(expected);\n\tconst actualIDs = new Set(actual);\n\tfor (const id of expectedIDs) {\n\t\tif (!actualIDs.has(id)) {\n\t\t\tissues.push(issue(\"missing_element\", [id], `${label} ${id} is missing from resolved layout`));\n\t\t}\n\t}\n\tfor (const id of actualIDs) {\n\t\tif (!expectedIDs.has(id)) {\n\t\t\tissues.push(issue(\"unexpected_element\", [id], `${label} ${id} is not in the measured diagram`));\n\t\t}\n\t}\n}\n\n/** checkFiniteRect rejects invalid numbers and negative sizes. */\nfunction checkFiniteRect(\n\tlabel: string,\n\tid: string,\n\trect: Rect,\n\tissues: GeometryIssue[],\n): void {\n\tif (!isFiniteRect(rect) || rect.width < 0 || rect.height < 0) {\n\t\tissues.push(issue(\"non_finite\", [id], `${label} ${id} has invalid geometry`));\n\t}\n}\n\n/** checkRectInBounds requires the whole box to fit inside the diagram. */\nfunction checkRectInBounds(\n\tlabel: string,\n\tid: string,\n\trect: Rect,\n\tbounds: Rect,\n\tissues: GeometryIssue[],\n): void {\n\tif (!contains(bounds, rect)) {\n\t\tissues.push(issue(\"out_of_bounds\", [id], `${label} ${id} lies outside the resolved view bounds`));\n\t}\n}\n\n/** checkNodeOverlaps prevents two nodes from sharing the same area. */\nfunction checkNodeOverlaps(nodes: ResolvedNode[], issues: GeometryIssue[]): void {\n\tforEachPair(nodes, (first, second) => {\n\t\tif (overlaps(first.bounds, second.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"node_overlap\",\n\t\t\t\t[first.id, second.id],\n\t\t\t\t`nodes ${first.id} and ${second.id} overlap`,\n\t\t\t));\n\t\t}\n\t});\n}\n\n/**\n * checkGroupOverlaps allows one real boundary inside another, but rejects\n * boundaries that partly cover each other and suggest false ownership.\n */\nfunction checkGroupOverlaps(groups: ResolvedGroup[], issues: GeometryIssue[]): void {\n\tforEachPair(groups, (first, second) => {\n\t\tif (\n\t\t\toverlaps(first.bounds, second.bounds) &&\n\t\t\t!contains(first.bounds, second.bounds) &&\n\t\t\t!contains(second.bounds, first.bounds)\n\t\t) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"group_overlap\",\n\t\t\t\t[first.id, second.id],\n\t\t\t\t`groups ${first.id} and ${second.id} partially overlap`,\n\t\t\t));\n\t\t}\n\t});\n}\n\n/**\n * checkOwnership requires each child to be inside the parent named by the\n * model. Visual overlap never creates ownership.\n */\nfunction checkOwnership(\n\tnodes: MeasuredNode[],\n\tgroups: MeasuredGroup[],\n\tresolvedNodes: Map,\n\tresolvedGroups: Map,\n\tissues: GeometryIssue[],\n): void {\n\tfor (const node of nodes) {\n\t\tconst child = resolvedNodes.get(node.id);\n\t\tif (child && child.parentId !== node.parentId) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[node.id],\n\t\t\t\t`node ${node.id} has the wrong parent ID`,\n\t\t\t));\n\t\t}\n\t\tif (!node.parentId) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst parent = resolvedGroups.get(node.parentId);\n\t\tif (child && parent && !contains(parent.bounds, child.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[node.id, node.parentId],\n\t\t\t\t`node ${node.id} lies outside owning group ${node.parentId}`,\n\t\t\t));\n\t\t}\n\t}\n\tfor (const group of groups) {\n\t\tconst child = resolvedGroups.get(group.id);\n\t\tif (child && child.parentId !== group.parentId) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[group.id],\n\t\t\t\t`group ${group.id} has the wrong parent ID`,\n\t\t\t));\n\t\t}\n\t\tif (!group.parentId) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst parent = resolvedGroups.get(group.parentId);\n\t\tif (child && parent && !contains(parent.bounds, child.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[group.id, group.parentId],\n\t\t\t\t`group ${group.id} lies outside owning group ${group.parentId}`,\n\t\t\t));\n\t\t}\n\t}\n}\n\n/**\n * checkEdges checks connected node IDs, complete routes, crossings, labels,\n * and boundary crossings for every relationship.\n */\nfunction checkEdges(\n\tmeasured: MeasuredDiagram,\n\tresolved: ResolvedLayout,\n\tnodes: Map,\n\tgroups: Map,\n\tmeasuredNodes: Map,\n\tmeasuredGroups: Map,\n\tissues: GeometryIssue[],\n): void {\n\tconst measuredEdges = new Map(measured.edges.map(edge => [edge.id, edge]));\n\tconst labels: Array<{id: string; bounds: Rect}> = [];\n\tfor (const edge of resolved.edges) {\n\t\tconst expected = measuredEdges.get(edge.id);\n\t\tif (!expected) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\tedge.sourceId !== expected.sourceId ||\n\t\t\tedge.targetId !== expected.targetId\n\t\t) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"disconnected_edge\",\n\t\t\t\t[edge.id, edge.sourceId, edge.targetId],\n\t\t\t\t`edge ${edge.id} endpoints do not match its measured contract`,\n\t\t\t));\n\t\t}\n\t\tif (edge.sections.length === 0 || edge.sections.some(section => section.length < 2)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"disconnected_edge\",\n\t\t\t\t[edge.id],\n\t\t\t\t`edge ${edge.id} has no complete route section`,\n\t\t\t));\n\t\t\tcontinue;\n\t\t}\n\t\tcheckSectionConnections(edge, nodes, issues);\n\t\tfor (const section of edge.sections) {\n\t\t\tfor (const point of section) {\n\t\t\t\tif (!isFinitePoint(point) || !pointInRect(point, resolved.bounds, true)) {\n\t\t\t\t\tissues.push(issue(\n\t\t\t\t\t\t\"out_of_bounds\",\n\t\t\t\t\t\t[edge.id],\n\t\t\t\t\t\t`edge ${edge.id} has a route point outside the resolved view`,\n\t\t\t\t\t));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const node of nodes.values()) {\n\t\t\tif (node.id === edge.sourceId || node.id === edge.targetId) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (routeIntersectsRect(edge.sections, inset(node.bounds, 0.5))) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"edge_through_node\",\n\t\t\t\t\t[edge.id, node.id],\n\t\t\t\t\t`edge ${edge.id} crosses unrelated node ${node.id}`,\n\t\t\t\t));\n\t\t\t}\n\t\t}\n\t\tfor (const group of groups.values()) {\n\t\t\tconst sourceInside = belongsToGroup(\n\t\t\t\tedge.sourceId,\n\t\t\t\tgroup.id,\n\t\t\t\tmeasuredNodes,\n\t\t\t\tmeasuredGroups,\n\t\t\t);\n\t\t\tconst targetInside = belongsToGroup(\n\t\t\t\tedge.targetId,\n\t\t\t\tgroup.id,\n\t\t\t\tmeasuredNodes,\n\t\t\t\tmeasuredGroups,\n\t\t\t);\n\t\t\tif (\n\t\t\t\tsourceInside === targetInside &&\n\t\t\t\trouteViolatesGroup(edge.sections, group.bounds, sourceInside)\n\t\t\t) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"edge_through_group\",\n\t\t\t\t\t[edge.id, group.id],\n\t\t\t\t\t`edge ${edge.id} violates group ${group.id} boundary`,\n\t\t\t\t));\n\t\t\t}\n\t\t}\n\t\tif (edge.labelBounds) {\n\t\t\tcheckFiniteRect(\"edge label\", edge.id, edge.labelBounds, issues);\n\t\t\tcheckRectInBounds(\"edge label\", edge.id, edge.labelBounds, resolved.bounds, issues);\n\t\t\tif (expected.labelSize && (\n\t\t\t\t!nearlyEqual(expected.labelSize.width, edge.labelBounds.width) ||\n\t\t\t\t!nearlyEqual(expected.labelSize.height, edge.labelBounds.height)\n\t\t\t)) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"size_mismatch\",\n\t\t\t\t\t[edge.id],\n\t\t\t\t\t`edge ${edge.id} label size changed after measurement`,\n\t\t\t\t));\n\t\t\t}\n\t\t\tfor (const node of nodes.values()) {\n\t\t\t\tif (overlaps(edge.labelBounds, node.bounds)) {\n\t\t\t\t\tissues.push(issue(\n\t\t\t\t\t\t\"label_node_overlap\",\n\t\t\t\t\t\t[edge.id, node.id],\n\t\t\t\t\t\t`edge ${edge.id} label overlaps node ${node.id}`,\n\t\t\t\t\t));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const group of groups.values()) {\n\t\t\t\tif (overlaps(edge.labelBounds, group.titleBounds)) {\n\t\t\t\t\tissues.push(issue(\n\t\t\t\t\t\t\"label_title_overlap\",\n\t\t\t\t\t\t[edge.id, group.id],\n\t\t\t\t\t\t`edge ${edge.id} label overlaps group ${group.id} title`,\n\t\t\t\t\t));\n\t\t\t\t}\n\t\t\t}\n\t\t\tlabels.push({id: edge.id, bounds: edge.labelBounds});\n\t\t} else if (expected.labelSize) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"missing_element\",\n\t\t\t\t[edge.id],\n\t\t\t\t`edge ${edge.id} is missing its measured label`,\n\t\t\t));\n\t\t}\n\t}\n\tforEachPair(labels, (first, second) => {\n\t\tif (overlaps(first.bounds, second.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"label_label_overlap\",\n\t\t\t\t[first.id, second.id],\n\t\t\t\t`edge labels ${first.id} and ${second.id} overlap`,\n\t\t\t));\n\t\t}\n\t});\n\tfor (const label of labels) {\n\t\tfor (const edge of resolved.edges) {\n\t\t\tif (routeIntersectsRect(edge.sections, inset(label.bounds, 0.5))) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"label_edge_overlap\",\n\t\t\t\t\t[label.id, edge.id],\n\t\t\t\t\t`edge ${edge.id} crosses label ${label.id}`,\n\t\t\t\t));\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * checkSectionConnections requires one ordered route from the source border to\n * the target border. Separate or reversed sections are not a complete route.\n */\nfunction checkSectionConnections(\n\tedge: ResolvedEdge,\n\tnodes: Map,\n\tissues: GeometryIssue[],\n): void {\n\tfor (let index = 1; index < edge.sections.length; index++) {\n\t\tconst previous = edge.sections[index - 1].slice(-1)[0];\n\t\tconst current = edge.sections[index][0];\n\t\tif (!samePoint(previous, current)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"disconnected_edge\",\n\t\t\t\t[edge.id],\n\t\t\t\t`edge ${edge.id} has disconnected route sections`,\n\t\t\t));\n\t\t\treturn;\n\t\t}\n\t}\n\tconst source = nodes.get(edge.sourceId);\n\tconst target = nodes.get(edge.targetId);\n\tconst start = edge.sections[0][0];\n\tconst end = edge.sections.slice(-1)[0].slice(-1)[0];\n\tif (\n\t\t!source ||\n\t\t!target ||\n\t\t!pointOnBorder(start, source.bounds) ||\n\t\t!pointOnBorder(end, target.bounds)\n\t) {\n\t\tissues.push(issue(\n\t\t\t\"disconnected_edge\",\n\t\t\t[edge.id, edge.sourceId, edge.targetId],\n\t\t\t`edge ${edge.id} does not connect both node borders`,\n\t\t));\n\t}\n}\n\n/** belongsToGroup follows parent IDs to decide whether a node belongs to a group. */\nfunction belongsToGroup(\n\tnodeId: string,\n\tgroupId: string,\n\tnodes: Map,\n\tgroups: Map,\n): boolean {\n\tlet parent = nodes.get(nodeId)?.parentId;\n\twhile (parent) {\n\t\tif (parent === groupId) {\n\t\t\treturn true;\n\t\t}\n\t\tparent = groups.get(parent)?.parentId;\n\t}\n\treturn false;\n}\n\n/**\n * routeViolatesGroup checks the middle of each line. When both connected nodes\n * are inside a group, the line must stay inside it. When both are outside, the\n * line must stay outside it.\n */\nfunction routeViolatesGroup(\n\tsections: Point[][],\n\tgroup: Rect,\n\tshouldBeInside: boolean,\n): boolean {\n\tfor (const section of sections) {\n\t\tfor (let index = 1; index < section.length; index++) {\n\t\t\tconst midpoint = {\n\t\t\t\tx: (section[index - 1].x + section[index].x) / 2,\n\t\t\t\ty: (section[index - 1].y + section[index].y) / 2,\n\t\t\t};\n\t\t\tif (pointInRect(midpoint, group, false) !== shouldBeInside) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\n/** routeIntersectsRect reports whether any part of a route enters a box. */\nfunction routeIntersectsRect(sections: Point[][], rect: Rect): boolean {\n\treturn sections.some(section => section.some((point, index) =>\n\t\tindex > 0 && segmentIntersectsRect(section[index - 1], point, rect),\n\t));\n}\n\n/**\n * segmentIntersectsRect checks both straight and diagonal lines. A line may\n * touch the box border, but it may not enter the box.\n */\nfunction segmentIntersectsRect(start: Point, end: Point, rect: Rect): boolean {\n\tconst dx = end.x - start.x;\n\tconst dy = end.y - start.y;\n\tlet minimum = 0;\n\tlet maximum = 1;\n\tfor (const [origin, delta, lower, upper] of [\n\t\t[start.x, dx, rect.x, rect.x + rect.width],\n\t\t[start.y, dy, rect.y, rect.y + rect.height],\n\t] as const) {\n\t\tif (Math.abs(delta) < Number.EPSILON) {\n\t\t\tif (origin <= lower || origin >= upper) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst first = (lower - origin) / delta;\n\t\tconst second = (upper - origin) / delta;\n\t\tminimum = Math.max(minimum, Math.min(first, second));\n\t\tmaximum = Math.min(maximum, Math.max(first, second));\n\t\tif (minimum >= maximum) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn maximum > 0 && minimum < 1;\n}\n\n/** overlaps treats touching borders as contact, not shared area. */\nfunction overlaps(first: Rect, second: Rect): boolean {\n\treturn (\n\t\tfirst.x < second.x + second.width &&\n\t\tsecond.x < first.x + first.width &&\n\t\tfirst.y < second.y + second.height &&\n\t\tsecond.y < first.y + first.height\n\t);\n}\n\n/** contains requires the whole inner box to be inside the outer box. */\nfunction contains(outer: Rect, inner: Rect): boolean {\n\treturn (\n\t\touter.x <= inner.x &&\n\t\touter.y <= inner.y &&\n\t\touter.x + outer.width >= inner.x + inner.width &&\n\t\touter.y + outer.height >= inner.y + inner.height\n\t);\n}\n\n/** pointInRect can include or exclude points that only touch the border. */\nfunction pointInRect(point: Point, rect: Rect, inclusive: boolean): boolean {\n\tif (inclusive) {\n\t\treturn (\n\t\t\tpoint.x >= rect.x &&\n\t\t\tpoint.y >= rect.y &&\n\t\t\tpoint.x <= rect.x + rect.width &&\n\t\t\tpoint.y <= rect.y + rect.height\n\t\t);\n\t}\n\treturn (\n\t\tpoint.x > rect.x &&\n\t\tpoint.y > rect.y &&\n\t\tpoint.x < rect.x + rect.width &&\n\t\tpoint.y < rect.y + rect.height\n\t);\n}\n\n/** inset makes a box smaller so touching its border does not count as crossing it. */\nfunction inset(rect: Rect, amount: number): Rect {\n\treturn {\n\t\tx: rect.x + amount,\n\t\ty: rect.y + amount,\n\t\twidth: Math.max(0, rect.width - amount * 2),\n\t\theight: Math.max(0, rect.height - amount * 2),\n\t};\n}\n\n/** isFinitePoint accepts only real numbers that SVG can draw. */\nfunction isFinitePoint(point: Point): boolean {\n\treturn Number.isFinite(point.x) && Number.isFinite(point.y);\n}\n\n/** isFiniteRect checks all four numbers in a box. */\nfunction isFiniteRect(rect: Rect): boolean {\n\treturn isFinitePoint(rect) && Number.isFinite(rect.width) && Number.isFinite(rect.height);\n}\n\n/** samePoint compares route points while allowing tiny browser number changes. */\nfunction samePoint(first: Point, second: Point): boolean {\n\treturn nearlyEqual(first.x, second.x) && nearlyEqual(first.y, second.y);\n}\n\n/** pointOnBorder checks that a route endpoint touches one side of a node box. */\nfunction pointOnBorder(point: Point, rect: Rect): boolean {\n\tconst withinX = point.x >= rect.x - 0.1 && point.x <= rect.x + rect.width + 0.1;\n\tconst withinY = point.y >= rect.y - 0.1 && point.y <= rect.y + rect.height + 0.1;\n\tconst onVertical = nearlyEqual(point.x, rect.x) ||\n\t\tnearlyEqual(point.x, rect.x + rect.width);\n\tconst onHorizontal = nearlyEqual(point.y, rect.y) ||\n\t\tnearlyEqual(point.y, rect.y + rect.height);\n\treturn (withinY && onVertical) || (withinX && onHorizontal);\n}\n\n/** nearlyEqual hides only browser rounding smaller than one tenth of a unit. */\nfunction nearlyEqual(first: number, second: number): boolean {\n\treturn Math.abs(first - second) <= 0.1;\n}\n\n/** forEachPair compares each pair once. */\nfunction forEachPair(items: T[], visit: (first: T, second: T) => void): void {\n\tfor (let first = 0; first < items.length; first++) {\n\t\tfor (let second = first + 1; second < items.length; second++) {\n\t\t\tvisit(items[first], items[second]);\n\t\t}\n\t}\n}\n\n/** issue creates one layout problem report. */\nfunction issue(\n\tcode: GeometryIssueCode,\n\telementIds: string[],\n\tmessage: string,\n): GeometryIssue {\n\treturn {code, elementIds, message};\n}\n","import {svgTextWrap} from \"./svg-text\";\nimport {SVG_STYLES} from \"./constants\";\n\nexport const create = {\n\telement(type: string, attrs: Record = {}, className?: string) {\n\t\tconst el = document.createElementNS('http://www.w3.org/2000/svg', type);\n\t\tObject.entries(attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n\t\tif (className) el.classList.add(className);\n\t\treturn el;\n\t},\n\n\tuse(id: string, attrs: Record = {}) {\n\t\tconst el = this.element('use', attrs);\n\t\tel.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#' + id);\n\t\treturn el;\n\t},\n\n\tpath(path: string, attrs: Record = {}, className?: string) {\n\t\tconst p = this.element(\"path\", {...attrs, d: path}, className);\n\t\treturn p;\n\t},\n\n\ttext(text: string, attrs: Record = {}) {\n\t\tconst t = this.element('text', attrs) as SVGTextElement;\n\t\tif (text) t.textContent = text;\n\t\treturn t;\n\t},\n\n\ttextArea(text: string, width: number, fontSize: number, bold: boolean, x = 0, y = 0, anchor = '') {\n\t\tconst attrs: Record = {\n\t\t\t'font-family': SVG_STYLES.edgeText['font-family'],\n\t\t\t'font-size': `${fontSize}px`,\n\t\t\t'font-weight': bold ? 'bold' : 'normal'\n\t\t};\n\t\tconst {lines, maxW} = svgTextWrap(text, width, attrs);\n\t\tconst txt = this.text('', {x: 0, y, 'text-anchor': anchor || undefined});\n\t\t\n\t\tlines.forEach((line, i) => {\n\t\t\tconst span = this.element('tspan', {x, dy: `${fontSize + 2}px`, ...attrs});\n\t\t\tspan.textContent = line;\n\t\t\ttxt.append(span);\n\t\t});\n\t\t\n\t\treturn {txt, dy: (lines.length + 1) * (fontSize + 2), maxW};\n\t},\n\n\trect(width: number, height: number, x = 0, y = 0, r = 0, className?: string) {\n\t\treturn this.element('rect', {x, y, rx: r, ry: r, width, height}, className) as SVGRectElement;\n\t},\n\n\ticon(icon: string, x = 0, y = 0) {\n\t\treturn this.use(icon, {x, y});\n\t},\n\n\texpand(x: number, y: number, expanded: boolean) {\n\t\tconst g = this.element('g', {transform: `translate(${x},${y})`}, 'expand') as SVGGElement;\n\t\tg.append(\n\t\t\tthis.rect(19, 19, 0, 0, 1),\n\t\t\tthis.text(expanded ? '-' : '+', {x: 10, y: 14, 'text-anchor': 'middle'})\n\t\t);\n\t\treturn g;\n\t}\n};\n\nexport function setPosition(g: SVGGElement, x: number, y: number) {\n\tg.setAttribute('transform', `translate(${x},${y})`);\n}\n","interface Point {\n\tx: number;\n\ty: number;\n}\n\ninterface BBox extends Point {\n\twidth: number;\n\theight: number;\n}\n\n\nexport function insideBox(p: Point, b: BBox, centeredBox = true): boolean {\n\treturn centeredBox ?\n\t\t(p.x > b.x - b.width / 2 && p.x < b.x + b.width / 2 && p.y > b.y - b.height / 2 && p.y < b.y + b.height / 2) :\n\t\t(p.x > b.x && p.x < b.x + b.width && p.y > b.y && p.y < b.y + b.height)\n}\n\nexport function boxesOverlap(b1: BBox, b2: BBox): boolean {\n\treturn b1.x < b2.x + b2.width && b1.y < b2.y + b2.height && b1.x + b1.width > b2.x && b1.y + b1.height > b2.y\n}\n\nexport function uncenterBox(b: BBox): BBox {\n\treturn {x: b.x - b.width / 2, y: b.y - b.height / 2, width: b.width, height: b.height}\n}\n\nexport function scaleBox(b: BBox, sc: number): BBox {\n\treturn {x: b.x * sc, y: b.y * sc, width: b.width * sc, height: b.height * sc}\n}\n\n// intersect 2 segments (p1->q1) with (p2, q2)\n// if the lines intersect, the result contains the x and y of the intersection (treating the lines as infinite)\n// and booleans for whether line segment 1 or line segment 2 contain the point\nfunction segmentIntersection(p1: Point, q1: Point, p2: Point, q2: Point) {\n\tlet denominator, a, b, numerator1, numerator2,\n\t\tresult: { x: number, y: number, onLine1: boolean, onLine2: boolean } = {\n\t\t\tx: null,\n\t\t\ty: null,\n\t\t\tonLine1: false,\n\t\t\tonLine2: false\n\t\t};\n\tdenominator = (q2.y - p2.y) * (q1.x - p1.x) - (q2.x - p2.x) * (q1.y - p1.y);\n\tif (denominator == 0) {\n\t\treturn result;\n\t}\n\ta = p1.y - p2.y;\n\tb = p1.x - p2.x;\n\tnumerator1 = ((q2.x - p2.x) * a) - ((q2.y - p2.y) * b);\n\tnumerator2 = ((q1.x - p1.x) * a) - ((q1.y - p1.y) * b);\n\ta = numerator1 / denominator;\n\tb = numerator2 / denominator;\n\n\t// if we cast these lines infinitely in both directions, they intersect here:\n\tresult.x = p1.x + (a * (q1.x - p1.x));\n\tresult.y = p1.y + (a * (q1.y - p1.y));\n\n\t// if line1 is a segment and line2 is infinite, they intersect if:\n\tif (a > 0 && a < 1) {\n\t\tresult.onLine1 = true;\n\t}\n\t// if line2 is a segment and line1 is infinite, they intersect if:\n\tif (b >= 0 && b <= 1) {\n\t\tresult.onLine2 = true;\n\t}\n\t// if line1 and line2 are segments, they intersect if both of the above are true\n\treturn result;\n}\n\n// intersects a segment (p1->p2) with a box\nexport function intersectRectFull(p1: Point, p2: Point, box: BBox): Point[] {\n\tconst w = box.width / 2\n\tconst h = box.height / 2\n\tconst segs: { p: Point; q: Point }[] = [\n\t\t{p: {x: box.x - w, y: box.y - h}, q: {x: box.x - w, y: box.y + h}},\n\t\t{p: {x: box.x - w, y: box.y - h}, q: {x: box.x + w, y: box.y - h}},\n\t\t{p: {x: box.x + w, y: box.y - h}, q: {x: box.x + w, y: box.y + h}},\n\t\t{p: {x: box.x - w, y: box.y + h}, q: {x: box.x + w, y: box.y + h}},\n\t]\n\treturn segs.map(s => segmentIntersection(p1, p2, s.p, s.q)).filter(ret => ret.onLine1 && ret.onLine2)\n}\n\n// intersects a line that goes from p to the center of the box\nexport function intersectRect(box: BBox, p: Point): Point {\n\tif (insideBox(p, box)) return {x: box.x, y: box.y}\n\treturn intersectRectFull(box, p, box)[0] || {x: box.x, y: box.y}\n}\n\nexport function intersectEllipse(ellCenter: Point, rx: number, ry: number, nodeCenter: Point, point: Point) {\n\n\t//translate all to center ellipse\n\tconst p1 = {x: point.x - ellCenter.x, y: point.y - ellCenter.y}\n\tconst p2 = {x: nodeCenter.x - ellCenter.x, y: nodeCenter.y - ellCenter.y}\n\n\tif (p2.x == p1.x) { //hack to avoid singularity\n\t\tp1.x += .0000001\n\t}\n\n\tconst s = (p2.y - p1.y) / (p2.x - p1.x);\n\tconst si = p2.y - (s * p2.x);\n\tconst a = (ry * ry) + (rx * rx * s * s);\n\tconst b = 2 * rx * rx * si * s;\n\tconst c = rx * rx * si * si - rx * rx * ry * ry;\n\n\tconst radicand_sqrt = Math.sqrt((b * b) - (4 * a * c));\n\tconst x = p1.x > p2.x ?\n\t\t(-b + radicand_sqrt) / (2 * a) :\n\t\t(-b - radicand_sqrt) / (2 * a)\n\tconst pos = {\n\t\tx: x,\n\t\ty: s * x + si\n\t}\n\t//translate back\n\tpos.x += ellCenter.x;\n\tpos.y += ellCenter.y\n\n\treturn pos;\n}\n\nexport interface Segment {\n\tp: Point;\n\tq: Point;\n}\n\n// given a polyline as a list of segments, interrupt it over the box so no line is inside the box\nexport function intersectPolylineBox(segments: Segment[], box: BBox) {\n\tfor (let i = 0; i < segments.length; i++) {\n\t\tconst s = segments[i]\n\t\tif (insideBox(s.p, box)) {\n\t\t\tif (insideBox(s.q, box)) { // segment both ends inside box\n\t\t\t\tsegments.splice(i, 1)\n\t\t\t\ti -= 1\n\t\t\t} else { // segment start inside box\n\t\t\t\ts.p = intersectRectFull(s.p, s.q, box)[0]\n\t\t\t}\n\t\t} else {\n\t\t\tif (insideBox(s.q, box)) { // segment end inside box\n\t\t\t\ts.q = intersectRectFull(s.p, s.q, box)[0]\n\t\t\t} else { // both ends outside\n\t\t\t\tconst ret = intersectRectFull(s.p, s.q, box)\n\t\t\t\tif (ret.length == 2) { // intersects the box, splice segment\n\t\t\t\t\t// order the intersection points, closest first\n\t\t\t\t\tconst dst1 = Math.abs(ret[0].x - s.p.x) + Math.abs(ret[0].y - s.p.y)\n\t\t\t\t\tconst dst2 = Math.abs(ret[1].x - s.p.x) + Math.abs(ret[1].y - s.p.y)\n\t\t\t\t\tif (dst1 > dst2) ret.reverse()\n\t\t\t\t\t// split the segment in 2\n\t\t\t\t\tconst s2 = {p: ret[1], q: s.q}\n\t\t\t\t\ts.q = ret[0]\n\t\t\t\t\tsegments.splice(i + 1, 0, s2)\n\t\t\t\t\ti += 1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function project(p: Point, a: Point, b: Point): Point {\n\tlet atob = {x: b.x - a.x, y: b.y - a.y};\n\tlet atop = {x: p.x - a.x, y: p.y - a.y};\n\tlet len = atob.x * atob.x + atob.y * atob.y;\n\tlet dot = atop.x * atob.x + atop.y * atob.y;\n\tlet t = Math.min(1, Math.max(0, dot / len));\n\treturn {\n\t\tx: a.x + atob.x * t,\n\t\ty: a.y + atob.y * t\n\t};\n}\n\nexport function cabDistance(p1: Point, p2: Point): number {\n\treturn Math.abs(p2.x - p1.x) + Math.abs(p2.y - p1.y)\n}","import {intersectEllipse, intersectRect} from \"./intersect\";\n\ninterface Point {\n\tx: number;\n\ty: number;\n}\n\ninterface BBox extends Point {\n\twidth: number;\n\theight: number;\n}\n\ninterface D3Node extends BBox {\n\tintersect: (p: Point) => Point\n}\n\nfunction cylinderRadiusY(width: number) {\n\treturn width / 2 / (5.5 + width / 70);\n}\n\nexport function shapeLabelOffsetY(shape: string, width: number, height: number) {\n\tswitch (shape.toLowerCase()) {\n\t\tcase \"cylinder\":\n\t\t\treturn 2 * cylinderRadiusY(width);\n\t\tcase \"person\":\n\t\t\treturn height * 0.4;\n\t\tcase \"folder\":\n\t\t\treturn width / 10;\n\t\tcase \"robot\":\n\t\t\treturn height * 0.35;\n\t\tcase \"webbrowser\":\n\t\t\treturn height / 8;\n\t\tdefault:\n\t\t\treturn 0;\n\t}\n}\n\nclass D3Element {\n\tprivate readonly _el: SVGElement\n\n\tconstructor(el: SVGElement) {\n\t\tthis._el = el;\n\t}\n\n\tnode() {\n\t\treturn this._el;\n\t}\n\n\tattr(name: string, value: string | number) {\n\t\tthis._el.setAttribute(name, String(value))\n\t\treturn this;\n\t}\n\n\tinsert(type: string, pos: string) {\n\t\tconst el = document.createElementNS('http://www.w3.org/2000/svg', type)\n\t\tconst el2 = this._el.insertBefore(el, this._el.querySelector(pos))\n\t\treturn new D3Element(el2)\n\t}\n}\n\n\nfunction rect(parent: D3Element, bbox: BBox, node: D3Node, rounded = false) {\n\tconst shapeSvg = parent.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", rounded ? node.width / 8 : 3)\n\t\t.attr(\"ry\", rounded ? node.width / 8 : 3)\n\t\t.attr(\"x\", -bbox.width / 2)\n\t\t.attr(\"y\", -bbox.height / 2)\n\t\t.attr(\"width\", bbox.width)\n\t\t.attr(\"height\", bbox.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect(node, point);\n\t};\n\n\treturn shapeSvg;\n}\n\n\nfunction cylinder(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = bbox.width;\n\tconst rx = w / 2;\n\tconst ry = cylinderRadiusY(w);\n\tconst h = bbox.height;\n\n\tconst shape =\n\t\t`M 0,${ry} a${rx},${ry} 0,0,0 ${w} 0 a ${rx},${ry} 0,0,0 ${-w} 0 l 0,${h - 2 * ry} a ${rx},${ry} 0,0,0 ${w} 0 l 0,${-h + 2 * ry}`;\n\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"cylinder\", w, h))\n\t\t.insert('path', ':first-child')\n\t\t.attr('d', shape)\n\t\t.attr('transform', 'translate(' + -w / 2 + ',' + -(h / 2) + ')');\n\n\tnode.intersect = function (point: Point) {\n\t\tconst pos = intersectRect(node, point)\n\t\tlet cy = node.y + node.height / 2 - ry\n\t\tif (pos.y > cy)\n\t\t\treturn intersectEllipse({x: node.x, y: cy}, rx, ry, node, point)\n\n\t\tcy = node.y - node.height / 2 + ry\n\t\tif (pos.y < cy)\n\t\t\treturn intersectEllipse({x: node.x, y: cy}, rx, ry, node, point)\n\n\t\treturn pos;\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction person(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = bbox.width;\n\tconst h = bbox.height;\n\n\tconst shape =\n\t\t`M ${.38 * w},${h / 3} A${w / 2},${h / 2} 0,0,0 0 ${h / 2}\n\t\tL${w / 11},${h} L${w - w / 11},${h} L${w},${h / 2}\n\t\tA${w / 2},${h / 2} 0,0,0 ${w - .38 * w} ${h / 3} \n\t\tA${w / 6},${w / 6} 0,1,0 ${.38 * w} ${h / 3}`;\n\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"person\", w, h))\n\t\t.insert('path', ':first-child')\n\t\t.attr('d', shape)\n\t\t.attr('transform', 'translate(' + -w / 2 + ',' + -(h / 2) + ')');\n\n\tnode.intersect = function (point: Point) {\n\t\tconst pos = intersectRect(node, point)\n\t\treturn pos;\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction _ellipse(parent: D3Element, bbox: BBox, node: D3Node, rx: number, ry: number) {\n\tconst shapeSvg = parent.insert(\"ellipse\", \":first-child\")\n\t\t.attr(\"cx\", 0)\n\t\t.attr(\"cy\", 0)\n\t\t.attr('rx', rx)\n\t\t.attr('ry', ry)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectEllipse(node, rx, ry, node, point)\n\t};\n\treturn shapeSvg;\n}\n\nfunction circle(parent: D3Element, bbox: BBox, node: D3Node) {\n\treturn _ellipse(parent, bbox, node, node.width / 2, node.width / 2)\n}\n\nfunction ellipse(parent: D3Element, bbox: BBox, node: D3Node) {\n\treturn _ellipse(parent, bbox, node, node.width * .55, node.width * .45)\n}\n\nfunction hexagon(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst sz = node.width / 2\n\t// drawing a hexagon from polar coords\n\t// [0,1,2,3,4,5,6].map(i=>`${Math.sin(Math.PI/3*i+Math.PI/6).toFixed(4)},${Math.cos(Math.PI/3*i+Math.PI/6).toFixed(4)}`).join(',')\n\tconst shapeSvg = parent.insert(\"polygon\", \":first-child\")\n\t\t.attr(\"points\",\n\t\t\t[0.5000, 0.8660, 1.0000, 0.0000, 0.5000, -0.8660, -0.5000, -0.8660, -1.0000, -0.0000, -0.5000, 0.8660, 0.5000, 0.8660].map(n => n * sz).join(','))\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectEllipse(node, node.width / 2, node.width / 2, node, point)\n\t};\n\treturn shapeSvg;\n}\n\nfunction component(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dx = node.width / 10\n\tconst shapeSvg = parent.insert('g', ':first-child')\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2 - dx)\n\t\t.attr(\"y\", -node.height / 2 + dx)\n\t\t.attr(\"width\", dx * 2)\n\t\t.attr(\"height\", dx);\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2 - dx)\n\t\t.attr(\"y\", -node.height / 2 + dx * 2.5)\n\t\t.attr(\"width\", dx * 2)\n\t\t.attr(\"height\", dx);\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2)\n\t\t.attr(\"y\", -node.height / 2)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x - dx / 2, y: node.y, width: node.width + dx, height: node.height}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction folder(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dy = node.width / 20\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"folder\", node.width, node.height))\n\t\t.insert('g', ':first-child')\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2)\n\t\t.attr(\"y\", -node.height / 2 + dy * 2)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height - dy * 2);\n\tshapeSvg.insert(\"path\", \":first-child\")\n\t\t.attr('d', `M0,${-node.height / 2 + 2 * dy} l${dy},${-2 * dy} h${node.width / 2 - dy * 2} v${dy * 2}`)\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x, y: node.y + dy / 2, width: node.width, height: node.height + dy}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction mobiledevicelandscape(parent: D3Element, bbox: BBox, node: D3Node, rounded = false) {\n\tconst dx = node.width / 8\n\tconst r = node.width / 14\n\tconst shapeSvg = parent.insert('g', ':first-child')\n\tshapeSvg.insert('path', ':first-child')\n\t\t.attr('d', `M${-node.width / 2},${-node.height / 2} l0,${node.height} M${node.width / 2},${-node.height / 2} l0,${node.height}`)\n\tshapeSvg.insert('circle', ':first-child')\n\t\t.attr('cx', -node.width / 2 - dx / 2)\n\t\t.attr('cy', 0)\n\t\t.attr('r', r * .4)\n\tshapeSvg.insert('rect', ':first-child')\n\t\t.attr('x', node.width / 2 + dx / 2 - r * .2)\n\t\t.attr('y', -r)\n\t\t.attr('width', r * .4)\n\t\t.attr('height', r * 2)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", r)\n\t\t.attr(\"ry\", r)\n\t\t.attr(\"x\", -bbox.width / 2 - dx)\n\t\t.attr(\"y\", -bbox.height / 2)\n\t\t.attr(\"width\", bbox.width + 2 * dx)\n\t\t.attr(\"height\", bbox.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x, y: node.y, width: node.width + 2 * dx, height: node.height}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction mobiledeviceportrait(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dy = node.width / 8\n\tconst r = node.width / 14\n\tconst shapeSvg = parent.insert('g', ':first-child')\n\tshapeSvg.insert('path', ':first-child')\n\t\t.attr('d', `M${-node.width / 2},${-node.height / 2} l${node.width},0 M${-node.width / 2},${node.height / 2} l${node.width},0`)\n\tshapeSvg.insert('circle', ':first-child')\n\t\t.attr('cx', 0)\n\t\t.attr('cy', node.height / 2 + dy / 2)\n\t\t.attr('r', r * .4)\n\tshapeSvg.insert('rect', ':first-child')\n\t\t.attr('x', -r)\n\t\t.attr('y', -node.height / 2 - dy / 2 - r * .2)\n\t\t.attr('width', r * 2)\n\t\t.attr('height', r * .4)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", r)\n\t\t.attr(\"ry\", r)\n\t\t.attr(\"x\", -bbox.width / 2)\n\t\t.attr(\"y\", -bbox.height / 2 - dy)\n\t\t.attr(\"width\", bbox.width)\n\t\t.attr(\"height\", bbox.height + 2 * dy);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x, y: node.y, width: node.width, height: node.height + 2 * dy}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction pipe(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = node.width;\n\tconst h = node.height;\n\tconst ry = h / 2;\n\tconst rx = ry / (2.5 + w / 70);\n\n\tconst shape =\n\t\t`M${-rx},0\n\t\ta${rx},${ry} 0,0,1 0,${h}\n\t\ta${rx},${ry} 0,0,1 0,${-h}\n\t\tl${w},0\n\t\ta${rx},${ry} 0,0,1 0,${h}\n\t\tl${-w},0`;\n\n\tconst shapeSvg = parent\n\t\t.insert('path', ':first-child')\n\t\t.attr('d', shape)\n\t\t.attr('transform', 'translate(' + -w / 2 + ',' + -(h / 2) + ')');\n\n\tnode.intersect = function (point: Point) {\n\t\treturn intersectRect({x: node.x - rx, y: node.y, width: node.width + 2 * rx, height: node.height}, point)\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction robot(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = node.width\n\tconst h = node.height\n\t\n\t// Small head at top (like person shape but robot-styled)\n\tconst headSize = Math.min(w * 0.28, h * 0.25)\n\tconst headR = headSize * 0.2\n\tconst antennaH = headSize * 0.25\n\tconst antennaR = headSize * 0.08\n\t\n\t// Eye dimensions\n\tconst eyeR = headSize * 0.12\n\tconst eyeSpacing = headSize * 0.22\n\t\n\t// Ear dimensions \n\tconst earW = headSize * 0.12\n\tconst earH = headSize * 0.3\n\t\n\t// Body fills most of the space for text\n\tconst bodyW = w\n\tconst bodyTop = -h / 2 + antennaH + headSize\n\tconst bodyH = h - antennaH - headSize\n\tconst bodyR = 3\n\t\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"robot\", w, h))\n\t\t.insert('g', ':first-child')\n\t\n\t// Body - main rectangle for text (draw first so it's behind)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", bodyR)\n\t\t.attr(\"ry\", bodyR)\n\t\t.attr('x', -bodyW / 2)\n\t\t.attr('y', bodyTop)\n\t\t.attr('width', bodyW)\n\t\t.attr('height', bodyH)\n\t\n\t// Head\n\tconst headTop = -h / 2 + antennaH\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", headR)\n\t\t.attr(\"ry\", headR)\n\t\t.attr('x', -headSize / 2)\n\t\t.attr('y', headTop)\n\t\t.attr('width', headSize)\n\t\t.attr('height', headSize)\n\t\n\t// Antenna\n\tshapeSvg.insert(\"line\", \":first-child\")\n\t\t.attr('class', 'robot-antenna')\n\t\t.attr('x1', 0)\n\t\t.attr('y1', headTop)\n\t\t.attr('x2', 0)\n\t\t.attr('y2', -h / 2 + antennaR * 2)\n\t\t.attr('stroke-width', antennaR * 0.6)\n\t\t.attr('stroke-linecap', 'round')\n\t\n\t// Antenna ball\n\tshapeSvg.insert(\"circle\", \":first-child\")\n\t\t.attr('class', 'robot-antenna-ball')\n\t\t.attr('cx', 0)\n\t\t.attr('cy', -h / 2 + antennaR * 2)\n\t\t.attr('r', antennaR * 1.2)\n\t\n\t// Eyes\n\tconst eyeY = headTop + headSize * 0.4\n\tshapeSvg.insert(\"circle\", \":first-child\")\n\t\t.attr('class', 'robot-eye')\n\t\t.attr('cx', -eyeSpacing)\n\t\t.attr('cy', eyeY)\n\t\t.attr('r', eyeR)\n\tshapeSvg.insert(\"circle\", \":first-child\")\n\t\t.attr('class', 'robot-eye')\n\t\t.attr('cx', eyeSpacing)\n\t\t.attr('cy', eyeY)\n\t\t.attr('r', eyeR)\n\t\n\t// Mouth - simple smile\n\tconst mouthY = headTop + headSize * 0.7\n\tconst mouthW = headSize * 0.28\n\tshapeSvg.insert(\"path\", \":first-child\")\n\t\t.attr('class', 'robot-mouth')\n\t\t.attr('d', `M${-mouthW / 2},${mouthY} Q0,${mouthY + mouthW * 0.3} ${mouthW / 2},${mouthY}`)\n\t\t.attr('fill', 'none')\n\t\t.attr('stroke-width', antennaR * 0.5)\n\t\t.attr('stroke-linecap', 'round')\n\t\n\t// Ears\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", earW * 0.25)\n\t\t.attr(\"ry\", earW * 0.25)\n\t\t.attr('x', -headSize / 2 - earW - 1)\n\t\t.attr('y', eyeY - earH / 2)\n\t\t.attr('width', earW)\n\t\t.attr('height', earH)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", earW * 0.25)\n\t\t.attr(\"ry\", earW * 0.25)\n\t\t.attr('x', headSize / 2 + 1)\n\t\t.attr('y', eyeY - earH / 2)\n\t\t.attr('width', earW)\n\t\t.attr('height', earH)\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect(node, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction webbrowser(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dy = node.height / 8\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"webbrowser\", node.width, node.height))\n\t\t.insert('g', ':first-child')\n\tshapeSvg.insert(\"path\", \":first-child\")\n\t\t.attr('d', `\n\t\t\tM${-node.width / 2},${-node.height / 2 + dy} h${node.width}\n\t\t\tM${-node.width / 2 + dy / 4},${-node.height / 2 + dy / 4} h${dy / 2} v${dy / 2} h${-dy / 2} z\n\t\t\tM${-node.width / 2 + dy},${-node.height / 2 + dy / 4} h${node.width - dy - dy / 4} v${dy / 2} h${-node.width + dy + dy / 4} z\n\t\t`)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2)\n\t\t.attr(\"y\", -node.height / 2)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect(node, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nexport const shapes: { [key: string]: (parent: SVGElement, node: D3Node) => SVGElement } = {\n\tbox: (parent: SVGElement, node: D3Node) => rect(new D3Element(parent), node, node).node(),\n\troundedbox: (parent: SVGElement, node: D3Node) => rect(new D3Element(parent), node, node, true).node(),\n\tcomponent: (parent: SVGElement, node: D3Node) => component(new D3Element(parent), node, node).node(),\n\tcylinder: (parent: SVGElement, node: D3Node) => cylinder(new D3Element(parent), node, node).node(),\n\tperson: (parent: SVGElement, node: D3Node) => person(new D3Element(parent), node, node).node(),\n\tcircle: (parent: SVGElement, node: D3Node) => circle(new D3Element(parent), node, node).node(),\n\tellipse: (parent: SVGElement, node: D3Node) => ellipse(new D3Element(parent), node, node).node(),\n\thexagon: (parent: SVGElement, node: D3Node) => hexagon(new D3Element(parent), node, node).node(),\n\tfolder: (parent: SVGElement, node: D3Node) => folder(new D3Element(parent), node, node).node(),\n\tmobiledevicelandscape: (parent: SVGElement, node: D3Node) => mobiledevicelandscape(new D3Element(parent), node, node).node(),\n\tmobiledeviceportrait: (parent: SVGElement, node: D3Node) => mobiledeviceportrait(new D3Element(parent), node, node).node(),\n\tmobiledevice: (parent: SVGElement, node: D3Node) => mobiledeviceportrait(new D3Element(parent), node, node).node(),\n\tpipe: (parent: SVGElement, node: D3Node) => pipe(new D3Element(parent), node, node).node(),\n\trobot: (parent: SVGElement, node: D3Node) => robot(new D3Element(parent), node, node).node(),\n\twebbrowser: (parent: SVGElement, node: D3Node) => webbrowser(new D3Element(parent), node, node).node(),\n}\n","/**\n * Undo functionality\n * at every change in the document, Undo can save a new version\n * so the user can \"undo\" and \"redo\" changes by reverting to an\n * older version of the document\n */\n\nexport class Undo {\n\tprivate readonly versions: Doc[] = [];\n\tprivate pos: number = 0;\n\tprivate lastSavedPos: number = 0;\n\tprivate readonly exportDoc: () => Doc;\n\tprivate readonly importDoc: (d: Doc) => void;\n\tchange: () => void;\n\tprivate tmpPreviousState: Doc | null = null;\n\n\tconstructor(id: string, exportDoc: () => Doc, importDoc: (d: Doc) => void) {\n\t\tthis.exportDoc = exportDoc;\n\t\tthis.importDoc = importDoc;\n\t\tthis.change = debounce(() => this.saveNow(), 300);\n\t}\n\n\t// Store the state previous to the changes collected in the debounce period\n\tbeforeChange() {\n\t\tif (!this.tmpPreviousState) {\n\t\t\tthis.tmpPreviousState = this.deepClone(this.exportDoc());\n\t\t}\n\t}\n\n\tlength() {\n\t\treturn this.versions.length;\n\t}\n\n\tcurrentState() {\n\t\treturn this.deepClone(this.versions[this.pos - 1]);\n\t}\n\n\tprivate saveNow() {\n\t\tif (!this.tmpPreviousState) {\n\t\t\tthrow Error(\"undo.change() was called without previously calling undo.beforeChange()!\");\n\t\t}\n\t\t\n\t\tthis.versions[this.pos] = this.deepClone(this.exportDoc());\n\t\tthis.versions[this.pos - 1] = this.tmpPreviousState;\n\t\tthis.tmpPreviousState = null;\n\t\tthis.pos += 1;\n\t\t\n\t\t// Remove anything that might be on top of this version\n\t\tthis.versions.splice(this.pos);\n\t}\n\n\tprivate deepClone(doc: Doc): Doc {\n\t\t// Use modern structuredClone if available, fallback to JSON\n\t\tif (typeof structuredClone !== 'undefined') {\n\t\t\treturn structuredClone(doc);\n\t\t}\n\t\treturn JSON.parse(JSON.stringify(doc));\n\t}\n\n\tundo() {\n\t\tif (this.pos < 2) return;\n\t\tthis.pos -= 1;\n\t\tconst doc = this.versions[this.pos - 1];\n\t\tthis.importDoc(this.deepClone(doc));\n\t}\n\n\tredo() {\n\t\tif (this.pos > this.versions.length - 1) return;\n\t\tconst doc = this.versions[this.pos];\n\t\tthis.importDoc(this.deepClone(doc));\n\t\tthis.pos += 1;\n\t}\n\n\tchanged() {\n\t\treturn this.pos !== this.lastSavedPos;\n\t}\n\n\tsetSaved() {\n\t\tthis.lastSavedPos = this.pos;\n\t}\n}\n\nfunction debounce(func: () => void, wait: number) {\n\tlet timeout: ReturnType;\n\treturn function () {\n\t\tconst context = this;\n\t\tconst later = function () {\n\t\t\ttimeout = null;\n\t\t\tfunc.apply(context);\n\t\t};\n\t\tclearTimeout(timeout);\n\t\ttimeout = setTimeout(later, wait);\n\t};\n}","import {applyStyle, NodeStyle, SVG_STYLES} from \"./constants\";\nimport {create} from \"./svg-create\";\nimport {svgTextWrap} from \"./svg-text\";\n\ninterface TextBlockLayout {\n\tlines: string[];\n\tfontSize: number;\n\tlineHeight: number;\n\tbold: boolean;\n\tfield?: string;\n\tgapAfter: number;\n}\n\nexport interface NodeContentLayout {\n\tblocks: TextBlockLayout[];\n\ttextHeight: number;\n\tminimumHeight: number;\n\t// The icon shares the content stack so text never draws over it.\n\ticon?: string;\n}\n\nconst HORIZONTAL_PADDING = 18;\nconst VERTICAL_PADDING = 18;\nconst TITLE_GAP = 6;\nconst METADATA_GAP = 10;\nconst ICON_SIZE = 32;\nconst ICON_GAP = 12;\n\nfunction textBlock(\n\ttext: string,\n\twidth: number,\n\tfontSize: number,\n\tbold: boolean,\n\tgapAfter: number,\n\tfield?: string,\n): TextBlockLayout {\n\tconst attrs = {\n\t\t\"font-family\": String(SVG_STYLES.nodeText[\"font-family\"]),\n\t\t\"font-size\": `${fontSize}px`,\n\t\t\"font-weight\": bold ? \"bold\" : \"normal\",\n\t};\n\tconst wrapped = svgTextWrap(text, width, attrs);\n\tconst lines = wrapped.lines.length > 0 ? wrapped.lines : [\"\"];\n\n\treturn {\n\t\tlines,\n\t\tfontSize,\n\t\tlineHeight: fontSize + 2,\n\t\tbold,\n\t\tfield,\n\t\tgapAfter,\n\t};\n}\n\nexport function layoutNodeContent(\n\ttitle: string,\n\tsubtitle: string,\n\tdescription: string,\n\tnodeWidth: number,\n\tfontSize: number,\n\tstyle: NodeStyle,\n): NodeContentLayout {\n\tconst textWidth = Math.max(nodeWidth - HORIZONTAL_PADDING * 2, 80);\n\tconst blocks = [textBlock(title, textWidth, fontSize, true, TITLE_GAP, \"name\")];\n\tif (style.metadata !== false && subtitle) {\n\t\tblocks.push(textBlock(`[${subtitle}]`, textWidth, fontSize * 0.7, false, METADATA_GAP));\n\t}\n\tif (style.description !== false && description) {\n\t\tblocks.push(textBlock(description, textWidth, Math.min(fontSize * 0.8, 16), false, 0, \"description\"));\n\t}\n\tblocks[blocks.length - 1].gapAfter = 0;\n\tconst textHeight = blocks.reduce(\n\t\t(height, block) => height + block.lines.length * block.lineHeight + block.gapAfter,\n\t\t0,\n\t);\n\n\treturn {\n\t\tblocks,\n\t\ttextHeight,\n\t\tminimumHeight: textHeight + VERTICAL_PADDING * 2 + (style.icon ? ICON_SIZE + ICON_GAP : 0),\n\t\ticon: style.icon,\n\t};\n}\n\nexport function buildNodeContent(layout: NodeContentLayout, color?: string): SVGGElement {\n\tconst group = create.element(\"g\") as SVGGElement;\n\tconst iconHeight = layout.icon ? ICON_SIZE + ICON_GAP : 0;\n\tlet top = -(layout.textHeight + iconHeight) / 2;\n\tif (layout.icon) {\n\t\tgroup.append(create.element(\"image\", {\n\t\t\thref: layout.icon,\n\t\t\tx: -ICON_SIZE / 2,\n\t\t\ty: top,\n\t\t\twidth: ICON_SIZE,\n\t\t\theight: ICON_SIZE,\n\t\t\tpreserveAspectRatio: \"xMidYMid meet\",\n\t\t}, \"nodeIcon\"));\n\t\ttop += iconHeight;\n\t}\n\n\tlayout.blocks.forEach((block) => {\n\t\tconst text = create.text(\"\", {\"text-anchor\": \"middle\"});\n\t\tapplyStyle(text, SVG_STYLES.nodeText);\n\t\tif (color) {\n\t\t\ttext.setAttribute(\"fill\", color);\n\t\t}\n\t\tif (block.field) {\n\t\t\ttext.setAttribute(\"data-field\", block.field);\n\t\t}\n\n\t\tblock.lines.forEach((line, index) => {\n\t\t\tconst span = create.element(\"tspan\", {\n\t\t\t\tx: 0,\n\t\t\t\ty: top + block.fontSize + index * block.lineHeight,\n\t\t\t\t\"font-size\": `${block.fontSize}px`,\n\t\t\t\t\"font-weight\": block.bold ? \"bold\" : \"normal\",\n\t\t\t});\n\t\t\tspan.textContent = line;\n\t\t\ttext.append(span);\n\t\t});\n\n\t\tgroup.append(text);\n\t\ttop += block.lines.length * block.lineHeight + block.gapAfter;\n\t});\n\n\treturn group;\n}\n","import {defs} from \"./defs\";\nimport {create, setPosition} from \"./svg-create\";\nimport {cursorInteraction} from \"svg-editor-tools/lib/cursor-interaction\";\nimport {shapeLabelOffsetY, shapes} from \"./shapes\";\nimport {\n\tboxesOverlap,\n\tcabDistance,\n\tinsideBox,\n\tintersectPolylineBox,\n\tproject,\n\tscaleBox,\n\tSegment,\n\tuncenterBox\n} from \"./intersect\";\nimport {autoLayout, LayoutOptions, validateCurrentLayout} from \"./layout\";\nimport {Undo} from \"./undo\";\nimport {\n\tADD_LABEL_VERTEX,\n\tADD_VERTEX,\n\tDEL_VERTEX,\n\tDESELECT,\n\tfindShortcut,\n\tREDO,\n\tSELECT_ALL,\n\tUNDO,\n\tZOOM_100,\n\tZOOM_FIT,\n\tZOOM_IN,\n\tZOOM_OUT\n} from \"../shortcuts\";\nimport {\n\tPoint,\n\tBBox,\n\tNodeStyle,\n\tEdgeStyle,\n\tDEFAULT_EDGE_STYLE,\n\tDEFAULT_NODE_STYLE,\n\tSVG_STYLES,\n\tSVG_PADDING,\n\tDEFAULT_GRID_SIZE,\n\tapplyStyle\n} from \"./constants\";\nimport {\n\tcalculateEdgeVertices,\n\tcalculateLabelPlacement,\n\tcreateEdgePath,\n\tEdgeLabelPlacement\n} from \"./edge-utils\";\nimport {\n\tbuildNodeContent,\n\tlayoutNodeContent,\n\tNodeContentLayout\n} from \"./node-content\";\nimport {ValidatedLayout} from \"./geometry\";\n\n\n// Point and BBox interfaces are now imported from constants\n\nexport interface Group extends BBox {\n\tid: string;\n\tname: string;\n\tnodes: (Node | Group)[];\n\tref?: SVGGElement;\n\tstyle: NodeStyle;\n\tlayoutBounds?: BBox;\n\tlayoutTitleBounds?: BBox;\n}\n\nexport interface NodeLink {\n\thref: string;\n\texportHref: string;\n}\n\nexport type LayoutDirection = 'UP' | 'DOWN' | 'LEFT' | 'RIGHT';\n\nexport interface Node extends BBox {\n\tid: string;\n\ttitle: string;\n\tsub: string;\n\tdescription: string;\n\n\tref?: SVGGElement;\n\tselected?: boolean;\n\n\tintersect: (p: Point) => Point\n\n\tstyle: NodeStyle\n\tlink?: NodeLink\n\tcontentLayout: NodeContentLayout\n}\n\n// NodeStyle interface is now imported from constants\n\n// EdgeStyle interface is now imported from constants\n\n// Default styles are now imported from constants\nconst defaultEdgeStyle = DEFAULT_EDGE_STYLE;\nconst defaultNodeStyle = DEFAULT_NODE_STYLE;\n\n// Edge and EdgeVertex interfaces are now defined in edge-utils.ts\n// Using local interfaces for compatibility with existing code\nexport interface Edge {\n\tid: string;\n\tlabel: string;\n\tfrom: Node;\n\tto: Node;\n\tvertices?: EdgeVertex[];\n\tref?: SVGGElement;\n\tstyle: EdgeStyle;\n\tinitVertex: (p: Point) => EdgeVertex;\n\tuserDeletedVertices?: boolean; // Track if user explicitly deleted vertices\n\tlabelVertex?: EdgeVertex; // ELK-calculated label position (separate from routing vertices)\n\tlabelBounds?: BBox;\n\tlayoutSections?: Point[][];\n\tlayoutLabelBounds?: BBox;\n}\n\ninterface EdgeVertex extends Point {\n\tid: string\n\tselected?: boolean\n\tedge: Edge\n\tref?: SVGElement\n\tlabel?: boolean\n\tauto?: boolean\n}\n\ninterface SavedEdgePoint extends Point {\n\tlabel?: boolean;\n\tauto?: boolean;\n}\n\ninterface Layout {\n\t[k: string]: Point | SavedEdgePoint[] | boolean\n}\n\n/** graphCount numbers the graphs created in this page; each GraphData uses it once for its idPrefix. */\nlet graphCount = 0\n\nexport class GraphData {\n\tid: string;\n\tname: string;\n\tnodesMap: Map;\n\tedges: Edge[];\n\tedgeVertices: Map\n\tgroupsMap: Map;\n\tmetadata: any;\n\tlayoutDirection?: LayoutDirection;\n\tvalidatedLayout?: ValidatedLayout;\n\tcolorToVarMap: Map = new Map(); // For CSS custom properties theming\n\t/**\n\t * svg is the element this graph draws into. Each graph has its own element,\n\t * so several graphs on one page never change each other's drawing, zoom, or\n\t * export. It carries no document-wide id; exportSVG adds id \"graph\" to the copy.\n\t */\n\treadonly svg: SVGSVGElement;\n\t/**\n\t * idPrefix starts every id this graph writes into its live svg, for example\n\t * \"g2-arrow\" or \"g2-\" plus a model element id, so two graphs in one page never\n\t * share an id. exportSVG removes it, so saved files keep the plain ids.\n\t */\n\treadonly idPrefix: string;\n\t/** selectListener receives the selected node in the editor; buildGraph sets it. */\n\tselectListener: (n: Node) => void;\n\t/** dragging is true while the editor user drags this graph's nodes or selection box. */\n\tdragging = false;\n\tprivate _undo: Undo;\n\tprivate _gridVisible: boolean = false;\n\tprivate _snapToGrid: boolean = true;\n\tprivate _gridSize: number = 25;\n\tprivate _skipAutoFit: boolean = false;\n\n\tconstructor(id?: string, name?: string) {\n\t\tthis.id = id;\n\t\tthis.name = name;\n\n\t\tthis.edges = [];\n\t\tthis.edgeVertices = new Map;\n\t\tthis.nodesMap = new Map;\n\t\tthis.groupsMap = new Map;\n\t\tthis.svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n\t\tthis.idPrefix = `g${++graphCount}-`;\n\n\t\tthis._undo = new Undo(\n\t\t\tthis.id,\n\t\t\t() => this.exportLayout(true),\n\t\t\t(lo) => this.importLayout(lo, true)\n\t\t)\n\t}\n\n\t// after the graph model is build using addNode, addEdge etc, initialize\n\tinit(layout?: Layout) {\n\t\tlayout && this.importLayout(layout)\n\t\tthis._undo = new Undo(\n\t\t\tthis.id,\n\t\t\t() => this.exportLayout(true),\n\t\t\t(lo) => this.importLayout(lo, true)\n\t\t)\n\t\tif (this._undo.length()) {\n\t\t\tthis.importLayout(this._undo.currentState())\n\t\t}\n\t\t\n\t\t// Save initial state so first action is undoable\n\t\tthis._undo.beforeChange()\n\t\tthis._undo.change()\n\t}\n\n\taddNode(id: string, label: string, sub: string, description: string, style: NodeStyle, link?: NodeLink) {\n\t\tif (this.nodesMap.has(id)) throw Error('duplicate node: ' + id)\n\t\tconst nodeStyle = {...defaultNodeStyle, ...style};\n\t\tconst shape = (nodeStyle.shape || 'Box').toLowerCase();\n\t\tconst minimumWidth = 280;\n\t\tconst minimumHeight = shape === 'person' ? 240 : 180;\n\t\tconst width = Math.max(minimumWidth, nodeStyle.width || 0);\n\t\tconst fontSize = nodeStyle.fontSize || 22;\n\t\tconst contentLayout = layoutNodeContent(label, sub, description, width, fontSize, nodeStyle);\n\t\tlet height = Math.max(minimumHeight, nodeStyle.height || 0, contentLayout.minimumHeight);\n\n\t\t// Some shapes shift labels down to reserve visual space for an icon,\n\t\t// header, or curved edge. Grow until the shifted content also fits.\n\t\tfor (let i = 0; i < 20; i++) {\n\t\t\tconst requiredHeight = contentLayout.minimumHeight +\n\t\t\t\tMath.abs(shapeLabelOffsetY(shape, width, height));\n\t\t\tif (requiredHeight <= height + 0.1) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\theight = requiredHeight;\n\t\t}\n\n\t\tconst n: Node = {\n\t\t\tid, title: label, sub, description, style: nodeStyle,\n\t\t\tx: 0, y: 0, width, height, intersect: null, link, contentLayout\n\t\t}\n\t\tthis.nodesMap.set(n.id, n)\n\t}\n\n\tnodes() {\n\t\treturn Array.from(this.nodesMap.values())\n\t}\n\n\taddEdge(id: string, fromNode: string, toNode: string, label: string, vertices: Point[], style: EdgeStyle) {\n\t\tvertices && vertices.forEach((p, i) => {\n\t\t\tconst v = p as EdgeVertex\n\t\t\tv.id = `v-${id}-${i}`\n\t\t\tthis.edgeVertices.set(v.id, v)\n\t\t})\n\t\t// Deterministic vertex IDs.\n\t\t//\n\t\t// `mdl svg` renders diagrams headlessly and saves the resulting SVG. If we\n\t\t// generate random vertex IDs, the SVG changes on every run even when the\n\t\t// underlying model and layout are unchanged. Use a stable hash instead.\n\t\tconst fnv1a36 = (input: string) => {\n\t\t\tlet h = 0x811c9dc5\n\t\t\tfor (let i = 0; i < input.length; i++) {\n\t\t\t\th ^= input.charCodeAt(i)\n\t\t\t\th = Math.imul(h, 0x01000193)\n\t\t\t}\n\t\t\treturn (h >>> 0).toString(36)\n\t\t}\n\t\tconst stableVertexID = (edgeID: string, p: Point) => {\n\t\t\tconst x = (p as any).x\n\t\t\tconst y = (p as any).y\n\t\t\treturn `v-${edgeID}-a-${fnv1a36(`${edgeID}:${x}:${y}`)}`\n\t\t}\n\t\tconst initVertex = (p: Point) => {\n\t\t\tconst v = p as EdgeVertex\n\t\t\tif (!v.id) {\n\t\t\t\tv.id = stableVertexID(edge.id, p)\n\t\t\t\tthis.edgeVertices.set(v.id, v)\n\t\t\t}\n\t\t\tv.edge = edge\n\t\t\treturn p as EdgeVertex\n\t\t}\n\t\tconst edge = {\n\t\t\tid,\n\t\t\tfrom: this.nodesMap.get(fromNode),\n\t\t\tto: this.nodesMap.get(toNode),\n\t\t\tlabel,\n\t\t\tvertices: null as EdgeVertex[],\n\t\t\tstyle: {...defaultEdgeStyle, ...style},\n\t\t\tinitVertex,\n\t\t\tuserDeletedVertices: false\n\t\t}\n\t\tthis.edges.push(edge)\n\t\tif (vertices) {\n\t\t\tedge.vertices = vertices.map(p => edge.initVertex(p))\n\t\t}\n\t}\n\n\taddGroup(id: string, name: string, nodesOrGroups: string[], style: NodeStyle) {\n\t\tif (this.groupsMap.has(id)) {\n\t\t\tconsole.error(`Group exists: ${id} ${name}`)\n\t\t\treturn\n\t\t}\n\t\tconst group: Group = {\n\t\t\tid, name, x: null, y: null, width: null, height: null,\n\t\t\tnodes: nodesOrGroups.map(k => {\n\t\t\t\tconst n = this.nodesMap.get(k) || this.groupsMap.get(k)\n\t\t\t\tif (!n) console.error(`Node or group ${k} not found for group ${id} \"${name}\"`)\n\t\t\t\treturn n\n\t\t\t}).filter(Boolean),\n\t\t\tstyle\n\t\t}\n\t\tthis.groupsMap.set(id, group)\n\t}\n\n\t// private rebuildNode(node: Node) {\n\t// \tconst p = node.ref.parentElement;\n\t// \tp.removeChild(node.ref)\n\t// \tnode.ref = buildNode(node, this)\n\t// \tp.appendChild(node.ref)\n\t// \tthis.redrawEdges(node)\n\t// \tthis.redrawGroups(node)\n\t// }\n\n\tsetNodeSelected(node: Node, selected: boolean) {\n\t\tnode.selected = selected\n\t\tselected ?\n\t\t\tnode.ref.classList.add('selected') :\n\t\t\tnode.ref.classList.remove('selected')\n\t\tthis.updateEdgesSel()\n\t}\n\n\tprivate updateEdgesSel() {\n\t\tthis.edges.forEach(e => {\n\t\t\tif (e.to.selected || e.from.selected) {\n\t\t\t\te.ref.classList.add('selected')\n\t\t\t} else {\n\t\t\t\te.ref.classList.remove('selected')\n\t\t\t}\n\t\t})\n\t}\n\n\t/** clearResolvedLayout returns drawing to manual mode after any user edit. */\n\tprivate clearResolvedLayout() {\n\t\tthis.validatedLayout = undefined\n\t\tthis.edges.forEach(edge => {\n\t\t\tedge.layoutSections = undefined\n\t\t\tedge.layoutLabelBounds = undefined\n\t\t})\n\t\tthis.groupsMap.forEach(group => {\n\t\t\tgroup.layoutBounds = undefined\n\t\t\tgroup.layoutTitleBounds = undefined\n\t\t})\n\t}\n\n\tmoveNode(n: Node, x: number, y: number, disableSnap: boolean = false, skipUndo: boolean = false) {\n\t\tif (!n) return\n\t\t\n\t\t// Apply snap-to-grid if enabled and not explicitly disabled\n\t\tif (this._snapToGrid && !disableSnap) {\n\t\t\tconst snapped = this.snapToGrid(x, y);\n\t\t\tx = snapped.x;\n\t\t\ty = snapped.y;\n\t\t}\n\t\t\n\t\tif (n.x == x && n.y == y) return\n\t\t\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.beforeChange()\n\t\t}\n\t\tthis.clearResolvedLayout()\n\t\tn.x = x;\n\t\tn.y = y;\n\t\tsetPosition(n.ref, x, y)\n\t\tthis.redrawEdges(n);\n\t\tthis.redrawGroups(n)\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.change()\n\t\t}\n\t}\n\n\tmoveEdgeVertex(v: EdgeVertex, x: number, y: number, disableSnap: boolean = false, skipUndo: boolean = false) {\n\t\t\n\t\tif (this._snapToGrid && !disableSnap) {\n\t\t\tconst snapped = this.snapToGrid(x, y);\n\t\t\tx = snapped.x;\n\t\t\ty = snapped.y;\n\t\t}\n\t\t// Use exact coordinates (no rounding needed with modern grid system)\n\t\t\n\t\tif (v.x == x && v.y == y) return\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.beforeChange()\n\t\t}\n\t\tthis.clearResolvedLayout()\n\t\tv.x = x;\n\t\tv.y = y;\n\t\tthis.redrawEdge(v.edge)\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.change()\n\t\t}\n\t}\n\n\tmoveSelected(dx: number, dy: number, disableSnap: boolean = false) {\n\t\tthis.nodes().forEach(n => n.selected && this.moveNode(n, n.x + dx, n.y + dy, disableSnap, false))\n\t\tthis.edgeVertices.forEach(v => v.selected && this.moveEdgeVertex(v, v.x + dx, v.y + dy, disableSnap, false))\n\t}\n\n\tinsertEdgeVertex(edge: Edge, p: Point, pos: number, isLabel: boolean) {\n\t\tthis._undo.beforeChange()\n\t\tthis.clearResolvedLayout()\n\t\tconst v = edge.initVertex(p)\n\t\tv.selected = true\n\t\tif (isLabel) { // when shift down, make it label position\n\t\t\tedge.vertices.forEach(v => v.label = false)\n\t\t\tv.label = true\n\t\t}\n\t\tedge.vertices.splice(pos - 1, 0, v)\n\t\tthis.redrawEdge(edge)\n\t\tthis._undo.change()\n\t}\n\n\tdeleteEdgeVertex(v: EdgeVertex) {\n\t\tthis._undo.beforeChange()\n\t\tthis.clearResolvedLayout()\n\t\t\n\t\tconst index = v.edge.vertices.indexOf(v)\n\t\tif (index >= 0) {\n\t\t\tv.edge.vertices.splice(index, 1)\n\t\t\tthis.edgeVertices.delete(v.id)\n\t\t\t\n\t\t\t// Mark that user explicitly deleted vertices from this edge\n\t\t\tv.edge.userDeletedVertices = true\n\t\t}\n\t\t\n\t\tthis.redrawEdge(v.edge)\n\t\tthis._undo.change()\n\t}\n\n\tchanged() {\n\t\treturn this._undo.changed()\n\t}\n\n\tundo() {\n\t\tthis._undo.undo()\n\t}\n\n\tredo() {\n\t\tthis._undo.redo()\n\t}\n\n\t// moves the entire graph to be aligned top-left of the drawing area\n\t// used to bring back to visible the nodes that end up at negative coordinates\n\talignTopLeft() {\n\t\tconst contentBounds = this.calculateContentBounds()\n\t\tconst padding = 100 // Reasonable padding for viewport\n\t\t\n\t\tconst offsetX = -contentBounds.x + padding\n\t\tconst offsetY = -contentBounds.y + padding\n\t\t\n\t\t// Set flag to prevent React useEffect from calling fitToView during this operation\n\t\tthis._skipAutoFit = true\n\t\t\n\t\tthis._undo.beforeChange()\n\t\t\n\t\tthis.nodesMap.forEach(node => {\n\t\t\tthis.moveNode(node, node.x + offsetX, node.y + offsetY, true, true) // Disable snap and undo during reset\n\t\t})\n\t\t\n\t\tthis.edgeVertices.forEach(vertex => {\n\t\t\tthis.moveEdgeVertex(vertex, vertex.x + offsetX, vertex.y + offsetY, true, true) // Disable snap and undo during reset\n\t\t})\n\t\t\n\t\tthis._undo.change()\n\t\t\n\t\t// DON'T clear view state here - let resetPanTransform handle it to avoid React useEffect recursion\n\t}\n\t\n\t// Reset pan transform to (0,0) while preserving zoom\n\tresetPanTransform() {\n\t\tconst currentZoom = getZoom(this)\n\t\tconst zoomGroup = this.svg.querySelector('g.zoom') as SVGGElement\n\t\tif (zoomGroup) {\n\t\t\tzoomGroup.setAttribute('transform', `scale(${currentZoom}) translate(0, 0)`)\n\t\t\tupdatePanningOptimized(this)\n\t\t}\n\t\t\n\t\t// Clear view state so this reset is not overridden\n\t\tclearViewState(this)\n\t\t\n\t\t// Reset the skip auto fit flag after reset is complete\n\t\tthis._skipAutoFit = false\n\t}\n\t\n\t// Check if auto-fit should be skipped (used by React useEffect)\n\tshouldSkipAutoFit(): boolean {\n\t\treturn this._skipAutoFit\n\t}\n\n\t// Reset view to default state: 100% zoom, centered at origin\n\tresetView() {\n\t\tconst zoomGroup = this.svg.querySelector('g.zoom') as SVGGElement\n\t\tif (zoomGroup) {\n\t\t\t// Reset to 100% zoom, centered at origin\n\t\t\tzoomGroup.setAttribute('transform', 'scale(1) translate(0, 0)')\n\t\t\tupdatePanning(this)\n\t\t}\n\t\t\n\t\t// Clear any saved view state so this reset position is not overridden\n\t\tclearViewState(this)\n\t}\n\n\t//redraw connected edges\n\tprivate redrawEdges(n: Node) {\n\t\tthis.edges.forEach(e => (n == e.from || n == e.to) && this.redrawEdge(e))\n\t\tthis.updateEdgesSel()\n\t}\n\n\tredrawEdge(e: Edge) {\n\t\tconst p = e.ref.parentElement;\n\t\tp.removeChild(e.ref)\n\t\te.ref = buildEdge(e, this)\n\t\tp.append(e.ref)\n\t}\n\n\tprivate redrawGroups(node: Node) {\n\t\tthis.groupsMap.forEach(group => {\n\t\t\t//if (group.nodes.indexOf(node) == -1) return\n\t\t\tconst p = group.ref.parentElement\n\t\t\tp.removeChild(group.ref)\n\t\t\tbuildGroup(group)\n\t\t\tp.append(group.ref)\n\t\t})\n\t}\n\n\texportSVG() {\n\t\tif (!this.validatedLayout) {\n\t\t\tthis.validatedLayout = validateCurrentLayout(this)\n\t\t}\n\t\t// Get the original SVG\n\t\tconst originalSvg = this.svg\n\t\tconst elastic = originalSvg.querySelector('rect.elastic')\n\t\t\n\t\t// Clone the SVG for export (completely separate from the live one)\n\t\tconst exportSvg = originalSvg.cloneNode(true) as SVGSVGElement\n\t\t// Standalone files keep the ids saved files have always used: the root id\n\t\t// \"graph\", written before the other root attributes as in earlier files,\n\t\t// and this graph's own ids without the live idPrefix.\n\t\tconst rootAttributes = Array.from(exportSvg.attributes)\n\t\trootAttributes.forEach(attr => exportSvg.removeAttributeNode(attr))\n\t\texportSvg.setAttribute('id', 'graph')\n\t\trootAttributes.forEach(attr => exportSvg.setAttributeNode(attr))\n\t\tthis.removeIdPrefix(exportSvg)\n\n\t\t// Standalone SVGs navigate to sibling view files instead of editor routes.\n\t\texportSvg.querySelectorAll('a.nodeLink[data-export-href]').forEach(link => {\n\t\t\tlink.setAttribute('href', link.getAttribute('data-export-href') || '')\n\t\t\tlink.removeAttribute('data-export-href')\n\t\t})\n\t\t\n\t\t// Remove elastic element from export\n\t\tconst exportElastic = exportSvg.querySelector('rect.elastic')\n\t\tif (exportElastic) {\n\t\t\texportElastic.remove()\n\t\t}\n\t\t\n\t\t// Export the exact bounds that passed geometry validation. Recomputing\n\t\t// them here can omit routed relationship labels from the SVG canvas.\n\t\tconst contentBounds = this.validatedLayout.bounds\n\t\t\n\t\t// Add padding around content\n\t\tconst padding = 50\n\t\t\n\t\t// Calculate final export dimensions (always positive)\n\t\tconst exportWidth = contentBounds.width + (padding * 2)\n\t\tconst exportHeight = contentBounds.height + (padding * 2)\n\t\t\n\t\t// Calculate offset to move content to start at (padding, padding) within the export area\n\t\tconst offsetX = -contentBounds.x + padding\n\t\tconst offsetY = -contentBounds.y + padding\n\t\t\n\t\t// Apply export positioning to the cloned SVG elements\n\t\tconst exportZoomGroup = exportSvg.querySelector('g.zoom') as SVGGElement\n\t\tif (exportZoomGroup) {\n\t\t\t// Reset zoom to 1 and apply offset transform to position content properly\n\t\t\texportZoomGroup.setAttribute('transform', `scale(1) translate(${offsetX}, ${offsetY})`)\n\t\t}\n\t\t\n\t\t// Set proper viewBox and dimensions for export - viewBox always starts at (0,0)\n\t\texportSvg.setAttribute('viewBox', `0 0 ${exportWidth} ${exportHeight}`)\n\t\texportSvg.setAttribute('width', String(exportWidth))\n\t\texportSvg.setAttribute('height', String(exportHeight))\n\t\t\n\t\t// Add required SVG namespace for browser compatibility\n\t\texportSvg.setAttribute('xmlns', 'http://www.w3.org/2000/svg')\n\t\t\n\t\t// Convert inline styles to CSS custom properties for theming support\n\t\tthis.convertStylesToCustomProperties(exportSvg)\n\t\t\n\t\t// Inject metadata with current layout\n\t\tconst script = document.createElement('script')\n\t\tscript.setAttribute('type', 'application/json')\n\t\tthis.metadata.layout = this.exportLayout()\n\t\tscript.append('')\n\t\texportSvg.insertBefore(script, exportSvg.firstChild)\n\t\t\n\t\t// Get the export SVG as string\n\t\tconst src = exportSvg.outerHTML\n\t\t\n\t\t// No restoration needed since we never touched the original SVG!\n\t\treturn src\n\t}\n\n\t/**\n\t * removeIdPrefix rewrites the export copy's ids, url(#…) references, and #…\n\t * links that name this graph's own elements back to their saved names, for\n\t * example \"g2-arrow\" to \"arrow\" and \"url(#g2-arrow)\" to \"url(#arrow)\". Values\n\t * that do not start with this graph's idPrefix, such as node links and image\n\t * URLs, stay unchanged.\n\t */\n\tprivate removeIdPrefix(svg: SVGSVGElement) {\n\t\tconst prefix = this.idPrefix\n\t\tsvg.querySelectorAll('*').forEach(el => {\n\t\t\tfor (const attr of Array.from(el.attributes)) {\n\t\t\t\tif (attr.name === 'id' && attr.value.startsWith(prefix)) {\n\t\t\t\t\tattr.value = attr.value.slice(prefix.length)\n\t\t\t\t} else if (attr.value.includes(`url(#${prefix}`)) {\n\t\t\t\t\tattr.value = attr.value.split(`url(#${prefix}`).join('url(#')\n\t\t\t\t} else if (attr.localName === 'href' && attr.value.startsWith(`#${prefix}`)) {\n\t\t\t\t\tattr.value = '#' + attr.value.slice(prefix.length + 1)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\t// Convert inline fill/stroke attributes to CSS custom properties with fallbacks.\n\t// This enables theming: container pages can override colors via CSS variables.\n\tprivate convertStylesToCustomProperties(svg: SVGSVGElement) {\n\t\tif (this.colorToVarMap.size === 0) return\n\n\t\t// Process all elements with fill attribute\n\t\tsvg.querySelectorAll('[fill]').forEach(el => {\n\t\t\tconst fill = el.getAttribute('fill')\n\t\t\tif (fill && this.colorToVarMap.has(fill)) {\n\t\t\t\tel.setAttribute('fill', `var(${this.colorToVarMap.get(fill)}, ${fill})`)\n\t\t\t}\n\t\t})\n\n\t\t// Process all elements with stroke attribute\n\t\tsvg.querySelectorAll('[stroke]').forEach(el => {\n\t\t\tconst stroke = el.getAttribute('stroke')\n\t\t\tif (stroke && this.colorToVarMap.has(stroke)) {\n\t\t\t\tel.setAttribute('stroke', `var(${this.colorToVarMap.get(stroke)}, ${stroke})`)\n\t\t\t}\n\t\t})\n\t}\n\n\t// Calculate the actual bounds of all content including nodes, edges, and groups\n\tcalculateContentBounds(): BBox {\n\t\tlet minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity\n\t\t\n\t\t// Process nodes (including their actual dimensions)\n\t\tthis.nodes().forEach(node => {\n\t\t\tconst left = node.x - node.width / 2\n\t\t\tconst right = node.x + node.width / 2\n\t\t\tconst top = node.y - node.height / 2\n\t\t\tconst bottom = node.y + node.height / 2\n\t\t\t\n\t\t\tminX = Math.min(minX, left)\n\t\t\tmaxX = Math.max(maxX, right)\n\t\t\tminY = Math.min(minY, top)\n\t\t\tmaxY = Math.max(maxY, bottom)\n\t\t})\n\t\t\n\t\t// Process edge vertices (much faster than complex label calculations)\n\t\tthis.edgeVertices.forEach(vertex => {\n\t\t\tminX = Math.min(minX, vertex.x - 5)\n\t\t\tmaxX = Math.max(maxX, vertex.x + 5)\n\t\t\tminY = Math.min(minY, vertex.y - 5)\n\t\t\tmaxY = Math.max(maxY, vertex.y + 5)\n\t\t})\n\t\t\n\t\t// Process groups\n\t\tthis.groupsMap.forEach(group => {\n\t\t\tconst left = group.x - group.width / 2\n\t\t\tconst right = group.x + group.width / 2\n\t\t\tconst top = group.y - group.height / 2\n\t\t\tconst bottom = group.y + group.height / 2\n\t\t\t\n\t\t\tminX = Math.min(minX, left)\n\t\t\tmaxX = Math.max(maxX, right)\n\t\t\tminY = Math.min(minY, top)\n\t\t\tmaxY = Math.max(maxY, bottom)\n\t\t})\n\t\t\n\t\t// Process edges (simplified - just endpoints and vertices, skip complex label calculations)\n\t\tthis.edges.forEach(edge => {\n\t\t\t// Edge endpoints\n\t\t\tminX = Math.min(minX, edge.from.x - 10, edge.to.x - 10)\n\t\t\tmaxX = Math.max(maxX, edge.from.x + 10, edge.to.x + 10)\n\t\t\tminY = Math.min(minY, edge.from.y - 10, edge.to.y - 10)\n\t\t\tmaxY = Math.max(maxY, edge.from.y + 10, edge.to.y + 10)\n\t\t\t\n\t\t\t// Edge vertices (if any)\n\t\t\tif (edge.vertices) {\n\t\t\t\tedge.vertices.forEach(vertex => {\n\t\t\t\t\tminX = Math.min(minX, vertex.x - 10)\n\t\t\t\t\tmaxX = Math.max(maxX, vertex.x + 10)\n\t\t\t\t\tminY = Math.min(minY, vertex.y - 10)\n\t\t\t\t\tmaxY = Math.max(maxY, vertex.y + 10)\n\t\t\t\t})\n\t\t\t}\n\t\t\t\n\t\t\t// Simplified label bounds (avoid expensive path calculations)\n\t\t\tif (edge.label && edge.label.trim()) {\n\t\t\t\t// Just use approximate center between from and to nodes\n\t\t\t\tconst centerX = (edge.from.x + edge.to.x) / 2\n\t\t\t\tconst centerY = (edge.from.y + edge.to.y) / 2\n\t\t\t\tconst approxLabelSize = edge.label.length * 10 + 50 // Rough estimate\n\t\t\t\t\n\t\t\t\tminX = Math.min(minX, centerX - approxLabelSize)\n\t\t\t\tmaxX = Math.max(maxX, centerX + approxLabelSize)\n\t\t\t\tminY = Math.min(minY, centerY - 25)\n\t\t\t\tmaxY = Math.max(maxY, centerY + 25)\n\t\t\t}\n\t\t})\n\t\t\n\t\t// Handle empty graph\n\t\tif (minX === Infinity) {\n\t\t\treturn { x: 0, y: 0, width: 100, height: 100 }\n\t\t}\n\t\t\n\t\treturn {\n\t\t\tx: minX,\n\t\t\ty: minY,\n\t\t\twidth: maxX - minX,\n\t\t\theight: maxY - minY\n\t\t}\n\t}\n\n\n\n\t/**\n\t * @param full when true, the edges without vertices are saved too, used for undo buffer\n\t * for saving, full is false\n\t */\n\texportLayout(full = false) {\n\t\tconst ret: Layout = {}\n\t\tthis.nodes().forEach(n => ret[n.id] = {x: n.x, y: n.y})\n\t\tthis.edges.forEach(e => {\n\t\t\tif (!e.vertices) return\n\t\t\t// Save all vertices (both user and auto-generated), preserving their properties\n\t\t\tconst lst = e.vertices.map(v => ({\n\t\t\t\tx: v.x, \n\t\t\t\ty: v.y, \n\t\t\t\tlabel: v.label,\n\t\t\t\tauto: v.auto // Preserve auto flag so we know which are ELK-generated\n\t\t\t}));\n\t\t\tif (lst.length || full) {\n\t\t\t\tret[`e-${e.id}`] = lst\n\t\t\t}\n\t\t\t// Also save the userDeletedVertices flag as metadata\n\t\t\tif (e.userDeletedVertices) {\n\t\t\t\tret[`e-${e.id}-deleted`] = true\n\t\t\t}\n\t\t})\n\t\treturn ret\n\t}\n\n\tsetSaved() {\n\t\tthis._undo.setSaved()\n\t}\n\n\timportLayout(layout: Layout, rerender = false) {\n\t\tthis.clearResolvedLayout()\n\t\tfor (const [k, v] of Object.entries(layout)) {\n\t\t\tconst n = this.nodesMap.get(k)\n\t\t\tif (n) {\n\t\t\t\tconst point = requiredSavedPoint(k, v)\n\t\t\t\tn.x = point.x\n\t\t\t\tn.y = point.y\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (k.endsWith('-deleted')) {\n\t\t\t\tconst edgeId = k.slice(2, -8); // Remove 'e-' prefix and '-deleted' suffix\n\t\t\t\tconst edge = this.edges.find(candidate => candidate.id === edgeId)\n\t\t\t\tif (!edge || v !== true) {\n\t\t\t\t\tthrow new Error(`invalid deleted-edge layout entry ${k}`)\n\t\t\t\t}\n\t\t\t\tedge.userDeletedVertices = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (k.startsWith('e-')) {\n\t\t\t\tconst edge = this.edges.find(candidate => candidate.id === k.slice(2))\n\t\t\t\tif (!edge || !Array.isArray(v)) {\n\t\t\t\t\tthrow new Error(`invalid edge layout entry ${k}`)\n\t\t\t\t}\n\t\t\t\tfor (const vertex of edge.vertices ?? []) {\n\t\t\t\t\tthis.edgeVertices.delete(vertex.id)\n\t\t\t\t}\n\t\t\t\tedge.vertices = v.map((saved, index) => {\n\t\t\t\t\tconst point = requiredSavedPoint(`${k}[${index}]`, saved)\n\t\t\t\t\tconst vertex = edge.initVertex(point)\n\t\t\t\t\tvertex.label = saved.label\n\t\t\t\t\tvertex.auto = saved.auto\n\t\t\t\t\treturn vertex\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tthrow new Error(`layout contains unknown element ${k}`)\n\t\t}\n\t\tfor (const node of this.nodes()) {\n\t\t\tif (!(node.id in layout)) {\n\t\t\t\tthrow new Error(`layout is missing node ${node.id}`)\n\t\t\t}\n\t\t}\n\t\tif (rerender) {\n\t\t\tthis.nodes().forEach(n => setPosition(n.ref, n.x, n.y))\n\t\t\tthis.edges.forEach(e => this.redrawEdge(e))\n\t\t\tthis.updateEdgesSel()\n\t\t\tthis.redrawGroups(null)\n\t\t}\n\t}\n\n\tasync autoLayout(options?: LayoutOptions) {\n\t\tconst auto = await autoLayout(this, options)\n\t\tthis._undo.beforeChange()\n\n\t\tfor (const placedNode of auto.nodes) {\n\t\t\tconst node = this.nodesMap.get(placedNode.id)\n\t\t\tif (!node) {\n\t\t\t\tthrow new Error(`layout contains unknown node ${placedNode.id}`)\n\t\t\t}\n\t\t\tnode.x = placedNode.x\n\t\t\tnode.y = placedNode.y\n\t\t\tsetPosition(node.ref, node.x, node.y)\n\t\t}\n\n\t\tfor (const placedGroup of auto.groups) {\n\t\t\tconst group = this.groupsMap.get(placedGroup.id)\n\t\t\tif (!group) {\n\t\t\t\tthrow new Error(`layout contains unknown group ${placedGroup.id}`)\n\t\t\t}\n\t\t\tgroup.layoutBounds = placedGroup.bounds\n\t\t\tgroup.layoutTitleBounds = placedGroup.titleBounds\n\t\t\tgroup.x = placedGroup.bounds.x + placedGroup.bounds.width / 2\n\t\t\tgroup.y = placedGroup.bounds.y + placedGroup.bounds.height / 2\n\t\t\tgroup.width = placedGroup.bounds.width\n\t\t\tgroup.height = placedGroup.bounds.height\n\t\t}\n\n\t\tfor (const placedEdge of auto.edges) {\n\t\t\tconst edge = this.edges.find(candidate => candidate.id === placedEdge.id)\n\t\t\tif (!edge) {\n\t\t\t\tthrow new Error(`layout contains unknown edge ${placedEdge.id}`)\n\t\t\t}\n\t\t\tfor (const vertex of edge.vertices ?? []) {\n\t\t\t\tthis.edgeVertices.delete(vertex.id)\n\t\t\t}\n\t\t\tedge.layoutSections = placedEdge.sections\n\t\t\tedge.layoutLabelBounds = placedEdge.labelBounds\n\t\t\tedge.vertices = interiorRoutePoints(placedEdge.sections).map(point => {\n\t\t\t\tconst vertex = edge.initVertex(point)\n\t\t\t\tvertex.auto = true\n\t\t\t\treturn vertex\n\t\t\t})\n\t\t\tedge.userDeletedVertices = false\n\t\t}\n\n\t\tthis.validatedLayout = auto.validated\n\t\tthis.edges.forEach(edge => this.redrawEdge(edge))\n\t\tthis.redrawGroups(null)\n\t\tthis.fitToView()\n\t\tthis._undo.change()\n\t}\n\n\talignSelectionV() {\n\t\tconst lst: Point[] = this.nodes().filter(n => n.selected)\n\t\tlst.push(...Array.from(this.edgeVertices.values()).filter(v => v.selected))\n\t\tlet minY = Math.min(...lst.map(p => p.y))\n\t\tthis.nodesMap.forEach(n => n.selected && this.moveNode(n, n.x, minY, false, false))\n\t\tthis.edgeVertices.forEach(v => v.selected && this.moveEdgeVertex(v, v.x, minY, false, false))\n\t}\n\n\talignSelectionH() {\n\t\tconst lst: Point[] = this.nodes().filter(n => n.selected)\n\t\tlst.push(...Array.from(this.edgeVertices.values()).filter(v => v.selected))\n\t\tlet minX = Math.min(...lst.map(p => p.x))\n\t\tthis.nodesMap.forEach(n => n.selected && this.moveNode(n, minX, n.y, false, false))\n\t\tthis.edgeVertices.forEach(v => v.selected && this.moveEdgeVertex(v, minX, v.y, false, false))\n\t}\n\n\tdistributeSelectionH() {\n\t\tconst selectedNodes = this.nodes().filter(n => n.selected)\n\t\tconst selectedVertices = Array.from(this.edgeVertices.values()).filter(v => v.selected)\n\t\t\n\t\tif (selectedNodes.length + selectedVertices.length < 3) return // Need at least 3 elements to distribute\n\t\t\n\t\tthis._undo.beforeChange()\n\t\t\n\t\t// Combine and sort by X coordinate\n\t\tconst allElements = [...selectedNodes, ...selectedVertices]\n\t\tallElements.sort((a, b) => a.x - b.x)\n\t\t\n\t\tconst minX = allElements[0].x\n\t\tconst maxX = allElements[allElements.length - 1].x\n\t\tconst spacing = (maxX - minX) / (allElements.length - 1)\n\t\t\n\t\t// Distribute elements evenly between leftmost and rightmost\n\t\tallElements.forEach((element, index) => {\n\t\t\tconst newX = minX + (index * spacing)\n\t\t\tif ('title' in element) {\n\t\t\t\t// It's a Node\n\t\t\t\tthis.moveNode(element as Node, newX, element.y, false, true)\n\t\t\t} else {\n\t\t\t\t// It's an EdgeVertex\n\t\t\t\tthis.moveEdgeVertex(element as EdgeVertex, newX, element.y, false, true)\n\t\t\t}\n\t\t})\n\t\t\n\t\tthis._undo.change()\n\t}\n\n\tdistributeSelectionV() {\n\t\tconst selectedNodes = this.nodes().filter(n => n.selected)\n\t\tconst selectedVertices = Array.from(this.edgeVertices.values()).filter(v => v.selected)\n\t\t\n\t\tif (selectedNodes.length + selectedVertices.length < 3) return // Need at least 3 elements to distribute\n\t\t\n\t\tthis._undo.beforeChange()\n\t\t\n\t\t// Combine and sort by Y coordinate\n\t\tconst allElements = [...selectedNodes, ...selectedVertices]\n\t\tallElements.sort((a, b) => a.y - b.y)\n\t\t\n\t\tconst minY = allElements[0].y\n\t\tconst maxY = allElements[allElements.length - 1].y\n\t\tconst spacing = (maxY - minY) / (allElements.length - 1)\n\t\t\n\t\t// Distribute elements evenly between topmost and bottommost\n\t\tallElements.forEach((element, index) => {\n\t\t\tconst newY = minY + (index * spacing)\n\t\t\tif ('title' in element) {\n\t\t\t\t// It's a Node\n\t\t\t\tthis.moveNode(element as Node, element.x, newY, false, true)\n\t\t\t} else {\n\t\t\t\t// It's an EdgeVertex\n\t\t\t\tthis.moveEdgeVertex(element as EdgeVertex, element.x, newY, false, true)\n\t\t\t}\n\t\t})\n\t\t\n\t\tthis._undo.change()\n\t}\n\n\t// Set edge selection state\n\tsetEdgeSelected(edge: Edge, selected: boolean) {\n\t\t// Mark the edge as selected by selecting its connected nodes\n\t\tif (selected) {\n\t\t\tthis.setNodeSelected(edge.from, true)\n\t\t\tthis.setNodeSelected(edge.to, true)\n\t\t}\n\t\t// Update visual selection\n\t\tthis.updateEdgesSel()\n\t}\n\n\t// Fit the entire graph to the current viewport\n\tfitToView() {\n\t\tconst contentBounds = this.calculateContentBounds()\n\t\t\n\t\t// Handle edge case where there's no content\n\t\tif (contentBounds.width === 0 || contentBounds.height === 0) {\n\t\t\treturn\n\t\t}\n\t\t\n\t\t// Get viewport dimensions\n\t\tconst viewportWidth = this.svg.parentElement?.clientWidth || 800\n\t\tconst viewportHeight = this.svg.parentElement?.clientHeight || 600\n\t\t\n\t\t// Add padding around content\n\t\tconst padding = 40\n\t\t\n\t\t// Calculate zoom to fit content with padding\n\t\tconst zoomX = (viewportWidth - padding * 2) / contentBounds.width\n\t\tconst zoomY = (viewportHeight - padding * 2) / contentBounds.height\n\t\tconst optimalZoom = Math.min(zoomX, zoomY)\n\t\t\n\t\t// Clamp zoom between reasonable bounds\n\t\tconst finalZoom = Math.max(Math.min(optimalZoom, 2), 0.1)\n\t\t\n\t\t// Calculate content center in drawing coordinates\n\t\tconst contentCenterX = contentBounds.x + contentBounds.width / 2\n\t\tconst contentCenterY = contentBounds.y + contentBounds.height / 2\n\t\t\n\t\t// Calculate viewport center in screen coordinates\n\t\tconst viewportCenterX = viewportWidth / 2\n\t\tconst viewportCenterY = viewportHeight / 2\n\t\t\n\t\t// Calculate translation needed to center content in viewport\n\t\t// With translate(x,y) scale(zoom), translation is in screen coordinates\n\t\tconst translateX = viewportCenterX - (contentCenterX * finalZoom)\n\t\tconst translateY = viewportCenterY - (contentCenterY * finalZoom)\n\t\t\n\t\t// Apply zoom and translation transform\n\t\tconst zoomGroup = this.svg.querySelector('g.zoom') as SVGGElement\n\t\tif (zoomGroup) {\n\t\t\tzoomGroup.setAttribute('transform', `translate(${translateX}, ${translateY}) scale(${finalZoom})`)\n\t\t}\n\t\t\n\t\t// Update panning\n\t\tupdatePanning(this)\n\t\t\n\t\t// Save view state so this fit position is preserved after reload\n\t\tsaveViewState(this)\n\t}\n\n\t// Save current layout state for restoration\n\tprivate saveLayoutState(): Layout {\n\t\treturn this.exportLayout(true) // Include all vertices for complete state\n\t}\n\n\t// Restore layout state\n\tprivate restoreLayoutState(state: Layout) {\n\t\tthis.importLayout(state, true) // Rerender after restoring\n\t}\n\n\t// Grid functionality\n\tisGridVisible(): boolean {\n\t\treturn this._gridVisible;\n\t}\n\n\tisSnapToGrid(): boolean {\n\t\treturn this._snapToGrid;\n\t}\n\n\tgetGridSize(): number {\n\t\treturn this._gridSize;\n\t}\n\n\ttoggleGrid() {\n\t\tthis._gridVisible = !this._gridVisible;\n\t\tthis.updateGridDisplay();\n\t\t// Force toolbar update by dispatching a custom event\n\t\twindow.dispatchEvent(new CustomEvent('gridStateChanged'));\n\t}\n\n\ttoggleSnapToGrid() {\n\t\tthis._snapToGrid = !this._snapToGrid;\n\t\t// Force toolbar update by dispatching a custom event\n\t\twindow.dispatchEvent(new CustomEvent('gridStateChanged'));\n\t}\n\n\tsnapAllToGrid() {\n\t\tif (!this._snapToGrid) return;\n\t\t\n\t\tthis._undo.beforeChange();\n\t\tthis.nodes().forEach(node => {\n\t\t\tconst snappedX = Math.round(node.x / this._gridSize) * this._gridSize;\n\t\t\tconst snappedY = Math.round(node.y / this._gridSize) * this._gridSize;\n\t\t\tthis.moveNode(node, snappedX, snappedY, false, true);\n\t\t});\n\t\tthis._undo.change();\n\t}\n\n\t// Helper method to snap a point to grid\n\tprivate snapToGrid(x: number, y: number): { x: number, y: number } {\n\t\treturn {\n\t\t\tx: Math.round(x / this._gridSize) * this._gridSize,\n\t\t\ty: Math.round(y / this._gridSize) * this._gridSize\n\t\t};\n\t}\n\n\tupdateGridDisplay() {\n\t\tconst svg = this.svg;\n\n\t\t// Remove existing grid pattern and background\n\t\tconst existingGrid = svg.querySelector(`#${this.idPrefix}grid-pattern`);\n\t\tif (existingGrid) {\n\t\t\texistingGrid.remove();\n\t\t}\n\n\t\tconst existingGridRect = svg.querySelector(`#${this.idPrefix}grid-background`);\n\t\tif (existingGridRect) {\n\t\t\texistingGridRect.remove();\n\t\t}\n\n\t\tif (!this._gridVisible) return;\n\n\t\t// Create grid pattern in defs\n\t\tlet defs = svg.querySelector('defs');\n\t\tif (!defs) {\n\t\t\tdefs = document.createElementNS('http://www.w3.org/2000/svg', 'defs');\n\t\t\tsvg.insertBefore(defs, svg.firstChild);\n\t\t}\n\n\t\tconst pattern = document.createElementNS('http://www.w3.org/2000/svg', 'pattern');\n\t\tpattern.id = `${this.idPrefix}grid-pattern`;\n\t\tpattern.setAttribute('width', this._gridSize.toString());\n\t\tpattern.setAttribute('height', this._gridSize.toString());\n\t\tpattern.setAttribute('patternUnits', 'userSpaceOnUse');\n\n\t\tconst path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n\t\tpath.setAttribute('d', `M ${this._gridSize} 0 L 0 0 0 ${this._gridSize}`);\n\t\tpath.setAttribute('fill', 'none');\n\t\tpath.setAttribute('stroke', '#d0d0d0');\n\t\tpath.setAttribute('stroke-width', '1');\n\t\tpath.setAttribute('opacity', '0.8');\n\n\t\tpattern.appendChild(path);\n\t\tdefs.appendChild(pattern);\n\n\t\t// Create grid background rectangle\n\t\tconst rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\n\t\trect.id = `${this.idPrefix}grid-background`;\n\t\trect.setAttribute('x', '-10000');\n\t\trect.setAttribute('y', '-10000');\n\t\trect.setAttribute('width', '20000');\n\t\trect.setAttribute('height', '20000');\n\t\trect.setAttribute('fill', `url(#${this.idPrefix}grid-pattern)`);\n\t\trect.setAttribute('pointer-events', 'none');\n\n\t\t// Insert grid as first child of zoom group so it transforms with content\n\t\tconst zoomGroup = svg.querySelector('g.zoom');\n\t\tif (zoomGroup) {\n\t\t\tzoomGroup.insertBefore(rect, zoomGroup.firstChild);\n\t\t}\n\t}\n}\n\n/** interiorRoutePoints returns only the editable points between edge endpoints. */\nfunction interiorRoutePoints(sections: Point[][]): Point[] {\n\tconst route: Point[] = []\n\tfor (const section of sections) {\n\t\tfor (const point of section) {\n\t\t\tconst previous = route[route.length - 1]\n\t\t\tif (!previous || previous.x !== point.x || previous.y !== point.y) {\n\t\t\t\troute.push(point)\n\t\t\t}\n\t\t}\n\t}\n\treturn route.slice(1, -1)\n}\n\n/** requiredSavedPoint checks coordinates when reading saved editor layout data. */\nfunction requiredSavedPoint(\n\tid: string,\n\tvalue: Point | SavedEdgePoint | SavedEdgePoint[] | boolean,\n): SavedEdgePoint {\n\tif (\n\t\ttypeof value !== 'object' ||\n\t\tArray.isArray(value) ||\n\t\t!Number.isFinite(value.x) ||\n\t\t!Number.isFinite(value.y)\n\t) {\n\t\tthrow new Error(`layout entry ${id} must contain valid x and y coordinates`)\n\t}\n\treturn value\n}\n\nfunction escapeCdata(code: string) {\n\treturn code.replace(/]]>/g, ']]]>]> void, dragMode: 'pan' | 'select') => {\n\tconst svg = data.svg\n\tsvg.setAttribute('width', '100%')\n\tsvg.setAttribute('height', '100%')\n\tdocument.body.append(svg) // make sure svg element is connected, we will measure texts sizes\n\n\tdata.selectListener = onNodeSelect\n\n\t_buildGraph(data)\n\tconst elasticEl = create.rect(300, 300, 50, 50, 0, 'elastic')\n\tsvg.append(elasticEl)\n\n\t// Initialize grid display now that the zoom group exists\n\tdata.updateGridDisplay()\n\n\t// Call addCursorInteraction with dragMode\n\taddCursorInteraction(data, dragMode)\n\n\treturn {\n\t\tsvg,\n\t\tsetZoom: (zoom: number) => setZoom(data, zoom),\n\t}\n}\n\n/** buildGraphView draws data into its own svg without editor handling and returns that svg. */\nexport const buildGraphView = (data: GraphData) => {\n\t_buildGraph(data)\n\treturn data.svg\n}\n\nconst _buildGraph = (data: GraphData) => {\n\t// Every graph owns the reusable SVG definitions referenced by its drawn\n\t// elements, including relationship arrowheads, icons, and filters.\n\tdata.svg.innerHTML = defs(data.idPrefix)\n\n\t//toplevel groups\n\tconst zoomG = create.element('g', {}, 'zoom') as SVGGElement\n\tconst nodesG = create.element('g', {}, 'nodes') as SVGGElement\n\tconst edgesG = create.element('g', {}, 'edges') as SVGGElement\n\tconst groupsG = create.element('g', {}, 'groups') as SVGGElement\n\tzoomG.append(groupsG, edgesG, nodesG)\n\n\n\tdata.nodesMap.forEach((n) => {\n\t\tbuildNode(n, data)\n\t\tnodesG.append(n.ref)\n\t})\n\n\tdata.edges.forEach(edge => {\n\t\tedge.labelBounds = undefined\n\t})\n\tdata.edges.forEach(e => {\n\t\tbuildEdge(e, data)\n\t\tedgesG.append(e.ref)\n\t})\n\n\tdata.groupsMap.forEach((group) => {\n\t\tbuildGroup(group)\n\t\tgroupsG.append(group.ref)\n\t})\n\n\tdata.svg.append(zoomG)\n}\n\n/** buildEdge draws one relationship of data, using data's idPrefix for its ids and arrowhead. */\nfunction buildEdge(edge: Edge, data: GraphData) {\n\tconst n1 = edge.from;\n\n\tconst g = create.element('g', {}, 'edge') as SVGGElement\n\tg.setAttribute('id', data.idPrefix + edge.id)\n\tg.setAttribute('data-from', edge.from.id)\n\tg.setAttribute('data-to', edge.to.id)\n\n\tconst position = (edge.style.position || 50) / 100\n\n\tconst vertices = edge.layoutSections\n\t\t? completeRoutePoints(edge.layoutSections)\n\t\t: calculateEdgeVertices(edge)\n\tconst {bg, txt} = edge.layoutLabelBounds\n\t\t? buildPlacedEdgeLabel(edge.layoutLabelBounds, edge)\n\t\t: buildEdgeLabel(calculateLabelPlacement(vertices, position, n1), edge)\n\tg.append(bg, txt)\n\n\tconst path = createEdgePath(vertices)\n\n\tconst p = create.path(path, {'marker-end': `url(#${data.idPrefix}arrow)`}, 'edge')\n\tp.setAttribute('fill', 'none')\n\tp.setAttribute('stroke', edge.style.color)\n\tp.setAttribute('stroke-width', String(edge.style.thickness))\n\tp.setAttribute('stroke-linecap', 'round')\n\tedge.style.dashed && p.setAttribute('stroke-dasharray', '8')\n\tg.append(p)\n\t\n\t// Debug visualization removed - arrow issue fixed\n\n\t// drag handlers\n\tfor (const p of edge.vertices ?? []) {\n\t\tconst v = p as EdgeVertex\n\t\tv.ref = create.element('circle', {id: data.idPrefix + v.id, cx: p.x, cy: p.y, r: 7, fill: 'none'}, 'v-dot')\n\t\tv.selected && v.ref.classList.add('selected')\n\t\tv.auto && v.ref.classList.add('auto')\n\t\tg.append(v.ref)\n\t}\n\n\tedge.ref = g\n\treturn g\n}\n\n/** completeRoutePoints joins connected layout sections without duplicate points. */\nfunction completeRoutePoints(sections: Point[][]): Point[] {\n\tconst route: Point[] = []\n\tfor (const section of sections) {\n\t\tfor (const point of section) {\n\t\t\tconst previous = route[route.length - 1]\n\t\t\tif (!previous || previous.x !== point.x || previous.y !== point.y) {\n\t\t\t\troute.push(point)\n\t\t\t}\n\t\t}\n\t}\n\treturn route\n}\n\n/** buildPlacedEdgeLabel draws one label in the box chosen by layout. */\nfunction buildPlacedEdgeLabel(bounds: BBox, edge: Edge) {\n\tconst centerX = bounds.x + bounds.width / 2\n\tconst centerY = bounds.y + bounds.height / 2\n\tconst {txt} = create.textArea(\n\t\tedge.label,\n\t\tedge.style.width,\n\t\tedge.style.fontSize,\n\t\tfalse,\n\t\tcenterX,\n\t\tbounds.y,\n\t\t'middle',\n\t)\n\tapplyStyle(txt, SVG_STYLES.edgeText)\n\ttxt.setAttribute('stroke', 'none')\n\ttxt.setAttribute('font-size', String(edge.style.fontSize))\n\ttxt.setAttribute('fill', edge.style.color)\n\ttxt.setAttribute('data-field', 'label')\n\tconst bg = create.rect(bounds.width, bounds.height, bounds.x, bounds.y)\n\tapplyStyle(bg, SVG_STYLES.edgeRect)\n\treturn {\n\t\tbg,\n\t\ttxt,\n\t}\n}\n\n/**\n * buildEdgeLabel adapts an older saved label anchor into a complete label box.\n * It uses one fixed side and lets validation reject any resulting collision.\n */\nfunction buildEdgeLabel(placement: EdgeLabelPlacement, edge: Edge) {\n\tconst labelGap = 12;\n\tconst fontSize = edge.style.fontSize\n\tlet {txt, dy, maxW} = create.textArea(edge.label, edge.style.width, fontSize, false, placement.x, placement.y, 'middle')\n\tdy -= fontSize / 2\n\tmaxW += fontSize\n\tconst centerX = placement.orientation === 'vertical'\n\t\t? placement.x + maxW / 2 + labelGap\n\t\t: placement.x\n\tconst centerY = placement.orientation === 'vertical'\n\t\t? placement.y\n\t\t: placement.y - dy / 2 - labelGap\n\tconst bounds = {\n\t\tx: centerX - maxW / 2,\n\t\ty: centerY - dy / 2,\n\t\twidth: maxW,\n\t\theight: dy,\n\t}\n\ttxt.querySelectorAll('tspan').forEach((span: SVGTSpanElement) => {\n\t\tspan.setAttribute('x', String(centerX))\n\t})\n\ttxt.setAttribute('y', String(centerY - dy / 2))\n\n\tapplyStyle(txt, SVG_STYLES.edgeText)\n\ttxt.setAttribute('stroke', 'none')\n\ttxt.setAttribute('font-size', String(edge.style.fontSize))\n\ttxt.setAttribute('fill', edge.style.color)\n\n\tconst bg = create.rect(bounds.width, bounds.height, bounds.x, bounds.y)\n\tapplyStyle(bg, SVG_STYLES.edgeRect)\n\ttxt.setAttribute('data-field', 'label')\n\tedge.labelBounds = bounds\n\treturn {bg, txt}\n}\n\n\n/** buildNode draws one element of data, using data's idPrefix for its id. */\nfunction buildNode(n: Node, data: GraphData) {\n\tconst g = create.element('g', {}, 'node') as SVGGElement\n\tg.setAttribute('id', data.idPrefix + n.id)\n\tn.selected && g.classList.add('selected')\n\tsetPosition(g, n.x, n.y)\n\tconst link = n.link\n\t\t? create.element('a', {\n\t\t\thref: n.link.href,\n\t\t\t'data-export-href': n.link.exportHref,\n\t\t\t'aria-label': `Open ${n.title}`,\n\t\t}, 'nodeLink') as SVGAElement\n\t\t: null\n\tconst content = link || g\n\tif (link) {\n\t\tg.classList.add('linked')\n\t\tg.append(link)\n\t}\n\n\t// Ensure we use the correct shape from style, defaulting to Box\n\tconst shapeType = n.style.shape || 'Box';\n\tconst shapeFn = shapes[shapeType.toLowerCase()] || shapes.box\n\tconst shape: SVGElement = shapeFn(content, n);\n\n\tshape.classList.add('nodeBorder')\n\n\t// Apply generic styles first\n\tapplyStyle(shape, SVG_STYLES.nodeBorder)\n\t// Then apply tag-specific styles to override generic ones\n\tshape.setAttribute('fill', n.style.background)\n\tshape.setAttribute('stroke', n.style.stroke)\n\tshape.setAttribute('opacity', String(n.style.opacity))\n\tsetBorderStyle(shape, n.style.border)\n\n\tconst tg = buildNodeContent(n.contentLayout, n.style.color)\n\tconst labelOffsetY = Number(content.getAttribute('label-offset-y')) || 0\n\tsetPosition(tg, 0, labelOffsetY / 2)\n\tcontent.append(tg)\n\n\t// @ts-ignore\n\tg.__data = n;\n\tn.ref = g;\n\n\treturn g\n}\n\n\nfunction buildGroup(group: Group) {\n\tif (group.nodes.length == 0) {\n\t\treturn\n\t}\n\tconst g = create.element('g', {}, 'group') as SVGGElement\n\tif (group.layoutBounds && group.layoutTitleBounds) {\n\t\tconst bounds = group.layoutBounds\n\t\tconst title = group.layoutTitleBounds\n\t\tconst rect = create.rect(bounds.width, bounds.height, bounds.x, bounds.y)\n\t\tapplyStyle(rect, SVG_STYLES.groupRect)\n\t\tgroup.style.stroke && rect.setAttribute('stroke', group.style.stroke)\n\t\tgroup.style.background && rect.setAttribute('fill', group.style.background)\n\t\tconst text = create.text(group.name, {\n\t\t\tx: title.x,\n\t\t\ty: title.y,\n\t\t\t'dominant-baseline': 'hanging',\n\t\t})\n\t\tapplyStyle(text, SVG_STYLES.groupText)\n\t\tgroup.style.color && text.setAttribute('fill', group.style.color)\n\t\tg.append(rect, text)\n\t\tgroup.ref = g\n\t\treturn\n\t}\n\n\tlet p0: Point = {x: 1e100, y: 1e100}, p1: Point = {x: 0, y: 0}\n\tgroup.nodes.forEach(n => {\n\t\t// Calculate visual bounds accounting for shapes that extend beyond center\n\t\tconst shape = (n as Node).style?.shape?.toLowerCase() || 'box'\n\t\t\n\t\tlet topExtension = n.height / 2\n\t\tlet bottomExtension = n.height / 2\n\t\t\n\t\tif (shape === 'robot') {\n\t\t\t// Robot shape extends above with antenna\n\t\t\t// Account for antenna height (h * 0.08) plus some margin\n\t\t\tconst antennaH = n.height * 0.12\n\t\t\ttopExtension = n.height / 2 + antennaH\n\t\t\tbottomExtension = n.height / 2\n\t\t} else if (shape === 'hexagon') {\n\t\t\t// Hexagon extends to ±0.866 * (width/2) vertically\n\t\t\t// For width=280, that's ±121.24px from center\n\t\t\tconst hexHeight = n.width / 2 * 0.866\n\t\t\ttopExtension = hexHeight\n\t\t\tbottomExtension = hexHeight\n\t\t}\n\t\t\n\t\tconst b = {\n\t\t\tx: n.x - n.width / 2,\n\t\t\ty: n.y - topExtension,\n\t\t\twidth: n.width,\n\t\t\theight: topExtension + bottomExtension\n\t\t}\n\t\tp0.x = Math.min(p0.x, b.x)\n\t\tp0.y = Math.min(p0.y, b.y)\n\t\tp1.x = Math.max(p1.x, b.x + b.width)\n\t\tp1.y = Math.max(p1.y, b.y + b.height)\n\t})\n\tconst pad = 25 // Padding around content\n\tconst labelHeight = 30 // Space for the group label at bottom\n\tconst w = Math.max(p1.x - p0.x, 200)\n\tconst h = p1.y - p0.y\n\tconst bb = {\n\t\tx: p0.x - pad,\n\t\ty: p0.y - pad,\n\t\twidth: w + pad * 2,\n\t\theight: h + pad * 2 + labelHeight,\n\t}\n\tconst r = create.rect(bb.width, bb.height, bb.x, bb.y)\n\tgroup.x = bb.x + bb.width / 2\n\tgroup.y = bb.y + bb.height / 2\n\tgroup.width = bb.width\n\tgroup.height = bb.height\n\tapplyStyle(r, SVG_STYLES.groupRect)\n\tgroup.style.stroke && r.setAttribute('stroke', group.style.stroke)\n\tgroup.style.background && r.setAttribute('fill', group.style.background)\n\n\tconst txt = create.text(group.name, {x: p0.x, y: bb.y + bb.height - SVG_STYLES.groupText[\"font-size\"]})\n\tapplyStyle(txt, SVG_STYLES.groupText)\n\tgroup.style.color && txt.setAttribute('fill', group.style.color)\n\n\tg.append(r, txt)\n\tgroup.ref = g\n}\n\nfunction findClosestSegment(graph: GraphData, p: Point) {\n\t// find the closest point on a segment\n\tlet fnd = {dst: Number.POSITIVE_INFINITY, pos: -1, edge: null as Edge, prj: null as Point}\n\tgraph.edges.forEach(edge => {\n\t\tconst vertices = edge.vertices || []\n\t\tconst pts = [edge.from, ...vertices, edge.to]\n\t\tfor (let i = 1; i < pts.length; i++) {\n\t\t\tconst prj = project(p, pts[i - 1], pts[i])\n\t\t\tconst dst = cabDistance(p, prj)\n\t\t\tif (dst > 50) continue\n\t\t\tif (dst < fnd.dst) {\n\t\t\t\tfnd = {dst, pos: i, prj, edge}\n\t\t\t}\n\t\t}\n\t})\n\treturn fnd.edge ? fnd : null\n}\n\n/** mouseToDrawing converts a mouse event over data's svg to drawing coordinates. */\nfunction mouseToDrawing(data: GraphData, e: MouseEvent): Point {\n\t// transform event coords to drawing coords\n\tconst b = data.svg.getBoundingClientRect()\n\tconst z = getZoom(data)\n\t\n\t// Get current pan transform\n\tconst currentTransform = getCurrentTransform(data)\n\t\n\t// Convert screen coordinates to drawing coordinates accounting for zoom and pan\n\t// The transform values are in screen coordinates, so we need to divide by zoom and subtract\n\treturn {\n\t\tx: (e.clientX - b.x - currentTransform.x) / z,\n\t\ty: (e.clientY - b.y - currentTransform.y) / z\n\t}\n}\n\ninterface Handle extends Point {\n\tid: string\n\tselected?: boolean\n\tref?: SVGElement\n}\n\n// Custom cursor interaction that prioritizes panning over selection, on data's svg\nfunction addCustomCursorInteraction(data: GraphData, conn: {\n\tnodeFromEvent(e: MouseEvent): Handle | null;\n\tsetSelection(handles: Handle[]): void;\n\tsetDragging(dragging: boolean): void;\n\tisSelected(handle: Handle): boolean;\n\tgetSelection(): Handle[];\n\tgetZoom(): number;\n\tmoveNode(h: Handle, x: number, y: number): void;\n\tboxSelection(box: DOMRect, add: boolean): void;\n\tupdatePanning(): void;\n}, dragMode: 'pan' | 'select') {\n\tconst svg = data.svg\n\tlet ini: { x: number; y: number; n: Handle }[] = []\n\tlet elastic: any = null\n\tlet isPanning = false\n\tlet panStartX = 0\n\tlet panStartY = 0\n\tlet initialTransform = { x: 0, y: 0 }\n\tlet pendingSelectionChange: { node: Handle; shiftKey: boolean } | null = null\n\tlet pendingNavigation: string | null = null\n\tlet hasDragged = false\n\tlet suppressLinkClick = false\n\t\n\t// Store event listeners for cleanup\n\tconst eventListeners: Array<{ element: Element | Window, event: string, handler: EventListener }> = []\n\n\t// Simple elastic selection box implementation - use mouseToDrawing for proper coordinate conversion\n\tfunction createElastic() {\n\t\tlet startDrawingX = 0, startDrawingY = 0, rect: SVGRectElement | null = null\n\t\t\n\t\treturn {\n\t\t\tini(e: MouseEvent) {\n\t\t\t\t// Use mouseToDrawing to get proper drawing coordinates (accounts for zoom and pan)\n\t\t\t\tconst pt = mouseToDrawing(data, e)\n\t\t\t\tstartDrawingX = pt.x\n\t\t\t\tstartDrawingY = pt.y\n\t\t\t\t\n\t\t\t\trect = document.createElementNS(\"http://www.w3.org/2000/svg\", \"rect\")\n\t\t\t\trect.setAttribute('fill', 'rgba(0, 100, 255, 0.1)')\n\t\t\t\trect.setAttribute('stroke', 'rgba(0, 100, 255, 0.5)')\n\t\t\t\trect.setAttribute('stroke-width', '1')\n\t\t\t\trect.setAttribute('stroke-dasharray', '3,3')\n\t\t\t\trect.setAttribute('x', String(startDrawingX))\n\t\t\t\trect.setAttribute('y', String(startDrawingY))\n\t\t\t\trect.setAttribute('width', '0')\n\t\t\t\trect.setAttribute('height', '0')\n\t\t\t\t\n\t\t\t\t// Add to the zoom group so it transforms with the content\n\t\t\t\tconst zoomGroup = svg.querySelector('g.zoom')\n\t\t\t\tif (zoomGroup) {\n\t\t\t\t\tzoomGroup.appendChild(rect)\n\t\t\t\t} else {\n\t\t\t\t\tsvg.appendChild(rect)\n\t\t\t\t}\n\t\t\t},\n\t\t\tupdate(e: MouseEvent) {\n\t\t\t\tif (!rect) return\n\t\t\t\t\n\t\t\t\t// Convert current mouse position to drawing coordinates (accounts for zoom and pan)\n\t\t\t\tconst currentPt = mouseToDrawing(data, e)\n\t\t\t\tconst currentDrawingX = currentPt.x\n\t\t\t\tconst currentDrawingY = currentPt.y\n\t\t\t\t\n\t\t\t\t// Calculate rectangle bounds in drawing coordinates\n\t\t\t\tconst x = Math.min(startDrawingX, currentDrawingX)\n\t\t\t\tconst y = Math.min(startDrawingY, currentDrawingY)\n\t\t\t\tconst width = Math.abs(currentDrawingX - startDrawingX)\n\t\t\t\tconst height = Math.abs(currentDrawingY - startDrawingY)\n\t\t\t\t\n\t\t\t\trect.setAttribute('x', String(x))\n\t\t\t\trect.setAttribute('y', String(y))\n\t\t\t\trect.setAttribute('width', String(width))\n\t\t\t\trect.setAttribute('height', String(height))\n\t\t\t},\n\t\t\tend(): DOMRect | null {\n\t\t\t\tif (!rect) return null\n\t\t\t\t\n\t\t\t\t// Get final rectangle bounds in drawing coordinates\n\t\t\t\tconst x = parseFloat(rect.getAttribute('x') || '0')\n\t\t\t\tconst y = parseFloat(rect.getAttribute('y') || '0')\n\t\t\t\tconst width = parseFloat(rect.getAttribute('width') || '0')\n\t\t\t\tconst height = parseFloat(rect.getAttribute('height') || '0')\n\t\t\t\t\n\t\t\t\trect.remove()\n\t\t\t\trect = null\n\t\t\t\t\n\t\t\t\t// Return drawing coordinates directly for boxSelection since we're now working in the same coordinate system\n\t\t\t\tif (width > 5 && height > 5) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tx: x, y: y, width: width, height: height,\n\t\t\t\t\t\tleft: x, top: y, right: x + width, bottom: y + height\n\t\t\t\t\t} as DOMRect\n\t\t\t\t}\n\t\t\t\treturn null\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction getCurrentTransformLocal() {\n\t\tconst zoomGroup = svg.querySelector('g.zoom') as SVGGElement\n\t\tif (!zoomGroup) return { x: 0, y: 0 }\n\t\t\n\t\tconst transform = zoomGroup.getAttribute('transform') || ''\n\t\tconst translateMatch = transform.match(/translate\\(([^,]+),([^)]+)\\)/)\n\t\tif (translateMatch) {\n\t\t\treturn {\n\t\t\t\tx: parseFloat(translateMatch[1]) || 0,\n\t\t\t\ty: parseFloat(translateMatch[2]) || 0\n\t\t\t}\n\t\t}\n\t\treturn { x: 0, y: 0 }\n\t}\n\n\tfunction setTransform(x: number, y: number) {\n\t\tconst zoomGroup = svg.querySelector('g.zoom') as SVGGElement\n\t\tif (!zoomGroup) return\n\t\t\n\t\tconst zoom = getZoom(data)\n\t\tzoomGroup.setAttribute('transform', `translate(${x}, ${y}) scale(${zoom})`)\n\t}\n\n\tfunction onMouseDown(e: MouseEvent) {\n\t\te.preventDefault();\n\t\thasDragged = false\n\t\tpendingSelectionChange = null\n\t\tconst target = e.target\n\t\tconst link = target instanceof Element ? target.closest('a.nodeLink') : null\n\t\tpendingNavigation = e.shiftKey ? null : link?.getAttribute('href') || null\n\n\t\tconst node = conn.nodeFromEvent(e)\n\t\t\n\t\t// Determine effective mode: invert if shift is held\n\t\tconst effectiveMode = e.shiftKey ? (dragMode === 'pan' ? 'select' : 'pan') : dragMode\n\t\t\n\t\tif (!node) { // Clicked on empty space\n\t\t\tif (effectiveMode === 'pan') {\n\t\t\t\t// Pan mode: pan and deselect\n\t\t\t\tisPanning = true;\n\t\t\t\telastic = null;\n\t\t\t\tpanStartX = e.clientX;\n\t\t\t\tpanStartY = e.clientY;\n\t\t\t\tinitialTransform = getCurrentTransformLocal();\n\t\t\t\tini = [];\n\t\t\t\t// Deselect all elements when clicking empty space in pan mode\n\t\t\t\tconn.setSelection([]);\n\t\t\t} else {\n\t\t\t\t// Select mode: ONLY select, no panning\n\t\t\t\tisPanning = false;\n\t\t\t\telastic = createElastic();\n\t\t\t\tif (elastic) elastic.ini(e);\n\t\t\t\tini = [];\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Clicked on a node/vertex - behavior depends on effective mode\n\t\tif (effectiveMode === 'pan') {\n\t\t\t// Pan mode: select the element, don't pan\n\t\t\tisPanning = false;\n\t\t\telastic = null;\n\t\t\t\n\t\t\tconst nodes = conn.getSelection()\n\t\t\tif (conn.isSelected(node)) {\n\t\t\t\t// Clicking on a selected node - prepare to drag all selected elements\n\t\t\t\tini = nodes.map(n => ({ x: n.x, y: n.y, n }))\n\t\t\t\t// No selection change needed since we're clicking on already selected element\n\t\t\t} else {\n\t\t\t\t// Clicking on an unselected node - select only this element\n\t\t\t\tconn.setSelection([node]);\n\t\t\t\tini = [{ x: node.x, y: node.y, n: node }];\n\t\t\t}\n\t\t} else {\n\t\t\t// Select mode: selection/drag logic\n\t\t\tisPanning = false; // Ensure no panning if a node is clicked\n\t\t\telastic = null; // Ensure no selection box if a node is clicked\n\t\t\tconst nodes = conn.getSelection()\n\t\t\t\n\t\t\tif (e.shiftKey && dragMode === 'select') {\n\t\t\t\t// Shift+click in select mode: immediately change selection (no dragging expected)\n\t\t\t\tif (conn.isSelected(node)) {\n\t\t\t\t\tconst index = nodes.findIndex(n => n.id === node.id)\n\t\t\t\t\tif (index >= 0) nodes.splice(index, 1)\n\t\t\t\t} else {\n\t\t\t\t\tnodes.push(node)\n\t\t\t\t}\n\t\t\t\tconn.setSelection(nodes)\n\t\t\t\tini = nodes.map(n => ({ x: n.x, y: n.y, n }))\n\t\t\t} else {\n\t\t\t\t// Regular click: defer selection change until we know if it's a drag or click\n\t\t\t\tif (conn.isSelected(node)) {\n\t\t\t\t\t// Clicking on a selected node - prepare to drag all selected elements\n\t\t\t\t\tini = nodes.map(n => ({ x: n.x, y: n.y, n }))\n\t\t\t\t\t// No pending selection change needed since we're clicking on already selected element\n\t\t\t\t\tpendingSelectionChange = null\n\t\t\t\t} else {\n\t\t\t\t\t// Clicking on an unselected node - defer selection change until we determine if it's a click or drag\n\t\t\t\t\tpendingSelectionChange = { node, shiftKey: e.shiftKey }\n\t\t\t\t\t// For now, prepare to drag just the clicked node (we'll update selection when drag starts)\n\t\t\t\t\tini = [{ x: node.x, y: node.y, n: node }]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onMouseMove(e: MouseEvent, dx: number, dy: number) {\n\t\t// Check if we've moved enough to consider this a drag\n\t\tconst dragThreshold = 3 // pixels\n\t\tif (!hasDragged && (Math.abs(dx) > dragThreshold || Math.abs(dy) > dragThreshold)) {\n\t\t\thasDragged = true\n\t\t\tpendingNavigation = null\n\t\t\t\n\t\t\t// If we have a pending selection change and we're now dragging, apply it\n\t\t\tif (pendingSelectionChange) {\n\t\t\t\tconst nodes = conn.getSelection()\n\t\t\t\tnodes.length = 0\n\t\t\t\tnodes.push(pendingSelectionChange.node)\n\t\t\t\tconn.setSelection(nodes)\n\t\t\t\t// Update ini to drag only the newly selected node\n\t\t\t\tini = [{ x: pendingSelectionChange.node.x, y: pendingSelectionChange.node.y, n: pendingSelectionChange.node }]\n\t\t\t\tpendingSelectionChange = null\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (isPanning) {\n\t\t\t// Pan the view - apply mouse delta directly (no zoom division needed)\n\t\t\t// setTransform expects screen coordinates, dx/dy are already screen pixel deltas\n\t\t\tconst newX = initialTransform.x + dx\n\t\t\tconst newY = initialTransform.y + dy\n\t\t\tsetTransform(newX, newY)\n\t\t} else if (ini.length > 0 && hasDragged) {\n\t\t\t// Move selected nodes/vertices (only if we've actually started dragging)\n\t\t\t// dx, dy are screen pixel deltas, convert to drawing coordinate deltas\n\t\t\tconst zoom = conn.getZoom()\n\t\t\tconst drawingDx = dx / zoom\n\t\t\tconst drawingDy = dy / zoom\n\t\t\tini.forEach(item => {\n\t\t\t\t// item.x, item.y are initial drawing coordinates\n\t\t\t\t// Add the drawing coordinate delta to get new position\n\t\t\t\tconn.moveNode(item.n, item.x + drawingDx, item.y + drawingDy)\n\t\t\t})\n\t\t\tconn.setDragging(true)\n\t\t} else if (elastic) {\n\t\t\t// Update selection box\n\t\t\telastic.update(e)\n\t\t\tconn.setDragging(true)\n\t\t}\n\t}\n\n\tfunction onMouseUp(e: MouseEvent) {\n\t\tconn.setDragging(false)\n\t\tconst navigation = hasDragged ? null : pendingNavigation\n\t\tif (hasDragged) {\n\t\t\tsuppressLinkClick = true\n\t\t\twindow.setTimeout(() => {\n\t\t\t\tsuppressLinkClick = false\n\t\t\t}, 0)\n\t\t}\n\t\t\n\t\t// If we have a pending selection change and didn't drag, apply it now (it was just a click)\n\t\tif (pendingSelectionChange && !hasDragged) {\n\t\t\tconst nodes = conn.getSelection()\n\t\t\tnodes.length = 0\n\t\t\tnodes.push(pendingSelectionChange.node)\n\t\t\tconn.setSelection(nodes)\n\t\t}\n\t\t\n\t\tif (elastic) {\n\t\t\tconst box = elastic.end()\n\t\t\tif (box) {\n\t\t\t\tconn.boxSelection(box, e.shiftKey)\n\t\t\t} else if (!ini.length) {\n\t\t\t\t// Deselect if no box was drawn\n\t\t\t\tconn.setSelection([])\n\t\t\t}\n\t\t\telastic = null\n\t\t}\n\t\t\n\t\t// Save view state if user was panning (user-initiated view change)\n\t\tif (isPanning && hasDragged) {\n\t\t\tsaveViewState(data)\n\t\t}\n\t\t\n\t\t// Reset state\n\t\tpendingSelectionChange = null\n\t\tpendingNavigation = null\n\t\thasDragged = false\n\t\tisPanning = false\n\t\tconn.updatePanning()\n\t\tif (navigation) {\n\t\t\twindow.location.href = navigation\n\t\t}\n\t}\n\n\tfunction onClick(e: MouseEvent) {\n\t\tconst target = e.target\n\t\tif (!(target instanceof Element) || !target.closest('a.nodeLink')) return\n\t\te.preventDefault()\n\t\tif (!suppressLinkClick) return\n\t\te.stopPropagation()\n\t\tsuppressLinkClick = false\n\t}\n\n\t// Add drag and drop functionality\n\tfunction addDnd(element: SVGSVGElement) {\n\t\tlet md: { ex: number; ey: number } | null = null\n\n\t\tfunction convertEvent(e: MouseEvent | TouchEvent): MouseEvent {\n\t\t\tif ('changedTouches' in e && e.changedTouches) {\n\t\t\t\treturn e.changedTouches[0] as any\n\t\t\t}\n\t\t\treturn e as MouseEvent\n\t\t}\n\n\t\tfunction onMouseMoveHandler(e: MouseEvent | TouchEvent) {\n\t\t\tif (!md) return\n\t\t\te = convertEvent(e)\n\t\t\tonMouseMove(e, e.clientX - md.ex, e.clientY - md.ey)\n\t\t}\n\n\t\tfunction removeListeners() {\n\t\t\tdocument.removeEventListener('touchmove', onMouseMoveHandler as any)\n\t\t\tdocument.removeEventListener('mousemove', onMouseMoveHandler as any)\n\t\t\tdocument.removeEventListener('mouseup', onMouseUpHandler)\n\t\t\tdocument.removeEventListener('touchend', onMouseUpHandler)\n\t\t}\n\n\t\tfunction onMouseUpHandler(e: MouseEvent | TouchEvent) {\n\t\t\tremoveListeners()\n\t\t\tonMouseUp(convertEvent(e))\n\t\t\tmd = null\n\t\t}\n\n\t\tfunction onMouseDownHandler(e: MouseEvent | TouchEvent) {\n\t\t\te = convertEvent(e)\n\t\t\tmd = { ex: e.clientX, ey: e.clientY }\n\t\t\tonMouseDown(e)\n\t\t\tdocument.addEventListener('touchmove', onMouseMoveHandler as any)\n\t\t\tdocument.addEventListener('mousemove', onMouseMoveHandler as any)\n\t\t\tdocument.addEventListener('mouseup', onMouseUpHandler)\n\t\t\tdocument.addEventListener('touchend', onMouseUpHandler)\n\t\t}\n\n\t\telement.addEventListener('mousedown', onMouseDownHandler as any)\n\t\telement.addEventListener('touchstart', onMouseDownHandler as any)\n\t\t\n\t\t// Track these listeners for cleanup\n\t\teventListeners.push(\n\t\t\t{ element, event: 'mousedown', handler: onMouseDownHandler as any },\n\t\t\t{ element, event: 'touchstart', handler: onMouseDownHandler as any }\n\t\t)\n\t}\n\n\taddDnd(svg)\n\tsvg.addEventListener('click', onClick)\n\teventListeners.push({ element: svg, event: 'click', handler: onClick })\n\t\n\t// Return cleanup function\n\treturn () => {\n\t\teventListeners.forEach(({ element, event, handler }) => {\n\t\t\telement.removeEventListener(event, handler)\n\t\t})\n\t}\n}\n\n/**\n * addCursorInteraction attaches the editor's mouse, wheel, keyboard, and\n * unsaved-changes handling for data and its svg, replacing handlers attached by\n * an earlier call. The cleanup function is stored as the svg's\n * __cursorInteractionCleanup; the editor calls it when it removes the graph.\n */\nexport function addCursorInteraction(data: GraphData, dragMode: 'pan' | 'select') {\n\tconst svg = data.svg\n\t// Clean up any existing event listeners to prevent conflicts\n\tconst existingCleanup = (svg as any).__cursorInteractionCleanup\n\tif (existingCleanup) {\n\t\texistingCleanup()\n\t}\n\n\tfunction getData(el: SVGElement) {\n\t\t// @ts-ignore\n\t\treturn el.__data\n\t}\n\n\t// Store event listeners for cleanup\n\tconst eventListeners: Array<{ element: Element | Window, event: string, handler: EventListener }> = []\n\n\tconst beforeUnloadHandler = (e: BeforeUnloadEvent) => {\n\t\tif (!data.changed()) return\n\t\te.preventDefault()\n\t\te.returnValue = ''\n\t}\n\twindow.addEventListener(\"beforeunload\", beforeUnloadHandler)\n\teventListeners.push({ element: window, event: 'beforeunload', handler: beforeUnloadHandler })\n\n\tfunction setDotSelected(d: Handle, selected: boolean) {\n\t\td.selected = selected\n\t\tconst dotEl = svg.querySelector('#' + data.idPrefix + d.id)\n\t\td.selected ? dotEl.classList.add('selected') : dotEl.classList.remove('selected')\n\t}\n\n\t// show moving dot along edge when ALT is pressed\n\tconst mouseMoveHandler = (e: MouseEvent) => {\n\t\tif (!e.altKey) return\n\t\tconst fnd = findClosestSegment(data, mouseToDrawing(data, e))\n\t\tif (fnd) {\n\t\t\tconst {prj} = fnd\n\t\t\tconst parent = svg.querySelector('g.edges')\n\t\t\tlet dot = parent.querySelector(`#${data.idPrefix}prj`)\n\t\t\tif (!dot) {\n\t\t\t\tdot = create.element('circle', {id: `${data.idPrefix}prj`, cx: prj.x, cy: prj.y, r: 7})\n\t\t\t\tparent.append(dot)\n\t\t\t}\n\t\t\tdot.setAttribute('cx', String(prj.x))\n\t\t\tdot.setAttribute('cy', String(prj.y))\n\t\t} else {\n\t\t\tremovePrjDot()\n\t\t}\n\t}\n\tsvg.addEventListener('mousemove', mouseMoveHandler)\n\teventListeners.push({ element: svg, event: 'mousemove', handler: mouseMoveHandler })\n\n\tconst keyUpHandler = (e: KeyboardEvent) => {\n\t\tconst key = findShortcut(e, true)\n\t\tif (key == ADD_VERTEX || key == ADD_LABEL_VERTEX) return\n\t\tremovePrjDot()\n\t}\n\twindow.addEventListener('keyup', keyUpHandler)\n\teventListeners.push({ element: window, event: 'keyup', handler: keyUpHandler })\n\n\tfunction removePrjDot() {\n\t\tconst el = svg.querySelector(`g.edges #${data.idPrefix}prj`)\n\t\tel && el.parentElement.removeChild(el)\n\t}\n\n\tconst clickHandler = (e: MouseEvent) => {\n\t\tconst key = findShortcut(e, true)\n\t\tif (key != ADD_LABEL_VERTEX && key != ADD_VERTEX) return\n\t\tconst fnd = findClosestSegment(data, mouseToDrawing(data, e))\n\t\tif (fnd) {\n\t\t\tconst {edge, pos, prj} = fnd\n\t\t\t// depending on keyboard modifier, make it label position\n\t\t\tdata.insertEdgeVertex(edge, prj, pos, key == ADD_LABEL_VERTEX)\n\t\t\tremovePrjDot()\n\t\t}\n\t}\n\tsvg.addEventListener('click', clickHandler)\n\teventListeners.push({ element: svg, event: 'click', handler: clickHandler })\n\n\tconst wheelHandler = (e: WheelEvent) => {\n\t\t// Handle wheel zoom directly without relying on shortcuts\n\t\t// deltaY > 0 means scrolling down (zoom out), deltaY < 0 means scrolling up (zoom in)\n\t\tconst delta = Math.sign(e.deltaY) * 0.1 // Normalize to 0.1 zoom steps\n\t\tconst currentZoom = getZoom(data)\n\t\tconst newZoom = Math.max(0.1, Math.min(5, currentZoom - delta)) // Clamp zoom between 0.1 and 5\n\t\t\n\t\tif (newZoom !== currentZoom) {\n\t\t\t// Convert absolute screen coordinates to SVG-relative coordinates\n\t\t\tconst rect = svg.getBoundingClientRect()\n\t\t\tconst svgX = e.clientX - rect.left\n\t\t\tconst svgY = e.clientY - rect.top\n\t\t\tsetZoomCentered(data, newZoom, svgX, svgY)\n\t\t\te.preventDefault()\n\t\t\t\n\t\t\t// Save view state after user wheel zoom\n\t\t\tsaveViewState(data)\n\t\t}\n\t}\n\tsvg.addEventListener('wheel', wheelHandler)\n\teventListeners.push({ element: svg, event: 'wheel', handler: wheelHandler })\n\n\tconst keyDownHandler = (e: KeyboardEvent) => {\n\t\tconst shortcut = findShortcut(e)\n\t\t\n\t\t\n\t\tif (shortcut) {\n\t\t\te.preventDefault() // Prevent browser default for all recognized shortcuts\n\t\t}\n\t\t\n\t\tswitch (shortcut) {\n\t\t\tcase DEL_VERTEX:\n\t\t\t\tconst selectedVertices = Array.from(data.edgeVertices.values()).filter(v => v.selected);\n\t\t\t\tselectedVertices.forEach(v => {\n\t\t\t\t\tdata.deleteEdgeVertex(v)\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\tcase UNDO:\n\t\t\t\tdata.undo()\n\t\t\t\tbreak\n\t\t\tcase REDO:\n\t\t\t\tdata.redo()\n\t\t\t\tbreak\n\t\t\tcase ZOOM_IN:\n\t\t\t\tconst newZoomIn = Math.min(5, getZoom(data) * 1.2)\n\t\t\t\t// Center zoom on viewport center like mouse wheel\n\t\t\t\tsetZoomCentered(data, newZoomIn)\n\t\t\t\tsaveViewState(data) // Save after user keyboard zoom\n\t\t\t\tbreak\n\t\t\tcase ZOOM_OUT:\n\t\t\t\tconst newZoomOut = Math.max(0.1, getZoom(data) / 1.2)\n\t\t\t\t// Center zoom on viewport center like mouse wheel\n\t\t\t\tsetZoomCentered(data, newZoomOut)\n\t\t\t\tsaveViewState(data) // Save after user keyboard zoom\n\t\t\t\tbreak\n\t\t\tcase ZOOM_100:\n\t\t\t\t// Center zoom on viewport center like mouse wheel\n\t\t\t\tsetZoomCentered(data, 1)\n\t\t\t\tsaveViewState(data) // Save after user keyboard zoom\n\t\t\t\tbreak\n\t\t\tcase ZOOM_FIT:\n\t\t\t\tdata.fitToView()\n\t\t\t\t// Don't save view state here - fitToView should not be persisted\n\t\t\t\tbreak\n\t\t\tcase SELECT_ALL:\n\t\t\t\tdata.nodes().forEach(n => data.setNodeSelected(n, true))\n\t\t\t\tdata.edgeVertices.forEach(v => setDotSelected(v, true))\n\t\t\t\tbreak\n\t\t\tcase DESELECT:\n\t\t\t\tdata.nodes().forEach(n => data.setNodeSelected(n, false))\n\t\t\t\tdata.edgeVertices.forEach(v => setDotSelected(v, false))\n\t\t\t\tbreak\n\t\t}\n\t}\n\twindow.addEventListener('keydown', keyDownHandler)\n\teventListeners.push({ element: window, event: 'keydown', handler: keyDownHandler })\n\n\t// Custom cursor interaction with pan-first behavior\n\tconst customInteractionCleanup = addCustomCursorInteraction(data, {\n\t\tnodeFromEvent(e: MouseEvent): Handle {\n\t\t\te.preventDefault()\n\t\t\t// node clicked\n\t\t\tlet el = (e.target as SVGElement).closest('g.nodes g.node') as SVGElement\n\t\t\tif (el) return getData(el)\n\t\t\t// vertex dot clicked; its id is the vertex id after this graph's idPrefix\n\t\t\tel = (e.target as SVGElement).closest('g.edges g.edge .v-dot') as SVGElement\n\t\t\tif (el) {\n\t\t\t\treturn data.edgeVertices.get(el.id.slice(data.idPrefix.length))\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\t\tsetSelection(handles: Handle[]) {\n\t\t\t// nodes\n\t\t\tdata.nodes().forEach(n => data.setNodeSelected(n, handles.some(h => h.id == n.id)))\n\t\t\t// dots\n\t\t\tdata.edgeVertices.forEach(d => setDotSelected(d, handles.some(h => h.id == d.id)))\n\t\t\tdata.selectListener(data.nodes().find(n => n.selected))\n\t\t},\n\t\tsetDragging(d: boolean) {\n\t\t\tdata.dragging = d\n\t\t},\n\t\tisSelected(handle: Handle): boolean {\n\t\t\treturn handle.selected\n\t\t},\n\t\tgetSelection(): Handle[] {\n\t\t\tconst ret: Handle[] = data.nodes().filter(n => n.selected)\n\t\t\tdata.edgeVertices.forEach(d => d.selected && ret.push(d))\n\t\t\treturn ret\n\t\t},\n\t\tgetZoom: () => getZoom(data),\n\t\tmoveNode(h: Handle, x: number, y: number) {\n\t\t\tif (data.nodesMap.has(h.id))\n\t\t\t\tdata.moveNode(h as Node, x, y)\n\t\t\telse {\n\t\t\t\t(h as EdgeVertex).auto = false\n\t\t\t\tdata.moveEdgeVertex(h as EdgeVertex, x, y)\n\t\t\t}\n\t\t},\n\t\tboxSelection(box: DOMRect, add) {\n\t\t\t// Box is now already in drawing coordinates, no need to scale\n\t\t\t// nodes\n\t\t\tdata.nodesMap.forEach(n => {\n\t\t\t\tconst inBox = boxesOverlap(uncenterBox(n), box)\n\t\t\t\tif (inBox) {\n\t\t\t\t\t// Toggle selection for elements in the box\n\t\t\t\t\tdata.setNodeSelected(n, !n.selected)\n\t\t\t\t} else if (!add) {\n\t\t\t\t\t// If not holding shift and element is outside box, deselect it\n\t\t\t\t\tdata.setNodeSelected(n, false)\n\t\t\t\t}\n\t\t\t})\n\t\t\t// dots\n\t\t\tdata.edgeVertices.forEach(d => {\n\t\t\t\tconst inBox = insideBox(d, box, false)\n\t\t\t\tif (inBox) {\n\t\t\t\t\t// Toggle selection for elements in the box\n\t\t\t\t\tsetDotSelected(d, !d.selected)\n\t\t\t\t} else if (!add) {\n\t\t\t\t\t// If not holding shift and element is outside box, deselect it\n\t\t\t\t\tsetDotSelected(d, false)\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tdata.selectListener(data.nodes().find(n => n.selected))\n\t\t},\n\t\tupdatePanning: () => updatePanning(data),\n\t}, dragMode)\n\t\n\t// Store cleanup function on the SVG element for later use\n\tconst cleanup = () => {\n\t\teventListeners.forEach(({ element, event, handler }) => {\n\t\t\telement.removeEventListener(event, handler)\n\t\t})\n\t\tif (customInteractionCleanup) {\n\t\t\tcustomInteractionCleanup()\n\t\t}\n\t}\n\t\n\t// Store cleanup function on SVG element\n\t;(svg as any).__cursorInteractionCleanup = cleanup\n}\n\n/** getZoom returns data's current zoom, or 1 before data has been drawn. */\nexport function getZoom(data: GraphData) {\n\tconst el = data.svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return 1\n\t\n\t// Parse zoom from transform attribute to match how we set it\n\tconst transform = el.getAttribute('transform') || ''\n\tconst scaleMatch = transform.match(/scale\\(([^)]+)\\)/)\n\tif (scaleMatch) {\n\t\treturn parseFloat(scaleMatch[1]) || 1\n\t}\n\treturn 1\n}\n\n// svgPadding is now imported as SVG_PADDING from constants.ts\n\n/** setZoom sets data's zoom and keeps its current pan; it does nothing before data is drawn. */\nexport function setZoom(data: GraphData, zoom: number) {\n\tconst el = data.svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return\n\t\n\t// Preserve existing translation when setting zoom\n\tconst currentTransform = getCurrentTransform(data)\n\tel.setAttribute('transform', `translate(${currentTransform.x}, ${currentTransform.y}) scale(${zoom})`)\n\t\n\t// also set panning size\n\tupdatePanning(data)\n}\n\n/**\n * setZoomCentered sets data's zoom while keeping the drawing point under\n * (centerX, centerY) in place, by default the center of the svg's container.\n */\nexport function setZoomCentered(data: GraphData, newZoom: number, centerX?: number, centerY?: number) {\n\tconst svg = data.svg\n\tconst el = svg.querySelector('g.zoom') as SVGGElement\n\tconst oldZoom = getZoom(data)\n\t\n\t// If no center point provided, use viewport center\n\tif (centerX === undefined || centerY === undefined) {\n\t\t// Use the parent container's dimensions for the visible viewport\n\t\t// The SVG might be larger than the visible area due to overflow\n\t\tconst container = svg.parentElement\n\t\tif (container) {\n\t\t\tcenterX = container.clientWidth / 2\n\t\t\tcenterY = container.clientHeight / 2\n\t\t} else {\n\t\t\t// Fallback to SVG dimensions if no parent\n\t\t\tcenterX = svg.clientWidth / 2\n\t\t\tcenterY = svg.clientHeight / 2\n\t\t}\n\t}\n\t\n\t// Get current transform\n\tconst currentTransform = getCurrentTransform(data)\n\t\n\t// Convert screen coordinates to drawing coordinates\n\t// For transform order translate(tx, ty) scale(s):\n\t// screen_point = (drawing_point * scale) + translation\n\t// So: drawing_point = (screen_point - translation) / scale\n\tconst drawingX = (centerX - currentTransform.x) / oldZoom\n\tconst drawingY = (centerY - currentTransform.y) / oldZoom\n\t\n\t// Calculate new translation to keep the same drawing point at the same screen position\n\t// screen_point = (drawing_point * new_scale) + new_translation\n\t// So: new_translation = screen_point - (drawing_point * new_scale)\n\tconst newTranslateX = centerX - (drawingX * newZoom)\n\tconst newTranslateY = centerY - (drawingY * newZoom)\n\t\n\t// Apply the new transform\n\tel.setAttribute('transform', `translate(${newTranslateX}, ${newTranslateY}) scale(${newZoom})`)\n\t\n\t// Update panning\n\tupdatePanning(data)\n}\n\n/** getCurrentTransform returns data's current pan, or (0, 0) before data is drawn. */\nfunction getCurrentTransform(data: GraphData) {\n\tconst el = data.svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return { x: 0, y: 0 }\n\t\n\tconst transform = el.getAttribute('transform') || ''\n\tconst translateMatch = transform.match(/translate\\(([^,]+),([^)]+)\\)/)\n\tif (translateMatch) {\n\t\treturn {\n\t\t\tx: parseFloat(translateMatch[1]) || 0,\n\t\t\ty: parseFloat(translateMatch[2]) || 0\n\t\t}\n\t}\n\treturn { x: 0, y: 0 }\n}\n\n/** updatePanning resizes data's svg to fit its zoomed drawing; it does nothing until the svg is placed. */\nfunction updatePanning(data: GraphData) {\n\tconst svg = data.svg\n\tconst el = svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return\n\tconst bb = el.getBBox()\n\tconst zoom = getZoom(data)\n\tif (!svg.parentElement) return\n\tconst w = Math.max(svg.parentElement.clientWidth / zoom, bb.x + bb.width + SVG_PADDING)\n\tconst h = Math.max(svg.parentElement.clientHeight / zoom, bb.y + bb.height + SVG_PADDING)\n\tsvg.setAttribute('width', String(w * zoom))\n\tsvg.setAttribute('height', String(h * zoom))\n\t\n\t// Note: View state saving removed from here to prevent interference with reset/fit functions\n\t// View state is now only saved on user interactions and page unload\n}\n\n// Optimized version that uses pre-calculated content bounds instead of expensive getBBox()\nfunction updatePanningOptimized(graphData: GraphData) {\n\tconst svg = graphData.svg\n\tconst bb = graphData.calculateContentBounds() // Use already calculated bounds\n\tconst zoom = getZoom(graphData)\n\tconst w = Math.max(svg.parentElement.clientWidth / zoom, bb.x + bb.width + SVG_PADDING)\n\tconst h = Math.max(svg.parentElement.clientHeight / zoom, bb.y + bb.height + SVG_PADDING)\n\tsvg.setAttribute('width', String(w * zoom))\n\tsvg.setAttribute('height', String(h * zoom))\n}\n\n/** getZoomAuto returns the zoom that fits graphData's content in its svg's container. */\nexport const getZoomAuto = (graphData: GraphData) => {\n\t// Use proper content bounds calculation\n\tconst contentBounds = graphData.calculateContentBounds()\n\tconst viewportWidth = graphData.svg.parentElement?.clientWidth || 800\n\tconst viewportHeight = graphData.svg.parentElement?.clientHeight || 600\n\t\n\t// Add padding around content\n\tconst padding = 40\n\t\n\t// Calculate zoom to fit content with padding\n\tconst zoomX = (viewportWidth - padding * 2) / contentBounds.width\n\tconst zoomY = (viewportHeight - padding * 2) / contentBounds.height\n\tconst zoom = Math.min(zoomX, zoomY)\n\t\n\t// Clamp zoom between reasonable bounds\n\treturn Math.max(Math.min(zoom, 2), 0.1)\n}\n\nconst setBorderStyle = (el: SVGElement, style: string) => {\n\tif (style == 'Dashed') el.setAttribute('stroke-dasharray', '4')\n\telse if (style == 'Dotted') el.setAttribute('stroke-dasharray', '2')\n}\n\n// View state persistence - similar to undo cache but for zoom/pan\nconst viewStateCache = new Map();\n\n// Save data's current view state (zoom and pan) under its view id\nexport function saveViewState(data: GraphData) {\n\tconst zoom = getZoom(data);\n\tconst transform = getCurrentTransform(data);\n\t\n\tconst state = {\n\t\tzoom,\n\t\ttransform: { x: transform.x, y: transform.y }\n\t};\n\t\n\tviewStateCache.set(data.id, state);\n}\n\n// Restore the view state saved for data's view id, if it exists\nexport function restoreViewState(data: GraphData): boolean {\n\tif (!viewStateCache.has(data.id)) {\n\t\treturn false;\n\t}\n\t\n\tconst state = viewStateCache.get(data.id);\n\tif (!state) {\n\t\treturn false;\n\t}\n\t\n\t// Restore zoom and transform\n\tconst zoomGroup = data.svg.querySelector('g.zoom') as SVGGElement;\n\tif (zoomGroup) {\n\t\tzoomGroup.setAttribute('transform', `scale(${state.zoom}) translate(${state.transform.x}, ${state.transform.y})`);\n\t\tupdatePanning(data);\n\t}\n\t\n\treturn true;\n}\n\n// Clear the view state saved for data's view id\nexport function clearViewState(data: GraphData) {\n\tviewStateCache.delete(data.id);\n}\n","import fontFaces from \"../fonts.css?inline\";\nimport fontLicense from \"@fontsource/inter/LICENSE?raw\";\n\n/**\n * defs returns one graph's shared SVG definitions. Every id starts with prefix,\n * the graph's idPrefix, so definitions of graphs on the same page stay distinct.\n */\nexport const defs = (prefix: string) => `\n\n\t\n\t${fontLicense.replace(/&/g, \"&\").replace(/\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n`\n","// This file is the only owner of automatic positions. It gives ELK the exact\n// measured sizes, reads ELK's complete result, and does not repair that result.\n\nimport type {\n\tElkExtendedEdge,\n\tElkLabel,\n\tElkNode,\n\tElkPoint,\n} from \"elkjs/lib/elk-api\";\n\nimport {\n\tMeasuredDiagram,\n\tMeasuredEdge,\n\tMeasuredGroup,\n\tMeasuredNode,\n\tPoint,\n\tResolvedEdge,\n\tResolvedGroup,\n\tResolvedLayout,\n\tResolvedNode,\n} from \"./geometry\";\n\n/** AutomaticLayoutOptions are the choices a caller may make before layout. */\nexport interface AutomaticLayoutOptions {\n\tdirection: \"UP\" | \"DOWN\" | \"LEFT\" | \"RIGHT\";\n\tnodeSpacing: number;\n\tlayerSpacing: number;\n}\n\nconst defaultOptions: AutomaticLayoutOptions = {\n\tdirection: \"DOWN\",\n\tnodeSpacing: 80,\n\tlayerSpacing: 80,\n};\n\n/**\n * resolveAutomatic runs one compound ELK layout with exact measured sizes.\n * ELK errors and incomplete results are returned to the caller unchanged.\n */\nexport async function resolveAutomatic(\n\tdiagram: MeasuredDiagram,\n\toptions: Partial = {},\n): Promise {\n\tconst settings = {...defaultOptions, ...options};\n\tconst graph = buildLayoutTree(diagram, settings);\n\tconst ELK = await import(\"elkjs/lib/elk.bundled.js\").then(module => module.default);\n\tconst elk = new ELK();\n\tconst result = await elk.layout(graph);\n\treturn readResolvedLayout(diagram, result);\n}\n\n/**\n * buildLayoutTree creates one ELK tree. Nodes belong to their declared group,\n * groups belong to their declared parent, and each edge belongs to the nearest\n * group shared by both connected nodes.\n */\nfunction buildLayoutTree(\n\tdiagram: MeasuredDiagram,\n\toptions: AutomaticLayoutOptions,\n): ElkNode {\n\tconst nodes = new Map(diagram.nodes.map(node => [node.id, node]));\n\tconst groups = new Map(diagram.groups.map(group => [group.id, group]));\n\tcheckMeasuredLinks(diagram, nodes, groups);\n\n\tconst childrenByParent = new Map();\n\tfor (const node of diagram.nodes) {\n\t\tappend(childrenByParent, node.parentId, node);\n\t}\n\tconst groupsByParent = new Map();\n\tfor (const group of diagram.groups) {\n\t\tappend(groupsByParent, group.parentId, group);\n\t}\n\n\tconst elkGroups = new Map();\n\tconst buildGroup = (group: MeasuredGroup): ElkNode => {\n\t\tconst child: ElkNode = {\n\t\t\tid: group.id,\n\t\t\tchildren: [\n\t\t\t\t...(groupsByParent.get(group.id) ?? []).map(buildGroup),\n\t\t\t\t...(childrenByParent.get(group.id) ?? []).map(buildNode),\n\t\t\t],\n\t\t\tedges: [],\n\t\t\tlabels: [{\n\t\t\t\ttext: group.id,\n\t\t\t\twidth: group.titleSize.width,\n\t\t\t\theight: group.titleSize.height,\n\t\t\t}],\n\t\t\tlayoutOptions: groupLayoutOptions(options, group.titleSize.height),\n\t\t};\n\t\telkGroups.set(group.id, child);\n\t\treturn child;\n\t};\n\n\tconst root: ElkNode = {\n\t\tid: diagram.id,\n\t\tchildren: [\n\t\t\t...(groupsByParent.get(undefined) ?? []).map(buildGroup),\n\t\t\t...(childrenByParent.get(undefined) ?? []).map(buildNode),\n\t\t],\n\t\tedges: [],\n\t\tlayoutOptions: rootLayoutOptions(options),\n\t};\n\n\tfor (const edge of diagram.edges) {\n\t\tconst owner = lowestCommonGroup(edge, nodes, groups);\n\t\tconst container = owner ? elkGroups.get(owner) : root;\n\t\tif (!container) {\n\t\t\tthrow new Error(`edge ${edge.id} has missing layout group ${owner}`);\n\t\t}\n\t\tcontainer.edges?.push(buildEdge(edge));\n\t}\n\treturn root;\n}\n\n/** buildNode passes the measured node size to ELK without padding or guesses. */\nfunction buildNode(node: MeasuredNode): ElkNode {\n\treturn {\n\t\tid: node.id,\n\t\twidth: node.size.width,\n\t\theight: node.size.height,\n\t\tlayoutOptions: {\n\t\t\t\"elk.nodeSize.constraints\": \"FIXED_SIZE\",\n\t\t\t\"elk.portConstraints\": \"FREE\",\n\t\t},\n\t};\n}\n\n/** buildEdge passes the exact label size and stable endpoint IDs to ELK. */\nfunction buildEdge(edge: MeasuredEdge): ElkExtendedEdge {\n\treturn {\n\t\tid: edge.id,\n\t\tsources: [edge.sourceId],\n\t\ttargets: [edge.targetId],\n\t\tlabels: edge.labelSize ? [{\n\t\t\ttext: edge.id,\n\t\t\twidth: edge.labelSize.width,\n\t\t\theight: edge.labelSize.height,\n\t\t\tlayoutOptions: {\n\t\t\t\t\"elk.edgeLabels.inline\": \"false\",\n\t\t\t\t\"elk.edgeLabels.placement\": \"CENTER\",\n\t\t\t},\n\t\t}] : [],\n\t};\n}\n\n/** rootLayoutOptions set the rules shared by the full compound layout. */\nfunction rootLayoutOptions(options: AutomaticLayoutOptions): Record {\n\treturn {\n\t\t\"elk.algorithm\": \"layered\",\n\t\t\"elk.direction\": options.direction,\n\t\t\"elk.edgeRouting\": \"ORTHOGONAL\",\n\t\t\"elk.hierarchyHandling\": \"INCLUDE_CHILDREN\",\n\t\t\"elk.padding\": \"[top=40,left=40,bottom=40,right=40]\",\n\t\t\"elk.spacing.nodeNode\": String(options.nodeSpacing),\n\t\t\"elk.spacing.componentComponent\": String(options.nodeSpacing),\n\t\t\"elk.layered.spacing.nodeNodeBetweenLayers\": String(options.layerSpacing),\n\t\t\"elk.layered.spacing.edgeNodeBetweenLayers\": \"30\",\n\t\t\"elk.layered.spacing.edgeEdgeBetweenLayers\": \"20\",\n\t\t\"elk.layered.nodePlacement.strategy\": \"NETWORK_SIMPLEX\",\n\t\t\"elk.layered.nodePlacement.favorStraightEdges\": \"true\",\n\t\t\"elk.layered.crossingMinimization.strategy\": \"LAYER_SWEEP\",\n\t\t\"elk.layered.unnecessaryBendpoints\": \"true\",\n\t\t\"elk.edgeLabels.inline\": \"false\",\n\t\t\"elk.edgeLabels.avoidOverlap\": \"true\",\n\t\t\"elk.layered.edgeLabels.sideSelection\": \"SMART_DOWN\",\n\t\t\"elk.spacing.edgeLabel\": \"12\",\n\t};\n}\n\n/** groupLayoutOptions reserve title space and keep each group's children together. */\nfunction groupLayoutOptions(\n\toptions: AutomaticLayoutOptions,\n\ttitleHeight: number,\n): Record {\n\treturn {\n\t\t...rootLayoutOptions(options),\n\t\t\"elk.padding\": `[top=${titleHeight + 30},left=30,bottom=30,right=30]`,\n\t\t\"elk.nodeLabels.placement\": \"[H_LEFT,V_TOP,INSIDE]\",\n\t\t\"elk.spacing.labelNode\": \"10\",\n\t};\n}\n\n/**\n * checkMeasuredLinks rejects broken ownership and endpoints before calling ELK,\n * so ELK never has to guess what the model meant.\n */\nfunction checkMeasuredLinks(\n\tdiagram: MeasuredDiagram,\n\tnodes: Map,\n\tgroups: Map,\n): void {\n\tfor (const node of diagram.nodes) {\n\t\tif (node.parentId && !groups.has(node.parentId)) {\n\t\t\tthrow new Error(`node ${node.id} has missing parent group ${node.parentId}`);\n\t\t}\n\t}\n\tfor (const group of diagram.groups) {\n\t\tif (group.parentId && !groups.has(group.parentId)) {\n\t\t\tthrow new Error(`group ${group.id} has missing parent group ${group.parentId}`);\n\t\t}\n\t}\n\tfor (const edge of diagram.edges) {\n\t\tif (!nodes.has(edge.sourceId) || !nodes.has(edge.targetId)) {\n\t\t\tthrow new Error(\n\t\t\t\t`edge ${edge.id} connects missing node ${edge.sourceId} or ${edge.targetId}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** lowestCommonGroup finds the nearest boundary that contains both endpoints. */\nfunction lowestCommonGroup(\n\tedge: MeasuredEdge,\n\tnodes: Map,\n\tgroups: Map,\n): string | undefined {\n\tconst sourceGroups = parentGroups(nodes.get(edge.sourceId)?.parentId, groups);\n\tconst targetGroups = new Set(parentGroups(nodes.get(edge.targetId)?.parentId, groups));\n\treturn sourceGroups.find(group => targetGroups.has(group));\n}\n\n/** parentGroups returns parent IDs from nearest to farthest. */\nfunction parentGroups(\n\tparentId: string | undefined,\n\tgroups: Map,\n): string[] {\n\tconst result: string[] = [];\n\tlet current = parentId;\n\twhile (current) {\n\t\tresult.push(current);\n\t\tcurrent = groups.get(current)?.parentId;\n\t}\n\treturn result;\n}\n\n/** readResolvedLayout changes ELK's parent-relative values into diagram positions. */\nfunction readResolvedLayout(\n\tdiagram: MeasuredDiagram,\n\troot: ElkNode,\n): ResolvedLayout {\n\tif (root.width === undefined || root.height === undefined) {\n\t\tthrow new Error(`ELK did not size diagram ${diagram.id}`);\n\t}\n\tconst nodes: ResolvedNode[] = [];\n\tconst groups: ResolvedGroup[] = [];\n\tconst edges: ResolvedEdge[] = [];\n\tconst measuredNodes = new Map(diagram.nodes.map(node => [node.id, node]));\n\tconst measuredGroups = new Map(diagram.groups.map(group => [group.id, group]));\n\n\treadContainer(\n\t\troot,\n\t\t0,\n\t\t0,\n\t\tmeasuredNodes,\n\t\tmeasuredGroups,\n\t\tnodes,\n\t\tgroups,\n\t\tedges,\n\t);\n\treturn {\n\t\tdiagramId: diagram.id,\n\t\tbounds: {x: 0, y: 0, width: root.width, height: root.height},\n\t\tnodes,\n\t\tgroups,\n\t\tedges,\n\t};\n}\n\n/**\n * readContainer walks one ELK group, adding its parent's position exactly once\n * to each child, edge point, and label box.\n */\nfunction readContainer(\n\tcontainer: ElkNode,\n\tparentX: number,\n\tparentY: number,\n\tmeasuredNodes: Map,\n\tmeasuredGroups: Map,\n\tnodes: ResolvedNode[],\n\tgroups: ResolvedGroup[],\n\tedges: ResolvedEdge[],\n): void {\n\tconst containerX = parentX + (container.x ?? 0);\n\tconst containerY = parentY + (container.y ?? 0);\n\tfor (const child of container.children ?? []) {\n\t\tconst childX = containerX + requiredNumber(child.x, child.id, \"x\");\n\t\tconst childY = containerY + requiredNumber(child.y, child.id, \"y\");\n\t\tconst width = requiredNumber(child.width, child.id, \"width\");\n\t\tconst height = requiredNumber(child.height, child.id, \"height\");\n\t\tconst measuredNode = measuredNodes.get(child.id);\n\t\tif (measuredNode) {\n\t\t\tnodes.push({\n\t\t\t\tid: child.id,\n\t\t\t\tparentId: measuredNode.parentId,\n\t\t\t\tbounds: {x: childX, y: childY, width, height},\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst measuredGroup = measuredGroups.get(child.id);\n\t\tif (!measuredGroup) {\n\t\t\tthrow new Error(`ELK returned unknown node ${child.id}`);\n\t\t}\n\t\tconst label = requiredLabel(child.labels?.[0], child.id);\n\t\tgroups.push({\n\t\t\tid: child.id,\n\t\t\tparentId: measuredGroup.parentId,\n\t\t\tbounds: {x: childX, y: childY, width, height},\n\t\t\ttitleBounds: {\n\t\t\t\tx: childX + requiredNumber(label.x, child.id, \"title x\"),\n\t\t\t\ty: childY + requiredNumber(label.y, child.id, \"title y\"),\n\t\t\t\twidth: requiredNumber(label.width, child.id, \"title width\"),\n\t\t\t\theight: requiredNumber(label.height, child.id, \"title height\"),\n\t\t\t},\n\t\t});\n\t\treadContainer(\n\t\t\tchild,\n\t\t\tcontainerX,\n\t\t\tcontainerY,\n\t\t\tmeasuredNodes,\n\t\t\tmeasuredGroups,\n\t\t\tnodes,\n\t\t\tgroups,\n\t\t\tedges,\n\t\t);\n\t}\n\tfor (const edge of container.edges ?? []) {\n\t\tedges.push(readEdge(edge, containerX, containerY));\n\t}\n}\n\n/** readEdge copies every ELK section and label without choosing new positions. */\nfunction readEdge(edge: ElkExtendedEdge, offsetX: number, offsetY: number): ResolvedEdge {\n\tconst sections = (edge.sections ?? []).map(section => [\n\t\taddOffset(section.startPoint, offsetX, offsetY),\n\t\t...(section.bendPoints ?? []).map(point => addOffset(point, offsetX, offsetY)),\n\t\taddOffset(section.endPoint, offsetX, offsetY),\n\t]);\n\tconst label = edge.labels?.[0];\n\treturn {\n\t\tid: edge.id,\n\t\tsourceId: requiredEndpoint(edge.sources, edge.id, \"source\"),\n\t\ttargetId: requiredEndpoint(edge.targets, edge.id, \"target\"),\n\t\tsections,\n\t\tlabelBounds: label ? {\n\t\t\tx: offsetX + requiredNumber(label.x, edge.id, \"label x\"),\n\t\t\ty: offsetY + requiredNumber(label.y, edge.id, \"label y\"),\n\t\t\twidth: requiredNumber(label.width, edge.id, \"label width\"),\n\t\t\theight: requiredNumber(label.height, edge.id, \"label height\"),\n\t\t} : undefined,\n\t};\n}\n\n/** addOffset changes one parent-relative ELK point into a diagram point. */\nfunction addOffset(point: ElkPoint, offsetX: number, offsetY: number): Point {\n\treturn {x: offsetX + point.x, y: offsetY + point.y};\n}\n\n/** requiredNumber rejects incomplete ELK output instead of filling in zero. */\nfunction requiredNumber(\n\tvalue: number | undefined,\n\telementId: string,\n\tfield: string,\n): number {\n\tif (value === undefined) {\n\t\tthrow new Error(`ELK omitted ${field} for ${elementId}`);\n\t}\n\treturn value;\n}\n\n/** requiredEndpoint requires each MDL relationship to have exactly one endpoint. */\nfunction requiredEndpoint(\n\tendpoints: string[],\n\tedgeId: string,\n\tfield: string,\n): string {\n\tif (endpoints.length !== 1) {\n\t\tthrow new Error(`ELK returned ${endpoints.length} ${field}s for edge ${edgeId}`);\n\t}\n\treturn endpoints[0];\n}\n\n/** requiredLabel rejects a group whose measured title was not placed by ELK. */\nfunction requiredLabel(label: ElkLabel | undefined, groupId: string): ElkLabel {\n\tif (!label) {\n\t\tthrow new Error(`ELK omitted title for group ${groupId}`);\n\t}\n\treturn label;\n}\n\n/** append adds a child to one parent entry while keeping model order. */\nfunction append(\n\titems: Map,\n\tparentId: string | undefined,\n\titem: T,\n): void {\n\tconst siblings = items.get(parentId) ?? [];\n\tsiblings.push(item);\n\titems.set(parentId, siblings);\n}\n","// This file connects the editable graph to the layout pipeline. It measures\n// the current SVG once, asks ELK for one complete answer, validates that answer,\n// and returns positions without changing them.\n\nimport {resolveAutomatic} from \"./automatic-layout\";\nimport {\n\tMeasuredDiagram,\n\tMeasuredEdge,\n\tMeasuredGroup,\n\tMeasuredNode,\n\tRect,\n\tResolvedLayout,\n\tValidatedLayout,\n\tvalidateResolvedLayout,\n} from \"./geometry\";\nimport {Edge, GraphData, Group, LayoutDirection, Node} from \"./graph\";\nimport {calculateEdgeVertices} from \"./edge-utils\";\nimport {resolveManual} from \"./manual-layout\";\n\n/** LayoutOptions are the explicit choices available to editor and CLI callers. */\nexport interface LayoutOptions {\n\tdirection?: LayoutDirection;\n\tnodeSpacing?: number;\n\tlayerSpacing?: number;\n\tcompactLayout?: boolean;\n}\n\n/** GraphLayout carries checked positions back to the editable graph. */\nexport interface GraphLayout {\n\tvalidated: ValidatedLayout;\n\tnodes: Array<{id: string; x: number; y: number}>;\n\tgroups: Array<{id: string; bounds: Rect; titleBounds: Rect}>;\n\tedges: Array<{\n\t\tid: string;\n\t\tsections: Array>;\n\t\tlabelBounds?: Rect;\n\t}>;\n}\n\n/**\n * autoLayout measures, lays out, and validates a graph. It does not catch\n * errors because callers must not save a diagram after any failed step.\n */\nexport async function autoLayout(\n\tgraph: GraphData,\n\toptions: LayoutOptions = {},\n): Promise {\n\tawait document.fonts.ready;\n\tconst measured = measureGraph(graph);\n\tconst spacing = options.compactLayout ? 56 : 80;\n\tconst resolved = await resolveAutomatic(measured, {\n\t\tdirection: options.direction ?? graph.layoutDirection ?? \"DOWN\",\n\t\tnodeSpacing: options.nodeSpacing ?? spacing,\n\t\tlayerSpacing: options.layerSpacing ?? spacing,\n\t});\n\tconst validated = validateResolvedLayout(measured, resolved);\n\tconst measuredNodes = new Map(measured.nodes.map(node => [node.id, node]));\n\treturn {\n\t\tvalidated,\n\t\tnodes: validated.nodes.map(node => {\n\t\t\tconst measuredNode = measuredNodes.get(node.id);\n\t\t\tif (!measuredNode) {\n\t\t\t\tthrow new Error(`validated layout contains unknown node ${node.id}`);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tid: node.id,\n\t\t\t\tx: node.bounds.x + measuredNode.centerOffset.x,\n\t\t\t\ty: node.bounds.y + measuredNode.centerOffset.y,\n\t\t\t};\n\t\t}),\n\t\tgroups: validated.groups.map(group => ({\n\t\t\tid: group.id,\n\t\t\tbounds: group.bounds,\n\t\t\ttitleBounds: group.titleBounds,\n\t\t})),\n\t\tedges: validated.edges.map(edge => ({\n\t\t\tid: edge.id,\n\t\t\tsections: edge.sections,\n\t\t\tlabelBounds: edge.labelBounds,\n\t\t})),\n\t};\n}\n\n/**\n * validateCurrentLayout adapts the fully drawn editor state into the manual\n * layout contract. It never reads automatic positions to fill missing data.\n */\nexport function validateCurrentLayout(graph: GraphData): ValidatedLayout {\n\tconst measured = measureGraph(graph);\n\tconst measuredNodes = new Map(measured.nodes.map(node => [node.id, node]));\n\tconst nodes = graph.nodes().map(node => {\n\t\tconst measuredNode = measuredNodes.get(node.id);\n\t\tif (!measuredNode) {\n\t\t\tthrow new Error(`measured diagram omitted node ${node.id}`);\n\t\t}\n\t\treturn {\n\t\t\tid: node.id,\n\t\t\tparentId: measuredNode.parentId,\n\t\t\tbounds: {\n\t\t\t\tx: node.x - measuredNode.centerOffset.x,\n\t\t\t\ty: node.y - measuredNode.centerOffset.y,\n\t\t\t\t...measuredNode.size,\n\t\t\t},\n\t\t};\n\t});\n\tconst groups = Array.from(graph.groupsMap.values()).map(group => {\n\t\tif (!group.ref?.isConnected) {\n\t\t\tthrow new Error(`group ${group.id} must be drawn before saving`);\n\t\t}\n\t\tconst boundary = group.ref.querySelector(\"rect\");\n\t\tconst title = group.ref.querySelector(\"text\");\n\t\tif (!(boundary instanceof SVGGraphicsElement) || !(title instanceof SVGGraphicsElement)) {\n\t\t\tthrow new Error(`group ${group.id} is missing its boundary or title`);\n\t\t}\n\t\treturn {\n\t\t\tid: group.id,\n\t\t\tparentId: measured.groups.find(candidate => candidate.id === group.id)?.parentId,\n\t\t\tbounds: copyBox(boundary.getBBox()),\n\t\t\ttitleBounds: copyBox(title.getBBox()),\n\t\t};\n\t});\n\tconst edges = graph.edges.map(edge => {\n\t\tconst sections = edge.layoutSections ?? [calculateEdgeVertices(edge)];\n\t\tconst labelBounds = edge.layoutLabelBounds ?? edge.labelBounds;\n\t\tif (edge.label.trim().length > 0 && !labelBounds) {\n\t\t\tthrow new Error(`edge ${edge.id} is missing its label position`);\n\t\t}\n\t\treturn {\n\t\t\tid: edge.id,\n\t\t\tsourceId: edge.from.id,\n\t\t\ttargetId: edge.to.id,\n\t\t\tsections,\n\t\t\tlabelBounds: labelBounds ? {...labelBounds} : undefined,\n\t\t};\n\t});\n\tconst snapshot: ResolvedLayout = {\n\t\tdiagramId: graph.id,\n\t\tbounds: contentBounds(nodes.map(node => node.bounds), groups, edges),\n\t\tnodes,\n\t\tgroups,\n\t\tedges,\n\t};\n\treturn resolveManual(measured, snapshot);\n}\n\n/**\n * measureGraph reads the exact node and label boxes already drawn by the\n * browser. Parent IDs come only from the model's declared groups.\n */\nfunction measureGraph(graph: GraphData): MeasuredDiagram {\n\tconst {nodeParents, groupParents} = declaredParents(graph);\n\treturn {\n\t\tid: graph.id,\n\t\tnodes: graph.nodes().map(node => measureNode(node, nodeParents.get(node.id))),\n\t\tgroups: Array.from(graph.groupsMap.values()).map(group =>\n\t\t\tmeasureGroup(group, groupParents.get(group.id)),\n\t\t),\n\t\tedges: graph.edges.map(measureEdge),\n\t};\n}\n\n/** measureNode returns the complete box drawn for one node and its center. */\nfunction measureNode(node: Node, parentId: string | undefined): MeasuredNode {\n\tif (!node.ref?.isConnected) {\n\t\tthrow new Error(`node ${node.id} must be drawn before layout`);\n\t}\n\tconst bounds = node.ref.getBBox();\n\tcheckMeasuredBox(node.id, bounds);\n\treturn {\n\t\tid: node.id,\n\t\tparentId,\n\t\tsize: {width: bounds.width, height: bounds.height},\n\t\tcontentSize: {width: bounds.width, height: bounds.height},\n\t\tcenterOffset: {x: -bounds.x, y: -bounds.y},\n\t\tshape: node.style.shape ?? \"Box\",\n\t};\n}\n\n/** measureGroup reads the title box already drawn by the browser. */\nfunction measureGroup(group: Group, parentId: string | undefined): MeasuredGroup {\n\tif (!group.ref?.isConnected) {\n\t\tthrow new Error(`group ${group.id} must be drawn before layout`);\n\t}\n\tconst title = group.ref.querySelector(\"text\");\n\tif (!(title instanceof SVGGraphicsElement)) {\n\t\tthrow new Error(`group ${group.id} is missing its drawn title`);\n\t}\n\tconst bounds = title.getBBox();\n\tcheckMeasuredBox(group.id, bounds);\n\treturn {\n\t\tid: group.id,\n\t\tparentId,\n\t\ttitleSize: {width: bounds.width, height: bounds.height},\n\t};\n}\n\n/** measureEdge uses the label background that the current SVG already drew. */\nfunction measureEdge(edge: Edge): MeasuredEdge {\n\tconst hasLabel = edge.label.trim().length > 0;\n\tif (hasLabel && !edge.labelBounds) {\n\t\tthrow new Error(`edge ${edge.id} must be drawn before layout`);\n\t}\n\treturn {\n\t\tid: edge.id,\n\t\tsourceId: edge.from.id,\n\t\ttargetId: edge.to.id,\n\t\tlabelSize: hasLabel ? {\n\t\t\twidth: edge.labelBounds?.width ?? 0,\n\t\t\theight: edge.labelBounds?.height ?? 0,\n\t\t} : undefined,\n\t};\n}\n\n/**\n * declaredParents records model ownership and rejects elements that appear in\n * more than one group. Visual position never decides ownership.\n */\nfunction declaredParents(graph: GraphData): {\n\tnodeParents: Map;\n\tgroupParents: Map;\n} {\n\tconst nodeParents = new Map();\n\tconst groupParents = new Map();\n\tfor (const group of graph.groupsMap.values()) {\n\t\tfor (const member of group.nodes) {\n\t\t\tconst parents = isGroup(member) ? groupParents : nodeParents;\n\t\t\tconst existing = parents.get(member.id);\n\t\t\tif (existing && existing !== group.id) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${isGroup(member) ? \"group\" : \"node\"} ${member.id} belongs to both ` +\n\t\t\t\t\t`${existing} and ${group.id}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tparents.set(member.id, group.id);\n\t\t}\n\t}\n\treturn {nodeParents, groupParents};\n}\n\n/** checkMeasuredBox rejects missing or invalid browser measurements. */\nfunction checkMeasuredBox(id: string, box: Rect): void {\n\tif (\n\t\t!Number.isFinite(box.x) ||\n\t\t!Number.isFinite(box.y) ||\n\t\t!Number.isFinite(box.width) ||\n\t\t!Number.isFinite(box.height) ||\n\t\tbox.width <= 0 ||\n\t\tbox.height <= 0\n\t) {\n\t\tthrow new Error(`browser returned invalid measured box for ${id}`);\n\t}\n}\n\n/** contentBounds returns the smallest box that contains all drawn geometry. */\nfunction contentBounds(\n\tnodes: Rect[],\n\tgroups: Array<{bounds: Rect; titleBounds: Rect}>,\n\tedges: Array<{sections: Array>; labelBounds?: Rect}>,\n): Rect {\n\tconst boxes = [\n\t\t...nodes,\n\t\t...groups.flatMap(group => [group.bounds, group.titleBounds]),\n\t\t...edges.flatMap(edge => edge.labelBounds ? [edge.labelBounds] : []),\n\t];\n\tconst points = edges.flatMap(edge => edge.sections.flat());\n\tif (boxes.length === 0 && points.length === 0) {\n\t\treturn {x: 0, y: 0, width: 0, height: 0};\n\t}\n\tconst left = Math.min(\n\t\t...boxes.map(box => box.x),\n\t\t...points.map(point => point.x),\n\t);\n\tconst top = Math.min(\n\t\t...boxes.map(box => box.y),\n\t\t...points.map(point => point.y),\n\t);\n\tconst right = Math.max(\n\t\t...boxes.map(box => box.x + box.width),\n\t\t...points.map(point => point.x),\n\t);\n\tconst bottom = Math.max(\n\t\t...boxes.map(box => box.y + box.height),\n\t\t...points.map(point => point.y),\n\t);\n\treturn {x: left, y: top, width: right - left, height: bottom - top};\n}\n\n/** copyBox copies the browser's read-only SVG box into the layout contract. */\nfunction copyBox(box: DOMRect): Rect {\n\treturn {x: box.x, y: box.y, width: box.width, height: box.height};\n}\n\n/** isGroup tells group boundaries from nodes without using display names. */\nfunction isGroup(member: Node | Group): member is Group {\n\treturn \"nodes\" in member;\n}\n","// Manual layout has its own entry point. It never fills missing positions from\n// automatic layout and never changes the positions a user authored.\n\nimport {\n\tMeasuredDiagram,\n\tResolvedLayout,\n\tValidatedLayout,\n\tvalidateResolvedLayout,\n} from \"./geometry\";\n\n/**\n * resolveManual checks one complete saved layout against the current measured\n * diagram. Missing or old IDs, incomplete routes, and collisions are errors.\n */\nexport function resolveManual(\n\tmeasured: MeasuredDiagram,\n\tcompleteSnapshot: ResolvedLayout,\n): ValidatedLayout {\n\treturn validateResolvedLayout(measured, completeSnapshot);\n}\n","type TextAttributes = Record;\n\ninterface TextSize {\n\twidth: number;\n\theight: number;\n}\n\n/** WrappedText contains the exact lines and widest rendered line. */\nexport interface WrappedText {\n\tlines: string[];\n\tmaxW: number;\n}\n\nconst measuredText = new Map();\nlet measurementSVG: SVGSVGElement | undefined;\n\n/** loadDiagramFonts completes local font loading before text is wrapped or measured. */\nexport async function loadDiagramFonts(): Promise {\n\tawait Promise.all([400, 600, 700].map(weight => document.fonts.load(`${weight} 22px Inter`)));\n\tawait document.fonts.ready;\n}\n\n/**\n * measureSVGText returns the browser's rendered text size. Results are cached\n * because node and edge layout often measures the same words many times.\n */\nexport function measureSVGText(text: string, attrs: TextAttributes): TextSize {\n\tconst key = measurementKey(text, attrs);\n\tconst cached = measuredText.get(key);\n\tif (cached) {\n\t\treturn cached;\n\t}\n\n\tconst node = document.createElementNS(\"http://www.w3.org/2000/svg\", \"text\");\n\tnode.setAttribute(\"x\", \"0\");\n\tnode.setAttribute(\"y\", \"0\");\n\tfor (const [name, value] of Object.entries(attrs)) {\n\t\tnode.setAttribute(name, value);\n\t}\n\tnode.textContent = text;\n\n\tconst svg = getMeasurementSVG();\n\tsvg.appendChild(node);\n\tconst bounds = node.getBBox();\n\tnode.remove();\n\tconst size = {width: bounds.width, height: bounds.height};\n\tmeasuredText.set(key, size);\n\treturn size;\n}\n\n/**\n * svgTextWrap splits text into lines that fit the given width. It uses the\n * same browser text sizes that SVG drawing uses.\n */\nexport function svgTextWrap(\n\ttext: string,\n\twidth: number,\n\tattrs: TextAttributes,\n): WrappedText {\n\tlet maxW = 0;\n\tconst lines = text.trim().split(\"\\n\").flatMap(paragraph => {\n\t\tconst paragraphLines: string[] = [];\n\t\tlet currentLine: string[] = [];\n\t\tfor (const word of paragraph.trim().split(/\\s+/)) {\n\t\t\tif (measureSVGText(word, attrs).width > width) {\n\t\t\t\tif (currentLine.length > 0) {\n\t\t\t\t\tparagraphLines.push(currentLine.join(\" \"));\n\t\t\t\t\tcurrentLine = [];\n\t\t\t\t}\n\t\t\t\tconst parts = breakLongWord(word, width, attrs);\n\t\t\t\tfor (const part of parts.slice(0, -1)) {\n\t\t\t\t\tparagraphLines.push(part);\n\t\t\t\t\tmaxW = Math.max(maxW, measureSVGText(part, attrs).width);\n\t\t\t\t}\n\t\t\t\tcurrentLine = parts.slice(-1);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst nextLine = [...currentLine, word];\n\t\t\tconst size = measureSVGText(nextLine.join(\" \"), attrs);\n\t\t\tif (size.width > width && currentLine.length > 0) {\n\t\t\t\tparagraphLines.push(currentLine.join(\" \"));\n\t\t\t\tcurrentLine = [word];\n\t\t\t} else {\n\t\t\t\tmaxW = Math.max(maxW, size.width);\n\t\t\t\tcurrentLine = nextLine;\n\t\t\t}\n\t\t}\n\t\tif (currentLine.length > 0) {\n\t\t\tconst line = currentLine.join(\" \");\n\t\t\tparagraphLines.push(line);\n\t\t\tmaxW = Math.max(maxW, measureSVGText(line, attrs).width);\n\t\t}\n\t\treturn paragraphLines;\n\t});\n\treturn {lines, maxW};\n}\n\n/** getMeasurementSVG creates the single hidden SVG used for text measurement. */\nfunction getMeasurementSVG(): SVGSVGElement {\n\tif (measurementSVG?.isConnected) {\n\t\treturn measurementSVG;\n\t}\n\tmeasurementSVG = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n\tmeasurementSVG.setAttribute(\"aria-hidden\", \"true\");\n\tmeasurementSVG.style.position = \"absolute\";\n\tmeasurementSVG.style.visibility = \"hidden\";\n\tmeasurementSVG.style.pointerEvents = \"none\";\n\tdocument.body.appendChild(measurementSVG);\n\treturn measurementSVG;\n}\n\n/** measurementKey gives equal text and font settings the same cache entry. */\nfunction measurementKey(text: string, attrs: TextAttributes): string {\n\tconst attributes = Object.entries(attrs).sort(([first], [second]) =>\n\t\tfirst.localeCompare(second),\n\t);\n\treturn JSON.stringify([text, attributes]);\n}\n\n/** breakLongWord splits one word only when it cannot fit on an empty line. */\nfunction breakLongWord(\n\tword: string,\n\tmaxWidth: number,\n\tattrs: TextAttributes,\n): string[] {\n\tconst parts: string[] = [];\n\tlet currentPart = \"\";\n\tfor (const character of word) {\n\t\tconst nextPart = currentPart + character;\n\t\tif (measureSVGText(nextPart, attrs).width > maxWidth && currentPart.length > 0) {\n\t\t\tparts.push(currentPart);\n\t\t\tcurrentPart = character;\n\t\t} else {\n\t\t\tcurrentPart = nextPart;\n\t\t}\n\t}\n\tif (currentPart.length > 0) {\n\t\tparts.push(currentPart);\n\t}\n\treturn parts;\n}\n\n\n","import {GraphData, LayoutDirection, NodeLink} from \"./graph-view/graph\";\nimport {EdgeStyle, NodeStyle} from \"./graph-view/constants\";\n\n\ninterface Model {\n\tname: string\n\tdescription: string\n\tversion: string\n\tmodel: {\n\t\tenterprise: {\n\t\t\tname: string\n\t\t}\n\t\tpeople: Element[]\n\t\tsoftwareSystems: Element[]\n\t\tdeploymentNodes: Element[]\n\t}\n\tviews: {\n\t\tsystemLandscapeViews: View[]\n\t\tcontainerViews: View[]\n\t\tcomponentViews: View[]\n\t\tdynamicViews: View[]\n\t\tdeploymentViews: View[]\n\t\tstyles: {\n\t\t\telements: (NodeStyle & {tag: string})[];\n\t\t\trelationships: (EdgeStyle & {tag: string})[];\n\t\t}\n\t}\n}\n\ninterface Layouts {\n\t[key: string]: { // keyed by view key\n\t\t[key: string]: { x: number; y: number } // keyed by element id\n\t}\n}\n\ninterface Element {\n\tid: string;\n\tname: string;\n\ttechnology?: string;\n\tdescription?: string;\n\turl?: string;\n\tparent?: Element;\n\ttags?: string;\n\tlocation?: string;\n\tcontainers?: Element[];\n\tcomponents?: Element[];\n\trelationships?: Relation[];\n\tproperties?: { [key: string]: string }\n\tchildren?: Element[];\n\tinfrastructureNodes?: Element[];\n}\n\ninterface Relation {\n\tid: string;\n\tdescription: string;\n\ttags: string;\n\tsourceId: string;\n\tdestinationId: string;\n\ttechnology: string;\n\tinteractionStyle: string;\n}\n\ntype RankDirection = 'TopBottom' | 'BottomTop' | 'LeftRight' | 'RightLeft';\n\ninterface View {\n\tkey: string;\n\ttitle: string;\n\tdescription: string\n\tautomaticLayout?: {\n\t\trankDirection?: RankDirection;\n\t};\n\telements: {\n\t\tid: string\n\t}[];\n\trelationships: {\n\t\tid: string;\n\t\tvertices: { x: number; y: number }[];\n\t\trouting: string; // takes priority over style\n\t}[];\n\tsoftwareSystemId?: string;\n\tcontainerId?: string;\n\texternalContainersBoundariesVisible?: boolean;\n}\n\nconst layoutDirections: Record = {\n\tTopBottom: 'DOWN',\n\tBottomTop: 'UP',\n\tLeftRight: 'RIGHT',\n\tRightLeft: 'LEFT',\n};\n\ninterface Metadata {\n\tname: string\n\tdescription: string\n\tversion: string\n\telements: {\n\t\tid: string\n\t\ttags?: string;\n\t\tlocation?: string;\n\t\tproperties?: { [key: string]: string };\n\t\telementViewKey?: string;\n\t\ttechnology?: string;\n\t\turl?: string;\n\t}[]\n}\n\nexport type ViewsList = {\n\tkey: string;\n\ttitle: string;\n\tsection: string;\n}[]\n\nexport const parseView = (model: Model, layouts: Layouts, viewKey: string) => {\n\n\tconst elements = new Map();\n\tconst relations = new Map();\n\n\tconst collectRels = (el: Element) => {\n\t\tif (Array.isArray(el.relationships)) {\n\t\t\tel.relationships.forEach(rel => {\n\t\t\t\trelations.set(rel.id, rel)\n\t\t\t})\n\t\t}\n\t}\n\n\t// People\n\tmodel.model.people && model.model.people.forEach((el: Element) => {\n\t\telements.set(el.id, el)\n\t\tif (Array.isArray(el.relationships)) {\n\t\t\tel.relationships.forEach(rel => {\n\t\t\t\trelations.set(rel.id, rel)\n\t\t\t})\n\t\t}\n\t})\n\t// Software Systems\n\tmodel.model.softwareSystems && model.model.softwareSystems.forEach((el: Element) => {\n\t\telements.set(el.id, el)\n\t\tcollectRels(el)\n\n\t\tif (Array.isArray(el.containers)) {\n\t\t\tel.containers.forEach((el1: Element) => {\n\t\t\t\tel1.parent = el;\n\t\t\t\telements.set(el1.id, el1)\n\t\t\t\tcollectRels(el1)\n\t\t\t\tif (Array.isArray(el1.components)) {\n\t\t\t\t\tel1.components.forEach((el2: Element) => {\n\t\t\t\t\t\tel2.parent = el1;\n\t\t\t\t\t\telements.set(el2.id, el2)\n\t\t\t\t\t\tcollectRels(el2)\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t})\n\n\t// Deployment Nodes\n\tif (model.model.deploymentNodes) {\n\t\tconst containerInstances = (el: any) => {\n\t\t\tel.containerInstances && el.containerInstances.forEach((item: any) => {\n\t\t\t\tconst el1 = {...elements.get(item.containerId), id: item.id}\n\t\t\t\telements.set(el1.id, el1)\n\t\t\t\tel1.parent = el\n\t\t\t\tcollectRels(item)\n\t\t\t})\n\t\t}\n\n\t\tconst recAddNodes = (el: Element, parent: Element) => {\n\t\t\tel.parent = parent;\n\t\t\telements.set(el.id, el)\n\t\t\tcollectRels(el)\n\t\t\tcontainerInstances(el)\n\t\t\tel.children && el.children.forEach((el1: Element) => recAddNodes(el1, el))\n\t\t\tel.infrastructureNodes && el.infrastructureNodes.forEach((el1: Element) => recAddNodes(el1, el))\n\t\t}\n\n\t\tmodel.model.deploymentNodes.forEach((el: Element) => recAddNodes(el, null))\n\t}\n\n\t// Create graph from selected view\n\tconst {view, section} = getView(model, viewKey)\n\n\tif (!view) return null\n\n\tconst graph = new GraphData(view.key, view.title || view.key)\n\tconst rankDirection = view.automaticLayout?.rankDirection\n\tgraph.layoutDirection = rankDirection ? layoutDirections[rankDirection] : undefined\n\tconst metadata: Metadata = {name: graph.name, description: view.description, version: model.version, elements: []}\n\tgraph.metadata = metadata\n\n\tif (!view.elements) return graph\n\n\t//grouping rules - elements that are groups will not be nodes\n\tconst groupingIDs: { [key: string]: boolean } = {}\n\tif (section == 'deploymentViews' || section == 'containerViews') {\n\t\tview.elements.forEach(ref => {\n\t\t\tconst el = elements.get(ref.id)\n\t\t\tif (el?.parent) {\n\t\t\t\tgroupingIDs[el.parent.id] = true\n\t\t\t}\n\t\t})\n\t} else if (section === 'componentViews') {\n\t\t// Selected components belong to the view's container. Other containers\n\t\t// receive boundaries only when the view requests them.\n\t\tview.elements.forEach(ref => {\n\t\t\tconst parent = elements.get(ref.id)?.parent;\n\t\t\tif (!parent?.components) return;\n\t\t\tif (parent.id !== view.containerId && !view.externalContainersBoundariesVisible) return;\n\t\t\t// A container listed as a node keeps its own relationships; it cannot\n\t\t\t// also be replaced by a group with the same identifier.\n\t\t\tif (!view.elements.some(candidate => candidate.id === parent.id)) {\n\t\t\t\tgroupingIDs[parent.id] = true;\n\t\t\t}\n\t\t});\n\t} else if (view.softwareSystemId) {\n\t\t//don't show grouping if the element is listed in the view\n\t\tif (!view.elements.find(ref => ref.id == view.softwareSystemId))\n\t\t\tgroupingIDs[view.softwareSystemId] = true\n\t} else if (section == 'systemLandscapeViews') {\n\t\t// create a virtual parent element from enterprise\n\t\tconst p: Element = {id: '__enterprise__', ...model.model.enterprise}\n\t\telements.set(p.id, p)\n\t\tif (model.model.people) model.model.people.filter(el => el.location != 'External').forEach(el => el.parent = p)\n\t\tif (model.model.softwareSystems) model.model.softwareSystems.filter(el => el.location != 'External').forEach(el => el.parent = p)\n\t\tgroupingIDs[p.id] = true\n\t}\n\n\tconst styles = model.views.styles\n\n\t// Build color-to-variable mapping for CSS custom properties theming\n\tconst cssClassName = (tag: string) => tag.toLowerCase().replace(/[^a-z0-9-]/g, '-')\n\t\n\tif (styles?.elements) {\n\t\tstyles.elements.forEach(s => {\n\t\t\tif (s.tag) {\n\t\t\t\tconst varPrefix = `--mdl-${cssClassName(s.tag)}`\n\t\t\t\tif (s.background) graph.colorToVarMap.set(s.background as string, `${varPrefix}-bg`)\n\t\t\t\tif (s.color) graph.colorToVarMap.set(s.color as string, `${varPrefix}-color`)\n\t\t\t\tif (s.stroke) graph.colorToVarMap.set(s.stroke as string, `${varPrefix}-stroke`)\n\t\t\t}\n\t\t})\n\t}\n\n\tif (styles?.relationships) {\n\t\tstyles.relationships.forEach(s => {\n\t\t\tif (s.tag) {\n\t\t\t\tconst varPrefix = `--mdl-rel-${cssClassName(s.tag)}`\n\t\t\t\tif (s.color) graph.colorToVarMap.set(s.color as string, `${varPrefix}-color`)\n\t\t\t}\n\t\t})\n\t}\n\n\t//nodes\n\tview.elements.forEach((ref) => {\n\t\t// except grouping elements\n\t\tif (groupingIDs[ref.id]) return\n\n\t\tconst el = elements.get(ref.id)\n\t\tconst elementViewKey = el ? lookupContainerViewKey(model, el.id) : undefined\n\n\t\tlet sub = ''\n\t\tlet style = {}\n\t\tif (el) {\n\t\t\tconst tags = el.tags.split(',')\n\t\t\tsub = tags[tags.length - 1] // subtitle is []\n\t\t\tif (el.technology)\n\t\t\t\tsub += ': ' + el.technology // or [: ]\n\n\t\t\ttags.forEach(tag => {\n\t\t\t\tconst s = styles && styles.elements && styles.elements.find(s => s.tag == tag)\n\t\t\t\ts && (style = {...style, ...s})\n\t\t\t})\n\t\t}\n\n\t\tgraph.addNode(\n\t\t\tref.id,\n\t\t\tel ? (el.name || ref.id) : ref.id,\n\t\t\tsub,\n\t\t\t(el && el.description) ? el.description : '',\n\t\t\tstyle,\n\t\t\tnodeLink(el, elementViewKey)\n\t\t)\n\t\tel && metadata.elements.push({\n\t\t\tid: el.id,\n\t\t\ttags: el.tags,\n\t\t\tlocation: el.location,\n\t\t\tproperties: el.properties,\n\t\t\telementViewKey,\n\t\t\ttechnology: el.technology,\n\t\t\turl: el.url\n\t\t})\n\t})\n\t//edges\n\tif (Array.isArray(view.relationships)) {\n\t\tview.relationships.forEach(ref => {\n\t\t\tconst rel = relations.get(ref.id)\n\t\t\tif (!rel) return;\n\n\t\t\tif (!graph.nodesMap.has(rel.sourceId)) {\n\t\t\t\tif (elements.has(rel.sourceId)) {\n\t\t\t\t\tconst el = elements.get(rel.sourceId)\n\t\t\t\t\tconsole.warn('Element not found in this view: ', el.id, el.name)\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('Element not found: ', rel.sourceId)\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!graph.nodesMap.has(rel.destinationId)) {\n\t\t\t\tif (elements.has(rel.destinationId)) {\n\t\t\t\t\tconst el = elements.get(rel.destinationId)\n\t\t\t\t\tconsole.warn('Element not found in this view: ', el.id, el.name)\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('Element not found: ', rel.destinationId)\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet style: any = {}\n\t\t\trel.tags.split(',').forEach(tag => {\n\t\t\t\tconst s = styles && styles.relationships && styles.relationships.find(s => s.tag == tag)\n\t\t\t\ts && (style = {...style, ...s})\n\t\t\t})\n\t\t\tif (ref.routing) style.routing = ref.routing\n\n\t\t\tconst label = rel.technology ? `${rel.description}\\n[${rel.technology}]` : rel.description\n\t\t\tgraph.addEdge(rel.id, rel.sourceId, rel.destinationId, label, ref.vertices, style)\n\t\t})\n\t}\n\n\t//groups\n\t//sort by depth to solve dependency\n\tconst level = (el: Element) => {\n\t\tlet i = 0\n\t\tfor (let p = el.parent; p; p = p.parent) i++;\n\t\treturn i\n\t}\n\tconst gElements = Object.keys(groupingIDs)\n\t\t.map(id => elements.get(id))\n\t\t.sort((a, b) => level(a) > level(b) ? -1 : 1)\n\n\tgElements.forEach(parent => {\n\t\tlet style = {}\n\t\tif (section == 'deploymentViews') {\n\t\t\tconst el = elements.get(parent.id)\n\t\t\tconst tags = el.tags.split(',')\n\t\t\ttags.forEach(tag => {\n\t\t\t\tconst s = styles && styles.elements && styles.elements.find(s => s.tag == tag)\n\t\t\t\ts && (style = {...style, ...s})\n\t\t\t})\n\t\t}\n\t\t\n\t\t// Filter group members more carefully to respect boundaries\n\t\tconst groupMembers = view.elements\n\t\t\t.map(ref => elements.get(ref.id))\n\t\t\t.filter(el => {\n\t\t\t\tif (!el || el.parent !== parent) return false;\n\t\t\t\t\n\t\t\t\t// For system landscape views, respect the location-based grouping\n\t\t\t\tif (section === 'systemLandscapeViews' && parent.id === '__enterprise__') {\n\t\t\t\t\t// Only include elements that are explicitly non-external\n\t\t\t\t\treturn el.location !== 'External';\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// For other view types, include if parent matches\n\t\t\t\treturn true;\n\t\t\t})\n\t\t\t.map(el => el.id);\n\t\t\n\t\t// Only create group if it has members\n\t\tif (groupMembers.length > 0) {\n\t\t\tgraph.addGroup(\n\t\t\t\tparent.id,\n\t\t\t\tparent.name,\n\t\t\t\tgroupMembers,\n\t\t\t\tstyle\n\t\t\t)\n\t\t}\n\t})\n\n\t//layout if any and init graph\n\tgraph.init(layouts[graph.id])\n\treturn graph\n}\n\nfunction nodeLink(element: Element | undefined, elementViewKey: string | undefined): NodeLink | undefined {\n\tif (elementViewKey) {\n\t\tconst encodedViewKey = encodeURIComponent(elementViewKey)\n\t\treturn {\n\t\t\thref: `?id=${encodedViewKey}`,\n\t\t\texportHref: `${encodedViewKey}.svg`,\n\t\t}\n\t}\n\tif (element?.url) {\n\t\treturn {\n\t\t\thref: element.url,\n\t\t\texportHref: element.url,\n\t\t}\n\t}\n\treturn undefined\n}\n\n// lookup the view in all Views sections in the model. return the view and the section\nfunction getView(model: Model, viewKey: string) {\n\tlet view: View = null, section: string = ''\n\tObject.keys(model.views).filter(s => s.endsWith('Views')).some((s: string) => {\n\t\treturn ((model.views as any)[s]).some((v: View) => {\n\t\t\tif (v.key == viewKey) {\n\t\t\t\tview = v\n\t\t\t\tsection = s\n\t\t\t\treturn true\n\t\t\t}\n\t\t})\n\t})\n\treturn {view, section}\n}\n\n\nfunction lookupContainerViewKey(model: Model, softwareSystemId: string) {\n\tconst view = model.views.containerViews?.find(candidate => candidate.softwareSystemId == softwareSystemId)\n\treturn view?.key\n}\n\nexport const listViews = (model: any) => {\n\tconst viewsList: ViewsList = []\n\tconst sections = Object.keys(model.views).filter(section => section.endsWith('Views'))\n\tsections.forEach(s => {\n\t\tmodel.views[s].forEach((v: View) => {\n\t\t\tviewsList.push({key: v.key, title: v.title || v.key, section: s})\n\t\t})\n\t})\n\treturn viewsList;\n}\n","import React, {FC} from \"react\";\nimport { isMac, getModifierKeyName, getModifierKeyProperty } from './utils/platform';\n\ninterface Combination {\n\tctrl?: boolean;\n\tshift?: boolean;\n\talt?: boolean;\n\twheel?: boolean\n\tkey?: string;\n\tclick?: boolean;\n}\n\ninterface Shortcut {\n\tid: string,\n\thelp: string,\n\tcombinations: Combination[]\n}\n\nexport const SAVE = 'save'\n\nexport const UNDO = 'undo'\nexport const REDO = 'redo'\nexport const ADD_VERTEX = 'add-vertex'\nexport const ADD_LABEL_VERTEX = 'add-label-vertex'\nexport const DEL_VERTEX = 'del-vertex'\n\nexport const ZOOM_IN = 'zoom-in'\nexport const ZOOM_OUT = 'zoom-out'\nexport const ZOOM_FIT = 'zoom-fit'\nexport const ZOOM_100 = 'zoom-100'\n\nexport const SELECT_ALL = 'select-all'\nexport const DESELECT = 'deselect'\n\nexport const MOVE_LEFT = 'move-left'\nexport const MOVE_RIGHT = 'move-right'\nexport const MOVE_UP = 'move-up'\nexport const MOVE_DOWN = 'move-down'\nexport const MOVE_LEFT_FINE = 'move-left-fine'\nexport const MOVE_RIGHT_FINE = 'move-right-fine'\nexport const MOVE_UP_FINE = 'move-up-fine'\nexport const MOVE_DOWN_FINE = 'move-down-fine'\n\nexport const PAN_VIEW = 'pan-view'\nexport const SELECT_ELEMENT = 'select-element'\nexport const MULTI_SELECT = 'multi-select'\nexport const BOX_SELECT = 'box-select'\nexport const MOVE_ELEMENTS = 'move-elements'\n\nexport const HELP = 'help'\n\n// New shortcuts for toolbar buttons\nexport const TOGGLE_DRAG_MODE = 'toggle_drag_mode'\nexport const ALIGN_HORIZONTAL = 'align_horizontal'\nexport const ALIGN_VERTICAL = 'align_vertical'\nexport const DISTRIBUTE_HORIZONTAL = 'distribute_horizontal'\nexport const DISTRIBUTE_VERTICAL = 'distribute_vertical'\nexport const AUTO_LAYOUT = 'auto_layout'\nexport const RESET_POSITION = 'reset_position'\nexport const TOGGLE_GRID = 'toggle_grid'\nexport const TOGGLE_SNAP_TO_GRID = 'toggle_snap_to_grid'\nexport const SNAP_ALL_TO_GRID = 'snap_all_to_grid'\n\nconst shortcuts: { name: string; list: Shortcut[] }[] = [\n\t{\n\t\tname: 'Help',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: HELP,\n\t\t\t\thelp: 'Show/hide this help',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{key: '?', shift: true},\n\t\t\t\t\t{key: 'F1', shift: true}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'File',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: SAVE,\n\t\t\t\thelp: 'Save',\n\t\t\t\tcombinations: [{key: 's', ctrl: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'History',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: UNDO,\n\t\t\t\thelp: 'Undo',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, key: 'z'},\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: REDO,\n\t\t\t\thelp: 'Redo',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, shift: true, key: 'z'},\n\t\t\t\t\t{ctrl: true, key: 'y'},\n\t\t\t\t]\n\t\t\t}\n\n\t\t],\n\t},\n\t{\n\t\tname: 'Relationship editing',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: ADD_VERTEX,\n\t\t\t\thelp: 'Add relationship vertex',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{alt: true, click: true},\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ADD_LABEL_VERTEX,\n\t\t\t\thelp: 'Add label anchor relationship vertex',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{alt: true, shift: true, click: true},\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DEL_VERTEX,\n\t\t\t\thelp: 'Remove relationship vertex',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{key: 'DELETE'},\n\t\t\t\t\t{key: 'BACKSPACE'}\n\t\t\t\t]\n\t\t\t},\n\t\t]\n\t},\n\t{\n\t\tname: 'Zoom',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: ZOOM_IN,\n\t\t\t\thelp: 'Zoom in',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, key: '='}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ZOOM_OUT,\n\t\t\t\thelp: 'Zoom out',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, key: '-'}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ZOOM_FIT,\n\t\t\t\thelp: 'Zoom - fit',\n\t\t\t\tcombinations: [{ctrl: true, key: '9'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ZOOM_100,\n\t\t\t\thelp: 'Zoom 100%',\n\t\t\t\tcombinations: [{ctrl: true, key: '0'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'wheel_zoom',\n\t\t\t\thelp: 'Zoom in/out with mouse wheel',\n\t\t\t\tcombinations: [{wheel: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Mouse Interactions',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: PAN_VIEW,\n\t\t\t\thelp: 'Pan view (drag empty space)',\n\t\t\t\tcombinations: [{click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: SELECT_ELEMENT,\n\t\t\t\thelp: 'Select element',\n\t\t\t\tcombinations: [{click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MULTI_SELECT,\n\t\t\t\thelp: 'Add/remove from selection',\n\t\t\t\tcombinations: [{shift: true, click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: BOX_SELECT,\n\t\t\t\thelp: 'Box selection (drag empty space)',\n\t\t\t\tcombinations: [{shift: true, click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_ELEMENTS,\n\t\t\t\thelp: 'Move selected elements',\n\t\t\t\tcombinations: [{click: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Select',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: SELECT_ALL,\n\t\t\t\thelp: 'Select All',\n\t\t\t\tcombinations: [{ctrl: true, key: 'a'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DESELECT,\n\t\t\t\thelp: 'Deselect',\n\t\t\t\tcombinations: [{key: 'ESC'}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Move',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: MOVE_UP,\n\t\t\t\thelp: 'Move up (grid increment)',\n\t\t\t\tcombinations: [{key: 'UP'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_UP_FINE,\n\t\t\t\thelp: 'Move up (1 pixel)',\n\t\t\t\tcombinations: [{key: 'UP', shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_RIGHT,\n\t\t\t\thelp: 'Move right (grid increment)',\n\t\t\t\tcombinations: [{key: 'RIGHT'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_RIGHT_FINE,\n\t\t\t\thelp: 'Move right (1 pixel)',\n\t\t\t\tcombinations: [{key: 'RIGHT', shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_DOWN,\n\t\t\t\thelp: 'Move down (grid increment)',\n\t\t\t\tcombinations: [{key: 'DOWN'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_DOWN_FINE,\n\t\t\t\thelp: 'Move down (1 pixel)',\n\t\t\t\tcombinations: [{key: 'DOWN', shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_LEFT,\n\t\t\t\thelp: 'Move left (grid increment)',\n\t\t\t\tcombinations: [{key: 'LEFT'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_LEFT_FINE,\n\t\t\t\thelp: 'Move left (1 pixel)',\n\t\t\t\tcombinations: [{key: 'LEFT', shift: true}]\n\t\t\t},\n\t\t]\n\t},\n\t\t\t{\n\t\t\tname: 'View',\n\t\t\tlist: [\n\t\t\t\t{\n\t\t\t\t\tid: TOGGLE_DRAG_MODE,\n\t\t\t\t\thelp: 'Toggle between pan and select mode',\n\t\t\t\t\tcombinations: [{key: 't'}]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: RESET_POSITION,\n\t\t\t\t\thelp: 'Reset position and view',\n\t\t\t\t\tcombinations: [{key: 'Home', ctrl: true}]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t{\n\t\tname: 'Alignment',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: ALIGN_HORIZONTAL,\n\t\t\t\thelp: 'Align selected elements horizontally',\n\t\t\t\tcombinations: [{key: 'h', ctrl: true, shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ALIGN_VERTICAL,\n\t\t\t\thelp: 'Align selected elements vertically',\n\t\t\t\tcombinations: [{key: 'a', ctrl: true, shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DISTRIBUTE_HORIZONTAL,\n\t\t\t\thelp: 'Distribute selected elements horizontally',\n\t\t\t\tcombinations: [{key: 'h', ctrl: true, alt: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DISTRIBUTE_VERTICAL,\n\t\t\t\thelp: 'Distribute selected elements vertically',\n\t\t\t\tcombinations: [{key: 'v', ctrl: true, alt: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Layout',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: AUTO_LAYOUT,\n\t\t\t\thelp: 'Auto layout all elements',\n\t\t\t\tcombinations: [{key: 'l', ctrl: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Grid',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: TOGGLE_GRID,\n\t\t\t\thelp: 'Toggle grid visibility',\n\t\t\t\tcombinations: [{key: 'g', ctrl: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: TOGGLE_SNAP_TO_GRID,\n\t\t\t\thelp: 'Toggle snap to grid',\n\t\t\t\tcombinations: [{key: 'g', ctrl: true, shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: SNAP_ALL_TO_GRID,\n\t\t\t\thelp: 'Snap all elements to grid',\n\t\t\t\tcombinations: [{key: 'g', ctrl: true, alt: true}]\n\t\t\t}\n\t\t]\n\t}\n]\n\nconst shortcutMap = shortcuts\n\t.reduce((lst, s) => lst.concat(s.list), [] as Shortcut[])\n\t.reduce<{ [k: string]: Shortcut }>((map, s) => {\n\t\tmap[s.id] = s;\n\t\treturn map\n\t}, {})\n\nconst checkKey = (e: KeyboardEvent | MouseEvent, shortcut: Shortcut, click: boolean, wheel: boolean) => {\n\treturn shortcut.combinations.some(c => {\n\t\tif (Boolean(c.shift) != e.shiftKey) return false\n\t\t// Use platform-appropriate modifier key\n\t\tif (c.ctrl) {\n\t\t\tconst modifierKey = getModifierKeyProperty(e as KeyboardEvent);\n\t\t\tif (!modifierKey) return false;\n\t\t}\n\t\tif (Boolean(c.alt) != e.altKey) return false\n\t\tif (click) return c.click\n\t\tif (wheel) return c.wheel\n\t\tif (c.key) {\n\t\t\tconst ke = e as KeyboardEvent\n\t\t\tif (c.key == 'DELETE') return ke.key == 'Delete'\n\t\t\tif (c.key == 'BACKSPACE') return ke.key == 'Backspace'\n\t\t\tif (c.key == 'ESC') return ke.key == 'Escape'\n\t\t\tif (c.key == 'UP') return ke.key == 'ArrowUp'\n\t\t\tif (c.key == 'DOWN') return ke.key == 'ArrowDown'\n\t\t\tif (c.key == 'LEFT') return ke.key == 'ArrowLeft'\n\t\t\tif (c.key == 'RIGHT') return ke.key == 'ArrowRight'\n\t\t\treturn c.key && ke.key && c.key.toLowerCase() == ke.key.toLowerCase()\n\t\t}\n\t\treturn false\n\t})\n}\n\nexport const findShortcut = (e: KeyboardEvent | MouseEvent, click = false, wheel = false) => {\n\t// Find all matching shortcuts\n\tconst matches = Object.keys(shortcutMap).filter(k => checkKey(e, shortcutMap[k], click, wheel))\n\t\n\tif (matches.length === 0) return undefined\n\tif (matches.length === 1) return matches[0]\n\t\n\t// If multiple matches, prefer the one with more specific modifiers\n\t// Sort by number of modifiers (shift, ctrl, alt) in descending order\n\tconst sortedMatches = matches.sort((a, b) => {\n\t\tconst aShortcut = shortcutMap[a]\n\t\tconst bShortcut = shortcutMap[b]\n\t\t\n\t\tconst aModifiers = aShortcut.combinations[0]\n\t\tconst bModifiers = bShortcut.combinations[0]\n\t\t\n\t\tconst aCount = (aModifiers.shift ? 1 : 0) + (aModifiers.ctrl ? 1 : 0) + (aModifiers.alt ? 1 : 0)\n\t\tconst bCount = (bModifiers.shift ? 1 : 0) + (bModifiers.ctrl ? 1 : 0) + (bModifiers.alt ? 1 : 0)\n\t\t\n\t\treturn bCount - aCount // Descending order (more modifiers first)\n\t})\n\t\n\treturn sortedMatches[0]\n}\n\nconst comboText = (c: Combination) => {\n\treturn [\n\t\tc.ctrl && getModifierKeyName().toUpperCase(),\n\t\tc.shift && 'SHIFT',\n\t\tc.alt && 'ALT',\n\t\tc.key && (c.key.length > 1 ? c.key : `\"${c.key.toUpperCase()}\"`),\n\t\tc.click && 'CLICK',\n\t\tc.wheel && 'WHEEL'\n\t].filter(Boolean).join(' + ')\n}\n\nexport const Help: FC = () => {\n\treturn
\n\t\t

Shortcuts

\n\t\t\n\t\t\t\n\t\t\t{\n\t\t\t\tshortcuts.map(section => <>\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t{section.list.map(item => \n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t)\n\t\t\t}\n\t\t\t\n\t\t
{section.name}
{item.combinations.map(comboText).join(', ')}{item.help}
\n\t
\n}\n","/**\n * Robust platform detection utilities\n */\n\n/**\n * Detects if the user is on a Mac platform using multiple detection methods\n * for maximum compatibility across browsers and future-proofing.\n */\nexport const isMac = (): boolean => {\n if (typeof navigator === 'undefined') return false;\n \n // Method 1: Check userAgentData (modern browsers, most reliable)\n if ('userAgentData' in navigator && (navigator as any).userAgentData) {\n const platform = (navigator as any).userAgentData.platform;\n if (platform && platform.toLowerCase().includes('mac')) {\n return true;\n }\n }\n \n // Method 2: Check userAgent string (widely supported)\n const userAgent = navigator.userAgent.toLowerCase();\n if (userAgent.includes('mac os') || userAgent.includes('macintosh')) {\n return true;\n }\n \n // Method 3: Check platform (fallback, deprecated but still widely supported)\n if (navigator.platform) {\n const platform = navigator.platform.toLowerCase();\n if (platform.includes('mac') || platform.includes('darwin')) {\n return true;\n }\n }\n \n // Method 4: Check for Mac-specific features as additional validation\n try {\n const testEvent = new KeyboardEvent('keydown', { metaKey: true });\n if (testEvent.metaKey !== undefined) {\n // Additional heuristic: Mac typically has different key layouts\n return /mac|darwin|os x/i.test(navigator.userAgent);\n }\n } catch (e) {\n // Ignore errors in older browsers\n }\n \n return false;\n};\n\n/**\n * Gets the appropriate modifier key name for the current platform\n */\nexport const getModifierKeyName = (): string => {\n return isMac() ? 'Cmd' : 'Ctrl';\n};\n\n/**\n * Gets the appropriate modifier key property for keyboard events\n */\nexport const getModifierKeyProperty = (event: KeyboardEvent): boolean => {\n return isMac() ? event.metaKey : event.ctrlKey;\n};\n\n/**\n * Gets the appropriate Alt key name for the current platform\n */\nexport const getAltKeyName = (): string => {\n return isMac() ? 'Option' : 'Alt';\n}; ","// Imports\nimport ___CSS_LOADER_API_SOURCEMAP_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/sourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/api.js\";\nimport ___CSS_LOADER_GET_URL_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/getUrl.js\";\nvar ___CSS_LOADER_URL_IMPORT_0___ = new URL(\"@fontsource/inter/files/inter-latin-400-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_1___ = new URL(\"@fontsource/inter/files/inter-latin-500-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_2___ = new URL(\"@fontsource/inter/files/inter-latin-600-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_3___ = new URL(\"@fontsource/inter/files/inter-latin-700-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_SOURCEMAP_IMPORT___);\nvar ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___);\nvar ___CSS_LOADER_URL_REPLACEMENT_1___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_1___);\nvar ___CSS_LOADER_URL_REPLACEMENT_2___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_2___);\nvar ___CSS_LOADER_URL_REPLACEMENT_3___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_3___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_0___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_1___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_2___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_3___}) format(\"woff2\");\n}\n`, \"\",{\"version\":3,\"sources\":[\"webpack://./src/fonts.css\"],\"names\":[],\"mappings\":\"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF\",\"sourcesContent\":[\"/* Local Inter files keep browser text measurement identical without internet access. */\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 400;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-400-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 500;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-500-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 600;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-600-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 700;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-700-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\"],\"sourceRoot\":\"\"}]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___;\n","// Imports\nimport ___CSS_LOADER_API_SOURCEMAP_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/sourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/api.js\";\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_SOURCEMAP_IMPORT___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `html, body, #root {\n height: 100%;\n}\n\nbody {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n color: #666;\n margin: 0;\n}\n\n#root {\n display: flex;\n flex-direction: column;\n}\n#root > div.graph {\n flex: 1;\n overflow: auto;\n position: relative;\n}\n\n.toolbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 10px;\n background-color: #f0f0f0;\n border-bottom: 1px solid #cccccc;\n}\n\n.toolbar > div {\n display: flex;\n align-items: center;\n}\n\n.toolbar button {\n padding: 5px 8px;\n margin: 0 2px;\n cursor: pointer;\n}\n\n.toolbar button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Drag mode toggle button styles */\n.toolbar button.mode-toggle {\n position: relative;\n border: 1px solid #8f9fc9;\n width: 40px;\n min-height: 28px;\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\n border-color: #8f9fc9;\n color: white;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n}\n\n.toolbar button.mode-toggle:hover {\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\n border-color: #abb8db;\n}\n\n.toolbar button.mode-toggle.select-mode:active {\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\n}\n\n/* Pan mode and active toggle - darker blue */\n.toolbar button.mode-toggle.pan-mode,\n.toolbar button.active-toggle {\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n.toolbar button.mode-toggle.pan-mode:hover,\n.toolbar button.active-toggle:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\n.toolbar button.mode-toggle.pan-mode:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n/* Toggle buttons when inactive - gray styling */\n.toolbar button.inactive-toggle {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n.toolbar button.inactive-toggle:hover {\n background: #b1b1b1;\n}\n\n.toolbar button.inactive-toggle:active {\n background: #a1a1a1;\n}\n\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\n.toolbar button .fas {\n font-size: 1em;\n vertical-align: middle;\n}\n\n/* Zoom percentage display */\n.toolbar button.zoom-display {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n font-size: 11px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\n padding: 6px 8px;\n text-align: center;\n}\n\n.toolbar-group {\n display: flex;\n align-items: center;\n margin-right: 25px; /* Large space between groups */\n}\n\n.toolbar-group:last-child {\n margin-right: 0; /* Remove right margin from the last group (help button) */\n}\n\nbutton {\n border: none;\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n border-radius: 3px;\n padding: 6px 10px;\n color: #fff;\n outline: none;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n margin-right: 5px;\n min-width: 32px;\n min-height: 28px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n line-height: 1;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n position: relative;\n}\n\nbutton:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\nbutton:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n}\n\nbutton:last-child {\n margin-right: 0;\n}\n\n/* Save button when no changes - gray */\nbutton.action {\n background: #c1c1c1;\n color: #999;\n}\n\nbutton.action:active {\n background: #b1b1b1;\n}\n\n/* Save button when there are changes - orange */\nbutton.grp {\n background: linear-gradient(to bottom, #ee9564, #de7d48);\n margin-right: 0;\n}\n\nbutton.grp:active {\n background: #d67540;\n}\n\n/* Auto-arrange button with AI purple to blue gradient */\nbutton.auto-arrange {\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\n border-color: #4a4c93;\n}\n\nbutton.auto-arrange:hover {\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\n border-color: #5a5ca3;\n}\n\nbutton.auto-arrange:active {\n background: linear-gradient(135deg, #593B83, #357abd);\n border-color: #3a3c83;\n}\n\nselect {\n border: 1px solid #ccc;\n background: white;\n border-radius: 3px;\n padding: 3px 7px;\n color: #666;\n outline: none;\n margin-right: 5px;\n font-size: 12px;\n}\n\nselect:disabled {\n background: #f5f5f5;\n color: #999;\n}\n\nbutton:disabled {\n background: #c1c1c1;\n color: #999;\n}\n\n#root > div > svg {\n position: absolute;\n user-select: none;\n}\n\n\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\n stroke: #29c229;\n}\n.edge .v-dot {\n fill: transparent;\n stroke: transparent;\n stroke-width: 3px;\n cursor: pointer;\n transition: stroke 0.15s ease;\n}\n.edge .v-dot:hover {\n stroke: #999;\n fill: rgba(153, 153, 153, 0.1);\n}\n.edge .v-dot.selected {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.1);\n}\n.edge .v-dot.selected:hover {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.2);\n}\n.edge .v-dot.auto.selected {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.1);\n}\n.edge .v-dot.auto.selected:hover {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.2);\n}\ncircle#prj {\n fill: none;\n stroke: #777;\n}\n\n.nodeShadow {\n fill: none;\n stroke-width: 4px;\n stroke: rgba(0, 0, 0, 0.13);\n}\n\ng.node {\n user-select: none;\n cursor: default;\n}\n\ng.node.linked {\n cursor: pointer;\n}\n\ng.node text {\n pointer-events: none;\n}\n\n.icon {\n fill: #aaa;\n stroke: #fff;\n}\n#icon-cube {\n fill: #aaa;\n}\n\n/* Ensure all button icons are uncolored */\nbutton .icon,\nbutton svg,\nbutton path {\n fill: currentColor !important;\n stroke: none !important;\n}\n\n/* Font Awesome icon styling in buttons */\nbutton i {\n font-size: 12px;\n color: inherit;\n}\n\nrect.elastic {\n pointer-events: none;\n stroke: none;\n fill: #3bd8281f;\n display: none;\n}\nrect.elastic.on {\n display: block;\n}\n\n.popover {\n position: absolute;\n top: 50px;\n bottom: 10px;\n overflow: auto;\n right: 10px;\n background: ghostwhite;\n padding: 30px;\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\n border: solid 1px #eee;\n}\n\n.popover th {\n text-align: left;\n padding: 20px 0px 10px;\n}\n.popover td {\n padding-right: 20px;\n font-size: 14px;\n}\n\n/* Simple tooltip system with smart positioning */\n[data-tooltip] {\n position: relative;\n}\n\n[data-tooltip]:hover::after {\n content: attr(data-tooltip);\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(0, 0, 0, 0.9);\n color: white;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 12px !important;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n font-weight: normal !important;\n white-space: nowrap;\n z-index: 1000;\n pointer-events: none;\n margin-top: 5px;\n animation: tooltip-appear 0.1s ease-out;\n min-width: 120px;\n max-width: calc(100vw - 20px);\n box-sizing: border-box;\n}\n\n[data-tooltip]:hover::before {\n content: '';\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-bottom-color: rgba(0, 0, 0, 0.9);\n z-index: 1000;\n pointer-events: none;\n margin-top: 1px;\n animation: tooltip-appear 0.1s ease-out;\n}\n\n/* Special handling for rightmost elements that might overflow */\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 0;\n transform: none;\n}\n\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 16px;\n transform: none;\n}\n\n@keyframes tooltip-appear {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(-5px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\nselect {\n position: relative;\n}\n\n/* Robot shape internal elements - inherit stroke from parent node */\n.node .robot-eye-socket {\n fill: none;\n stroke: inherit;\n stroke-width: 2;\n}\n\n.node .robot-eye {\n fill: currentColor;\n stroke: none;\n}\n\n.node .robot-mouth {\n stroke: inherit;\n}\n\n.node .robot-antenna {\n stroke: inherit;\n}\n\n.node .robot-antenna-ball {\n fill: currentColor;\n stroke: inherit;\n stroke-width: 1.5;\n}\n\n.node .robot-panel {\n stroke: inherit;\n}\n\n.node .robot-indicator {\n fill: currentColor;\n stroke: none;\n}`, \"\",{\"version\":3,\"sources\":[\"webpack://./src/style.css\"],\"names\":[],\"mappings\":\"AAAA;IACI,YAAY;AAChB;;AAEA;IACI,uFAAuF;IACvF,WAAW;IACX,SAAS;AACb;;AAEA;IACI,aAAa;IACb,sBAAsB;AAC1B;AACA;IACI,OAAO;IACP,cAAc;IACd,kBAAkB;AACtB;;AAEA;IACI,aAAa;IACb,8BAA8B;IAC9B,mBAAmB;IACnB,iBAAiB;IACjB,yBAAyB;IACzB,gCAAgC;AACpC;;AAEA;IACI,aAAa;IACb,mBAAmB;AACvB;;AAEA;IACI,gBAAgB;IAChB,aAAa;IACb,eAAe;AACnB;;AAEA;IACI,YAAY;IACZ,mBAAmB;AACvB;;AAEA,mCAAmC;AACn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Ac;IACd,WAAW;IACX,sBAAsB;IACtB,aAAa;IACb,uCAAuC;IACvC,sBAAsB;AAC1B;;AAEA;IACI,gBAAgB;IAChB,sBAAsB;AAC1B;AACA;IACI,mBAAmB;IACnB,eAAe;AACnB;;AAEA,iDAAiD;AACjD;IACI,kBAAkB;AACtB;;AAEA;IACI,2BAA2B;IAC3B,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,2BAA2B;IAC3B,8BAA8B;IAC9B,YAAY;IACZ,iBAAiB;IACjB,kBAAkB;IAClB,0BAA0B;IAC1B,8EAA8E;IAC9E,8BAA8B;IAC9B,mBAAmB;IACnB,aAAa;IACb,oBAAoB;IACpB,eAAe;IACf,uCAAuC;IACvC,gBAAgB;IAChB,6BAA6B;IAC7B,sBAAsB;AAC1B;;AAEA;IACI,WAAW;IACX,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,2BAA2B;IAC3B,6BAA6B;IAC7B,uCAAuC;IACvC,aAAa;IACb,oBAAoB;IACpB,eAAe;IACf,uCAAuC;AAC3C;;AAEA,gEAAgE;AAChE;IACI,2DAA2D;IAC3D,UAAU;IACV,QAAQ;IACR,eAAe;AACnB;;AAEA;IACI,2DAA2D;IAC3D,UAAU;IACV,WAAW;IACX,eAAe;AACnB;;AAEA;IACI;QACI,UAAU;QACV,4CAA4C;IAChD;IACA;QACI,UAAU;QACV,yCAAyC;IAC7C;AACJ;;AAEA;IACI,kBAAkB;AACtB;;AAEA,oEAAoE;AACpE;IACI,UAAU;IACV,eAAe;IACf,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,YAAY;AAChB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,eAAe;IACf,iBAAiB;AACrB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,YAAY;AAChB\",\"sourcesContent\":[\"html, body, #root {\\n height: 100%;\\n}\\n\\nbody {\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n color: #666;\\n margin: 0;\\n}\\n\\n#root {\\n display: flex;\\n flex-direction: column;\\n}\\n#root > div.graph {\\n flex: 1;\\n overflow: auto;\\n position: relative;\\n}\\n\\n.toolbar {\\n display: flex;\\n justify-content: space-between;\\n align-items: center;\\n padding: 4px 10px;\\n background-color: #f0f0f0;\\n border-bottom: 1px solid #cccccc;\\n}\\n\\n.toolbar > div {\\n display: flex;\\n align-items: center;\\n}\\n\\n.toolbar button {\\n padding: 5px 8px;\\n margin: 0 2px;\\n cursor: pointer;\\n}\\n\\n.toolbar button:disabled {\\n opacity: 0.5;\\n cursor: not-allowed;\\n}\\n\\n/* Drag mode toggle button styles */\\n.toolbar button.mode-toggle {\\n position: relative;\\n border: 1px solid #8f9fc9;\\n width: 40px;\\n min-height: 28px;\\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\\n border-color: #8f9fc9;\\n color: white;\\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\\n}\\n\\n.toolbar button.mode-toggle:hover {\\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\\n border-color: #abb8db;\\n}\\n\\n.toolbar button.mode-toggle.select-mode:active {\\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\\n}\\n\\n/* Pan mode and active toggle - darker blue */\\n.toolbar button.mode-toggle.pan-mode,\\n.toolbar button.active-toggle {\\n background: linear-gradient(to bottom, #4a90e2, #357abd);\\n border-color: #2968a3;\\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\\n}\\n\\n.toolbar button.mode-toggle.pan-mode:hover,\\n.toolbar button.active-toggle:hover {\\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\\n}\\n\\n.toolbar button.mode-toggle.pan-mode:active {\\n background: linear-gradient(to bottom, #357abd, #2968a3);\\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\\n}\\n\\n/* Toggle buttons when inactive - gray styling */\\n.toolbar button.inactive-toggle {\\n background: #c1c1c1;\\n color: #999;\\n border-color: #c1c1c1;\\n box-shadow: none;\\n}\\n\\n.toolbar button.inactive-toggle:hover {\\n background: #b1b1b1;\\n}\\n\\n.toolbar button.inactive-toggle:active {\\n background: #a1a1a1;\\n}\\n\\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\\n background: #c1c1c1;\\n color: #999;\\n border-color: #c1c1c1;\\n box-shadow: none;\\n}\\n\\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\\n.toolbar button .fas {\\n font-size: 1em;\\n vertical-align: middle;\\n}\\n\\n/* Zoom percentage display */\\n.toolbar button.zoom-display {\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\\n font-size: 11px;\\n font-weight: 600;\\n font-variant-numeric: tabular-nums;\\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\\n padding: 6px 8px;\\n text-align: center;\\n}\\n\\n.toolbar-group {\\n display: flex;\\n align-items: center;\\n margin-right: 25px; /* Large space between groups */\\n}\\n\\n.toolbar-group:last-child {\\n margin-right: 0; /* Remove right margin from the last group (help button) */\\n}\\n\\nbutton {\\n border: none;\\n background: linear-gradient(to bottom, #4a90e2, #357abd);\\n border-color: #2968a3;\\n border-radius: 3px;\\n padding: 6px 10px;\\n color: #fff;\\n outline: none;\\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\\n margin-right: 5px;\\n min-width: 32px;\\n min-height: 28px;\\n display: inline-flex;\\n align-items: center;\\n justify-content: center;\\n font-size: 14px;\\n line-height: 1;\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n position: relative;\\n}\\n\\nbutton:hover {\\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\\n}\\n\\nbutton:active {\\n background: linear-gradient(to bottom, #357abd, #2968a3);\\n}\\n\\nbutton:last-child {\\n margin-right: 0;\\n}\\n\\n/* Save button when no changes - gray */\\nbutton.action {\\n background: #c1c1c1;\\n color: #999;\\n}\\n\\nbutton.action:active {\\n background: #b1b1b1;\\n}\\n\\n/* Save button when there are changes - orange */\\nbutton.grp {\\n background: linear-gradient(to bottom, #ee9564, #de7d48);\\n margin-right: 0;\\n}\\n\\nbutton.grp:active {\\n background: #d67540;\\n}\\n\\n/* Auto-arrange button with AI purple to blue gradient */\\nbutton.auto-arrange {\\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\\n border-color: #4a4c93;\\n}\\n\\nbutton.auto-arrange:hover {\\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\\n border-color: #5a5ca3;\\n}\\n\\nbutton.auto-arrange:active {\\n background: linear-gradient(135deg, #593B83, #357abd);\\n border-color: #3a3c83;\\n}\\n\\nselect {\\n border: 1px solid #ccc;\\n background: white;\\n border-radius: 3px;\\n padding: 3px 7px;\\n color: #666;\\n outline: none;\\n margin-right: 5px;\\n font-size: 12px;\\n}\\n\\nselect:disabled {\\n background: #f5f5f5;\\n color: #999;\\n}\\n\\nbutton:disabled {\\n background: #c1c1c1;\\n color: #999;\\n}\\n\\n#root > div > svg {\\n position: absolute;\\n user-select: none;\\n}\\n\\n\\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\\n stroke: #29c229;\\n}\\n.edge .v-dot {\\n fill: transparent;\\n stroke: transparent;\\n stroke-width: 3px;\\n cursor: pointer;\\n transition: stroke 0.15s ease;\\n}\\n.edge .v-dot:hover {\\n stroke: #999;\\n fill: rgba(153, 153, 153, 0.1);\\n}\\n.edge .v-dot.selected {\\n stroke: #29c229;\\n fill: rgba(41, 194, 41, 0.1);\\n}\\n.edge .v-dot.selected:hover {\\n stroke: #29c229;\\n fill: rgba(41, 194, 41, 0.2);\\n}\\n.edge .v-dot.auto.selected {\\n stroke: #777;\\n fill: rgba(119, 119, 119, 0.1);\\n}\\n.edge .v-dot.auto.selected:hover {\\n stroke: #777;\\n fill: rgba(119, 119, 119, 0.2);\\n}\\ncircle#prj {\\n fill: none;\\n stroke: #777;\\n}\\n\\n.nodeShadow {\\n fill: none;\\n stroke-width: 4px;\\n stroke: rgba(0, 0, 0, 0.13);\\n}\\n\\ng.node {\\n user-select: none;\\n cursor: default;\\n}\\n\\ng.node.linked {\\n cursor: pointer;\\n}\\n\\ng.node text {\\n pointer-events: none;\\n}\\n\\n.icon {\\n fill: #aaa;\\n stroke: #fff;\\n}\\n#icon-cube {\\n fill: #aaa;\\n}\\n\\n/* Ensure all button icons are uncolored */\\nbutton .icon,\\nbutton svg,\\nbutton path {\\n fill: currentColor !important;\\n stroke: none !important;\\n}\\n\\n/* Font Awesome icon styling in buttons */\\nbutton i {\\n font-size: 12px;\\n color: inherit;\\n}\\n\\nrect.elastic {\\n pointer-events: none;\\n stroke: none;\\n fill: #3bd8281f;\\n display: none;\\n}\\nrect.elastic.on {\\n display: block;\\n}\\n\\n.popover {\\n position: absolute;\\n top: 50px;\\n bottom: 10px;\\n overflow: auto;\\n right: 10px;\\n background: ghostwhite;\\n padding: 30px;\\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\\n border: solid 1px #eee;\\n}\\n\\n.popover th {\\n text-align: left;\\n padding: 20px 0px 10px;\\n}\\n.popover td {\\n padding-right: 20px;\\n font-size: 14px;\\n}\\n\\n/* Simple tooltip system with smart positioning */\\n[data-tooltip] {\\n position: relative;\\n}\\n\\n[data-tooltip]:hover::after {\\n content: attr(data-tooltip);\\n position: absolute;\\n top: 100%;\\n left: 50%;\\n transform: translateX(-50%);\\n background: rgba(0, 0, 0, 0.9);\\n color: white;\\n padding: 6px 12px;\\n border-radius: 4px;\\n font-size: 12px !important;\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\\n font-weight: normal !important;\\n white-space: nowrap;\\n z-index: 1000;\\n pointer-events: none;\\n margin-top: 5px;\\n animation: tooltip-appear 0.1s ease-out;\\n min-width: 120px;\\n max-width: calc(100vw - 20px);\\n box-sizing: border-box;\\n}\\n\\n[data-tooltip]:hover::before {\\n content: '';\\n position: absolute;\\n top: 100%;\\n left: 50%;\\n transform: translateX(-50%);\\n border: 4px solid transparent;\\n border-bottom-color: rgba(0, 0, 0, 0.9);\\n z-index: 1000;\\n pointer-events: none;\\n margin-top: 1px;\\n animation: tooltip-appear 0.1s ease-out;\\n}\\n\\n/* Special handling for rightmost elements that might overflow */\\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\\n /* Apply to last 2 toolbar groups (save and help buttons) */\\n left: auto;\\n right: 0;\\n transform: none;\\n}\\n\\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\\n /* Apply to last 2 toolbar groups (save and help buttons) */\\n left: auto;\\n right: 16px;\\n transform: none;\\n}\\n\\n@keyframes tooltip-appear {\\n from {\\n opacity: 0;\\n transform: translateX(-50%) translateY(-5px);\\n }\\n to {\\n opacity: 1;\\n transform: translateX(-50%) translateY(0);\\n }\\n}\\n\\nselect {\\n position: relative;\\n}\\n\\n/* Robot shape internal elements - inherit stroke from parent node */\\n.node .robot-eye-socket {\\n fill: none;\\n stroke: inherit;\\n stroke-width: 2;\\n}\\n\\n.node .robot-eye {\\n fill: currentColor;\\n stroke: none;\\n}\\n\\n.node .robot-mouth {\\n stroke: inherit;\\n}\\n\\n.node .robot-antenna {\\n stroke: inherit;\\n}\\n\\n.node .robot-antenna-ball {\\n fill: currentColor;\\n stroke: inherit;\\n stroke-width: 1.5;\\n}\\n\\n.node .robot-panel {\\n stroke: inherit;\\n}\\n\\n.node .robot-indicator {\\n fill: currentColor;\\n stroke: none;\\n}\"],\"sourceRoot\":\"\"}]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___;\n","// Imports\nimport ___CSS_LOADER_API_SOURCEMAP_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/sourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/api.js\";\nimport ___CSS_LOADER_GET_URL_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/getUrl.js\";\nvar ___CSS_LOADER_URL_IMPORT_0___ = new URL(\"@fontsource/inter/files/inter-latin-400-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_1___ = new URL(\"@fontsource/inter/files/inter-latin-500-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_2___ = new URL(\"@fontsource/inter/files/inter-latin-600-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_3___ = new URL(\"@fontsource/inter/files/inter-latin-700-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_SOURCEMAP_IMPORT___);\nvar ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___);\nvar ___CSS_LOADER_URL_REPLACEMENT_1___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_1___);\nvar ___CSS_LOADER_URL_REPLACEMENT_2___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_2___);\nvar ___CSS_LOADER_URL_REPLACEMENT_3___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_3___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_0___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_1___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_2___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_3___}) format(\"woff2\");\n}\n`, \"\",{\"version\":3,\"sources\":[\"webpack://./src/fonts.css\"],\"names\":[],\"mappings\":\"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF\",\"sourcesContent\":[\"/* Local Inter files keep browser text measurement identical without internet access. */\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 400;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-400-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 500;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-500-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 600;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-600-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 700;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-700-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\"],\"sourceRoot\":\"\"}]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___.toString();\n","\n import API from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\";\n import domAPI from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleDomAPI.js\";\n import insertFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertBySelector.js\";\n import setAttributes from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js\";\n import insertStyleElement from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertStyleElement.js\";\n import styleTagTransformFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleTagTransform.js\";\n import content, * as namedExport from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./fonts.css\";\n \n \n\nvar options = {};\n\noptions.styleTagTransform = styleTagTransformFn;\noptions.setAttributes = setAttributes;\noptions.insert = insertFn.bind(null, \"head\");\noptions.domAPI = domAPI;\noptions.insertStyleElement = insertStyleElement;\n\nvar update = API(content, options);\n\n\n\nexport * from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./fonts.css\";\n export default content && content.locals ? content.locals : undefined;\n","\n import API from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\";\n import domAPI from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleDomAPI.js\";\n import insertFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertBySelector.js\";\n import setAttributes from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js\";\n import insertStyleElement from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertStyleElement.js\";\n import styleTagTransformFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleTagTransform.js\";\n import content, * as namedExport from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./style.css\";\n \n \n\nvar options = {};\n\noptions.styleTagTransform = styleTagTransformFn;\noptions.setAttributes = setAttributes;\noptions.insert = insertFn.bind(null, \"head\");\noptions.domAPI = domAPI;\noptions.insertStyleElement = insertStyleElement;\n\nvar update = API(content, options);\n\n\n\nexport * from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./style.css\";\n export default content && content.locals ? content.locals : undefined;\n"],"names":["el","style","Object","entries","forEach","key","value","setAttribute","String","nodeBorder","nodeText","stroke","edgeText","edgeRect","fill","groupRect","groupText","cursor","thickness","color","opacity","fontSize","width","dashed","p1","p2","Math","sqrt","x","y","height","background","shape","metadata","description","calculateEdgeVertices","edge","n1","from","n2","to","vertices","concat","unshift","push","interior","slice","firstRoutingVertex","find","vertex","label","lastRoutingVertex","index","length","intersect","Error","id","calculateLabelPlacement","position","defaultPoint","segment","point","labelIndex","findIndex","movable","labelVertex","auto","adjacentSegments","p","q","reduce","longest","candidate","_constants__WEBPACK_IMPORTED_MODULE_0__","gd","undefined","targetLength","sum","traversed","segmentPosition","horizontalDistance","abs","verticalDistance","orientation","createEdgePath","path","Symbol","GeometryValidationError","issues","constructor","super","map","issue","message","join","this","name","validateResolvedLayout","measured","resolved","diagramId","checkUniqueIDs","nodes","node","groups","group","edges","checkCoverage","measuredNodes","Map","measuredGroups","resolvedNodes","resolvedGroups","checkFiniteRect","bounds","expected","get","nearlyEqual","size","contentSize","checkRectInBounds","titleBounds","contains","titleSize","forEachPair","first","second","overlaps","checkNodeOverlaps","checkGroupOverlaps","child","parentId","parent","checkOwnership","measuredEdges","labels","sourceId","targetId","sections","some","section","checkSectionConnections","isFinitePoint","pointInRect","values","routeIntersectsRect","inset","sourceInside","belongsToGroup","routeViolatesGroup","labelBounds","labelSize","checkEdges","ids","seen","Set","has","add","actual","expectedIDs","actualIDs","rect","Number","isFinite","isFiniteRect","samePoint","source","target","start","end","pointOnBorder","nodeId","groupId","shouldBeInside","dx","dy","minimum","maximum","origin","delta","lower","upper","EPSILON","max","min","segmentIntersectsRect","outer","inner","inclusive","amount","withinX","withinY","onVertical","onHorizontal","items","visit","code","elementIds","create","element","type","attrs","className","document","createElementNS","k","v","classList","use","setAttributeNS","d","text","t","textContent","textArea","bold","anchor","constants","M5","lines","maxW","svg_text","U2","txt","line","i","span","append","r","rx","ry","icon","expand","expanded","g","transform","setPosition","insideBox","b","centeredBox","intersectRect","box","w","h","s","q1","q2","denominator","a","numerator1","numerator2","result","onLine1","onLine2","segmentIntersection","filter","ret","intersectRectFull","intersectEllipse","ellCenter","nodeCenter","si","c","radicand_sqrt","pos","project","atob","len","dot","cabDistance","cylinderRadiusY","shapeLabelOffsetY","toLowerCase","D3Element","_el","attr","insert","el2","insertBefore","querySelector","bbox","rounded","shapeSvg","_ellipse","mobiledeviceportrait","shapes","roundedbox","component","cylinder","cy","person","circle","ellipse","hexagon","sz","n","folder","mobiledevicelandscape","mobiledevice","pipe","robot","headSize","headR","antennaH","antennaR","eyeR","eyeSpacing","earW","earH","bodyW","bodyTop","bodyH","headTop","eyeY","mouthY","mouthW","webbrowser","Undo","versions","lastSavedPos","exportDoc","importDoc","change","tmpPreviousState","func","timeout","context","clearTimeout","setTimeout","apply","debounce","saveNow","beforeChange","deepClone","currentState","splice","doc","structuredClone","JSON","parse","stringify","undo","redo","changed","setSaved","textBlock","gapAfter","field","wrapped","lineHeight","defaultEdgeStyle","Y$","defaultNodeStyle","nD","graphCount","GraphData","nodesMap","edgeVertices","groupsMap","layoutDirection","validatedLayout","colorToVarMap","svg","idPrefix","selectListener","dragging","_undo","_gridVisible","_snapToGrid","_gridSize","_skipAutoFit","exportLayout","lo","importLayout","init","layout","addNode","sub","link","nodeStyle","minimumHeight","contentLayout","title","subtitle","nodeWidth","textWidth","HORIZONTAL_PADDING","blocks","textHeight","block","VERTICAL_PADDING","ICON_SIZE","layoutNodeContent","requiredHeight","set","Array","addEdge","fromNode","toNode","initVertex","edgeID","input","charCodeAt","imul","toString","fnv1a36","stableVertexID","userDeletedVertices","addGroup","nodesOrGroups","console","error","Boolean","setNodeSelected","selected","ref","remove","updateEdgesSel","e","clearResolvedLayout","layoutSections","layoutLabelBounds","layoutBounds","layoutTitleBounds","moveNode","disableSnap","skipUndo","snapped","snapToGrid","redrawEdges","redrawGroups","moveEdgeVertex","redrawEdge","moveSelected","insertEdgeVertex","isLabel","deleteEdgeVertex","indexOf","delete","alignTopLeft","contentBounds","calculateContentBounds","offsetX","offsetY","resetPanTransform","currentZoom","getZoom","zoomGroup","graphData","bb","zoom","parentElement","clientWidth","clientHeight","updatePanningOptimized","clearViewState","shouldSkipAutoFit","resetView","updatePanning","removeChild","buildEdge","buildGroup","exportSVG","U","originalSvg","exportSvg","cloneNode","rootAttributes","attributes","removeAttributeNode","setAttributeNode","removeIdPrefix","querySelectorAll","getAttribute","removeAttribute","exportElastic","exportWidth","padding","exportHeight","exportZoomGroup","convertStylesToCustomProperties","script","createElement","replace","firstChild","outerHTML","prefix","startsWith","includes","split","localName","minX","Infinity","minY","maxX","maxY","left","right","top","bottom","trim","centerX","centerY","approxLabelSize","full","lst","rerender","requiredSavedPoint","endsWith","edgeId","isArray","saved","autoLayout","options","placedNode","placedGroup","placedEdge","interiorRoutePoints","validated","fitToView","alignSelectionV","alignSelectionH","distributeSelectionH","selectedNodes","selectedVertices","allElements","sort","spacing","newX","distributeSelectionV","newY","setEdgeSelected","viewportWidth","viewportHeight","zoomX","zoomY","optimalZoom","finalZoom","translateX","translateY","saveViewState","saveLayoutState","restoreLayoutState","state","isGridVisible","isSnapToGrid","getGridSize","toggleGrid","updateGridDisplay","window","dispatchEvent","CustomEvent","toggleSnapToGrid","snapAllToGrid","snappedX","round","snappedY","existingGrid","existingGridRect","defs","pattern","appendChild","route","previous","buildGraph","data","onNodeSelect","dragMode","body","_buildGraph","elasticEl","addCursorInteraction","setZoom","currentTransform","getCurrentTransform","buildGraphView","innerHTML","fontsinline","A","LICENSE_raw","zoomG","nodesG","edgesG","groupsG","href","exportHref","content","shapeType","AV","setBorderStyle","border","tg","iconHeight","preserveAspectRatio","buildNodeContent","__data","buildNode","completeRoutePoints","edge_utils","l","bg","buildPlacedEdgeLabel","placement","buildEdgeLabel","IW","Zr","cx","p0","topExtension","bottomExtension","hexHeight","pad","findClosestSegment","graph","fnd","dst","POSITIVE_INFINITY","prj","pts","mouseToDrawing","getBoundingClientRect","z","clientX","clientY","addCustomCursorInteraction","conn","ini","elastic","isPanning","panStartX","panStartY","initialTransform","pendingSelectionChange","pendingNavigation","hasDragged","suppressLinkClick","eventListeners","onClick","Element","closest","preventDefault","stopPropagation","md","convertEvent","changedTouches","onMouseMoveHandler","getSelection","setSelection","setTransform","drawingDx","drawingDy","item","setDragging","update","onMouseMove","ex","ey","onMouseUpHandler","removeEventListener","navigation","boxSelection","shiftKey","location","onMouseUp","onMouseDownHandler","nodeFromEvent","effectiveMode","isSelected","translateMatch","match","parseFloat","getCurrentTransformLocal","startDrawingX","startDrawingY","pt","currentPt","currentDrawingX","currentDrawingY","createElastic","onMouseDown","addEventListener","event","handler","addDnd","existingCleanup","__cursorInteractionCleanup","beforeUnloadHandler","returnValue","setDotSelected","dotEl","mouseMoveHandler","altKey","removePrjDot","keyUpHandler","shortcuts","Yp","Zj","_s","clickHandler","wheelHandler","sign","deltaY","newZoom","svgX","svgY","setZoomCentered","keyDownHandler","shortcut","bl","Ur","newZoomIn","hU","newZoomOut","i1","mD","F","Gn","customInteractionCleanup","getData","handles","handle","b1","b2","scaleMatch","oldZoom","container","newTranslateX","newTranslateY","getBBox","viewStateCache","restoreViewState","defaultOptions","direction","nodeSpacing","layerSpacing","async","resolveAutomatic","diagram","checkMeasuredLinks","childrenByParent","groupsByParent","elkGroups","children","layoutOptions","groupLayoutOptions","root","rootLayoutOptions","owner","lowestCommonGroup","buildLayoutTree","elk","__webpack_require__","then","bind","module","default","readContainer","readResolvedLayout","sources","targets","titleHeight","sourceGroups","parentGroups","targetGroups","current","parentX","parentY","containerX","containerY","childX","requiredNumber","childY","measuredNode","measuredGroup","requiredLabel","readEdge","addOffset","startPoint","bendPoints","endPoint","requiredEndpoint","elementId","endpoints","siblings","fonts","ready","measureGraph","compactLayout","geometry","centerOffset","validateCurrentLayout","isConnected","boundary","SVGGraphicsElement","copyBox","snapshot","completeSnapshot","resolveManual","nodeParents","groupParents","member","parents","isGroup","existing","declaredParents","checkMeasuredBox","measureNode","measureGroup","measureEdge","hasLabel","boxes","flatMap","points","flat","measuredText","measurementSVG","loadDiagramFonts","Promise","all","weight","load","measureSVGText","localeCompare","measurementKey","cached","visibility","pointerEvents","svgTextWrap","paragraph","paragraphLines","currentLine","word","parts","breakLongWord","part","nextLine","maxWidth","currentPart","character","nextPart","layoutDirections","TopBottom","BottomTop","LeftRight","RightLeft","model","viewsList","keys","views","layouts","viewKey","elements","relations","collectRels","relationships","rel","people","softwareSystems","containers","el1","components","deploymentNodes","containerInstances","containerId","recAddNodes","infrastructureNodes","view","getView","_graph_view_graph__WEBPACK_IMPORTED_MODULE_0__","jg","rankDirection","automaticLayout","version","groupingIDs","externalContainersBoundariesVisible","softwareSystemId","enterprise","styles","cssClassName","tag","varPrefix","elementViewKey","containerViews","lookupContainerViewKey","tags","technology","encodedViewKey","encodeURIComponent","url","nodeLink","properties","warn","destinationId","routing","level","groupMembers","ADD_VERTEX","ADD_LABEL_VERTEX","DEL_VERTEX","ZOOM_IN","ZOOM_OUT","ZOOM_FIT","ZOOM_100","SELECT_ALL","DESELECT","MOVE_LEFT","MOVE_RIGHT","MOVE_UP","MOVE_DOWN","MOVE_LEFT_FINE","MOVE_RIGHT_FINE","MOVE_UP_FINE","MOVE_DOWN_FINE","TOGGLE_DRAG_MODE","ALIGN_HORIZONTAL","ALIGN_VERTICAL","DISTRIBUTE_HORIZONTAL","DISTRIBUTE_VERTICAL","AUTO_LAYOUT","RESET_POSITION","TOGGLE_GRID","TOGGLE_SNAP_TO_GRID","SNAP_ALL_TO_GRID","list","help","combinations","shift","ctrl","alt","click","wheel","shortcutMap","comboText","_utils_platform__WEBPACK_IMPORTED_MODULE_1__","sy","toUpperCase","react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__","jsxs","jsx","Fragment","colSpan","matches","SA","ke","checkKey","aShortcut","bShortcut","aModifiers","bModifiers","aCount","isMac","navigator","userAgentData","platform","userAgent","KeyboardEvent","metaKey","test","ctrlKey","___CSS_LOADER_URL_IMPORT_0___","URL","___CSS_LOADER_URL_IMPORT_1___","___CSS_LOADER_URL_IMPORT_2___","___CSS_LOADER_URL_IMPORT_3___","___CSS_LOADER_EXPORT___","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default","___CSS_LOADER_URL_REPLACEMENT_0___","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default","___CSS_LOADER_URL_REPLACEMENT_1___","___CSS_LOADER_URL_REPLACEMENT_2___","___CSS_LOADER_URL_REPLACEMENT_3___","names","mappings","sourcesContent","sourceRoot","__WEBPACK_DEFAULT_EXPORT__","styleTagTransform","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default","setAttributes","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default","domAPI","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default","insertStyleElement","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_cjs_js_fonts_css__WEBPACK_IMPORTED_MODULE_6__","locals","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_cjs_js_style_css__WEBPACK_IMPORTED_MODULE_6__"],"sourceRoot":""} \ No newline at end of file diff --git a/cmd/mdl/webapp/dist/948.js b/cmd/mdl/webapp/dist/948.js index 3dc8d2f6..9e26e4b2 100644 --- a/cmd/mdl/webapp/dist/948.js +++ b/cmd/mdl/webapp/dist/948.js @@ -1,2 +1,2 @@ -"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[948],{948(e,n,r){var t=r(763),u=r(108),s=r(987);r.d(n,["Graph",0,({data:e,onSelect:n,dragMode:r})=>{const[i,a]=(0,t.useState)(null),d=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(!d.current)return;d.current.innerHTML="";const t=(0,u.ZG)(e,e=>n(e?e.id:null),r);d.current.append(t.svg),a(t),(0,u.F_)(e.id)||e.shouldSkipAutoFit()||e.fitToView();const s=()=>{e?.id&&(0,u.Kp)(e.id)};return window.addEventListener("beforeunload",s),()=>{e?.id&&(0,u.Kp)(e.id),window.removeEventListener("beforeunload",s),d.current&&(d.current.innerHTML="")}},[e,n]),(0,t.useEffect)(()=>{if(i?.svg){const e=i.svg,n=e.__cursorInteractionCleanup;n&&n(),(0,u.Qy)(e,r)}},[r,i]),(0,s.jsx)("div",{className:"graph",ref:d})}])}}]); +"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[948],{948(e,n,r){var t=r(763),u=r(108),s=r(987);r.d(n,["Graph",0,({data:e,onSelect:n,dragMode:r})=>{const[a,c]=(0,t.useState)(null),o=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(!o.current)return;o.current.innerHTML="";const t=(0,u.ZG)(e,e=>n(e?e.id:null),r);o.current.append(t.svg),c(t),(0,u.F_)(e)||e.shouldSkipAutoFit()||e.fitToView();const s=()=>{e?.id&&(0,u.Kp)(e)};return window.addEventListener("beforeunload",s),()=>{e?.id&&(0,u.Kp)(e),window.removeEventListener("beforeunload",s),t.svg.__cursorInteractionCleanup(),o.current&&(o.current.innerHTML="")}},[e,n]),(0,t.useEffect)(()=>{if(a?.svg){const n=a.svg.__cursorInteractionCleanup;n&&n(),(0,u.Qy)(e,r)}},[r,a]),(0,s.jsx)("div",{className:"graph",ref:o})}])}}]); //# sourceMappingURL=948.js.map \ No newline at end of file diff --git a/cmd/mdl/webapp/dist/948.js.map b/cmd/mdl/webapp/dist/948.js.map index 71ee2034..649ddf24 100644 --- a/cmd/mdl/webapp/dist/948.js.map +++ b/cmd/mdl/webapp/dist/948.js.map @@ -1 +1 @@ -{"version":3,"file":"948.js","mappings":"qIASgC,EAAEA,OAAMC,WAAUC,eACjD,MAAOC,EAAYC,IAAiB,EAAAC,EAAAC,UAAc,MAC5CC,GAAM,EAAAF,EAAAG,QAAuB,MAyDnC,OAtDA,EAAAH,EAAAI,WAAU,KACT,IAAKF,EAAIG,QAAS,OAGlBH,EAAIG,QAAQC,UAAY,GAGxB,MAAMC,GAAI,EAAAC,EAAAC,IAAWd,EAAOe,GAAmBd,EAASc,EAAIA,EAAEC,GAAK,MAAOd,GAC1EK,EAAIG,QAAQO,OAAOL,EAAEM,KACrBd,EAAcQ,IAIT,EAAAC,EAAAM,IAAiBnB,EAAKgB,KAAQhB,EAAKoB,qBACvCpB,EAAKqB,YAGN,MAAMC,EAAqB,KACtBtB,GAAMgB,KACT,EAAAH,EAAAU,IAAcvB,EAAKgB,KAMrB,OAFAQ,OAAOC,iBAAiB,eAAgBH,GAEjC,KAEFtB,GAAMgB,KACT,EAAAH,EAAAU,IAAcvB,EAAKgB,IAGpBQ,OAAOE,oBAAoB,eAAgBJ,GAEvCf,EAAIG,UACPH,EAAIG,QAAQC,UAAY,MAGxB,CAACX,EAAMC,KAGV,EAAAI,EAAAI,WAAU,KACT,GAAIN,GAAYe,IAAK,CAEpB,MAAMA,EAAMf,EAAWe,IACjBS,EAAmBT,EAAYU,2BACjCD,GACHA,KAID,EAAAd,EAAAgB,IAAqBX,EAAKhB,EAC3B,GACE,CAACA,EAAUC,KAEP,EAAA2B,EAAAC,KAAA,OAAKC,UAAU,QAAQzB,IAAKA","sources":["webpack://app/./src/graph-view/graph-react.tsx"],"sourcesContent":["import React, {FC, useEffect, useRef, useState} from \"react\";\nimport {buildGraph, GraphData, Node, addCursorInteraction, restoreViewState, saveViewState} from \"./graph\";\n\ninterface Props {\n\tdata: GraphData;\n\tonSelect: (nodeName: string | null) => void;\n\tdragMode: 'pan' | 'select';\n}\n\nexport const Graph: FC = ({data, onSelect, dragMode}) => {\n\tconst [graphState, setGraphState] = useState(null);\n\tconst ref = useRef(null);\n\n\t// Single effect for building the graph and handling all setup/cleanup\n\tuseEffect(() => {\n\t\tif (!ref.current) return;\n\n\t\t// Clear previous content\n\t\tref.current.innerHTML = '';\n\n\t\t// Build graph with current props\n\t\tconst g = buildGraph(data, (n: Node | null) => onSelect(n ? n.id : null), dragMode);\n\t\tref.current.append(g.svg);\n\t\tsetGraphState(g);\n\t\t\n\t\t// Try to restore previous view state, otherwise use auto fit\n\t\t// Skip auto fit if we're in the middle of a reset operation to prevent infinite loop\n\t\tif (!restoreViewState(data.id) && !data.shouldSkipAutoFit()) {\n\t\t\tdata.fitToView();\n\t\t}\n\t\t// Save view state before page unload\n\t\tconst handleBeforeUnload = () => {\n\t\t\tif (data?.id) {\n\t\t\t\tsaveViewState(data.id);\n\t\t\t}\n\t\t};\n\t\t\n\t\twindow.addEventListener('beforeunload', handleBeforeUnload);\n\n\t\treturn () => {\n\t\t\t// Save view state before cleanup\n\t\t\tif (data?.id) {\n\t\t\t\tsaveViewState(data.id);\n\t\t\t}\n\t\t\t\n\t\t\twindow.removeEventListener('beforeunload', handleBeforeUnload);\n\t\t\t\n\t\t\tif (ref.current) {\n\t\t\t\tref.current.innerHTML = '';\n\t\t\t}\n\t\t};\n\t}, [data, onSelect]);\n\n\t// Effect for updating drag mode on existing graph\n\tuseEffect(() => {\n\t\tif (graphState?.svg) {\n\t\t\t// Clean up existing cursor interaction\n\t\t\tconst svg = graphState.svg;\n\t\t\tconst existingCleanup = (svg as any).__cursorInteractionCleanup;\n\t\t\tif (existingCleanup) {\n\t\t\t\texistingCleanup();\n\t\t\t}\n\t\t\t\n\t\t\t// Set up cursor interaction with current drag mode\n\t\t\taddCursorInteraction(svg, dragMode);\n\t\t}\n\t}, [dragMode, graphState]);\n\n\treturn
;\n}"],"names":["data","onSelect","dragMode","graphState","setGraphState","react__WEBPACK_IMPORTED_MODULE_0__","useState","ref","useRef","useEffect","current","innerHTML","g","_graph__WEBPACK_IMPORTED_MODULE_1__","ZG","n","id","append","svg","F_","shouldSkipAutoFit","fitToView","handleBeforeUnload","Kp","window","addEventListener","removeEventListener","existingCleanup","__cursorInteractionCleanup","Qy","react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__","jsx","className"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"948.js","mappings":"qIASgC,EAAEA,OAAMC,WAAUC,eACjD,MAAOC,EAAYC,IAAiB,EAAAC,EAAAC,UAAc,MAC5CC,GAAM,EAAAF,EAAAG,QAAuB,MA4DnC,OAzDA,EAAAH,EAAAI,WAAU,KACT,IAAKF,EAAIG,QAAS,OAGlBH,EAAIG,QAAQC,UAAY,GAGxB,MAAMC,GAAI,EAAAC,EAAAC,IAAWd,EAAOe,GAAmBd,EAASc,EAAIA,EAAEC,GAAK,MAAOd,GAC1EK,EAAIG,QAAQO,OAAOL,EAAEM,KACrBd,EAAcQ,IAIT,EAAAC,EAAAM,IAAiBnB,IAAUA,EAAKoB,qBACpCpB,EAAKqB,YAGN,MAAMC,EAAqB,KACtBtB,GAAMgB,KACT,EAAAH,EAAAU,IAAcvB,IAMhB,OAFAwB,OAAOC,iBAAiB,eAAgBH,GAEjC,KAEFtB,GAAMgB,KACT,EAAAH,EAAAU,IAAcvB,GAGfwB,OAAOE,oBAAoB,eAAgBJ,GAG1CV,EAAEM,IAAYS,6BAEXpB,EAAIG,UACPH,EAAIG,QAAQC,UAAY,MAGxB,CAACX,EAAMC,KAGV,EAAAI,EAAAI,WAAU,KACT,GAAIN,GAAYe,IAAK,CAEpB,MACMU,EADMzB,EAAWe,IACcS,2BACjCC,GACHA,KAID,EAAAf,EAAAgB,IAAqB7B,EAAME,EAC5B,GACE,CAACA,EAAUC,KAEP,EAAA2B,EAAAC,KAAA,OAAKC,UAAU,QAAQzB,IAAKA","sources":["webpack://app/./src/graph-view/graph-react.tsx"],"sourcesContent":["import React, {FC, useEffect, useRef, useState} from \"react\";\nimport {buildGraph, GraphData, Node, addCursorInteraction, restoreViewState, saveViewState} from \"./graph\";\n\ninterface Props {\n\tdata: GraphData;\n\tonSelect: (nodeName: string | null) => void;\n\tdragMode: 'pan' | 'select';\n}\n\nexport const Graph: FC = ({data, onSelect, dragMode}) => {\n\tconst [graphState, setGraphState] = useState(null);\n\tconst ref = useRef(null);\n\n\t// Single effect for building the graph and handling all setup/cleanup\n\tuseEffect(() => {\n\t\tif (!ref.current) return;\n\n\t\t// Clear previous content\n\t\tref.current.innerHTML = '';\n\n\t\t// Build graph with current props\n\t\tconst g = buildGraph(data, (n: Node | null) => onSelect(n ? n.id : null), dragMode);\n\t\tref.current.append(g.svg);\n\t\tsetGraphState(g);\n\t\t\n\t\t// Try to restore previous view state, otherwise use auto fit\n\t\t// Skip auto fit if we're in the middle of a reset operation to prevent infinite loop\n\t\tif (!restoreViewState(data) && !data.shouldSkipAutoFit()) {\n\t\t\tdata.fitToView();\n\t\t}\n\t\t// Save view state before page unload\n\t\tconst handleBeforeUnload = () => {\n\t\t\tif (data?.id) {\n\t\t\t\tsaveViewState(data);\n\t\t\t}\n\t\t};\n\t\t\n\t\twindow.addEventListener('beforeunload', handleBeforeUnload);\n\n\t\treturn () => {\n\t\t\t// Save view state before cleanup\n\t\t\tif (data?.id) {\n\t\t\t\tsaveViewState(data);\n\t\t\t}\n\t\t\t\n\t\t\twindow.removeEventListener('beforeunload', handleBeforeUnload);\n\t\t\t// Each graph has its own svg, so the next graph's buildGraph no longer\n\t\t\t// replaces this graph's window keyboard and unload handlers; remove them here.\n\t\t\t(g.svg as any).__cursorInteractionCleanup();\n\t\t\t\n\t\t\tif (ref.current) {\n\t\t\t\tref.current.innerHTML = '';\n\t\t\t}\n\t\t};\n\t}, [data, onSelect]);\n\n\t// Effect for updating drag mode on existing graph\n\tuseEffect(() => {\n\t\tif (graphState?.svg) {\n\t\t\t// Clean up existing cursor interaction\n\t\t\tconst svg = graphState.svg;\n\t\t\tconst existingCleanup = (svg as any).__cursorInteractionCleanup;\n\t\t\tif (existingCleanup) {\n\t\t\t\texistingCleanup();\n\t\t\t}\n\t\t\t\n\t\t\t// Set up cursor interaction with current drag mode\n\t\t\taddCursorInteraction(data, dragMode);\n\t\t}\n\t}, [dragMode, graphState]);\n\n\treturn
;\n}"],"names":["data","onSelect","dragMode","graphState","setGraphState","react__WEBPACK_IMPORTED_MODULE_0__","useState","ref","useRef","useEffect","current","innerHTML","g","_graph__WEBPACK_IMPORTED_MODULE_1__","ZG","n","id","append","svg","F_","shouldSkipAutoFit","fitToView","handleBeforeUnload","Kp","window","addEventListener","removeEventListener","__cursorInteractionCleanup","existingCleanup","Qy","react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__","jsx","className"],"sourceRoot":""} \ No newline at end of file diff --git a/cmd/mdl/webapp/dist/main.js b/cmd/mdl/webapp/dist/main.js index 6b9ce5d0..69669d09 100644 --- a/cmd/mdl/webapp/dist/main.js +++ b/cmd/mdl/webapp/dist/main.js @@ -1,2 +1,2 @@ -"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[792],{522(e,t,a){a.d(t,{Root:()=>T,S:()=>D});var n=a(763),o=a(108),s=a(32),i=a(71),l=(a(983),a(264));const r={};function c(e){const t=e.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1)}var d=a(686),h=a(987);const u=({model:e,currentID:t,onViewChange:a,graph:n,onAutoLayout:o,onSave:s,onToggleHelp:l,saving:r,layouting:c,dragMode:d,setDragMode:u})=>{const p=(0,i.B)(e);return(0,h.jsxs)("div",{className:"toolbar",children:[(0,h.jsx)(g,{views:p,currentID:t,onViewChange:a}),(0,h.jsx)(m,{graph:n,onAutoLayout:o,onSave:s,onToggleHelp:l,saving:r,layouting:c,dragMode:d,setDragMode:u})]})},g=({views:e,currentID:t,onViewChange:a})=>(0,h.jsxs)("div",{children:["View:",e.length>1?(0,h.jsxs)("select",{onChange:e=>a(e.target.value),value:t,children:[(0,h.jsx)("option",{disabled:!0,value:"",hidden:!0,children:"..."}),e.map(e=>(0,h.jsx)("option",{value:e.key,children:c(e.section)+": "+e.title},e.key))]}):(0,h.jsx)("span",{style:{marginLeft:"8px",fontWeight:"bold"},children:e[0]?c(e[0].section)+": "+e[0].title:"No views available"})]}),m=({graph:e,onAutoLayout:t,onSave:a,onToggleHelp:n,saving:o,layouting:s,dragMode:i,setDragMode:l})=>(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(p,{dragMode:i,setDragMode:l})}),(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(f,{graph:e})}),(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(x,{graph:e})}),(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(j,{onAutoLayout:t,layouting:s})}),(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(y,{graph:e})}),(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(S,{graph:e})}),(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(k,{onSave:a,saving:o,graph:e})}),(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(b,{onToggleHelp:n})})]}),p=({dragMode:e,setDragMode:t})=>(0,h.jsx)("button",{className:"mode-toggle "+("select"===e?"select-mode":"pan-mode"),onClick:()=>t("pan"===e?"select":"pan"),"data-tooltip":"pan"===e?"Pan Mode: Drag to pan the view (T)":"Select Mode: Drag to select elements, Shift+click to add/remove selection (T)",children:"pan"===e?(0,h.jsx)("i",{className:"fas fa-hand-paper"}):(0,h.jsx)("i",{className:"fas fa-mouse-pointer"})}),f=({graph:e})=>{const t=(0,d.sy)();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("button",{onClick:()=>e.undo(),"data-tooltip":`Undo the last change made to the diagram (${t}+Z)`,children:(0,h.jsx)("i",{className:"fas fa-undo"})}),(0,h.jsx)("button",{onClick:()=>e.redo(),"data-tooltip":`Redo the last undone action (${t}+Shift+Z / ${t}+Y)`,children:(0,h.jsx)("i",{className:"fas fa-redo"})})]})},x=({graph:e})=>{const t=(0,d.sy)();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("button",{onClick:()=>e.alignSelectionH(),"data-tooltip":`Align all selected elements horizontally (left edges) (${t}+Shift+H)`,children:(0,h.jsx)("i",{className:"fas fa-align-left"})}),(0,h.jsx)("button",{onClick:()=>e.alignSelectionV(),"data-tooltip":`Align all selected elements vertically (top edges) (${t}+Shift+A)`,children:(0,h.jsx)("i",{className:"fas fa-align-left",style:{transform:"rotate(90deg)"}})}),(0,h.jsx)("button",{onClick:()=>e.distributeSelectionH(),"data-tooltip":`Distribute selected elements evenly horizontally (equal spacing) (${t}+Alt+H)`,children:(0,h.jsx)("i",{className:"fas fa-ellipsis-h"})}),(0,h.jsx)("button",{onClick:()=>e.distributeSelectionV(),"data-tooltip":`Distribute selected elements evenly vertically (equal spacing) (${t}+Alt+V)`,children:(0,h.jsx)("i",{className:"fas fa-ellipsis-v"})})]})},j=({onAutoLayout:e,layouting:t})=>{const a=(0,d.sy)();return(0,h.jsx)("button",{className:"auto-arrange",onClick:e,disabled:t,"data-tooltip":`Automatically arrange all elements using the Layered algorithm (${a}+L)`,children:t?(0,h.jsx)("i",{className:"fas fa-spinner fa-spin"}):(0,h.jsx)("i",{className:"fas fa-magic"})})},y=({graph:e})=>{const[t,a]=(0,n.useState)(e.isGridVisible()),[o,s]=(0,n.useState)(e.isSnapToGrid()),i=(0,d.sy)();return n.useEffect(()=>{const t=()=>{a(e.isGridVisible()),s(e.isSnapToGrid())};return t(),window.addEventListener("gridStateChanged",t),()=>{window.removeEventListener("gridStateChanged",t)}},[e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("button",{className:t?"active-toggle":"inactive-toggle",onClick:()=>{e.toggleGrid(),a(e.isGridVisible())},"data-tooltip":`Toggle grid visibility (${i}+G)`,children:(0,h.jsx)("i",{className:"fas fa-th"})}),(0,h.jsx)("button",{className:o?"active-toggle":"inactive-toggle",onClick:()=>{e.toggleSnapToGrid(),s(e.isSnapToGrid())},"data-tooltip":`Toggle snap to grid (${i}+Shift+G)`,children:(0,h.jsx)("i",{className:"fas fa-magnet"})}),(0,h.jsx)("button",{onClick:()=>{e.snapAllToGrid()},disabled:!o,"data-tooltip":`Snap all elements to grid (${i}+Alt+G)`,children:(0,h.jsx)("i",{className:"fas fa-border-all"})})]})},v=()=>{const[e,t]=(0,n.useState)(100);return(0,n.useEffect)(()=>{const e=()=>{const e=Math.round(100*(0,o.IX)());t(e)};e();const a=setInterval(e,100);return()=>clearInterval(a)},[]),(0,h.jsxs)("button",{onClick:()=>(0,o.a_)(1),className:"zoom-display","data-tooltip":"Click to reset zoom to 100%",children:[e,"%"]})},S=({graph:e})=>{const t=(0,d.sy)();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("button",{onClick:()=>{(0,o.a_)(Math.max(.1,(0,o.IX)()/1.2))},"data-tooltip":`Zoom out to see more of the diagram (${t}+-)`,children:(0,h.jsx)("i",{className:"fas fa-search-minus"})}),(0,h.jsx)(v,{}),(0,h.jsx)("button",{onClick:()=>{(0,o.a_)(Math.min(5,1.2*(0,o.IX)()))},"data-tooltip":`Zoom in to see details more clearly (${t}+=)`,children:(0,h.jsx)("i",{className:"fas fa-search-plus"})}),(0,h.jsx)("button",{onClick:()=>{e.fitToView()},"data-tooltip":`Fit diagram to view (${t}+9)`,children:(0,h.jsx)("i",{className:"fas fa-expand"})})]})},k=({onSave:e,saving:t,graph:a})=>{const[o,s]=(0,n.useState)(!1),i=(0,d.sy)();return(0,n.useEffect)(()=>{const e=()=>{s(a.changed())};e();const t=setInterval(e,100);return()=>clearInterval(t)},[a]),(0,h.jsx)("button",{className:o?"grp":"action",disabled:t,onClick:e,"data-tooltip":`Save the current diagram layout (${i}+S)`,children:t?(0,h.jsx)("i",{className:"fas fa-spinner fa-spin"}):(0,h.jsx)("i",{className:"fas fa-save"})})},b=({onToggleHelp:e})=>(0,h.jsx)("button",{onClick:e,"data-tooltip":"Show keyboard shortcuts and help information (Shift+? / Shift+F1)",children:(0,h.jsx)("i",{className:"fas fa-question-circle"})}),C=(0,n.lazy)(()=>Promise.resolve().then(a.bind(a,264)).then(e=>({default:e.Help}))),w=(0,n.lazy)(()=>a.e(948).then(a.bind(a,948)).then(e=>({default:e.Graph}))),N=(e,t)=>{console.error(`${e} failed:`,t),alert(`${e} failed. See console for details.`)},T=({model:e,layout:t})=>(0,h.jsx)(s.Kd,{children:(0,h.jsx)(s.BV,{children:(0,h.jsx)(s.qh,{path:"/",element:(0,h.jsx)(R,{model:e,layouts:t})})})}),D=()=>{var e;(e=new URLSearchParams(document.location.search).get("id")||"")?delete r[e]:Object.keys(r).forEach(e=>delete r[e])},R=({model:e,layouts:t})=>{const[a,o]=(0,s.ok)(),c=decodeURI(a.get("id")||""),[d,g]=(0,n.useState)(!1),[m,p]=(0,n.useState)("pan"),f=((e,t,a)=>{if(r[a])return r[a];const n=(0,i.R)(e,t,a);return n&&(r[a]=n),n})(e,t,c),{layouting:x,handleAutoLayout:j}=(e=>{const[t,a]=(0,n.useState)(!1);return{layouting:t,handleAutoLayout:(0,n.useCallback)(async t=>{a(!0);try{const a={direction:e.layoutDirection||"DOWN",...t||{}};await e.autoLayout(a)}finally{a(!1)}},[e])}})(f||{}),{saving:y,handleSave:v}=((e,t)=>{const[a,o]=(0,n.useState)(!1);return{saving:a,handleSave:(0,n.useCallback)(async()=>{o(!0);try{const a=await fetch("data/save?id="+encodeURIComponent(t),{method:"post",body:e.exportSVG()});if(202!==a.status){const e=(await a.text()).trim();throw new Error(e||`save failed with HTTP ${a.status}`)}e.setSaved()}finally{o(!1)}},[e,t])}})(f||{},c);if(!f)return(0,h.jsx)(E,{model:e});const S=(0,n.useCallback)(()=>{g(!d)},[d]),k=(0,n.useCallback)(()=>{j().catch(e=>N("Layout",e))},[j]),b=(0,n.useCallback)(()=>{v().catch(e=>N("Save",e))},[v]);(0,n.useEffect)(()=>{f&&f.name&&(document.title=`${f.name} - Model`)},[f]),((e,t,a,o,s,i)=>{(0,n.useEffect)(()=>{const n=n=>{const r=(0,l.Yp)(n);r&&n.preventDefault(),"help"===r?e():"save"===r?t():r===l.aX&&s&&o?s("pan"===o?"select":"pan"):a&&(r===l.t9?a.alignSelectionH():r===l.Jk?a.alignSelectionV():r===l.DE?a.distributeSelectionH():r===l.Vy?a.distributeSelectionV():r===l.Hd&&i?i():r===l._t?a.resetView():r===l.Op?a.toggleGrid():r===l.hZ?a.toggleSnapToGrid():r===l.OE?a.snapAllToGrid():r===l.Gg?a.moveSelected(-a.getGridSize(),0):r===l.J8?a.moveSelected(-1,0,!0):r===l.b3?a.moveSelected(a.getGridSize(),0):r===l.iD?a.moveSelected(1,0,!0):r===l.uK?a.moveSelected(0,-a.getGridSize()):r===l.l8?a.moveSelected(0,-1,!0):r===l.rB?a.moveSelected(0,a.getGridSize()):r===l.mt&&a.moveSelected(0,1,!0))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t,a,o,s,i])})(S,b,f,m,p,k);const T=(0,n.useCallback)(e=>{o({id:encodeURIComponent(e)})},[o]),D=(0,n.useCallback)(e=>{if(e){const a=f.metadata.elements.find(t=>t.id===e);console.log((t=a,JSON.parse(JSON.stringify(t))))}var t},[f]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(u,{model:e,currentID:c,onViewChange:T,graph:f,onAutoLayout:k,onSave:b,onToggleHelp:S,saving:y,layouting:x,dragMode:m,setDragMode:p}),(0,h.jsx)(n.Suspense,{fallback:(0,h.jsx)("div",{children:"Loading graph..."}),children:(0,h.jsx)(w,{data:f,onSelect:D,dragMode:m},c)}),d&&(0,h.jsx)(n.Suspense,{fallback:(0,h.jsx)("div",{children:"Loading help..."}),children:(0,h.jsx)(C,{})})]})},E=({model:e})=>{const t=(0,i.B)(e);return n.useEffect(()=>{document.title="Model - Architecture Diagrams as Code",t.length>0&&(document.location.href="?id="+t[0].key)},[t]),t.length>0?(0,h.jsxs)(h.Fragment,{children:["Redirecting to ",t[0].title]}):(0,h.jsx)(h.Fragment,{children:"No views available"})}},279(e,t,a){var n=a(122),o=a(763),s=a(522);a(574),a(919),a(769);class i{callback;handler;running=!1;timeoutId=null;constructor(e){this.callback=e,this.handler=()=>{this.running=!1,this.timeoutId=null,this.callback()}}start(e){this.running&&this.stop(),this.timeoutId=setTimeout(this.handler,e),this.running=!0}stop(){this.running&&null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.running=!1,this.timeoutId=null)}isRunning(){return this.running}}class l{static DEFAULT_OPTIONS={minDelay:1e3,maxDelay:6e4,handshakeTimeout:5e3};static LIVERELOAD_PROTOCOLS=["http://livereload.com/protocols/official-9","http://livereload.com/protocols/2.x-remote-control"];uri;options;fileChangeHandler;socket=null;nextDelay;connectionDesired=!1;disconnectionReason="";handshakeTimeout;reconnectTimer;constructor(e,t){this.fileChangeHandler=e,this.options={...l.DEFAULT_OPTIONS,...t},this.uri="ws://localhost:35729/livereload",this.nextDelay=this.options.minDelay,this.handshakeTimeout=new i(()=>this.handleHandshakeTimeout()),this.reconnectTimer=new i(()=>this.attemptReconnection())}connect(){this.connectionDesired=!0,this.isSocketConnected()||(this.prepareForConnection(),this.createWebSocket())}disconnect(){this.connectionDesired=!1,this.reconnectTimer.stop(),this.isSocketConnected()&&(this.disconnectionReason="manual",this.socket.close())}isSocketConnected(){return null!==this.socket&&this.socket.readyState===WebSocket.OPEN}prepareForConnection(){this.reconnectTimer.stop(),this.disconnectionReason="cannot-connect"}createWebSocket(){this.socket=new WebSocket(this.uri),this.socket.onopen=()=>this.handleOpen(),this.socket.onclose=()=>this.handleClose(),this.socket.onmessage=e=>this.handleMessage(e),this.socket.onerror=()=>this.handleError()}handleOpen(){this.disconnectionReason="handshake-failed",this.startHandshake()}handleClose(){console.log(`WebSocket disconnected: ${this.disconnectionReason}. Retry in ${this.nextDelay}ms`),this.scheduleReconnection()}handleMessage(e){try{const t=JSON.parse(e.data);this.processMessage(t)}catch(e){console.error("Failed to parse WebSocket message:",e)}}handleError(){}processMessage(e){switch(e.command){case"hello":this.handleHelloMessage();break;case"reload":this.handleReloadMessage(e);break;default:console.log("Unknown WebSocket message received:",e)}}handleHelloMessage(){this.handshakeTimeout.stop(),this.nextDelay=this.options.minDelay}handleReloadMessage(e){this.reconnectTimer.stop(),this.connect(),e.path&&this.fileChangeHandler(e.path)}startHandshake(){const e={command:"hello",protocols:l.LIVERELOAD_PROTOCOLS,ver:"3.3.1"};this.sendCommand(e),this.handshakeTimeout.start(this.options.handshakeTimeout)}handleHandshakeTimeout(){this.isSocketConnected()&&(this.disconnectionReason="handshake-timeout",this.socket.close())}attemptReconnection(){this.connectionDesired&&this.connect()}scheduleReconnection(){this.connectionDesired&&(this.reconnectTimer.isRunning()||(this.reconnectTimer.start(this.nextDelay),this.nextDelay=Math.min(this.options.maxDelay,2*this.nextDelay)))}sendCommand(e){this.isSocketConnected()&&this.socket.send(JSON.stringify(e))}}var r=a(718),c=a(987);const d=(0,o.lazy)(()=>Promise.resolve().then(a.bind(a,522)).then(e=>({default:e.Root}))),h=()=>{const[e,t]=(0,o.useState)({data:null,error:null,loading:!0}),a=async()=>{t(e=>({...e,loading:!0,error:null}));try{const[e,a]=await Promise.all([fetch("data/model.json"),fetch("data/layout.json")]);if(!e.ok)throw new Error(`Failed to fetch model: ${e.statusText}`);if(!a.ok)throw new Error(`Failed to fetch layout: ${a.statusText}`);const[n,o]=await Promise.all([e.json(),a.json()]);await(0,r.Mt)(),t({data:{model:n,layout:o},error:null,loading:!1})}catch(e){console.error("Failed to load data:",e),t({data:null,error:e instanceof Error?e.message:"Unknown error occurred",loading:!1})}},n=e=>{e.endsWith(".svg")||(console.log("File changed:",e),(0,s.S)(),a())};return(0,o.useEffect)(()=>{const e=new l(n);return e.connect(),a(),()=>{e.disconnect()}},[]),e.loading?(0,c.jsx)(u,{}):e.error?(0,c.jsx)(g,{error:e.error,onRetry:a}):e.data?(0,c.jsx)(o.Suspense,{fallback:(0,c.jsx)(u,{}),children:(0,c.jsx)(d,{model:e.data.model,layout:e.data.layout})}):(0,c.jsx)(g,{error:"No data available",onRetry:a})},u=()=>(0,c.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"Arial, sans-serif"},children:(0,c.jsx)("div",{children:"Loading..."})}),g=({error:e,onRetry:t})=>(0,c.jsxs)("div",{style:{padding:"20px",color:"red",fontFamily:"monospace",whiteSpace:"pre-wrap",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh"},children:[(0,c.jsx)("h2",{children:"Error loading application"}),(0,c.jsx)("p",{children:e}),(0,c.jsx)("button",{onClick:t,style:{padding:"10px 20px",fontSize:"16px",cursor:"pointer",backgroundColor:"#007bff",color:"white",border:"none",borderRadius:"4px"},children:"Retry"})]}),m=document.getElementById("root");if(!m)throw new Error("Root container not found");(0,n.createRoot)(m).render((0,c.jsx)(h,{}))}},e=>{e.O(0,[453,96,286],()=>e(e.s=279)),e.O()}]); +"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[792],{522(e,t,a){a.d(t,{Root:()=>T,S:()=>D});var n=a(763),o=a(108),s=a(32),i=a(71),l=(a(983),a(264));const r={};function c(e){const t=e.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1)}var d=a(686),h=a(987);const u=({model:e,currentID:t,onViewChange:a,graph:n,onAutoLayout:o,onSave:s,onToggleHelp:l,saving:r,layouting:c,dragMode:d,setDragMode:u})=>{const p=(0,i.B)(e);return(0,h.jsxs)("div",{className:"toolbar",children:[(0,h.jsx)(g,{views:p,currentID:t,onViewChange:a}),(0,h.jsx)(m,{graph:n,onAutoLayout:o,onSave:s,onToggleHelp:l,saving:r,layouting:c,dragMode:d,setDragMode:u})]})},g=({views:e,currentID:t,onViewChange:a})=>(0,h.jsxs)("div",{children:["View:",e.length>1?(0,h.jsxs)("select",{onChange:e=>a(e.target.value),value:t,children:[(0,h.jsx)("option",{disabled:!0,value:"",hidden:!0,children:"..."}),e.map(e=>(0,h.jsx)("option",{value:e.key,children:c(e.section)+": "+e.title},e.key))]}):(0,h.jsx)("span",{style:{marginLeft:"8px",fontWeight:"bold"},children:e[0]?c(e[0].section)+": "+e[0].title:"No views available"})]}),m=({graph:e,onAutoLayout:t,onSave:a,onToggleHelp:n,saving:o,layouting:s,dragMode:i,setDragMode:l})=>(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(p,{dragMode:i,setDragMode:l})}),(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(f,{graph:e})}),(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(x,{graph:e})}),(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(j,{onAutoLayout:t,layouting:s})}),(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(y,{graph:e})}),(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(S,{graph:e})}),(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(k,{onSave:a,saving:o,graph:e})}),(0,h.jsx)("div",{className:"toolbar-group",children:(0,h.jsx)(b,{onToggleHelp:n})})]}),p=({dragMode:e,setDragMode:t})=>(0,h.jsx)("button",{className:"mode-toggle "+("select"===e?"select-mode":"pan-mode"),onClick:()=>t("pan"===e?"select":"pan"),"data-tooltip":"pan"===e?"Pan Mode: Drag to pan the view (T)":"Select Mode: Drag to select elements, Shift+click to add/remove selection (T)",children:"pan"===e?(0,h.jsx)("i",{className:"fas fa-hand-paper"}):(0,h.jsx)("i",{className:"fas fa-mouse-pointer"})}),f=({graph:e})=>{const t=(0,d.sy)();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("button",{onClick:()=>e.undo(),"data-tooltip":`Undo the last change made to the diagram (${t}+Z)`,children:(0,h.jsx)("i",{className:"fas fa-undo"})}),(0,h.jsx)("button",{onClick:()=>e.redo(),"data-tooltip":`Redo the last undone action (${t}+Shift+Z / ${t}+Y)`,children:(0,h.jsx)("i",{className:"fas fa-redo"})})]})},x=({graph:e})=>{const t=(0,d.sy)();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("button",{onClick:()=>e.alignSelectionH(),"data-tooltip":`Align all selected elements horizontally (left edges) (${t}+Shift+H)`,children:(0,h.jsx)("i",{className:"fas fa-align-left"})}),(0,h.jsx)("button",{onClick:()=>e.alignSelectionV(),"data-tooltip":`Align all selected elements vertically (top edges) (${t}+Shift+A)`,children:(0,h.jsx)("i",{className:"fas fa-align-left",style:{transform:"rotate(90deg)"}})}),(0,h.jsx)("button",{onClick:()=>e.distributeSelectionH(),"data-tooltip":`Distribute selected elements evenly horizontally (equal spacing) (${t}+Alt+H)`,children:(0,h.jsx)("i",{className:"fas fa-ellipsis-h"})}),(0,h.jsx)("button",{onClick:()=>e.distributeSelectionV(),"data-tooltip":`Distribute selected elements evenly vertically (equal spacing) (${t}+Alt+V)`,children:(0,h.jsx)("i",{className:"fas fa-ellipsis-v"})})]})},j=({onAutoLayout:e,layouting:t})=>{const a=(0,d.sy)();return(0,h.jsx)("button",{className:"auto-arrange",onClick:e,disabled:t,"data-tooltip":`Automatically arrange all elements using the Layered algorithm (${a}+L)`,children:t?(0,h.jsx)("i",{className:"fas fa-spinner fa-spin"}):(0,h.jsx)("i",{className:"fas fa-magic"})})},y=({graph:e})=>{const[t,a]=(0,n.useState)(e.isGridVisible()),[o,s]=(0,n.useState)(e.isSnapToGrid()),i=(0,d.sy)();return n.useEffect(()=>{const t=()=>{a(e.isGridVisible()),s(e.isSnapToGrid())};return t(),window.addEventListener("gridStateChanged",t),()=>{window.removeEventListener("gridStateChanged",t)}},[e]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("button",{className:t?"active-toggle":"inactive-toggle",onClick:()=>{e.toggleGrid(),a(e.isGridVisible())},"data-tooltip":`Toggle grid visibility (${i}+G)`,children:(0,h.jsx)("i",{className:"fas fa-th"})}),(0,h.jsx)("button",{className:o?"active-toggle":"inactive-toggle",onClick:()=>{e.toggleSnapToGrid(),s(e.isSnapToGrid())},"data-tooltip":`Toggle snap to grid (${i}+Shift+G)`,children:(0,h.jsx)("i",{className:"fas fa-magnet"})}),(0,h.jsx)("button",{onClick:()=>{e.snapAllToGrid()},disabled:!o,"data-tooltip":`Snap all elements to grid (${i}+Alt+G)`,children:(0,h.jsx)("i",{className:"fas fa-border-all"})})]})},v=({graph:e})=>{const[t,a]=(0,n.useState)(100);return(0,n.useEffect)(()=>{const t=()=>{const t=Math.round(100*(0,o.IX)(e));a(t)};t();const n=setInterval(t,100);return()=>clearInterval(n)},[e]),(0,h.jsxs)("button",{onClick:()=>(0,o.a_)(e,1),className:"zoom-display","data-tooltip":"Click to reset zoom to 100%",children:[t,"%"]})},S=({graph:e})=>{const t=(0,d.sy)();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("button",{onClick:()=>{(0,o.a_)(e,Math.max(.1,(0,o.IX)(e)/1.2))},"data-tooltip":`Zoom out to see more of the diagram (${t}+-)`,children:(0,h.jsx)("i",{className:"fas fa-search-minus"})}),(0,h.jsx)(v,{graph:e}),(0,h.jsx)("button",{onClick:()=>{(0,o.a_)(e,Math.min(5,1.2*(0,o.IX)(e)))},"data-tooltip":`Zoom in to see details more clearly (${t}+=)`,children:(0,h.jsx)("i",{className:"fas fa-search-plus"})}),(0,h.jsx)("button",{onClick:()=>{e.fitToView()},"data-tooltip":`Fit diagram to view (${t}+9)`,children:(0,h.jsx)("i",{className:"fas fa-expand"})})]})},k=({onSave:e,saving:t,graph:a})=>{const[o,s]=(0,n.useState)(!1),i=(0,d.sy)();return(0,n.useEffect)(()=>{const e=()=>{s(a.changed())};e();const t=setInterval(e,100);return()=>clearInterval(t)},[a]),(0,h.jsx)("button",{className:o?"grp":"action",disabled:t,onClick:e,"data-tooltip":`Save the current diagram layout (${i}+S)`,children:t?(0,h.jsx)("i",{className:"fas fa-spinner fa-spin"}):(0,h.jsx)("i",{className:"fas fa-save"})})},b=({onToggleHelp:e})=>(0,h.jsx)("button",{onClick:e,"data-tooltip":"Show keyboard shortcuts and help information (Shift+? / Shift+F1)",children:(0,h.jsx)("i",{className:"fas fa-question-circle"})}),C=(0,n.lazy)(()=>Promise.resolve().then(a.bind(a,264)).then(e=>({default:e.Help}))),w=(0,n.lazy)(()=>a.e(948).then(a.bind(a,948)).then(e=>({default:e.Graph}))),N=(e,t)=>{console.error(`${e} failed:`,t),alert(`${e} failed. See console for details.`)},T=({model:e,layout:t})=>(0,h.jsx)(s.Kd,{children:(0,h.jsx)(s.BV,{children:(0,h.jsx)(s.qh,{path:"/",element:(0,h.jsx)(R,{model:e,layouts:t})})})}),D=()=>{var e;(e=new URLSearchParams(document.location.search).get("id")||"")?delete r[e]:Object.keys(r).forEach(e=>delete r[e])},R=({model:e,layouts:t})=>{const[a,o]=(0,s.ok)(),c=decodeURI(a.get("id")||""),[d,g]=(0,n.useState)(!1),[m,p]=(0,n.useState)("pan"),f=((e,t,a)=>{if(r[a])return r[a];const n=(0,i.R)(e,t,a);return n&&(r[a]=n),n})(e,t,c),{layouting:x,handleAutoLayout:j}=(e=>{const[t,a]=(0,n.useState)(!1);return{layouting:t,handleAutoLayout:(0,n.useCallback)(async t=>{a(!0);try{const a={direction:e.layoutDirection||"DOWN",...t||{}};await e.autoLayout(a)}finally{a(!1)}},[e])}})(f||{}),{saving:y,handleSave:v}=((e,t)=>{const[a,o]=(0,n.useState)(!1);return{saving:a,handleSave:(0,n.useCallback)(async()=>{o(!0);try{const a=await fetch("data/save?id="+encodeURIComponent(t),{method:"post",body:e.exportSVG()});if(202!==a.status){const e=(await a.text()).trim();throw new Error(e||`save failed with HTTP ${a.status}`)}e.setSaved()}finally{o(!1)}},[e,t])}})(f||{},c);if(!f)return(0,h.jsx)(E,{model:e});const S=(0,n.useCallback)(()=>{g(!d)},[d]),k=(0,n.useCallback)(()=>{j().catch(e=>N("Layout",e))},[j]),b=(0,n.useCallback)(()=>{v().catch(e=>N("Save",e))},[v]);(0,n.useEffect)(()=>{f&&f.name&&(document.title=`${f.name} - Model`)},[f]),((e,t,a,o,s,i)=>{(0,n.useEffect)(()=>{const n=n=>{const r=(0,l.Yp)(n);r&&n.preventDefault(),"help"===r?e():"save"===r?t():r===l.aX&&s&&o?s("pan"===o?"select":"pan"):a&&(r===l.t9?a.alignSelectionH():r===l.Jk?a.alignSelectionV():r===l.DE?a.distributeSelectionH():r===l.Vy?a.distributeSelectionV():r===l.Hd&&i?i():r===l._t?a.resetView():r===l.Op?a.toggleGrid():r===l.hZ?a.toggleSnapToGrid():r===l.OE?a.snapAllToGrid():r===l.Gg?a.moveSelected(-a.getGridSize(),0):r===l.J8?a.moveSelected(-1,0,!0):r===l.b3?a.moveSelected(a.getGridSize(),0):r===l.iD?a.moveSelected(1,0,!0):r===l.uK?a.moveSelected(0,-a.getGridSize()):r===l.l8?a.moveSelected(0,-1,!0):r===l.rB?a.moveSelected(0,a.getGridSize()):r===l.mt&&a.moveSelected(0,1,!0))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t,a,o,s,i])})(S,b,f,m,p,k);const T=(0,n.useCallback)(e=>{o({id:encodeURIComponent(e)})},[o]),D=(0,n.useCallback)(e=>{if(e){const a=f.metadata.elements.find(t=>t.id===e);console.log((t=a,JSON.parse(JSON.stringify(t))))}var t},[f]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(u,{model:e,currentID:c,onViewChange:T,graph:f,onAutoLayout:k,onSave:b,onToggleHelp:S,saving:y,layouting:x,dragMode:m,setDragMode:p}),(0,h.jsx)(n.Suspense,{fallback:(0,h.jsx)("div",{children:"Loading graph..."}),children:(0,h.jsx)(w,{data:f,onSelect:D,dragMode:m},c)}),d&&(0,h.jsx)(n.Suspense,{fallback:(0,h.jsx)("div",{children:"Loading help..."}),children:(0,h.jsx)(C,{})})]})},E=({model:e})=>{const t=(0,i.B)(e);return n.useEffect(()=>{document.title="Model - Architecture Diagrams as Code",t.length>0&&(document.location.href="?id="+t[0].key)},[t]),t.length>0?(0,h.jsxs)(h.Fragment,{children:["Redirecting to ",t[0].title]}):(0,h.jsx)(h.Fragment,{children:"No views available"})}},279(e,t,a){var n=a(122),o=a(763),s=a(522);a(574),a(919),a(769);class i{callback;handler;running=!1;timeoutId=null;constructor(e){this.callback=e,this.handler=()=>{this.running=!1,this.timeoutId=null,this.callback()}}start(e){this.running&&this.stop(),this.timeoutId=setTimeout(this.handler,e),this.running=!0}stop(){this.running&&null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.running=!1,this.timeoutId=null)}isRunning(){return this.running}}class l{static DEFAULT_OPTIONS={minDelay:1e3,maxDelay:6e4,handshakeTimeout:5e3};static LIVERELOAD_PROTOCOLS=["http://livereload.com/protocols/official-9","http://livereload.com/protocols/2.x-remote-control"];uri;options;fileChangeHandler;socket=null;nextDelay;connectionDesired=!1;disconnectionReason="";handshakeTimeout;reconnectTimer;constructor(e,t){this.fileChangeHandler=e,this.options={...l.DEFAULT_OPTIONS,...t},this.uri="ws://localhost:35729/livereload",this.nextDelay=this.options.minDelay,this.handshakeTimeout=new i(()=>this.handleHandshakeTimeout()),this.reconnectTimer=new i(()=>this.attemptReconnection())}connect(){this.connectionDesired=!0,this.isSocketConnected()||(this.prepareForConnection(),this.createWebSocket())}disconnect(){this.connectionDesired=!1,this.reconnectTimer.stop(),this.isSocketConnected()&&(this.disconnectionReason="manual",this.socket.close())}isSocketConnected(){return null!==this.socket&&this.socket.readyState===WebSocket.OPEN}prepareForConnection(){this.reconnectTimer.stop(),this.disconnectionReason="cannot-connect"}createWebSocket(){this.socket=new WebSocket(this.uri),this.socket.onopen=()=>this.handleOpen(),this.socket.onclose=()=>this.handleClose(),this.socket.onmessage=e=>this.handleMessage(e),this.socket.onerror=()=>this.handleError()}handleOpen(){this.disconnectionReason="handshake-failed",this.startHandshake()}handleClose(){console.log(`WebSocket disconnected: ${this.disconnectionReason}. Retry in ${this.nextDelay}ms`),this.scheduleReconnection()}handleMessage(e){try{const t=JSON.parse(e.data);this.processMessage(t)}catch(e){console.error("Failed to parse WebSocket message:",e)}}handleError(){}processMessage(e){switch(e.command){case"hello":this.handleHelloMessage();break;case"reload":this.handleReloadMessage(e);break;default:console.log("Unknown WebSocket message received:",e)}}handleHelloMessage(){this.handshakeTimeout.stop(),this.nextDelay=this.options.minDelay}handleReloadMessage(e){this.reconnectTimer.stop(),this.connect(),e.path&&this.fileChangeHandler(e.path)}startHandshake(){const e={command:"hello",protocols:l.LIVERELOAD_PROTOCOLS,ver:"3.3.1"};this.sendCommand(e),this.handshakeTimeout.start(this.options.handshakeTimeout)}handleHandshakeTimeout(){this.isSocketConnected()&&(this.disconnectionReason="handshake-timeout",this.socket.close())}attemptReconnection(){this.connectionDesired&&this.connect()}scheduleReconnection(){this.connectionDesired&&(this.reconnectTimer.isRunning()||(this.reconnectTimer.start(this.nextDelay),this.nextDelay=Math.min(this.options.maxDelay,2*this.nextDelay)))}sendCommand(e){this.isSocketConnected()&&this.socket.send(JSON.stringify(e))}}var r=a(718),c=a(987);const d=(0,o.lazy)(()=>Promise.resolve().then(a.bind(a,522)).then(e=>({default:e.Root}))),h=()=>{const[e,t]=(0,o.useState)({data:null,error:null,loading:!0}),a=async()=>{t(e=>({...e,loading:!0,error:null}));try{const[e,a]=await Promise.all([fetch("data/model.json"),fetch("data/layout.json")]);if(!e.ok)throw new Error(`Failed to fetch model: ${e.statusText}`);if(!a.ok)throw new Error(`Failed to fetch layout: ${a.statusText}`);const[n,o]=await Promise.all([e.json(),a.json()]);await(0,r.Mt)(),t({data:{model:n,layout:o},error:null,loading:!1})}catch(e){console.error("Failed to load data:",e),t({data:null,error:e instanceof Error?e.message:"Unknown error occurred",loading:!1})}},n=e=>{e.endsWith(".svg")||(console.log("File changed:",e),(0,s.S)(),a())};return(0,o.useEffect)(()=>{const e=new l(n);return e.connect(),a(),()=>{e.disconnect()}},[]),e.loading?(0,c.jsx)(u,{}):e.error?(0,c.jsx)(g,{error:e.error,onRetry:a}):e.data?(0,c.jsx)(o.Suspense,{fallback:(0,c.jsx)(u,{}),children:(0,c.jsx)(d,{model:e.data.model,layout:e.data.layout})}):(0,c.jsx)(g,{error:"No data available",onRetry:a})},u=()=>(0,c.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"Arial, sans-serif"},children:(0,c.jsx)("div",{children:"Loading..."})}),g=({error:e,onRetry:t})=>(0,c.jsxs)("div",{style:{padding:"20px",color:"red",fontFamily:"monospace",whiteSpace:"pre-wrap",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh"},children:[(0,c.jsx)("h2",{children:"Error loading application"}),(0,c.jsx)("p",{children:e}),(0,c.jsx)("button",{onClick:t,style:{padding:"10px 20px",fontSize:"16px",cursor:"pointer",backgroundColor:"#007bff",color:"white",border:"none",borderRadius:"4px"},children:"Retry"})]}),m=document.getElementById("root");if(!m)throw new Error("Root container not found");(0,n.createRoot)(m).render((0,c.jsx)(h,{}))}},e=>{e.O(0,[453,96,286],()=>e(e.s=279)),e.O()}]); //# sourceMappingURL=main.js.map \ No newline at end of file diff --git a/cmd/mdl/webapp/dist/main.js.map b/cmd/mdl/webapp/dist/main.js.map index a7334f88..35dec5eb 100644 --- a/cmd/mdl/webapp/dist/main.js.map +++ b/cmd/mdl/webapp/dist/main.js.map @@ -1 +1 @@ -{"version":3,"file":"main.js","mappings":"yKA6BA,MAAMA,EAAuC,CAAC,ECvBvC,SAASC,EAAaC,GAC3B,MAAMC,EAAQD,EAAME,QAAQ,WAAY,OACxC,OAAOD,EAAME,OAAO,GAAGC,cAAgBH,EAAMI,MAAM,EACrD,uBCYO,MAAMC,EAA4B,EACvCC,QAAOC,YAAWC,eAAcC,QAChCC,eAAcC,SAAQC,eAAcC,SAAQC,YAC5CC,WAAUC,kBAEV,MAAMC,GAAQ,EAAAC,EAAAC,GAAUb,GAExB,OACE,EAAAc,EAAAC,MAAA,OAAKC,UAAU,UAASC,SAAA,EACtB,EAAAH,EAAAI,KAACC,EAAY,CACXR,MAAOA,E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EACTnQ,MAAO,CACNuQ,QAAS,YACTI,SAAU,OACVC,OAAQ,UACRC,gBAAiB,UACjBL,MAAO,QACPM,OAAQ,OACRC,aAAc,OACb/R,SACF,aAOGgS,EAAYxL,SAASyL,eAAe,QAC1C,IAAKD,EACJ,MAAM,IAAInJ,MAAM,6BAGJ,EAAAqJ,EAAAC,YAAWH,GACnBI,QAAO,EAAAvS,EAAAI,KAAC+P,EAAG","sources":["webpack://app/./src/hooks.ts","webpack://app/./src/utils.ts","webpack://app/./src/components/Toolbar.tsx","webpack://app/./src/Root.tsx","webpack://app/./src/websocket.ts","webpack://app/./src/index.tsx"],"sourcesContent":["import { useState, useCallback, useEffect } from 'react';\nimport { GraphData } from './graph-view/graph';\nimport { parseView } from './parseModel';\nimport { LayoutOptions } from './graph-view/layout';\nimport { \n findShortcut, \n HELP, \n SAVE, \n TOGGLE_DRAG_MODE,\n ALIGN_HORIZONTAL,\n ALIGN_VERTICAL,\n DISTRIBUTE_HORIZONTAL,\n DISTRIBUTE_VERTICAL,\n AUTO_LAYOUT,\n RESET_POSITION,\n TOGGLE_GRID,\n TOGGLE_SNAP_TO_GRID,\n SNAP_ALL_TO_GRID,\n MOVE_LEFT,\n MOVE_RIGHT,\n MOVE_UP,\n MOVE_DOWN,\n MOVE_LEFT_FINE,\n MOVE_RIGHT_FINE,\n MOVE_UP_FINE,\n MOVE_DOWN_FINE\n} from './shortcuts';\n\n// Global state for graphs to preserve edits\nconst graphs: { [key: string]: GraphData } = {};\n\n// Custom hook for graph management\nexport const useGraph = (model: any, layouts: any, currentID: string): GraphData | null => {\n if (graphs[currentID]) {\n return graphs[currentID];\n }\n \n const graph = parseView(model, layouts, currentID);\n if (graph) {\n graphs[currentID] = graph;\n }\n \n return graph;\n};\n\n// Custom hook for auto layout functionality\nexport const useAutoLayout = (graph: GraphData) => {\n const [layouting, setLayouting] = useState(false);\n\n const handleAutoLayout = useCallback(async (opts?: LayoutOptions) => {\n setLayouting(true);\n try {\n const options: LayoutOptions = {\n direction: graph.layoutDirection || 'DOWN',\n ...(opts || {})\n };\n await graph.autoLayout(options);\n } finally {\n setLayouting(false);\n }\n }, [graph]);\n\n return { layouting, handleAutoLayout };\n};\n\n// Custom hook for save functionality\nexport const useSave = (graph: GraphData, currentID: string) => {\n const [saving, setSaving] = useState(false);\n\n const handleSave = useCallback(async () => {\n setSaving(true);\n \n try {\n const response = await fetch('data/save?id=' + encodeURIComponent(currentID), {\n method: 'post',\n body: graph.exportSVG()\n });\n \n if (response.status !== 202) {\n const detail = (await response.text()).trim();\n throw new Error(detail || `save failed with HTTP ${response.status}`);\n }\n graph.setSaved();\n } finally {\n setSaving(false);\n }\n }, [graph, currentID]);\n\n return { saving, handleSave };\n};\n\n// Custom hook for keyboard shortcuts\nexport const useKeyboardShortcuts = (\n toggleHelp: () => void,\n saveLayout: () => void,\n graph?: GraphData,\n dragMode?: 'pan' | 'select',\n setDragMode?: (mode: 'pan' | 'select') => void,\n onAutoLayout?: () => void\n) => {\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n const shortcut = findShortcut(e);\n \n // Prevent browser default for all recognized shortcuts\n if (shortcut) {\n e.preventDefault();\n }\n \n if (shortcut === HELP) {\n toggleHelp();\n } else if (shortcut === SAVE) {\n saveLayout();\n } else if (shortcut === TOGGLE_DRAG_MODE && setDragMode && dragMode) {\n setDragMode(dragMode === 'pan' ? 'select' : 'pan');\n } else if (graph) {\n // Graph-dependent shortcuts\n if (shortcut === ALIGN_HORIZONTAL) {\n graph.alignSelectionH();\n } else if (shortcut === ALIGN_VERTICAL) {\n graph.alignSelectionV();\n } else if (shortcut === DISTRIBUTE_HORIZONTAL) {\n graph.distributeSelectionH();\n } else if (shortcut === DISTRIBUTE_VERTICAL) {\n graph.distributeSelectionV();\n } else if (shortcut === AUTO_LAYOUT && onAutoLayout) {\n onAutoLayout();\n } else if (shortcut === RESET_POSITION) {\n graph.resetView();\n } else if (shortcut === TOGGLE_GRID) {\n graph.toggleGrid();\n } else if (shortcut === TOGGLE_SNAP_TO_GRID) {\n graph.toggleSnapToGrid();\n } else if (shortcut === SNAP_ALL_TO_GRID) {\n graph.snapAllToGrid();\n } else if (shortcut === MOVE_LEFT) {\n graph.moveSelected(-graph.getGridSize(), 0);\n } else if (shortcut === MOVE_LEFT_FINE) {\n graph.moveSelected(-1, 0, true); // Disable snap for fine movement\n } else if (shortcut === MOVE_RIGHT) {\n graph.moveSelected(graph.getGridSize(), 0);\n } else if (shortcut === MOVE_RIGHT_FINE) {\n graph.moveSelected(1, 0, true); // Disable snap for fine movement\n } else if (shortcut === MOVE_UP) {\n graph.moveSelected(0, -graph.getGridSize());\n } else if (shortcut === MOVE_UP_FINE) {\n graph.moveSelected(0, -1, true); // Disable snap for fine movement\n } else if (shortcut === MOVE_DOWN) {\n graph.moveSelected(0, graph.getGridSize());\n } else if (shortcut === MOVE_DOWN_FINE) {\n graph.moveSelected(0, 1, true); // Disable snap for fine movement\n }\n }\n };\n\n window.addEventListener('keydown', handleKeyDown);\n return () => window.removeEventListener('keydown', handleKeyDown);\n }, [toggleHelp, saveLayout, graph, dragMode, setDragMode, onAutoLayout]);\n};\n\n// Utility function to clear graph cache\nexport const clearGraphCache = (currentID?: string) => {\n if (currentID) {\n delete graphs[currentID];\n } else {\n Object.keys(graphs).forEach(key => delete graphs[key]);\n }\n};","// Helper functions for the application\n\nexport function removeEmptyProps(obj: any) {\n return JSON.parse(JSON.stringify(obj));\n}\n\nexport function camelToWords(camel: string) {\n const split = camel.replace(/([A-Z])/g, \" $1\");\n return split.charAt(0).toUpperCase() + split.slice(1);\n}\n\nexport function getCurrentViewID() {\n const params = new URLSearchParams(document.location.search);\n return params.get('id') || '';\n} ","import React, { FC, useState, useEffect } from 'react';\nimport { getZoomAuto, GraphData, setZoom, getZoom, setZoomCentered } from '../graph-view/graph';\nimport { listViews } from '../parseModel';\nimport { camelToWords } from '../utils';\nimport { getModifierKeyName } from '../utils/platform';\n\n// Types\ninterface ToolbarProps {\n model: any;\n currentID: string;\n onViewChange: (id: string) => void;\n graph: GraphData;\n onAutoLayout: () => void;\n onSave: () => void;\n onToggleHelp: () => void;\n saving: boolean;\n layouting: boolean;\n dragMode: 'pan' | 'select';\n setDragMode: (mode: 'pan' | 'select') => void;\n}\n\nexport const Toolbar: FC = ({\n model, currentID, onViewChange, graph, \n onAutoLayout, onSave, onToggleHelp, saving, layouting,\n dragMode, setDragMode\n}) => {\n const views = listViews(model);\n \n return (\n
\n \n \n
\n );\n};\n\nconst ViewSelector: FC<{\n views: any[];\n currentID: string;\n onViewChange: (id: string) => void;\n}> = ({ views, currentID, onViewChange }) => (\n
\n View:\n {views.length > 1 ? (\n \n ) : (\n \n {views[0] ? camelToWords(views[0].section) + ': ' + views[0].title : 'No views available'}\n \n )}\n
\n);\n\nconst ToolbarActions: FC<{\n graph: GraphData;\n onAutoLayout: () => void;\n onSave: () => void;\n onToggleHelp: () => void;\n saving: boolean;\n layouting: boolean;\n dragMode: 'pan' | 'select';\n setDragMode: (mode: 'pan' | 'select') => void;\n}> = ({\n graph, onAutoLayout, onSave, onToggleHelp, saving, layouting,\n dragMode, setDragMode\n}) => (\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n);\n\nconst DragModeButton: FC<{\n dragMode: 'pan' | 'select';\n setDragMode: (mode: 'pan' | 'select') => void;\n}> = ({ dragMode, setDragMode }) => (\n \n);\n\nconst UndoRedoButtons: FC<{ graph: GraphData }> = ({ graph }) => {\n const modKey = getModifierKeyName();\n return (\n <>\n \n \n \n );\n};\n\nconst AlignmentButtons: FC<{ graph: GraphData }> = ({ graph }) => {\n const modKey = getModifierKeyName();\n return (\n <>\n \n \n \n \n \n );\n};\n\nconst LayoutControls: FC<{\n onAutoLayout: () => void;\n layouting: boolean;\n}> = ({ onAutoLayout, layouting }) => {\n const modKey = getModifierKeyName();\n return (\n \n );\n};\n\nconst GridControls: FC<{ graph: GraphData }> = ({ graph }) => {\n const [gridVisible, setGridVisible] = useState(graph.isGridVisible());\n const [snapToGrid, setSnapToGrid] = useState(graph.isSnapToGrid());\n const modKey = getModifierKeyName();\n \n // Update state when graph changes or when grid state changes via shortcuts\n React.useEffect(() => {\n const updateGridState = () => {\n setGridVisible(graph.isGridVisible());\n setSnapToGrid(graph.isSnapToGrid());\n };\n \n // Initial update\n updateGridState();\n \n // Listen for grid state changes from keyboard shortcuts\n window.addEventListener('gridStateChanged', updateGridState);\n \n return () => {\n window.removeEventListener('gridStateChanged', updateGridState);\n };\n }, [graph]);\n \n const handleToggleGrid = () => {\n graph.toggleGrid();\n setGridVisible(graph.isGridVisible());\n };\n \n const handleToggleSnap = () => {\n graph.toggleSnapToGrid();\n setSnapToGrid(graph.isSnapToGrid());\n };\n \n const handleSnapAll = () => {\n graph.snapAllToGrid();\n };\n \n return (\n <>\n \n \n \n \n );\n};\n\nconst ZoomDisplay: FC = () => {\n const [zoom, setZoomState] = useState(100);\n\n useEffect(() => {\n const updateZoom = () => {\n const currentZoom = Math.round(getZoom() * 100);\n setZoomState(currentZoom);\n };\n\n // Update zoom initially\n updateZoom();\n\n // Update zoom every 100ms to catch changes from wheel/keyboard/etc\n const interval = setInterval(updateZoom, 100);\n\n return () => clearInterval(interval);\n }, []);\n\n return (\n \n );\n};\n\nconst ZoomControls: FC<{ graph: GraphData }> = ({ graph }) => {\n const modKey = getModifierKeyName();\n return (\n <>\n \n \n \n \n \n );\n};\n\nconst SaveButton: FC<{\n onSave: () => void;\n saving: boolean;\n graph: GraphData;\n}> = ({ onSave, saving, graph }) => {\n const [hasChanges, setHasChanges] = useState(false);\n const modKey = getModifierKeyName();\n \n // Check for changes periodically\n useEffect(() => {\n const checkChanges = () => {\n setHasChanges(graph.changed());\n };\n \n // Initial check\n checkChanges();\n \n // Check every 100ms for changes\n const interval = setInterval(checkChanges, 100);\n \n return () => clearInterval(interval);\n }, [graph]);\n \n return (\n \n );\n};\n\nconst HelpButton: FC<{\n onToggleHelp: () => void;\n}> = ({ onToggleHelp }) => {\n return (\n \n );\n};","import React, { FC, useState, useCallback, useEffect, Suspense, lazy } from \"react\";\nimport { GraphData } from \"./graph-view/graph\";\nimport { BrowserRouter as Router, Routes, Route, useSearchParams } from 'react-router-dom';\nimport { listViews } from \"./parseModel\";\nimport { useGraph, useAutoLayout, useSave, useKeyboardShortcuts, clearGraphCache } from \"./hooks\";\nimport { Toolbar } from \"./components/Toolbar\";\nimport { removeEmptyProps, getCurrentViewID } from \"./utils\";\n\nconst Help = lazy(() => import(\"./shortcuts\").then(module => ({ default: module.Help })));\nconst Graph = lazy(() => import(\"./graph-view/graph-react\").then(module => ({ default: module.Graph })));\n\n// Types\ninterface ModelData {\n model: any;\n layout: any;\n}\n\nconst reportInteractiveError = (action: string, error: unknown) => {\n console.error(`${action} failed:`, error);\n alert(`${action} failed. See console for details.`);\n};\n\nexport const Root: FC = ({ model, layout }) => (\n \n \n } />\n \n \n);\n\nexport const refreshGraph = () => {\n const currentID = getCurrentViewID();\n clearGraphCache(currentID);\n};\n\nconst ModelPane: FC<{ model: any; layouts: any }> = ({ model, layouts }) => {\n const [searchParams, setSearchParams] = useSearchParams();\n const currentID = decodeURI(searchParams.get('id') || '');\n \n // UI State\n const [helpVisible, setHelpVisible] = useState(false);\n const [dragMode, setDragMode] = useState<'pan' | 'select'>('pan');\n \n // Get or create graph for current view\n const graph = useGraph(model, layouts, currentID);\n \n // Custom hooks for functionality\n const { layouting, handleAutoLayout } = useAutoLayout(graph || ({} as GraphData));\n const { saving, handleSave } = useSave(graph || ({} as GraphData), currentID);\n \n if (!graph) {\n return ;\n }\n\n const handleToggleHelp = useCallback(() => {\n setHelpVisible(!helpVisible);\n }, [helpVisible]);\n\n const handleInteractiveAutoLayout = useCallback(() => {\n void handleAutoLayout().catch(error => reportInteractiveError('Layout', error));\n }, [handleAutoLayout]);\n\n const handleInteractiveSave = useCallback(() => {\n void handleSave().catch(error => reportInteractiveError('Save', error));\n }, [handleSave]);\n\n // Update document title when view changes\n useEffect(() => {\n if (graph && graph.name) {\n document.title = `${graph.name} - Model`;\n }\n }, [graph]);\n\n // Setup keyboard shortcuts\n useKeyboardShortcuts(\n handleToggleHelp,\n handleInteractiveSave,\n graph,\n dragMode,\n setDragMode,\n handleInteractiveAutoLayout,\n );\n\n const handleViewChange = useCallback((id: string) => {\n setSearchParams({ id: encodeURIComponent(id) });\n }, [setSearchParams]);\n\n const handleSelect = useCallback((id: string | null) => {\n if (id) {\n const element = graph.metadata.elements.find((m: any) => m.id === id);\n console.log(removeEmptyProps(element));\n }\n }, [graph]);\n\n\treturn (\n\t\t<>\n\t\t\t\n\t\t\tLoading graph...
}>\n\t\t\t\t\n\t\t\t\n\t\t\t{helpVisible && (\n\t\t\t\tLoading help...
}>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t)}\n\t\t\n\t);\n};\n\nconst ViewRedirect: FC<{ model: any }> = ({ model }) => {\n const views = listViews(model);\n \n React.useEffect(() => {\n // Set default title when no view is selected\n document.title = 'Model - Architecture Diagrams as Code';\n \n if (views.length > 0) {\n document.location.href = '?id=' + views[0].key;\n }\n }, [views]);\n\n if (views.length > 0) {\n return <>Redirecting to {views[0].title};\n }\n return <>No views available;\n};\n\n","interface LiveReloadOptions {\n\tminDelay: number;\n\tmaxDelay: number;\n\thandshakeTimeout: number;\n}\n\ninterface LiveReloadMessage {\n\tcommand: string;\n\tprotocols?: string[];\n\tver?: string;\n\tpath?: string;\n}\n\nclass Timer {\n\tprivate readonly callback: () => void;\n\tprivate readonly handler: () => void;\n\tprivate running: boolean = false;\n\tprivate timeoutId: ReturnType | null = null;\n\n\tconstructor(callback: () => void) {\n\t\tthis.callback = callback;\n\t\tthis.handler = () => {\n\t\t\tthis.running = false;\n\t\t\tthis.timeoutId = null;\n\t\t\tthis.callback();\n\t\t};\n\t}\n\n\tstart(timeout: number): void {\n\t\tif (this.running) {\n\t\t\tthis.stop();\n\t\t}\n\t\tthis.timeoutId = setTimeout(this.handler, timeout);\n\t\tthis.running = true;\n\t}\n\n\tstop(): void {\n\t\tif (this.running && this.timeoutId !== null) {\n\t\t\tclearTimeout(this.timeoutId);\n\t\t\tthis.running = false;\n\t\t\tthis.timeoutId = null;\n\t\t}\n\t}\n\n\tisRunning(): boolean {\n\t\treturn this.running;\n\t}\n}\n\n/**\n * RefreshConnector implements the livereload protocol to listen for file changes via WebSocket\n */\nexport class RefreshConnector {\n\tprivate static readonly DEFAULT_OPTIONS: LiveReloadOptions = {\n\t\tminDelay: 1000,\n\t\tmaxDelay: 60000,\n\t\thandshakeTimeout: 5000\n\t};\n\n\tprivate static readonly LIVERELOAD_PROTOCOLS = [\n\t\t'http://livereload.com/protocols/official-9',\n\t\t'http://livereload.com/protocols/2.x-remote-control'\n\t];\n\n\tprivate readonly uri: string;\n\tprivate readonly options: LiveReloadOptions;\n\tprivate readonly fileChangeHandler: (path: string) => void;\n\t\n\tprivate socket: WebSocket | null = null;\n\tprivate nextDelay: number;\n\tprivate connectionDesired: boolean = false;\n\tprivate disconnectionReason: string = '';\n\t\n\tprivate readonly handshakeTimeout: Timer;\n\tprivate readonly reconnectTimer: Timer;\n\n\tconstructor(fileChangeHandler: (file: string) => void, options?: Partial) {\n\t\tthis.fileChangeHandler = fileChangeHandler;\n\t\tthis.options = { ...RefreshConnector.DEFAULT_OPTIONS, ...options };\n\t\tthis.uri = 'ws://localhost:35729/livereload';\n\t\tthis.nextDelay = this.options.minDelay;\n\n\t\tthis.handshakeTimeout = new Timer(() => this.handleHandshakeTimeout());\n\t\tthis.reconnectTimer = new Timer(() => this.attemptReconnection());\n\t}\n\n\tconnect(): void {\n\t\tthis.connectionDesired = true;\n\n\t\tif (this.isSocketConnected()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.prepareForConnection();\n\t\tthis.createWebSocket();\n\t}\n\n\tdisconnect(): void {\n\t\tthis.connectionDesired = false;\n\t\tthis.reconnectTimer.stop();\n\n\t\tif (this.isSocketConnected()) {\n\t\t\tthis.disconnectionReason = 'manual';\n\t\t\tthis.socket!.close();\n\t\t}\n\t}\n\n\tprivate isSocketConnected(): boolean {\n\t\treturn this.socket !== null && this.socket.readyState === WebSocket.OPEN;\n\t}\n\n\tprivate prepareForConnection(): void {\n\t\tthis.reconnectTimer.stop();\n\t\tthis.disconnectionReason = 'cannot-connect';\n\t}\n\n\tprivate createWebSocket(): void {\n\t\tthis.socket = new WebSocket(this.uri);\n\t\tthis.socket.onopen = () => this.handleOpen();\n\t\tthis.socket.onclose = () => this.handleClose();\n\t\tthis.socket.onmessage = (event) => this.handleMessage(event);\n\t\tthis.socket.onerror = () => this.handleError();\n\t}\n\n\tprivate handleOpen(): void {\n\t\tthis.disconnectionReason = 'handshake-failed';\n\t\tthis.startHandshake();\n\t}\n\n\tprivate handleClose(): void {\n\t\tconsole.log(`WebSocket disconnected: ${this.disconnectionReason}. Retry in ${this.nextDelay}ms`);\n\t\tthis.scheduleReconnection();\n\t}\n\n\tprivate handleMessage(event: MessageEvent): void {\n\t\ttry {\n\t\t\tconst message: LiveReloadMessage = JSON.parse(event.data);\n\t\t\tthis.processMessage(message);\n\t\t} catch (error) {\n\t\t\tconsole.error('Failed to parse WebSocket message:', error);\n\t\t}\n\t}\n\n\tprivate handleError(): void {\n\t\t// Error handling is done in onclose\n\t}\n\n\tprivate processMessage(message: LiveReloadMessage): void {\n\t\tswitch (message.command) {\n\t\t\tcase 'hello':\n\t\t\t\tthis.handleHelloMessage();\n\t\t\t\tbreak;\n\t\t\tcase 'reload':\n\t\t\t\tthis.handleReloadMessage(message);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('Unknown WebSocket message received:', message);\n\t\t}\n\t}\n\n\tprivate handleHelloMessage(): void {\n\t\tthis.handshakeTimeout.stop();\n\t\tthis.nextDelay = this.options.minDelay;\n\t}\n\n\tprivate handleReloadMessage(message: LiveReloadMessage): void {\n\t\t// The livereload server closes connection after sending reload\n\t\t// We must reconnect\n\t\tthis.reconnectTimer.stop();\n\t\tthis.connect();\n\n\t\tif (message.path) {\n\t\t\tthis.fileChangeHandler(message.path);\n\t\t}\n\t}\n\n\tprivate startHandshake(): void {\n\t\tconst helloMessage: LiveReloadMessage = {\n\t\t\tcommand: 'hello',\n\t\t\tprotocols: RefreshConnector.LIVERELOAD_PROTOCOLS,\n\t\t\tver: '3.3.1'\n\t\t};\n\t\t\n\t\tthis.sendCommand(helloMessage);\n\t\tthis.handshakeTimeout.start(this.options.handshakeTimeout);\n\t}\n\n\tprivate handleHandshakeTimeout(): void {\n\t\tif (this.isSocketConnected()) {\n\t\t\tthis.disconnectionReason = 'handshake-timeout';\n\t\t\tthis.socket!.close();\n\t\t}\n\t}\n\n\tprivate attemptReconnection(): void {\n\t\tif (this.connectionDesired) {\n\t\t\tthis.connect();\n\t\t}\n\t}\n\n\tprivate scheduleReconnection(): void {\n\t\tif (!this.connectionDesired) {\n\t\t\treturn; // Don't reconnect after manual disconnection\n\t\t}\n\n\t\tif (!this.reconnectTimer.isRunning()) {\n\t\t\tthis.reconnectTimer.start(this.nextDelay);\n\t\t\tthis.nextDelay = Math.min(this.options.maxDelay, this.nextDelay * 2);\n\t\t}\n\t}\n\n\tprivate sendCommand(command: LiveReloadMessage): void {\n\t\tif (this.isSocketConnected()) {\n\t\t\tthis.socket!.send(JSON.stringify(command));\n\t\t}\n\t}\n}","import { createRoot } from 'react-dom/client';\nimport React, { Suspense, lazy, useEffect, useState } from 'react';\nimport { refreshGraph } from \"./Root\";\nimport \"./fonts.css\";\nimport './style.css';\nimport '@fortawesome/fontawesome-free/css/all.css';\nimport { RefreshConnector } from \"./websocket\";\nimport {loadDiagramFonts} from \"./graph-view/svg-text\";\n\nconst Root = lazy(() => import('./Root').then(module => ({ default: module.Root })));\n\ninterface ModelData {\n\tmodel: any;\n\tlayout: any;\n}\n\ninterface AppState {\n\tdata: ModelData | null;\n\terror: string | null;\n\tloading: boolean;\n}\n\nconst App: React.FC = () => {\n\tconst [state, setState] = useState({\n\t\tdata: null,\n\t\terror: null,\n\t\tloading: true\n\t});\n\n\tconst loadData = async () => {\n\t\tsetState(prev => ({ ...prev, loading: true, error: null }));\n\t\t\n\t\ttry {\n\t\t\tconst [modelResponse, layoutResponse] = await Promise.all([\n\t\t\t\tfetch('data/model.json'),\n\t\t\t\tfetch('data/layout.json')\n\t\t\t]);\n\n\t\t\tif (!modelResponse.ok) {\n\t\t\t\tthrow new Error(`Failed to fetch model: ${modelResponse.statusText}`);\n\t\t\t}\n\t\t\t\n\t\t\tif (!layoutResponse.ok) {\n\t\t\t\tthrow new Error(`Failed to fetch layout: ${layoutResponse.statusText}`);\n\t\t\t}\n\n\t\t\tconst [model, layout] = await Promise.all([\n\t\t\t\tmodelResponse.json(),\n\t\t\t\tlayoutResponse.json()\n\t\t\t]);\n\t\t\tawait loadDiagramFonts();\n\n\t\t\tsetState({\n\t\t\t\tdata: { model, layout },\n\t\t\t\terror: null,\n\t\t\t\tloading: false\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconsole.error('Failed to load data:', error);\n\t\t\tsetState({\n\t\t\t\tdata: null,\n\t\t\t\terror: error instanceof Error ? error.message : 'Unknown error occurred',\n\t\t\t\tloading: false\n\t\t\t});\n\t\t}\n\t};\n\n\tconst handleFileChange = (path: string) => {\n\t\tif (path.endsWith('.svg')) {\n\t\t\treturn; // Ignore SVG changes to avoid infinite loops\n\t\t}\n\t\t\n\t\tconsole.log('File changed:', path);\n\t\trefreshGraph();\n\t\tloadData();\n\t};\n\n\tuseEffect(() => {\n\t\tconst refreshConnector = new RefreshConnector(handleFileChange);\n\t\trefreshConnector.connect();\n\n\t\t// Initial data load\n\t\tloadData();\n\n\t\treturn () => {\n\t\t\trefreshConnector.disconnect();\n\t\t};\n\t}, []);\n\n\tif (state.loading) {\n\t\treturn ;\n\t}\n\n\tif (state.error) {\n\t\treturn ;\n\t}\n\n\tif (!state.data) {\n\t\treturn ;\n\t}\n\n\treturn (\n\t\t}>\n\t\t\t\n\t\t\n\t);\n};\n\nconst LoadingScreen: React.FC = () => (\n\t
\n\t\t
Loading...
\n\t
\n);\n\nconst ErrorScreen: React.FC<{ error: string; onRetry: () => void }> = ({ error, onRetry }) => (\n\t
\n\t\t

Error loading application

\n\t\t

{error}

\n\t\t\n\t
\n);\n\n// Initialize the application\nconst container = document.getElementById('root');\nif (!container) {\n\tthrow new Error('Root container not found');\n}\n\nconst root = createRoot(container);\nroot.render();\n"],"names":["graphs","camelToWords","camel","split","replace","charAt","toUpperCase","slice","Toolbar","model","currentID","onViewChange","graph","onAutoLayout","onSave","onToggleHelp","saving","layouting","dragMode","setDragMode","views","parseModel","B","jsx_runtime","jsxs","className","children","jsx","ViewSelector","ToolbarActions","length","onChange","e","target","value","disabled","hidden","map","view","key","section","title","style","marginLeft","fontWeight","display","alignItems","DragModeButton","UndoRedoButtons","AlignmentButtons","LayoutControls","GridControls","ZoomControls","SaveButton","HelpButton","onClick","modKey","platform","sy","Fragment","undo","redo","alignSelectionH","alignSelectionV","transform","distributeSelectionH","distributeSelectionV","gridVisible","setGridVisible","react","useState","isGridVisible","snapToGrid","setSnapToGrid","isSnapToGrid","useEffect","updateGridState","window","addEventListener","removeEventListener","toggleGrid","toggleSnapToGrid","snapAllToGrid","ZoomDisplay","zoom","setZoomState","updateZoom","currentZoom","Math","round","graph_view_graph","IX","interval","setInterval","clearInterval","a_","max","min","fitToView","hasChanges","setHasChanges","checkChanges","changed","Help","lazy","Promise","resolve","then","__webpack_require__","bind","module","default","Graph","reportInteractiveError","action","error","console","alert","Root","layout","chunk_62JRHF6Z","Kd","BV","qh","path","element","ModelPane","layouts","refreshGraph","URLSearchParams","document","location","search","get","Object","keys","forEach","searchParams","setSearchParams","ok","decodeURI","helpVisible","setHelpVisible","R","useGraph","handleAutoLayout","setLayouting","useCallback","async","options","direction","layoutDirection","opts","autoLayout","useAutoLayout","handleSave","setSaving","response","fetch","encodeURIComponent","method","body","exportSVG","status","detail","text","trim","Error","setSaved","useSave","ViewRedirect","handleToggleHelp","handleInteractiveAutoLayout","catch","handleInteractiveSave","name","toggleHelp","saveLayout","handleKeyDown","shortcut","shortcuts","Yp","preventDefault","aX","t9","Jk","DE","Vy","Hd","_t","resetView","Op","hZ","OE","Gg","moveSelected","getGridSize","J8","b3","iD","uK","l8","rB","mt","useKeyboardShortcuts","handleViewChange","id","handleSelect","metadata","elements","find","m","log","obj","JSON","parse","stringify","Suspense","fallback","data","onSelect","href","Timer","callback","handler","running","timeoutId","constructor","this","start","timeout","stop","setTimeout","clearTimeout","isRunning","RefreshConnector","static","minDelay","maxDelay","handshakeTimeout","uri","fileChangeHandler","socket","nextDelay","connectionDesired","disconnectionReason","reconnectTimer","DEFAULT_OPTIONS","handleHandshakeTimeout","attemptReconnection","connect","isSocketConnected","prepareForConnection","createWebSocket","disconnect","close","readyState","WebSocket","OPEN","onopen","handleOpen","onclose","handleClose","onmessage","event","handleMessage","onerror","handleError","startHandshake","scheduleReconnection","message","processMessage","command","handleHelloMessage","handleReloadMessage","helloMessage","protocols","LIVERELOAD_PROTOCOLS","ver","sendCommand","send","src_Root","App","state","setState","loading","loadData","prev","modelResponse","layoutResponse","all","statusText","json","svg_text","Mt","handleFileChange","endsWith","S","refreshConnector","LoadingScreen","ErrorScreen","onRetry","justifyContent","height","fontFamily","padding","color","whiteSpace","flexDirection","fontSize","cursor","backgroundColor","border","borderRadius","container","getElementById","client","createRoot","render"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"main.js","mappings":"yKA6BA,MAAMA,EAAuC,CAAC,ECvBvC,SAASC,EAAaC,GAC3B,MAAMC,EAAQD,EAAME,QAAQ,WAAY,OACxC,OAAOD,EAAME,OAAO,GAAGC,cAAgBH,EAAMI,MAAM,EACrD,uBCYO,MAAMC,EAA4B,EACvCC,QAAOC,YAAWC,eAAcC,QAChCC,eAAcC,SAAQC,eAAcC,SAAQC,YAC5CC,WAAUC,kBAEV,MAAMC,GAAQ,EAAAC,EAAAC,GAAUb,GAExB,OACE,EAAAc,EAAAC,MAAA,OAAKC,UAAU,UAASC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Q,SACPrR,SAAA,EACD,EAAAH,EAAAI,KAAA,MAAAD,SAAI,+BACJ,EAAAH,EAAAI,KAAA,KAAAD,SAAIyF,KACJ,EAAA5F,EAAAI,KAAA,UACC4B,QAASsP,EACTnQ,MAAO,CACNuQ,QAAS,YACTI,SAAU,OACVC,OAAQ,UACRC,gBAAiB,UACjBL,MAAO,QACPM,OAAQ,OACRC,aAAc,OACb/R,SACF,aAOGgS,EAAYxL,SAASyL,eAAe,QAC1C,IAAKD,EACJ,MAAM,IAAInJ,MAAM,6BAGJ,EAAAqJ,EAAAC,YAAWH,GACnBI,QAAO,EAAAvS,EAAAI,KAAC+P,EAAG","sources":["webpack://app/./src/hooks.ts","webpack://app/./src/utils.ts","webpack://app/./src/components/Toolbar.tsx","webpack://app/./src/Root.tsx","webpack://app/./src/websocket.ts","webpack://app/./src/index.tsx"],"sourcesContent":["import { useState, useCallback, useEffect } from 'react';\nimport { GraphData } from './graph-view/graph';\nimport { parseView } from './parseModel';\nimport { LayoutOptions } from './graph-view/layout';\nimport { \n findShortcut, \n HELP, \n SAVE, \n TOGGLE_DRAG_MODE,\n ALIGN_HORIZONTAL,\n ALIGN_VERTICAL,\n DISTRIBUTE_HORIZONTAL,\n DISTRIBUTE_VERTICAL,\n AUTO_LAYOUT,\n RESET_POSITION,\n TOGGLE_GRID,\n TOGGLE_SNAP_TO_GRID,\n SNAP_ALL_TO_GRID,\n MOVE_LEFT,\n MOVE_RIGHT,\n MOVE_UP,\n MOVE_DOWN,\n MOVE_LEFT_FINE,\n MOVE_RIGHT_FINE,\n MOVE_UP_FINE,\n MOVE_DOWN_FINE\n} from './shortcuts';\n\n// Global state for graphs to preserve edits\nconst graphs: { [key: string]: GraphData } = {};\n\n// Custom hook for graph management\nexport const useGraph = (model: any, layouts: any, currentID: string): GraphData | null => {\n if (graphs[currentID]) {\n return graphs[currentID];\n }\n \n const graph = parseView(model, layouts, currentID);\n if (graph) {\n graphs[currentID] = graph;\n }\n \n return graph;\n};\n\n// Custom hook for auto layout functionality\nexport const useAutoLayout = (graph: GraphData) => {\n const [layouting, setLayouting] = useState(false);\n\n const handleAutoLayout = useCallback(async (opts?: LayoutOptions) => {\n setLayouting(true);\n try {\n const options: LayoutOptions = {\n direction: graph.layoutDirection || 'DOWN',\n ...(opts || {})\n };\n await graph.autoLayout(options);\n } finally {\n setLayouting(false);\n }\n }, [graph]);\n\n return { layouting, handleAutoLayout };\n};\n\n// Custom hook for save functionality\nexport const useSave = (graph: GraphData, currentID: string) => {\n const [saving, setSaving] = useState(false);\n\n const handleSave = useCallback(async () => {\n setSaving(true);\n \n try {\n const response = await fetch('data/save?id=' + encodeURIComponent(currentID), {\n method: 'post',\n body: graph.exportSVG()\n });\n \n if (response.status !== 202) {\n const detail = (await response.text()).trim();\n throw new Error(detail || `save failed with HTTP ${response.status}`);\n }\n graph.setSaved();\n } finally {\n setSaving(false);\n }\n }, [graph, currentID]);\n\n return { saving, handleSave };\n};\n\n// Custom hook for keyboard shortcuts\nexport const useKeyboardShortcuts = (\n toggleHelp: () => void,\n saveLayout: () => void,\n graph?: GraphData,\n dragMode?: 'pan' | 'select',\n setDragMode?: (mode: 'pan' | 'select') => void,\n onAutoLayout?: () => void\n) => {\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n const shortcut = findShortcut(e);\n \n // Prevent browser default for all recognized shortcuts\n if (shortcut) {\n e.preventDefault();\n }\n \n if (shortcut === HELP) {\n toggleHelp();\n } else if (shortcut === SAVE) {\n saveLayout();\n } else if (shortcut === TOGGLE_DRAG_MODE && setDragMode && dragMode) {\n setDragMode(dragMode === 'pan' ? 'select' : 'pan');\n } else if (graph) {\n // Graph-dependent shortcuts\n if (shortcut === ALIGN_HORIZONTAL) {\n graph.alignSelectionH();\n } else if (shortcut === ALIGN_VERTICAL) {\n graph.alignSelectionV();\n } else if (shortcut === DISTRIBUTE_HORIZONTAL) {\n graph.distributeSelectionH();\n } else if (shortcut === DISTRIBUTE_VERTICAL) {\n graph.distributeSelectionV();\n } else if (shortcut === AUTO_LAYOUT && onAutoLayout) {\n onAutoLayout();\n } else if (shortcut === RESET_POSITION) {\n graph.resetView();\n } else if (shortcut === TOGGLE_GRID) {\n graph.toggleGrid();\n } else if (shortcut === TOGGLE_SNAP_TO_GRID) {\n graph.toggleSnapToGrid();\n } else if (shortcut === SNAP_ALL_TO_GRID) {\n graph.snapAllToGrid();\n } else if (shortcut === MOVE_LEFT) {\n graph.moveSelected(-graph.getGridSize(), 0);\n } else if (shortcut === MOVE_LEFT_FINE) {\n graph.moveSelected(-1, 0, true); // Disable snap for fine movement\n } else if (shortcut === MOVE_RIGHT) {\n graph.moveSelected(graph.getGridSize(), 0);\n } else if (shortcut === MOVE_RIGHT_FINE) {\n graph.moveSelected(1, 0, true); // Disable snap for fine movement\n } else if (shortcut === MOVE_UP) {\n graph.moveSelected(0, -graph.getGridSize());\n } else if (shortcut === MOVE_UP_FINE) {\n graph.moveSelected(0, -1, true); // Disable snap for fine movement\n } else if (shortcut === MOVE_DOWN) {\n graph.moveSelected(0, graph.getGridSize());\n } else if (shortcut === MOVE_DOWN_FINE) {\n graph.moveSelected(0, 1, true); // Disable snap for fine movement\n }\n }\n };\n\n window.addEventListener('keydown', handleKeyDown);\n return () => window.removeEventListener('keydown', handleKeyDown);\n }, [toggleHelp, saveLayout, graph, dragMode, setDragMode, onAutoLayout]);\n};\n\n// Utility function to clear graph cache\nexport const clearGraphCache = (currentID?: string) => {\n if (currentID) {\n delete graphs[currentID];\n } else {\n Object.keys(graphs).forEach(key => delete graphs[key]);\n }\n};","// Helper functions for the application\n\nexport function removeEmptyProps(obj: any) {\n return JSON.parse(JSON.stringify(obj));\n}\n\nexport function camelToWords(camel: string) {\n const split = camel.replace(/([A-Z])/g, \" $1\");\n return split.charAt(0).toUpperCase() + split.slice(1);\n}\n\nexport function getCurrentViewID() {\n const params = new URLSearchParams(document.location.search);\n return params.get('id') || '';\n} ","import React, { FC, useState, useEffect } from 'react';\nimport { getZoomAuto, GraphData, setZoom, getZoom, setZoomCentered } from '../graph-view/graph';\nimport { listViews } from '../parseModel';\nimport { camelToWords } from '../utils';\nimport { getModifierKeyName } from '../utils/platform';\n\n// Types\ninterface ToolbarProps {\n model: any;\n currentID: string;\n onViewChange: (id: string) => void;\n graph: GraphData;\n onAutoLayout: () => void;\n onSave: () => void;\n onToggleHelp: () => void;\n saving: boolean;\n layouting: boolean;\n dragMode: 'pan' | 'select';\n setDragMode: (mode: 'pan' | 'select') => void;\n}\n\nexport const Toolbar: FC = ({\n model, currentID, onViewChange, graph, \n onAutoLayout, onSave, onToggleHelp, saving, layouting,\n dragMode, setDragMode\n}) => {\n const views = listViews(model);\n \n return (\n
\n \n \n
\n );\n};\n\nconst ViewSelector: FC<{\n views: any[];\n currentID: string;\n onViewChange: (id: string) => void;\n}> = ({ views, currentID, onViewChange }) => (\n
\n View:\n {views.length > 1 ? (\n \n ) : (\n \n {views[0] ? camelToWords(views[0].section) + ': ' + views[0].title : 'No views available'}\n \n )}\n
\n);\n\nconst ToolbarActions: FC<{\n graph: GraphData;\n onAutoLayout: () => void;\n onSave: () => void;\n onToggleHelp: () => void;\n saving: boolean;\n layouting: boolean;\n dragMode: 'pan' | 'select';\n setDragMode: (mode: 'pan' | 'select') => void;\n}> = ({\n graph, onAutoLayout, onSave, onToggleHelp, saving, layouting,\n dragMode, setDragMode\n}) => (\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n);\n\nconst DragModeButton: FC<{\n dragMode: 'pan' | 'select';\n setDragMode: (mode: 'pan' | 'select') => void;\n}> = ({ dragMode, setDragMode }) => (\n \n);\n\nconst UndoRedoButtons: FC<{ graph: GraphData }> = ({ graph }) => {\n const modKey = getModifierKeyName();\n return (\n <>\n \n \n \n );\n};\n\nconst AlignmentButtons: FC<{ graph: GraphData }> = ({ graph }) => {\n const modKey = getModifierKeyName();\n return (\n <>\n \n \n \n \n \n );\n};\n\nconst LayoutControls: FC<{\n onAutoLayout: () => void;\n layouting: boolean;\n}> = ({ onAutoLayout, layouting }) => {\n const modKey = getModifierKeyName();\n return (\n \n );\n};\n\nconst GridControls: FC<{ graph: GraphData }> = ({ graph }) => {\n const [gridVisible, setGridVisible] = useState(graph.isGridVisible());\n const [snapToGrid, setSnapToGrid] = useState(graph.isSnapToGrid());\n const modKey = getModifierKeyName();\n \n // Update state when graph changes or when grid state changes via shortcuts\n React.useEffect(() => {\n const updateGridState = () => {\n setGridVisible(graph.isGridVisible());\n setSnapToGrid(graph.isSnapToGrid());\n };\n \n // Initial update\n updateGridState();\n \n // Listen for grid state changes from keyboard shortcuts\n window.addEventListener('gridStateChanged', updateGridState);\n \n return () => {\n window.removeEventListener('gridStateChanged', updateGridState);\n };\n }, [graph]);\n \n const handleToggleGrid = () => {\n graph.toggleGrid();\n setGridVisible(graph.isGridVisible());\n };\n \n const handleToggleSnap = () => {\n graph.toggleSnapToGrid();\n setSnapToGrid(graph.isSnapToGrid());\n };\n \n const handleSnapAll = () => {\n graph.snapAllToGrid();\n };\n \n return (\n <>\n \n \n \n \n );\n};\n\nconst ZoomDisplay: FC<{ graph: GraphData }> = ({ graph }) => {\n const [zoom, setZoomState] = useState(100);\n\n useEffect(() => {\n const updateZoom = () => {\n const currentZoom = Math.round(getZoom(graph) * 100);\n setZoomState(currentZoom);\n };\n\n // Update zoom initially\n updateZoom();\n\n // Update zoom every 100ms to catch changes from wheel/keyboard/etc\n const interval = setInterval(updateZoom, 100);\n\n return () => clearInterval(interval);\n }, [graph]);\n\n return (\n \n );\n};\n\nconst ZoomControls: FC<{ graph: GraphData }> = ({ graph }) => {\n const modKey = getModifierKeyName();\n return (\n <>\n \n \n \n \n \n );\n};\n\nconst SaveButton: FC<{\n onSave: () => void;\n saving: boolean;\n graph: GraphData;\n}> = ({ onSave, saving, graph }) => {\n const [hasChanges, setHasChanges] = useState(false);\n const modKey = getModifierKeyName();\n \n // Check for changes periodically\n useEffect(() => {\n const checkChanges = () => {\n setHasChanges(graph.changed());\n };\n \n // Initial check\n checkChanges();\n \n // Check every 100ms for changes\n const interval = setInterval(checkChanges, 100);\n \n return () => clearInterval(interval);\n }, [graph]);\n \n return (\n \n );\n};\n\nconst HelpButton: FC<{\n onToggleHelp: () => void;\n}> = ({ onToggleHelp }) => {\n return (\n \n );\n};","import React, { FC, useState, useCallback, useEffect, Suspense, lazy } from \"react\";\nimport { GraphData } from \"./graph-view/graph\";\nimport { BrowserRouter as Router, Routes, Route, useSearchParams } from 'react-router-dom';\nimport { listViews } from \"./parseModel\";\nimport { useGraph, useAutoLayout, useSave, useKeyboardShortcuts, clearGraphCache } from \"./hooks\";\nimport { Toolbar } from \"./components/Toolbar\";\nimport { removeEmptyProps, getCurrentViewID } from \"./utils\";\n\nconst Help = lazy(() => import(\"./shortcuts\").then(module => ({ default: module.Help })));\nconst Graph = lazy(() => import(\"./graph-view/graph-react\").then(module => ({ default: module.Graph })));\n\n// Types\ninterface ModelData {\n model: any;\n layout: any;\n}\n\nconst reportInteractiveError = (action: string, error: unknown) => {\n console.error(`${action} failed:`, error);\n alert(`${action} failed. See console for details.`);\n};\n\nexport const Root: FC = ({ model, layout }) => (\n \n \n } />\n \n \n);\n\nexport const refreshGraph = () => {\n const currentID = getCurrentViewID();\n clearGraphCache(currentID);\n};\n\nconst ModelPane: FC<{ model: any; layouts: any }> = ({ model, layouts }) => {\n const [searchParams, setSearchParams] = useSearchParams();\n const currentID = decodeURI(searchParams.get('id') || '');\n \n // UI State\n const [helpVisible, setHelpVisible] = useState(false);\n const [dragMode, setDragMode] = useState<'pan' | 'select'>('pan');\n \n // Get or create graph for current view\n const graph = useGraph(model, layouts, currentID);\n \n // Custom hooks for functionality\n const { layouting, handleAutoLayout } = useAutoLayout(graph || ({} as GraphData));\n const { saving, handleSave } = useSave(graph || ({} as GraphData), currentID);\n \n if (!graph) {\n return ;\n }\n\n const handleToggleHelp = useCallback(() => {\n setHelpVisible(!helpVisible);\n }, [helpVisible]);\n\n const handleInteractiveAutoLayout = useCallback(() => {\n void handleAutoLayout().catch(error => reportInteractiveError('Layout', error));\n }, [handleAutoLayout]);\n\n const handleInteractiveSave = useCallback(() => {\n void handleSave().catch(error => reportInteractiveError('Save', error));\n }, [handleSave]);\n\n // Update document title when view changes\n useEffect(() => {\n if (graph && graph.name) {\n document.title = `${graph.name} - Model`;\n }\n }, [graph]);\n\n // Setup keyboard shortcuts\n useKeyboardShortcuts(\n handleToggleHelp,\n handleInteractiveSave,\n graph,\n dragMode,\n setDragMode,\n handleInteractiveAutoLayout,\n );\n\n const handleViewChange = useCallback((id: string) => {\n setSearchParams({ id: encodeURIComponent(id) });\n }, [setSearchParams]);\n\n const handleSelect = useCallback((id: string | null) => {\n if (id) {\n const element = graph.metadata.elements.find((m: any) => m.id === id);\n console.log(removeEmptyProps(element));\n }\n }, [graph]);\n\n\treturn (\n\t\t<>\n\t\t\t\n\t\t\tLoading graph...}>\n\t\t\t\t\n\t\t\t\n\t\t\t{helpVisible && (\n\t\t\t\tLoading help...}>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t)}\n\t\t\n\t);\n};\n\nconst ViewRedirect: FC<{ model: any }> = ({ model }) => {\n const views = listViews(model);\n \n React.useEffect(() => {\n // Set default title when no view is selected\n document.title = 'Model - Architecture Diagrams as Code';\n \n if (views.length > 0) {\n document.location.href = '?id=' + views[0].key;\n }\n }, [views]);\n\n if (views.length > 0) {\n return <>Redirecting to {views[0].title};\n }\n return <>No views available;\n};\n\n","interface LiveReloadOptions {\n\tminDelay: number;\n\tmaxDelay: number;\n\thandshakeTimeout: number;\n}\n\ninterface LiveReloadMessage {\n\tcommand: string;\n\tprotocols?: string[];\n\tver?: string;\n\tpath?: string;\n}\n\nclass Timer {\n\tprivate readonly callback: () => void;\n\tprivate readonly handler: () => void;\n\tprivate running: boolean = false;\n\tprivate timeoutId: ReturnType | null = null;\n\n\tconstructor(callback: () => void) {\n\t\tthis.callback = callback;\n\t\tthis.handler = () => {\n\t\t\tthis.running = false;\n\t\t\tthis.timeoutId = null;\n\t\t\tthis.callback();\n\t\t};\n\t}\n\n\tstart(timeout: number): void {\n\t\tif (this.running) {\n\t\t\tthis.stop();\n\t\t}\n\t\tthis.timeoutId = setTimeout(this.handler, timeout);\n\t\tthis.running = true;\n\t}\n\n\tstop(): void {\n\t\tif (this.running && this.timeoutId !== null) {\n\t\t\tclearTimeout(this.timeoutId);\n\t\t\tthis.running = false;\n\t\t\tthis.timeoutId = null;\n\t\t}\n\t}\n\n\tisRunning(): boolean {\n\t\treturn this.running;\n\t}\n}\n\n/**\n * RefreshConnector implements the livereload protocol to listen for file changes via WebSocket\n */\nexport class RefreshConnector {\n\tprivate static readonly DEFAULT_OPTIONS: LiveReloadOptions = {\n\t\tminDelay: 1000,\n\t\tmaxDelay: 60000,\n\t\thandshakeTimeout: 5000\n\t};\n\n\tprivate static readonly LIVERELOAD_PROTOCOLS = [\n\t\t'http://livereload.com/protocols/official-9',\n\t\t'http://livereload.com/protocols/2.x-remote-control'\n\t];\n\n\tprivate readonly uri: string;\n\tprivate readonly options: LiveReloadOptions;\n\tprivate readonly fileChangeHandler: (path: string) => void;\n\t\n\tprivate socket: WebSocket | null = null;\n\tprivate nextDelay: number;\n\tprivate connectionDesired: boolean = false;\n\tprivate disconnectionReason: string = '';\n\t\n\tprivate readonly handshakeTimeout: Timer;\n\tprivate readonly reconnectTimer: Timer;\n\n\tconstructor(fileChangeHandler: (file: string) => void, options?: Partial) {\n\t\tthis.fileChangeHandler = fileChangeHandler;\n\t\tthis.options = { ...RefreshConnector.DEFAULT_OPTIONS, ...options };\n\t\tthis.uri = 'ws://localhost:35729/livereload';\n\t\tthis.nextDelay = this.options.minDelay;\n\n\t\tthis.handshakeTimeout = new Timer(() => this.handleHandshakeTimeout());\n\t\tthis.reconnectTimer = new Timer(() => this.attemptReconnection());\n\t}\n\n\tconnect(): void {\n\t\tthis.connectionDesired = true;\n\n\t\tif (this.isSocketConnected()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.prepareForConnection();\n\t\tthis.createWebSocket();\n\t}\n\n\tdisconnect(): void {\n\t\tthis.connectionDesired = false;\n\t\tthis.reconnectTimer.stop();\n\n\t\tif (this.isSocketConnected()) {\n\t\t\tthis.disconnectionReason = 'manual';\n\t\t\tthis.socket!.close();\n\t\t}\n\t}\n\n\tprivate isSocketConnected(): boolean {\n\t\treturn this.socket !== null && this.socket.readyState === WebSocket.OPEN;\n\t}\n\n\tprivate prepareForConnection(): void {\n\t\tthis.reconnectTimer.stop();\n\t\tthis.disconnectionReason = 'cannot-connect';\n\t}\n\n\tprivate createWebSocket(): void {\n\t\tthis.socket = new WebSocket(this.uri);\n\t\tthis.socket.onopen = () => this.handleOpen();\n\t\tthis.socket.onclose = () => this.handleClose();\n\t\tthis.socket.onmessage = (event) => this.handleMessage(event);\n\t\tthis.socket.onerror = () => this.handleError();\n\t}\n\n\tprivate handleOpen(): void {\n\t\tthis.disconnectionReason = 'handshake-failed';\n\t\tthis.startHandshake();\n\t}\n\n\tprivate handleClose(): void {\n\t\tconsole.log(`WebSocket disconnected: ${this.disconnectionReason}. Retry in ${this.nextDelay}ms`);\n\t\tthis.scheduleReconnection();\n\t}\n\n\tprivate handleMessage(event: MessageEvent): void {\n\t\ttry {\n\t\t\tconst message: LiveReloadMessage = JSON.parse(event.data);\n\t\t\tthis.processMessage(message);\n\t\t} catch (error) {\n\t\t\tconsole.error('Failed to parse WebSocket message:', error);\n\t\t}\n\t}\n\n\tprivate handleError(): void {\n\t\t// Error handling is done in onclose\n\t}\n\n\tprivate processMessage(message: LiveReloadMessage): void {\n\t\tswitch (message.command) {\n\t\t\tcase 'hello':\n\t\t\t\tthis.handleHelloMessage();\n\t\t\t\tbreak;\n\t\t\tcase 'reload':\n\t\t\t\tthis.handleReloadMessage(message);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('Unknown WebSocket message received:', message);\n\t\t}\n\t}\n\n\tprivate handleHelloMessage(): void {\n\t\tthis.handshakeTimeout.stop();\n\t\tthis.nextDelay = this.options.minDelay;\n\t}\n\n\tprivate handleReloadMessage(message: LiveReloadMessage): void {\n\t\t// The livereload server closes connection after sending reload\n\t\t// We must reconnect\n\t\tthis.reconnectTimer.stop();\n\t\tthis.connect();\n\n\t\tif (message.path) {\n\t\t\tthis.fileChangeHandler(message.path);\n\t\t}\n\t}\n\n\tprivate startHandshake(): void {\n\t\tconst helloMessage: LiveReloadMessage = {\n\t\t\tcommand: 'hello',\n\t\t\tprotocols: RefreshConnector.LIVERELOAD_PROTOCOLS,\n\t\t\tver: '3.3.1'\n\t\t};\n\t\t\n\t\tthis.sendCommand(helloMessage);\n\t\tthis.handshakeTimeout.start(this.options.handshakeTimeout);\n\t}\n\n\tprivate handleHandshakeTimeout(): void {\n\t\tif (this.isSocketConnected()) {\n\t\t\tthis.disconnectionReason = 'handshake-timeout';\n\t\t\tthis.socket!.close();\n\t\t}\n\t}\n\n\tprivate attemptReconnection(): void {\n\t\tif (this.connectionDesired) {\n\t\t\tthis.connect();\n\t\t}\n\t}\n\n\tprivate scheduleReconnection(): void {\n\t\tif (!this.connectionDesired) {\n\t\t\treturn; // Don't reconnect after manual disconnection\n\t\t}\n\n\t\tif (!this.reconnectTimer.isRunning()) {\n\t\t\tthis.reconnectTimer.start(this.nextDelay);\n\t\t\tthis.nextDelay = Math.min(this.options.maxDelay, this.nextDelay * 2);\n\t\t}\n\t}\n\n\tprivate sendCommand(command: LiveReloadMessage): void {\n\t\tif (this.isSocketConnected()) {\n\t\t\tthis.socket!.send(JSON.stringify(command));\n\t\t}\n\t}\n}","import { createRoot } from 'react-dom/client';\nimport React, { Suspense, lazy, useEffect, useState } from 'react';\nimport { refreshGraph } from \"./Root\";\nimport \"./fonts.css\";\nimport './style.css';\nimport '@fortawesome/fontawesome-free/css/all.css';\nimport { RefreshConnector } from \"./websocket\";\nimport {loadDiagramFonts} from \"./graph-view/svg-text\";\n\nconst Root = lazy(() => import('./Root').then(module => ({ default: module.Root })));\n\ninterface ModelData {\n\tmodel: any;\n\tlayout: any;\n}\n\ninterface AppState {\n\tdata: ModelData | null;\n\terror: string | null;\n\tloading: boolean;\n}\n\nconst App: React.FC = () => {\n\tconst [state, setState] = useState({\n\t\tdata: null,\n\t\terror: null,\n\t\tloading: true\n\t});\n\n\tconst loadData = async () => {\n\t\tsetState(prev => ({ ...prev, loading: true, error: null }));\n\t\t\n\t\ttry {\n\t\t\tconst [modelResponse, layoutResponse] = await Promise.all([\n\t\t\t\tfetch('data/model.json'),\n\t\t\t\tfetch('data/layout.json')\n\t\t\t]);\n\n\t\t\tif (!modelResponse.ok) {\n\t\t\t\tthrow new Error(`Failed to fetch model: ${modelResponse.statusText}`);\n\t\t\t}\n\t\t\t\n\t\t\tif (!layoutResponse.ok) {\n\t\t\t\tthrow new Error(`Failed to fetch layout: ${layoutResponse.statusText}`);\n\t\t\t}\n\n\t\t\tconst [model, layout] = await Promise.all([\n\t\t\t\tmodelResponse.json(),\n\t\t\t\tlayoutResponse.json()\n\t\t\t]);\n\t\t\tawait loadDiagramFonts();\n\n\t\t\tsetState({\n\t\t\t\tdata: { model, layout },\n\t\t\t\terror: null,\n\t\t\t\tloading: false\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconsole.error('Failed to load data:', error);\n\t\t\tsetState({\n\t\t\t\tdata: null,\n\t\t\t\terror: error instanceof Error ? error.message : 'Unknown error occurred',\n\t\t\t\tloading: false\n\t\t\t});\n\t\t}\n\t};\n\n\tconst handleFileChange = (path: string) => {\n\t\tif (path.endsWith('.svg')) {\n\t\t\treturn; // Ignore SVG changes to avoid infinite loops\n\t\t}\n\t\t\n\t\tconsole.log('File changed:', path);\n\t\trefreshGraph();\n\t\tloadData();\n\t};\n\n\tuseEffect(() => {\n\t\tconst refreshConnector = new RefreshConnector(handleFileChange);\n\t\trefreshConnector.connect();\n\n\t\t// Initial data load\n\t\tloadData();\n\n\t\treturn () => {\n\t\t\trefreshConnector.disconnect();\n\t\t};\n\t}, []);\n\n\tif (state.loading) {\n\t\treturn ;\n\t}\n\n\tif (state.error) {\n\t\treturn ;\n\t}\n\n\tif (!state.data) {\n\t\treturn ;\n\t}\n\n\treturn (\n\t\t}>\n\t\t\t\n\t\t\n\t);\n};\n\nconst LoadingScreen: React.FC = () => (\n\t
\n\t\t
Loading...
\n\t
\n);\n\nconst ErrorScreen: React.FC<{ error: string; onRetry: () => void }> = ({ error, onRetry }) => (\n\t
\n\t\t

Error loading application

\n\t\t

{error}

\n\t\t\n\t
\n);\n\n// Initialize the application\nconst container = document.getElementById('root');\nif (!container) {\n\tthrow new Error('Root container not found');\n}\n\nconst root = createRoot(container);\nroot.render();\n"],"names":["graphs","camelToWords","camel","split","replace","charAt","toUpperCase","slice","Toolbar","model","currentID","onViewChange","graph","onAutoLayout","onSave","onToggleHelp","saving","layouting","dragMode","setDragMode","views","parseModel","B","jsx_runtime","jsxs","className","children","jsx","ViewSelector","ToolbarActions","length","onChange","e","target","value","disabled","hidden","map","view","key","section","title","style","marginLeft","fontWeight","display","alignItems","DragModeButton","UndoRedoButtons","AlignmentButtons","LayoutControls","GridControls","ZoomControls","SaveButton","HelpButton","onClick","modKey","platform","sy","Fragment","undo","redo","alignSelectionH","alignSelectionV","transform","distributeSelectionH","distributeSelectionV","gridVisible","setGridVisible","react","useState","isGridVisible","snapToGrid","setSnapToGrid","isSnapToGrid","useEffect","updateGridState","window","addEventListener","removeEventListener","toggleGrid","toggleSnapToGrid","snapAllToGrid","ZoomDisplay","zoom","setZoomState","updateZoom","currentZoom","Math","round","graph_view_graph","IX","interval","setInterval","clearInterval","a_","max","min","fitToView","hasChanges","setHasChanges","checkChanges","changed","Help","lazy","Promise","resolve","then","__webpack_require__","bind","module","default","Graph","reportInteractiveError","action","error","console","alert","Root","layout","chunk_62JRHF6Z","Kd","BV","qh","path","element","ModelPane","layouts","refreshGraph","URLSearchParams","document","location","search","get","Object","keys","forEach","searchParams","setSearchParams","ok","decodeURI","helpVisible","setHelpVisible","R","useGraph","handleAutoLayout","setLayouting","useCallback","async","options","direction","layoutDirection","opts","autoLayout","useAutoLayout","handleSave","setSaving","response","fetch","encodeURIComponent","method","body","exportSVG","status","detail","text","trim","Error","setSaved","useSave","ViewRedirect","handleToggleHelp","handleInteractiveAutoLayout","catch","handleInteractiveSave","name","toggleHelp","saveLayout","handleKeyDown","shortcut","shortcuts","Yp","preventDefault","aX","t9","Jk","DE","Vy","Hd","_t","resetView","Op","hZ","OE","Gg","moveSelected","getGridSize","J8","b3","iD","uK","l8","rB","mt","useKeyboardShortcuts","handleViewChange","id","handleSelect","metadata","elements","find","m","log","obj","JSON","parse","stringify","Suspense","fallback","data","onSelect","href","Timer","callback","handler","running","timeoutId","constructor","this","start","timeout","stop","setTimeout","clearTimeout","isRunning","RefreshConnector","static","minDelay","maxDelay","handshakeTimeout","uri","fileChangeHandler","socket","nextDelay","connectionDesired","disconnectionReason","reconnectTimer","DEFAULT_OPTIONS","handleHandshakeTimeout","attemptReconnection","connect","isSocketConnected","prepareForConnection","createWebSocket","disconnect","close","readyState","WebSocket","OPEN","onopen","handleOpen","onclose","handleClose","onmessage","event","handleMessage","onerror","handleError","startHandshake","scheduleReconnection","message","processMessage","command","handleHelloMessage","handleReloadMessage","helloMessage","protocols","LIVERELOAD_PROTOCOLS","ver","sendCommand","send","src_Root","App","state","setState","loading","loadData","prev","modelResponse","layoutResponse","all","statusText","json","svg_text","Mt","handleFileChange","endsWith","S","refreshConnector","LoadingScreen","ErrorScreen","onRetry","justifyContent","height","fontFamily","padding","color","whiteSpace","flexDirection","fontSize","cursor","backgroundColor","border","borderRadius","container","getElementById","client","createRoot","render"],"sourceRoot":""} \ No newline at end of file diff --git a/cmd/mdl/webapp/src/components/Toolbar.tsx b/cmd/mdl/webapp/src/components/Toolbar.tsx index 2691b7dd..9564c96f 100644 --- a/cmd/mdl/webapp/src/components/Toolbar.tsx +++ b/cmd/mdl/webapp/src/components/Toolbar.tsx @@ -240,12 +240,12 @@ const GridControls: FC<{ graph: GraphData }> = ({ graph }) => { ); }; -const ZoomDisplay: FC = () => { +const ZoomDisplay: FC<{ graph: GraphData }> = ({ graph }) => { const [zoom, setZoomState] = useState(100); useEffect(() => { const updateZoom = () => { - const currentZoom = Math.round(getZoom() * 100); + const currentZoom = Math.round(getZoom(graph) * 100); setZoomState(currentZoom); }; @@ -256,11 +256,11 @@ const ZoomDisplay: FC = () => { const interval = setInterval(updateZoom, 100); return () => clearInterval(interval); - }, []); + }, [graph]); return ( - + diff --git a/cmd/mdl/webapp/src/graph-view/defs.ts b/cmd/mdl/webapp/src/graph-view/defs.ts index 5bf40e1e..c532cb21 100644 --- a/cmd/mdl/webapp/src/graph-view/defs.ts +++ b/cmd/mdl/webapp/src/graph-view/defs.ts @@ -1,18 +1,22 @@ import fontFaces from "../fonts.css?inline"; import fontLicense from "@fontsource/inter/LICENSE?raw"; -export const defs = ` +/** + * defs returns one graph's shared SVG definitions. Every id starts with prefix, + * the graph's idPrefix, so definitions of graphs on the same page stay distinct. + */ +export const defs = (prefix: string) => ` - ${fontLicense.replace(/&/g, "&").replace(/ - ${fontLicense.replace(/&/g, "&").replace(/ + - + - + ` diff --git a/cmd/mdl/webapp/src/graph-view/graph-react.tsx b/cmd/mdl/webapp/src/graph-view/graph-react.tsx index a3ba1edf..cdb88627 100644 --- a/cmd/mdl/webapp/src/graph-view/graph-react.tsx +++ b/cmd/mdl/webapp/src/graph-view/graph-react.tsx @@ -25,13 +25,13 @@ export const Graph: FC = ({data, onSelect, dragMode}) => { // Try to restore previous view state, otherwise use auto fit // Skip auto fit if we're in the middle of a reset operation to prevent infinite loop - if (!restoreViewState(data.id) && !data.shouldSkipAutoFit()) { + if (!restoreViewState(data) && !data.shouldSkipAutoFit()) { data.fitToView(); } // Save view state before page unload const handleBeforeUnload = () => { if (data?.id) { - saveViewState(data.id); + saveViewState(data); } }; @@ -40,10 +40,13 @@ export const Graph: FC = ({data, onSelect, dragMode}) => { return () => { // Save view state before cleanup if (data?.id) { - saveViewState(data.id); + saveViewState(data); } window.removeEventListener('beforeunload', handleBeforeUnload); + // Each graph has its own svg, so the next graph's buildGraph no longer + // replaces this graph's window keyboard and unload handlers; remove them here. + (g.svg as any).__cursorInteractionCleanup(); if (ref.current) { ref.current.innerHTML = ''; @@ -62,7 +65,7 @@ export const Graph: FC = ({data, onSelect, dragMode}) => { } // Set up cursor interaction with current drag mode - addCursorInteraction(svg, dragMode); + addCursorInteraction(data, dragMode); } }, [dragMode, graphState]); diff --git a/cmd/mdl/webapp/src/graph-view/graph.ts b/cmd/mdl/webapp/src/graph-view/graph.ts index ace9f6d5..53cd50dc 100644 --- a/cmd/mdl/webapp/src/graph-view/graph.ts +++ b/cmd/mdl/webapp/src/graph-view/graph.ts @@ -133,6 +133,9 @@ interface Layout { [k: string]: Point | SavedEdgePoint[] | boolean } +/** graphCount numbers the graphs created in this page; each GraphData uses it once for its idPrefix. */ +let graphCount = 0 + export class GraphData { id: string; name: string; @@ -144,6 +147,22 @@ export class GraphData { layoutDirection?: LayoutDirection; validatedLayout?: ValidatedLayout; colorToVarMap: Map = new Map(); // For CSS custom properties theming + /** + * svg is the element this graph draws into. Each graph has its own element, + * so several graphs on one page never change each other's drawing, zoom, or + * export. It carries no document-wide id; exportSVG adds id "graph" to the copy. + */ + readonly svg: SVGSVGElement; + /** + * idPrefix starts every id this graph writes into its live svg, for example + * "g2-arrow" or "g2-" plus a model element id, so two graphs in one page never + * share an id. exportSVG removes it, so saved files keep the plain ids. + */ + readonly idPrefix: string; + /** selectListener receives the selected node in the editor; buildGraph sets it. */ + selectListener: (n: Node) => void; + /** dragging is true while the editor user drags this graph's nodes or selection box. */ + dragging = false; private _undo: Undo; private _gridVisible: boolean = false; private _snapToGrid: boolean = true; @@ -158,15 +177,14 @@ export class GraphData { this.edgeVertices = new Map; this.nodesMap = new Map; this.groupsMap = new Map; + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.idPrefix = `g${++graphCount}-`; this._undo = new Undo( this.id, () => this.exportLayout(true), (lo) => this.importLayout(lo, true) ) - - // @ts-ignore - window.graph = this } // after the graph model is build using addNode, addEdge etc, initialize @@ -450,15 +468,15 @@ export class GraphData { // Reset pan transform to (0,0) while preserving zoom resetPanTransform() { - const currentZoom = getZoom() - const zoomGroup = svg.querySelector('g.zoom') as SVGGElement + const currentZoom = getZoom(this) + const zoomGroup = this.svg.querySelector('g.zoom') as SVGGElement if (zoomGroup) { zoomGroup.setAttribute('transform', `scale(${currentZoom}) translate(0, 0)`) updatePanningOptimized(this) } // Clear view state so this reset is not overridden - clearViewState(this.id) + clearViewState(this) // Reset the skip auto fit flag after reset is complete this._skipAutoFit = false @@ -471,15 +489,15 @@ export class GraphData { // Reset view to default state: 100% zoom, centered at origin resetView() { - const zoomGroup = svg.querySelector('g.zoom') as SVGGElement + const zoomGroup = this.svg.querySelector('g.zoom') as SVGGElement if (zoomGroup) { // Reset to 100% zoom, centered at origin zoomGroup.setAttribute('transform', 'scale(1) translate(0, 0)') - updatePanning() + updatePanning(this) } // Clear any saved view state so this reset position is not overridden - clearViewState(this.id) + clearViewState(this) } //redraw connected edges @@ -491,7 +509,7 @@ export class GraphData { redrawEdge(e: Edge) { const p = e.ref.parentElement; p.removeChild(e.ref) - e.ref = buildEdge(e) + e.ref = buildEdge(e, this) p.append(e.ref) } @@ -510,11 +528,19 @@ export class GraphData { this.validatedLayout = validateCurrentLayout(this) } // Get the original SVG - const originalSvg: SVGSVGElement = document.querySelector('svg#graph') + const originalSvg = this.svg const elastic = originalSvg.querySelector('rect.elastic') // Clone the SVG for export (completely separate from the live one) const exportSvg = originalSvg.cloneNode(true) as SVGSVGElement + // Standalone files keep the ids saved files have always used: the root id + // "graph", written before the other root attributes as in earlier files, + // and this graph's own ids without the live idPrefix. + const rootAttributes = Array.from(exportSvg.attributes) + rootAttributes.forEach(attr => exportSvg.removeAttributeNode(attr)) + exportSvg.setAttribute('id', 'graph') + rootAttributes.forEach(attr => exportSvg.setAttributeNode(attr)) + this.removeIdPrefix(exportSvg) // Standalone SVGs navigate to sibling view files instead of editor routes. exportSvg.querySelectorAll('a.nodeLink[data-export-href]').forEach(link => { @@ -575,6 +601,28 @@ export class GraphData { return src } + /** + * removeIdPrefix rewrites the export copy's ids, url(#…) references, and #… + * links that name this graph's own elements back to their saved names, for + * example "g2-arrow" to "arrow" and "url(#g2-arrow)" to "url(#arrow)". Values + * that do not start with this graph's idPrefix, such as node links and image + * URLs, stay unchanged. + */ + private removeIdPrefix(svg: SVGSVGElement) { + const prefix = this.idPrefix + svg.querySelectorAll('*').forEach(el => { + for (const attr of Array.from(el.attributes)) { + if (attr.name === 'id' && attr.value.startsWith(prefix)) { + attr.value = attr.value.slice(prefix.length) + } else if (attr.value.includes(`url(#${prefix}`)) { + attr.value = attr.value.split(`url(#${prefix}`).join('url(#') + } else if (attr.localName === 'href' && attr.value.startsWith(`#${prefix}`)) { + attr.value = '#' + attr.value.slice(prefix.length + 1) + } + } + }) + } + // Convert inline fill/stroke attributes to CSS custom properties with fallbacks. // This enables theming: container pages can override colors via CSS variables. private convertStylesToCustomProperties(svg: SVGSVGElement) { @@ -915,8 +963,8 @@ export class GraphData { } // Get viewport dimensions - const viewportWidth = svg.parentElement?.clientWidth || 800 - const viewportHeight = svg.parentElement?.clientHeight || 600 + const viewportWidth = this.svg.parentElement?.clientWidth || 800 + const viewportHeight = this.svg.parentElement?.clientHeight || 600 // Add padding around content const padding = 40 @@ -943,16 +991,16 @@ export class GraphData { const translateY = viewportCenterY - (contentCenterY * finalZoom) // Apply zoom and translation transform - const zoomGroup = svg.querySelector('g.zoom') as SVGGElement + const zoomGroup = this.svg.querySelector('g.zoom') as SVGGElement if (zoomGroup) { zoomGroup.setAttribute('transform', `translate(${translateX}, ${translateY}) scale(${finalZoom})`) } // Update panning - updatePanning() + updatePanning(this) // Save view state so this fit position is preserved after reload - saveViewState(this.id) + saveViewState(this) } // Save current layout state for restoration @@ -1012,15 +1060,15 @@ export class GraphData { } updateGridDisplay() { - if (!svg) return; + const svg = this.svg; // Remove existing grid pattern and background - const existingGrid = svg.querySelector('#grid-pattern'); + const existingGrid = svg.querySelector(`#${this.idPrefix}grid-pattern`); if (existingGrid) { existingGrid.remove(); } - const existingGridRect = svg.querySelector('#grid-background'); + const existingGridRect = svg.querySelector(`#${this.idPrefix}grid-background`); if (existingGridRect) { existingGridRect.remove(); } @@ -1035,7 +1083,7 @@ export class GraphData { } const pattern = document.createElementNS('http://www.w3.org/2000/svg', 'pattern'); - pattern.id = 'grid-pattern'; + pattern.id = `${this.idPrefix}grid-pattern`; pattern.setAttribute('width', this._gridSize.toString()); pattern.setAttribute('height', this._gridSize.toString()); pattern.setAttribute('patternUnits', 'userSpaceOnUse'); @@ -1052,12 +1100,12 @@ export class GraphData { // Create grid background rectangle const rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); - rect.id = 'grid-background'; + rect.id = `${this.idPrefix}grid-background`; rect.setAttribute('x', '-10000'); rect.setAttribute('y', '-10000'); rect.setAttribute('width', '20000'); rect.setAttribute('height', '20000'); - rect.setAttribute('fill', 'url(#grid-pattern)'); + rect.setAttribute('fill', `url(#${this.idPrefix}grid-pattern)`); rect.setAttribute('pointer-events', 'none'); // Insert grid as first child of zoom group so it transforms with content @@ -1104,35 +1152,19 @@ function escapeCdata(code: string) { -let svg: SVGSVGElement = document.querySelector('svg#graph') -if (!svg) { - svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); - svg.setAttribute('id', 'graph') - svg.addEventListener('click', e => clickListener(e)) - // addCursorInteraction(svg) // Call will be updated in buildGraph -} -svg.setAttribute('width', '100%') -svg.setAttribute('height', '100%') - -let clickListener: (e: MouseEvent) => void -let dragging = false; -let selectListener: (n: Node) => void - - +/** + * buildGraph draws data into its own svg for the editor and attaches the + * editor's mouse, wheel, and keyboard handling to that graph. Calling it again + * for the same graph redraws the same svg and replaces the earlier handlers. + * onNodeSelect receives the selected node; the caller places the returned svg. + */ export const buildGraph = (data: GraphData, onNodeSelect: (n: Node) => void, dragMode: 'pan' | 'select') => { + const svg = data.svg + svg.setAttribute('width', '100%') + svg.setAttribute('height', '100%') document.body.append(svg) // make sure svg element is connected, we will measure texts sizes - // @ts-ignore - svg.__data = data - - selectListener = onNodeSelect - //use event delegation - clickListener = e => { - if (dragging) { - return; - } - // const el = (e.target as any).closest('.node > .expand'); - } + data.selectListener = onNodeSelect _buildGraph(data) const elasticEl = create.rect(300, 300, 50, 50, 0, 'elastic') @@ -1142,25 +1174,24 @@ export const buildGraph = (data: GraphData, onNodeSelect: (n: Node) => void, dra data.updateGridDisplay() // Call addCursorInteraction with dragMode - addCursorInteraction(svg, dragMode) + addCursorInteraction(data, dragMode) return { svg, - setZoom, + setZoom: (zoom: number) => setZoom(data, zoom), } } +/** buildGraphView draws data into its own svg without editor handling and returns that svg. */ export const buildGraphView = (data: GraphData) => { - svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); - svg.setAttribute('id', 'graph') _buildGraph(data) - return svg + return data.svg } const _buildGraph = (data: GraphData) => { // Every graph owns the reusable SVG definitions referenced by its drawn // elements, including relationship arrowheads, icons, and filters. - svg.innerHTML = defs + data.svg.innerHTML = defs(data.idPrefix) //toplevel groups const zoomG = create.element('g', {}, 'zoom') as SVGGElement @@ -1179,7 +1210,7 @@ const _buildGraph = (data: GraphData) => { edge.labelBounds = undefined }) data.edges.forEach(e => { - buildEdge(e) + buildEdge(e, data) edgesG.append(e.ref) }) @@ -1188,14 +1219,15 @@ const _buildGraph = (data: GraphData) => { groupsG.append(group.ref) }) - svg.append(zoomG) + data.svg.append(zoomG) } -function buildEdge(edge: Edge) { +/** buildEdge draws one relationship of data, using data's idPrefix for its ids and arrowhead. */ +function buildEdge(edge: Edge, data: GraphData) { const n1 = edge.from; const g = create.element('g', {}, 'edge') as SVGGElement - g.setAttribute('id', edge.id) + g.setAttribute('id', data.idPrefix + edge.id) g.setAttribute('data-from', edge.from.id) g.setAttribute('data-to', edge.to.id) @@ -1211,7 +1243,7 @@ function buildEdge(edge: Edge) { const path = createEdgePath(vertices) - const p = create.path(path, {'marker-end': 'url(#arrow)'}, 'edge') + const p = create.path(path, {'marker-end': `url(#${data.idPrefix}arrow)`}, 'edge') p.setAttribute('fill', 'none') p.setAttribute('stroke', edge.style.color) p.setAttribute('stroke-width', String(edge.style.thickness)) @@ -1224,7 +1256,7 @@ function buildEdge(edge: Edge) { // drag handlers for (const p of edge.vertices ?? []) { const v = p as EdgeVertex - v.ref = create.element('circle', {id: v.id, cx: p.x, cy: p.y, r: 7, fill: 'none'}, 'v-dot') + v.ref = create.element('circle', {id: data.idPrefix + v.id, cx: p.x, cy: p.y, r: 7, fill: 'none'}, 'v-dot') v.selected && v.ref.classList.add('selected') v.auto && v.ref.classList.add('auto') g.append(v.ref) @@ -1314,12 +1346,10 @@ function buildEdgeLabel(placement: EdgeLabelPlacement, edge: Edge) { } +/** buildNode draws one element of data, using data's idPrefix for its id. */ function buildNode(n: Node, data: GraphData) { - // @ts-ignore - window.gdata = data - const g = create.element('g', {}, 'node') as SVGGElement - g.setAttribute('id', n.id) + g.setAttribute('id', data.idPrefix + n.id) n.selected && g.classList.add('selected') setPosition(g, n.x, n.y) const link = n.link @@ -1465,13 +1495,14 @@ function findClosestSegment(graph: GraphData, p: Point) { return fnd.edge ? fnd : null } -function mouseToDrawing(e: MouseEvent): Point { +/** mouseToDrawing converts a mouse event over data's svg to drawing coordinates. */ +function mouseToDrawing(data: GraphData, e: MouseEvent): Point { // transform event coords to drawing coords - const b = svg.getBoundingClientRect() - const z = getZoom() + const b = data.svg.getBoundingClientRect() + const z = getZoom(data) // Get current pan transform - const currentTransform = getCurrentTransform() + const currentTransform = getCurrentTransform(data) // Convert screen coordinates to drawing coordinates accounting for zoom and pan // The transform values are in screen coordinates, so we need to divide by zoom and subtract @@ -1487,8 +1518,8 @@ interface Handle extends Point { ref?: SVGElement } -// Custom cursor interaction that prioritizes panning over selection -function addCustomCursorInteraction(svg: SVGSVGElement, conn: { +// Custom cursor interaction that prioritizes panning over selection, on data's svg +function addCustomCursorInteraction(data: GraphData, conn: { nodeFromEvent(e: MouseEvent): Handle | null; setSelection(handles: Handle[]): void; setDragging(dragging: boolean): void; @@ -1499,6 +1530,7 @@ function addCustomCursorInteraction(svg: SVGSVGElement, conn: { boxSelection(box: DOMRect, add: boolean): void; updatePanning(): void; }, dragMode: 'pan' | 'select') { + const svg = data.svg let ini: { x: number; y: number; n: Handle }[] = [] let elastic: any = null let isPanning = false @@ -1520,7 +1552,7 @@ function addCustomCursorInteraction(svg: SVGSVGElement, conn: { return { ini(e: MouseEvent) { // Use mouseToDrawing to get proper drawing coordinates (accounts for zoom and pan) - const pt = mouseToDrawing(e) + const pt = mouseToDrawing(data, e) startDrawingX = pt.x startDrawingY = pt.y @@ -1546,7 +1578,7 @@ function addCustomCursorInteraction(svg: SVGSVGElement, conn: { if (!rect) return // Convert current mouse position to drawing coordinates (accounts for zoom and pan) - const currentPt = mouseToDrawing(e) + const currentPt = mouseToDrawing(data, e) const currentDrawingX = currentPt.x const currentDrawingY = currentPt.y @@ -1604,7 +1636,7 @@ function addCustomCursorInteraction(svg: SVGSVGElement, conn: { const zoomGroup = svg.querySelector('g.zoom') as SVGGElement if (!zoomGroup) return - const zoom = getZoom() + const zoom = getZoom(data) zoomGroup.setAttribute('transform', `translate(${x}, ${y}) scale(${zoom})`) } @@ -1766,10 +1798,7 @@ function addCustomCursorInteraction(svg: SVGSVGElement, conn: { // Save view state if user was panning (user-initiated view change) if (isPanning && hasDragged) { - const graphData = (svg as any).__data as GraphData - if (graphData && graphData.id) { - saveViewState(graphData.id) - } + saveViewState(data) } // Reset state @@ -1854,7 +1883,14 @@ function addCustomCursorInteraction(svg: SVGSVGElement, conn: { } } -export function addCursorInteraction(svg: SVGSVGElement, dragMode: 'pan' | 'select') { +/** + * addCursorInteraction attaches the editor's mouse, wheel, keyboard, and + * unsaved-changes handling for data and its svg, replacing handlers attached by + * an earlier call. The cleanup function is stored as the svg's + * __cursorInteractionCleanup; the editor calls it when it removes the graph. + */ +export function addCursorInteraction(data: GraphData, dragMode: 'pan' | 'select') { + const svg = data.svg // Clean up any existing event listeners to prevent conflicts const existingCleanup = (svg as any).__cursorInteractionCleanup if (existingCleanup) { @@ -1866,13 +1902,11 @@ export function addCursorInteraction(svg: SVGSVGElement, dragMode: 'pan' | 'sele return el.__data } - const gd = () => (getData(svg) as GraphData) - // Store event listeners for cleanup const eventListeners: Array<{ element: Element | Window, event: string, handler: EventListener }> = [] const beforeUnloadHandler = (e: BeforeUnloadEvent) => { - if (!gd().changed()) return + if (!data.changed()) return e.preventDefault() e.returnValue = '' } @@ -1881,20 +1915,20 @@ export function addCursorInteraction(svg: SVGSVGElement, dragMode: 'pan' | 'sele function setDotSelected(d: Handle, selected: boolean) { d.selected = selected - const dotEl = svg.querySelector('#' + d.id) + const dotEl = svg.querySelector('#' + data.idPrefix + d.id) d.selected ? dotEl.classList.add('selected') : dotEl.classList.remove('selected') } // show moving dot along edge when ALT is pressed const mouseMoveHandler = (e: MouseEvent) => { if (!e.altKey) return - const fnd = findClosestSegment(gd(), mouseToDrawing(e)) + const fnd = findClosestSegment(data, mouseToDrawing(data, e)) if (fnd) { const {prj} = fnd const parent = svg.querySelector('g.edges') - let dot = parent.querySelector('#prj') + let dot = parent.querySelector(`#${data.idPrefix}prj`) if (!dot) { - dot = create.element('circle', {id: 'prj', cx: prj.x, cy: prj.y, r: 7}) + dot = create.element('circle', {id: `${data.idPrefix}prj`, cx: prj.x, cy: prj.y, r: 7}) parent.append(dot) } dot.setAttribute('cx', String(prj.x)) @@ -1915,18 +1949,18 @@ export function addCursorInteraction(svg: SVGSVGElement, dragMode: 'pan' | 'sele eventListeners.push({ element: window, event: 'keyup', handler: keyUpHandler }) function removePrjDot() { - const el = svg.querySelector('g.edges #prj') + const el = svg.querySelector(`g.edges #${data.idPrefix}prj`) el && el.parentElement.removeChild(el) } const clickHandler = (e: MouseEvent) => { const key = findShortcut(e, true) if (key != ADD_LABEL_VERTEX && key != ADD_VERTEX) return - const fnd = findClosestSegment(gd(), mouseToDrawing(e)) + const fnd = findClosestSegment(data, mouseToDrawing(data, e)) if (fnd) { const {edge, pos, prj} = fnd // depending on keyboard modifier, make it label position - gd().insertEdgeVertex(edge, prj, pos, key == ADD_LABEL_VERTEX) + data.insertEdgeVertex(edge, prj, pos, key == ADD_LABEL_VERTEX) removePrjDot() } } @@ -1937,7 +1971,7 @@ export function addCursorInteraction(svg: SVGSVGElement, dragMode: 'pan' | 'sele // Handle wheel zoom directly without relying on shortcuts // deltaY > 0 means scrolling down (zoom out), deltaY < 0 means scrolling up (zoom in) const delta = Math.sign(e.deltaY) * 0.1 // Normalize to 0.1 zoom steps - const currentZoom = getZoom() + const currentZoom = getZoom(data) const newZoom = Math.max(0.1, Math.min(5, currentZoom - delta)) // Clamp zoom between 0.1 and 5 if (newZoom !== currentZoom) { @@ -1945,14 +1979,11 @@ export function addCursorInteraction(svg: SVGSVGElement, dragMode: 'pan' | 'sele const rect = svg.getBoundingClientRect() const svgX = e.clientX - rect.left const svgY = e.clientY - rect.top - setZoomCentered(newZoom, svgX, svgY) + setZoomCentered(data, newZoom, svgX, svgY) e.preventDefault() // Save view state after user wheel zoom - const graphData = (svg as any).__data as GraphData - if (graphData && graphData.id) { - saveViewState(graphData.id) - } + saveViewState(data) } } svg.addEventListener('wheel', wheelHandler) @@ -1968,45 +1999,45 @@ export function addCursorInteraction(svg: SVGSVGElement, dragMode: 'pan' | 'sele switch (shortcut) { case DEL_VERTEX: - const selectedVertices = Array.from(gd().edgeVertices.values()).filter(v => v.selected); + const selectedVertices = Array.from(data.edgeVertices.values()).filter(v => v.selected); selectedVertices.forEach(v => { - gd().deleteEdgeVertex(v) + data.deleteEdgeVertex(v) }) break case UNDO: - gd().undo() + data.undo() break case REDO: - gd().redo() + data.redo() break case ZOOM_IN: - const newZoomIn = Math.min(5, getZoom() * 1.2) + const newZoomIn = Math.min(5, getZoom(data) * 1.2) // Center zoom on viewport center like mouse wheel - setZoomCentered(newZoomIn) - saveViewState(gd().id) // Save after user keyboard zoom + setZoomCentered(data, newZoomIn) + saveViewState(data) // Save after user keyboard zoom break case ZOOM_OUT: - const newZoomOut = Math.max(0.1, getZoom() / 1.2) + const newZoomOut = Math.max(0.1, getZoom(data) / 1.2) // Center zoom on viewport center like mouse wheel - setZoomCentered(newZoomOut) - saveViewState(gd().id) // Save after user keyboard zoom + setZoomCentered(data, newZoomOut) + saveViewState(data) // Save after user keyboard zoom break case ZOOM_100: // Center zoom on viewport center like mouse wheel - setZoomCentered(1) - saveViewState(gd().id) // Save after user keyboard zoom + setZoomCentered(data, 1) + saveViewState(data) // Save after user keyboard zoom break case ZOOM_FIT: - gd().fitToView() + data.fitToView() // Don't save view state here - fitToView should not be persisted break case SELECT_ALL: - gd().nodes().forEach(n => gd().setNodeSelected(n, true)) - gd().edgeVertices.forEach(v => setDotSelected(v, true)) + data.nodes().forEach(n => data.setNodeSelected(n, true)) + data.edgeVertices.forEach(v => setDotSelected(v, true)) break case DESELECT: - gd().nodes().forEach(n => gd().setNodeSelected(n, false)) - gd().edgeVertices.forEach(v => setDotSelected(v, false)) + data.nodes().forEach(n => data.setNodeSelected(n, false)) + data.edgeVertices.forEach(v => setDotSelected(v, false)) break } } @@ -2014,61 +2045,61 @@ export function addCursorInteraction(svg: SVGSVGElement, dragMode: 'pan' | 'sele eventListeners.push({ element: window, event: 'keydown', handler: keyDownHandler }) // Custom cursor interaction with pan-first behavior - const customInteractionCleanup = addCustomCursorInteraction(svg, { + const customInteractionCleanup = addCustomCursorInteraction(data, { nodeFromEvent(e: MouseEvent): Handle { e.preventDefault() // node clicked let el = (e.target as SVGElement).closest('g.nodes g.node') as SVGElement if (el) return getData(el) - // vertex dot clicked + // vertex dot clicked; its id is the vertex id after this graph's idPrefix el = (e.target as SVGElement).closest('g.edges g.edge .v-dot') as SVGElement if (el) { - return gd().edgeVertices.get(el.id) + return data.edgeVertices.get(el.id.slice(data.idPrefix.length)) } return null }, setSelection(handles: Handle[]) { // nodes - gd().nodes().forEach(n => gd().setNodeSelected(n, handles.some(h => h.id == n.id))) + data.nodes().forEach(n => data.setNodeSelected(n, handles.some(h => h.id == n.id))) // dots - gd().edgeVertices.forEach(d => setDotSelected(d, handles.some(h => h.id == d.id))) - selectListener(gd().nodes().find(n => n.selected)) + data.edgeVertices.forEach(d => setDotSelected(d, handles.some(h => h.id == d.id))) + data.selectListener(data.nodes().find(n => n.selected)) }, setDragging(d: boolean) { - dragging = d + data.dragging = d }, isSelected(handle: Handle): boolean { return handle.selected }, getSelection(): Handle[] { - const ret: Handle[] = gd().nodes().filter(n => n.selected) - gd().edgeVertices.forEach(d => d.selected && ret.push(d)) + const ret: Handle[] = data.nodes().filter(n => n.selected) + data.edgeVertices.forEach(d => d.selected && ret.push(d)) return ret }, - getZoom: getZoom, + getZoom: () => getZoom(data), moveNode(h: Handle, x: number, y: number) { - if (gd().nodesMap.has(h.id)) - gd().moveNode(h as Node, x, y) + if (data.nodesMap.has(h.id)) + data.moveNode(h as Node, x, y) else { (h as EdgeVertex).auto = false - gd().moveEdgeVertex(h as EdgeVertex, x, y) + data.moveEdgeVertex(h as EdgeVertex, x, y) } }, boxSelection(box: DOMRect, add) { // Box is now already in drawing coordinates, no need to scale // nodes - gd().nodesMap.forEach(n => { + data.nodesMap.forEach(n => { const inBox = boxesOverlap(uncenterBox(n), box) if (inBox) { // Toggle selection for elements in the box - gd().setNodeSelected(n, !n.selected) + data.setNodeSelected(n, !n.selected) } else if (!add) { // If not holding shift and element is outside box, deselect it - gd().setNodeSelected(n, false) + data.setNodeSelected(n, false) } }) // dots - gd().edgeVertices.forEach(d => { + data.edgeVertices.forEach(d => { const inBox = insideBox(d, box, false) if (inBox) { // Toggle selection for elements in the box @@ -2079,9 +2110,9 @@ export function addCursorInteraction(svg: SVGSVGElement, dragMode: 'pan' | 'sele } }) - selectListener(gd().nodes().find(n => n.selected)) + data.selectListener(data.nodes().find(n => n.selected)) }, - updatePanning: updatePanning, + updatePanning: () => updatePanning(data), }, dragMode) // Store cleanup function on the SVG element for later use @@ -2098,9 +2129,9 @@ export function addCursorInteraction(svg: SVGSVGElement, dragMode: 'pan' | 'sele ;(svg as any).__cursorInteractionCleanup = cleanup } -export function getZoom() { - if (!svg) return 1 - const el = svg.querySelector('g.zoom') as SVGGElement +/** getZoom returns data's current zoom, or 1 before data has been drawn. */ +export function getZoom(data: GraphData) { + const el = data.svg.querySelector('g.zoom') as SVGGElement if (!el) return 1 // Parse zoom from transform attribute to match how we set it @@ -2114,22 +2145,27 @@ export function getZoom() { // svgPadding is now imported as SVG_PADDING from constants.ts -export function setZoom(zoom: number) { - if (!svg) return - const el = svg.querySelector('g.zoom') as SVGGElement +/** setZoom sets data's zoom and keeps its current pan; it does nothing before data is drawn. */ +export function setZoom(data: GraphData, zoom: number) { + const el = data.svg.querySelector('g.zoom') as SVGGElement if (!el) return // Preserve existing translation when setting zoom - const currentTransform = getCurrentTransform() + const currentTransform = getCurrentTransform(data) el.setAttribute('transform', `translate(${currentTransform.x}, ${currentTransform.y}) scale(${zoom})`) // also set panning size - updatePanning() + updatePanning(data) } -export function setZoomCentered(newZoom: number, centerX?: number, centerY?: number) { +/** + * setZoomCentered sets data's zoom while keeping the drawing point under + * (centerX, centerY) in place, by default the center of the svg's container. + */ +export function setZoomCentered(data: GraphData, newZoom: number, centerX?: number, centerY?: number) { + const svg = data.svg const el = svg.querySelector('g.zoom') as SVGGElement - const oldZoom = getZoom() + const oldZoom = getZoom(data) // If no center point provided, use viewport center if (centerX === undefined || centerY === undefined) { @@ -2147,7 +2183,7 @@ export function setZoomCentered(newZoom: number, centerX?: number, centerY?: num } // Get current transform - const currentTransform = getCurrentTransform() + const currentTransform = getCurrentTransform(data) // Convert screen coordinates to drawing coordinates // For transform order translate(tx, ty) scale(s): @@ -2166,12 +2202,12 @@ export function setZoomCentered(newZoom: number, centerX?: number, centerY?: num el.setAttribute('transform', `translate(${newTranslateX}, ${newTranslateY}) scale(${newZoom})`) // Update panning - updatePanning() + updatePanning(data) } -function getCurrentTransform() { - if (!svg) return { x: 0, y: 0 } - const el = svg.querySelector('g.zoom') as SVGGElement +/** getCurrentTransform returns data's current pan, or (0, 0) before data is drawn. */ +function getCurrentTransform(data: GraphData) { + const el = data.svg.querySelector('g.zoom') as SVGGElement if (!el) return { x: 0, y: 0 } const transform = el.getAttribute('transform') || '' @@ -2185,12 +2221,13 @@ function getCurrentTransform() { return { x: 0, y: 0 } } -function updatePanning() { - if (!svg) return +/** updatePanning resizes data's svg to fit its zoomed drawing; it does nothing until the svg is placed. */ +function updatePanning(data: GraphData) { + const svg = data.svg const el = svg.querySelector('g.zoom') as SVGGElement if (!el) return const bb = el.getBBox() - const zoom = getZoom() + const zoom = getZoom(data) if (!svg.parentElement) return const w = Math.max(svg.parentElement.clientWidth / zoom, bb.x + bb.width + SVG_PADDING) const h = Math.max(svg.parentElement.clientHeight / zoom, bb.y + bb.height + SVG_PADDING) @@ -2203,25 +2240,21 @@ function updatePanning() { // Optimized version that uses pre-calculated content bounds instead of expensive getBBox() function updatePanningOptimized(graphData: GraphData) { + const svg = graphData.svg const bb = graphData.calculateContentBounds() // Use already calculated bounds - const zoom = getZoom() + const zoom = getZoom(graphData) const w = Math.max(svg.parentElement.clientWidth / zoom, bb.x + bb.width + SVG_PADDING) const h = Math.max(svg.parentElement.clientHeight / zoom, bb.y + bb.height + SVG_PADDING) svg.setAttribute('width', String(w * zoom)) svg.setAttribute('height', String(h * zoom)) } -export const getZoomAuto = () => { - // Get the graph data to calculate proper content bounds - const graphData = (svg as any).__data as GraphData - if (!graphData) { - return 1 // Default zoom if no graph data - } - +/** getZoomAuto returns the zoom that fits graphData's content in its svg's container. */ +export const getZoomAuto = (graphData: GraphData) => { // Use proper content bounds calculation const contentBounds = graphData.calculateContentBounds() - const viewportWidth = svg.parentElement?.clientWidth || 800 - const viewportHeight = svg.parentElement?.clientHeight || 600 + const viewportWidth = graphData.svg.parentElement?.clientWidth || 800 + const viewportHeight = graphData.svg.parentElement?.clientHeight || 600 // Add padding around content const padding = 40 @@ -2243,43 +2276,41 @@ const setBorderStyle = (el: SVGElement, style: string) => { // View state persistence - similar to undo cache but for zoom/pan const viewStateCache = new Map(); -// Save current view state (zoom and pan) -export function saveViewState(graphId: string) { - if (!svg) return; - - const zoom = getZoom(); - const transform = getCurrentTransform(); +// Save data's current view state (zoom and pan) under its view id +export function saveViewState(data: GraphData) { + const zoom = getZoom(data); + const transform = getCurrentTransform(data); const state = { zoom, transform: { x: transform.x, y: transform.y } }; - viewStateCache.set(graphId, state); + viewStateCache.set(data.id, state); } -// Restore view state if it exists -export function restoreViewState(graphId: string): boolean { - if (!svg || !viewStateCache.has(graphId)) { +// Restore the view state saved for data's view id, if it exists +export function restoreViewState(data: GraphData): boolean { + if (!viewStateCache.has(data.id)) { return false; } - const state = viewStateCache.get(graphId); + const state = viewStateCache.get(data.id); if (!state) { return false; } // Restore zoom and transform - const zoomGroup = svg.querySelector('g.zoom') as SVGGElement; + const zoomGroup = data.svg.querySelector('g.zoom') as SVGGElement; if (zoomGroup) { zoomGroup.setAttribute('transform', `scale(${state.zoom}) translate(${state.transform.x}, ${state.transform.y})`); - updatePanning(); + updatePanning(data); } return true; } -// Clear view state for a graph -export function clearViewState(graphId: string) { - viewStateCache.delete(graphId); +// Clear the view state saved for data's view id +export function clearViewState(data: GraphData) { + viewStateCache.delete(data.id); } diff --git a/cmd/mdl/webapp/src/parseModel.test.ts b/cmd/mdl/webapp/src/parseModel.test.ts index 24301a3c..68c509bf 100644 --- a/cmd/mdl/webapp/src/parseModel.test.ts +++ b/cmd/mdl/webapp/src/parseModel.test.ts @@ -2,12 +2,6 @@ import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"; import {parseView} from "./parseModel"; -vi.hoisted(() => { - vi.stubGlobal("document", { - querySelector: () => ({setAttribute: () => {}}), - }); -}); - // Parser tests use fixed text sizes; browser tests verify the rendered geometry. vi.mock("./graph-view/svg-text", () => ({ measureSVGText: (text: string) => ({width: text.length * 8, height: 16}), @@ -15,7 +9,8 @@ vi.mock("./graph-view/svg-text", () => ({ })); beforeEach(() => { - vi.stubGlobal("window", {}); + // Each parsed GraphData creates its own svg element; parsing never draws into it. + vi.stubGlobal("document", {createElementNS: () => ({})}); vi.useFakeTimers(); }); From 501815fccb52d28e08031e717e4f107be68c03ec Mon Sep 17 00:00:00 2001 From: Raphael Simon Date: Tue, 10 Nov 2026 13:13:18 -0800 Subject: [PATCH 2/2] Style the relationship-point preview by class The preview dot shown on Alt-hover is now created with a per-graph id, so the editor style sheet's circle#prj rule no longer matched and the dot was drawn black. The dot carries a class and the rule selects it. The #icon-cube rule repeated the .icon rule on the same element and is removed. Export no longer rewrites href values and leaves user-authored node links untouched. The unused dragging flag and its callback are removed. Browser tests check the preview dot's colors after a real Alt-hover, that each graph is fitted inside its own container, and that a node link starting with the live id prefix survives export unchanged. --- cmd/mdl/graph_isolation_test.go | 79 ++++++++++++++--- cmd/mdl/svg_e2e_test.go | 113 ++++++++++++++++++++++++- cmd/mdl/webapp/dist/286.js | 2 +- cmd/mdl/webapp/dist/286.js.map | 2 +- cmd/mdl/webapp/src/graph-view/graph.ts | 29 +++---- cmd/mdl/webapp/src/style.css | 5 +- 6 files changed, 188 insertions(+), 42 deletions(-) diff --git a/cmd/mdl/graph_isolation_test.go b/cmd/mdl/graph_isolation_test.go index 273b7470..a8332f6a 100644 --- a/cmd/mdl/graph_isolation_test.go +++ b/cmd/mdl/graph_isolation_test.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "math" "net" "net/http" "os" @@ -33,10 +34,21 @@ type ( OwnNodes bool `json:"ownNodes"` // Zoom is the transform that fitting the layout set on this svg. Zoom string `json:"zoom"` + // Container is the width and height of the element that holds this svg. + Container [2]float64 `json:"container"` + // FittedContent is this graph's content box (left, top, right, bottom) + // after Zoom, in the container's coordinates; empty when Zoom is not a + // translate-then-scale transform. + FittedContent []float64 `json:"fittedContent"` // Grid is true when this svg shows its own grid. Grid bool `json:"grid"` - // Unresolved lists url(#…) and #… references with no target in this svg. + // Unresolved lists url(#…) and #… references with no target in this svg; + // node links are user-authored targets, not references, and are skipped. Unresolved []string `json:"unresolved"` + // IDPrefix is the prefix of this graph's live ids. + IDPrefix string `json:"idPrefix"` + // ExportLinks lists the exported node link targets. + ExportLinks []string `json:"exportLinks"` // Export is the graph's exported SVG file. Export string `json:"export"` // ExportRootID is the id of the exported root element. @@ -97,20 +109,34 @@ func TestTwoGraphsInOneDocument(t *testing.T) { })()` const layoutScript = `(async () => { const graphs = [window.firstGraph, ` + editorGraphScript + `]; + // A fixed-size holder keeps the first graph's container size unchanged by layout. const holder = document.createElement("div"); + holder.style.cssText = "width: 640px; height: 480px; overflow: hidden"; document.body.append(holder); holder.append(graphs[0].svg); graphs.forEach(graph => graph.toggleGrid()); + const containers = graphs.map(graph => + [graph.svg.parentElement.clientWidth, graph.svg.parentElement.clientHeight]); await Promise.all(graphs.map(graph => graph.autoLayout())); const ids = [...document.querySelectorAll("[id]")].map(el => el.id); return { duplicates: ids.filter((id, index) => ids.indexOf(id) !== index), - graphs: graphs.map(graph => { + graphs: graphs.map((graph, index) => { const svg = graph.svg; const refs = graph.nodes().map(node => node.ref); const drawn = [...svg.querySelectorAll("g.nodes > g.node")]; + const zoom = svg.querySelector("g.zoom").getAttribute("transform") || ""; + const fit = zoom.match(/^translate\(([^,]+), ([^)]+)\) scale\(([^)]+)\)$/); + const fitted = []; + if (fit) { + const [x, y, scale] = fit.slice(1).map(Number); + const content = graph.calculateContentBounds(); + fitted.push(x + content.x * scale, y + content.y * scale, + x + (content.x + content.width) * scale, y + (content.y + content.height) * scale); + } const unresolved = []; for (const el of svg.querySelectorAll("*")) { + if (el.matches("a.nodeLink")) continue; for (const attr of el.attributes) { const target = attr.value.match(/^url\(#(.+)\)$/)?.[1] ?? (attr.localName === "href" && attr.value.startsWith("#") ? attr.value.slice(1) : null); @@ -119,16 +145,21 @@ func TestTwoGraphsInOneDocument(t *testing.T) { } const markup = graph.exportSVG(); const exported = new DOMParser().parseFromString(markup, "image/svg+xml").documentElement; - const leaks = [...exported.querySelectorAll("*")].flatMap(el => [...el.attributes] - .filter(attr => (attr.name === "id" && attr.value.startsWith(graph.idPrefix)) || - attr.value.includes("#" + graph.idPrefix)) - .map(attr => attr.value)); + const leaks = [...exported.querySelectorAll("*")].filter(el => !el.matches("a.nodeLink")) + .flatMap(el => [...el.attributes] + .filter(attr => (attr.name === "id" && attr.value.startsWith(graph.idPrefix)) || + attr.value.includes("#" + graph.idPrefix)) + .map(attr => attr.value)); return { nodes: graph.nodes().map(node => node.id).sort(), ownNodes: drawn.length === refs.length && drawn.every(el => refs.includes(el)), - zoom: svg.querySelector("g.zoom").getAttribute("transform") || "", + zoom, + container: containers[index], + fittedContent: fitted, grid: svg.querySelector("pattern") !== null, unresolved, + idPrefix: graph.idPrefix, + exportLinks: [...exported.querySelectorAll("a.nodeLink")].map(link => link.getAttribute("href")).sort(), export: markup, exportRootId: exported.id, exportNodes: [...exported.querySelectorAll("g.node")].map(node => node.id).sort(), @@ -161,20 +192,41 @@ func TestTwoGraphsInOneDocument(t *testing.T) { if len(result.Graphs) != 2 { t.Fatalf("expected two graphs, got %d", len(result.Graphs)) } + if result.Graphs[0].Zoom == result.Graphs[1].Zoom { + t.Errorf("both graphs have the same fit transform %q", result.Graphs[0].Zoom) + } + // The person's model URL starts with the first graph's live id prefix; the + // export must keep this user-authored link exactly as written. + if result.Graphs[0].IDPrefix != "g1-" { + t.Fatalf("first graph id prefix %q, want g1- for the link check", result.Graphs[0].IDPrefix) + } for i, want := range []struct { view string nodes []string + links []string orientation string }{ - {"Context", []string{"shop", "user"}, "horizontal"}, - {"Containers", []string{"db", "user", "web"}, "vertical"}, + {"Context", []string{"shop", "user"}, []string{"#g1-guide", "Containers.svg"}, "horizontal"}, + {"Containers", []string{"db", "user", "web"}, []string{"#g1-guide"}, "vertical"}, } { got := result.Graphs[i] if !reflect.DeepEqual(got.Nodes, want.nodes) || !got.OwnNodes { t.Errorf("%s: svg nodes %v (only its own: %t), want %v", want.view, got.Nodes, got.OwnNodes, want.nodes) } - if got.Zoom == "" { - t.Errorf("%s: layout fit was not applied to this graph's svg", want.view) + // Fitting centers a graph's own content in its own container. + width, height := got.Container[0], got.Container[1] + if len(got.FittedContent) != 4 { + t.Errorf("%s: transform %q is not this graph's fit", want.view, got.Zoom) + } else if left, top, right, bottom := got.FittedContent[0], got.FittedContent[1], + got.FittedContent[2], got.FittedContent[3]; math.Abs((left+right)/2-width/2) > 0.5 || + math.Abs((top+bottom)/2-height/2) > 0.5 || + left < -0.5 || top < -0.5 || right > width+0.5 || bottom > height+0.5 { + t.Errorf("%s: fitted content %v is not centered inside its %vx%v container", + want.view, got.FittedContent, width, height) + } + if !reflect.DeepEqual(got.ExportLinks, want.links) { + t.Errorf("%s: exported node links %v, want %v with the user's #g1-guide unchanged", + want.view, got.ExportLinks, want.links) } if !got.Grid { t.Errorf("%s: svg has no grid", want.view) @@ -203,13 +255,14 @@ func TestTwoGraphsInOneDocument(t *testing.T) { } // twoViewDesign returns one model with two views that share the element -// "user" and differ in shapes, colors, and layout direction. +// "user" and differ in shapes, colors, and layout direction. The user's URL +// starts with the first graph's live id prefix text, "g1-". func twoViewDesign() *mdl.Design { return &mdl.Design{ Name: "Two views", Model: &mdl.Model{ People: []*mdl.Person{{ - ID: "user", Name: "Customer", Tags: "Element,Person,person", + ID: "user", Name: "Customer", Tags: "Element,Person,person", URL: "#g1-guide", Relationships: []*mdl.Relationship{ {ID: "browse", SourceID: "user", DestinationID: "shop", Description: "Browses", Tags: "Relationship"}, {ID: "order", SourceID: "user", DestinationID: "web", Description: "Orders through", Tags: "Relationship"}, diff --git a/cmd/mdl/svg_e2e_test.go b/cmd/mdl/svg_e2e_test.go index 06837813..d4a34672 100644 --- a/cmd/mdl/svg_e2e_test.go +++ b/cmd/mdl/svg_e2e_test.go @@ -15,6 +15,7 @@ import ( "testing" "time" + "github.com/chromedp/cdproto/input" cdruntime "github.com/chromedp/cdproto/runtime" "github.com/chromedp/chromedp" "github.com/jaschaephraim/lrserver" @@ -45,6 +46,21 @@ type ( ExpectedWidth float64 `json:"expectedWidth"` ExpectedHeight float64 `json:"expectedHeight"` } + + // pagePoint is a position in page (CSS pixel) coordinates. + pagePoint struct { + X float64 `json:"x"` + Y float64 `json:"y"` + } + + // previewDotStyle compares the relationship-point preview dot's computed + // colors with the colors the editor style sheet's "circle.prj" rule sets. + previewDotStyle struct { + Fill string `json:"fill"` + Stroke string `json:"stroke"` + RuleFill string `json:"ruleFill"` + RuleStroke string `json:"ruleStroke"` + } ) const ( @@ -229,6 +245,82 @@ func TestManualEditAfterAutoLayout(t *testing.T) { } } +// TestEdgePointPreviewStyle moves the mouse over a relationship with Alt held, +// as an editor user does before adding a relationship point, and checks that +// the preview dot gets the colors of the editor style sheet's preview rule. +func TestEdgePointPreviewStyle(t *testing.T) { + if !hasChrome() { + t.Skip("skipping: Chrome/Chromium not available in PATH") + } + design, err := loadDesign("goa.design/model/examples/basic/model", false) + if err != nil { + t.Fatalf("load design: %v", err) + } + listener, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatalf("listen: %v", err) + } + server := NewServer(design) + httpServer := &http.Server{ReadHeaderTimeout: 3 * time.Second} + serverDone := make(chan error, 1) + outDir := t.TempDir() + go func() { + serverDone <- server.ServeOnListener(outDir, "", httpServer, http.NewServeMux(), listener) + }() + t.Cleanup(func() { + if err := httpServer.Close(); err != nil { + t.Errorf("close editor server: %v", err) + } + if err := <-serverDone; err != nil && err != http.ErrServerClosed { + t.Errorf("editor server: %v", err) + } + }) + testContext, cleanup := newChromeContext(t) + defer cleanup() + + const previewDot = "#root > div.graph svg g.edges > circle" + // The middle of the drawn relationship line, in page coordinates. + const edgeMiddleScript = `(() => { + const path = document.querySelector("#root > div.graph svg g.edge > path.edge"); + const middle = path.getPointAtLength(path.getTotalLength() / 2); + const point = new DOMPoint(middle.x, middle.y).matrixTransform(path.getScreenCTM()); + return {x: point.x, y: point.y}; + })()` + const styleScript = `(() => { + const style = getComputedStyle(document.querySelector("` + previewDot + `")); + const rule = [...document.styleSheets].flatMap(sheet => [...sheet.cssRules]) + .find(rule => rule.selectorText === "circle.prj"); + return { + fill: style.fill, + stroke: style.stroke, + ruleFill: rule?.style.fill ?? "", + ruleStroke: rule?.style.stroke ?? "", + }; + })()` + var middle pagePoint + if err := chromedp.Run(testContext, + chromedp.Navigate(fmt.Sprintf("http://%s/?id=SystemContext", listener.Addr().String())), + chromedp.WaitVisible(editorNodeSelector, chromedp.ByQuery), + clickEditorButton(autoLayoutButton), + chromedp.Evaluate(edgeMiddleScript, &middle), + ); err != nil { + t.Fatalf("lay out view and find relationship: %v", err) + } + var style previewDotStyle + if err := chromedp.Run(testContext, + chromedp.MouseEvent(input.MouseMoved, middle.X, middle.Y, chromedp.ButtonModifiers(input.ModifierAlt)), + chromedp.Poll(`document.querySelector("`+previewDot+`") !== null`, nil, + chromedp.WithPollingTimeout(5*time.Second)), + chromedp.Evaluate(styleScript, &style), + ); err != nil { + t.Fatalf("show relationship point preview: %v", err) + } + if style.RuleFill == "" || style.Fill != style.RuleFill || style.Stroke != style.RuleStroke { + t.Fatalf("preview dot fill %q stroke %q, want circle.prj rule fill %q stroke %q", + style.Fill, style.Stroke, style.RuleFill, style.RuleStroke) + } +} + // TestSVGAuthoredPresentation checks the shared renderer and its standalone // export with explicit shapes, an image icon, content choices, and boundary colors. func TestSVGAuthoredPresentation(t *testing.T) { @@ -768,16 +860,29 @@ func newChromeContext(t *testing.T) (context.Context, func()) { // clickEditorButton clicks one editor toolbar button and waits until the editor // enables it again, which happens once the layout or save it started finishes. +// It fails, naming the selector, when the button is missing or stays disabled +// for 15 seconds. func clickEditorButton(selector string) chromedp.Action { var finished bool - script := fmt.Sprintf(`new Promise(resolve => { - const button = document.querySelector(%q); - new MutationObserver((records, observer) => { + script := fmt.Sprintf(`new Promise((resolve, reject) => { + const selector = %q; + const button = document.querySelector(selector); + if (!button) { + reject(new Error("no editor button matches " + selector)); + return; + } + const observer = new MutationObserver(records => { if (records.some(record => record.oldValue !== null)) { observer.disconnect(); + clearTimeout(timer); resolve(true); } - }).observe(button, {attributeFilter: ["disabled"], attributeOldValue: true}); + }); + const timer = setTimeout(() => { + observer.disconnect(); + reject(new Error("editor button " + selector + " was not enabled again within 15 seconds")); + }, 15000); + observer.observe(button, {attributeFilter: ["disabled"], attributeOldValue: true}); button.click(); })`, selector) return chromedp.Evaluate(script, &finished, func(params *cdruntime.EvaluateParams) *cdruntime.EvaluateParams { diff --git a/cmd/mdl/webapp/dist/286.js b/cmd/mdl/webapp/dist/286.js index 84349f6d..e13e1776 100644 --- a/cmd/mdl/webapp/dist/286.js +++ b/cmd/mdl/webapp/dist/286.js @@ -1,2 +1,2 @@ -"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[286],{628(t,e,n){n.d(e,["AV",0,(t,e)=>{Object.entries(e).forEach(([e,n])=>{t.setAttribute(e,String(n))})},"M5",0,{nodeBorder:{"stroke-width":1.5},nodeText:{"font-family":"Inter, -apple-system, BlinkMacSystemFont, sans-serif",stroke:"none"},edgeText:{"font-family":"Inter, -apple-system, BlinkMacSystemFont, sans-serif",stroke:"none"},edgeRect:{fill:"none",stroke:"none"},groupRect:{fill:"none",stroke:"#8492a6","stroke-width":1.5,"stroke-dasharray":"6 4"},groupText:{fill:"#475569","font-size":20,"font-weight":"600","font-family":"Inter, -apple-system, BlinkMacSystemFont, sans-serif",cursor:"default"}},"Y$",0,{thickness:2,color:"#64748b",opacity:1,fontSize:18,width:200,dashed:!0},"gd",0,(t,e)=>Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)),"nD",0,{width:280,height:180,background:"#ffffff",color:"#334155",opacity:1,stroke:"#8492a6",fontSize:22,shape:"Box",metadata:!0,description:!0}])},977(t,e,n){n.d(e,{IW:()=>r,Zr:()=>s,l:()=>i});var o=n(628);function i(t){const e=t.from,n=t.to;let o=t.vertices?t.vertices.concat():[];o.unshift(e),o.push(n);const i=o.slice(1,-1),r=i.find(t=>!t.label)??n;let s=e;for(let t=i.length-1;t>=0;t--)if(!i[t].label){s=i[t];break}if(!e.intersect||!n.intersect)throw new Error(`edge ${t.id} nodes must be drawn before routing`);return o[0]=e.intersect(r),o[o.length-1]=n.intersect(s),o}function r(t,e,n){let i,r={x:n.x,y:n.y};const s=t.findIndex(t=>t.label);let a=!0;if(s>=0){const e=t[s];r=e,a=!0===e.auto;const n=[];s>0&&n.push({p:t[s-1],q:r}),st?(0,o.gd)(e.p,e.q)>(0,o.gd)(t.p,t.q)?e:t:e,void 0)}else{const n=t.slice(1).reduce((e,n,i)=>e+(0,o.gd)(t[i],n),0)*e;let s=0;for(let e=1;e0&&s+d>=n){const t=(n-s)/d;r={x:a.p.x+(a.q.x-a.p.x)*t,y:a.p.y+(a.q.y-a.p.y)*t},i=a;break}s+=d}}const d=i?Math.abs(i.q.x-i.p.x):0,l=i?Math.abs(i.q.y-i.p.y):0;return{...r,orientation:l>d?"vertical":"horizontal",segment:i,movable:a}}function s(t){if(t.length<2)throw new Error("edge route must contain at least two points");return t.slice(1).reduce((t,e)=>`${t} L${e.x},${e.y}`,`M${t[0].x},${t[0].y}`)}},20(t,e,n){n.d(e,{r:()=>i}),Symbol("ValidatedLayout");class o extends Error{issues;constructor(t){super(t.map(t=>t.message).join("\n")),this.name="GeometryValidationError",this.issues=t}}function i(t,e){const n=[];t.id!==e.diagramId&&n.push(C("missing_element",[t.id,e.diagramId],`layout ${e.diagramId} does not resolve measured diagram ${t.id}`)),r("measured node",t.nodes.map(t=>t.id),n),r("measured group",t.groups.map(t=>t.id),n),r("measured edge",t.edges.map(t=>t.id),n),r("resolved node",e.nodes.map(t=>t.id),n),r("resolved group",e.groups.map(t=>t.id),n),r("resolved edge",e.edges.map(t=>t.id),n),s("node",t.nodes.map(t=>t.id),e.nodes.map(t=>t.id),n),s("group",t.groups.map(t=>t.id),e.groups.map(t=>t.id),n),s("edge",t.edges.map(t=>t.id),e.edges.map(t=>t.id),n);const i=new Map(t.nodes.map(t=>[t.id,t])),b=new Map(t.groups.map(t=>[t.id,t])),y=new Map(e.nodes.map(t=>[t.id,t])),B=new Map(e.groups.map(t=>[t.id,t]));a("diagram",e.diagramId,e.bounds,n);for(const t of e.nodes){a("node",t.id,t.bounds,n);const o=i.get(t.id);!o||x(o.size.width,t.bounds.width)&&x(o.size.height,t.bounds.height)||n.push(C("size_mismatch",[t.id],`node ${t.id} size changed after measurement`)),o&&(o.contentSize.width>t.bounds.width||o.contentSize.height>t.bounds.height)&&n.push(C("content_overflow",[t.id],`node ${t.id} content exceeds its resolved bounds`)),d("node",t.id,t.bounds,e.bounds,n)}for(const t of e.groups){a("group",t.id,t.bounds,n),a("group title",t.id,t.titleBounds,n),d("group",t.id,t.bounds,e.bounds,n),g(t.bounds,t.titleBounds)||n.push(C("false_containment",[t.id],`group ${t.id} does not contain its title`));const o=b.get(t.id);!o||x(o.titleSize.width,t.titleBounds.width)&&x(o.titleSize.height,t.titleBounds.height)||n.push(C("size_mismatch",[t.id],`group ${t.id} title size changed after measurement`))}if(function(t,e){w(t,(t,n)=>{A(t.bounds,n.bounds)&&e.push(C("node_overlap",[t.id,n.id],`nodes ${t.id} and ${n.id} overlap`))})}(e.nodes,n),function(t,e){w(t,(t,n)=>{!A(t.bounds,n.bounds)||g(t.bounds,n.bounds)||g(n.bounds,t.bounds)||e.push(C("group_overlap",[t.id,n.id],`groups ${t.id} and ${n.id} partially overlap`))})}(e.groups,n),function(t,e,n,o,i){for(const e of t){const t=n.get(e.id);if(t&&t.parentId!==e.parentId&&i.push(C("false_containment",[e.id],`node ${e.id} has the wrong parent ID`)),!e.parentId)continue;const r=o.get(e.parentId);t&&r&&!g(r.bounds,t.bounds)&&i.push(C("false_containment",[e.id,e.parentId],`node ${e.id} lies outside owning group ${e.parentId}`))}for(const t of e){const e=o.get(t.id);if(e&&e.parentId!==t.parentId&&i.push(C("false_containment",[t.id],`group ${t.id} has the wrong parent ID`)),!t.parentId)continue;const n=o.get(t.parentId);e&&n&&!g(n.bounds,e.bounds)&&i.push(C("false_containment",[t.id,t.parentId],`group ${t.id} lies outside owning group ${t.parentId}`))}}(t.nodes,t.groups,y,B,n),function(t,e,n,o,i,r,s){const g=new Map(t.edges.map(t=>[t.id,t])),b=[];for(const t of e.edges){const y=g.get(t.id);if(y)if(t.sourceId===y.sourceId&&t.targetId===y.targetId||s.push(C("disconnected_edge",[t.id,t.sourceId,t.targetId],`edge ${t.id} endpoints do not match its measured contract`)),0===t.sections.length||t.sections.some(t=>t.length<2))s.push(C("disconnected_edge",[t.id],`edge ${t.id} has no complete route section`));else{l(t,n,s);for(const n of t.sections)for(const o of n)if(!m(o)||!f(o,e.bounds,!0)){s.push(C("out_of_bounds",[t.id],`edge ${t.id} has a route point outside the resolved view`));break}for(const e of n.values())e.id!==t.sourceId&&e.id!==t.targetId&&u(t.sections,p(e.bounds,.5))&&s.push(C("edge_through_node",[t.id,e.id],`edge ${t.id} crosses unrelated node ${e.id}`));for(const e of o.values()){const n=c(t.sourceId,e.id,i,r);n===c(t.targetId,e.id,i,r)&&h(t.sections,e.bounds,n)&&s.push(C("edge_through_group",[t.id,e.id],`edge ${t.id} violates group ${e.id} boundary`))}if(t.labelBounds){a("edge label",t.id,t.labelBounds,s),d("edge label",t.id,t.labelBounds,e.bounds,s),!y.labelSize||x(y.labelSize.width,t.labelBounds.width)&&x(y.labelSize.height,t.labelBounds.height)||s.push(C("size_mismatch",[t.id],`edge ${t.id} label size changed after measurement`));for(const e of n.values())A(t.labelBounds,e.bounds)&&s.push(C("label_node_overlap",[t.id,e.id],`edge ${t.id} label overlaps node ${e.id}`));for(const e of o.values())A(t.labelBounds,e.titleBounds)&&s.push(C("label_title_overlap",[t.id,e.id],`edge ${t.id} label overlaps group ${e.id} title`));b.push({id:t.id,bounds:t.labelBounds})}else y.labelSize&&s.push(C("missing_element",[t.id],`edge ${t.id} is missing its measured label`))}}w(b,(t,e)=>{A(t.bounds,e.bounds)&&s.push(C("label_label_overlap",[t.id,e.id],`edge labels ${t.id} and ${e.id} overlap`))});for(const t of b)for(const n of e.edges)u(n.sections,p(t.bounds,.5))&&s.push(C("label_edge_overlap",[t.id,n.id],`edge ${n.id} crosses label ${t.id}`))}(t,e,y,B,i,b,n),n.length>0)throw new o(n);return e}function r(t,e,n){const o=new Set;for(const i of e)o.has(i)&&n.push(C("duplicate_id",[i],`${t} ${i} is duplicated`)),o.add(i)}function s(t,e,n,o){const i=new Set(e),r=new Set(n);for(const e of i)r.has(e)||o.push(C("missing_element",[e],`${t} ${e} is missing from resolved layout`));for(const e of r)i.has(e)||o.push(C("unexpected_element",[e],`${t} ${e} is not in the measured diagram`))}function a(t,e,n,o){(!function(t){return m(t)&&Number.isFinite(t.width)&&Number.isFinite(t.height)}(n)||n.width<0||n.height<0)&&o.push(C("non_finite",[e],`${t} ${e} has invalid geometry`))}function d(t,e,n,o,i){g(o,n)||i.push(C("out_of_bounds",[e],`${t} ${e} lies outside the resolved view bounds`))}function l(t,e,n){for(let e=1;et.some((n,o)=>o>0&&function(t,e,n){const o=e.x-t.x,i=e.y-t.y;let r=0,s=1;for(const[e,a,d,l]of[[t.x,o,n.x,n.x+n.width],[t.y,i,n.y,n.y+n.height]]){if(Math.abs(a)=l)return!1;continue}const t=(d-e)/a,n=(l-e)/a;if(r=Math.max(r,Math.min(t,n)),s=Math.min(s,Math.max(t,n)),r>=s)return!1}return s>0&&r<1}(t[o-1],n,e)))}function A(t,e){return t.x=e.x+e.width&&t.y+t.height>=e.y+e.height}function f(t,e,n){return n?t.x>=e.x&&t.y>=e.y&&t.x<=e.x+e.width&&t.y<=e.y+e.height:t.x>e.x&&t.y>e.y&&t.x=e.x-.1&&t.x<=e.x+e.width+.1,o=t.y>=e.y-.1&&t.y<=e.y+e.height+.1,i=x(t.x,e.x)||x(t.x,e.x+e.width),r=x(t.y,e.y)||x(t.y,e.y+e.height);return o&&i||n&&r}function x(t,e){return Math.abs(t-e)<=.1}function w(t,e){for(let n=0;n$,Qy:()=>j,ZG:()=>_,oP:()=>D,IX:()=>P,F_:()=>H,Kp:()=>O,a_:()=>R});var o=n(74),i=n(321),r=n(718),s=n(628);const a={element(t,e={},n){const o=document.createElementNS("http://www.w3.org/2000/svg",t);return Object.entries(e).forEach(([t,e])=>o.setAttribute(t,String(e))),n&&o.classList.add(n),o},use(t,e={}){const n=this.element("use",e);return n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","#"+t),n},path(t,e={},n){return this.element("path",{...e,d:t},n)},text(t,e={}){const n=this.element("text",e);return t&&(n.textContent=t),n},textArea(t,e,n,o,i=0,a=0,d=""){const l={"font-family":s.M5.edgeText["font-family"],"font-size":`${n}px`,"font-weight":o?"bold":"normal"},{lines:c,maxW:h}=(0,r.U2)(t,e,l),u=this.text("",{x:0,y:a,"text-anchor":d||void 0});return c.forEach((t,e)=>{const o=this.element("tspan",{x:i,dy:`${n+2}px`,...l});o.textContent=t,u.append(o)}),{txt:u,dy:(c.length+1)*(n+2),maxW:h}},rect(t,e,n=0,o=0,i=0,r){return this.element("rect",{x:n,y:o,rx:i,ry:i,width:t,height:e},r)},icon(t,e=0,n=0){return this.use(t,{x:e,y:n})},expand(t,e,n){const o=this.element("g",{transform:`translate(${t},${e})`},"expand");return o.append(this.rect(19,19,0,0,1),this.text(n?"-":"+",{x:10,y:14,"text-anchor":"middle"})),o}};function d(t,e,n){t.setAttribute("transform",`translate(${e},${n})`)}function l(t,e,n=!0){return n?t.x>e.x-e.width/2&&t.xe.y-e.height/2&&t.ye.x&&t.xe.y&&t.yfunction(t,e,n,o){let i,r,s,a,d,l={x:null,y:null,onLine1:!1,onLine2:!1};return i=(o.y-n.y)*(e.x-t.x)-(o.x-n.x)*(e.y-t.y),0==i||(r=t.y-n.y,s=t.x-n.x,a=(o.x-n.x)*r-(o.y-n.y)*s,d=(e.x-t.x)*r-(e.y-t.y)*s,r=a/i,s=d/i,l.x=t.x+r*(e.x-t.x),l.y=t.y+r*(e.y-t.y),r>0&&r<1&&(l.onLine1=!0),s>=0&&s<=1&&(l.onLine2=!0)),l}(t,e,n.p,n.q)).filter(t=>t.onLine1&&t.onLine2)}(t,e,t)[0]||{x:t.x,y:t.y}}function h(t,e,n,o,i){const r={x:i.x-t.x,y:i.y-t.y},s=o.x-t.x,a=o.y-t.y;s==r.x&&(r.x+=1e-7);const d=(a-r.y)/(s-r.x),l=a-d*s,c=n*n+e*e*d*d,h=2*e*e*l*d,u=e*e*l*l-e*e*n*n,A=Math.sqrt(h*h-4*c*u),g=r.x>s?(-h+A)/(2*c):(-h-A)/(2*c),f={x:g,y:d*g+l};return f.x+=t.x,f.y+=t.y,f}function u(t,e,n){let o=n.x-e.x,i=n.y-e.y,r=o*o+i*i,s=(t.x-e.x)*o+(t.y-e.y)*i,a=Math.min(1,Math.max(0,s/r));return{x:e.x+o*a,y:e.y+i*a}}function A(t,e){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function g(t){return t/2/(5.5+t/70)}function f(t,e,n){switch(t.toLowerCase()){case"cylinder":return 2*g(e);case"person":return.4*n;case"folder":return e/10;case"robot":return.35*n;case"webbrowser":return n/8;default:return 0}}class p{_el;constructor(t){this._el=t}node(){return this._el}attr(t,e){return this._el.setAttribute(t,String(e)),this}insert(t,e){const n=document.createElementNS("http://www.w3.org/2000/svg",t),o=this._el.insertBefore(n,this._el.querySelector(e));return new p(o)}}function m(t,e,n,o=!1){const i=t.insert("rect",":first-child").attr("rx",o?n.width/8:3).attr("ry",o?n.width/8:3).attr("x",-e.width/2).attr("y",-e.height/2).attr("width",e.width).attr("height",e.height);return n.intersect=function(t){return c(n,t)},i}function b(t,e,n,o,i){const r=t.insert("ellipse",":first-child").attr("cx",0).attr("cy",0).attr("rx",o).attr("ry",i).attr("width",n.width).attr("height",n.height);return n.intersect=function(t){return h(n,o,i,n,t)},r}function y(t,e,n){const o=n.width/8,i=n.width/14,r=t.insert("g",":first-child");return r.insert("path",":first-child").attr("d",`M${-n.width/2},${-n.height/2} l${n.width},0 M${-n.width/2},${n.height/2} l${n.width},0`),r.insert("circle",":first-child").attr("cx",0).attr("cy",n.height/2+o/2).attr("r",.4*i),r.insert("rect",":first-child").attr("x",-i).attr("y",-n.height/2-o/2-.2*i).attr("width",2*i).attr("height",.4*i),r.insert("rect",":first-child").attr("rx",i).attr("ry",i).attr("x",-e.width/2).attr("y",-e.height/2-o).attr("width",e.width).attr("height",e.height+2*o),n.intersect=function(t){return c({x:n.x,y:n.y,width:n.width,height:n.height+2*o},t)},r}const x={box:(t,e)=>m(new p(t),e,e).node(),roundedbox:(t,e)=>m(new p(t),e,e,!0).node(),component:(t,e)=>function(t,e,n){const o=n.width/10,i=t.insert("g",":first-child");return i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2-o).attr("y",-n.height/2+o).attr("width",2*o).attr("height",o),i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2-o).attr("y",-n.height/2+2.5*o).attr("width",2*o).attr("height",o),i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2).attr("y",-n.height/2).attr("width",n.width).attr("height",n.height),n.intersect=function(t){return c({x:n.x-o/2,y:n.y,width:n.width+o,height:n.height},t)},i}(new p(t),0,e).node(),cylinder:(t,e)=>function(t,e,n){const o=e.width,i=o/2,r=g(o),s=e.height,a=`M 0,${r} a${i},${r} 0,0,0 ${o} 0 a ${i},${r} 0,0,0 ${-o} 0 l 0,${s-2*r} a ${i},${r} 0,0,0 ${o} 0 l 0,${2*r-s}`,d=t.attr("label-offset-y",f("cylinder",o,s)).insert("path",":first-child").attr("d",a).attr("transform","translate("+-o/2+","+-s/2+")");return n.intersect=function(t){const e=c(n,t);let o=n.y+n.height/2-r;return e.y>o?h({x:n.x,y:o},i,r,n,t):(o=n.y-n.height/2+r,e.yfunction(t,e,n){const o=e.width,i=e.height,r=`M ${.38*o},${i/3} A${o/2},${i/2} 0,0,0 0 ${i/2}\n\t\tL${o/11},${i} L${o-o/11},${i} L${o},${i/2}\n\t\tA${o/2},${i/2} 0,0,0 ${o-.38*o} ${i/3} \n\t\tA${o/6},${o/6} 0,1,0 ${.38*o} ${i/3}`,s=t.attr("label-offset-y",f("person",o,i)).insert("path",":first-child").attr("d",r).attr("transform","translate("+-o/2+","+-i/2+")");return n.intersect=function(t){return c(n,t)},s}(new p(t),e,e).node(),circle:(t,e)=>function(t,e,n){return b(t,0,n,n.width/2,n.width/2)}(new p(t),0,e).node(),ellipse:(t,e)=>function(t,e,n){return b(t,0,n,.55*n.width,.45*n.width)}(new p(t),0,e).node(),hexagon:(t,e)=>function(t,e,n){const o=n.width/2,i=t.insert("polygon",":first-child").attr("points",[.5,.866,1,0,.5,-.866,-.5,-.866,-1,-0,-.5,.866,.5,.866].map(t=>t*o).join(",")).attr("width",n.width).attr("height",n.height);return n.intersect=function(t){return h(n,n.width/2,n.width/2,n,t)},i}(new p(t),0,e).node(),folder:(t,e)=>function(t,e,n){const o=n.width/20,i=t.attr("label-offset-y",f("folder",n.width,n.height)).insert("g",":first-child");return i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2).attr("y",-n.height/2+2*o).attr("width",n.width).attr("height",n.height-2*o),i.insert("path",":first-child").attr("d",`M0,${-n.height/2+2*o} l${o},${-2*o} h${n.width/2-2*o} v${2*o}`),n.intersect=function(t){return c({x:n.x,y:n.y+o/2,width:n.width,height:n.height+o},t)},i}(new p(t),0,e).node(),mobiledevicelandscape:(t,e)=>function(t,e,n){const o=n.width/8,i=n.width/14,r=t.insert("g",":first-child");return r.insert("path",":first-child").attr("d",`M${-n.width/2},${-n.height/2} l0,${n.height} M${n.width/2},${-n.height/2} l0,${n.height}`),r.insert("circle",":first-child").attr("cx",-n.width/2-o/2).attr("cy",0).attr("r",.4*i),r.insert("rect",":first-child").attr("x",n.width/2+o/2-.2*i).attr("y",-i).attr("width",.4*i).attr("height",2*i),r.insert("rect",":first-child").attr("rx",i).attr("ry",i).attr("x",-e.width/2-o).attr("y",-e.height/2).attr("width",e.width+2*o).attr("height",e.height),n.intersect=function(t){return c({x:n.x,y:n.y,width:n.width+2*o,height:n.height},t)},r}(new p(t),e,e).node(),mobiledeviceportrait:(t,e)=>y(new p(t),e,e).node(),mobiledevice:(t,e)=>y(new p(t),e,e).node(),pipe:(t,e)=>function(t,e,n){const o=n.width,i=n.height,r=i/2,s=r/(2.5+o/70),a=`M${-s},0\n\t\ta${s},${r} 0,0,1 0,${i}\n\t\ta${s},${r} 0,0,1 0,${-i}\n\t\tl${o},0\n\t\ta${s},${r} 0,0,1 0,${i}\n\t\tl${-o},0`,d=t.insert("path",":first-child").attr("d",a).attr("transform","translate("+-o/2+","+-i/2+")");return n.intersect=function(t){return c({x:n.x-s,y:n.y,width:n.width+2*s,height:n.height},t)},d}(new p(t),0,e).node(),robot:(t,e)=>function(t,e,n){const o=n.width,i=n.height,r=Math.min(.28*o,.25*i),s=.2*r,a=.25*r,d=.08*r,l=.12*r,h=.22*r,u=.12*r,A=.3*r,g=o,p=-i/2+a+r,m=i-a-r,b=t.attr("label-offset-y",f("robot",o,i)).insert("g",":first-child");b.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-g/2).attr("y",p).attr("width",g).attr("height",m);const y=-i/2+a;b.insert("rect",":first-child").attr("rx",s).attr("ry",s).attr("x",-r/2).attr("y",y).attr("width",r).attr("height",r),b.insert("line",":first-child").attr("class","robot-antenna").attr("x1",0).attr("y1",y).attr("x2",0).attr("y2",-i/2+2*d).attr("stroke-width",.6*d).attr("stroke-linecap","round"),b.insert("circle",":first-child").attr("class","robot-antenna-ball").attr("cx",0).attr("cy",-i/2+2*d).attr("r",1.2*d);const x=y+.4*r;b.insert("circle",":first-child").attr("class","robot-eye").attr("cx",-h).attr("cy",x).attr("r",l),b.insert("circle",":first-child").attr("class","robot-eye").attr("cx",h).attr("cy",x).attr("r",l);const w=y+.7*r,C=.28*r;return b.insert("path",":first-child").attr("class","robot-mouth").attr("d",`M${-C/2},${w} Q0,${w+.3*C} ${C/2},${w}`).attr("fill","none").attr("stroke-width",.5*d).attr("stroke-linecap","round"),b.insert("rect",":first-child").attr("rx",.25*u).attr("ry",.25*u).attr("x",-r/2-u-1).attr("y",x-A/2).attr("width",u).attr("height",A),b.insert("rect",":first-child").attr("rx",.25*u).attr("ry",.25*u).attr("x",r/2+1).attr("y",x-A/2).attr("width",u).attr("height",A),n.intersect=function(t){return c(n,t)},b}(new p(t),0,e).node(),webbrowser:(t,e)=>function(t,e,n){const o=n.height/8,i=t.attr("label-offset-y",f("webbrowser",n.width,n.height)).insert("g",":first-child");return i.insert("path",":first-child").attr("d",`\n\t\t\tM${-n.width/2},${-n.height/2+o} h${n.width}\n\t\t\tM${-n.width/2+o/4},${-n.height/2+o/4} h${o/2} v${o/2} h${-o/2} z\n\t\t\tM${-n.width/2+o},${-n.height/2+o/4} h${n.width-o-o/4} v${o/2} h${-n.width+o+o/4} z\n\t\t`),i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2).attr("y",-n.height/2).attr("width",n.width).attr("height",n.height),n.intersect=function(t){return c(n,t)},i}(new p(t),0,e).node()};var w=n(983);class C{versions=[];pos=0;lastSavedPos=0;exportDoc;importDoc;change;tmpPreviousState=null;constructor(t,e,n){this.exportDoc=e,this.importDoc=n,this.change=function(t){let e;return function(){const n=this;clearTimeout(e),e=setTimeout(function(){e=null,t.apply(n)},300)}}(()=>this.saveNow())}beforeChange(){this.tmpPreviousState||(this.tmpPreviousState=this.deepClone(this.exportDoc()))}length(){return this.versions.length}currentState(){return this.deepClone(this.versions[this.pos-1])}saveNow(){if(!this.tmpPreviousState)throw Error("undo.change() was called without previously calling undo.beforeChange()!");this.versions[this.pos]=this.deepClone(this.exportDoc()),this.versions[this.pos-1]=this.tmpPreviousState,this.tmpPreviousState=null,this.pos+=1,this.versions.splice(this.pos)}deepClone(t){return"undefined"!=typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t))}undo(){if(this.pos<2)return;this.pos-=1;const t=this.versions[this.pos-1];this.importDoc(this.deepClone(t))}redo(){if(this.pos>this.versions.length-1)return;const t=this.versions[this.pos];this.importDoc(this.deepClone(t)),this.pos+=1}changed(){return this.pos!==this.lastSavedPos}setSaved(){this.lastSavedPos=this.pos}}var B=n(264),v=n(977);function I(t,e,n,o,i,a){const d={"font-family":String(s.M5.nodeText["font-family"]),"font-size":`${n}px`,"font-weight":o?"bold":"normal"},l=(0,r.U2)(t,e,d);return{lines:l.lines.length>0?l.lines:[""],fontSize:n,lineHeight:n+2,bold:o,field:a,gapAfter:i}}n(20);const k=s.Y$,E=s.nD;let S=0;class ${id;name;nodesMap;edges;edgeVertices;groupsMap;metadata;layoutDirection;validatedLayout;colorToVarMap=new Map;svg;idPrefix;selectListener;dragging=!1;_undo;_gridVisible=!1;_snapToGrid=!0;_gridSize=25;_skipAutoFit=!1;constructor(t,e){this.id=t,this.name=e,this.edges=[],this.edgeVertices=new Map,this.nodesMap=new Map,this.groupsMap=new Map,this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.idPrefix=`g${++S}-`,this._undo=new C(this.id,()=>this.exportLayout(!0),t=>this.importLayout(t,!0))}init(t){t&&this.importLayout(t),this._undo=new C(this.id,()=>this.exportLayout(!0),t=>this.importLayout(t,!0)),this._undo.length()&&this.importLayout(this._undo.currentState()),this._undo.beforeChange(),this._undo.change()}addNode(t,e,n,o,i,r){if(this.nodesMap.has(t))throw Error("duplicate node: "+t);const s={...E,...i},a=(s.shape||"Box").toLowerCase(),d="person"===a?240:180,l=Math.max(280,s.width||0),c=function(t,e,n,o,i,r){const s=Math.max(o-36,80),a=[I(t,s,i,!0,6,"name")];!1!==r.metadata&&e&&a.push(I(`[${e}]`,s,.7*i,!1,10)),!1!==r.description&&n&&a.push(I(n,s,Math.min(.8*i,16),!1,0,"description")),a[a.length-1].gapAfter=0;const d=a.reduce((t,e)=>t+e.lines.length*e.lineHeight+e.gapAfter,0);return{blocks:a,textHeight:d,minimumHeight:d+36+(r.icon?44:0),icon:r.icon}}(e,n,o,l,s.fontSize||22,s);let h=Math.max(d,s.height||0,c.minimumHeight);for(let t=0;t<20;t++){const t=c.minimumHeight+Math.abs(f(a,l,h));if(t<=h+.1)break;h=t}const u={id:t,title:e,sub:n,description:o,style:s,x:0,y:0,width:l,height:h,intersect:null,link:r,contentLayout:c};this.nodesMap.set(u.id,u)}nodes(){return Array.from(this.nodesMap.values())}addEdge(t,e,n,o,i,r){i&&i.forEach((e,n)=>{const o=e;o.id=`v-${t}-${n}`,this.edgeVertices.set(o.id,o)});const s={id:t,from:this.nodesMap.get(e),to:this.nodesMap.get(n),label:o,vertices:null,style:{...k,...r},initVertex:t=>{const e=t;return e.id||(e.id=((t,e)=>`v-${t}-a-${(t=>{let e=2166136261;for(let n=0;n>>0).toString(36)})(`${t}:${e.x}:${e.y}`)}`)(s.id,t),this.edgeVertices.set(e.id,e)),e.edge=s,t},userDeletedVertices:!1};this.edges.push(s),i&&(s.vertices=i.map(t=>s.initVertex(t)))}addGroup(t,e,n,o){if(this.groupsMap.has(t))return void console.error(`Group exists: ${t} ${e}`);const i={id:t,name:e,x:null,y:null,width:null,height:null,nodes:n.map(n=>{const o=this.nodesMap.get(n)||this.groupsMap.get(n);return o||console.error(`Node or group ${n} not found for group ${t} "${e}"`),o}).filter(Boolean),style:o};this.groupsMap.set(t,i)}setNodeSelected(t,e){t.selected=e,e?t.ref.classList.add("selected"):t.ref.classList.remove("selected"),this.updateEdgesSel()}updateEdgesSel(){this.edges.forEach(t=>{t.to.selected||t.from.selected?t.ref.classList.add("selected"):t.ref.classList.remove("selected")})}clearResolvedLayout(){this.validatedLayout=void 0,this.edges.forEach(t=>{t.layoutSections=void 0,t.layoutLabelBounds=void 0}),this.groupsMap.forEach(t=>{t.layoutBounds=void 0,t.layoutTitleBounds=void 0})}moveNode(t,e,n,o=!1,i=!1){if(t){if(this._snapToGrid&&!o){const t=this.snapToGrid(e,n);e=t.x,n=t.y}t.x==e&&t.y==n||(i||this._undo.beforeChange(),this.clearResolvedLayout(),t.x=e,t.y=n,d(t.ref,e,n),this.redrawEdges(t),this.redrawGroups(t),i||this._undo.change())}}moveEdgeVertex(t,e,n,o=!1,i=!1){if(this._snapToGrid&&!o){const t=this.snapToGrid(e,n);e=t.x,n=t.y}t.x==e&&t.y==n||(i||this._undo.beforeChange(),this.clearResolvedLayout(),t.x=e,t.y=n,this.redrawEdge(t.edge),i||this._undo.change())}moveSelected(t,e,n=!1){this.nodes().forEach(o=>o.selected&&this.moveNode(o,o.x+t,o.y+e,n,!1)),this.edgeVertices.forEach(o=>o.selected&&this.moveEdgeVertex(o,o.x+t,o.y+e,n,!1))}insertEdgeVertex(t,e,n,o){this._undo.beforeChange(),this.clearResolvedLayout();const i=t.initVertex(e);i.selected=!0,o&&(t.vertices.forEach(t=>t.label=!1),i.label=!0),t.vertices.splice(n-1,0,i),this.redrawEdge(t),this._undo.change()}deleteEdgeVertex(t){this._undo.beforeChange(),this.clearResolvedLayout();const e=t.edge.vertices.indexOf(t);e>=0&&(t.edge.vertices.splice(e,1),this.edgeVertices.delete(t.id),t.edge.userDeletedVertices=!0),this.redrawEdge(t.edge),this._undo.change()}changed(){return this._undo.changed()}undo(){this._undo.undo()}redo(){this._undo.redo()}alignTopLeft(){const t=this.calculateContentBounds(),e=100-t.x,n=100-t.y;this._skipAutoFit=!0,this._undo.beforeChange(),this.nodesMap.forEach(t=>{this.moveNode(t,t.x+e,t.y+n,!0,!0)}),this.edgeVertices.forEach(t=>{this.moveEdgeVertex(t,t.x+e,t.y+n,!0,!0)}),this._undo.change()}resetPanTransform(){const t=P(this),e=this.svg.querySelector("g.zoom");e&&(e.setAttribute("transform",`scale(${t}) translate(0, 0)`),function(t){const e=t.svg,n=t.calculateContentBounds(),o=P(t),i=Math.max(e.parentElement.clientWidth/o,n.x+n.width+20),r=Math.max(e.parentElement.clientHeight/o,n.y+n.height+20);e.setAttribute("width",String(i*o)),e.setAttribute("height",String(r*o))}(this)),Z(this),this._skipAutoFit=!1}shouldSkipAutoFit(){return this._skipAutoFit}resetView(){const t=this.svg.querySelector("g.zoom");t&&(t.setAttribute("transform","scale(1) translate(0, 0)"),U(this)),Z(this)}redrawEdges(t){this.edges.forEach(e=>(t==e.from||t==e.to)&&this.redrawEdge(e)),this.updateEdgesSel()}redrawEdge(t){const e=t.ref.parentElement;e.removeChild(t.ref),t.ref=V(t,this),e.append(t.ref)}redrawGroups(t){this.groupsMap.forEach(t=>{const e=t.ref.parentElement;e.removeChild(t.ref),T(t),e.append(t.ref)})}exportSVG(){this.validatedLayout||(this.validatedLayout=(0,w.U)(this));const t=this.svg,e=(t.querySelector("rect.elastic"),t.cloneNode(!0)),n=Array.from(e.attributes);n.forEach(t=>e.removeAttributeNode(t)),e.setAttribute("id","graph"),n.forEach(t=>e.setAttributeNode(t)),this.removeIdPrefix(e),e.querySelectorAll("a.nodeLink[data-export-href]").forEach(t=>{t.setAttribute("href",t.getAttribute("data-export-href")||""),t.removeAttribute("data-export-href")});const o=e.querySelector("rect.elastic");o&&o.remove();const i=this.validatedLayout.bounds,r=i.width+100,s=i.height+100,a=50-i.x,d=50-i.y,l=e.querySelector("g.zoom");l&&l.setAttribute("transform",`scale(1) translate(${a}, ${d})`),e.setAttribute("viewBox",`0 0 ${r} ${s}`),e.setAttribute("width",String(r)),e.setAttribute("height",String(s)),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.convertStylesToCustomProperties(e);const c=document.createElement("script");return c.setAttribute("type","application/json"),this.metadata.layout=this.exportLayout(),c.append("/g,"]]]>]>"),e.insertBefore(c,e.firstChild),e.outerHTML}removeIdPrefix(t){const e=this.idPrefix;t.querySelectorAll("*").forEach(t=>{for(const n of Array.from(t.attributes))"id"===n.name&&n.value.startsWith(e)?n.value=n.value.slice(e.length):n.value.includes(`url(#${e}`)?n.value=n.value.split(`url(#${e}`).join("url(#"):"href"===n.localName&&n.value.startsWith(`#${e}`)&&(n.value="#"+n.value.slice(e.length+1))})}convertStylesToCustomProperties(t){0!==this.colorToVarMap.size&&(t.querySelectorAll("[fill]").forEach(t=>{const e=t.getAttribute("fill");e&&this.colorToVarMap.has(e)&&t.setAttribute("fill",`var(${this.colorToVarMap.get(e)}, ${e})`)}),t.querySelectorAll("[stroke]").forEach(t=>{const e=t.getAttribute("stroke");e&&this.colorToVarMap.has(e)&&t.setAttribute("stroke",`var(${this.colorToVarMap.get(e)}, ${e})`)}))}calculateContentBounds(){let t=1/0,e=1/0,n=-1/0,o=-1/0;return this.nodes().forEach(i=>{const r=i.x-i.width/2,s=i.x+i.width/2,a=i.y-i.height/2,d=i.y+i.height/2;t=Math.min(t,r),n=Math.max(n,s),e=Math.min(e,a),o=Math.max(o,d)}),this.edgeVertices.forEach(i=>{t=Math.min(t,i.x-5),n=Math.max(n,i.x+5),e=Math.min(e,i.y-5),o=Math.max(o,i.y+5)}),this.groupsMap.forEach(i=>{const r=i.x-i.width/2,s=i.x+i.width/2,a=i.y-i.height/2,d=i.y+i.height/2;t=Math.min(t,r),n=Math.max(n,s),e=Math.min(e,a),o=Math.max(o,d)}),this.edges.forEach(i=>{if(t=Math.min(t,i.from.x-10,i.to.x-10),n=Math.max(n,i.from.x+10,i.to.x+10),e=Math.min(e,i.from.y-10,i.to.y-10),o=Math.max(o,i.from.y+10,i.to.y+10),i.vertices&&i.vertices.forEach(i=>{t=Math.min(t,i.x-10),n=Math.max(n,i.x+10),e=Math.min(e,i.y-10),o=Math.max(o,i.y+10)}),i.label&&i.label.trim()){const r=(i.from.x+i.to.x)/2,s=(i.from.y+i.to.y)/2,a=10*i.label.length+50;t=Math.min(t,r-a),n=Math.max(n,r+a),e=Math.min(e,s-25),o=Math.max(o,s+25)}}),t===1/0?{x:0,y:0,width:100,height:100}:{x:t,y:e,width:n-t,height:o-e}}exportLayout(t=!1){const e={};return this.nodes().forEach(t=>e[t.id]={x:t.x,y:t.y}),this.edges.forEach(n=>{if(!n.vertices)return;const o=n.vertices.map(t=>({x:t.x,y:t.y,label:t.label,auto:t.auto}));(o.length||t)&&(e[`e-${n.id}`]=o),n.userDeletedVertices&&(e[`e-${n.id}-deleted`]=!0)}),e}setSaved(){this._undo.setSaved()}importLayout(t,e=!1){this.clearResolvedLayout();for(const[e,n]of Object.entries(t)){const t=this.nodesMap.get(e);if(t){const o=L(e,n);t.x=o.x,t.y=o.y;continue}if(e.endsWith("-deleted")){const t=e.slice(2,-8),o=this.edges.find(e=>e.id===t);if(!o||!0!==n)throw new Error(`invalid deleted-edge layout entry ${e}`);o.userDeletedVertices=!0;continue}if(e.startsWith("e-")){const t=this.edges.find(t=>t.id===e.slice(2));if(!t||!Array.isArray(n))throw new Error(`invalid edge layout entry ${e}`);for(const e of t.vertices??[])this.edgeVertices.delete(e.id);t.vertices=n.map((n,o)=>{const i=L(`${e}[${o}]`,n),r=t.initVertex(i);return r.label=n.label,r.auto=n.auto,r});continue}throw new Error(`layout contains unknown element ${e}`)}for(const e of this.nodes())if(!(e.id in t))throw new Error(`layout is missing node ${e.id}`);e&&(this.nodes().forEach(t=>d(t.ref,t.x,t.y)),this.edges.forEach(t=>this.redrawEdge(t)),this.updateEdgesSel(),this.redrawGroups(null))}async autoLayout(t){const e=await(0,w.k)(this,t);this._undo.beforeChange();for(const t of e.nodes){const e=this.nodesMap.get(t.id);if(!e)throw new Error(`layout contains unknown node ${t.id}`);e.x=t.x,e.y=t.y,d(e.ref,e.x,e.y)}for(const t of e.groups){const e=this.groupsMap.get(t.id);if(!e)throw new Error(`layout contains unknown group ${t.id}`);e.layoutBounds=t.bounds,e.layoutTitleBounds=t.titleBounds,e.x=t.bounds.x+t.bounds.width/2,e.y=t.bounds.y+t.bounds.height/2,e.width=t.bounds.width,e.height=t.bounds.height}for(const t of e.edges){const e=this.edges.find(e=>e.id===t.id);if(!e)throw new Error(`layout contains unknown edge ${t.id}`);for(const t of e.vertices??[])this.edgeVertices.delete(t.id);e.layoutSections=t.sections,e.layoutLabelBounds=t.labelBounds,e.vertices=M(t.sections).map(t=>{const n=e.initVertex(t);return n.auto=!0,n}),e.userDeletedVertices=!1}this.validatedLayout=e.validated,this.edges.forEach(t=>this.redrawEdge(t)),this.redrawGroups(null),this.fitToView(),this._undo.change()}alignSelectionV(){const t=this.nodes().filter(t=>t.selected);t.push(...Array.from(this.edgeVertices.values()).filter(t=>t.selected));let e=Math.min(...t.map(t=>t.y));this.nodesMap.forEach(t=>t.selected&&this.moveNode(t,t.x,e,!1,!1)),this.edgeVertices.forEach(t=>t.selected&&this.moveEdgeVertex(t,t.x,e,!1,!1))}alignSelectionH(){const t=this.nodes().filter(t=>t.selected);t.push(...Array.from(this.edgeVertices.values()).filter(t=>t.selected));let e=Math.min(...t.map(t=>t.x));this.nodesMap.forEach(t=>t.selected&&this.moveNode(t,e,t.y,!1,!1)),this.edgeVertices.forEach(t=>t.selected&&this.moveEdgeVertex(t,e,t.y,!1,!1))}distributeSelectionH(){const t=this.nodes().filter(t=>t.selected),e=Array.from(this.edgeVertices.values()).filter(t=>t.selected);if(t.length+e.length<3)return;this._undo.beforeChange();const n=[...t,...e];n.sort((t,e)=>t.x-e.x);const o=n[0].x,i=(n[n.length-1].x-o)/(n.length-1);n.forEach((t,e)=>{const n=o+e*i;"title"in t?this.moveNode(t,n,t.y,!1,!0):this.moveEdgeVertex(t,n,t.y,!1,!0)}),this._undo.change()}distributeSelectionV(){const t=this.nodes().filter(t=>t.selected),e=Array.from(this.edgeVertices.values()).filter(t=>t.selected);if(t.length+e.length<3)return;this._undo.beforeChange();const n=[...t,...e];n.sort((t,e)=>t.y-e.y);const o=n[0].y,i=(n[n.length-1].y-o)/(n.length-1);n.forEach((t,e)=>{const n=o+e*i;"title"in t?this.moveNode(t,t.x,n,!1,!0):this.moveEdgeVertex(t,t.x,n,!1,!0)}),this._undo.change()}setEdgeSelected(t,e){e&&(this.setNodeSelected(t.from,!0),this.setNodeSelected(t.to,!0)),this.updateEdgesSel()}fitToView(){const t=this.calculateContentBounds();if(0===t.width||0===t.height)return;const e=this.svg.parentElement?.clientWidth||800,n=this.svg.parentElement?.clientHeight||600,o=(e-80)/t.width,i=(n-80)/t.height,r=Math.min(o,i),s=Math.max(Math.min(r,2),.1),a=e/2-(t.x+t.width/2)*s,d=n/2-(t.y+t.height/2)*s,l=this.svg.querySelector("g.zoom");l&&l.setAttribute("transform",`translate(${a}, ${d}) scale(${s})`),U(this),O(this)}saveLayoutState(){return this.exportLayout(!0)}restoreLayoutState(t){this.importLayout(t,!0)}isGridVisible(){return this._gridVisible}isSnapToGrid(){return this._snapToGrid}getGridSize(){return this._gridSize}toggleGrid(){this._gridVisible=!this._gridVisible,this.updateGridDisplay(),window.dispatchEvent(new CustomEvent("gridStateChanged"))}toggleSnapToGrid(){this._snapToGrid=!this._snapToGrid,window.dispatchEvent(new CustomEvent("gridStateChanged"))}snapAllToGrid(){this._snapToGrid&&(this._undo.beforeChange(),this.nodes().forEach(t=>{const e=Math.round(t.x/this._gridSize)*this._gridSize,n=Math.round(t.y/this._gridSize)*this._gridSize;this.moveNode(t,e,n,!1,!0)}),this._undo.change())}snapToGrid(t,e){return{x:Math.round(t/this._gridSize)*this._gridSize,y:Math.round(e/this._gridSize)*this._gridSize}}updateGridDisplay(){const t=this.svg,e=t.querySelector(`#${this.idPrefix}grid-pattern`);e&&e.remove();const n=t.querySelector(`#${this.idPrefix}grid-background`);if(n&&n.remove(),!this._gridVisible)return;let o=t.querySelector("defs");o||(o=document.createElementNS("http://www.w3.org/2000/svg","defs"),t.insertBefore(o,t.firstChild));const i=document.createElementNS("http://www.w3.org/2000/svg","pattern");i.id=`${this.idPrefix}grid-pattern`,i.setAttribute("width",this._gridSize.toString()),i.setAttribute("height",this._gridSize.toString()),i.setAttribute("patternUnits","userSpaceOnUse");const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",`M ${this._gridSize} 0 L 0 0 0 ${this._gridSize}`),r.setAttribute("fill","none"),r.setAttribute("stroke","#d0d0d0"),r.setAttribute("stroke-width","1"),r.setAttribute("opacity","0.8"),i.appendChild(r),o.appendChild(i);const s=document.createElementNS("http://www.w3.org/2000/svg","rect");s.id=`${this.idPrefix}grid-background`,s.setAttribute("x","-10000"),s.setAttribute("y","-10000"),s.setAttribute("width","20000"),s.setAttribute("height","20000"),s.setAttribute("fill",`url(#${this.idPrefix}grid-pattern)`),s.setAttribute("pointer-events","none");const a=t.querySelector("g.zoom");a&&a.insertBefore(s,a.firstChild)}}function M(t){const e=[];for(const n of t)for(const t of n){const n=e[e.length-1];n&&n.x===t.x&&n.y===t.y||e.push(t)}return e.slice(1,-1)}function L(t,e){if("object"!=typeof e||Array.isArray(e)||!Number.isFinite(e.x)||!Number.isFinite(e.y))throw new Error(`layout entry ${t} must contain valid x and y coordinates`);return e}const _=(t,e,n)=>{const o=t.svg;o.setAttribute("width","100%"),o.setAttribute("height","100%"),document.body.append(o),t.selectListener=e,z(t);const i=a.rect(300,300,50,50,0,"elastic");return o.append(i),t.updateGridDisplay(),j(t,n),{svg:o,setZoom:e=>function(t,e){const n=t.svg.querySelector("g.zoom");if(!n)return;const o=W(t);n.setAttribute("transform",`translate(${o.x}, ${o.y}) scale(${e})`),U(t)}(t,e)}},D=t=>(z(t),t.svg),z=t=>{var e;t.svg.innerHTML=(e=t.idPrefix,`\n\n\t\n\t${i.replace(/&/g,"&").replace(/\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n`);const n=a.element("g",{},"zoom"),r=a.element("g",{},"nodes"),l=a.element("g",{},"edges"),c=a.element("g",{},"groups");n.append(c,l,r),t.nodesMap.forEach(e=>{!function(t,e){const n=a.element("g",{},"node");n.setAttribute("id",e.idPrefix+t.id),t.selected&&n.classList.add("selected"),d(n,t.x,t.y);const o=t.link?a.element("a",{href:t.link.href,"data-export-href":t.link.exportHref,"aria-label":`Open ${t.title}`},"nodeLink"):null,i=o||n;o&&(n.classList.add("linked"),n.append(o));const r=t.style.shape||"Box",l=(x[r.toLowerCase()]||x.box)(i,t);l.classList.add("nodeBorder"),(0,s.AV)(l,s.M5.nodeBorder),l.setAttribute("fill",t.style.background),l.setAttribute("stroke",t.style.stroke),l.setAttribute("opacity",String(t.style.opacity)),G(l,t.style.border);const c=function(t,e){const n=a.element("g"),o=t.icon?44:0;let i=-(t.textHeight+o)/2;return t.icon&&(n.append(a.element("image",{href:t.icon,x:-16,y:i,width:32,height:32,preserveAspectRatio:"xMidYMid meet"},"nodeIcon")),i+=o),t.blocks.forEach(t=>{const o=a.text("",{"text-anchor":"middle"});(0,s.AV)(o,s.M5.nodeText),e&&o.setAttribute("fill",e),t.field&&o.setAttribute("data-field",t.field),t.lines.forEach((e,n)=>{const r=a.element("tspan",{x:0,y:i+t.fontSize+n*t.lineHeight,"font-size":`${t.fontSize}px`,"font-weight":t.bold?"bold":"normal"});r.textContent=e,o.append(r)}),n.append(o),i+=t.lines.length*t.lineHeight+t.gapAfter}),n}(t.contentLayout,t.style.color);d(c,0,(Number(i.getAttribute("label-offset-y"))||0)/2),i.append(c),n.__data=t,t.ref=n}(e,t),r.append(e.ref)}),t.edges.forEach(t=>{t.labelBounds=void 0}),t.edges.forEach(e=>{V(e,t),l.append(e.ref)}),t.groupsMap.forEach(t=>{T(t),c.append(t.ref)}),t.svg.append(n)};function V(t,e){const n=t.from,o=a.element("g",{},"edge");o.setAttribute("id",e.idPrefix+t.id),o.setAttribute("data-from",t.from.id),o.setAttribute("data-to",t.to.id);const i=(t.style.position||50)/100,r=t.layoutSections?function(t){const e=[];for(const n of t)for(const t of n){const n=e[e.length-1];n&&n.x===t.x&&n.y===t.y||e.push(t)}return e}(t.layoutSections):(0,v.l)(t),{bg:d,txt:l}=t.layoutLabelBounds?function(t,e){const n=t.x+t.width/2,{txt:o}=(t.y,t.height,a.textArea(e.label,e.style.width,e.style.fontSize,!1,n,t.y,"middle"));(0,s.AV)(o,s.M5.edgeText),o.setAttribute("stroke","none"),o.setAttribute("font-size",String(e.style.fontSize)),o.setAttribute("fill",e.style.color),o.setAttribute("data-field","label");const i=a.rect(t.width,t.height,t.x,t.y);return(0,s.AV)(i,s.M5.edgeRect),{bg:i,txt:o}}(t.layoutLabelBounds,t):function(t,e){const n=e.style.fontSize;let{txt:o,dy:i,maxW:r}=a.textArea(e.label,e.style.width,n,!1,t.x,t.y,"middle");i-=n/2,r+=n;const d="vertical"===t.orientation?t.x+r/2+12:t.x,l="vertical"===t.orientation?t.y:t.y-i/2-12,c={x:d-r/2,y:l-i/2,width:r,height:i};o.querySelectorAll("tspan").forEach(t=>{t.setAttribute("x",String(d))}),o.setAttribute("y",String(l-i/2)),(0,s.AV)(o,s.M5.edgeText),o.setAttribute("stroke","none"),o.setAttribute("font-size",String(e.style.fontSize)),o.setAttribute("fill",e.style.color);const h=a.rect(c.width,c.height,c.x,c.y);return(0,s.AV)(h,s.M5.edgeRect),o.setAttribute("data-field","label"),e.labelBounds=c,{bg:h,txt:o}}((0,v.IW)(r,i,n),t);o.append(d,l);const c=(0,v.Zr)(r),h=a.path(c,{"marker-end":`url(#${e.idPrefix}arrow)`},"edge");h.setAttribute("fill","none"),h.setAttribute("stroke",t.style.color),h.setAttribute("stroke-width",String(t.style.thickness)),h.setAttribute("stroke-linecap","round"),t.style.dashed&&h.setAttribute("stroke-dasharray","8"),o.append(h);for(const n of t.vertices??[]){const t=n;t.ref=a.element("circle",{id:e.idPrefix+t.id,cx:n.x,cy:n.y,r:7,fill:"none"},"v-dot"),t.selected&&t.ref.classList.add("selected"),t.auto&&t.ref.classList.add("auto"),o.append(t.ref)}return t.ref=o,o}function T(t){if(0==t.nodes.length)return;const e=a.element("g",{},"group");if(t.layoutBounds&&t.layoutTitleBounds){const n=t.layoutBounds,o=t.layoutTitleBounds,i=a.rect(n.width,n.height,n.x,n.y);(0,s.AV)(i,s.M5.groupRect),t.style.stroke&&i.setAttribute("stroke",t.style.stroke),t.style.background&&i.setAttribute("fill",t.style.background);const r=a.text(t.name,{x:o.x,y:o.y,"dominant-baseline":"hanging"});return(0,s.AV)(r,s.M5.groupText),t.style.color&&r.setAttribute("fill",t.style.color),e.append(i,r),void(t.ref=e)}let n={x:1e100,y:1e100},o={x:0,y:0};t.nodes.forEach(t=>{const e=t.style?.shape?.toLowerCase()||"box";let i=t.height/2,r=t.height/2;if("robot"===e){const e=.12*t.height;i=t.height/2+e,r=t.height/2}else if("hexagon"===e){const e=t.width/2*.866;i=e,r=e}const s={x:t.x-t.width/2,y:t.y-i,width:t.width,height:i+r};n.x=Math.min(n.x,s.x),n.y=Math.min(n.y,s.y),o.x=Math.max(o.x,s.x+s.width),o.y=Math.max(o.y,s.y+s.height)});const i=Math.max(o.x-n.x,200),r=o.y-n.y,d={x:n.x-25,y:n.y-25,width:i+50,height:r+50+30},l=a.rect(d.width,d.height,d.x,d.y);t.x=d.x+d.width/2,t.y=d.y+d.height/2,t.width=d.width,t.height=d.height,(0,s.AV)(l,s.M5.groupRect),t.style.stroke&&l.setAttribute("stroke",t.style.stroke),t.style.background&&l.setAttribute("fill",t.style.background);const c=a.text(t.name,{x:n.x,y:d.y+d.height-s.M5.groupText["font-size"]});(0,s.AV)(c,s.M5.groupText),t.style.color&&c.setAttribute("fill",t.style.color),e.append(l,c),t.ref=e}function F(t,e){let n={dst:Number.POSITIVE_INFINITY,pos:-1,edge:null,prj:null};return t.edges.forEach(t=>{const o=t.vertices||[],i=[t.from,...o,t.to];for(let o=1;o50||s3||Math.abs(d)>3)&&(u=!0,h=null,c)){const t=e.getSelection();t.length=0,t.push(c.node),e.setSelection(t),i=[{x:c.node.x,y:c.node.y,n:c.node}],c=null}if(s)!function(e,n){const i=o.querySelector("g.zoom");if(!i)return;const r=P(t);i.setAttribute("transform",`translate(${e}, ${n}) scale(${r})`)}(l.x+a,l.y+d);else if(i.length>0&&u){const t=e.getZoom(),n=a/t,o=d/t;i.forEach(t=>{e.moveNode(t.n,t.x+n,t.y+o)}),e.setDragging(!0)}else r&&(r.update(n),e.setDragging(!0))}(n=m(n),n.clientX-p.ex,n.clientY-p.ey)}function y(n){document.removeEventListener("touchmove",b),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",y),document.removeEventListener("touchend",y),function(n){e.setDragging(!1);const o=u?null:h;if(u&&(A=!0,window.setTimeout(()=>{A=!1},0)),c&&!u){const t=e.getSelection();t.length=0,t.push(c.node),e.setSelection(t)}if(r){const t=r.end();t?e.boxSelection(t,n.shiftKey):i.length||e.setSelection([]),r=null}s&&u&&O(t),c=null,h=null,u=!1,s=!1,e.updatePanning(),o&&(window.location.href=o)}(m(n)),p=null}function x(A){A=m(A),p={ex:A.clientX,ey:A.clientY},function(A){A.preventDefault(),u=!1,c=null;const g=A.target,f=g instanceof Element?g.closest("a.nodeLink"):null;h=A.shiftKey?null:f?.getAttribute("href")||null;const p=e.nodeFromEvent(A),m=A.shiftKey?"pan"===n?"select":"pan":n;if(p)if("pan"===m){s=!1,r=null;const t=e.getSelection();e.isSelected(p)?i=t.map(t=>({x:t.x,y:t.y,n:t})):(e.setSelection([p]),i=[{x:p.x,y:p.y,n:p}])}else{s=!1,r=null;const t=e.getSelection();if(A.shiftKey&&"select"===n){if(e.isSelected(p)){const e=t.findIndex(t=>t.id===p.id);e>=0&&t.splice(e,1)}else t.push(p);e.setSelection(t),i=t.map(t=>({x:t.x,y:t.y,n:t}))}else e.isSelected(p)?(i=t.map(t=>({x:t.x,y:t.y,n:t})),c=null):(c={node:p,shiftKey:A.shiftKey},i=[{x:p.x,y:p.y,n:p}])}else"pan"===m?(s=!0,r=null,a=A.clientX,d=A.clientY,l=function(){const t=o.querySelector("g.zoom");if(!t)return{x:0,y:0};const e=(t.getAttribute("transform")||"").match(/translate\(([^,]+),([^)]+)\)/);return e?{x:parseFloat(e[1])||0,y:parseFloat(e[2])||0}:{x:0,y:0}}(),i=[],e.setSelection([])):(s=!1,r=function(){let e=0,n=0,i=null;return{ini(r){const s=N(t,r);e=s.x,n=s.y,i=document.createElementNS("http://www.w3.org/2000/svg","rect"),i.setAttribute("fill","rgba(0, 100, 255, 0.1)"),i.setAttribute("stroke","rgba(0, 100, 255, 0.5)"),i.setAttribute("stroke-width","1"),i.setAttribute("stroke-dasharray","3,3"),i.setAttribute("x",String(e)),i.setAttribute("y",String(n)),i.setAttribute("width","0"),i.setAttribute("height","0");const a=o.querySelector("g.zoom");a?a.appendChild(i):o.appendChild(i)},update(o){if(!i)return;const r=N(t,o),s=r.x,a=r.y,d=Math.min(e,s),l=Math.min(n,a),c=Math.abs(s-e),h=Math.abs(a-n);i.setAttribute("x",String(d)),i.setAttribute("y",String(l)),i.setAttribute("width",String(c)),i.setAttribute("height",String(h))},end(){if(!i)return null;const t=parseFloat(i.getAttribute("x")||"0"),e=parseFloat(i.getAttribute("y")||"0"),n=parseFloat(i.getAttribute("width")||"0"),o=parseFloat(i.getAttribute("height")||"0");return i.remove(),i=null,n>5&&o>5?{x:t,y:e,width:n,height:o,left:t,top:e,right:t+n,bottom:e+o}:null}}}(),r&&r.ini(A),i=[])}(A),document.addEventListener("touchmove",b),document.addEventListener("mousemove",b),document.addEventListener("mouseup",y),document.addEventListener("touchend",y)}f.addEventListener("mousedown",x),f.addEventListener("touchstart",x),g.push({element:f,event:"mousedown",handler:x},{element:f,event:"touchstart",handler:x})}(o),o.addEventListener("click",f),g.push({element:o,event:"click",handler:f}),()=>{g.forEach(({element:t,event:e,handler:n})=>{t.removeEventListener(e,n)})}}function j(t,e){const n=t.svg,o=n.__cursorInteractionCleanup;o&&o();const i=[],r=e=>{t.changed()&&(e.preventDefault(),e.returnValue="")};function s(e,o){e.selected=o;const i=n.querySelector("#"+t.idPrefix+e.id);e.selected?i.classList.add("selected"):i.classList.remove("selected")}window.addEventListener("beforeunload",r),i.push({element:window,event:"beforeunload",handler:r});const d=e=>{if(!e.altKey)return;const o=F(t,N(t,e));if(o){const{prj:e}=o,i=n.querySelector("g.edges");let r=i.querySelector(`#${t.idPrefix}prj`);r||(r=a.element("circle",{id:`${t.idPrefix}prj`,cx:e.x,cy:e.y,r:7}),i.append(r)),r.setAttribute("cx",String(e.x)),r.setAttribute("cy",String(e.y))}else h()};n.addEventListener("mousemove",d),i.push({element:n,event:"mousemove",handler:d});const c=t=>{const e=(0,B.Yp)(t,!0);e!=B.Zj&&e!=B._s&&h()};function h(){const e=n.querySelector(`g.edges #${t.idPrefix}prj`);e&&e.parentElement.removeChild(e)}window.addEventListener("keyup",c),i.push({element:window,event:"keyup",handler:c});const u=e=>{const n=(0,B.Yp)(e,!0);if(n!=B._s&&n!=B.Zj)return;const o=F(t,N(t,e));if(o){const{edge:e,pos:i,prj:r}=o;t.insertEdgeVertex(e,r,i,n==B._s),h()}};n.addEventListener("click",u),i.push({element:n,event:"click",handler:u});const A=e=>{const o=.1*Math.sign(e.deltaY),i=P(t),r=Math.max(.1,Math.min(5,i-o));if(r!==i){const o=n.getBoundingClientRect(),i=e.clientX-o.left,s=e.clientY-o.top;R(t,r,i,s),e.preventDefault(),O(t)}};n.addEventListener("wheel",A),i.push({element:n,event:"wheel",handler:A});const g=e=>{const n=(0,B.Yp)(e);switch(n&&e.preventDefault(),n){case B.bl:Array.from(t.edgeVertices.values()).filter(t=>t.selected).forEach(e=>{t.deleteEdgeVertex(e)});break;case"undo":t.undo();break;case"redo":t.redo();break;case B.Ur:const e=Math.min(5,1.2*P(t));R(t,e),O(t);break;case B.hU:const n=Math.max(.1,P(t)/1.2);R(t,n),O(t);break;case B.i1:R(t,1),O(t);break;case B.mD:t.fitToView();break;case B.F:t.nodes().forEach(e=>t.setNodeSelected(e,!0)),t.edgeVertices.forEach(t=>s(t,!0));break;case B.Gn:t.nodes().forEach(e=>t.setNodeSelected(e,!1)),t.edgeVertices.forEach(t=>s(t,!1))}};window.addEventListener("keydown",g),i.push({element:window,event:"keydown",handler:g});const f=q(t,{nodeFromEvent(e){e.preventDefault();let n=e.target.closest("g.nodes g.node");return n?function(t){return t.__data}(n):(n=e.target.closest("g.edges g.edge .v-dot"),n?t.edgeVertices.get(n.id.slice(t.idPrefix.length)):null)},setSelection(e){t.nodes().forEach(n=>t.setNodeSelected(n,e.some(t=>t.id==n.id))),t.edgeVertices.forEach(t=>s(t,e.some(e=>e.id==t.id))),t.selectListener(t.nodes().find(t=>t.selected))},setDragging(e){t.dragging=e},isSelected:t=>t.selected,getSelection(){const e=t.nodes().filter(t=>t.selected);return t.edgeVertices.forEach(t=>t.selected&&e.push(t)),e},getZoom:()=>P(t),moveNode(e,n,o){t.nodesMap.has(e.id)?t.moveNode(e,n,o):(e.auto=!1,t.moveEdgeVertex(e,n,o))},boxSelection(e,n){t.nodesMap.forEach(o=>{var i,r,s;(i={x:(s=o).x-s.width/2,y:s.y-s.height/2,width:s.width,height:s.height}).x<(r=e).x+r.width&&i.yr.x&&i.y+i.height>r.y?t.setNodeSelected(o,!o.selected):n||t.setNodeSelected(o,!1)}),t.edgeVertices.forEach(t=>{l(t,e,!1)?s(t,!t.selected):n||s(t,!1)}),t.selectListener(t.nodes().find(t=>t.selected))},updatePanning:()=>U(t)},e);n.__cursorInteractionCleanup=()=>{i.forEach(({element:t,event:e,handler:n})=>{t.removeEventListener(e,n)}),f&&f()}}function P(t){const e=t.svg.querySelector("g.zoom");if(!e)return 1;const n=(e.getAttribute("transform")||"").match(/scale\(([^)]+)\)/);return n&&parseFloat(n[1])||1}function R(t,e,n,o){const i=t.svg,r=i.querySelector("g.zoom"),s=P(t);if(void 0===n||void 0===o){const t=i.parentElement;t?(n=t.clientWidth/2,o=t.clientHeight/2):(n=i.clientWidth/2,o=i.clientHeight/2)}const a=W(t),d=n-(n-a.x)/s*e,l=o-(o-a.y)/s*e;r.setAttribute("transform",`translate(${d}, ${l}) scale(${e})`),U(t)}function W(t){const e=t.svg.querySelector("g.zoom");if(!e)return{x:0,y:0};const n=(e.getAttribute("transform")||"").match(/translate\(([^,]+),([^)]+)\)/);return n?{x:parseFloat(n[1])||0,y:parseFloat(n[2])||0}:{x:0,y:0}}function U(t){const e=t.svg,n=e.querySelector("g.zoom");if(!n)return;const o=n.getBBox(),i=P(t);if(!e.parentElement)return;const r=Math.max(e.parentElement.clientWidth/i,o.x+o.width+20),s=Math.max(e.parentElement.clientHeight/i,o.y+o.height+20);e.setAttribute("width",String(r*i)),e.setAttribute("height",String(s*i))}const G=(t,e)=>{"Dashed"==e?t.setAttribute("stroke-dasharray","4"):"Dotted"==e&&t.setAttribute("stroke-dasharray","2")},Y=new Map;function O(t){const e=P(t),n=W(t),o={zoom:e,transform:{x:n.x,y:n.y}};Y.set(t.id,o)}function H(t){if(!Y.has(t.id))return!1;const e=Y.get(t.id);if(!e)return!1;const n=t.svg.querySelector("g.zoom");return n&&(n.setAttribute("transform",`scale(${e.zoom}) translate(${e.transform.x}, ${e.transform.y})`),U(t)),!0}function Z(t){Y.delete(t.id)}},983(t,e,n){n.d(e,{k:()=>x,U:()=>w});var o=n(20);const i={direction:"DOWN",nodeSpacing:80,layerSpacing:80};async function r(t,e={}){const o=function(t,e){const n=new Map(t.nodes.map(t=>[t.id,t])),o=new Map(t.groups.map(t=>[t.id,t]));!function(t,e,n){for(const e of t.nodes)if(e.parentId&&!n.has(e.parentId))throw new Error(`node ${e.id} has missing parent group ${e.parentId}`);for(const e of t.groups)if(e.parentId&&!n.has(e.parentId))throw new Error(`group ${e.id} has missing parent group ${e.parentId}`);for(const n of t.edges)if(!e.has(n.sourceId)||!e.has(n.targetId))throw new Error(`edge ${n.id} connects missing node ${n.sourceId} or ${n.targetId}`)}(t,n,o);const i=new Map;for(const e of t.nodes)b(i,e.parentId,e);const r=new Map;for(const e of t.groups)b(r,e.parentId,e);const h=new Map,u=t=>{const n={id:t.id,children:[...(r.get(t.id)??[]).map(u),...(i.get(t.id)??[]).map(s)],edges:[],labels:[{text:t.id,width:t.titleSize.width,height:t.titleSize.height}],layoutOptions:l(e,t.titleSize.height)};return h.set(t.id,n),n},A={id:t.id,children:[...(r.get(void 0)??[]).map(u),...(i.get(void 0)??[]).map(s)],edges:[],layoutOptions:d(e)};for(const e of t.edges){const t=c(e,n,o),i=t?h.get(t):A;if(!i)throw new Error(`edge ${e.id} has missing layout group ${t}`);i.edges?.push(a(e))}return A}(t,{...i,...e}),r=new(await n.e(726).then(n.t.bind(n,862,23)).then(t=>t.default));return function(t,e){if(void 0===e.width||void 0===e.height)throw new Error(`ELK did not size diagram ${t.id}`);const n=[],o=[],i=[];return u(e,0,0,new Map(t.nodes.map(t=>[t.id,t])),new Map(t.groups.map(t=>[t.id,t])),n,o,i),{diagramId:t.id,bounds:{x:0,y:0,width:e.width,height:e.height},nodes:n,groups:o,edges:i}}(t,await r.layout(o))}function s(t){return{id:t.id,width:t.size.width,height:t.size.height,layoutOptions:{"elk.nodeSize.constraints":"FIXED_SIZE","elk.portConstraints":"FREE"}}}function a(t){return{id:t.id,sources:[t.sourceId],targets:[t.targetId],labels:t.labelSize?[{text:t.id,width:t.labelSize.width,height:t.labelSize.height,layoutOptions:{"elk.edgeLabels.inline":"false","elk.edgeLabels.placement":"CENTER"}}]:[]}}function d(t){return{"elk.algorithm":"layered","elk.direction":t.direction,"elk.edgeRouting":"ORTHOGONAL","elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.padding":"[top=40,left=40,bottom=40,right=40]","elk.spacing.nodeNode":String(t.nodeSpacing),"elk.spacing.componentComponent":String(t.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(t.layerSpacing),"elk.layered.spacing.edgeNodeBetweenLayers":"30","elk.layered.spacing.edgeEdgeBetweenLayers":"20","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.nodePlacement.favorStraightEdges":"true","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.unnecessaryBendpoints":"true","elk.edgeLabels.inline":"false","elk.edgeLabels.avoidOverlap":"true","elk.layered.edgeLabels.sideSelection":"SMART_DOWN","elk.spacing.edgeLabel":"12"}}function l(t,e){return{...d(t),"elk.padding":`[top=${e+30},left=30,bottom=30,right=30]`,"elk.nodeLabels.placement":"[H_LEFT,V_TOP,INSIDE]","elk.spacing.labelNode":"10"}}function c(t,e,n){const o=h(e.get(t.sourceId)?.parentId,n),i=new Set(h(e.get(t.targetId)?.parentId,n));return o.find(t=>i.has(t))}function h(t,e){const n=[];let o=t;for(;o;)n.push(o),o=e.get(o)?.parentId;return n}function u(t,e,n,o,i,r,s,a){const d=e+(t.x??0),l=n+(t.y??0);for(const e of t.children??[]){const t=d+f(e.x,e.id,"x"),n=l+f(e.y,e.id,"y"),c=f(e.width,e.id,"width"),h=f(e.height,e.id,"height"),A=o.get(e.id);if(A){r.push({id:e.id,parentId:A.parentId,bounds:{x:t,y:n,width:c,height:h}});continue}const g=i.get(e.id);if(!g)throw new Error(`ELK returned unknown node ${e.id}`);const p=m(e.labels?.[0],e.id);s.push({id:e.id,parentId:g.parentId,bounds:{x:t,y:n,width:c,height:h},titleBounds:{x:t+f(p.x,e.id,"title x"),y:n+f(p.y,e.id,"title y"),width:f(p.width,e.id,"title width"),height:f(p.height,e.id,"title height")}}),u(e,d,l,o,i,r,s,a)}for(const e of t.edges??[])a.push(A(e,d,l))}function A(t,e,n){const o=(t.sections??[]).map(t=>[g(t.startPoint,e,n),...(t.bendPoints??[]).map(t=>g(t,e,n)),g(t.endPoint,e,n)]),i=t.labels?.[0];return{id:t.id,sourceId:p(t.sources,t.id,"source"),targetId:p(t.targets,t.id,"target"),sections:o,labelBounds:i?{x:e+f(i.x,t.id,"label x"),y:n+f(i.y,t.id,"label y"),width:f(i.width,t.id,"label width"),height:f(i.height,t.id,"label height")}:void 0}}function g(t,e,n){return{x:e+t.x,y:n+t.y}}function f(t,e,n){if(void 0===t)throw new Error(`ELK omitted ${n} for ${e}`);return t}function p(t,e,n){if(1!==t.length)throw new Error(`ELK returned ${t.length} ${n}s for edge ${e}`);return t[0]}function m(t,e){if(!t)throw new Error(`ELK omitted title for group ${e}`);return t}function b(t,e,n){const o=t.get(e)??[];o.push(n),t.set(e,o)}n(108);var y=n(977);async function x(t,e={}){await document.fonts.ready;const n=C(t),i=e.compactLayout?56:80,s=await r(n,{direction:e.direction??t.layoutDirection??"DOWN",nodeSpacing:e.nodeSpacing??i,layerSpacing:e.layerSpacing??i}),a=(0,o.r)(n,s),d=new Map(n.nodes.map(t=>[t.id,t]));return{validated:a,nodes:a.nodes.map(t=>{const e=d.get(t.id);if(!e)throw new Error(`validated layout contains unknown node ${t.id}`);return{id:t.id,x:t.bounds.x+e.centerOffset.x,y:t.bounds.y+e.centerOffset.y}}),groups:a.groups.map(t=>({id:t.id,bounds:t.bounds,titleBounds:t.titleBounds})),edges:a.edges.map(t=>({id:t.id,sections:t.sections,labelBounds:t.labelBounds}))}}function w(t){const e=C(t),n=new Map(e.nodes.map(t=>[t.id,t])),i=t.nodes().map(t=>{const e=n.get(t.id);if(!e)throw new Error(`measured diagram omitted node ${t.id}`);return{id:t.id,parentId:e.parentId,bounds:{x:t.x-e.centerOffset.x,y:t.y-e.centerOffset.y,...e.size}}}),r=Array.from(t.groupsMap.values()).map(t=>{if(!t.ref?.isConnected)throw new Error(`group ${t.id} must be drawn before saving`);const n=t.ref.querySelector("rect"),o=t.ref.querySelector("text");if(!(n instanceof SVGGraphicsElement&&o instanceof SVGGraphicsElement))throw new Error(`group ${t.id} is missing its boundary or title`);return{id:t.id,parentId:e.groups.find(e=>e.id===t.id)?.parentId,bounds:k(n.getBBox()),titleBounds:k(o.getBBox())}}),s=t.edges.map(t=>{const e=t.layoutSections??[(0,y.l)(t)],n=t.layoutLabelBounds??t.labelBounds;if(t.label.trim().length>0&&!n)throw new Error(`edge ${t.id} is missing its label position`);return{id:t.id,sourceId:t.from.id,targetId:t.to.id,sections:e,labelBounds:n?{...n}:void 0}}),a={diagramId:t.id,bounds:I(i.map(t=>t.bounds),r,s),nodes:i,groups:r,edges:s};return function(t,e){return(0,o.r)(t,e)}(e,a)}function C(t){const{nodeParents:e,groupParents:n}=function(t){const e=new Map,n=new Map;for(const o of t.groupsMap.values())for(const t of o.nodes){const i=E(t)?n:e,r=i.get(t.id);if(r&&r!==o.id)throw new Error(`${E(t)?"group":"node"} ${t.id} belongs to both ${r} and ${o.id}`);i.set(t.id,o.id)}return{nodeParents:e,groupParents:n}}(t);return{id:t.id,nodes:t.nodes().map(t=>function(t,e){if(!t.ref?.isConnected)throw new Error(`node ${t.id} must be drawn before layout`);const n=t.ref.getBBox();return v(t.id,n),{id:t.id,parentId:e,size:{width:n.width,height:n.height},contentSize:{width:n.width,height:n.height},centerOffset:{x:-n.x,y:-n.y},shape:t.style.shape??"Box"}}(t,e.get(t.id))),groups:Array.from(t.groupsMap.values()).map(t=>function(t,e){if(!t.ref?.isConnected)throw new Error(`group ${t.id} must be drawn before layout`);const n=t.ref.querySelector("text");if(!(n instanceof SVGGraphicsElement))throw new Error(`group ${t.id} is missing its drawn title`);const o=n.getBBox();return v(t.id,o),{id:t.id,parentId:e,titleSize:{width:o.width,height:o.height}}}(t,n.get(t.id))),edges:t.edges.map(B)}}function B(t){const e=t.label.trim().length>0;if(e&&!t.labelBounds)throw new Error(`edge ${t.id} must be drawn before layout`);return{id:t.id,sourceId:t.from.id,targetId:t.to.id,labelSize:e?{width:t.labelBounds?.width??0,height:t.labelBounds?.height??0}:void 0}}function v(t,e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0)throw new Error(`browser returned invalid measured box for ${t}`)}function I(t,e,n){const o=[...t,...e.flatMap(t=>[t.bounds,t.titleBounds]),...n.flatMap(t=>t.labelBounds?[t.labelBounds]:[])],i=n.flatMap(t=>t.sections.flat());if(0===o.length&&0===i.length)return{x:0,y:0,width:0,height:0};const r=Math.min(...o.map(t=>t.x),...i.map(t=>t.x)),s=Math.min(...o.map(t=>t.y),...i.map(t=>t.y));return{x:r,y:s,width:Math.max(...o.map(t=>t.x+t.width),...i.map(t=>t.x))-r,height:Math.max(...o.map(t=>t.y+t.height),...i.map(t=>t.y))-s}}function k(t){return{x:t.x,y:t.y,width:t.width,height:t.height}}function E(t){return"nodes"in t}},718(t,e,n){n.d(e,{Mt:()=>r,U2:()=>a});const o=new Map;let i;async function r(){await Promise.all([400,600,700].map(t=>document.fonts.load(`${t} 22px Inter`))),await document.fonts.ready}function s(t,e){const n=function(t,e){const n=Object.entries(e).sort(([t],[e])=>t.localeCompare(e));return JSON.stringify([t,n])}(t,e),r=o.get(n);if(r)return r;const s=document.createElementNS("http://www.w3.org/2000/svg","text");s.setAttribute("x","0"),s.setAttribute("y","0");for(const[t,n]of Object.entries(e))s.setAttribute(t,n);s.textContent=t,(i?.isConnected||(i=document.createElementNS("http://www.w3.org/2000/svg","svg"),i.setAttribute("aria-hidden","true"),i.style.position="absolute",i.style.visibility="hidden",i.style.pointerEvents="none",document.body.appendChild(i)),i).appendChild(s);const a=s.getBBox();s.remove();const d={width:a.width,height:a.height};return o.set(n,d),d}function a(t,e,n){let o=0;return{lines:t.trim().split("\n").flatMap(t=>{const i=[];let r=[];for(const a of t.trim().split(/\s+/)){if(s(a,n).width>e){r.length>0&&(i.push(r.join(" ")),r=[]);const t=d(a,e,n);for(const e of t.slice(0,-1))i.push(e),o=Math.max(o,s(e,n).width);r=t.slice(-1);continue}const t=[...r,a],l=s(t.join(" "),n);l.width>e&&r.length>0?(i.push(r.join(" ")),r=[a]):(o=Math.max(o,l.width),r=t)}if(r.length>0){const t=r.join(" ");i.push(t),o=Math.max(o,s(t,n).width)}return i}),maxW:o}}function d(t,e,n){const o=[];let i="";for(const r of t){const t=i+r;s(t,n).width>e&&i.length>0?(o.push(i),i=r):i=t}return i.length>0&&o.push(i),o}},71(t,e,n){var o=n(108);const i={TopBottom:"DOWN",BottomTop:"UP",LeftRight:"RIGHT",RightLeft:"LEFT"};n.d(e,["B",0,t=>{const e=[];return Object.keys(t.views).filter(t=>t.endsWith("Views")).forEach(n=>{t.views[n].forEach(t=>{e.push({key:t.key,title:t.title||t.key,section:n})})}),e},"R",0,(t,e,n)=>{const r=new Map,s=new Map,a=t=>{Array.isArray(t.relationships)&&t.relationships.forEach(t=>{s.set(t.id,t)})};if(t.model.people&&t.model.people.forEach(t=>{r.set(t.id,t),Array.isArray(t.relationships)&&t.relationships.forEach(t=>{s.set(t.id,t)})}),t.model.softwareSystems&&t.model.softwareSystems.forEach(t=>{r.set(t.id,t),a(t),Array.isArray(t.containers)&&t.containers.forEach(e=>{e.parent=t,r.set(e.id,e),a(e),Array.isArray(e.components)&&e.components.forEach(t=>{t.parent=e,r.set(t.id,t),a(t)})})}),t.model.deploymentNodes){const e=t=>{t.containerInstances&&t.containerInstances.forEach(e=>{const n={...r.get(e.containerId),id:e.id};r.set(n.id,n),n.parent=t,a(e)})},n=(t,o)=>{t.parent=o,r.set(t.id,t),a(t),e(t),t.children&&t.children.forEach(e=>n(e,t)),t.infrastructureNodes&&t.infrastructureNodes.forEach(e=>n(e,t))};t.model.deploymentNodes.forEach(t=>n(t,null))}const{view:d,section:l}=function(t,e){let n=null,o="";return Object.keys(t.views).filter(t=>t.endsWith("Views")).some(i=>t.views[i].some(t=>{if(t.key==e)return n=t,o=i,!0})),{view:n,section:o}}(t,n);if(!d)return null;const c=new o.jg(d.key,d.title||d.key),h=d.automaticLayout?.rankDirection;c.layoutDirection=h?i[h]:void 0;const u={name:c.name,description:d.description,version:t.version,elements:[]};if(c.metadata=u,!d.elements)return c;const A={};if("deploymentViews"==l||"containerViews"==l)d.elements.forEach(t=>{const e=r.get(t.id);e?.parent&&(A[e.parent.id]=!0)});else if("componentViews"===l)d.elements.forEach(t=>{const e=r.get(t.id)?.parent;e?.components&&(e.id===d.containerId||d.externalContainersBoundariesVisible)&&(d.elements.some(t=>t.id===e.id)||(A[e.id]=!0))});else if(d.softwareSystemId)d.elements.find(t=>t.id==d.softwareSystemId)||(A[d.softwareSystemId]=!0);else if("systemLandscapeViews"==l){const e={id:"__enterprise__",...t.model.enterprise};r.set(e.id,e),t.model.people&&t.model.people.filter(t=>"External"!=t.location).forEach(t=>t.parent=e),t.model.softwareSystems&&t.model.softwareSystems.filter(t=>"External"!=t.location).forEach(t=>t.parent=e),A[e.id]=!0}const g=t.views.styles,f=t=>t.toLowerCase().replace(/[^a-z0-9-]/g,"-");g?.elements&&g.elements.forEach(t=>{if(t.tag){const e=`--mdl-${f(t.tag)}`;t.background&&c.colorToVarMap.set(t.background,`${e}-bg`),t.color&&c.colorToVarMap.set(t.color,`${e}-color`),t.stroke&&c.colorToVarMap.set(t.stroke,`${e}-stroke`)}}),g?.relationships&&g.relationships.forEach(t=>{if(t.tag){const e=`--mdl-rel-${f(t.tag)}`;t.color&&c.colorToVarMap.set(t.color,`${e}-color`)}}),d.elements.forEach(e=>{if(A[e.id])return;const n=r.get(e.id),o=n?function(t,e){const n=t.views.containerViews?.find(t=>t.softwareSystemId==e);return n?.key}(t,n.id):void 0;let i="",s={};if(n){const t=n.tags.split(",");i=t[t.length-1],n.technology&&(i+=": "+n.technology),t.forEach(t=>{const e=g&&g.elements&&g.elements.find(e=>e.tag==t);e&&(s={...s,...e})})}c.addNode(e.id,n&&n.name||e.id,i,n&&n.description?n.description:"",s,function(t,e){if(e){const t=encodeURIComponent(e);return{href:`?id=${t}`,exportHref:`${t}.svg`}}if(t?.url)return{href:t.url,exportHref:t.url}}(n,o)),n&&u.elements.push({id:n.id,tags:n.tags,location:n.location,properties:n.properties,elementViewKey:o,technology:n.technology,url:n.url})}),Array.isArray(d.relationships)&&d.relationships.forEach(t=>{const e=s.get(t.id);if(!e)return;if(!c.nodesMap.has(e.sourceId)){if(r.has(e.sourceId)){const t=r.get(e.sourceId);console.warn("Element not found in this view: ",t.id,t.name)}else console.warn("Element not found: ",e.sourceId);return}if(!c.nodesMap.has(e.destinationId)){if(r.has(e.destinationId)){const t=r.get(e.destinationId);console.warn("Element not found in this view: ",t.id,t.name)}else console.warn("Element not found: ",e.destinationId);return}let n={};e.tags.split(",").forEach(t=>{const e=g&&g.relationships&&g.relationships.find(e=>e.tag==t);e&&(n={...n,...e})}),t.routing&&(n.routing=t.routing);const o=e.technology?`${e.description}\n[${e.technology}]`:e.description;c.addEdge(e.id,e.sourceId,e.destinationId,o,t.vertices,n)});const p=t=>{let e=0;for(let n=t.parent;n;n=n.parent)e++;return e};return Object.keys(A).map(t=>r.get(t)).sort((t,e)=>p(t)>p(e)?-1:1).forEach(t=>{let e={};"deploymentViews"==l&&r.get(t.id).tags.split(",").forEach(t=>{const n=g&&g.elements&&g.elements.find(e=>e.tag==t);n&&(e={...e,...n})});const n=d.elements.map(t=>r.get(t.id)).filter(e=>!(!e||e.parent!==t||"systemLandscapeViews"===l&&"__enterprise__"===t.id&&"External"===e.location)).map(t=>t.id);n.length>0&&c.addGroup(t.id,t.name,n,e)}),c.init(e[c.id]),c}])},264(t,e,n){n(763);var o=n(686),i=n(987);const r="add-vertex",s="add-label-vertex",a="del-vertex",d="zoom-in",l="zoom-out",c="zoom-fit",h="zoom-100",u="select-all",A="deselect",g="move-left",f="move-right",p="move-up",m="move-down",b="move-left-fine",y="move-right-fine",x="move-up-fine",w="move-down-fine",C="toggle_drag_mode",B="align_horizontal",v="align_vertical",I="distribute_horizontal",k="distribute_vertical",E="auto_layout",S="reset_position",$="toggle_grid",M="toggle_snap_to_grid",L="snap_all_to_grid",_=[{name:"Help",list:[{id:"help",help:"Show/hide this help",combinations:[{key:"?",shift:!0},{key:"F1",shift:!0}]}]},{name:"File",list:[{id:"save",help:"Save",combinations:[{key:"s",ctrl:!0}]}]},{name:"History",list:[{id:"undo",help:"Undo",combinations:[{ctrl:!0,key:"z"}]},{id:"redo",help:"Redo",combinations:[{ctrl:!0,shift:!0,key:"z"},{ctrl:!0,key:"y"}]}]},{name:"Relationship editing",list:[{id:r,help:"Add relationship vertex",combinations:[{alt:!0,click:!0}]},{id:s,help:"Add label anchor relationship vertex",combinations:[{alt:!0,shift:!0,click:!0}]},{id:a,help:"Remove relationship vertex",combinations:[{key:"DELETE"},{key:"BACKSPACE"}]}]},{name:"Zoom",list:[{id:d,help:"Zoom in",combinations:[{ctrl:!0,key:"="}]},{id:l,help:"Zoom out",combinations:[{ctrl:!0,key:"-"}]},{id:c,help:"Zoom - fit",combinations:[{ctrl:!0,key:"9"}]},{id:h,help:"Zoom 100%",combinations:[{ctrl:!0,key:"0"}]},{id:"wheel_zoom",help:"Zoom in/out with mouse wheel",combinations:[{wheel:!0}]}]},{name:"Mouse Interactions",list:[{id:"pan-view",help:"Pan view (drag empty space)",combinations:[{click:!0}]},{id:"select-element",help:"Select element",combinations:[{click:!0}]},{id:"multi-select",help:"Add/remove from selection",combinations:[{shift:!0,click:!0}]},{id:"box-select",help:"Box selection (drag empty space)",combinations:[{shift:!0,click:!0}]},{id:"move-elements",help:"Move selected elements",combinations:[{click:!0}]}]},{name:"Select",list:[{id:u,help:"Select All",combinations:[{ctrl:!0,key:"a"}]},{id:A,help:"Deselect",combinations:[{key:"ESC"}]}]},{name:"Move",list:[{id:p,help:"Move up (grid increment)",combinations:[{key:"UP"}]},{id:x,help:"Move up (1 pixel)",combinations:[{key:"UP",shift:!0}]},{id:f,help:"Move right (grid increment)",combinations:[{key:"RIGHT"}]},{id:y,help:"Move right (1 pixel)",combinations:[{key:"RIGHT",shift:!0}]},{id:m,help:"Move down (grid increment)",combinations:[{key:"DOWN"}]},{id:w,help:"Move down (1 pixel)",combinations:[{key:"DOWN",shift:!0}]},{id:g,help:"Move left (grid increment)",combinations:[{key:"LEFT"}]},{id:b,help:"Move left (1 pixel)",combinations:[{key:"LEFT",shift:!0}]}]},{name:"View",list:[{id:C,help:"Toggle between pan and select mode",combinations:[{key:"t"}]},{id:S,help:"Reset position and view",combinations:[{key:"Home",ctrl:!0}]}]},{name:"Alignment",list:[{id:B,help:"Align selected elements horizontally",combinations:[{key:"h",ctrl:!0,shift:!0}]},{id:v,help:"Align selected elements vertically",combinations:[{key:"a",ctrl:!0,shift:!0}]},{id:I,help:"Distribute selected elements horizontally",combinations:[{key:"h",ctrl:!0,alt:!0}]},{id:k,help:"Distribute selected elements vertically",combinations:[{key:"v",ctrl:!0,alt:!0}]}]},{name:"Layout",list:[{id:E,help:"Auto layout all elements",combinations:[{key:"l",ctrl:!0}]}]},{name:"Grid",list:[{id:$,help:"Toggle grid visibility",combinations:[{key:"g",ctrl:!0}]},{id:M,help:"Toggle snap to grid",combinations:[{key:"g",ctrl:!0,shift:!0}]},{id:L,help:"Snap all elements to grid",combinations:[{key:"g",ctrl:!0,alt:!0}]}]}],D=_.reduce((t,e)=>t.concat(e.list),[]).reduce((t,e)=>(t[e.id]=e,t),{}),z=t=>[t.ctrl&&(0,o.sy)().toUpperCase(),t.shift&&"SHIFT",t.alt&&"ALT",t.key&&(t.key.length>1?t.key:`"${t.key.toUpperCase()}"`),t.click&&"CLICK",t.wheel&&"WHEEL"].filter(Boolean).join(" + ");n.d(e,["DE",0,I,"F",0,u,"Gg",0,g,"Gn",0,A,"Hd",0,E,"Help",0,()=>(0,i.jsxs)("div",{className:"popover",children:[(0,i.jsx)("h1",{children:"Shortcuts"}),(0,i.jsx)("table",{children:(0,i.jsx)("tbody",{children:_.map(t=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("tr",{children:(0,i.jsx)("th",{colSpan:2,children:t.name})}),t.list.map(t=>(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{children:t.combinations.map(z).join(", ")}),(0,i.jsx)("td",{children:t.help})]}))]}))})})]}),"J8",0,b,"Jk",0,v,"OE",0,L,"Op",0,$,"Ur",0,d,"Vy",0,k,"Yp",0,(t,e=!1,n=!1)=>{const i=Object.keys(D).filter(i=>((t,e,n,i)=>e.combinations.some(e=>{if(Boolean(e.shift)!=t.shiftKey)return!1;if(e.ctrl&&!(0,o.SA)(t))return!1;if(Boolean(e.alt)!=t.altKey)return!1;if(n)return e.click;if(i)return e.wheel;if(e.key){const n=t;return"DELETE"==e.key?"Delete"==n.key:"BACKSPACE"==e.key?"Backspace"==n.key:"ESC"==e.key?"Escape"==n.key:"UP"==e.key?"ArrowUp"==n.key:"DOWN"==e.key?"ArrowDown"==n.key:"LEFT"==e.key?"ArrowLeft"==n.key:"RIGHT"==e.key?"ArrowRight"==n.key:e.key&&n.key&&e.key.toLowerCase()==n.key.toLowerCase()}return!1}))(t,D[i],e,n));if(0!==i.length)return 1===i.length?i[0]:i.sort((t,e)=>{const n=D[t],o=D[e],i=n.combinations[0],r=o.combinations[0],s=(i.shift?1:0)+(i.ctrl?1:0)+(i.alt?1:0);return(r.shift?1:0)+(r.ctrl?1:0)+(r.alt?1:0)-s})[0]},"Zj",0,r,"_s",0,s,"_t",0,S,"aX",0,C,"b3",0,f,"bl",0,a,"hU",0,l,"hZ",0,M,"i1",0,h,"iD",0,y,"l8",0,x,"mD",0,c,"mt",0,w,"rB",0,m,"t9",0,B,"uK",0,p])},686(t,e,n){const o=()=>{if("undefined"==typeof navigator)return!1;if("userAgentData"in navigator&&navigator.userAgentData){const t=navigator.userAgentData.platform;if(t&&t.toLowerCase().includes("mac"))return!0}const t=navigator.userAgent.toLowerCase();if(t.includes("mac os")||t.includes("macintosh"))return!0;if(navigator.platform){const t=navigator.platform.toLowerCase();if(t.includes("mac")||t.includes("darwin"))return!0}try{if(void 0!==new KeyboardEvent("keydown",{metaKey:!0}).metaKey)return/mac|darwin|os x/i.test(navigator.userAgent)}catch(t){}return!1};n.d(e,["SA",0,t=>o()?t.metaKey:t.ctrlKey,"sy",0,()=>o()?"Cmd":"Ctrl"])},183(t,e,n){var o=n(220),i=n.n(o),r=n(716),s=n.n(r),a=n(247),d=n.n(a),l=new URL(n(390),n.b),c=new URL(n(513),n.b),h=new URL(n(568),n.b),u=new URL(n(483),n.b),A=s()(i()),g=d()(l),f=d()(c),p=d()(h),m=d()(u);A.push([t.id,`/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${g}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${f}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${p}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${m}) format("woff2");\n}\n`,"",{version:3,sources:["webpack://./src/fonts.css"],names:[],mappings:"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF",sourcesContent:['/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url("@fontsource/inter/files/inter-latin-400-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url("@fontsource/inter/files/inter-latin-500-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url("@fontsource/inter/files/inter-latin-600-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url("@fontsource/inter/files/inter-latin-700-normal.woff2") format("woff2");\n}\n'],sourceRoot:""}]);const b=A;n.d(e,["A",0,b])},870(t,e,n){var o=n(220),i=n.n(o),r=n(716),s=n.n(r)()(i());s.push([t.id,"html, body, #root {\n height: 100%;\n}\n\nbody {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n color: #666;\n margin: 0;\n}\n\n#root {\n display: flex;\n flex-direction: column;\n}\n#root > div.graph {\n flex: 1;\n overflow: auto;\n position: relative;\n}\n\n.toolbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 10px;\n background-color: #f0f0f0;\n border-bottom: 1px solid #cccccc;\n}\n\n.toolbar > div {\n display: flex;\n align-items: center;\n}\n\n.toolbar button {\n padding: 5px 8px;\n margin: 0 2px;\n cursor: pointer;\n}\n\n.toolbar button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Drag mode toggle button styles */\n.toolbar button.mode-toggle {\n position: relative;\n border: 1px solid #8f9fc9;\n width: 40px;\n min-height: 28px;\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\n border-color: #8f9fc9;\n color: white;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n}\n\n.toolbar button.mode-toggle:hover {\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\n border-color: #abb8db;\n}\n\n.toolbar button.mode-toggle.select-mode:active {\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\n}\n\n/* Pan mode and active toggle - darker blue */\n.toolbar button.mode-toggle.pan-mode,\n.toolbar button.active-toggle {\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n.toolbar button.mode-toggle.pan-mode:hover,\n.toolbar button.active-toggle:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\n.toolbar button.mode-toggle.pan-mode:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n/* Toggle buttons when inactive - gray styling */\n.toolbar button.inactive-toggle {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n.toolbar button.inactive-toggle:hover {\n background: #b1b1b1;\n}\n\n.toolbar button.inactive-toggle:active {\n background: #a1a1a1;\n}\n\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\n.toolbar button .fas {\n font-size: 1em;\n vertical-align: middle;\n}\n\n/* Zoom percentage display */\n.toolbar button.zoom-display {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n font-size: 11px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\n padding: 6px 8px;\n text-align: center;\n}\n\n.toolbar-group {\n display: flex;\n align-items: center;\n margin-right: 25px; /* Large space between groups */\n}\n\n.toolbar-group:last-child {\n margin-right: 0; /* Remove right margin from the last group (help button) */\n}\n\nbutton {\n border: none;\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n border-radius: 3px;\n padding: 6px 10px;\n color: #fff;\n outline: none;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n margin-right: 5px;\n min-width: 32px;\n min-height: 28px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n line-height: 1;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n position: relative;\n}\n\nbutton:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\nbutton:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n}\n\nbutton:last-child {\n margin-right: 0;\n}\n\n/* Save button when no changes - gray */\nbutton.action {\n background: #c1c1c1;\n color: #999;\n}\n\nbutton.action:active {\n background: #b1b1b1;\n}\n\n/* Save button when there are changes - orange */\nbutton.grp {\n background: linear-gradient(to bottom, #ee9564, #de7d48);\n margin-right: 0;\n}\n\nbutton.grp:active {\n background: #d67540;\n}\n\n/* Auto-arrange button with AI purple to blue gradient */\nbutton.auto-arrange {\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\n border-color: #4a4c93;\n}\n\nbutton.auto-arrange:hover {\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\n border-color: #5a5ca3;\n}\n\nbutton.auto-arrange:active {\n background: linear-gradient(135deg, #593B83, #357abd);\n border-color: #3a3c83;\n}\n\nselect {\n border: 1px solid #ccc;\n background: white;\n border-radius: 3px;\n padding: 3px 7px;\n color: #666;\n outline: none;\n margin-right: 5px;\n font-size: 12px;\n}\n\nselect:disabled {\n background: #f5f5f5;\n color: #999;\n}\n\nbutton:disabled {\n background: #c1c1c1;\n color: #999;\n}\n\n#root > div > svg {\n position: absolute;\n user-select: none;\n}\n\n\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\n stroke: #29c229;\n}\n.edge .v-dot {\n fill: transparent;\n stroke: transparent;\n stroke-width: 3px;\n cursor: pointer;\n transition: stroke 0.15s ease;\n}\n.edge .v-dot:hover {\n stroke: #999;\n fill: rgba(153, 153, 153, 0.1);\n}\n.edge .v-dot.selected {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.1);\n}\n.edge .v-dot.selected:hover {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.2);\n}\n.edge .v-dot.auto.selected {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.1);\n}\n.edge .v-dot.auto.selected:hover {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.2);\n}\ncircle#prj {\n fill: none;\n stroke: #777;\n}\n\n.nodeShadow {\n fill: none;\n stroke-width: 4px;\n stroke: rgba(0, 0, 0, 0.13);\n}\n\ng.node {\n user-select: none;\n cursor: default;\n}\n\ng.node.linked {\n cursor: pointer;\n}\n\ng.node text {\n pointer-events: none;\n}\n\n.icon {\n fill: #aaa;\n stroke: #fff;\n}\n#icon-cube {\n fill: #aaa;\n}\n\n/* Ensure all button icons are uncolored */\nbutton .icon,\nbutton svg,\nbutton path {\n fill: currentColor !important;\n stroke: none !important;\n}\n\n/* Font Awesome icon styling in buttons */\nbutton i {\n font-size: 12px;\n color: inherit;\n}\n\nrect.elastic {\n pointer-events: none;\n stroke: none;\n fill: #3bd8281f;\n display: none;\n}\nrect.elastic.on {\n display: block;\n}\n\n.popover {\n position: absolute;\n top: 50px;\n bottom: 10px;\n overflow: auto;\n right: 10px;\n background: ghostwhite;\n padding: 30px;\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\n border: solid 1px #eee;\n}\n\n.popover th {\n text-align: left;\n padding: 20px 0px 10px;\n}\n.popover td {\n padding-right: 20px;\n font-size: 14px;\n}\n\n/* Simple tooltip system with smart positioning */\n[data-tooltip] {\n position: relative;\n}\n\n[data-tooltip]:hover::after {\n content: attr(data-tooltip);\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(0, 0, 0, 0.9);\n color: white;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 12px !important;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n font-weight: normal !important;\n white-space: nowrap;\n z-index: 1000;\n pointer-events: none;\n margin-top: 5px;\n animation: tooltip-appear 0.1s ease-out;\n min-width: 120px;\n max-width: calc(100vw - 20px);\n box-sizing: border-box;\n}\n\n[data-tooltip]:hover::before {\n content: '';\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-bottom-color: rgba(0, 0, 0, 0.9);\n z-index: 1000;\n pointer-events: none;\n margin-top: 1px;\n animation: tooltip-appear 0.1s ease-out;\n}\n\n/* Special handling for rightmost elements that might overflow */\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 0;\n transform: none;\n}\n\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 16px;\n transform: none;\n}\n\n@keyframes tooltip-appear {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(-5px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\nselect {\n position: relative;\n}\n\n/* Robot shape internal elements - inherit stroke from parent node */\n.node .robot-eye-socket {\n fill: none;\n stroke: inherit;\n stroke-width: 2;\n}\n\n.node .robot-eye {\n fill: currentColor;\n stroke: none;\n}\n\n.node .robot-mouth {\n stroke: inherit;\n}\n\n.node .robot-antenna {\n stroke: inherit;\n}\n\n.node .robot-antenna-ball {\n fill: currentColor;\n stroke: inherit;\n stroke-width: 1.5;\n}\n\n.node .robot-panel {\n stroke: inherit;\n}\n\n.node .robot-indicator {\n fill: currentColor;\n stroke: none;\n}","",{version:3,sources:["webpack://./src/style.css"],names:[],mappings:"AAAA;IACI,YAAY;AAChB;;AAEA;IACI,uFAAuF;IACvF,WAAW;IACX,SAAS;AACb;;AAEA;IACI,aAAa;IACb,sBAAsB;AAC1B;AACA;IACI,OAAO;IACP,cAAc;IACd,kBAAkB;AACtB;;AAEA;IACI,aAAa;IACb,8BAA8B;IAC9B,mBAAmB;IACnB,iBAAiB;IACjB,yBAAyB;IACzB,gCAAgC;AACpC;;AAEA;IACI,aAAa;IACb,mBAAmB;AACvB;;AAEA;IACI,gBAAgB;IAChB,aAAa;IACb,eAAe;AACnB;;AAEA;IACI,YAAY;IACZ,mBAAmB;AACvB;;AAEA,mCAAmC;AACnC;IACI,kBAAkB;IAClB,yBAAyB;IACzB,WAAW;IACX,gBAAgB;IAChB,wDAAwD;IACxD,qBAAqB;IACrB,YAAY;IACZ,yCAAyC;AAC7C;;AAEA;IACI,wDAAwD;IACxD,qBAAqB;AACzB;;AAEA;IACI,wDAAwD;AAC5D;;AAEA,6CAA6C;AAC7C;;IAEI,wDAAwD;IACxD,qBAAqB;IACrB,2CAA2C;AAC/C;;AAEA;;IAEI,wDAAwD;AAC5D;;AAEA;IACI,wDAAwD;IACxD,2CAA2C;AAC/C;;AAEA,gDAAgD;AAChD;IACI,mBAAmB;IACnB,WAAW;IACX,qBAAqB;IACrB,gBAAgB;AACpB;;AAEA;I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IACf,uCAAuC;IACvC,gBAAgB;IAChB,6BAA6B;IAC7B,sBAAsB;AAC1B;;AAEA;IACI,WAAW;IACX,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,2BAA2B;IAC3B,6BAA6B;IAC7B,uCAAuC;IACvC,aAAa;IACb,oBAAoB;IACpB,eAAe;IACf,uCAAuC;AAC3C;;AAEA,gEAAgE;AAChE;IACI,2DAA2D;IAC3D,UAAU;IACV,QAAQ;IACR,eAAe;AACnB;;AAEA;IACI,2DAA2D;IAC3D,UAAU;IACV,WAAW;IACX,eAAe;AACnB;;AAEA;IACI;QACI,UAAU;QACV,4CAA4C;IAChD;IACA;QACI,UAAU;QACV,yCAAyC;IAC7C;AACJ;;AAEA;IACI,kBAAkB;AACtB;;AAEA,oEAAoE;AACpE;IACI,UAAU;IACV,eAAe;IACf,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,YAAY;AAChB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,eAAe;IACf,iBAAiB;AACrB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,YAAY;AAChB",sourcesContent:["html, body, #root {\n height: 100%;\n}\n\nbody {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n color: #666;\n margin: 0;\n}\n\n#root {\n display: flex;\n flex-direction: column;\n}\n#root > div.graph {\n flex: 1;\n overflow: auto;\n position: relative;\n}\n\n.toolbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 10px;\n background-color: #f0f0f0;\n border-bottom: 1px solid #cccccc;\n}\n\n.toolbar > div {\n display: flex;\n align-items: center;\n}\n\n.toolbar button {\n padding: 5px 8px;\n margin: 0 2px;\n cursor: pointer;\n}\n\n.toolbar button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Drag mode toggle button styles */\n.toolbar button.mode-toggle {\n position: relative;\n border: 1px solid #8f9fc9;\n width: 40px;\n min-height: 28px;\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\n border-color: #8f9fc9;\n color: white;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n}\n\n.toolbar button.mode-toggle:hover {\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\n border-color: #abb8db;\n}\n\n.toolbar button.mode-toggle.select-mode:active {\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\n}\n\n/* Pan mode and active toggle - darker blue */\n.toolbar button.mode-toggle.pan-mode,\n.toolbar button.active-toggle {\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n.toolbar button.mode-toggle.pan-mode:hover,\n.toolbar button.active-toggle:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\n.toolbar button.mode-toggle.pan-mode:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n/* Toggle buttons when inactive - gray styling */\n.toolbar button.inactive-toggle {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n.toolbar button.inactive-toggle:hover {\n background: #b1b1b1;\n}\n\n.toolbar button.inactive-toggle:active {\n background: #a1a1a1;\n}\n\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\n.toolbar button .fas {\n font-size: 1em;\n vertical-align: middle;\n}\n\n/* Zoom percentage display */\n.toolbar button.zoom-display {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n font-size: 11px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\n padding: 6px 8px;\n text-align: center;\n}\n\n.toolbar-group {\n display: flex;\n align-items: center;\n margin-right: 25px; /* Large space between groups */\n}\n\n.toolbar-group:last-child {\n margin-right: 0; /* Remove right margin from the last group (help button) */\n}\n\nbutton {\n border: none;\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n border-radius: 3px;\n padding: 6px 10px;\n color: #fff;\n outline: none;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n margin-right: 5px;\n min-width: 32px;\n min-height: 28px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n line-height: 1;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n position: relative;\n}\n\nbutton:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\nbutton:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n}\n\nbutton:last-child {\n margin-right: 0;\n}\n\n/* Save button when no changes - gray */\nbutton.action {\n background: #c1c1c1;\n color: #999;\n}\n\nbutton.action:active {\n background: #b1b1b1;\n}\n\n/* Save button when there are changes - orange */\nbutton.grp {\n background: linear-gradient(to bottom, #ee9564, #de7d48);\n margin-right: 0;\n}\n\nbutton.grp:active {\n background: #d67540;\n}\n\n/* Auto-arrange button with AI purple to blue gradient */\nbutton.auto-arrange {\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\n border-color: #4a4c93;\n}\n\nbutton.auto-arrange:hover {\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\n border-color: #5a5ca3;\n}\n\nbutton.auto-arrange:active {\n background: linear-gradient(135deg, #593B83, #357abd);\n border-color: #3a3c83;\n}\n\nselect {\n border: 1px solid #ccc;\n background: white;\n border-radius: 3px;\n padding: 3px 7px;\n color: #666;\n outline: none;\n margin-right: 5px;\n font-size: 12px;\n}\n\nselect:disabled {\n background: #f5f5f5;\n color: #999;\n}\n\nbutton:disabled {\n background: #c1c1c1;\n color: #999;\n}\n\n#root > div > svg {\n position: absolute;\n user-select: none;\n}\n\n\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\n stroke: #29c229;\n}\n.edge .v-dot {\n fill: transparent;\n stroke: transparent;\n stroke-width: 3px;\n cursor: pointer;\n transition: stroke 0.15s ease;\n}\n.edge .v-dot:hover {\n stroke: #999;\n fill: rgba(153, 153, 153, 0.1);\n}\n.edge .v-dot.selected {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.1);\n}\n.edge .v-dot.selected:hover {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.2);\n}\n.edge .v-dot.auto.selected {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.1);\n}\n.edge .v-dot.auto.selected:hover {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.2);\n}\ncircle#prj {\n fill: none;\n stroke: #777;\n}\n\n.nodeShadow {\n fill: none;\n stroke-width: 4px;\n stroke: rgba(0, 0, 0, 0.13);\n}\n\ng.node {\n user-select: none;\n cursor: default;\n}\n\ng.node.linked {\n cursor: pointer;\n}\n\ng.node text {\n pointer-events: none;\n}\n\n.icon {\n fill: #aaa;\n stroke: #fff;\n}\n#icon-cube {\n fill: #aaa;\n}\n\n/* Ensure all button icons are uncolored */\nbutton .icon,\nbutton svg,\nbutton path {\n fill: currentColor !important;\n stroke: none !important;\n}\n\n/* Font Awesome icon styling in buttons */\nbutton i {\n font-size: 12px;\n color: inherit;\n}\n\nrect.elastic {\n pointer-events: none;\n stroke: none;\n fill: #3bd8281f;\n display: none;\n}\nrect.elastic.on {\n display: block;\n}\n\n.popover {\n position: absolute;\n top: 50px;\n bottom: 10px;\n overflow: auto;\n right: 10px;\n background: ghostwhite;\n padding: 30px;\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\n border: solid 1px #eee;\n}\n\n.popover th {\n text-align: left;\n padding: 20px 0px 10px;\n}\n.popover td {\n padding-right: 20px;\n font-size: 14px;\n}\n\n/* Simple tooltip system with smart positioning */\n[data-tooltip] {\n position: relative;\n}\n\n[data-tooltip]:hover::after {\n content: attr(data-tooltip);\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(0, 0, 0, 0.9);\n color: white;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 12px !important;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n font-weight: normal !important;\n white-space: nowrap;\n z-index: 1000;\n pointer-events: none;\n margin-top: 5px;\n animation: tooltip-appear 0.1s ease-out;\n min-width: 120px;\n max-width: calc(100vw - 20px);\n box-sizing: border-box;\n}\n\n[data-tooltip]:hover::before {\n content: '';\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-bottom-color: rgba(0, 0, 0, 0.9);\n z-index: 1000;\n pointer-events: none;\n margin-top: 1px;\n animation: tooltip-appear 0.1s ease-out;\n}\n\n/* Special handling for rightmost elements that might overflow */\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 0;\n transform: none;\n}\n\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 16px;\n transform: none;\n}\n\n@keyframes tooltip-appear {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(-5px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\nselect {\n position: relative;\n}\n\n/* Robot shape internal elements - inherit stroke from parent node */\n.node .robot-eye-socket {\n fill: none;\n stroke: inherit;\n stroke-width: 2;\n}\n\n.node .robot-eye {\n fill: currentColor;\n stroke: none;\n}\n\n.node .robot-mouth {\n stroke: inherit;\n}\n\n.node .robot-antenna {\n stroke: inherit;\n}\n\n.node .robot-antenna-ball {\n fill: currentColor;\n stroke: inherit;\n stroke-width: 1.5;\n}\n\n.node .robot-panel {\n stroke: inherit;\n}\n\n.node .robot-indicator {\n fill: currentColor;\n stroke: none;\n}"],sourceRoot:""}]);const a=s;n.d(e,["A",0,a])},74(t,e,n){var o=n(220),i=n.n(o),r=n(716),s=n.n(r),a=n(247),d=n.n(a),l=new URL(n(390),n.b),c=new URL(n(513),n.b),h=new URL(n(568),n.b),u=new URL(n(483),n.b),A=s()(i()),g=d()(l),f=d()(c),p=d()(h),m=d()(u);A.push([t.id,`/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${g}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${f}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${p}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${m}) format("woff2");\n}\n`,"",{version:3,sources:["webpack://./src/fonts.css"],names:[],mappings:"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF",sourcesContent:['/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url("@fontsource/inter/files/inter-latin-400-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url("@fontsource/inter/files/inter-latin-500-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url("@fontsource/inter/files/inter-latin-600-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url("@fontsource/inter/files/inter-latin-700-normal.woff2") format("woff2");\n}\n'],sourceRoot:""}]);const b=A.toString();n.d(e,["A",0,b])},574(t,e,n){var o=n(582),i=n.n(o),r=n(991),s=n.n(r),a=n(725),d=n.n(a),l=n(798),c=n.n(l),h=n(754),u=n.n(h),A=n(567),g=n.n(A),f=n(183),p={};p.styleTagTransform=g(),p.setAttributes=c(),p.insert=d().bind(null,"head"),p.domAPI=s(),p.insertStyleElement=u(),i()(f.A,p),f.A&&f.A.locals&&f.A.locals},919(t,e,n){var o=n(582),i=n.n(o),r=n(991),s=n.n(r),a=n(725),d=n.n(a),l=n(798),c=n.n(l),h=n(754),u=n.n(h),A=n(567),g=n.n(A),f=n(870),p={};p.styleTagTransform=g(),p.setAttributes=c(),p.insert=d().bind(null,"head"),p.domAPI=s(),p.insertStyleElement=u(),i()(f.A,p),f.A&&f.A.locals&&f.A.locals}}]); +"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[286],{628(t,e,n){n.d(e,["AV",0,(t,e)=>{Object.entries(e).forEach(([e,n])=>{t.setAttribute(e,String(n))})},"M5",0,{nodeBorder:{"stroke-width":1.5},nodeText:{"font-family":"Inter, -apple-system, BlinkMacSystemFont, sans-serif",stroke:"none"},edgeText:{"font-family":"Inter, -apple-system, BlinkMacSystemFont, sans-serif",stroke:"none"},edgeRect:{fill:"none",stroke:"none"},groupRect:{fill:"none",stroke:"#8492a6","stroke-width":1.5,"stroke-dasharray":"6 4"},groupText:{fill:"#475569","font-size":20,"font-weight":"600","font-family":"Inter, -apple-system, BlinkMacSystemFont, sans-serif",cursor:"default"}},"Y$",0,{thickness:2,color:"#64748b",opacity:1,fontSize:18,width:200,dashed:!0},"gd",0,(t,e)=>Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)),"nD",0,{width:280,height:180,background:"#ffffff",color:"#334155",opacity:1,stroke:"#8492a6",fontSize:22,shape:"Box",metadata:!0,description:!0}])},977(t,e,n){n.d(e,{IW:()=>r,Zr:()=>s,l:()=>i});var o=n(628);function i(t){const e=t.from,n=t.to;let o=t.vertices?t.vertices.concat():[];o.unshift(e),o.push(n);const i=o.slice(1,-1),r=i.find(t=>!t.label)??n;let s=e;for(let t=i.length-1;t>=0;t--)if(!i[t].label){s=i[t];break}if(!e.intersect||!n.intersect)throw new Error(`edge ${t.id} nodes must be drawn before routing`);return o[0]=e.intersect(r),o[o.length-1]=n.intersect(s),o}function r(t,e,n){let i,r={x:n.x,y:n.y};const s=t.findIndex(t=>t.label);let a=!0;if(s>=0){const e=t[s];r=e,a=!0===e.auto;const n=[];s>0&&n.push({p:t[s-1],q:r}),st?(0,o.gd)(e.p,e.q)>(0,o.gd)(t.p,t.q)?e:t:e,void 0)}else{const n=t.slice(1).reduce((e,n,i)=>e+(0,o.gd)(t[i],n),0)*e;let s=0;for(let e=1;e0&&s+d>=n){const t=(n-s)/d;r={x:a.p.x+(a.q.x-a.p.x)*t,y:a.p.y+(a.q.y-a.p.y)*t},i=a;break}s+=d}}const d=i?Math.abs(i.q.x-i.p.x):0,l=i?Math.abs(i.q.y-i.p.y):0;return{...r,orientation:l>d?"vertical":"horizontal",segment:i,movable:a}}function s(t){if(t.length<2)throw new Error("edge route must contain at least two points");return t.slice(1).reduce((t,e)=>`${t} L${e.x},${e.y}`,`M${t[0].x},${t[0].y}`)}},20(t,e,n){n.d(e,{r:()=>i}),Symbol("ValidatedLayout");class o extends Error{issues;constructor(t){super(t.map(t=>t.message).join("\n")),this.name="GeometryValidationError",this.issues=t}}function i(t,e){const n=[];t.id!==e.diagramId&&n.push(C("missing_element",[t.id,e.diagramId],`layout ${e.diagramId} does not resolve measured diagram ${t.id}`)),r("measured node",t.nodes.map(t=>t.id),n),r("measured group",t.groups.map(t=>t.id),n),r("measured edge",t.edges.map(t=>t.id),n),r("resolved node",e.nodes.map(t=>t.id),n),r("resolved group",e.groups.map(t=>t.id),n),r("resolved edge",e.edges.map(t=>t.id),n),s("node",t.nodes.map(t=>t.id),e.nodes.map(t=>t.id),n),s("group",t.groups.map(t=>t.id),e.groups.map(t=>t.id),n),s("edge",t.edges.map(t=>t.id),e.edges.map(t=>t.id),n);const i=new Map(t.nodes.map(t=>[t.id,t])),b=new Map(t.groups.map(t=>[t.id,t])),y=new Map(e.nodes.map(t=>[t.id,t])),B=new Map(e.groups.map(t=>[t.id,t]));a("diagram",e.diagramId,e.bounds,n);for(const t of e.nodes){a("node",t.id,t.bounds,n);const o=i.get(t.id);!o||x(o.size.width,t.bounds.width)&&x(o.size.height,t.bounds.height)||n.push(C("size_mismatch",[t.id],`node ${t.id} size changed after measurement`)),o&&(o.contentSize.width>t.bounds.width||o.contentSize.height>t.bounds.height)&&n.push(C("content_overflow",[t.id],`node ${t.id} content exceeds its resolved bounds`)),d("node",t.id,t.bounds,e.bounds,n)}for(const t of e.groups){a("group",t.id,t.bounds,n),a("group title",t.id,t.titleBounds,n),d("group",t.id,t.bounds,e.bounds,n),g(t.bounds,t.titleBounds)||n.push(C("false_containment",[t.id],`group ${t.id} does not contain its title`));const o=b.get(t.id);!o||x(o.titleSize.width,t.titleBounds.width)&&x(o.titleSize.height,t.titleBounds.height)||n.push(C("size_mismatch",[t.id],`group ${t.id} title size changed after measurement`))}if(function(t,e){w(t,(t,n)=>{A(t.bounds,n.bounds)&&e.push(C("node_overlap",[t.id,n.id],`nodes ${t.id} and ${n.id} overlap`))})}(e.nodes,n),function(t,e){w(t,(t,n)=>{!A(t.bounds,n.bounds)||g(t.bounds,n.bounds)||g(n.bounds,t.bounds)||e.push(C("group_overlap",[t.id,n.id],`groups ${t.id} and ${n.id} partially overlap`))})}(e.groups,n),function(t,e,n,o,i){for(const e of t){const t=n.get(e.id);if(t&&t.parentId!==e.parentId&&i.push(C("false_containment",[e.id],`node ${e.id} has the wrong parent ID`)),!e.parentId)continue;const r=o.get(e.parentId);t&&r&&!g(r.bounds,t.bounds)&&i.push(C("false_containment",[e.id,e.parentId],`node ${e.id} lies outside owning group ${e.parentId}`))}for(const t of e){const e=o.get(t.id);if(e&&e.parentId!==t.parentId&&i.push(C("false_containment",[t.id],`group ${t.id} has the wrong parent ID`)),!t.parentId)continue;const n=o.get(t.parentId);e&&n&&!g(n.bounds,e.bounds)&&i.push(C("false_containment",[t.id,t.parentId],`group ${t.id} lies outside owning group ${t.parentId}`))}}(t.nodes,t.groups,y,B,n),function(t,e,n,o,i,r,s){const g=new Map(t.edges.map(t=>[t.id,t])),b=[];for(const t of e.edges){const y=g.get(t.id);if(y)if(t.sourceId===y.sourceId&&t.targetId===y.targetId||s.push(C("disconnected_edge",[t.id,t.sourceId,t.targetId],`edge ${t.id} endpoints do not match its measured contract`)),0===t.sections.length||t.sections.some(t=>t.length<2))s.push(C("disconnected_edge",[t.id],`edge ${t.id} has no complete route section`));else{l(t,n,s);for(const n of t.sections)for(const o of n)if(!m(o)||!f(o,e.bounds,!0)){s.push(C("out_of_bounds",[t.id],`edge ${t.id} has a route point outside the resolved view`));break}for(const e of n.values())e.id!==t.sourceId&&e.id!==t.targetId&&u(t.sections,p(e.bounds,.5))&&s.push(C("edge_through_node",[t.id,e.id],`edge ${t.id} crosses unrelated node ${e.id}`));for(const e of o.values()){const n=c(t.sourceId,e.id,i,r);n===c(t.targetId,e.id,i,r)&&h(t.sections,e.bounds,n)&&s.push(C("edge_through_group",[t.id,e.id],`edge ${t.id} violates group ${e.id} boundary`))}if(t.labelBounds){a("edge label",t.id,t.labelBounds,s),d("edge label",t.id,t.labelBounds,e.bounds,s),!y.labelSize||x(y.labelSize.width,t.labelBounds.width)&&x(y.labelSize.height,t.labelBounds.height)||s.push(C("size_mismatch",[t.id],`edge ${t.id} label size changed after measurement`));for(const e of n.values())A(t.labelBounds,e.bounds)&&s.push(C("label_node_overlap",[t.id,e.id],`edge ${t.id} label overlaps node ${e.id}`));for(const e of o.values())A(t.labelBounds,e.titleBounds)&&s.push(C("label_title_overlap",[t.id,e.id],`edge ${t.id} label overlaps group ${e.id} title`));b.push({id:t.id,bounds:t.labelBounds})}else y.labelSize&&s.push(C("missing_element",[t.id],`edge ${t.id} is missing its measured label`))}}w(b,(t,e)=>{A(t.bounds,e.bounds)&&s.push(C("label_label_overlap",[t.id,e.id],`edge labels ${t.id} and ${e.id} overlap`))});for(const t of b)for(const n of e.edges)u(n.sections,p(t.bounds,.5))&&s.push(C("label_edge_overlap",[t.id,n.id],`edge ${n.id} crosses label ${t.id}`))}(t,e,y,B,i,b,n),n.length>0)throw new o(n);return e}function r(t,e,n){const o=new Set;for(const i of e)o.has(i)&&n.push(C("duplicate_id",[i],`${t} ${i} is duplicated`)),o.add(i)}function s(t,e,n,o){const i=new Set(e),r=new Set(n);for(const e of i)r.has(e)||o.push(C("missing_element",[e],`${t} ${e} is missing from resolved layout`));for(const e of r)i.has(e)||o.push(C("unexpected_element",[e],`${t} ${e} is not in the measured diagram`))}function a(t,e,n,o){(!function(t){return m(t)&&Number.isFinite(t.width)&&Number.isFinite(t.height)}(n)||n.width<0||n.height<0)&&o.push(C("non_finite",[e],`${t} ${e} has invalid geometry`))}function d(t,e,n,o,i){g(o,n)||i.push(C("out_of_bounds",[e],`${t} ${e} lies outside the resolved view bounds`))}function l(t,e,n){for(let e=1;et.some((n,o)=>o>0&&function(t,e,n){const o=e.x-t.x,i=e.y-t.y;let r=0,s=1;for(const[e,a,d,l]of[[t.x,o,n.x,n.x+n.width],[t.y,i,n.y,n.y+n.height]]){if(Math.abs(a)=l)return!1;continue}const t=(d-e)/a,n=(l-e)/a;if(r=Math.max(r,Math.min(t,n)),s=Math.min(s,Math.max(t,n)),r>=s)return!1}return s>0&&r<1}(t[o-1],n,e)))}function A(t,e){return t.x=e.x+e.width&&t.y+t.height>=e.y+e.height}function f(t,e,n){return n?t.x>=e.x&&t.y>=e.y&&t.x<=e.x+e.width&&t.y<=e.y+e.height:t.x>e.x&&t.y>e.y&&t.x=e.x-.1&&t.x<=e.x+e.width+.1,o=t.y>=e.y-.1&&t.y<=e.y+e.height+.1,i=x(t.x,e.x)||x(t.x,e.x+e.width),r=x(t.y,e.y)||x(t.y,e.y+e.height);return o&&i||n&&r}function x(t,e){return Math.abs(t-e)<=.1}function w(t,e){for(let n=0;n$,Qy:()=>j,ZG:()=>_,oP:()=>D,IX:()=>P,F_:()=>H,Kp:()=>O,a_:()=>R});var o=n(74),i=n(321),r=n(718),s=n(628);const a={element(t,e={},n){const o=document.createElementNS("http://www.w3.org/2000/svg",t);return Object.entries(e).forEach(([t,e])=>o.setAttribute(t,String(e))),n&&o.classList.add(n),o},use(t,e={}){const n=this.element("use",e);return n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","#"+t),n},path(t,e={},n){return this.element("path",{...e,d:t},n)},text(t,e={}){const n=this.element("text",e);return t&&(n.textContent=t),n},textArea(t,e,n,o,i=0,a=0,d=""){const l={"font-family":s.M5.edgeText["font-family"],"font-size":`${n}px`,"font-weight":o?"bold":"normal"},{lines:c,maxW:h}=(0,r.U2)(t,e,l),u=this.text("",{x:0,y:a,"text-anchor":d||void 0});return c.forEach((t,e)=>{const o=this.element("tspan",{x:i,dy:`${n+2}px`,...l});o.textContent=t,u.append(o)}),{txt:u,dy:(c.length+1)*(n+2),maxW:h}},rect(t,e,n=0,o=0,i=0,r){return this.element("rect",{x:n,y:o,rx:i,ry:i,width:t,height:e},r)},icon(t,e=0,n=0){return this.use(t,{x:e,y:n})},expand(t,e,n){const o=this.element("g",{transform:`translate(${t},${e})`},"expand");return o.append(this.rect(19,19,0,0,1),this.text(n?"-":"+",{x:10,y:14,"text-anchor":"middle"})),o}};function d(t,e,n){t.setAttribute("transform",`translate(${e},${n})`)}function l(t,e,n=!0){return n?t.x>e.x-e.width/2&&t.xe.y-e.height/2&&t.ye.x&&t.xe.y&&t.yfunction(t,e,n,o){let i,r,s,a,d,l={x:null,y:null,onLine1:!1,onLine2:!1};return i=(o.y-n.y)*(e.x-t.x)-(o.x-n.x)*(e.y-t.y),0==i||(r=t.y-n.y,s=t.x-n.x,a=(o.x-n.x)*r-(o.y-n.y)*s,d=(e.x-t.x)*r-(e.y-t.y)*s,r=a/i,s=d/i,l.x=t.x+r*(e.x-t.x),l.y=t.y+r*(e.y-t.y),r>0&&r<1&&(l.onLine1=!0),s>=0&&s<=1&&(l.onLine2=!0)),l}(t,e,n.p,n.q)).filter(t=>t.onLine1&&t.onLine2)}(t,e,t)[0]||{x:t.x,y:t.y}}function h(t,e,n,o,i){const r={x:i.x-t.x,y:i.y-t.y},s=o.x-t.x,a=o.y-t.y;s==r.x&&(r.x+=1e-7);const d=(a-r.y)/(s-r.x),l=a-d*s,c=n*n+e*e*d*d,h=2*e*e*l*d,u=e*e*l*l-e*e*n*n,A=Math.sqrt(h*h-4*c*u),g=r.x>s?(-h+A)/(2*c):(-h-A)/(2*c),f={x:g,y:d*g+l};return f.x+=t.x,f.y+=t.y,f}function u(t,e,n){let o=n.x-e.x,i=n.y-e.y,r=o*o+i*i,s=(t.x-e.x)*o+(t.y-e.y)*i,a=Math.min(1,Math.max(0,s/r));return{x:e.x+o*a,y:e.y+i*a}}function A(t,e){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function g(t){return t/2/(5.5+t/70)}function f(t,e,n){switch(t.toLowerCase()){case"cylinder":return 2*g(e);case"person":return.4*n;case"folder":return e/10;case"robot":return.35*n;case"webbrowser":return n/8;default:return 0}}class p{_el;constructor(t){this._el=t}node(){return this._el}attr(t,e){return this._el.setAttribute(t,String(e)),this}insert(t,e){const n=document.createElementNS("http://www.w3.org/2000/svg",t),o=this._el.insertBefore(n,this._el.querySelector(e));return new p(o)}}function m(t,e,n,o=!1){const i=t.insert("rect",":first-child").attr("rx",o?n.width/8:3).attr("ry",o?n.width/8:3).attr("x",-e.width/2).attr("y",-e.height/2).attr("width",e.width).attr("height",e.height);return n.intersect=function(t){return c(n,t)},i}function b(t,e,n,o,i){const r=t.insert("ellipse",":first-child").attr("cx",0).attr("cy",0).attr("rx",o).attr("ry",i).attr("width",n.width).attr("height",n.height);return n.intersect=function(t){return h(n,o,i,n,t)},r}function y(t,e,n){const o=n.width/8,i=n.width/14,r=t.insert("g",":first-child");return r.insert("path",":first-child").attr("d",`M${-n.width/2},${-n.height/2} l${n.width},0 M${-n.width/2},${n.height/2} l${n.width},0`),r.insert("circle",":first-child").attr("cx",0).attr("cy",n.height/2+o/2).attr("r",.4*i),r.insert("rect",":first-child").attr("x",-i).attr("y",-n.height/2-o/2-.2*i).attr("width",2*i).attr("height",.4*i),r.insert("rect",":first-child").attr("rx",i).attr("ry",i).attr("x",-e.width/2).attr("y",-e.height/2-o).attr("width",e.width).attr("height",e.height+2*o),n.intersect=function(t){return c({x:n.x,y:n.y,width:n.width,height:n.height+2*o},t)},r}const x={box:(t,e)=>m(new p(t),e,e).node(),roundedbox:(t,e)=>m(new p(t),e,e,!0).node(),component:(t,e)=>function(t,e,n){const o=n.width/10,i=t.insert("g",":first-child");return i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2-o).attr("y",-n.height/2+o).attr("width",2*o).attr("height",o),i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2-o).attr("y",-n.height/2+2.5*o).attr("width",2*o).attr("height",o),i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2).attr("y",-n.height/2).attr("width",n.width).attr("height",n.height),n.intersect=function(t){return c({x:n.x-o/2,y:n.y,width:n.width+o,height:n.height},t)},i}(new p(t),0,e).node(),cylinder:(t,e)=>function(t,e,n){const o=e.width,i=o/2,r=g(o),s=e.height,a=`M 0,${r} a${i},${r} 0,0,0 ${o} 0 a ${i},${r} 0,0,0 ${-o} 0 l 0,${s-2*r} a ${i},${r} 0,0,0 ${o} 0 l 0,${2*r-s}`,d=t.attr("label-offset-y",f("cylinder",o,s)).insert("path",":first-child").attr("d",a).attr("transform","translate("+-o/2+","+-s/2+")");return n.intersect=function(t){const e=c(n,t);let o=n.y+n.height/2-r;return e.y>o?h({x:n.x,y:o},i,r,n,t):(o=n.y-n.height/2+r,e.yfunction(t,e,n){const o=e.width,i=e.height,r=`M ${.38*o},${i/3} A${o/2},${i/2} 0,0,0 0 ${i/2}\n\t\tL${o/11},${i} L${o-o/11},${i} L${o},${i/2}\n\t\tA${o/2},${i/2} 0,0,0 ${o-.38*o} ${i/3} \n\t\tA${o/6},${o/6} 0,1,0 ${.38*o} ${i/3}`,s=t.attr("label-offset-y",f("person",o,i)).insert("path",":first-child").attr("d",r).attr("transform","translate("+-o/2+","+-i/2+")");return n.intersect=function(t){return c(n,t)},s}(new p(t),e,e).node(),circle:(t,e)=>function(t,e,n){return b(t,0,n,n.width/2,n.width/2)}(new p(t),0,e).node(),ellipse:(t,e)=>function(t,e,n){return b(t,0,n,.55*n.width,.45*n.width)}(new p(t),0,e).node(),hexagon:(t,e)=>function(t,e,n){const o=n.width/2,i=t.insert("polygon",":first-child").attr("points",[.5,.866,1,0,.5,-.866,-.5,-.866,-1,-0,-.5,.866,.5,.866].map(t=>t*o).join(",")).attr("width",n.width).attr("height",n.height);return n.intersect=function(t){return h(n,n.width/2,n.width/2,n,t)},i}(new p(t),0,e).node(),folder:(t,e)=>function(t,e,n){const o=n.width/20,i=t.attr("label-offset-y",f("folder",n.width,n.height)).insert("g",":first-child");return i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2).attr("y",-n.height/2+2*o).attr("width",n.width).attr("height",n.height-2*o),i.insert("path",":first-child").attr("d",`M0,${-n.height/2+2*o} l${o},${-2*o} h${n.width/2-2*o} v${2*o}`),n.intersect=function(t){return c({x:n.x,y:n.y+o/2,width:n.width,height:n.height+o},t)},i}(new p(t),0,e).node(),mobiledevicelandscape:(t,e)=>function(t,e,n){const o=n.width/8,i=n.width/14,r=t.insert("g",":first-child");return r.insert("path",":first-child").attr("d",`M${-n.width/2},${-n.height/2} l0,${n.height} M${n.width/2},${-n.height/2} l0,${n.height}`),r.insert("circle",":first-child").attr("cx",-n.width/2-o/2).attr("cy",0).attr("r",.4*i),r.insert("rect",":first-child").attr("x",n.width/2+o/2-.2*i).attr("y",-i).attr("width",.4*i).attr("height",2*i),r.insert("rect",":first-child").attr("rx",i).attr("ry",i).attr("x",-e.width/2-o).attr("y",-e.height/2).attr("width",e.width+2*o).attr("height",e.height),n.intersect=function(t){return c({x:n.x,y:n.y,width:n.width+2*o,height:n.height},t)},r}(new p(t),e,e).node(),mobiledeviceportrait:(t,e)=>y(new p(t),e,e).node(),mobiledevice:(t,e)=>y(new p(t),e,e).node(),pipe:(t,e)=>function(t,e,n){const o=n.width,i=n.height,r=i/2,s=r/(2.5+o/70),a=`M${-s},0\n\t\ta${s},${r} 0,0,1 0,${i}\n\t\ta${s},${r} 0,0,1 0,${-i}\n\t\tl${o},0\n\t\ta${s},${r} 0,0,1 0,${i}\n\t\tl${-o},0`,d=t.insert("path",":first-child").attr("d",a).attr("transform","translate("+-o/2+","+-i/2+")");return n.intersect=function(t){return c({x:n.x-s,y:n.y,width:n.width+2*s,height:n.height},t)},d}(new p(t),0,e).node(),robot:(t,e)=>function(t,e,n){const o=n.width,i=n.height,r=Math.min(.28*o,.25*i),s=.2*r,a=.25*r,d=.08*r,l=.12*r,h=.22*r,u=.12*r,A=.3*r,g=o,p=-i/2+a+r,m=i-a-r,b=t.attr("label-offset-y",f("robot",o,i)).insert("g",":first-child");b.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-g/2).attr("y",p).attr("width",g).attr("height",m);const y=-i/2+a;b.insert("rect",":first-child").attr("rx",s).attr("ry",s).attr("x",-r/2).attr("y",y).attr("width",r).attr("height",r),b.insert("line",":first-child").attr("class","robot-antenna").attr("x1",0).attr("y1",y).attr("x2",0).attr("y2",-i/2+2*d).attr("stroke-width",.6*d).attr("stroke-linecap","round"),b.insert("circle",":first-child").attr("class","robot-antenna-ball").attr("cx",0).attr("cy",-i/2+2*d).attr("r",1.2*d);const x=y+.4*r;b.insert("circle",":first-child").attr("class","robot-eye").attr("cx",-h).attr("cy",x).attr("r",l),b.insert("circle",":first-child").attr("class","robot-eye").attr("cx",h).attr("cy",x).attr("r",l);const w=y+.7*r,C=.28*r;return b.insert("path",":first-child").attr("class","robot-mouth").attr("d",`M${-C/2},${w} Q0,${w+.3*C} ${C/2},${w}`).attr("fill","none").attr("stroke-width",.5*d).attr("stroke-linecap","round"),b.insert("rect",":first-child").attr("rx",.25*u).attr("ry",.25*u).attr("x",-r/2-u-1).attr("y",x-A/2).attr("width",u).attr("height",A),b.insert("rect",":first-child").attr("rx",.25*u).attr("ry",.25*u).attr("x",r/2+1).attr("y",x-A/2).attr("width",u).attr("height",A),n.intersect=function(t){return c(n,t)},b}(new p(t),0,e).node(),webbrowser:(t,e)=>function(t,e,n){const o=n.height/8,i=t.attr("label-offset-y",f("webbrowser",n.width,n.height)).insert("g",":first-child");return i.insert("path",":first-child").attr("d",`\n\t\t\tM${-n.width/2},${-n.height/2+o} h${n.width}\n\t\t\tM${-n.width/2+o/4},${-n.height/2+o/4} h${o/2} v${o/2} h${-o/2} z\n\t\t\tM${-n.width/2+o},${-n.height/2+o/4} h${n.width-o-o/4} v${o/2} h${-n.width+o+o/4} z\n\t\t`),i.insert("rect",":first-child").attr("rx",3).attr("ry",3).attr("x",-n.width/2).attr("y",-n.height/2).attr("width",n.width).attr("height",n.height),n.intersect=function(t){return c(n,t)},i}(new p(t),0,e).node()};var w=n(983);class C{versions=[];pos=0;lastSavedPos=0;exportDoc;importDoc;change;tmpPreviousState=null;constructor(t,e,n){this.exportDoc=e,this.importDoc=n,this.change=function(t){let e;return function(){const n=this;clearTimeout(e),e=setTimeout(function(){e=null,t.apply(n)},300)}}(()=>this.saveNow())}beforeChange(){this.tmpPreviousState||(this.tmpPreviousState=this.deepClone(this.exportDoc()))}length(){return this.versions.length}currentState(){return this.deepClone(this.versions[this.pos-1])}saveNow(){if(!this.tmpPreviousState)throw Error("undo.change() was called without previously calling undo.beforeChange()!");this.versions[this.pos]=this.deepClone(this.exportDoc()),this.versions[this.pos-1]=this.tmpPreviousState,this.tmpPreviousState=null,this.pos+=1,this.versions.splice(this.pos)}deepClone(t){return"undefined"!=typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t))}undo(){if(this.pos<2)return;this.pos-=1;const t=this.versions[this.pos-1];this.importDoc(this.deepClone(t))}redo(){if(this.pos>this.versions.length-1)return;const t=this.versions[this.pos];this.importDoc(this.deepClone(t)),this.pos+=1}changed(){return this.pos!==this.lastSavedPos}setSaved(){this.lastSavedPos=this.pos}}var B=n(264),v=n(977);function I(t,e,n,o,i,a){const d={"font-family":String(s.M5.nodeText["font-family"]),"font-size":`${n}px`,"font-weight":o?"bold":"normal"},l=(0,r.U2)(t,e,d);return{lines:l.lines.length>0?l.lines:[""],fontSize:n,lineHeight:n+2,bold:o,field:a,gapAfter:i}}n(20);const k=s.Y$,E=s.nD;let S=0;class ${id;name;nodesMap;edges;edgeVertices;groupsMap;metadata;layoutDirection;validatedLayout;colorToVarMap=new Map;svg;idPrefix;selectListener;_undo;_gridVisible=!1;_snapToGrid=!0;_gridSize=25;_skipAutoFit=!1;constructor(t,e){this.id=t,this.name=e,this.edges=[],this.edgeVertices=new Map,this.nodesMap=new Map,this.groupsMap=new Map,this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.idPrefix=`g${++S}-`,this._undo=new C(this.id,()=>this.exportLayout(!0),t=>this.importLayout(t,!0))}init(t){t&&this.importLayout(t),this._undo=new C(this.id,()=>this.exportLayout(!0),t=>this.importLayout(t,!0)),this._undo.length()&&this.importLayout(this._undo.currentState()),this._undo.beforeChange(),this._undo.change()}addNode(t,e,n,o,i,r){if(this.nodesMap.has(t))throw Error("duplicate node: "+t);const s={...E,...i},a=(s.shape||"Box").toLowerCase(),d="person"===a?240:180,l=Math.max(280,s.width||0),c=function(t,e,n,o,i,r){const s=Math.max(o-36,80),a=[I(t,s,i,!0,6,"name")];!1!==r.metadata&&e&&a.push(I(`[${e}]`,s,.7*i,!1,10)),!1!==r.description&&n&&a.push(I(n,s,Math.min(.8*i,16),!1,0,"description")),a[a.length-1].gapAfter=0;const d=a.reduce((t,e)=>t+e.lines.length*e.lineHeight+e.gapAfter,0);return{blocks:a,textHeight:d,minimumHeight:d+36+(r.icon?44:0),icon:r.icon}}(e,n,o,l,s.fontSize||22,s);let h=Math.max(d,s.height||0,c.minimumHeight);for(let t=0;t<20;t++){const t=c.minimumHeight+Math.abs(f(a,l,h));if(t<=h+.1)break;h=t}const u={id:t,title:e,sub:n,description:o,style:s,x:0,y:0,width:l,height:h,intersect:null,link:r,contentLayout:c};this.nodesMap.set(u.id,u)}nodes(){return Array.from(this.nodesMap.values())}addEdge(t,e,n,o,i,r){i&&i.forEach((e,n)=>{const o=e;o.id=`v-${t}-${n}`,this.edgeVertices.set(o.id,o)});const s={id:t,from:this.nodesMap.get(e),to:this.nodesMap.get(n),label:o,vertices:null,style:{...k,...r},initVertex:t=>{const e=t;return e.id||(e.id=((t,e)=>`v-${t}-a-${(t=>{let e=2166136261;for(let n=0;n>>0).toString(36)})(`${t}:${e.x}:${e.y}`)}`)(s.id,t),this.edgeVertices.set(e.id,e)),e.edge=s,t},userDeletedVertices:!1};this.edges.push(s),i&&(s.vertices=i.map(t=>s.initVertex(t)))}addGroup(t,e,n,o){if(this.groupsMap.has(t))return void console.error(`Group exists: ${t} ${e}`);const i={id:t,name:e,x:null,y:null,width:null,height:null,nodes:n.map(n=>{const o=this.nodesMap.get(n)||this.groupsMap.get(n);return o||console.error(`Node or group ${n} not found for group ${t} "${e}"`),o}).filter(Boolean),style:o};this.groupsMap.set(t,i)}setNodeSelected(t,e){t.selected=e,e?t.ref.classList.add("selected"):t.ref.classList.remove("selected"),this.updateEdgesSel()}updateEdgesSel(){this.edges.forEach(t=>{t.to.selected||t.from.selected?t.ref.classList.add("selected"):t.ref.classList.remove("selected")})}clearResolvedLayout(){this.validatedLayout=void 0,this.edges.forEach(t=>{t.layoutSections=void 0,t.layoutLabelBounds=void 0}),this.groupsMap.forEach(t=>{t.layoutBounds=void 0,t.layoutTitleBounds=void 0})}moveNode(t,e,n,o=!1,i=!1){if(t){if(this._snapToGrid&&!o){const t=this.snapToGrid(e,n);e=t.x,n=t.y}t.x==e&&t.y==n||(i||this._undo.beforeChange(),this.clearResolvedLayout(),t.x=e,t.y=n,d(t.ref,e,n),this.redrawEdges(t),this.redrawGroups(t),i||this._undo.change())}}moveEdgeVertex(t,e,n,o=!1,i=!1){if(this._snapToGrid&&!o){const t=this.snapToGrid(e,n);e=t.x,n=t.y}t.x==e&&t.y==n||(i||this._undo.beforeChange(),this.clearResolvedLayout(),t.x=e,t.y=n,this.redrawEdge(t.edge),i||this._undo.change())}moveSelected(t,e,n=!1){this.nodes().forEach(o=>o.selected&&this.moveNode(o,o.x+t,o.y+e,n,!1)),this.edgeVertices.forEach(o=>o.selected&&this.moveEdgeVertex(o,o.x+t,o.y+e,n,!1))}insertEdgeVertex(t,e,n,o){this._undo.beforeChange(),this.clearResolvedLayout();const i=t.initVertex(e);i.selected=!0,o&&(t.vertices.forEach(t=>t.label=!1),i.label=!0),t.vertices.splice(n-1,0,i),this.redrawEdge(t),this._undo.change()}deleteEdgeVertex(t){this._undo.beforeChange(),this.clearResolvedLayout();const e=t.edge.vertices.indexOf(t);e>=0&&(t.edge.vertices.splice(e,1),this.edgeVertices.delete(t.id),t.edge.userDeletedVertices=!0),this.redrawEdge(t.edge),this._undo.change()}changed(){return this._undo.changed()}undo(){this._undo.undo()}redo(){this._undo.redo()}alignTopLeft(){const t=this.calculateContentBounds(),e=100-t.x,n=100-t.y;this._skipAutoFit=!0,this._undo.beforeChange(),this.nodesMap.forEach(t=>{this.moveNode(t,t.x+e,t.y+n,!0,!0)}),this.edgeVertices.forEach(t=>{this.moveEdgeVertex(t,t.x+e,t.y+n,!0,!0)}),this._undo.change()}resetPanTransform(){const t=P(this),e=this.svg.querySelector("g.zoom");e&&(e.setAttribute("transform",`scale(${t}) translate(0, 0)`),function(t){const e=t.svg,n=t.calculateContentBounds(),o=P(t),i=Math.max(e.parentElement.clientWidth/o,n.x+n.width+20),r=Math.max(e.parentElement.clientHeight/o,n.y+n.height+20);e.setAttribute("width",String(i*o)),e.setAttribute("height",String(r*o))}(this)),Z(this),this._skipAutoFit=!1}shouldSkipAutoFit(){return this._skipAutoFit}resetView(){const t=this.svg.querySelector("g.zoom");t&&(t.setAttribute("transform","scale(1) translate(0, 0)"),U(this)),Z(this)}redrawEdges(t){this.edges.forEach(e=>(t==e.from||t==e.to)&&this.redrawEdge(e)),this.updateEdgesSel()}redrawEdge(t){const e=t.ref.parentElement;e.removeChild(t.ref),t.ref=V(t,this),e.append(t.ref)}redrawGroups(t){this.groupsMap.forEach(t=>{const e=t.ref.parentElement;e.removeChild(t.ref),T(t),e.append(t.ref)})}exportSVG(){this.validatedLayout||(this.validatedLayout=(0,w.U)(this));const t=this.svg,e=(t.querySelector("rect.elastic"),t.cloneNode(!0)),n=Array.from(e.attributes);n.forEach(t=>e.removeAttributeNode(t)),e.setAttribute("id","graph"),n.forEach(t=>e.setAttributeNode(t)),this.removeIdPrefix(e),e.querySelectorAll("a.nodeLink[data-export-href]").forEach(t=>{t.setAttribute("href",t.getAttribute("data-export-href")||""),t.removeAttribute("data-export-href")});const o=e.querySelector("rect.elastic");o&&o.remove();const i=this.validatedLayout.bounds,r=i.width+100,s=i.height+100,a=50-i.x,d=50-i.y,l=e.querySelector("g.zoom");l&&l.setAttribute("transform",`scale(1) translate(${a}, ${d})`),e.setAttribute("viewBox",`0 0 ${r} ${s}`),e.setAttribute("width",String(r)),e.setAttribute("height",String(s)),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.convertStylesToCustomProperties(e);const c=document.createElement("script");return c.setAttribute("type","application/json"),this.metadata.layout=this.exportLayout(),c.append("/g,"]]]>]>"),e.insertBefore(c,e.firstChild),e.outerHTML}removeIdPrefix(t){const e=this.idPrefix,n=`url(#${e}`;t.querySelectorAll("*").forEach(t=>{if(!t.matches("a.nodeLink"))for(const o of Array.from(t.attributes))"id"===o.name&&o.value.startsWith(e)?o.value=o.value.slice(e.length):"href"!==o.localName&&o.value.startsWith(n)&&(o.value="url(#"+o.value.slice(n.length))})}convertStylesToCustomProperties(t){0!==this.colorToVarMap.size&&(t.querySelectorAll("[fill]").forEach(t=>{const e=t.getAttribute("fill");e&&this.colorToVarMap.has(e)&&t.setAttribute("fill",`var(${this.colorToVarMap.get(e)}, ${e})`)}),t.querySelectorAll("[stroke]").forEach(t=>{const e=t.getAttribute("stroke");e&&this.colorToVarMap.has(e)&&t.setAttribute("stroke",`var(${this.colorToVarMap.get(e)}, ${e})`)}))}calculateContentBounds(){let t=1/0,e=1/0,n=-1/0,o=-1/0;return this.nodes().forEach(i=>{const r=i.x-i.width/2,s=i.x+i.width/2,a=i.y-i.height/2,d=i.y+i.height/2;t=Math.min(t,r),n=Math.max(n,s),e=Math.min(e,a),o=Math.max(o,d)}),this.edgeVertices.forEach(i=>{t=Math.min(t,i.x-5),n=Math.max(n,i.x+5),e=Math.min(e,i.y-5),o=Math.max(o,i.y+5)}),this.groupsMap.forEach(i=>{const r=i.x-i.width/2,s=i.x+i.width/2,a=i.y-i.height/2,d=i.y+i.height/2;t=Math.min(t,r),n=Math.max(n,s),e=Math.min(e,a),o=Math.max(o,d)}),this.edges.forEach(i=>{if(t=Math.min(t,i.from.x-10,i.to.x-10),n=Math.max(n,i.from.x+10,i.to.x+10),e=Math.min(e,i.from.y-10,i.to.y-10),o=Math.max(o,i.from.y+10,i.to.y+10),i.vertices&&i.vertices.forEach(i=>{t=Math.min(t,i.x-10),n=Math.max(n,i.x+10),e=Math.min(e,i.y-10),o=Math.max(o,i.y+10)}),i.label&&i.label.trim()){const r=(i.from.x+i.to.x)/2,s=(i.from.y+i.to.y)/2,a=10*i.label.length+50;t=Math.min(t,r-a),n=Math.max(n,r+a),e=Math.min(e,s-25),o=Math.max(o,s+25)}}),t===1/0?{x:0,y:0,width:100,height:100}:{x:t,y:e,width:n-t,height:o-e}}exportLayout(t=!1){const e={};return this.nodes().forEach(t=>e[t.id]={x:t.x,y:t.y}),this.edges.forEach(n=>{if(!n.vertices)return;const o=n.vertices.map(t=>({x:t.x,y:t.y,label:t.label,auto:t.auto}));(o.length||t)&&(e[`e-${n.id}`]=o),n.userDeletedVertices&&(e[`e-${n.id}-deleted`]=!0)}),e}setSaved(){this._undo.setSaved()}importLayout(t,e=!1){this.clearResolvedLayout();for(const[e,n]of Object.entries(t)){const t=this.nodesMap.get(e);if(t){const o=L(e,n);t.x=o.x,t.y=o.y;continue}if(e.endsWith("-deleted")){const t=e.slice(2,-8),o=this.edges.find(e=>e.id===t);if(!o||!0!==n)throw new Error(`invalid deleted-edge layout entry ${e}`);o.userDeletedVertices=!0;continue}if(e.startsWith("e-")){const t=this.edges.find(t=>t.id===e.slice(2));if(!t||!Array.isArray(n))throw new Error(`invalid edge layout entry ${e}`);for(const e of t.vertices??[])this.edgeVertices.delete(e.id);t.vertices=n.map((n,o)=>{const i=L(`${e}[${o}]`,n),r=t.initVertex(i);return r.label=n.label,r.auto=n.auto,r});continue}throw new Error(`layout contains unknown element ${e}`)}for(const e of this.nodes())if(!(e.id in t))throw new Error(`layout is missing node ${e.id}`);e&&(this.nodes().forEach(t=>d(t.ref,t.x,t.y)),this.edges.forEach(t=>this.redrawEdge(t)),this.updateEdgesSel(),this.redrawGroups(null))}async autoLayout(t){const e=await(0,w.k)(this,t);this._undo.beforeChange();for(const t of e.nodes){const e=this.nodesMap.get(t.id);if(!e)throw new Error(`layout contains unknown node ${t.id}`);e.x=t.x,e.y=t.y,d(e.ref,e.x,e.y)}for(const t of e.groups){const e=this.groupsMap.get(t.id);if(!e)throw new Error(`layout contains unknown group ${t.id}`);e.layoutBounds=t.bounds,e.layoutTitleBounds=t.titleBounds,e.x=t.bounds.x+t.bounds.width/2,e.y=t.bounds.y+t.bounds.height/2,e.width=t.bounds.width,e.height=t.bounds.height}for(const t of e.edges){const e=this.edges.find(e=>e.id===t.id);if(!e)throw new Error(`layout contains unknown edge ${t.id}`);for(const t of e.vertices??[])this.edgeVertices.delete(t.id);e.layoutSections=t.sections,e.layoutLabelBounds=t.labelBounds,e.vertices=M(t.sections).map(t=>{const n=e.initVertex(t);return n.auto=!0,n}),e.userDeletedVertices=!1}this.validatedLayout=e.validated,this.edges.forEach(t=>this.redrawEdge(t)),this.redrawGroups(null),this.fitToView(),this._undo.change()}alignSelectionV(){const t=this.nodes().filter(t=>t.selected);t.push(...Array.from(this.edgeVertices.values()).filter(t=>t.selected));let e=Math.min(...t.map(t=>t.y));this.nodesMap.forEach(t=>t.selected&&this.moveNode(t,t.x,e,!1,!1)),this.edgeVertices.forEach(t=>t.selected&&this.moveEdgeVertex(t,t.x,e,!1,!1))}alignSelectionH(){const t=this.nodes().filter(t=>t.selected);t.push(...Array.from(this.edgeVertices.values()).filter(t=>t.selected));let e=Math.min(...t.map(t=>t.x));this.nodesMap.forEach(t=>t.selected&&this.moveNode(t,e,t.y,!1,!1)),this.edgeVertices.forEach(t=>t.selected&&this.moveEdgeVertex(t,e,t.y,!1,!1))}distributeSelectionH(){const t=this.nodes().filter(t=>t.selected),e=Array.from(this.edgeVertices.values()).filter(t=>t.selected);if(t.length+e.length<3)return;this._undo.beforeChange();const n=[...t,...e];n.sort((t,e)=>t.x-e.x);const o=n[0].x,i=(n[n.length-1].x-o)/(n.length-1);n.forEach((t,e)=>{const n=o+e*i;"title"in t?this.moveNode(t,n,t.y,!1,!0):this.moveEdgeVertex(t,n,t.y,!1,!0)}),this._undo.change()}distributeSelectionV(){const t=this.nodes().filter(t=>t.selected),e=Array.from(this.edgeVertices.values()).filter(t=>t.selected);if(t.length+e.length<3)return;this._undo.beforeChange();const n=[...t,...e];n.sort((t,e)=>t.y-e.y);const o=n[0].y,i=(n[n.length-1].y-o)/(n.length-1);n.forEach((t,e)=>{const n=o+e*i;"title"in t?this.moveNode(t,t.x,n,!1,!0):this.moveEdgeVertex(t,t.x,n,!1,!0)}),this._undo.change()}setEdgeSelected(t,e){e&&(this.setNodeSelected(t.from,!0),this.setNodeSelected(t.to,!0)),this.updateEdgesSel()}fitToView(){const t=this.calculateContentBounds();if(0===t.width||0===t.height)return;const e=this.svg.parentElement?.clientWidth||800,n=this.svg.parentElement?.clientHeight||600,o=(e-80)/t.width,i=(n-80)/t.height,r=Math.min(o,i),s=Math.max(Math.min(r,2),.1),a=e/2-(t.x+t.width/2)*s,d=n/2-(t.y+t.height/2)*s,l=this.svg.querySelector("g.zoom");l&&l.setAttribute("transform",`translate(${a}, ${d}) scale(${s})`),U(this),O(this)}saveLayoutState(){return this.exportLayout(!0)}restoreLayoutState(t){this.importLayout(t,!0)}isGridVisible(){return this._gridVisible}isSnapToGrid(){return this._snapToGrid}getGridSize(){return this._gridSize}toggleGrid(){this._gridVisible=!this._gridVisible,this.updateGridDisplay(),window.dispatchEvent(new CustomEvent("gridStateChanged"))}toggleSnapToGrid(){this._snapToGrid=!this._snapToGrid,window.dispatchEvent(new CustomEvent("gridStateChanged"))}snapAllToGrid(){this._snapToGrid&&(this._undo.beforeChange(),this.nodes().forEach(t=>{const e=Math.round(t.x/this._gridSize)*this._gridSize,n=Math.round(t.y/this._gridSize)*this._gridSize;this.moveNode(t,e,n,!1,!0)}),this._undo.change())}snapToGrid(t,e){return{x:Math.round(t/this._gridSize)*this._gridSize,y:Math.round(e/this._gridSize)*this._gridSize}}updateGridDisplay(){const t=this.svg,e=t.querySelector(`#${this.idPrefix}grid-pattern`);e&&e.remove();const n=t.querySelector(`#${this.idPrefix}grid-background`);if(n&&n.remove(),!this._gridVisible)return;let o=t.querySelector("defs");o||(o=document.createElementNS("http://www.w3.org/2000/svg","defs"),t.insertBefore(o,t.firstChild));const i=document.createElementNS("http://www.w3.org/2000/svg","pattern");i.id=`${this.idPrefix}grid-pattern`,i.setAttribute("width",this._gridSize.toString()),i.setAttribute("height",this._gridSize.toString()),i.setAttribute("patternUnits","userSpaceOnUse");const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",`M ${this._gridSize} 0 L 0 0 0 ${this._gridSize}`),r.setAttribute("fill","none"),r.setAttribute("stroke","#d0d0d0"),r.setAttribute("stroke-width","1"),r.setAttribute("opacity","0.8"),i.appendChild(r),o.appendChild(i);const s=document.createElementNS("http://www.w3.org/2000/svg","rect");s.id=`${this.idPrefix}grid-background`,s.setAttribute("x","-10000"),s.setAttribute("y","-10000"),s.setAttribute("width","20000"),s.setAttribute("height","20000"),s.setAttribute("fill",`url(#${this.idPrefix}grid-pattern)`),s.setAttribute("pointer-events","none");const a=t.querySelector("g.zoom");a&&a.insertBefore(s,a.firstChild)}}function M(t){const e=[];for(const n of t)for(const t of n){const n=e[e.length-1];n&&n.x===t.x&&n.y===t.y||e.push(t)}return e.slice(1,-1)}function L(t,e){if("object"!=typeof e||Array.isArray(e)||!Number.isFinite(e.x)||!Number.isFinite(e.y))throw new Error(`layout entry ${t} must contain valid x and y coordinates`);return e}const _=(t,e,n)=>{const o=t.svg;o.setAttribute("width","100%"),o.setAttribute("height","100%"),document.body.append(o),t.selectListener=e,z(t);const i=a.rect(300,300,50,50,0,"elastic");return o.append(i),t.updateGridDisplay(),j(t,n),{svg:o,setZoom:e=>function(t,e){const n=t.svg.querySelector("g.zoom");if(!n)return;const o=W(t);n.setAttribute("transform",`translate(${o.x}, ${o.y}) scale(${e})`),U(t)}(t,e)}},D=t=>(z(t),t.svg),z=t=>{var e;t.svg.innerHTML=(e=t.idPrefix,`\n\n\t\n\t${i.replace(/&/g,"&").replace(/\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n`);const n=a.element("g",{},"zoom"),r=a.element("g",{},"nodes"),l=a.element("g",{},"edges"),c=a.element("g",{},"groups");n.append(c,l,r),t.nodesMap.forEach(e=>{!function(t,e){const n=a.element("g",{},"node");n.setAttribute("id",e.idPrefix+t.id),t.selected&&n.classList.add("selected"),d(n,t.x,t.y);const o=t.link?a.element("a",{href:t.link.href,"data-export-href":t.link.exportHref,"aria-label":`Open ${t.title}`},"nodeLink"):null,i=o||n;o&&(n.classList.add("linked"),n.append(o));const r=t.style.shape||"Box",l=(x[r.toLowerCase()]||x.box)(i,t);l.classList.add("nodeBorder"),(0,s.AV)(l,s.M5.nodeBorder),l.setAttribute("fill",t.style.background),l.setAttribute("stroke",t.style.stroke),l.setAttribute("opacity",String(t.style.opacity)),G(l,t.style.border);const c=function(t,e){const n=a.element("g"),o=t.icon?44:0;let i=-(t.textHeight+o)/2;return t.icon&&(n.append(a.element("image",{href:t.icon,x:-16,y:i,width:32,height:32,preserveAspectRatio:"xMidYMid meet"},"nodeIcon")),i+=o),t.blocks.forEach(t=>{const o=a.text("",{"text-anchor":"middle"});(0,s.AV)(o,s.M5.nodeText),e&&o.setAttribute("fill",e),t.field&&o.setAttribute("data-field",t.field),t.lines.forEach((e,n)=>{const r=a.element("tspan",{x:0,y:i+t.fontSize+n*t.lineHeight,"font-size":`${t.fontSize}px`,"font-weight":t.bold?"bold":"normal"});r.textContent=e,o.append(r)}),n.append(o),i+=t.lines.length*t.lineHeight+t.gapAfter}),n}(t.contentLayout,t.style.color);d(c,0,(Number(i.getAttribute("label-offset-y"))||0)/2),i.append(c),n.__data=t,t.ref=n}(e,t),r.append(e.ref)}),t.edges.forEach(t=>{t.labelBounds=void 0}),t.edges.forEach(e=>{V(e,t),l.append(e.ref)}),t.groupsMap.forEach(t=>{T(t),c.append(t.ref)}),t.svg.append(n)};function V(t,e){const n=t.from,o=a.element("g",{},"edge");o.setAttribute("id",e.idPrefix+t.id),o.setAttribute("data-from",t.from.id),o.setAttribute("data-to",t.to.id);const i=(t.style.position||50)/100,r=t.layoutSections?function(t){const e=[];for(const n of t)for(const t of n){const n=e[e.length-1];n&&n.x===t.x&&n.y===t.y||e.push(t)}return e}(t.layoutSections):(0,v.l)(t),{bg:d,txt:l}=t.layoutLabelBounds?function(t,e){const n=t.x+t.width/2,{txt:o}=(t.y,t.height,a.textArea(e.label,e.style.width,e.style.fontSize,!1,n,t.y,"middle"));(0,s.AV)(o,s.M5.edgeText),o.setAttribute("stroke","none"),o.setAttribute("font-size",String(e.style.fontSize)),o.setAttribute("fill",e.style.color),o.setAttribute("data-field","label");const i=a.rect(t.width,t.height,t.x,t.y);return(0,s.AV)(i,s.M5.edgeRect),{bg:i,txt:o}}(t.layoutLabelBounds,t):function(t,e){const n=e.style.fontSize;let{txt:o,dy:i,maxW:r}=a.textArea(e.label,e.style.width,n,!1,t.x,t.y,"middle");i-=n/2,r+=n;const d="vertical"===t.orientation?t.x+r/2+12:t.x,l="vertical"===t.orientation?t.y:t.y-i/2-12,c={x:d-r/2,y:l-i/2,width:r,height:i};o.querySelectorAll("tspan").forEach(t=>{t.setAttribute("x",String(d))}),o.setAttribute("y",String(l-i/2)),(0,s.AV)(o,s.M5.edgeText),o.setAttribute("stroke","none"),o.setAttribute("font-size",String(e.style.fontSize)),o.setAttribute("fill",e.style.color);const h=a.rect(c.width,c.height,c.x,c.y);return(0,s.AV)(h,s.M5.edgeRect),o.setAttribute("data-field","label"),e.labelBounds=c,{bg:h,txt:o}}((0,v.IW)(r,i,n),t);o.append(d,l);const c=(0,v.Zr)(r),h=a.path(c,{"marker-end":`url(#${e.idPrefix}arrow)`},"edge");h.setAttribute("fill","none"),h.setAttribute("stroke",t.style.color),h.setAttribute("stroke-width",String(t.style.thickness)),h.setAttribute("stroke-linecap","round"),t.style.dashed&&h.setAttribute("stroke-dasharray","8"),o.append(h);for(const n of t.vertices??[]){const t=n;t.ref=a.element("circle",{id:e.idPrefix+t.id,cx:n.x,cy:n.y,r:7,fill:"none"},"v-dot"),t.selected&&t.ref.classList.add("selected"),t.auto&&t.ref.classList.add("auto"),o.append(t.ref)}return t.ref=o,o}function T(t){if(0==t.nodes.length)return;const e=a.element("g",{},"group");if(t.layoutBounds&&t.layoutTitleBounds){const n=t.layoutBounds,o=t.layoutTitleBounds,i=a.rect(n.width,n.height,n.x,n.y);(0,s.AV)(i,s.M5.groupRect),t.style.stroke&&i.setAttribute("stroke",t.style.stroke),t.style.background&&i.setAttribute("fill",t.style.background);const r=a.text(t.name,{x:o.x,y:o.y,"dominant-baseline":"hanging"});return(0,s.AV)(r,s.M5.groupText),t.style.color&&r.setAttribute("fill",t.style.color),e.append(i,r),void(t.ref=e)}let n={x:1e100,y:1e100},o={x:0,y:0};t.nodes.forEach(t=>{const e=t.style?.shape?.toLowerCase()||"box";let i=t.height/2,r=t.height/2;if("robot"===e){const e=.12*t.height;i=t.height/2+e,r=t.height/2}else if("hexagon"===e){const e=t.width/2*.866;i=e,r=e}const s={x:t.x-t.width/2,y:t.y-i,width:t.width,height:i+r};n.x=Math.min(n.x,s.x),n.y=Math.min(n.y,s.y),o.x=Math.max(o.x,s.x+s.width),o.y=Math.max(o.y,s.y+s.height)});const i=Math.max(o.x-n.x,200),r=o.y-n.y,d={x:n.x-25,y:n.y-25,width:i+50,height:r+50+30},l=a.rect(d.width,d.height,d.x,d.y);t.x=d.x+d.width/2,t.y=d.y+d.height/2,t.width=d.width,t.height=d.height,(0,s.AV)(l,s.M5.groupRect),t.style.stroke&&l.setAttribute("stroke",t.style.stroke),t.style.background&&l.setAttribute("fill",t.style.background);const c=a.text(t.name,{x:n.x,y:d.y+d.height-s.M5.groupText["font-size"]});(0,s.AV)(c,s.M5.groupText),t.style.color&&c.setAttribute("fill",t.style.color),e.append(l,c),t.ref=e}function F(t,e){let n={dst:Number.POSITIVE_INFINITY,pos:-1,edge:null,prj:null};return t.edges.forEach(t=>{const o=t.vertices||[],i=[t.from,...o,t.to];for(let o=1;o50||s3||Math.abs(d)>3)&&(u=!0,h=null,c)){const t=e.getSelection();t.length=0,t.push(c.node),e.setSelection(t),i=[{x:c.node.x,y:c.node.y,n:c.node}],c=null}if(s)!function(e,n){const i=o.querySelector("g.zoom");if(!i)return;const r=P(t);i.setAttribute("transform",`translate(${e}, ${n}) scale(${r})`)}(l.x+a,l.y+d);else if(i.length>0&&u){const t=e.getZoom(),n=a/t,o=d/t;i.forEach(t=>{e.moveNode(t.n,t.x+n,t.y+o)})}else r&&r.update(n)}(n=m(n),n.clientX-p.ex,n.clientY-p.ey)}function y(n){document.removeEventListener("touchmove",b),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",y),document.removeEventListener("touchend",y),function(n){const o=u?null:h;if(u&&(A=!0,window.setTimeout(()=>{A=!1},0)),c&&!u){const t=e.getSelection();t.length=0,t.push(c.node),e.setSelection(t)}if(r){const t=r.end();t?e.boxSelection(t,n.shiftKey):i.length||e.setSelection([]),r=null}s&&u&&O(t),c=null,h=null,u=!1,s=!1,e.updatePanning(),o&&(window.location.href=o)}(m(n)),p=null}function x(A){A=m(A),p={ex:A.clientX,ey:A.clientY},function(A){A.preventDefault(),u=!1,c=null;const g=A.target,f=g instanceof Element?g.closest("a.nodeLink"):null;h=A.shiftKey?null:f?.getAttribute("href")||null;const p=e.nodeFromEvent(A),m=A.shiftKey?"pan"===n?"select":"pan":n;if(p)if("pan"===m){s=!1,r=null;const t=e.getSelection();e.isSelected(p)?i=t.map(t=>({x:t.x,y:t.y,n:t})):(e.setSelection([p]),i=[{x:p.x,y:p.y,n:p}])}else{s=!1,r=null;const t=e.getSelection();if(A.shiftKey&&"select"===n){if(e.isSelected(p)){const e=t.findIndex(t=>t.id===p.id);e>=0&&t.splice(e,1)}else t.push(p);e.setSelection(t),i=t.map(t=>({x:t.x,y:t.y,n:t}))}else e.isSelected(p)?(i=t.map(t=>({x:t.x,y:t.y,n:t})),c=null):(c={node:p,shiftKey:A.shiftKey},i=[{x:p.x,y:p.y,n:p}])}else"pan"===m?(s=!0,r=null,a=A.clientX,d=A.clientY,l=function(){const t=o.querySelector("g.zoom");if(!t)return{x:0,y:0};const e=(t.getAttribute("transform")||"").match(/translate\(([^,]+),([^)]+)\)/);return e?{x:parseFloat(e[1])||0,y:parseFloat(e[2])||0}:{x:0,y:0}}(),i=[],e.setSelection([])):(s=!1,r=function(){let e=0,n=0,i=null;return{ini(r){const s=N(t,r);e=s.x,n=s.y,i=document.createElementNS("http://www.w3.org/2000/svg","rect"),i.setAttribute("fill","rgba(0, 100, 255, 0.1)"),i.setAttribute("stroke","rgba(0, 100, 255, 0.5)"),i.setAttribute("stroke-width","1"),i.setAttribute("stroke-dasharray","3,3"),i.setAttribute("x",String(e)),i.setAttribute("y",String(n)),i.setAttribute("width","0"),i.setAttribute("height","0");const a=o.querySelector("g.zoom");a?a.appendChild(i):o.appendChild(i)},update(o){if(!i)return;const r=N(t,o),s=r.x,a=r.y,d=Math.min(e,s),l=Math.min(n,a),c=Math.abs(s-e),h=Math.abs(a-n);i.setAttribute("x",String(d)),i.setAttribute("y",String(l)),i.setAttribute("width",String(c)),i.setAttribute("height",String(h))},end(){if(!i)return null;const t=parseFloat(i.getAttribute("x")||"0"),e=parseFloat(i.getAttribute("y")||"0"),n=parseFloat(i.getAttribute("width")||"0"),o=parseFloat(i.getAttribute("height")||"0");return i.remove(),i=null,n>5&&o>5?{x:t,y:e,width:n,height:o,left:t,top:e,right:t+n,bottom:e+o}:null}}}(),r&&r.ini(A),i=[])}(A),document.addEventListener("touchmove",b),document.addEventListener("mousemove",b),document.addEventListener("mouseup",y),document.addEventListener("touchend",y)}f.addEventListener("mousedown",x),f.addEventListener("touchstart",x),g.push({element:f,event:"mousedown",handler:x},{element:f,event:"touchstart",handler:x})}(o),o.addEventListener("click",f),g.push({element:o,event:"click",handler:f}),()=>{g.forEach(({element:t,event:e,handler:n})=>{t.removeEventListener(e,n)})}}function j(t,e){const n=t.svg,o=n.__cursorInteractionCleanup;o&&o();const i=[],r=e=>{t.changed()&&(e.preventDefault(),e.returnValue="")};function s(e,o){e.selected=o;const i=n.querySelector("#"+t.idPrefix+e.id);e.selected?i.classList.add("selected"):i.classList.remove("selected")}window.addEventListener("beforeunload",r),i.push({element:window,event:"beforeunload",handler:r});const d=e=>{if(!e.altKey)return;const o=F(t,N(t,e));if(o){const{prj:e}=o,i=n.querySelector("g.edges");let r=i.querySelector(`#${t.idPrefix}prj`);r||(r=a.element("circle",{id:`${t.idPrefix}prj`,cx:e.x,cy:e.y,r:7},"prj"),i.append(r)),r.setAttribute("cx",String(e.x)),r.setAttribute("cy",String(e.y))}else h()};n.addEventListener("mousemove",d),i.push({element:n,event:"mousemove",handler:d});const c=t=>{const e=(0,B.Yp)(t,!0);e!=B.Zj&&e!=B._s&&h()};function h(){const e=n.querySelector(`g.edges #${t.idPrefix}prj`);e&&e.parentElement.removeChild(e)}window.addEventListener("keyup",c),i.push({element:window,event:"keyup",handler:c});const u=e=>{const n=(0,B.Yp)(e,!0);if(n!=B._s&&n!=B.Zj)return;const o=F(t,N(t,e));if(o){const{edge:e,pos:i,prj:r}=o;t.insertEdgeVertex(e,r,i,n==B._s),h()}};n.addEventListener("click",u),i.push({element:n,event:"click",handler:u});const A=e=>{const o=.1*Math.sign(e.deltaY),i=P(t),r=Math.max(.1,Math.min(5,i-o));if(r!==i){const o=n.getBoundingClientRect(),i=e.clientX-o.left,s=e.clientY-o.top;R(t,r,i,s),e.preventDefault(),O(t)}};n.addEventListener("wheel",A),i.push({element:n,event:"wheel",handler:A});const g=e=>{const n=(0,B.Yp)(e);switch(n&&e.preventDefault(),n){case B.bl:Array.from(t.edgeVertices.values()).filter(t=>t.selected).forEach(e=>{t.deleteEdgeVertex(e)});break;case"undo":t.undo();break;case"redo":t.redo();break;case B.Ur:const e=Math.min(5,1.2*P(t));R(t,e),O(t);break;case B.hU:const n=Math.max(.1,P(t)/1.2);R(t,n),O(t);break;case B.i1:R(t,1),O(t);break;case B.mD:t.fitToView();break;case B.F:t.nodes().forEach(e=>t.setNodeSelected(e,!0)),t.edgeVertices.forEach(t=>s(t,!0));break;case B.Gn:t.nodes().forEach(e=>t.setNodeSelected(e,!1)),t.edgeVertices.forEach(t=>s(t,!1))}};window.addEventListener("keydown",g),i.push({element:window,event:"keydown",handler:g});const f=q(t,{nodeFromEvent(e){e.preventDefault();let n=e.target.closest("g.nodes g.node");return n?function(t){return t.__data}(n):(n=e.target.closest("g.edges g.edge .v-dot"),n?t.edgeVertices.get(n.id.slice(t.idPrefix.length)):null)},setSelection(e){t.nodes().forEach(n=>t.setNodeSelected(n,e.some(t=>t.id==n.id))),t.edgeVertices.forEach(t=>s(t,e.some(e=>e.id==t.id))),t.selectListener(t.nodes().find(t=>t.selected))},isSelected:t=>t.selected,getSelection(){const e=t.nodes().filter(t=>t.selected);return t.edgeVertices.forEach(t=>t.selected&&e.push(t)),e},getZoom:()=>P(t),moveNode(e,n,o){t.nodesMap.has(e.id)?t.moveNode(e,n,o):(e.auto=!1,t.moveEdgeVertex(e,n,o))},boxSelection(e,n){t.nodesMap.forEach(o=>{var i,r,s;(i={x:(s=o).x-s.width/2,y:s.y-s.height/2,width:s.width,height:s.height}).x<(r=e).x+r.width&&i.yr.x&&i.y+i.height>r.y?t.setNodeSelected(o,!o.selected):n||t.setNodeSelected(o,!1)}),t.edgeVertices.forEach(t=>{l(t,e,!1)?s(t,!t.selected):n||s(t,!1)}),t.selectListener(t.nodes().find(t=>t.selected))},updatePanning:()=>U(t)},e);n.__cursorInteractionCleanup=()=>{i.forEach(({element:t,event:e,handler:n})=>{t.removeEventListener(e,n)}),f&&f()}}function P(t){const e=t.svg.querySelector("g.zoom");if(!e)return 1;const n=(e.getAttribute("transform")||"").match(/scale\(([^)]+)\)/);return n&&parseFloat(n[1])||1}function R(t,e,n,o){const i=t.svg,r=i.querySelector("g.zoom"),s=P(t);if(void 0===n||void 0===o){const t=i.parentElement;t?(n=t.clientWidth/2,o=t.clientHeight/2):(n=i.clientWidth/2,o=i.clientHeight/2)}const a=W(t),d=n-(n-a.x)/s*e,l=o-(o-a.y)/s*e;r.setAttribute("transform",`translate(${d}, ${l}) scale(${e})`),U(t)}function W(t){const e=t.svg.querySelector("g.zoom");if(!e)return{x:0,y:0};const n=(e.getAttribute("transform")||"").match(/translate\(([^,]+),([^)]+)\)/);return n?{x:parseFloat(n[1])||0,y:parseFloat(n[2])||0}:{x:0,y:0}}function U(t){const e=t.svg,n=e.querySelector("g.zoom");if(!n)return;const o=n.getBBox(),i=P(t);if(!e.parentElement)return;const r=Math.max(e.parentElement.clientWidth/i,o.x+o.width+20),s=Math.max(e.parentElement.clientHeight/i,o.y+o.height+20);e.setAttribute("width",String(r*i)),e.setAttribute("height",String(s*i))}const G=(t,e)=>{"Dashed"==e?t.setAttribute("stroke-dasharray","4"):"Dotted"==e&&t.setAttribute("stroke-dasharray","2")},Y=new Map;function O(t){const e=P(t),n=W(t),o={zoom:e,transform:{x:n.x,y:n.y}};Y.set(t.id,o)}function H(t){if(!Y.has(t.id))return!1;const e=Y.get(t.id);if(!e)return!1;const n=t.svg.querySelector("g.zoom");return n&&(n.setAttribute("transform",`scale(${e.zoom}) translate(${e.transform.x}, ${e.transform.y})`),U(t)),!0}function Z(t){Y.delete(t.id)}},983(t,e,n){n.d(e,{k:()=>x,U:()=>w});var o=n(20);const i={direction:"DOWN",nodeSpacing:80,layerSpacing:80};async function r(t,e={}){const o=function(t,e){const n=new Map(t.nodes.map(t=>[t.id,t])),o=new Map(t.groups.map(t=>[t.id,t]));!function(t,e,n){for(const e of t.nodes)if(e.parentId&&!n.has(e.parentId))throw new Error(`node ${e.id} has missing parent group ${e.parentId}`);for(const e of t.groups)if(e.parentId&&!n.has(e.parentId))throw new Error(`group ${e.id} has missing parent group ${e.parentId}`);for(const n of t.edges)if(!e.has(n.sourceId)||!e.has(n.targetId))throw new Error(`edge ${n.id} connects missing node ${n.sourceId} or ${n.targetId}`)}(t,n,o);const i=new Map;for(const e of t.nodes)b(i,e.parentId,e);const r=new Map;for(const e of t.groups)b(r,e.parentId,e);const h=new Map,u=t=>{const n={id:t.id,children:[...(r.get(t.id)??[]).map(u),...(i.get(t.id)??[]).map(s)],edges:[],labels:[{text:t.id,width:t.titleSize.width,height:t.titleSize.height}],layoutOptions:l(e,t.titleSize.height)};return h.set(t.id,n),n},A={id:t.id,children:[...(r.get(void 0)??[]).map(u),...(i.get(void 0)??[]).map(s)],edges:[],layoutOptions:d(e)};for(const e of t.edges){const t=c(e,n,o),i=t?h.get(t):A;if(!i)throw new Error(`edge ${e.id} has missing layout group ${t}`);i.edges?.push(a(e))}return A}(t,{...i,...e}),r=new(await n.e(726).then(n.t.bind(n,862,23)).then(t=>t.default));return function(t,e){if(void 0===e.width||void 0===e.height)throw new Error(`ELK did not size diagram ${t.id}`);const n=[],o=[],i=[];return u(e,0,0,new Map(t.nodes.map(t=>[t.id,t])),new Map(t.groups.map(t=>[t.id,t])),n,o,i),{diagramId:t.id,bounds:{x:0,y:0,width:e.width,height:e.height},nodes:n,groups:o,edges:i}}(t,await r.layout(o))}function s(t){return{id:t.id,width:t.size.width,height:t.size.height,layoutOptions:{"elk.nodeSize.constraints":"FIXED_SIZE","elk.portConstraints":"FREE"}}}function a(t){return{id:t.id,sources:[t.sourceId],targets:[t.targetId],labels:t.labelSize?[{text:t.id,width:t.labelSize.width,height:t.labelSize.height,layoutOptions:{"elk.edgeLabels.inline":"false","elk.edgeLabels.placement":"CENTER"}}]:[]}}function d(t){return{"elk.algorithm":"layered","elk.direction":t.direction,"elk.edgeRouting":"ORTHOGONAL","elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.padding":"[top=40,left=40,bottom=40,right=40]","elk.spacing.nodeNode":String(t.nodeSpacing),"elk.spacing.componentComponent":String(t.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(t.layerSpacing),"elk.layered.spacing.edgeNodeBetweenLayers":"30","elk.layered.spacing.edgeEdgeBetweenLayers":"20","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.nodePlacement.favorStraightEdges":"true","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.unnecessaryBendpoints":"true","elk.edgeLabels.inline":"false","elk.edgeLabels.avoidOverlap":"true","elk.layered.edgeLabels.sideSelection":"SMART_DOWN","elk.spacing.edgeLabel":"12"}}function l(t,e){return{...d(t),"elk.padding":`[top=${e+30},left=30,bottom=30,right=30]`,"elk.nodeLabels.placement":"[H_LEFT,V_TOP,INSIDE]","elk.spacing.labelNode":"10"}}function c(t,e,n){const o=h(e.get(t.sourceId)?.parentId,n),i=new Set(h(e.get(t.targetId)?.parentId,n));return o.find(t=>i.has(t))}function h(t,e){const n=[];let o=t;for(;o;)n.push(o),o=e.get(o)?.parentId;return n}function u(t,e,n,o,i,r,s,a){const d=e+(t.x??0),l=n+(t.y??0);for(const e of t.children??[]){const t=d+f(e.x,e.id,"x"),n=l+f(e.y,e.id,"y"),c=f(e.width,e.id,"width"),h=f(e.height,e.id,"height"),A=o.get(e.id);if(A){r.push({id:e.id,parentId:A.parentId,bounds:{x:t,y:n,width:c,height:h}});continue}const g=i.get(e.id);if(!g)throw new Error(`ELK returned unknown node ${e.id}`);const p=m(e.labels?.[0],e.id);s.push({id:e.id,parentId:g.parentId,bounds:{x:t,y:n,width:c,height:h},titleBounds:{x:t+f(p.x,e.id,"title x"),y:n+f(p.y,e.id,"title y"),width:f(p.width,e.id,"title width"),height:f(p.height,e.id,"title height")}}),u(e,d,l,o,i,r,s,a)}for(const e of t.edges??[])a.push(A(e,d,l))}function A(t,e,n){const o=(t.sections??[]).map(t=>[g(t.startPoint,e,n),...(t.bendPoints??[]).map(t=>g(t,e,n)),g(t.endPoint,e,n)]),i=t.labels?.[0];return{id:t.id,sourceId:p(t.sources,t.id,"source"),targetId:p(t.targets,t.id,"target"),sections:o,labelBounds:i?{x:e+f(i.x,t.id,"label x"),y:n+f(i.y,t.id,"label y"),width:f(i.width,t.id,"label width"),height:f(i.height,t.id,"label height")}:void 0}}function g(t,e,n){return{x:e+t.x,y:n+t.y}}function f(t,e,n){if(void 0===t)throw new Error(`ELK omitted ${n} for ${e}`);return t}function p(t,e,n){if(1!==t.length)throw new Error(`ELK returned ${t.length} ${n}s for edge ${e}`);return t[0]}function m(t,e){if(!t)throw new Error(`ELK omitted title for group ${e}`);return t}function b(t,e,n){const o=t.get(e)??[];o.push(n),t.set(e,o)}n(108);var y=n(977);async function x(t,e={}){await document.fonts.ready;const n=C(t),i=e.compactLayout?56:80,s=await r(n,{direction:e.direction??t.layoutDirection??"DOWN",nodeSpacing:e.nodeSpacing??i,layerSpacing:e.layerSpacing??i}),a=(0,o.r)(n,s),d=new Map(n.nodes.map(t=>[t.id,t]));return{validated:a,nodes:a.nodes.map(t=>{const e=d.get(t.id);if(!e)throw new Error(`validated layout contains unknown node ${t.id}`);return{id:t.id,x:t.bounds.x+e.centerOffset.x,y:t.bounds.y+e.centerOffset.y}}),groups:a.groups.map(t=>({id:t.id,bounds:t.bounds,titleBounds:t.titleBounds})),edges:a.edges.map(t=>({id:t.id,sections:t.sections,labelBounds:t.labelBounds}))}}function w(t){const e=C(t),n=new Map(e.nodes.map(t=>[t.id,t])),i=t.nodes().map(t=>{const e=n.get(t.id);if(!e)throw new Error(`measured diagram omitted node ${t.id}`);return{id:t.id,parentId:e.parentId,bounds:{x:t.x-e.centerOffset.x,y:t.y-e.centerOffset.y,...e.size}}}),r=Array.from(t.groupsMap.values()).map(t=>{if(!t.ref?.isConnected)throw new Error(`group ${t.id} must be drawn before saving`);const n=t.ref.querySelector("rect"),o=t.ref.querySelector("text");if(!(n instanceof SVGGraphicsElement&&o instanceof SVGGraphicsElement))throw new Error(`group ${t.id} is missing its boundary or title`);return{id:t.id,parentId:e.groups.find(e=>e.id===t.id)?.parentId,bounds:k(n.getBBox()),titleBounds:k(o.getBBox())}}),s=t.edges.map(t=>{const e=t.layoutSections??[(0,y.l)(t)],n=t.layoutLabelBounds??t.labelBounds;if(t.label.trim().length>0&&!n)throw new Error(`edge ${t.id} is missing its label position`);return{id:t.id,sourceId:t.from.id,targetId:t.to.id,sections:e,labelBounds:n?{...n}:void 0}}),a={diagramId:t.id,bounds:I(i.map(t=>t.bounds),r,s),nodes:i,groups:r,edges:s};return function(t,e){return(0,o.r)(t,e)}(e,a)}function C(t){const{nodeParents:e,groupParents:n}=function(t){const e=new Map,n=new Map;for(const o of t.groupsMap.values())for(const t of o.nodes){const i=E(t)?n:e,r=i.get(t.id);if(r&&r!==o.id)throw new Error(`${E(t)?"group":"node"} ${t.id} belongs to both ${r} and ${o.id}`);i.set(t.id,o.id)}return{nodeParents:e,groupParents:n}}(t);return{id:t.id,nodes:t.nodes().map(t=>function(t,e){if(!t.ref?.isConnected)throw new Error(`node ${t.id} must be drawn before layout`);const n=t.ref.getBBox();return v(t.id,n),{id:t.id,parentId:e,size:{width:n.width,height:n.height},contentSize:{width:n.width,height:n.height},centerOffset:{x:-n.x,y:-n.y},shape:t.style.shape??"Box"}}(t,e.get(t.id))),groups:Array.from(t.groupsMap.values()).map(t=>function(t,e){if(!t.ref?.isConnected)throw new Error(`group ${t.id} must be drawn before layout`);const n=t.ref.querySelector("text");if(!(n instanceof SVGGraphicsElement))throw new Error(`group ${t.id} is missing its drawn title`);const o=n.getBBox();return v(t.id,o),{id:t.id,parentId:e,titleSize:{width:o.width,height:o.height}}}(t,n.get(t.id))),edges:t.edges.map(B)}}function B(t){const e=t.label.trim().length>0;if(e&&!t.labelBounds)throw new Error(`edge ${t.id} must be drawn before layout`);return{id:t.id,sourceId:t.from.id,targetId:t.to.id,labelSize:e?{width:t.labelBounds?.width??0,height:t.labelBounds?.height??0}:void 0}}function v(t,e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0)throw new Error(`browser returned invalid measured box for ${t}`)}function I(t,e,n){const o=[...t,...e.flatMap(t=>[t.bounds,t.titleBounds]),...n.flatMap(t=>t.labelBounds?[t.labelBounds]:[])],i=n.flatMap(t=>t.sections.flat());if(0===o.length&&0===i.length)return{x:0,y:0,width:0,height:0};const r=Math.min(...o.map(t=>t.x),...i.map(t=>t.x)),s=Math.min(...o.map(t=>t.y),...i.map(t=>t.y));return{x:r,y:s,width:Math.max(...o.map(t=>t.x+t.width),...i.map(t=>t.x))-r,height:Math.max(...o.map(t=>t.y+t.height),...i.map(t=>t.y))-s}}function k(t){return{x:t.x,y:t.y,width:t.width,height:t.height}}function E(t){return"nodes"in t}},718(t,e,n){n.d(e,{Mt:()=>r,U2:()=>a});const o=new Map;let i;async function r(){await Promise.all([400,600,700].map(t=>document.fonts.load(`${t} 22px Inter`))),await document.fonts.ready}function s(t,e){const n=function(t,e){const n=Object.entries(e).sort(([t],[e])=>t.localeCompare(e));return JSON.stringify([t,n])}(t,e),r=o.get(n);if(r)return r;const s=document.createElementNS("http://www.w3.org/2000/svg","text");s.setAttribute("x","0"),s.setAttribute("y","0");for(const[t,n]of Object.entries(e))s.setAttribute(t,n);s.textContent=t,(i?.isConnected||(i=document.createElementNS("http://www.w3.org/2000/svg","svg"),i.setAttribute("aria-hidden","true"),i.style.position="absolute",i.style.visibility="hidden",i.style.pointerEvents="none",document.body.appendChild(i)),i).appendChild(s);const a=s.getBBox();s.remove();const d={width:a.width,height:a.height};return o.set(n,d),d}function a(t,e,n){let o=0;return{lines:t.trim().split("\n").flatMap(t=>{const i=[];let r=[];for(const a of t.trim().split(/\s+/)){if(s(a,n).width>e){r.length>0&&(i.push(r.join(" ")),r=[]);const t=d(a,e,n);for(const e of t.slice(0,-1))i.push(e),o=Math.max(o,s(e,n).width);r=t.slice(-1);continue}const t=[...r,a],l=s(t.join(" "),n);l.width>e&&r.length>0?(i.push(r.join(" ")),r=[a]):(o=Math.max(o,l.width),r=t)}if(r.length>0){const t=r.join(" ");i.push(t),o=Math.max(o,s(t,n).width)}return i}),maxW:o}}function d(t,e,n){const o=[];let i="";for(const r of t){const t=i+r;s(t,n).width>e&&i.length>0?(o.push(i),i=r):i=t}return i.length>0&&o.push(i),o}},71(t,e,n){var o=n(108);const i={TopBottom:"DOWN",BottomTop:"UP",LeftRight:"RIGHT",RightLeft:"LEFT"};n.d(e,["B",0,t=>{const e=[];return Object.keys(t.views).filter(t=>t.endsWith("Views")).forEach(n=>{t.views[n].forEach(t=>{e.push({key:t.key,title:t.title||t.key,section:n})})}),e},"R",0,(t,e,n)=>{const r=new Map,s=new Map,a=t=>{Array.isArray(t.relationships)&&t.relationships.forEach(t=>{s.set(t.id,t)})};if(t.model.people&&t.model.people.forEach(t=>{r.set(t.id,t),Array.isArray(t.relationships)&&t.relationships.forEach(t=>{s.set(t.id,t)})}),t.model.softwareSystems&&t.model.softwareSystems.forEach(t=>{r.set(t.id,t),a(t),Array.isArray(t.containers)&&t.containers.forEach(e=>{e.parent=t,r.set(e.id,e),a(e),Array.isArray(e.components)&&e.components.forEach(t=>{t.parent=e,r.set(t.id,t),a(t)})})}),t.model.deploymentNodes){const e=t=>{t.containerInstances&&t.containerInstances.forEach(e=>{const n={...r.get(e.containerId),id:e.id};r.set(n.id,n),n.parent=t,a(e)})},n=(t,o)=>{t.parent=o,r.set(t.id,t),a(t),e(t),t.children&&t.children.forEach(e=>n(e,t)),t.infrastructureNodes&&t.infrastructureNodes.forEach(e=>n(e,t))};t.model.deploymentNodes.forEach(t=>n(t,null))}const{view:d,section:l}=function(t,e){let n=null,o="";return Object.keys(t.views).filter(t=>t.endsWith("Views")).some(i=>t.views[i].some(t=>{if(t.key==e)return n=t,o=i,!0})),{view:n,section:o}}(t,n);if(!d)return null;const c=new o.jg(d.key,d.title||d.key),h=d.automaticLayout?.rankDirection;c.layoutDirection=h?i[h]:void 0;const u={name:c.name,description:d.description,version:t.version,elements:[]};if(c.metadata=u,!d.elements)return c;const A={};if("deploymentViews"==l||"containerViews"==l)d.elements.forEach(t=>{const e=r.get(t.id);e?.parent&&(A[e.parent.id]=!0)});else if("componentViews"===l)d.elements.forEach(t=>{const e=r.get(t.id)?.parent;e?.components&&(e.id===d.containerId||d.externalContainersBoundariesVisible)&&(d.elements.some(t=>t.id===e.id)||(A[e.id]=!0))});else if(d.softwareSystemId)d.elements.find(t=>t.id==d.softwareSystemId)||(A[d.softwareSystemId]=!0);else if("systemLandscapeViews"==l){const e={id:"__enterprise__",...t.model.enterprise};r.set(e.id,e),t.model.people&&t.model.people.filter(t=>"External"!=t.location).forEach(t=>t.parent=e),t.model.softwareSystems&&t.model.softwareSystems.filter(t=>"External"!=t.location).forEach(t=>t.parent=e),A[e.id]=!0}const g=t.views.styles,f=t=>t.toLowerCase().replace(/[^a-z0-9-]/g,"-");g?.elements&&g.elements.forEach(t=>{if(t.tag){const e=`--mdl-${f(t.tag)}`;t.background&&c.colorToVarMap.set(t.background,`${e}-bg`),t.color&&c.colorToVarMap.set(t.color,`${e}-color`),t.stroke&&c.colorToVarMap.set(t.stroke,`${e}-stroke`)}}),g?.relationships&&g.relationships.forEach(t=>{if(t.tag){const e=`--mdl-rel-${f(t.tag)}`;t.color&&c.colorToVarMap.set(t.color,`${e}-color`)}}),d.elements.forEach(e=>{if(A[e.id])return;const n=r.get(e.id),o=n?function(t,e){const n=t.views.containerViews?.find(t=>t.softwareSystemId==e);return n?.key}(t,n.id):void 0;let i="",s={};if(n){const t=n.tags.split(",");i=t[t.length-1],n.technology&&(i+=": "+n.technology),t.forEach(t=>{const e=g&&g.elements&&g.elements.find(e=>e.tag==t);e&&(s={...s,...e})})}c.addNode(e.id,n&&n.name||e.id,i,n&&n.description?n.description:"",s,function(t,e){if(e){const t=encodeURIComponent(e);return{href:`?id=${t}`,exportHref:`${t}.svg`}}if(t?.url)return{href:t.url,exportHref:t.url}}(n,o)),n&&u.elements.push({id:n.id,tags:n.tags,location:n.location,properties:n.properties,elementViewKey:o,technology:n.technology,url:n.url})}),Array.isArray(d.relationships)&&d.relationships.forEach(t=>{const e=s.get(t.id);if(!e)return;if(!c.nodesMap.has(e.sourceId)){if(r.has(e.sourceId)){const t=r.get(e.sourceId);console.warn("Element not found in this view: ",t.id,t.name)}else console.warn("Element not found: ",e.sourceId);return}if(!c.nodesMap.has(e.destinationId)){if(r.has(e.destinationId)){const t=r.get(e.destinationId);console.warn("Element not found in this view: ",t.id,t.name)}else console.warn("Element not found: ",e.destinationId);return}let n={};e.tags.split(",").forEach(t=>{const e=g&&g.relationships&&g.relationships.find(e=>e.tag==t);e&&(n={...n,...e})}),t.routing&&(n.routing=t.routing);const o=e.technology?`${e.description}\n[${e.technology}]`:e.description;c.addEdge(e.id,e.sourceId,e.destinationId,o,t.vertices,n)});const p=t=>{let e=0;for(let n=t.parent;n;n=n.parent)e++;return e};return Object.keys(A).map(t=>r.get(t)).sort((t,e)=>p(t)>p(e)?-1:1).forEach(t=>{let e={};"deploymentViews"==l&&r.get(t.id).tags.split(",").forEach(t=>{const n=g&&g.elements&&g.elements.find(e=>e.tag==t);n&&(e={...e,...n})});const n=d.elements.map(t=>r.get(t.id)).filter(e=>!(!e||e.parent!==t||"systemLandscapeViews"===l&&"__enterprise__"===t.id&&"External"===e.location)).map(t=>t.id);n.length>0&&c.addGroup(t.id,t.name,n,e)}),c.init(e[c.id]),c}])},264(t,e,n){n(763);var o=n(686),i=n(987);const r="add-vertex",s="add-label-vertex",a="del-vertex",d="zoom-in",l="zoom-out",c="zoom-fit",h="zoom-100",u="select-all",A="deselect",g="move-left",f="move-right",p="move-up",m="move-down",b="move-left-fine",y="move-right-fine",x="move-up-fine",w="move-down-fine",C="toggle_drag_mode",B="align_horizontal",v="align_vertical",I="distribute_horizontal",k="distribute_vertical",E="auto_layout",S="reset_position",$="toggle_grid",M="toggle_snap_to_grid",L="snap_all_to_grid",_=[{name:"Help",list:[{id:"help",help:"Show/hide this help",combinations:[{key:"?",shift:!0},{key:"F1",shift:!0}]}]},{name:"File",list:[{id:"save",help:"Save",combinations:[{key:"s",ctrl:!0}]}]},{name:"History",list:[{id:"undo",help:"Undo",combinations:[{ctrl:!0,key:"z"}]},{id:"redo",help:"Redo",combinations:[{ctrl:!0,shift:!0,key:"z"},{ctrl:!0,key:"y"}]}]},{name:"Relationship editing",list:[{id:r,help:"Add relationship vertex",combinations:[{alt:!0,click:!0}]},{id:s,help:"Add label anchor relationship vertex",combinations:[{alt:!0,shift:!0,click:!0}]},{id:a,help:"Remove relationship vertex",combinations:[{key:"DELETE"},{key:"BACKSPACE"}]}]},{name:"Zoom",list:[{id:d,help:"Zoom in",combinations:[{ctrl:!0,key:"="}]},{id:l,help:"Zoom out",combinations:[{ctrl:!0,key:"-"}]},{id:c,help:"Zoom - fit",combinations:[{ctrl:!0,key:"9"}]},{id:h,help:"Zoom 100%",combinations:[{ctrl:!0,key:"0"}]},{id:"wheel_zoom",help:"Zoom in/out with mouse wheel",combinations:[{wheel:!0}]}]},{name:"Mouse Interactions",list:[{id:"pan-view",help:"Pan view (drag empty space)",combinations:[{click:!0}]},{id:"select-element",help:"Select element",combinations:[{click:!0}]},{id:"multi-select",help:"Add/remove from selection",combinations:[{shift:!0,click:!0}]},{id:"box-select",help:"Box selection (drag empty space)",combinations:[{shift:!0,click:!0}]},{id:"move-elements",help:"Move selected elements",combinations:[{click:!0}]}]},{name:"Select",list:[{id:u,help:"Select All",combinations:[{ctrl:!0,key:"a"}]},{id:A,help:"Deselect",combinations:[{key:"ESC"}]}]},{name:"Move",list:[{id:p,help:"Move up (grid increment)",combinations:[{key:"UP"}]},{id:x,help:"Move up (1 pixel)",combinations:[{key:"UP",shift:!0}]},{id:f,help:"Move right (grid increment)",combinations:[{key:"RIGHT"}]},{id:y,help:"Move right (1 pixel)",combinations:[{key:"RIGHT",shift:!0}]},{id:m,help:"Move down (grid increment)",combinations:[{key:"DOWN"}]},{id:w,help:"Move down (1 pixel)",combinations:[{key:"DOWN",shift:!0}]},{id:g,help:"Move left (grid increment)",combinations:[{key:"LEFT"}]},{id:b,help:"Move left (1 pixel)",combinations:[{key:"LEFT",shift:!0}]}]},{name:"View",list:[{id:C,help:"Toggle between pan and select mode",combinations:[{key:"t"}]},{id:S,help:"Reset position and view",combinations:[{key:"Home",ctrl:!0}]}]},{name:"Alignment",list:[{id:B,help:"Align selected elements horizontally",combinations:[{key:"h",ctrl:!0,shift:!0}]},{id:v,help:"Align selected elements vertically",combinations:[{key:"a",ctrl:!0,shift:!0}]},{id:I,help:"Distribute selected elements horizontally",combinations:[{key:"h",ctrl:!0,alt:!0}]},{id:k,help:"Distribute selected elements vertically",combinations:[{key:"v",ctrl:!0,alt:!0}]}]},{name:"Layout",list:[{id:E,help:"Auto layout all elements",combinations:[{key:"l",ctrl:!0}]}]},{name:"Grid",list:[{id:$,help:"Toggle grid visibility",combinations:[{key:"g",ctrl:!0}]},{id:M,help:"Toggle snap to grid",combinations:[{key:"g",ctrl:!0,shift:!0}]},{id:L,help:"Snap all elements to grid",combinations:[{key:"g",ctrl:!0,alt:!0}]}]}],D=_.reduce((t,e)=>t.concat(e.list),[]).reduce((t,e)=>(t[e.id]=e,t),{}),z=t=>[t.ctrl&&(0,o.sy)().toUpperCase(),t.shift&&"SHIFT",t.alt&&"ALT",t.key&&(t.key.length>1?t.key:`"${t.key.toUpperCase()}"`),t.click&&"CLICK",t.wheel&&"WHEEL"].filter(Boolean).join(" + ");n.d(e,["DE",0,I,"F",0,u,"Gg",0,g,"Gn",0,A,"Hd",0,E,"Help",0,()=>(0,i.jsxs)("div",{className:"popover",children:[(0,i.jsx)("h1",{children:"Shortcuts"}),(0,i.jsx)("table",{children:(0,i.jsx)("tbody",{children:_.map(t=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("tr",{children:(0,i.jsx)("th",{colSpan:2,children:t.name})}),t.list.map(t=>(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{children:t.combinations.map(z).join(", ")}),(0,i.jsx)("td",{children:t.help})]}))]}))})})]}),"J8",0,b,"Jk",0,v,"OE",0,L,"Op",0,$,"Ur",0,d,"Vy",0,k,"Yp",0,(t,e=!1,n=!1)=>{const i=Object.keys(D).filter(i=>((t,e,n,i)=>e.combinations.some(e=>{if(Boolean(e.shift)!=t.shiftKey)return!1;if(e.ctrl&&!(0,o.SA)(t))return!1;if(Boolean(e.alt)!=t.altKey)return!1;if(n)return e.click;if(i)return e.wheel;if(e.key){const n=t;return"DELETE"==e.key?"Delete"==n.key:"BACKSPACE"==e.key?"Backspace"==n.key:"ESC"==e.key?"Escape"==n.key:"UP"==e.key?"ArrowUp"==n.key:"DOWN"==e.key?"ArrowDown"==n.key:"LEFT"==e.key?"ArrowLeft"==n.key:"RIGHT"==e.key?"ArrowRight"==n.key:e.key&&n.key&&e.key.toLowerCase()==n.key.toLowerCase()}return!1}))(t,D[i],e,n));if(0!==i.length)return 1===i.length?i[0]:i.sort((t,e)=>{const n=D[t],o=D[e],i=n.combinations[0],r=o.combinations[0],s=(i.shift?1:0)+(i.ctrl?1:0)+(i.alt?1:0);return(r.shift?1:0)+(r.ctrl?1:0)+(r.alt?1:0)-s})[0]},"Zj",0,r,"_s",0,s,"_t",0,S,"aX",0,C,"b3",0,f,"bl",0,a,"hU",0,l,"hZ",0,M,"i1",0,h,"iD",0,y,"l8",0,x,"mD",0,c,"mt",0,w,"rB",0,m,"t9",0,B,"uK",0,p])},686(t,e,n){const o=()=>{if("undefined"==typeof navigator)return!1;if("userAgentData"in navigator&&navigator.userAgentData){const t=navigator.userAgentData.platform;if(t&&t.toLowerCase().includes("mac"))return!0}const t=navigator.userAgent.toLowerCase();if(t.includes("mac os")||t.includes("macintosh"))return!0;if(navigator.platform){const t=navigator.platform.toLowerCase();if(t.includes("mac")||t.includes("darwin"))return!0}try{if(void 0!==new KeyboardEvent("keydown",{metaKey:!0}).metaKey)return/mac|darwin|os x/i.test(navigator.userAgent)}catch(t){}return!1};n.d(e,["SA",0,t=>o()?t.metaKey:t.ctrlKey,"sy",0,()=>o()?"Cmd":"Ctrl"])},183(t,e,n){var o=n(220),i=n.n(o),r=n(716),s=n.n(r),a=n(247),d=n.n(a),l=new URL(n(390),n.b),c=new URL(n(513),n.b),h=new URL(n(568),n.b),u=new URL(n(483),n.b),A=s()(i()),g=d()(l),f=d()(c),p=d()(h),m=d()(u);A.push([t.id,`/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${g}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${f}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${p}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${m}) format("woff2");\n}\n`,"",{version:3,sources:["webpack://./src/fonts.css"],names:[],mappings:"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF",sourcesContent:['/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url("@fontsource/inter/files/inter-latin-400-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url("@fontsource/inter/files/inter-latin-500-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url("@fontsource/inter/files/inter-latin-600-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url("@fontsource/inter/files/inter-latin-700-normal.woff2") format("woff2");\n}\n'],sourceRoot:""}]);const b=A;n.d(e,["A",0,b])},870(t,e,n){var o=n(220),i=n.n(o),r=n(716),s=n.n(r)()(i());s.push([t.id,"html, body, #root {\n height: 100%;\n}\n\nbody {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n color: #666;\n margin: 0;\n}\n\n#root {\n display: flex;\n flex-direction: column;\n}\n#root > div.graph {\n flex: 1;\n overflow: auto;\n position: relative;\n}\n\n.toolbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 10px;\n background-color: #f0f0f0;\n border-bottom: 1px solid #cccccc;\n}\n\n.toolbar > div {\n display: flex;\n align-items: center;\n}\n\n.toolbar button {\n padding: 5px 8px;\n margin: 0 2px;\n cursor: pointer;\n}\n\n.toolbar button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Drag mode toggle button styles */\n.toolbar button.mode-toggle {\n position: relative;\n border: 1px solid #8f9fc9;\n width: 40px;\n min-height: 28px;\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\n border-color: #8f9fc9;\n color: white;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n}\n\n.toolbar button.mode-toggle:hover {\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\n border-color: #abb8db;\n}\n\n.toolbar button.mode-toggle.select-mode:active {\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\n}\n\n/* Pan mode and active toggle - darker blue */\n.toolbar button.mode-toggle.pan-mode,\n.toolbar button.active-toggle {\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n.toolbar button.mode-toggle.pan-mode:hover,\n.toolbar button.active-toggle:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\n.toolbar button.mode-toggle.pan-mode:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n/* Toggle buttons when inactive - gray styling */\n.toolbar button.inactive-toggle {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n.toolbar button.inactive-toggle:hover {\n background: #b1b1b1;\n}\n\n.toolbar button.inactive-toggle:active {\n background: #a1a1a1;\n}\n\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\n.toolbar button .fas {\n font-size: 1em;\n vertical-align: middle;\n}\n\n/* Zoom percentage display */\n.toolbar button.zoom-display {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n font-size: 11px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\n padding: 6px 8px;\n text-align: center;\n}\n\n.toolbar-group {\n display: flex;\n align-items: center;\n margin-right: 25px; /* Large space between groups */\n}\n\n.toolbar-group:last-child {\n margin-right: 0; /* Remove right margin from the last group (help button) */\n}\n\nbutton {\n border: none;\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n border-radius: 3px;\n padding: 6px 10px;\n color: #fff;\n outline: none;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n margin-right: 5px;\n min-width: 32px;\n min-height: 28px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n line-height: 1;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n position: relative;\n}\n\nbutton:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\nbutton:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n}\n\nbutton:last-child {\n margin-right: 0;\n}\n\n/* Save button when no changes - gray */\nbutton.action {\n background: #c1c1c1;\n color: #999;\n}\n\nbutton.action:active {\n background: #b1b1b1;\n}\n\n/* Save button when there are changes - orange */\nbutton.grp {\n background: linear-gradient(to bottom, #ee9564, #de7d48);\n margin-right: 0;\n}\n\nbutton.grp:active {\n background: #d67540;\n}\n\n/* Auto-arrange button with AI purple to blue gradient */\nbutton.auto-arrange {\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\n border-color: #4a4c93;\n}\n\nbutton.auto-arrange:hover {\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\n border-color: #5a5ca3;\n}\n\nbutton.auto-arrange:active {\n background: linear-gradient(135deg, #593B83, #357abd);\n border-color: #3a3c83;\n}\n\nselect {\n border: 1px solid #ccc;\n background: white;\n border-radius: 3px;\n padding: 3px 7px;\n color: #666;\n outline: none;\n margin-right: 5px;\n font-size: 12px;\n}\n\nselect:disabled {\n background: #f5f5f5;\n color: #999;\n}\n\nbutton:disabled {\n background: #c1c1c1;\n color: #999;\n}\n\n#root > div > svg {\n position: absolute;\n user-select: none;\n}\n\n\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\n stroke: #29c229;\n}\n.edge .v-dot {\n fill: transparent;\n stroke: transparent;\n stroke-width: 3px;\n cursor: pointer;\n transition: stroke 0.15s ease;\n}\n.edge .v-dot:hover {\n stroke: #999;\n fill: rgba(153, 153, 153, 0.1);\n}\n.edge .v-dot.selected {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.1);\n}\n.edge .v-dot.selected:hover {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.2);\n}\n.edge .v-dot.auto.selected {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.1);\n}\n.edge .v-dot.auto.selected:hover {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.2);\n}\ncircle.prj {\n fill: none;\n stroke: #777;\n}\n\n.nodeShadow {\n fill: none;\n stroke-width: 4px;\n stroke: rgba(0, 0, 0, 0.13);\n}\n\ng.node {\n user-select: none;\n cursor: default;\n}\n\ng.node.linked {\n cursor: pointer;\n}\n\ng.node text {\n pointer-events: none;\n}\n\n.icon {\n fill: #aaa;\n stroke: #fff;\n}\n\n/* Ensure all button icons are uncolored */\nbutton .icon,\nbutton svg,\nbutton path {\n fill: currentColor !important;\n stroke: none !important;\n}\n\n/* Font Awesome icon styling in buttons */\nbutton i {\n font-size: 12px;\n color: inherit;\n}\n\nrect.elastic {\n pointer-events: none;\n stroke: none;\n fill: #3bd8281f;\n display: none;\n}\nrect.elastic.on {\n display: block;\n}\n\n.popover {\n position: absolute;\n top: 50px;\n bottom: 10px;\n overflow: auto;\n right: 10px;\n background: ghostwhite;\n padding: 30px;\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\n border: solid 1px #eee;\n}\n\n.popover th {\n text-align: left;\n padding: 20px 0px 10px;\n}\n.popover td {\n padding-right: 20px;\n font-size: 14px;\n}\n\n/* Simple tooltip system with smart positioning */\n[data-tooltip] {\n position: relative;\n}\n\n[data-tooltip]:hover::after {\n content: attr(data-tooltip);\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(0, 0, 0, 0.9);\n color: white;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 12px !important;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n font-weight: normal !important;\n white-space: nowrap;\n z-index: 1000;\n pointer-events: none;\n margin-top: 5px;\n animation: tooltip-appear 0.1s ease-out;\n min-width: 120px;\n max-width: calc(100vw - 20px);\n box-sizing: border-box;\n}\n\n[data-tooltip]:hover::before {\n content: '';\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-bottom-color: rgba(0, 0, 0, 0.9);\n z-index: 1000;\n pointer-events: none;\n margin-top: 1px;\n animation: tooltip-appear 0.1s ease-out;\n}\n\n/* Special handling for rightmost elements that might overflow */\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 0;\n transform: none;\n}\n\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 16px;\n transform: none;\n}\n\n@keyframes tooltip-appear {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(-5px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\nselect {\n position: relative;\n}\n\n/* Robot shape internal elements - inherit stroke from parent node */\n.node .robot-eye-socket {\n fill: none;\n stroke: inherit;\n stroke-width: 2;\n}\n\n.node .robot-eye {\n fill: currentColor;\n stroke: none;\n}\n\n.node .robot-mouth {\n stroke: inherit;\n}\n\n.node .robot-antenna {\n stroke: inherit;\n}\n\n.node .robot-antenna-ball {\n fill: currentColor;\n stroke: inherit;\n stroke-width: 1.5;\n}\n\n.node .robot-panel {\n stroke: inherit;\n}\n\n.node .robot-indicator {\n fill: currentColor;\n stroke: none;\n}","",{version:3,sources:["webpack://./src/style.css"],names:[],mappings:"AAAA;IACI,YAAY;AAChB;;AAEA;IACI,uFAAuF;IACvF,WAAW;IACX,SAAS;AACb;;AAEA;IACI,aAAa;IACb,sBAAsB;AAC1B;AACA;IACI,OAAO;IACP,cAAc;IACd,kBAAkB;AACtB;;AAEA;IACI,aAAa;IACb,8BAA8B;IAC9B,mBAAmB;IACnB,iBAAiB;IACjB,yBAAyB;IACzB,gCAAgC;AACpC;;AAEA;IACI,aAAa;IACb,mBAAmB;AACvB;;AAEA;IACI,gBAAgB;IAChB,aAAa;IACb,eAAe;AACnB;;AAEA;IACI,YAAY;IACZ,mBAAmB;AACvB;;AAEA,mCAAmC;AACnC;IACI,kBAAkB;IAClB,yBAAyB;IACzB,WAAW;IACX,gBAAgB;IAChB,wDAAw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BAAgB;IAChB,sBAAsB;AAC1B;AACA;IACI,mBAAmB;IACnB,eAAe;AACnB;;AAEA,iDAAiD;AACjD;IACI,kBAAkB;AACtB;;AAEA;IACI,2BAA2B;IAC3B,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,2BAA2B;IAC3B,8BAA8B;IAC9B,YAAY;IACZ,iBAAiB;IACjB,kBAAkB;IAClB,0BAA0B;IAC1B,8EAA8E;IAC9E,8BAA8B;IAC9B,mBAAmB;IACnB,aAAa;IACb,oBAAoB;IACpB,eAAe;IACf,uCAAuC;IACvC,gBAAgB;IAChB,6BAA6B;IAC7B,sBAAsB;AAC1B;;AAEA;IACI,WAAW;IACX,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,2BAA2B;IAC3B,6BAA6B;IAC7B,uCAAuC;IACvC,aAAa;IACb,oBAAoB;IACpB,eAAe;IACf,uCAAuC;AAC3C;;AAEA,gEAAgE;AAChE;IACI,2DAA2D;IAC3D,UAAU;IACV,QAAQ;IACR,eAAe;AACnB;;AAEA;IACI,2DAA2D;IAC3D,UAAU;IACV,WAAW;IACX,eAAe;AACnB;;AAEA;IACI;QACI,UAAU;QACV,4CAA4C;IAChD;IACA;QACI,UAAU;QACV,yCAAyC;IAC7C;AACJ;;AAEA;IACI,kBAAkB;AACtB;;AAEA,oEAAoE;AACpE;IACI,UAAU;IACV,eAAe;IACf,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,YAAY;AAChB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,eAAe;IACf,iBAAiB;AACrB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,YAAY;AAChB",sourcesContent:["html, body, #root {\n height: 100%;\n}\n\nbody {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n color: #666;\n margin: 0;\n}\n\n#root {\n display: flex;\n flex-direction: column;\n}\n#root > div.graph {\n flex: 1;\n overflow: auto;\n position: relative;\n}\n\n.toolbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 10px;\n background-color: #f0f0f0;\n border-bottom: 1px solid #cccccc;\n}\n\n.toolbar > div {\n display: flex;\n align-items: center;\n}\n\n.toolbar button {\n padding: 5px 8px;\n margin: 0 2px;\n cursor: pointer;\n}\n\n.toolbar button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Drag mode toggle button styles */\n.toolbar button.mode-toggle {\n position: relative;\n border: 1px solid #8f9fc9;\n width: 40px;\n min-height: 28px;\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\n border-color: #8f9fc9;\n color: white;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n}\n\n.toolbar button.mode-toggle:hover {\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\n border-color: #abb8db;\n}\n\n.toolbar button.mode-toggle.select-mode:active {\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\n}\n\n/* Pan mode and active toggle - darker blue */\n.toolbar button.mode-toggle.pan-mode,\n.toolbar button.active-toggle {\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n.toolbar button.mode-toggle.pan-mode:hover,\n.toolbar button.active-toggle:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\n.toolbar button.mode-toggle.pan-mode:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n/* Toggle buttons when inactive - gray styling */\n.toolbar button.inactive-toggle {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n.toolbar button.inactive-toggle:hover {\n background: #b1b1b1;\n}\n\n.toolbar button.inactive-toggle:active {\n background: #a1a1a1;\n}\n\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\n.toolbar button .fas {\n font-size: 1em;\n vertical-align: middle;\n}\n\n/* Zoom percentage display */\n.toolbar button.zoom-display {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n font-size: 11px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\n padding: 6px 8px;\n text-align: center;\n}\n\n.toolbar-group {\n display: flex;\n align-items: center;\n margin-right: 25px; /* Large space between groups */\n}\n\n.toolbar-group:last-child {\n margin-right: 0; /* Remove right margin from the last group (help button) */\n}\n\nbutton {\n border: none;\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n border-radius: 3px;\n padding: 6px 10px;\n color: #fff;\n outline: none;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n margin-right: 5px;\n min-width: 32px;\n min-height: 28px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n line-height: 1;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n position: relative;\n}\n\nbutton:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\nbutton:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n}\n\nbutton:last-child {\n margin-right: 0;\n}\n\n/* Save button when no changes - gray */\nbutton.action {\n background: #c1c1c1;\n color: #999;\n}\n\nbutton.action:active {\n background: #b1b1b1;\n}\n\n/* Save button when there are changes - orange */\nbutton.grp {\n background: linear-gradient(to bottom, #ee9564, #de7d48);\n margin-right: 0;\n}\n\nbutton.grp:active {\n background: #d67540;\n}\n\n/* Auto-arrange button with AI purple to blue gradient */\nbutton.auto-arrange {\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\n border-color: #4a4c93;\n}\n\nbutton.auto-arrange:hover {\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\n border-color: #5a5ca3;\n}\n\nbutton.auto-arrange:active {\n background: linear-gradient(135deg, #593B83, #357abd);\n border-color: #3a3c83;\n}\n\nselect {\n border: 1px solid #ccc;\n background: white;\n border-radius: 3px;\n padding: 3px 7px;\n color: #666;\n outline: none;\n margin-right: 5px;\n font-size: 12px;\n}\n\nselect:disabled {\n background: #f5f5f5;\n color: #999;\n}\n\nbutton:disabled {\n background: #c1c1c1;\n color: #999;\n}\n\n#root > div > svg {\n position: absolute;\n user-select: none;\n}\n\n\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\n stroke: #29c229;\n}\n.edge .v-dot {\n fill: transparent;\n stroke: transparent;\n stroke-width: 3px;\n cursor: pointer;\n transition: stroke 0.15s ease;\n}\n.edge .v-dot:hover {\n stroke: #999;\n fill: rgba(153, 153, 153, 0.1);\n}\n.edge .v-dot.selected {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.1);\n}\n.edge .v-dot.selected:hover {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.2);\n}\n.edge .v-dot.auto.selected {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.1);\n}\n.edge .v-dot.auto.selected:hover {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.2);\n}\ncircle.prj {\n fill: none;\n stroke: #777;\n}\n\n.nodeShadow {\n fill: none;\n stroke-width: 4px;\n stroke: rgba(0, 0, 0, 0.13);\n}\n\ng.node {\n user-select: none;\n cursor: default;\n}\n\ng.node.linked {\n cursor: pointer;\n}\n\ng.node text {\n pointer-events: none;\n}\n\n.icon {\n fill: #aaa;\n stroke: #fff;\n}\n\n/* Ensure all button icons are uncolored */\nbutton .icon,\nbutton svg,\nbutton path {\n fill: currentColor !important;\n stroke: none !important;\n}\n\n/* Font Awesome icon styling in buttons */\nbutton i {\n font-size: 12px;\n color: inherit;\n}\n\nrect.elastic {\n pointer-events: none;\n stroke: none;\n fill: #3bd8281f;\n display: none;\n}\nrect.elastic.on {\n display: block;\n}\n\n.popover {\n position: absolute;\n top: 50px;\n bottom: 10px;\n overflow: auto;\n right: 10px;\n background: ghostwhite;\n padding: 30px;\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\n border: solid 1px #eee;\n}\n\n.popover th {\n text-align: left;\n padding: 20px 0px 10px;\n}\n.popover td {\n padding-right: 20px;\n font-size: 14px;\n}\n\n/* Simple tooltip system with smart positioning */\n[data-tooltip] {\n position: relative;\n}\n\n[data-tooltip]:hover::after {\n content: attr(data-tooltip);\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(0, 0, 0, 0.9);\n color: white;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 12px !important;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n font-weight: normal !important;\n white-space: nowrap;\n z-index: 1000;\n pointer-events: none;\n margin-top: 5px;\n animation: tooltip-appear 0.1s ease-out;\n min-width: 120px;\n max-width: calc(100vw - 20px);\n box-sizing: border-box;\n}\n\n[data-tooltip]:hover::before {\n content: '';\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-bottom-color: rgba(0, 0, 0, 0.9);\n z-index: 1000;\n pointer-events: none;\n margin-top: 1px;\n animation: tooltip-appear 0.1s ease-out;\n}\n\n/* Special handling for rightmost elements that might overflow */\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 0;\n transform: none;\n}\n\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 16px;\n transform: none;\n}\n\n@keyframes tooltip-appear {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(-5px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\nselect {\n position: relative;\n}\n\n/* Robot shape internal elements - inherit stroke from parent node */\n.node .robot-eye-socket {\n fill: none;\n stroke: inherit;\n stroke-width: 2;\n}\n\n.node .robot-eye {\n fill: currentColor;\n stroke: none;\n}\n\n.node .robot-mouth {\n stroke: inherit;\n}\n\n.node .robot-antenna {\n stroke: inherit;\n}\n\n.node .robot-antenna-ball {\n fill: currentColor;\n stroke: inherit;\n stroke-width: 1.5;\n}\n\n.node .robot-panel {\n stroke: inherit;\n}\n\n.node .robot-indicator {\n fill: currentColor;\n stroke: none;\n}"],sourceRoot:""}]);const a=s;n.d(e,["A",0,a])},74(t,e,n){var o=n(220),i=n.n(o),r=n(716),s=n.n(r),a=n(247),d=n.n(a),l=new URL(n(390),n.b),c=new URL(n(513),n.b),h=new URL(n(568),n.b),u=new URL(n(483),n.b),A=s()(i()),g=d()(l),f=d()(c),p=d()(h),m=d()(u);A.push([t.id,`/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${g}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${f}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${p}) format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${m}) format("woff2");\n}\n`,"",{version:3,sources:["webpack://./src/fonts.css"],names:[],mappings:"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF",sourcesContent:['/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url("@fontsource/inter/files/inter-latin-400-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url("@fontsource/inter/files/inter-latin-500-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url("@fontsource/inter/files/inter-latin-600-normal.woff2") format("woff2");\n}\n\n@font-face {\n\tfont-family: "Inter";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url("@fontsource/inter/files/inter-latin-700-normal.woff2") format("woff2");\n}\n'],sourceRoot:""}]);const b=A.toString();n.d(e,["A",0,b])},574(t,e,n){var o=n(582),i=n.n(o),r=n(991),s=n.n(r),a=n(725),d=n.n(a),l=n(798),c=n.n(l),h=n(754),u=n.n(h),A=n(567),g=n.n(A),f=n(183),p={};p.styleTagTransform=g(),p.setAttributes=c(),p.insert=d().bind(null,"head"),p.domAPI=s(),p.insertStyleElement=u(),i()(f.A,p),f.A&&f.A.locals&&f.A.locals},919(t,e,n){var o=n(582),i=n.n(o),r=n(991),s=n.n(r),a=n(725),d=n.n(a),l=n(798),c=n.n(l),h=n(754),u=n.n(h),A=n(567),g=n.n(A),f=n(870),p={};p.styleTagTransform=g(),p.setAttributes=c(),p.insert=d().bind(null,"head"),p.domAPI=s(),p.insertStyleElement=u(),i()(f.A,p),f.A&&f.A.locals&&f.A.locals}}]); //# sourceMappingURL=286.js.map \ No newline at end of file diff --git a/cmd/mdl/webapp/dist/286.js.map b/cmd/mdl/webapp/dist/286.js.map index 230738f3..9cc5ebd4 100644 --- a/cmd/mdl/webapp/dist/286.js.map +++ b/cmd/mdl/webapp/dist/286.js.map @@ -1 +1 @@ -{"version":3,"file":"286.js","mappings":"mGAwH0B,CAACA,EAAgBC,KAC1CC,OAAOC,QAAQF,GAAOG,QAAQ,EAAEC,EAAKC,MACpCN,EAAGO,aAAaF,EAAKG,OAAOF,cAxCJ,CACzBG,WAAY,CACX,eAAgB,KAEjBC,SAAU,CACT,cAAe,uDACfC,OAAQ,QAETC,SAAU,CACT,cAAe,uDACfD,OAAQ,QAETE,SAAU,CACTC,KAAM,OACNH,OAAQ,QAETI,UAAW,CACVD,KAAM,OACNH,OAAQ,UACR,eAAgB,IAChB,mBAAoB,OAErBK,UAAW,CACVF,KAAM,UACN,YAAa,GACb,cAAe,MACf,cAAe,uDACfG,OAAQ,mBAlDmC,CAC5CC,UAAW,EACXC,MAAO,UACPC,QAAS,EACTC,SAAU,GACVC,MAAO,IACPC,QAAQ,UA8DwB,CAACC,EAAWC,IACrCC,KAAKC,MAAMF,EAAGG,EAAIJ,EAAGI,IAAMH,EAAGG,EAAIJ,EAAGI,IAAMH,EAAGI,EAAIL,EAAGK,IAAMJ,EAAGI,EAAIL,EAAGK,WA5DhC,CAC5CP,MAAO,IACPQ,OAAQ,IACRC,WAAY,UACZZ,MAAO,UACPC,QAAS,EACTT,OAAQ,UACRU,SAAU,GACVW,MAAO,MACPC,UAAU,EACVC,aAAa,iECfP,SAASC,EAAsBC,GACrC,MAAMC,EAAKD,EAAKE,KAAMC,EAAKH,EAAKI,GAIhC,IAAIC,EAAoBL,EAAKK,SAAWL,EAAKK,SAASC,SAAW,GAIjED,EAASE,QAAQN,GACjBI,EAASG,KAAKL,GAEd,MAAMM,EAAWJ,EAASK,MAAM,GAAI,GAC9BC,EAAqBF,EAASG,KAAKC,IAAWA,EAAOC,QAAUX,EACrE,IAAIY,EA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AAOnG,QAAA,EAAAlH,QAAA,8BAAAsN,MAAA,GAAAC,SAAA,8TAAiYC,eAAA,62BAAw5BC,WAAA,MAEhyC,MAAAC,EAAeZ,EAAAhjB,iKCrCf6G,EAAA,GAEAA,EAAAgd,kBAA4BC,IAC5Bjd,EAAAkd,cAAwBC,IACxBnd,EAAA7O,OAAiBisB,IAAApO,KAAa,aAC9BhP,EAAAqd,OAAiBC,IACjBtd,EAAAud,mBAA6BC,IAEhBC,IAAIC,EAAAzZ,EAAOjE,GAKF0d,EAAAzZ,GAAWyZ,EAAAzZ,EAAO0Z,QAAUD,EAAAzZ,EAAO0Z,4ICbzD3d,EAAA,GAEAA,EAAAgd,kBAA4BC,IAC5Bjd,EAAAkd,cAAwBC,IACxBnd,EAAA7O,OAAiBisB,IAAApO,KAAa,aAC9BhP,EAAAqd,OAAiBC,IACjBtd,EAAAud,mBAA6BC,IAEhBC,IAAIG,EAAA3Z,EAAOjE,GAKF4d,EAAA3Z,GAAW2Z,EAAA3Z,EAAO0Z,QAAUC,EAAA3Z,EAAO0Z","sources":["webpack://app/./src/graph-view/constants.ts","webpack://app/./src/graph-view/edge-utils.ts","webpack://app/./src/graph-view/geometry.ts","webpack://app/./src/graph-view/svg-create.ts","webpack://app/./src/graph-view/intersect.ts","webpack://app/./src/graph-view/shapes.ts","webpack://app/./src/graph-view/undo.ts","webpack://app/./src/graph-view/node-content.ts","webpack://app/./src/graph-view/graph.ts","webpack://app/./src/graph-view/defs.ts","webpack://app/./src/graph-view/automatic-layout.ts","webpack://app/./src/graph-view/layout.ts","webpack://app/./src/graph-view/manual-layout.ts","webpack://app/./src/graph-view/svg-text.ts","webpack://app/./src/parseModel.ts","webpack://app/./src/shortcuts.tsx","webpack://app/./src/utils/platform.ts","webpack://app/./src/fonts.css","webpack://app/./src/style.css","webpack://app/./src/fonts.css?0e2c","webpack://app/./src/fonts.css?a158","webpack://app/./src/style.css?dd02"],"sourcesContent":["// Constants and default configurations for the graph view\n\nexport interface Point {\n\tx: number;\n\ty: number;\n}\n\nexport interface BBox extends Point {\n\twidth: number;\n\theight: number;\n}\n\nexport interface NodeStyle {\n\t// Width of element, in pixels.\n\twidth?: number\n\t// Height of element, in pixels.\n\theight?: number\n\t// Background color of element as HTML RGB hex string (e.g. \"#ffffff\")\n\tbackground?: string\n\t// Stroke color of element as HTML RGB hex string (e.g. \"#000000\")\n\tstroke?: string\n\t// Foreground (text) color of element as HTML RGB hex string (e.g. \"#ffffff\")\n\tcolor?: string\n\t// Standard font size used to render text, in pixels.\n\tfontSize?: number\n\t// Shape used to render element.\n\tshape?: string\n\t// URL of PNG/JPG/GIF file or Base64 data URI representation.\n\ticon?: string\n\t// Type of border used to render element.\n\tborder?: string\n\t// Opacity used to render element; 0-100.\n\topacity?: number\n\t// Whether element metadata should be shown.\n\tmetadata?: boolean\n\t// Whether element description should be shown.\n\tdescription?: boolean\n}\n\nexport interface EdgeStyle {\n\t// Thickness of line, in pixels.\n\tthickness?: number\n\t// Color of line as HTML RGB hex string (e.g. \"#ffffff\").\n\tcolor?: string\n\t// Standard font size used to render relationship annotation, in pixels.\n\tfontSize?: number\n\t// Width of relationship annotation, in pixels.\n\twidth?: number\n\t// Whether line is dashed.\n\tdashed?: boolean\n\t// Position of label along edge (0-100).\n\tposition?: number\n\t// Opacity used to render relationship; 0-100.\n\topacity?: number\n\t// Arrow style for the edge.\n\tarrowStyle?: 'normal' | 'large' | 'small' | 'none'\n}\n\n// Default styles\nexport const DEFAULT_EDGE_STYLE: EdgeStyle = {\n\tthickness: 2,\n\tcolor: '#64748b',\n\topacity: 1,\n\tfontSize: 18,\n\twidth: 200,\n\tdashed: true,\n};\n\nexport const DEFAULT_NODE_STYLE: NodeStyle = {\n\twidth: 280,\n\theight: 180,\n\tbackground: '#ffffff',\n\tcolor: '#334155',\n\topacity: 1,\n\tstroke: '#8492a6',\n\tfontSize: 22,\n\tshape: 'Box',\n\tmetadata: true,\n\tdescription: true,\n};\n\n// SVG styles\nexport const SVG_STYLES = {\n\tnodeBorder: {\n\t\t'stroke-width': 1.5,\n\t},\n\tnodeText: {\n\t\t'font-family': 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',\n\t\tstroke: \"none\"\n\t},\n\tedgeText: {\n\t\t'font-family': 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',\n\t\tstroke: \"none\"\n\t},\n\tedgeRect: {\n\t\tfill: \"none\",\n\t\tstroke: \"none\",\n\t},\n\tgroupRect: {\n\t\tfill: \"none\",\n\t\tstroke: \"#8492a6\",\n\t\t'stroke-width': 1.5,\n\t\t\"stroke-dasharray\": \"6 4\",\n\t},\n\tgroupText: {\n\t\tfill: \"#475569\",\n\t\t\"font-size\": 20,\n\t\t\"font-weight\": \"600\",\n\t\t'font-family': 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',\n\t\tcursor: \"default\"\n\t}\n};\n\n// Configuration constants\nexport const SVG_PADDING = 20;\nexport const DEFAULT_GRID_SIZE = 25;\nexport const EDGE_SPREAD_DISTANCE = 70;\nexport const EDGE_SPREAD_DISTANCE_X = 200;\n\n// Set presentation attributes so an author's later attributes override defaults.\nexport const applyStyle = (el: SVGElement, style: { [key: string]: string | number }) => {\n\tObject.entries(style).forEach(([key, value]) => {\n\t\tel.setAttribute(key, String(value));\n\t});\n};\n\n// Utility function to calculate distance between two points\nexport const calculateDistance = (p1: Point, p2: Point): number => {\n\treturn Math.sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));\n};\n","import { Point, calculateDistance } from './constants';\nimport { Segment } from './intersect';\n\n// Define interfaces locally since they're not exported from graph.ts\ninterface NodeStyle {\n\tbackground?: string;\n\tstroke?: string;\n\topacity?: number;\n\tfontSize?: number;\n\tshape?: string;\n\tborder?: string;\n}\n\ninterface Node extends Point {\n\tid: string;\n\ttitle: string;\n\tsub: string;\n\tdescription: string;\n\twidth: number;\n\theight: number;\n\tref?: SVGGElement;\n\tselected?: boolean;\n\tintersect: (p: Point) => Point;\n\tstyle: NodeStyle;\n}\n\ninterface EdgeVertex extends Point {\n\tid: string;\n\tselected?: boolean;\n\tref?: SVGElement;\n\tlabel?: boolean;\n\tauto?: boolean;\n}\n\ninterface EdgeStyle {\n\tcolor?: string;\n\tthickness?: number;\n\tfontSize?: number;\n\tposition?: number;\n\tdashed?: boolean;\n}\n\ninterface Edge {\n\tid: string;\n\tlabel: string;\n\tfrom: Node;\n\tto: Node;\n\tvertices?: EdgeVertex[];\n\tref?: SVGGElement;\n\tstyle: EdgeStyle;\n\tinitVertex: (p: Point) => EdgeVertex;\n\tuserDeletedVertices?: boolean; // Track if user explicitly deleted vertices\n}\n\nexport interface EdgeLabelPlacement extends Point {\n\torientation: 'horizontal' | 'vertical';\n\tsegment?: Segment;\n\tmovable: boolean;\n}\n\n/**\n * Calculate edge vertices, handling multi-edge scenarios and auto-vertices\n */\nexport function calculateEdgeVertices(edge: Edge): Point[] {\n\tconst n1 = edge.from, n2 = edge.to;\n\t\n\t\n\t// if vertices exists, follow them\n\tlet vertices: Point[] = edge.vertices ? edge.vertices.concat() : [];\n\t// Don't remove label vertices - they should be preserved for rendering\n\t// (The autoLayout process handles replacing old ones with new ones)\n\n\tvertices.unshift(n1)\n\tvertices.push(n2)\n\n\tconst interior = vertices.slice(1, -1) as EdgeVertex[];\n\tconst firstRoutingVertex = interior.find(vertex => !vertex.label) ?? n2;\n\tlet lastRoutingVertex: Point = n1;\n\tfor (let index = interior.length - 1; index >= 0; index--) {\n\t\tif (!interior[index].label) {\n\t\t\tlastRoutingVertex = interior[index];\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!n1.intersect || !n2.intersect) {\n\t\tthrow new Error(`edge ${edge.id} nodes must be drawn before routing`);\n\t}\n\tvertices[0] = n1.intersect(firstRoutingVertex);\n\tvertices[vertices.length - 1] = n2.intersect(lastRoutingVertex);\n\t\n\treturn vertices;\n}\n\n/**\n * Calculate the label anchor and the orientation of the path segment that owns\n * it. Renderers use the orientation to place text beside the relationship line\n * instead of centering text over vertical segments.\n */\nexport function calculateLabelPlacement(\n\tvertices: Point[],\n\tposition: number,\n\tdefaultPoint: Point,\n): EdgeLabelPlacement {\n\tlet point = {x: defaultPoint.x, y: defaultPoint.y};\n\tlet segment: Segment | undefined;\n\tconst labelIndex = vertices.findIndex(vertex => (vertex as EdgeVertex).label);\n\tlet movable = true;\n\n\tif (labelIndex >= 0) {\n\t\tconst labelVertex = vertices[labelIndex] as EdgeVertex;\n\t\tpoint = labelVertex;\n\t\tmovable = labelVertex.auto === true;\n\t\tconst adjacentSegments: Segment[] = [];\n\t\tif (labelIndex > 0) {\n\t\t\tadjacentSegments.push({p: vertices[labelIndex - 1], q: point});\n\t\t}\n\t\tif (labelIndex < vertices.length - 1) {\n\t\t\tadjacentSegments.push({p: point, q: vertices[labelIndex + 1]});\n\t\t}\n\t\tsegment = adjacentSegments.reduce((longest, candidate) => {\n\t\t\tif (!longest) {\n\t\t\t\treturn candidate;\n\t\t\t}\n\t\t\treturn calculateDistance(candidate.p, candidate.q) >\n\t\t\t\tcalculateDistance(longest.p, longest.q)\n\t\t\t\t? candidate\n\t\t\t\t: longest;\n\t\t}, undefined);\n\t} else {\n\t\tconst totalLength = vertices.slice(1).reduce(\n\t\t\t(sum, vertex, index) => sum + calculateDistance(vertices[index], vertex),\n\t\t\t0,\n\t\t);\n\t\tconst targetLength = totalLength * position;\n\t\tlet traversed = 0;\n\t\tfor (let index = 1; index < vertices.length; index++) {\n\t\t\tconst candidate = {p: vertices[index - 1], q: vertices[index]};\n\t\t\tconst length = calculateDistance(candidate.p, candidate.q);\n\t\t\tif (length > 0 && traversed + length >= targetLength) {\n\t\t\t\tconst segmentPosition = (targetLength - traversed) / length;\n\t\t\t\tpoint = {\n\t\t\t\t\tx: candidate.p.x + (candidate.q.x - candidate.p.x) * segmentPosition,\n\t\t\t\t\ty: candidate.p.y + (candidate.q.y - candidate.p.y) * segmentPosition,\n\t\t\t\t};\n\t\t\t\tsegment = candidate;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ttraversed += length;\n\t\t}\n\t}\n\n\tconst horizontalDistance = segment ? Math.abs(segment.q.x - segment.p.x) : 0;\n\tconst verticalDistance = segment ? Math.abs(segment.q.y - segment.p.y) : 0;\n\treturn {\n\t\t...point,\n\t\torientation: verticalDistance > horizontalDistance ? 'vertical' : 'horizontal',\n\t\tsegment,\n\t\tmovable,\n\t};\n}\n\n/** createEdgePath draws the given points without cutting or moving the route. */\nexport function createEdgePath(vertices: Point[]): string {\n\tif (vertices.length < 2) {\n\t\tthrow new Error(\"edge route must contain at least two points\");\n\t}\n\treturn vertices.slice(1).reduce(\n\t\t(path, point) => `${path} L${point.x},${point.y}`,\n\t\t`M${vertices[0].x},${vertices[0].y}`,\n\t);\n}","// This file defines the diagram sizes and positions shared by layout and SVG\n// drawing. Automatic and manual layout both produce ResolvedLayout. The SVG\n// drawing code accepts a layout only after this file has checked it.\n\n/** Point is one position in the diagram. */\nexport interface Point {\n\tx: number;\n\ty: number;\n}\n\n/** Size is a width and height. Both values must be zero or greater. */\nexport interface Size {\n\twidth: number;\n\theight: number;\n}\n\n/** Rect is a box that does not rotate. */\nexport interface Rect extends Point, Size {}\n\n/** MeasuredNode holds the exact box and text sizes needed before layout. */\nexport interface MeasuredNode {\n\tid: string;\n\tparentId?: string;\n\tsize: Size;\n\tcontentSize: Size;\n\tcenterOffset: Point;\n\tshape: string;\n}\n\n/** MeasuredGroup describes a boundary that must contain its children and title. */\nexport interface MeasuredGroup {\n\tid: string;\n\tparentId?: string;\n\ttitleSize: Size;\n}\n\n/** MeasuredEdge names the two connected nodes and the exact label size. */\nexport interface MeasuredEdge {\n\tid: string;\n\tsourceId: string;\n\ttargetId: string;\n\tlabelSize?: Size;\n}\n\n/**\n * MeasuredDiagram is the complete input to automatic or manual layout.\n * It contains sizes, but no positions.\n */\nexport interface MeasuredDiagram {\n\tid: string;\n\tnodes: MeasuredNode[];\n\tgroups: MeasuredGroup[];\n\tedges: MeasuredEdge[];\n}\n\n/** ResolvedNode is one measured node placed in the diagram. */\nexport interface ResolvedNode {\n\tid: string;\n\tparentId?: string;\n\tbounds: Rect;\n}\n\n/** ResolvedGroup is one placed boundary and its title box. */\nexport interface ResolvedGroup {\n\tid: string;\n\tparentId?: string;\n\tbounds: Rect;\n\ttitleBounds: Rect;\n}\n\n/**\n * ResolvedEdge contains a complete route. Each section is an ordered list of\n * points. labelBounds is the final label box chosen by layout.\n */\nexport interface ResolvedEdge {\n\tid: string;\n\tsourceId: string;\n\ttargetId: string;\n\tsections: Point[][];\n\tlabelBounds?: Rect;\n}\n\n/**\n * ResolvedLayout is the unchecked result of automatic or manual layout.\n * Drawing code must not use it directly.\n */\nexport interface ResolvedLayout {\n\tdiagramId: string;\n\tbounds: Rect;\n\tnodes: ResolvedNode[];\n\tgroups: ResolvedGroup[];\n\tedges: ResolvedEdge[];\n}\n\n/** GeometryIssueCode names one rule that the layout broke. */\nexport type GeometryIssueCode =\n\t| \"duplicate_id\"\n\t| \"missing_element\"\n\t| \"unexpected_element\"\n\t| \"non_finite\"\n\t| \"size_mismatch\"\n\t| \"content_overflow\"\n\t| \"node_overlap\"\n\t| \"group_overlap\"\n\t| \"false_containment\"\n\t| \"edge_through_node\"\n\t| \"edge_through_group\"\n\t| \"label_node_overlap\"\n\t| \"label_label_overlap\"\n\t| \"label_edge_overlap\"\n\t| \"label_title_overlap\"\n\t| \"out_of_bounds\"\n\t| \"disconnected_edge\";\n\n/** GeometryIssue reports the stable IDs of the affected diagram elements. */\nexport interface GeometryIssue {\n\tcode: GeometryIssueCode;\n\telementIds: string[];\n\tmessage: string;\n}\n\nconst validatedLayoutBrand: unique symbol = Symbol(\"ValidatedLayout\");\n\n/**\n * ValidatedLayout is the only layout the SVG drawing code accepts. The private\n * marker prevents other code from creating one without running the checks.\n */\nexport type ValidatedLayout = ResolvedLayout & {\n\treadonly [validatedLayoutBrand]: true;\n};\n\n/** GeometryValidationError reports every layout problem found in one check. */\nexport class GeometryValidationError extends Error {\n\treadonly issues: GeometryIssue[];\n\n\tconstructor(issues: GeometryIssue[]) {\n\t\tsuper(issues.map(issue => issue.message).join(\"\\n\"));\n\t\tthis.name = \"GeometryValidationError\";\n\t\tthis.issues = issues;\n\t}\n}\n\n/**\n * validateResolvedLayout checks that every element is present, every number is\n * valid, boundaries show true ownership, elements do not collide, and all\n * content stays inside the diagram.\n */\nexport function validateResolvedLayout(\n\tmeasured: MeasuredDiagram,\n\tresolved: ResolvedLayout,\n): ValidatedLayout {\n\tconst issues: GeometryIssue[] = [];\n\tif (measured.id !== resolved.diagramId) {\n\t\tissues.push(issue(\n\t\t\t\"missing_element\",\n\t\t\t[measured.id, resolved.diagramId],\n\t\t\t`layout ${resolved.diagramId} does not resolve measured diagram ${measured.id}`,\n\t\t));\n\t}\n\n\tcheckUniqueIDs(\"measured node\", measured.nodes.map(node => node.id), issues);\n\tcheckUniqueIDs(\"measured group\", measured.groups.map(group => group.id), issues);\n\tcheckUniqueIDs(\"measured edge\", measured.edges.map(edge => edge.id), issues);\n\tcheckUniqueIDs(\"resolved node\", resolved.nodes.map(node => node.id), issues);\n\tcheckUniqueIDs(\"resolved group\", resolved.groups.map(group => group.id), issues);\n\tcheckUniqueIDs(\"resolved edge\", resolved.edges.map(edge => edge.id), issues);\n\n\tcheckCoverage(\n\t\t\"node\",\n\t\tmeasured.nodes.map(node => node.id),\n\t\tresolved.nodes.map(node => node.id),\n\t\tissues,\n\t);\n\tcheckCoverage(\n\t\t\"group\",\n\t\tmeasured.groups.map(group => group.id),\n\t\tresolved.groups.map(group => group.id),\n\t\tissues,\n\t);\n\tcheckCoverage(\n\t\t\"edge\",\n\t\tmeasured.edges.map(edge => edge.id),\n\t\tresolved.edges.map(edge => edge.id),\n\t\tissues,\n\t);\n\n\tconst measuredNodes = new Map(measured.nodes.map(node => [node.id, node]));\n\tconst measuredGroups = new Map(measured.groups.map(group => [group.id, group]));\n\tconst resolvedNodes = new Map(resolved.nodes.map(node => [node.id, node]));\n\tconst resolvedGroups = new Map(resolved.groups.map(group => [group.id, group]));\n\n\tcheckFiniteRect(\"diagram\", resolved.diagramId, resolved.bounds, issues);\n\tfor (const node of resolved.nodes) {\n\t\tcheckFiniteRect(\"node\", node.id, node.bounds, issues);\n\t\tconst expected = measuredNodes.get(node.id);\n\t\tif (expected && (\n\t\t\t!nearlyEqual(expected.size.width, node.bounds.width) ||\n\t\t\t!nearlyEqual(expected.size.height, node.bounds.height)\n\t\t)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"size_mismatch\",\n\t\t\t\t[node.id],\n\t\t\t\t`node ${node.id} size changed after measurement`,\n\t\t\t));\n\t\t}\n\t\tif (expected && (\n\t\t\texpected.contentSize.width > node.bounds.width ||\n\t\t\texpected.contentSize.height > node.bounds.height\n\t\t)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"content_overflow\",\n\t\t\t\t[node.id],\n\t\t\t\t`node ${node.id} content exceeds its resolved bounds`,\n\t\t\t));\n\t\t}\n\t\tcheckRectInBounds(\"node\", node.id, node.bounds, resolved.bounds, issues);\n\t}\n\tfor (const group of resolved.groups) {\n\t\tcheckFiniteRect(\"group\", group.id, group.bounds, issues);\n\t\tcheckFiniteRect(\"group title\", group.id, group.titleBounds, issues);\n\t\tcheckRectInBounds(\"group\", group.id, group.bounds, resolved.bounds, issues);\n\t\tif (!contains(group.bounds, group.titleBounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[group.id],\n\t\t\t\t`group ${group.id} does not contain its title`,\n\t\t\t));\n\t\t}\n\t\tconst expected = measuredGroups.get(group.id);\n\t\tif (expected && (\n\t\t\t!nearlyEqual(expected.titleSize.width, group.titleBounds.width) ||\n\t\t\t!nearlyEqual(expected.titleSize.height, group.titleBounds.height)\n\t\t)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"size_mismatch\",\n\t\t\t\t[group.id],\n\t\t\t\t`group ${group.id} title size changed after measurement`,\n\t\t\t));\n\t\t}\n\t}\n\n\tcheckNodeOverlaps(resolved.nodes, issues);\n\tcheckGroupOverlaps(resolved.groups, issues);\n\tcheckOwnership(\n\t\tmeasured.nodes,\n\t\tmeasured.groups,\n\t\tresolvedNodes,\n\t\tresolvedGroups,\n\t\tissues,\n\t);\n\tcheckEdges(\n\t\tmeasured,\n\t\tresolved,\n\t\tresolvedNodes,\n\t\tresolvedGroups,\n\t\tmeasuredNodes,\n\t\tmeasuredGroups,\n\t\tissues,\n\t);\n\n\tif (issues.length > 0) {\n\t\tthrow new GeometryValidationError(issues);\n\t}\n\treturn resolved as ValidatedLayout;\n}\n\n/** checkUniqueIDs requires each model ID to appear only once. */\nfunction checkUniqueIDs(label: string, ids: string[], issues: GeometryIssue[]): void {\n\tconst seen = new Set();\n\tfor (const id of ids) {\n\t\tif (seen.has(id)) {\n\t\t\tissues.push(issue(\"duplicate_id\", [id], `${label} ${id} is duplicated`));\n\t\t}\n\t\tseen.add(id);\n\t}\n}\n\n/** checkCoverage rejects missing elements and old elements left in a layout. */\nfunction checkCoverage(\n\tlabel: string,\n\texpected: string[],\n\tactual: string[],\n\tissues: GeometryIssue[],\n): void {\n\tconst expectedIDs = new Set(expected);\n\tconst actualIDs = new Set(actual);\n\tfor (const id of expectedIDs) {\n\t\tif (!actualIDs.has(id)) {\n\t\t\tissues.push(issue(\"missing_element\", [id], `${label} ${id} is missing from resolved layout`));\n\t\t}\n\t}\n\tfor (const id of actualIDs) {\n\t\tif (!expectedIDs.has(id)) {\n\t\t\tissues.push(issue(\"unexpected_element\", [id], `${label} ${id} is not in the measured diagram`));\n\t\t}\n\t}\n}\n\n/** checkFiniteRect rejects invalid numbers and negative sizes. */\nfunction checkFiniteRect(\n\tlabel: string,\n\tid: string,\n\trect: Rect,\n\tissues: GeometryIssue[],\n): void {\n\tif (!isFiniteRect(rect) || rect.width < 0 || rect.height < 0) {\n\t\tissues.push(issue(\"non_finite\", [id], `${label} ${id} has invalid geometry`));\n\t}\n}\n\n/** checkRectInBounds requires the whole box to fit inside the diagram. */\nfunction checkRectInBounds(\n\tlabel: string,\n\tid: string,\n\trect: Rect,\n\tbounds: Rect,\n\tissues: GeometryIssue[],\n): void {\n\tif (!contains(bounds, rect)) {\n\t\tissues.push(issue(\"out_of_bounds\", [id], `${label} ${id} lies outside the resolved view bounds`));\n\t}\n}\n\n/** checkNodeOverlaps prevents two nodes from sharing the same area. */\nfunction checkNodeOverlaps(nodes: ResolvedNode[], issues: GeometryIssue[]): void {\n\tforEachPair(nodes, (first, second) => {\n\t\tif (overlaps(first.bounds, second.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"node_overlap\",\n\t\t\t\t[first.id, second.id],\n\t\t\t\t`nodes ${first.id} and ${second.id} overlap`,\n\t\t\t));\n\t\t}\n\t});\n}\n\n/**\n * checkGroupOverlaps allows one real boundary inside another, but rejects\n * boundaries that partly cover each other and suggest false ownership.\n */\nfunction checkGroupOverlaps(groups: ResolvedGroup[], issues: GeometryIssue[]): void {\n\tforEachPair(groups, (first, second) => {\n\t\tif (\n\t\t\toverlaps(first.bounds, second.bounds) &&\n\t\t\t!contains(first.bounds, second.bounds) &&\n\t\t\t!contains(second.bounds, first.bounds)\n\t\t) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"group_overlap\",\n\t\t\t\t[first.id, second.id],\n\t\t\t\t`groups ${first.id} and ${second.id} partially overlap`,\n\t\t\t));\n\t\t}\n\t});\n}\n\n/**\n * checkOwnership requires each child to be inside the parent named by the\n * model. Visual overlap never creates ownership.\n */\nfunction checkOwnership(\n\tnodes: MeasuredNode[],\n\tgroups: MeasuredGroup[],\n\tresolvedNodes: Map,\n\tresolvedGroups: Map,\n\tissues: GeometryIssue[],\n): void {\n\tfor (const node of nodes) {\n\t\tconst child = resolvedNodes.get(node.id);\n\t\tif (child && child.parentId !== node.parentId) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[node.id],\n\t\t\t\t`node ${node.id} has the wrong parent ID`,\n\t\t\t));\n\t\t}\n\t\tif (!node.parentId) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst parent = resolvedGroups.get(node.parentId);\n\t\tif (child && parent && !contains(parent.bounds, child.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[node.id, node.parentId],\n\t\t\t\t`node ${node.id} lies outside owning group ${node.parentId}`,\n\t\t\t));\n\t\t}\n\t}\n\tfor (const group of groups) {\n\t\tconst child = resolvedGroups.get(group.id);\n\t\tif (child && child.parentId !== group.parentId) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[group.id],\n\t\t\t\t`group ${group.id} has the wrong parent ID`,\n\t\t\t));\n\t\t}\n\t\tif (!group.parentId) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst parent = resolvedGroups.get(group.parentId);\n\t\tif (child && parent && !contains(parent.bounds, child.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[group.id, group.parentId],\n\t\t\t\t`group ${group.id} lies outside owning group ${group.parentId}`,\n\t\t\t));\n\t\t}\n\t}\n}\n\n/**\n * checkEdges checks connected node IDs, complete routes, crossings, labels,\n * and boundary crossings for every relationship.\n */\nfunction checkEdges(\n\tmeasured: MeasuredDiagram,\n\tresolved: ResolvedLayout,\n\tnodes: Map,\n\tgroups: Map,\n\tmeasuredNodes: Map,\n\tmeasuredGroups: Map,\n\tissues: GeometryIssue[],\n): void {\n\tconst measuredEdges = new Map(measured.edges.map(edge => [edge.id, edge]));\n\tconst labels: Array<{id: string; bounds: Rect}> = [];\n\tfor (const edge of resolved.edges) {\n\t\tconst expected = measuredEdges.get(edge.id);\n\t\tif (!expected) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\tedge.sourceId !== expected.sourceId ||\n\t\t\tedge.targetId !== expected.targetId\n\t\t) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"disconnected_edge\",\n\t\t\t\t[edge.id, edge.sourceId, edge.targetId],\n\t\t\t\t`edge ${edge.id} endpoints do not match its measured contract`,\n\t\t\t));\n\t\t}\n\t\tif (edge.sections.length === 0 || edge.sections.some(section => section.length < 2)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"disconnected_edge\",\n\t\t\t\t[edge.id],\n\t\t\t\t`edge ${edge.id} has no complete route section`,\n\t\t\t));\n\t\t\tcontinue;\n\t\t}\n\t\tcheckSectionConnections(edge, nodes, issues);\n\t\tfor (const section of edge.sections) {\n\t\t\tfor (const point of section) {\n\t\t\t\tif (!isFinitePoint(point) || !pointInRect(point, resolved.bounds, true)) {\n\t\t\t\t\tissues.push(issue(\n\t\t\t\t\t\t\"out_of_bounds\",\n\t\t\t\t\t\t[edge.id],\n\t\t\t\t\t\t`edge ${edge.id} has a route point outside the resolved view`,\n\t\t\t\t\t));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const node of nodes.values()) {\n\t\t\tif (node.id === edge.sourceId || node.id === edge.targetId) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (routeIntersectsRect(edge.sections, inset(node.bounds, 0.5))) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"edge_through_node\",\n\t\t\t\t\t[edge.id, node.id],\n\t\t\t\t\t`edge ${edge.id} crosses unrelated node ${node.id}`,\n\t\t\t\t));\n\t\t\t}\n\t\t}\n\t\tfor (const group of groups.values()) {\n\t\t\tconst sourceInside = belongsToGroup(\n\t\t\t\tedge.sourceId,\n\t\t\t\tgroup.id,\n\t\t\t\tmeasuredNodes,\n\t\t\t\tmeasuredGroups,\n\t\t\t);\n\t\t\tconst targetInside = belongsToGroup(\n\t\t\t\tedge.targetId,\n\t\t\t\tgroup.id,\n\t\t\t\tmeasuredNodes,\n\t\t\t\tmeasuredGroups,\n\t\t\t);\n\t\t\tif (\n\t\t\t\tsourceInside === targetInside &&\n\t\t\t\trouteViolatesGroup(edge.sections, group.bounds, sourceInside)\n\t\t\t) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"edge_through_group\",\n\t\t\t\t\t[edge.id, group.id],\n\t\t\t\t\t`edge ${edge.id} violates group ${group.id} boundary`,\n\t\t\t\t));\n\t\t\t}\n\t\t}\n\t\tif (edge.labelBounds) {\n\t\t\tcheckFiniteRect(\"edge label\", edge.id, edge.labelBounds, issues);\n\t\t\tcheckRectInBounds(\"edge label\", edge.id, edge.labelBounds, resolved.bounds, issues);\n\t\t\tif (expected.labelSize && (\n\t\t\t\t!nearlyEqual(expected.labelSize.width, edge.labelBounds.width) ||\n\t\t\t\t!nearlyEqual(expected.labelSize.height, edge.labelBounds.height)\n\t\t\t)) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"size_mismatch\",\n\t\t\t\t\t[edge.id],\n\t\t\t\t\t`edge ${edge.id} label size changed after measurement`,\n\t\t\t\t));\n\t\t\t}\n\t\t\tfor (const node of nodes.values()) {\n\t\t\t\tif (overlaps(edge.labelBounds, node.bounds)) {\n\t\t\t\t\tissues.push(issue(\n\t\t\t\t\t\t\"label_node_overlap\",\n\t\t\t\t\t\t[edge.id, node.id],\n\t\t\t\t\t\t`edge ${edge.id} label overlaps node ${node.id}`,\n\t\t\t\t\t));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const group of groups.values()) {\n\t\t\t\tif (overlaps(edge.labelBounds, group.titleBounds)) {\n\t\t\t\t\tissues.push(issue(\n\t\t\t\t\t\t\"label_title_overlap\",\n\t\t\t\t\t\t[edge.id, group.id],\n\t\t\t\t\t\t`edge ${edge.id} label overlaps group ${group.id} title`,\n\t\t\t\t\t));\n\t\t\t\t}\n\t\t\t}\n\t\t\tlabels.push({id: edge.id, bounds: edge.labelBounds});\n\t\t} else if (expected.labelSize) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"missing_element\",\n\t\t\t\t[edge.id],\n\t\t\t\t`edge ${edge.id} is missing its measured label`,\n\t\t\t));\n\t\t}\n\t}\n\tforEachPair(labels, (first, second) => {\n\t\tif (overlaps(first.bounds, second.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"label_label_overlap\",\n\t\t\t\t[first.id, second.id],\n\t\t\t\t`edge labels ${first.id} and ${second.id} overlap`,\n\t\t\t));\n\t\t}\n\t});\n\tfor (const label of labels) {\n\t\tfor (const edge of resolved.edges) {\n\t\t\tif (routeIntersectsRect(edge.sections, inset(label.bounds, 0.5))) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"label_edge_overlap\",\n\t\t\t\t\t[label.id, edge.id],\n\t\t\t\t\t`edge ${edge.id} crosses label ${label.id}`,\n\t\t\t\t));\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * checkSectionConnections requires one ordered route from the source border to\n * the target border. Separate or reversed sections are not a complete route.\n */\nfunction checkSectionConnections(\n\tedge: ResolvedEdge,\n\tnodes: Map,\n\tissues: GeometryIssue[],\n): void {\n\tfor (let index = 1; index < edge.sections.length; index++) {\n\t\tconst previous = edge.sections[index - 1].slice(-1)[0];\n\t\tconst current = edge.sections[index][0];\n\t\tif (!samePoint(previous, current)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"disconnected_edge\",\n\t\t\t\t[edge.id],\n\t\t\t\t`edge ${edge.id} has disconnected route sections`,\n\t\t\t));\n\t\t\treturn;\n\t\t}\n\t}\n\tconst source = nodes.get(edge.sourceId);\n\tconst target = nodes.get(edge.targetId);\n\tconst start = edge.sections[0][0];\n\tconst end = edge.sections.slice(-1)[0].slice(-1)[0];\n\tif (\n\t\t!source ||\n\t\t!target ||\n\t\t!pointOnBorder(start, source.bounds) ||\n\t\t!pointOnBorder(end, target.bounds)\n\t) {\n\t\tissues.push(issue(\n\t\t\t\"disconnected_edge\",\n\t\t\t[edge.id, edge.sourceId, edge.targetId],\n\t\t\t`edge ${edge.id} does not connect both node borders`,\n\t\t));\n\t}\n}\n\n/** belongsToGroup follows parent IDs to decide whether a node belongs to a group. */\nfunction belongsToGroup(\n\tnodeId: string,\n\tgroupId: string,\n\tnodes: Map,\n\tgroups: Map,\n): boolean {\n\tlet parent = nodes.get(nodeId)?.parentId;\n\twhile (parent) {\n\t\tif (parent === groupId) {\n\t\t\treturn true;\n\t\t}\n\t\tparent = groups.get(parent)?.parentId;\n\t}\n\treturn false;\n}\n\n/**\n * routeViolatesGroup checks the middle of each line. When both connected nodes\n * are inside a group, the line must stay inside it. When both are outside, the\n * line must stay outside it.\n */\nfunction routeViolatesGroup(\n\tsections: Point[][],\n\tgroup: Rect,\n\tshouldBeInside: boolean,\n): boolean {\n\tfor (const section of sections) {\n\t\tfor (let index = 1; index < section.length; index++) {\n\t\t\tconst midpoint = {\n\t\t\t\tx: (section[index - 1].x + section[index].x) / 2,\n\t\t\t\ty: (section[index - 1].y + section[index].y) / 2,\n\t\t\t};\n\t\t\tif (pointInRect(midpoint, group, false) !== shouldBeInside) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\n/** routeIntersectsRect reports whether any part of a route enters a box. */\nfunction routeIntersectsRect(sections: Point[][], rect: Rect): boolean {\n\treturn sections.some(section => section.some((point, index) =>\n\t\tindex > 0 && segmentIntersectsRect(section[index - 1], point, rect),\n\t));\n}\n\n/**\n * segmentIntersectsRect checks both straight and diagonal lines. A line may\n * touch the box border, but it may not enter the box.\n */\nfunction segmentIntersectsRect(start: Point, end: Point, rect: Rect): boolean {\n\tconst dx = end.x - start.x;\n\tconst dy = end.y - start.y;\n\tlet minimum = 0;\n\tlet maximum = 1;\n\tfor (const [origin, delta, lower, upper] of [\n\t\t[start.x, dx, rect.x, rect.x + rect.width],\n\t\t[start.y, dy, rect.y, rect.y + rect.height],\n\t] as const) {\n\t\tif (Math.abs(delta) < Number.EPSILON) {\n\t\t\tif (origin <= lower || origin >= upper) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst first = (lower - origin) / delta;\n\t\tconst second = (upper - origin) / delta;\n\t\tminimum = Math.max(minimum, Math.min(first, second));\n\t\tmaximum = Math.min(maximum, Math.max(first, second));\n\t\tif (minimum >= maximum) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn maximum > 0 && minimum < 1;\n}\n\n/** overlaps treats touching borders as contact, not shared area. */\nfunction overlaps(first: Rect, second: Rect): boolean {\n\treturn (\n\t\tfirst.x < second.x + second.width &&\n\t\tsecond.x < first.x + first.width &&\n\t\tfirst.y < second.y + second.height &&\n\t\tsecond.y < first.y + first.height\n\t);\n}\n\n/** contains requires the whole inner box to be inside the outer box. */\nfunction contains(outer: Rect, inner: Rect): boolean {\n\treturn (\n\t\touter.x <= inner.x &&\n\t\touter.y <= inner.y &&\n\t\touter.x + outer.width >= inner.x + inner.width &&\n\t\touter.y + outer.height >= inner.y + inner.height\n\t);\n}\n\n/** pointInRect can include or exclude points that only touch the border. */\nfunction pointInRect(point: Point, rect: Rect, inclusive: boolean): boolean {\n\tif (inclusive) {\n\t\treturn (\n\t\t\tpoint.x >= rect.x &&\n\t\t\tpoint.y >= rect.y &&\n\t\t\tpoint.x <= rect.x + rect.width &&\n\t\t\tpoint.y <= rect.y + rect.height\n\t\t);\n\t}\n\treturn (\n\t\tpoint.x > rect.x &&\n\t\tpoint.y > rect.y &&\n\t\tpoint.x < rect.x + rect.width &&\n\t\tpoint.y < rect.y + rect.height\n\t);\n}\n\n/** inset makes a box smaller so touching its border does not count as crossing it. */\nfunction inset(rect: Rect, amount: number): Rect {\n\treturn {\n\t\tx: rect.x + amount,\n\t\ty: rect.y + amount,\n\t\twidth: Math.max(0, rect.width - amount * 2),\n\t\theight: Math.max(0, rect.height - amount * 2),\n\t};\n}\n\n/** isFinitePoint accepts only real numbers that SVG can draw. */\nfunction isFinitePoint(point: Point): boolean {\n\treturn Number.isFinite(point.x) && Number.isFinite(point.y);\n}\n\n/** isFiniteRect checks all four numbers in a box. */\nfunction isFiniteRect(rect: Rect): boolean {\n\treturn isFinitePoint(rect) && Number.isFinite(rect.width) && Number.isFinite(rect.height);\n}\n\n/** samePoint compares route points while allowing tiny browser number changes. */\nfunction samePoint(first: Point, second: Point): boolean {\n\treturn nearlyEqual(first.x, second.x) && nearlyEqual(first.y, second.y);\n}\n\n/** pointOnBorder checks that a route endpoint touches one side of a node box. */\nfunction pointOnBorder(point: Point, rect: Rect): boolean {\n\tconst withinX = point.x >= rect.x - 0.1 && point.x <= rect.x + rect.width + 0.1;\n\tconst withinY = point.y >= rect.y - 0.1 && point.y <= rect.y + rect.height + 0.1;\n\tconst onVertical = nearlyEqual(point.x, rect.x) ||\n\t\tnearlyEqual(point.x, rect.x + rect.width);\n\tconst onHorizontal = nearlyEqual(point.y, rect.y) ||\n\t\tnearlyEqual(point.y, rect.y + rect.height);\n\treturn (withinY && onVertical) || (withinX && onHorizontal);\n}\n\n/** nearlyEqual hides only browser rounding smaller than one tenth of a unit. */\nfunction nearlyEqual(first: number, second: number): boolean {\n\treturn Math.abs(first - second) <= 0.1;\n}\n\n/** forEachPair compares each pair once. */\nfunction forEachPair(items: T[], visit: (first: T, second: T) => void): void {\n\tfor (let first = 0; first < items.length; first++) {\n\t\tfor (let second = first + 1; second < items.length; second++) {\n\t\t\tvisit(items[first], items[second]);\n\t\t}\n\t}\n}\n\n/** issue creates one layout problem report. */\nfunction issue(\n\tcode: GeometryIssueCode,\n\telementIds: string[],\n\tmessage: string,\n): GeometryIssue {\n\treturn {code, elementIds, message};\n}\n","import {svgTextWrap} from \"./svg-text\";\nimport {SVG_STYLES} from \"./constants\";\n\nexport const create = {\n\telement(type: string, attrs: Record = {}, className?: string) {\n\t\tconst el = document.createElementNS('http://www.w3.org/2000/svg', type);\n\t\tObject.entries(attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n\t\tif (className) el.classList.add(className);\n\t\treturn el;\n\t},\n\n\tuse(id: string, attrs: Record = {}) {\n\t\tconst el = this.element('use', attrs);\n\t\tel.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#' + id);\n\t\treturn el;\n\t},\n\n\tpath(path: string, attrs: Record = {}, className?: string) {\n\t\tconst p = this.element(\"path\", {...attrs, d: path}, className);\n\t\treturn p;\n\t},\n\n\ttext(text: string, attrs: Record = {}) {\n\t\tconst t = this.element('text', attrs) as SVGTextElement;\n\t\tif (text) t.textContent = text;\n\t\treturn t;\n\t},\n\n\ttextArea(text: string, width: number, fontSize: number, bold: boolean, x = 0, y = 0, anchor = '') {\n\t\tconst attrs: Record = {\n\t\t\t'font-family': SVG_STYLES.edgeText['font-family'],\n\t\t\t'font-size': `${fontSize}px`,\n\t\t\t'font-weight': bold ? 'bold' : 'normal'\n\t\t};\n\t\tconst {lines, maxW} = svgTextWrap(text, width, attrs);\n\t\tconst txt = this.text('', {x: 0, y, 'text-anchor': anchor || undefined});\n\t\t\n\t\tlines.forEach((line, i) => {\n\t\t\tconst span = this.element('tspan', {x, dy: `${fontSize + 2}px`, ...attrs});\n\t\t\tspan.textContent = line;\n\t\t\ttxt.append(span);\n\t\t});\n\t\t\n\t\treturn {txt, dy: (lines.length + 1) * (fontSize + 2), maxW};\n\t},\n\n\trect(width: number, height: number, x = 0, y = 0, r = 0, className?: string) {\n\t\treturn this.element('rect', {x, y, rx: r, ry: r, width, height}, className) as SVGRectElement;\n\t},\n\n\ticon(icon: string, x = 0, y = 0) {\n\t\treturn this.use(icon, {x, y});\n\t},\n\n\texpand(x: number, y: number, expanded: boolean) {\n\t\tconst g = this.element('g', {transform: `translate(${x},${y})`}, 'expand') as SVGGElement;\n\t\tg.append(\n\t\t\tthis.rect(19, 19, 0, 0, 1),\n\t\t\tthis.text(expanded ? '-' : '+', {x: 10, y: 14, 'text-anchor': 'middle'})\n\t\t);\n\t\treturn g;\n\t}\n};\n\nexport function setPosition(g: SVGGElement, x: number, y: number) {\n\tg.setAttribute('transform', `translate(${x},${y})`);\n}\n","interface Point {\n\tx: number;\n\ty: number;\n}\n\ninterface BBox extends Point {\n\twidth: number;\n\theight: number;\n}\n\n\nexport function insideBox(p: Point, b: BBox, centeredBox = true): boolean {\n\treturn centeredBox ?\n\t\t(p.x > b.x - b.width / 2 && p.x < b.x + b.width / 2 && p.y > b.y - b.height / 2 && p.y < b.y + b.height / 2) :\n\t\t(p.x > b.x && p.x < b.x + b.width && p.y > b.y && p.y < b.y + b.height)\n}\n\nexport function boxesOverlap(b1: BBox, b2: BBox): boolean {\n\treturn b1.x < b2.x + b2.width && b1.y < b2.y + b2.height && b1.x + b1.width > b2.x && b1.y + b1.height > b2.y\n}\n\nexport function uncenterBox(b: BBox): BBox {\n\treturn {x: b.x - b.width / 2, y: b.y - b.height / 2, width: b.width, height: b.height}\n}\n\nexport function scaleBox(b: BBox, sc: number): BBox {\n\treturn {x: b.x * sc, y: b.y * sc, width: b.width * sc, height: b.height * sc}\n}\n\n// intersect 2 segments (p1->q1) with (p2, q2)\n// if the lines intersect, the result contains the x and y of the intersection (treating the lines as infinite)\n// and booleans for whether line segment 1 or line segment 2 contain the point\nfunction segmentIntersection(p1: Point, q1: Point, p2: Point, q2: Point) {\n\tlet denominator, a, b, numerator1, numerator2,\n\t\tresult: { x: number, y: number, onLine1: boolean, onLine2: boolean } = {\n\t\t\tx: null,\n\t\t\ty: null,\n\t\t\tonLine1: false,\n\t\t\tonLine2: false\n\t\t};\n\tdenominator = (q2.y - p2.y) * (q1.x - p1.x) - (q2.x - p2.x) * (q1.y - p1.y);\n\tif (denominator == 0) {\n\t\treturn result;\n\t}\n\ta = p1.y - p2.y;\n\tb = p1.x - p2.x;\n\tnumerator1 = ((q2.x - p2.x) * a) - ((q2.y - p2.y) * b);\n\tnumerator2 = ((q1.x - p1.x) * a) - ((q1.y - p1.y) * b);\n\ta = numerator1 / denominator;\n\tb = numerator2 / denominator;\n\n\t// if we cast these lines infinitely in both directions, they intersect here:\n\tresult.x = p1.x + (a * (q1.x - p1.x));\n\tresult.y = p1.y + (a * (q1.y - p1.y));\n\n\t// if line1 is a segment and line2 is infinite, they intersect if:\n\tif (a > 0 && a < 1) {\n\t\tresult.onLine1 = true;\n\t}\n\t// if line2 is a segment and line1 is infinite, they intersect if:\n\tif (b >= 0 && b <= 1) {\n\t\tresult.onLine2 = true;\n\t}\n\t// if line1 and line2 are segments, they intersect if both of the above are true\n\treturn result;\n}\n\n// intersects a segment (p1->p2) with a box\nexport function intersectRectFull(p1: Point, p2: Point, box: BBox): Point[] {\n\tconst w = box.width / 2\n\tconst h = box.height / 2\n\tconst segs: { p: Point; q: Point }[] = [\n\t\t{p: {x: box.x - w, y: box.y - h}, q: {x: box.x - w, y: box.y + h}},\n\t\t{p: {x: box.x - w, y: box.y - h}, q: {x: box.x + w, y: box.y - h}},\n\t\t{p: {x: box.x + w, y: box.y - h}, q: {x: box.x + w, y: box.y + h}},\n\t\t{p: {x: box.x - w, y: box.y + h}, q: {x: box.x + w, y: box.y + h}},\n\t]\n\treturn segs.map(s => segmentIntersection(p1, p2, s.p, s.q)).filter(ret => ret.onLine1 && ret.onLine2)\n}\n\n// intersects a line that goes from p to the center of the box\nexport function intersectRect(box: BBox, p: Point): Point {\n\tif (insideBox(p, box)) return {x: box.x, y: box.y}\n\treturn intersectRectFull(box, p, box)[0] || {x: box.x, y: box.y}\n}\n\nexport function intersectEllipse(ellCenter: Point, rx: number, ry: number, nodeCenter: Point, point: Point) {\n\n\t//translate all to center ellipse\n\tconst p1 = {x: point.x - ellCenter.x, y: point.y - ellCenter.y}\n\tconst p2 = {x: nodeCenter.x - ellCenter.x, y: nodeCenter.y - ellCenter.y}\n\n\tif (p2.x == p1.x) { //hack to avoid singularity\n\t\tp1.x += .0000001\n\t}\n\n\tconst s = (p2.y - p1.y) / (p2.x - p1.x);\n\tconst si = p2.y - (s * p2.x);\n\tconst a = (ry * ry) + (rx * rx * s * s);\n\tconst b = 2 * rx * rx * si * s;\n\tconst c = rx * rx * si * si - rx * rx * ry * ry;\n\n\tconst radicand_sqrt = Math.sqrt((b * b) - (4 * a * c));\n\tconst x = p1.x > p2.x ?\n\t\t(-b + radicand_sqrt) / (2 * a) :\n\t\t(-b - radicand_sqrt) / (2 * a)\n\tconst pos = {\n\t\tx: x,\n\t\ty: s * x + si\n\t}\n\t//translate back\n\tpos.x += ellCenter.x;\n\tpos.y += ellCenter.y\n\n\treturn pos;\n}\n\nexport interface Segment {\n\tp: Point;\n\tq: Point;\n}\n\n// given a polyline as a list of segments, interrupt it over the box so no line is inside the box\nexport function intersectPolylineBox(segments: Segment[], box: BBox) {\n\tfor (let i = 0; i < segments.length; i++) {\n\t\tconst s = segments[i]\n\t\tif (insideBox(s.p, box)) {\n\t\t\tif (insideBox(s.q, box)) { // segment both ends inside box\n\t\t\t\tsegments.splice(i, 1)\n\t\t\t\ti -= 1\n\t\t\t} else { // segment start inside box\n\t\t\t\ts.p = intersectRectFull(s.p, s.q, box)[0]\n\t\t\t}\n\t\t} else {\n\t\t\tif (insideBox(s.q, box)) { // segment end inside box\n\t\t\t\ts.q = intersectRectFull(s.p, s.q, box)[0]\n\t\t\t} else { // both ends outside\n\t\t\t\tconst ret = intersectRectFull(s.p, s.q, box)\n\t\t\t\tif (ret.length == 2) { // intersects the box, splice segment\n\t\t\t\t\t// order the intersection points, closest first\n\t\t\t\t\tconst dst1 = Math.abs(ret[0].x - s.p.x) + Math.abs(ret[0].y - s.p.y)\n\t\t\t\t\tconst dst2 = Math.abs(ret[1].x - s.p.x) + Math.abs(ret[1].y - s.p.y)\n\t\t\t\t\tif (dst1 > dst2) ret.reverse()\n\t\t\t\t\t// split the segment in 2\n\t\t\t\t\tconst s2 = {p: ret[1], q: s.q}\n\t\t\t\t\ts.q = ret[0]\n\t\t\t\t\tsegments.splice(i + 1, 0, s2)\n\t\t\t\t\ti += 1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function project(p: Point, a: Point, b: Point): Point {\n\tlet atob = {x: b.x - a.x, y: b.y - a.y};\n\tlet atop = {x: p.x - a.x, y: p.y - a.y};\n\tlet len = atob.x * atob.x + atob.y * atob.y;\n\tlet dot = atop.x * atob.x + atop.y * atob.y;\n\tlet t = Math.min(1, Math.max(0, dot / len));\n\treturn {\n\t\tx: a.x + atob.x * t,\n\t\ty: a.y + atob.y * t\n\t};\n}\n\nexport function cabDistance(p1: Point, p2: Point): number {\n\treturn Math.abs(p2.x - p1.x) + Math.abs(p2.y - p1.y)\n}","import {intersectEllipse, intersectRect} from \"./intersect\";\n\ninterface Point {\n\tx: number;\n\ty: number;\n}\n\ninterface BBox extends Point {\n\twidth: number;\n\theight: number;\n}\n\ninterface D3Node extends BBox {\n\tintersect: (p: Point) => Point\n}\n\nfunction cylinderRadiusY(width: number) {\n\treturn width / 2 / (5.5 + width / 70);\n}\n\nexport function shapeLabelOffsetY(shape: string, width: number, height: number) {\n\tswitch (shape.toLowerCase()) {\n\t\tcase \"cylinder\":\n\t\t\treturn 2 * cylinderRadiusY(width);\n\t\tcase \"person\":\n\t\t\treturn height * 0.4;\n\t\tcase \"folder\":\n\t\t\treturn width / 10;\n\t\tcase \"robot\":\n\t\t\treturn height * 0.35;\n\t\tcase \"webbrowser\":\n\t\t\treturn height / 8;\n\t\tdefault:\n\t\t\treturn 0;\n\t}\n}\n\nclass D3Element {\n\tprivate readonly _el: SVGElement\n\n\tconstructor(el: SVGElement) {\n\t\tthis._el = el;\n\t}\n\n\tnode() {\n\t\treturn this._el;\n\t}\n\n\tattr(name: string, value: string | number) {\n\t\tthis._el.setAttribute(name, String(value))\n\t\treturn this;\n\t}\n\n\tinsert(type: string, pos: string) {\n\t\tconst el = document.createElementNS('http://www.w3.org/2000/svg', type)\n\t\tconst el2 = this._el.insertBefore(el, this._el.querySelector(pos))\n\t\treturn new D3Element(el2)\n\t}\n}\n\n\nfunction rect(parent: D3Element, bbox: BBox, node: D3Node, rounded = false) {\n\tconst shapeSvg = parent.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", rounded ? node.width / 8 : 3)\n\t\t.attr(\"ry\", rounded ? node.width / 8 : 3)\n\t\t.attr(\"x\", -bbox.width / 2)\n\t\t.attr(\"y\", -bbox.height / 2)\n\t\t.attr(\"width\", bbox.width)\n\t\t.attr(\"height\", bbox.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect(node, point);\n\t};\n\n\treturn shapeSvg;\n}\n\n\nfunction cylinder(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = bbox.width;\n\tconst rx = w / 2;\n\tconst ry = cylinderRadiusY(w);\n\tconst h = bbox.height;\n\n\tconst shape =\n\t\t`M 0,${ry} a${rx},${ry} 0,0,0 ${w} 0 a ${rx},${ry} 0,0,0 ${-w} 0 l 0,${h - 2 * ry} a ${rx},${ry} 0,0,0 ${w} 0 l 0,${-h + 2 * ry}`;\n\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"cylinder\", w, h))\n\t\t.insert('path', ':first-child')\n\t\t.attr('d', shape)\n\t\t.attr('transform', 'translate(' + -w / 2 + ',' + -(h / 2) + ')');\n\n\tnode.intersect = function (point: Point) {\n\t\tconst pos = intersectRect(node, point)\n\t\tlet cy = node.y + node.height / 2 - ry\n\t\tif (pos.y > cy)\n\t\t\treturn intersectEllipse({x: node.x, y: cy}, rx, ry, node, point)\n\n\t\tcy = node.y - node.height / 2 + ry\n\t\tif (pos.y < cy)\n\t\t\treturn intersectEllipse({x: node.x, y: cy}, rx, ry, node, point)\n\n\t\treturn pos;\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction person(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = bbox.width;\n\tconst h = bbox.height;\n\n\tconst shape =\n\t\t`M ${.38 * w},${h / 3} A${w / 2},${h / 2} 0,0,0 0 ${h / 2}\n\t\tL${w / 11},${h} L${w - w / 11},${h} L${w},${h / 2}\n\t\tA${w / 2},${h / 2} 0,0,0 ${w - .38 * w} ${h / 3} \n\t\tA${w / 6},${w / 6} 0,1,0 ${.38 * w} ${h / 3}`;\n\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"person\", w, h))\n\t\t.insert('path', ':first-child')\n\t\t.attr('d', shape)\n\t\t.attr('transform', 'translate(' + -w / 2 + ',' + -(h / 2) + ')');\n\n\tnode.intersect = function (point: Point) {\n\t\tconst pos = intersectRect(node, point)\n\t\treturn pos;\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction _ellipse(parent: D3Element, bbox: BBox, node: D3Node, rx: number, ry: number) {\n\tconst shapeSvg = parent.insert(\"ellipse\", \":first-child\")\n\t\t.attr(\"cx\", 0)\n\t\t.attr(\"cy\", 0)\n\t\t.attr('rx', rx)\n\t\t.attr('ry', ry)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectEllipse(node, rx, ry, node, point)\n\t};\n\treturn shapeSvg;\n}\n\nfunction circle(parent: D3Element, bbox: BBox, node: D3Node) {\n\treturn _ellipse(parent, bbox, node, node.width / 2, node.width / 2)\n}\n\nfunction ellipse(parent: D3Element, bbox: BBox, node: D3Node) {\n\treturn _ellipse(parent, bbox, node, node.width * .55, node.width * .45)\n}\n\nfunction hexagon(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst sz = node.width / 2\n\t// drawing a hexagon from polar coords\n\t// [0,1,2,3,4,5,6].map(i=>`${Math.sin(Math.PI/3*i+Math.PI/6).toFixed(4)},${Math.cos(Math.PI/3*i+Math.PI/6).toFixed(4)}`).join(',')\n\tconst shapeSvg = parent.insert(\"polygon\", \":first-child\")\n\t\t.attr(\"points\",\n\t\t\t[0.5000, 0.8660, 1.0000, 0.0000, 0.5000, -0.8660, -0.5000, -0.8660, -1.0000, -0.0000, -0.5000, 0.8660, 0.5000, 0.8660].map(n => n * sz).join(','))\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectEllipse(node, node.width / 2, node.width / 2, node, point)\n\t};\n\treturn shapeSvg;\n}\n\nfunction component(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dx = node.width / 10\n\tconst shapeSvg = parent.insert('g', ':first-child')\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2 - dx)\n\t\t.attr(\"y\", -node.height / 2 + dx)\n\t\t.attr(\"width\", dx * 2)\n\t\t.attr(\"height\", dx);\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2 - dx)\n\t\t.attr(\"y\", -node.height / 2 + dx * 2.5)\n\t\t.attr(\"width\", dx * 2)\n\t\t.attr(\"height\", dx);\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2)\n\t\t.attr(\"y\", -node.height / 2)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x - dx / 2, y: node.y, width: node.width + dx, height: node.height}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction folder(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dy = node.width / 20\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"folder\", node.width, node.height))\n\t\t.insert('g', ':first-child')\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2)\n\t\t.attr(\"y\", -node.height / 2 + dy * 2)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height - dy * 2);\n\tshapeSvg.insert(\"path\", \":first-child\")\n\t\t.attr('d', `M0,${-node.height / 2 + 2 * dy} l${dy},${-2 * dy} h${node.width / 2 - dy * 2} v${dy * 2}`)\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x, y: node.y + dy / 2, width: node.width, height: node.height + dy}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction mobiledevicelandscape(parent: D3Element, bbox: BBox, node: D3Node, rounded = false) {\n\tconst dx = node.width / 8\n\tconst r = node.width / 14\n\tconst shapeSvg = parent.insert('g', ':first-child')\n\tshapeSvg.insert('path', ':first-child')\n\t\t.attr('d', `M${-node.width / 2},${-node.height / 2} l0,${node.height} M${node.width / 2},${-node.height / 2} l0,${node.height}`)\n\tshapeSvg.insert('circle', ':first-child')\n\t\t.attr('cx', -node.width / 2 - dx / 2)\n\t\t.attr('cy', 0)\n\t\t.attr('r', r * .4)\n\tshapeSvg.insert('rect', ':first-child')\n\t\t.attr('x', node.width / 2 + dx / 2 - r * .2)\n\t\t.attr('y', -r)\n\t\t.attr('width', r * .4)\n\t\t.attr('height', r * 2)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", r)\n\t\t.attr(\"ry\", r)\n\t\t.attr(\"x\", -bbox.width / 2 - dx)\n\t\t.attr(\"y\", -bbox.height / 2)\n\t\t.attr(\"width\", bbox.width + 2 * dx)\n\t\t.attr(\"height\", bbox.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x, y: node.y, width: node.width + 2 * dx, height: node.height}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction mobiledeviceportrait(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dy = node.width / 8\n\tconst r = node.width / 14\n\tconst shapeSvg = parent.insert('g', ':first-child')\n\tshapeSvg.insert('path', ':first-child')\n\t\t.attr('d', `M${-node.width / 2},${-node.height / 2} l${node.width},0 M${-node.width / 2},${node.height / 2} l${node.width},0`)\n\tshapeSvg.insert('circle', ':first-child')\n\t\t.attr('cx', 0)\n\t\t.attr('cy', node.height / 2 + dy / 2)\n\t\t.attr('r', r * .4)\n\tshapeSvg.insert('rect', ':first-child')\n\t\t.attr('x', -r)\n\t\t.attr('y', -node.height / 2 - dy / 2 - r * .2)\n\t\t.attr('width', r * 2)\n\t\t.attr('height', r * .4)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", r)\n\t\t.attr(\"ry\", r)\n\t\t.attr(\"x\", -bbox.width / 2)\n\t\t.attr(\"y\", -bbox.height / 2 - dy)\n\t\t.attr(\"width\", bbox.width)\n\t\t.attr(\"height\", bbox.height + 2 * dy);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x, y: node.y, width: node.width, height: node.height + 2 * dy}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction pipe(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = node.width;\n\tconst h = node.height;\n\tconst ry = h / 2;\n\tconst rx = ry / (2.5 + w / 70);\n\n\tconst shape =\n\t\t`M${-rx},0\n\t\ta${rx},${ry} 0,0,1 0,${h}\n\t\ta${rx},${ry} 0,0,1 0,${-h}\n\t\tl${w},0\n\t\ta${rx},${ry} 0,0,1 0,${h}\n\t\tl${-w},0`;\n\n\tconst shapeSvg = parent\n\t\t.insert('path', ':first-child')\n\t\t.attr('d', shape)\n\t\t.attr('transform', 'translate(' + -w / 2 + ',' + -(h / 2) + ')');\n\n\tnode.intersect = function (point: Point) {\n\t\treturn intersectRect({x: node.x - rx, y: node.y, width: node.width + 2 * rx, height: node.height}, point)\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction robot(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = node.width\n\tconst h = node.height\n\t\n\t// Small head at top (like person shape but robot-styled)\n\tconst headSize = Math.min(w * 0.28, h * 0.25)\n\tconst headR = headSize * 0.2\n\tconst antennaH = headSize * 0.25\n\tconst antennaR = headSize * 0.08\n\t\n\t// Eye dimensions\n\tconst eyeR = headSize * 0.12\n\tconst eyeSpacing = headSize * 0.22\n\t\n\t// Ear dimensions \n\tconst earW = headSize * 0.12\n\tconst earH = headSize * 0.3\n\t\n\t// Body fills most of the space for text\n\tconst bodyW = w\n\tconst bodyTop = -h / 2 + antennaH + headSize\n\tconst bodyH = h - antennaH - headSize\n\tconst bodyR = 3\n\t\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"robot\", w, h))\n\t\t.insert('g', ':first-child')\n\t\n\t// Body - main rectangle for text (draw first so it's behind)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", bodyR)\n\t\t.attr(\"ry\", bodyR)\n\t\t.attr('x', -bodyW / 2)\n\t\t.attr('y', bodyTop)\n\t\t.attr('width', bodyW)\n\t\t.attr('height', bodyH)\n\t\n\t// Head\n\tconst headTop = -h / 2 + antennaH\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", headR)\n\t\t.attr(\"ry\", headR)\n\t\t.attr('x', -headSize / 2)\n\t\t.attr('y', headTop)\n\t\t.attr('width', headSize)\n\t\t.attr('height', headSize)\n\t\n\t// Antenna\n\tshapeSvg.insert(\"line\", \":first-child\")\n\t\t.attr('class', 'robot-antenna')\n\t\t.attr('x1', 0)\n\t\t.attr('y1', headTop)\n\t\t.attr('x2', 0)\n\t\t.attr('y2', -h / 2 + antennaR * 2)\n\t\t.attr('stroke-width', antennaR * 0.6)\n\t\t.attr('stroke-linecap', 'round')\n\t\n\t// Antenna ball\n\tshapeSvg.insert(\"circle\", \":first-child\")\n\t\t.attr('class', 'robot-antenna-ball')\n\t\t.attr('cx', 0)\n\t\t.attr('cy', -h / 2 + antennaR * 2)\n\t\t.attr('r', antennaR * 1.2)\n\t\n\t// Eyes\n\tconst eyeY = headTop + headSize * 0.4\n\tshapeSvg.insert(\"circle\", \":first-child\")\n\t\t.attr('class', 'robot-eye')\n\t\t.attr('cx', -eyeSpacing)\n\t\t.attr('cy', eyeY)\n\t\t.attr('r', eyeR)\n\tshapeSvg.insert(\"circle\", \":first-child\")\n\t\t.attr('class', 'robot-eye')\n\t\t.attr('cx', eyeSpacing)\n\t\t.attr('cy', eyeY)\n\t\t.attr('r', eyeR)\n\t\n\t// Mouth - simple smile\n\tconst mouthY = headTop + headSize * 0.7\n\tconst mouthW = headSize * 0.28\n\tshapeSvg.insert(\"path\", \":first-child\")\n\t\t.attr('class', 'robot-mouth')\n\t\t.attr('d', `M${-mouthW / 2},${mouthY} Q0,${mouthY + mouthW * 0.3} ${mouthW / 2},${mouthY}`)\n\t\t.attr('fill', 'none')\n\t\t.attr('stroke-width', antennaR * 0.5)\n\t\t.attr('stroke-linecap', 'round')\n\t\n\t// Ears\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", earW * 0.25)\n\t\t.attr(\"ry\", earW * 0.25)\n\t\t.attr('x', -headSize / 2 - earW - 1)\n\t\t.attr('y', eyeY - earH / 2)\n\t\t.attr('width', earW)\n\t\t.attr('height', earH)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", earW * 0.25)\n\t\t.attr(\"ry\", earW * 0.25)\n\t\t.attr('x', headSize / 2 + 1)\n\t\t.attr('y', eyeY - earH / 2)\n\t\t.attr('width', earW)\n\t\t.attr('height', earH)\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect(node, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction webbrowser(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dy = node.height / 8\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"webbrowser\", node.width, node.height))\n\t\t.insert('g', ':first-child')\n\tshapeSvg.insert(\"path\", \":first-child\")\n\t\t.attr('d', `\n\t\t\tM${-node.width / 2},${-node.height / 2 + dy} h${node.width}\n\t\t\tM${-node.width / 2 + dy / 4},${-node.height / 2 + dy / 4} h${dy / 2} v${dy / 2} h${-dy / 2} z\n\t\t\tM${-node.width / 2 + dy},${-node.height / 2 + dy / 4} h${node.width - dy - dy / 4} v${dy / 2} h${-node.width + dy + dy / 4} z\n\t\t`)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2)\n\t\t.attr(\"y\", -node.height / 2)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect(node, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nexport const shapes: { [key: string]: (parent: SVGElement, node: D3Node) => SVGElement } = {\n\tbox: (parent: SVGElement, node: D3Node) => rect(new D3Element(parent), node, node).node(),\n\troundedbox: (parent: SVGElement, node: D3Node) => rect(new D3Element(parent), node, node, true).node(),\n\tcomponent: (parent: SVGElement, node: D3Node) => component(new D3Element(parent), node, node).node(),\n\tcylinder: (parent: SVGElement, node: D3Node) => cylinder(new D3Element(parent), node, node).node(),\n\tperson: (parent: SVGElement, node: D3Node) => person(new D3Element(parent), node, node).node(),\n\tcircle: (parent: SVGElement, node: D3Node) => circle(new D3Element(parent), node, node).node(),\n\tellipse: (parent: SVGElement, node: D3Node) => ellipse(new D3Element(parent), node, node).node(),\n\thexagon: (parent: SVGElement, node: D3Node) => hexagon(new D3Element(parent), node, node).node(),\n\tfolder: (parent: SVGElement, node: D3Node) => folder(new D3Element(parent), node, node).node(),\n\tmobiledevicelandscape: (parent: SVGElement, node: D3Node) => mobiledevicelandscape(new D3Element(parent), node, node).node(),\n\tmobiledeviceportrait: (parent: SVGElement, node: D3Node) => mobiledeviceportrait(new D3Element(parent), node, node).node(),\n\tmobiledevice: (parent: SVGElement, node: D3Node) => mobiledeviceportrait(new D3Element(parent), node, node).node(),\n\tpipe: (parent: SVGElement, node: D3Node) => pipe(new D3Element(parent), node, node).node(),\n\trobot: (parent: SVGElement, node: D3Node) => robot(new D3Element(parent), node, node).node(),\n\twebbrowser: (parent: SVGElement, node: D3Node) => webbrowser(new D3Element(parent), node, node).node(),\n}\n","/**\n * Undo functionality\n * at every change in the document, Undo can save a new version\n * so the user can \"undo\" and \"redo\" changes by reverting to an\n * older version of the document\n */\n\nexport class Undo {\n\tprivate readonly versions: Doc[] = [];\n\tprivate pos: number = 0;\n\tprivate lastSavedPos: number = 0;\n\tprivate readonly exportDoc: () => Doc;\n\tprivate readonly importDoc: (d: Doc) => void;\n\tchange: () => void;\n\tprivate tmpPreviousState: Doc | null = null;\n\n\tconstructor(id: string, exportDoc: () => Doc, importDoc: (d: Doc) => void) {\n\t\tthis.exportDoc = exportDoc;\n\t\tthis.importDoc = importDoc;\n\t\tthis.change = debounce(() => this.saveNow(), 300);\n\t}\n\n\t// Store the state previous to the changes collected in the debounce period\n\tbeforeChange() {\n\t\tif (!this.tmpPreviousState) {\n\t\t\tthis.tmpPreviousState = this.deepClone(this.exportDoc());\n\t\t}\n\t}\n\n\tlength() {\n\t\treturn this.versions.length;\n\t}\n\n\tcurrentState() {\n\t\treturn this.deepClone(this.versions[this.pos - 1]);\n\t}\n\n\tprivate saveNow() {\n\t\tif (!this.tmpPreviousState) {\n\t\t\tthrow Error(\"undo.change() was called without previously calling undo.beforeChange()!\");\n\t\t}\n\t\t\n\t\tthis.versions[this.pos] = this.deepClone(this.exportDoc());\n\t\tthis.versions[this.pos - 1] = this.tmpPreviousState;\n\t\tthis.tmpPreviousState = null;\n\t\tthis.pos += 1;\n\t\t\n\t\t// Remove anything that might be on top of this version\n\t\tthis.versions.splice(this.pos);\n\t}\n\n\tprivate deepClone(doc: Doc): Doc {\n\t\t// Use modern structuredClone if available, fallback to JSON\n\t\tif (typeof structuredClone !== 'undefined') {\n\t\t\treturn structuredClone(doc);\n\t\t}\n\t\treturn JSON.parse(JSON.stringify(doc));\n\t}\n\n\tundo() {\n\t\tif (this.pos < 2) return;\n\t\tthis.pos -= 1;\n\t\tconst doc = this.versions[this.pos - 1];\n\t\tthis.importDoc(this.deepClone(doc));\n\t}\n\n\tredo() {\n\t\tif (this.pos > this.versions.length - 1) return;\n\t\tconst doc = this.versions[this.pos];\n\t\tthis.importDoc(this.deepClone(doc));\n\t\tthis.pos += 1;\n\t}\n\n\tchanged() {\n\t\treturn this.pos !== this.lastSavedPos;\n\t}\n\n\tsetSaved() {\n\t\tthis.lastSavedPos = this.pos;\n\t}\n}\n\nfunction debounce(func: () => void, wait: number) {\n\tlet timeout: ReturnType;\n\treturn function () {\n\t\tconst context = this;\n\t\tconst later = function () {\n\t\t\ttimeout = null;\n\t\t\tfunc.apply(context);\n\t\t};\n\t\tclearTimeout(timeout);\n\t\ttimeout = setTimeout(later, wait);\n\t};\n}","import {applyStyle, NodeStyle, SVG_STYLES} from \"./constants\";\nimport {create} from \"./svg-create\";\nimport {svgTextWrap} from \"./svg-text\";\n\ninterface TextBlockLayout {\n\tlines: string[];\n\tfontSize: number;\n\tlineHeight: number;\n\tbold: boolean;\n\tfield?: string;\n\tgapAfter: number;\n}\n\nexport interface NodeContentLayout {\n\tblocks: TextBlockLayout[];\n\ttextHeight: number;\n\tminimumHeight: number;\n\t// The icon shares the content stack so text never draws over it.\n\ticon?: string;\n}\n\nconst HORIZONTAL_PADDING = 18;\nconst VERTICAL_PADDING = 18;\nconst TITLE_GAP = 6;\nconst METADATA_GAP = 10;\nconst ICON_SIZE = 32;\nconst ICON_GAP = 12;\n\nfunction textBlock(\n\ttext: string,\n\twidth: number,\n\tfontSize: number,\n\tbold: boolean,\n\tgapAfter: number,\n\tfield?: string,\n): TextBlockLayout {\n\tconst attrs = {\n\t\t\"font-family\": String(SVG_STYLES.nodeText[\"font-family\"]),\n\t\t\"font-size\": `${fontSize}px`,\n\t\t\"font-weight\": bold ? \"bold\" : \"normal\",\n\t};\n\tconst wrapped = svgTextWrap(text, width, attrs);\n\tconst lines = wrapped.lines.length > 0 ? wrapped.lines : [\"\"];\n\n\treturn {\n\t\tlines,\n\t\tfontSize,\n\t\tlineHeight: fontSize + 2,\n\t\tbold,\n\t\tfield,\n\t\tgapAfter,\n\t};\n}\n\nexport function layoutNodeContent(\n\ttitle: string,\n\tsubtitle: string,\n\tdescription: string,\n\tnodeWidth: number,\n\tfontSize: number,\n\tstyle: NodeStyle,\n): NodeContentLayout {\n\tconst textWidth = Math.max(nodeWidth - HORIZONTAL_PADDING * 2, 80);\n\tconst blocks = [textBlock(title, textWidth, fontSize, true, TITLE_GAP, \"name\")];\n\tif (style.metadata !== false && subtitle) {\n\t\tblocks.push(textBlock(`[${subtitle}]`, textWidth, fontSize * 0.7, false, METADATA_GAP));\n\t}\n\tif (style.description !== false && description) {\n\t\tblocks.push(textBlock(description, textWidth, Math.min(fontSize * 0.8, 16), false, 0, \"description\"));\n\t}\n\tblocks[blocks.length - 1].gapAfter = 0;\n\tconst textHeight = blocks.reduce(\n\t\t(height, block) => height + block.lines.length * block.lineHeight + block.gapAfter,\n\t\t0,\n\t);\n\n\treturn {\n\t\tblocks,\n\t\ttextHeight,\n\t\tminimumHeight: textHeight + VERTICAL_PADDING * 2 + (style.icon ? ICON_SIZE + ICON_GAP : 0),\n\t\ticon: style.icon,\n\t};\n}\n\nexport function buildNodeContent(layout: NodeContentLayout, color?: string): SVGGElement {\n\tconst group = create.element(\"g\") as SVGGElement;\n\tconst iconHeight = layout.icon ? ICON_SIZE + ICON_GAP : 0;\n\tlet top = -(layout.textHeight + iconHeight) / 2;\n\tif (layout.icon) {\n\t\tgroup.append(create.element(\"image\", {\n\t\t\thref: layout.icon,\n\t\t\tx: -ICON_SIZE / 2,\n\t\t\ty: top,\n\t\t\twidth: ICON_SIZE,\n\t\t\theight: ICON_SIZE,\n\t\t\tpreserveAspectRatio: \"xMidYMid meet\",\n\t\t}, \"nodeIcon\"));\n\t\ttop += iconHeight;\n\t}\n\n\tlayout.blocks.forEach((block) => {\n\t\tconst text = create.text(\"\", {\"text-anchor\": \"middle\"});\n\t\tapplyStyle(text, SVG_STYLES.nodeText);\n\t\tif (color) {\n\t\t\ttext.setAttribute(\"fill\", color);\n\t\t}\n\t\tif (block.field) {\n\t\t\ttext.setAttribute(\"data-field\", block.field);\n\t\t}\n\n\t\tblock.lines.forEach((line, index) => {\n\t\t\tconst span = create.element(\"tspan\", {\n\t\t\t\tx: 0,\n\t\t\t\ty: top + block.fontSize + index * block.lineHeight,\n\t\t\t\t\"font-size\": `${block.fontSize}px`,\n\t\t\t\t\"font-weight\": block.bold ? \"bold\" : \"normal\",\n\t\t\t});\n\t\t\tspan.textContent = line;\n\t\t\ttext.append(span);\n\t\t});\n\n\t\tgroup.append(text);\n\t\ttop += block.lines.length * block.lineHeight + block.gapAfter;\n\t});\n\n\treturn group;\n}\n","import {defs} from \"./defs\";\nimport {create, setPosition} from \"./svg-create\";\nimport {cursorInteraction} from \"svg-editor-tools/lib/cursor-interaction\";\nimport {shapeLabelOffsetY, shapes} from \"./shapes\";\nimport {\n\tboxesOverlap,\n\tcabDistance,\n\tinsideBox,\n\tintersectPolylineBox,\n\tproject,\n\tscaleBox,\n\tSegment,\n\tuncenterBox\n} from \"./intersect\";\nimport {autoLayout, LayoutOptions, validateCurrentLayout} from \"./layout\";\nimport {Undo} from \"./undo\";\nimport {\n\tADD_LABEL_VERTEX,\n\tADD_VERTEX,\n\tDEL_VERTEX,\n\tDESELECT,\n\tfindShortcut,\n\tREDO,\n\tSELECT_ALL,\n\tUNDO,\n\tZOOM_100,\n\tZOOM_FIT,\n\tZOOM_IN,\n\tZOOM_OUT\n} from \"../shortcuts\";\nimport {\n\tPoint,\n\tBBox,\n\tNodeStyle,\n\tEdgeStyle,\n\tDEFAULT_EDGE_STYLE,\n\tDEFAULT_NODE_STYLE,\n\tSVG_STYLES,\n\tSVG_PADDING,\n\tDEFAULT_GRID_SIZE,\n\tapplyStyle\n} from \"./constants\";\nimport {\n\tcalculateEdgeVertices,\n\tcalculateLabelPlacement,\n\tcreateEdgePath,\n\tEdgeLabelPlacement\n} from \"./edge-utils\";\nimport {\n\tbuildNodeContent,\n\tlayoutNodeContent,\n\tNodeContentLayout\n} from \"./node-content\";\nimport {ValidatedLayout} from \"./geometry\";\n\n\n// Point and BBox interfaces are now imported from constants\n\nexport interface Group extends BBox {\n\tid: string;\n\tname: string;\n\tnodes: (Node | Group)[];\n\tref?: SVGGElement;\n\tstyle: NodeStyle;\n\tlayoutBounds?: BBox;\n\tlayoutTitleBounds?: BBox;\n}\n\nexport interface NodeLink {\n\thref: string;\n\texportHref: string;\n}\n\nexport type LayoutDirection = 'UP' | 'DOWN' | 'LEFT' | 'RIGHT';\n\nexport interface Node extends BBox {\n\tid: string;\n\ttitle: string;\n\tsub: string;\n\tdescription: string;\n\n\tref?: SVGGElement;\n\tselected?: boolean;\n\n\tintersect: (p: Point) => Point\n\n\tstyle: NodeStyle\n\tlink?: NodeLink\n\tcontentLayout: NodeContentLayout\n}\n\n// NodeStyle interface is now imported from constants\n\n// EdgeStyle interface is now imported from constants\n\n// Default styles are now imported from constants\nconst defaultEdgeStyle = DEFAULT_EDGE_STYLE;\nconst defaultNodeStyle = DEFAULT_NODE_STYLE;\n\n// Edge and EdgeVertex interfaces are now defined in edge-utils.ts\n// Using local interfaces for compatibility with existing code\nexport interface Edge {\n\tid: string;\n\tlabel: string;\n\tfrom: Node;\n\tto: Node;\n\tvertices?: EdgeVertex[];\n\tref?: SVGGElement;\n\tstyle: EdgeStyle;\n\tinitVertex: (p: Point) => EdgeVertex;\n\tuserDeletedVertices?: boolean; // Track if user explicitly deleted vertices\n\tlabelVertex?: EdgeVertex; // ELK-calculated label position (separate from routing vertices)\n\tlabelBounds?: BBox;\n\tlayoutSections?: Point[][];\n\tlayoutLabelBounds?: BBox;\n}\n\ninterface EdgeVertex extends Point {\n\tid: string\n\tselected?: boolean\n\tedge: Edge\n\tref?: SVGElement\n\tlabel?: boolean\n\tauto?: boolean\n}\n\ninterface SavedEdgePoint extends Point {\n\tlabel?: boolean;\n\tauto?: boolean;\n}\n\ninterface Layout {\n\t[k: string]: Point | SavedEdgePoint[] | boolean\n}\n\n/** graphCount numbers the graphs created in this page; each GraphData uses it once for its idPrefix. */\nlet graphCount = 0\n\nexport class GraphData {\n\tid: string;\n\tname: string;\n\tnodesMap: Map;\n\tedges: Edge[];\n\tedgeVertices: Map\n\tgroupsMap: Map;\n\tmetadata: any;\n\tlayoutDirection?: LayoutDirection;\n\tvalidatedLayout?: ValidatedLayout;\n\tcolorToVarMap: Map = new Map(); // For CSS custom properties theming\n\t/**\n\t * svg is the element this graph draws into. Each graph has its own element,\n\t * so several graphs on one page never change each other's drawing, zoom, or\n\t * export. It carries no document-wide id; exportSVG adds id \"graph\" to the copy.\n\t */\n\treadonly svg: SVGSVGElement;\n\t/**\n\t * idPrefix starts every id this graph writes into its live svg, for example\n\t * \"g2-arrow\" or \"g2-\" plus a model element id, so two graphs in one page never\n\t * share an id. exportSVG removes it, so saved files keep the plain ids.\n\t */\n\treadonly idPrefix: string;\n\t/** selectListener receives the selected node in the editor; buildGraph sets it. */\n\tselectListener: (n: Node) => void;\n\t/** dragging is true while the editor user drags this graph's nodes or selection box. */\n\tdragging = false;\n\tprivate _undo: Undo;\n\tprivate _gridVisible: boolean = false;\n\tprivate _snapToGrid: boolean = true;\n\tprivate _gridSize: number = 25;\n\tprivate _skipAutoFit: boolean = false;\n\n\tconstructor(id?: string, name?: string) {\n\t\tthis.id = id;\n\t\tthis.name = name;\n\n\t\tthis.edges = [];\n\t\tthis.edgeVertices = new Map;\n\t\tthis.nodesMap = new Map;\n\t\tthis.groupsMap = new Map;\n\t\tthis.svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n\t\tthis.idPrefix = `g${++graphCount}-`;\n\n\t\tthis._undo = new Undo(\n\t\t\tthis.id,\n\t\t\t() => this.exportLayout(true),\n\t\t\t(lo) => this.importLayout(lo, true)\n\t\t)\n\t}\n\n\t// after the graph model is build using addNode, addEdge etc, initialize\n\tinit(layout?: Layout) {\n\t\tlayout && this.importLayout(layout)\n\t\tthis._undo = new Undo(\n\t\t\tthis.id,\n\t\t\t() => this.exportLayout(true),\n\t\t\t(lo) => this.importLayout(lo, true)\n\t\t)\n\t\tif (this._undo.length()) {\n\t\t\tthis.importLayout(this._undo.currentState())\n\t\t}\n\t\t\n\t\t// Save initial state so first action is undoable\n\t\tthis._undo.beforeChange()\n\t\tthis._undo.change()\n\t}\n\n\taddNode(id: string, label: string, sub: string, description: string, style: NodeStyle, link?: NodeLink) {\n\t\tif (this.nodesMap.has(id)) throw Error('duplicate node: ' + id)\n\t\tconst nodeStyle = {...defaultNodeStyle, ...style};\n\t\tconst shape = (nodeStyle.shape || 'Box').toLowerCase();\n\t\tconst minimumWidth = 280;\n\t\tconst minimumHeight = shape === 'person' ? 240 : 180;\n\t\tconst width = Math.max(minimumWidth, nodeStyle.width || 0);\n\t\tconst fontSize = nodeStyle.fontSize || 22;\n\t\tconst contentLayout = layoutNodeContent(label, sub, description, width, fontSize, nodeStyle);\n\t\tlet height = Math.max(minimumHeight, nodeStyle.height || 0, contentLayout.minimumHeight);\n\n\t\t// Some shapes shift labels down to reserve visual space for an icon,\n\t\t// header, or curved edge. Grow until the shifted content also fits.\n\t\tfor (let i = 0; i < 20; i++) {\n\t\t\tconst requiredHeight = contentLayout.minimumHeight +\n\t\t\t\tMath.abs(shapeLabelOffsetY(shape, width, height));\n\t\t\tif (requiredHeight <= height + 0.1) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\theight = requiredHeight;\n\t\t}\n\n\t\tconst n: Node = {\n\t\t\tid, title: label, sub, description, style: nodeStyle,\n\t\t\tx: 0, y: 0, width, height, intersect: null, link, contentLayout\n\t\t}\n\t\tthis.nodesMap.set(n.id, n)\n\t}\n\n\tnodes() {\n\t\treturn Array.from(this.nodesMap.values())\n\t}\n\n\taddEdge(id: string, fromNode: string, toNode: string, label: string, vertices: Point[], style: EdgeStyle) {\n\t\tvertices && vertices.forEach((p, i) => {\n\t\t\tconst v = p as EdgeVertex\n\t\t\tv.id = `v-${id}-${i}`\n\t\t\tthis.edgeVertices.set(v.id, v)\n\t\t})\n\t\t// Deterministic vertex IDs.\n\t\t//\n\t\t// `mdl svg` renders diagrams headlessly and saves the resulting SVG. If we\n\t\t// generate random vertex IDs, the SVG changes on every run even when the\n\t\t// underlying model and layout are unchanged. Use a stable hash instead.\n\t\tconst fnv1a36 = (input: string) => {\n\t\t\tlet h = 0x811c9dc5\n\t\t\tfor (let i = 0; i < input.length; i++) {\n\t\t\t\th ^= input.charCodeAt(i)\n\t\t\t\th = Math.imul(h, 0x01000193)\n\t\t\t}\n\t\t\treturn (h >>> 0).toString(36)\n\t\t}\n\t\tconst stableVertexID = (edgeID: string, p: Point) => {\n\t\t\tconst x = (p as any).x\n\t\t\tconst y = (p as any).y\n\t\t\treturn `v-${edgeID}-a-${fnv1a36(`${edgeID}:${x}:${y}`)}`\n\t\t}\n\t\tconst initVertex = (p: Point) => {\n\t\t\tconst v = p as EdgeVertex\n\t\t\tif (!v.id) {\n\t\t\t\tv.id = stableVertexID(edge.id, p)\n\t\t\t\tthis.edgeVertices.set(v.id, v)\n\t\t\t}\n\t\t\tv.edge = edge\n\t\t\treturn p as EdgeVertex\n\t\t}\n\t\tconst edge = {\n\t\t\tid,\n\t\t\tfrom: this.nodesMap.get(fromNode),\n\t\t\tto: this.nodesMap.get(toNode),\n\t\t\tlabel,\n\t\t\tvertices: null as EdgeVertex[],\n\t\t\tstyle: {...defaultEdgeStyle, ...style},\n\t\t\tinitVertex,\n\t\t\tuserDeletedVertices: false\n\t\t}\n\t\tthis.edges.push(edge)\n\t\tif (vertices) {\n\t\t\tedge.vertices = vertices.map(p => edge.initVertex(p))\n\t\t}\n\t}\n\n\taddGroup(id: string, name: string, nodesOrGroups: string[], style: NodeStyle) {\n\t\tif (this.groupsMap.has(id)) {\n\t\t\tconsole.error(`Group exists: ${id} ${name}`)\n\t\t\treturn\n\t\t}\n\t\tconst group: Group = {\n\t\t\tid, name, x: null, y: null, width: null, height: null,\n\t\t\tnodes: nodesOrGroups.map(k => {\n\t\t\t\tconst n = this.nodesMap.get(k) || this.groupsMap.get(k)\n\t\t\t\tif (!n) console.error(`Node or group ${k} not found for group ${id} \"${name}\"`)\n\t\t\t\treturn n\n\t\t\t}).filter(Boolean),\n\t\t\tstyle\n\t\t}\n\t\tthis.groupsMap.set(id, group)\n\t}\n\n\t// private rebuildNode(node: Node) {\n\t// \tconst p = node.ref.parentElement;\n\t// \tp.removeChild(node.ref)\n\t// \tnode.ref = buildNode(node, this)\n\t// \tp.appendChild(node.ref)\n\t// \tthis.redrawEdges(node)\n\t// \tthis.redrawGroups(node)\n\t// }\n\n\tsetNodeSelected(node: Node, selected: boolean) {\n\t\tnode.selected = selected\n\t\tselected ?\n\t\t\tnode.ref.classList.add('selected') :\n\t\t\tnode.ref.classList.remove('selected')\n\t\tthis.updateEdgesSel()\n\t}\n\n\tprivate updateEdgesSel() {\n\t\tthis.edges.forEach(e => {\n\t\t\tif (e.to.selected || e.from.selected) {\n\t\t\t\te.ref.classList.add('selected')\n\t\t\t} else {\n\t\t\t\te.ref.classList.remove('selected')\n\t\t\t}\n\t\t})\n\t}\n\n\t/** clearResolvedLayout returns drawing to manual mode after any user edit. */\n\tprivate clearResolvedLayout() {\n\t\tthis.validatedLayout = undefined\n\t\tthis.edges.forEach(edge => {\n\t\t\tedge.layoutSections = undefined\n\t\t\tedge.layoutLabelBounds = undefined\n\t\t})\n\t\tthis.groupsMap.forEach(group => {\n\t\t\tgroup.layoutBounds = undefined\n\t\t\tgroup.layoutTitleBounds = undefined\n\t\t})\n\t}\n\n\tmoveNode(n: Node, x: number, y: number, disableSnap: boolean = false, skipUndo: boolean = false) {\n\t\tif (!n) return\n\t\t\n\t\t// Apply snap-to-grid if enabled and not explicitly disabled\n\t\tif (this._snapToGrid && !disableSnap) {\n\t\t\tconst snapped = this.snapToGrid(x, y);\n\t\t\tx = snapped.x;\n\t\t\ty = snapped.y;\n\t\t}\n\t\t\n\t\tif (n.x == x && n.y == y) return\n\t\t\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.beforeChange()\n\t\t}\n\t\tthis.clearResolvedLayout()\n\t\tn.x = x;\n\t\tn.y = y;\n\t\tsetPosition(n.ref, x, y)\n\t\tthis.redrawEdges(n);\n\t\tthis.redrawGroups(n)\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.change()\n\t\t}\n\t}\n\n\tmoveEdgeVertex(v: EdgeVertex, x: number, y: number, disableSnap: boolean = false, skipUndo: boolean = false) {\n\t\t\n\t\tif (this._snapToGrid && !disableSnap) {\n\t\t\tconst snapped = this.snapToGrid(x, y);\n\t\t\tx = snapped.x;\n\t\t\ty = snapped.y;\n\t\t}\n\t\t// Use exact coordinates (no rounding needed with modern grid system)\n\t\t\n\t\tif (v.x == x && v.y == y) return\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.beforeChange()\n\t\t}\n\t\tthis.clearResolvedLayout()\n\t\tv.x = x;\n\t\tv.y = y;\n\t\tthis.redrawEdge(v.edge)\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.change()\n\t\t}\n\t}\n\n\tmoveSelected(dx: number, dy: number, disableSnap: boolean = false) {\n\t\tthis.nodes().forEach(n => n.selected && this.moveNode(n, n.x + dx, n.y + dy, disableSnap, false))\n\t\tthis.edgeVertices.forEach(v => v.selected && this.moveEdgeVertex(v, v.x + dx, v.y + dy, disableSnap, false))\n\t}\n\n\tinsertEdgeVertex(edge: Edge, p: Point, pos: number, isLabel: boolean) {\n\t\tthis._undo.beforeChange()\n\t\tthis.clearResolvedLayout()\n\t\tconst v = edge.initVertex(p)\n\t\tv.selected = true\n\t\tif (isLabel) { // when shift down, make it label position\n\t\t\tedge.vertices.forEach(v => v.label = false)\n\t\t\tv.label = true\n\t\t}\n\t\tedge.vertices.splice(pos - 1, 0, v)\n\t\tthis.redrawEdge(edge)\n\t\tthis._undo.change()\n\t}\n\n\tdeleteEdgeVertex(v: EdgeVertex) {\n\t\tthis._undo.beforeChange()\n\t\tthis.clearResolvedLayout()\n\t\t\n\t\tconst index = v.edge.vertices.indexOf(v)\n\t\tif (index >= 0) {\n\t\t\tv.edge.vertices.splice(index, 1)\n\t\t\tthis.edgeVertices.delete(v.id)\n\t\t\t\n\t\t\t// Mark that user explicitly deleted vertices from this edge\n\t\t\tv.edge.userDeletedVertices = true\n\t\t}\n\t\t\n\t\tthis.redrawEdge(v.edge)\n\t\tthis._undo.change()\n\t}\n\n\tchanged() {\n\t\treturn this._undo.changed()\n\t}\n\n\tundo() {\n\t\tthis._undo.undo()\n\t}\n\n\tredo() {\n\t\tthis._undo.redo()\n\t}\n\n\t// moves the entire graph to be aligned top-left of the drawing area\n\t// used to bring back to visible the nodes that end up at negative coordinates\n\talignTopLeft() {\n\t\tconst contentBounds = this.calculateContentBounds()\n\t\tconst padding = 100 // Reasonable padding for viewport\n\t\t\n\t\tconst offsetX = -contentBounds.x + padding\n\t\tconst offsetY = -contentBounds.y + padding\n\t\t\n\t\t// Set flag to prevent React useEffect from calling fitToView during this operation\n\t\tthis._skipAutoFit = true\n\t\t\n\t\tthis._undo.beforeChange()\n\t\t\n\t\tthis.nodesMap.forEach(node => {\n\t\t\tthis.moveNode(node, node.x + offsetX, node.y + offsetY, true, true) // Disable snap and undo during reset\n\t\t})\n\t\t\n\t\tthis.edgeVertices.forEach(vertex => {\n\t\t\tthis.moveEdgeVertex(vertex, vertex.x + offsetX, vertex.y + offsetY, true, true) // Disable snap and undo during reset\n\t\t})\n\t\t\n\t\tthis._undo.change()\n\t\t\n\t\t// DON'T clear view state here - let resetPanTransform handle it to avoid React useEffect recursion\n\t}\n\t\n\t// Reset pan transform to (0,0) while preserving zoom\n\tresetPanTransform() {\n\t\tconst currentZoom = getZoom(this)\n\t\tconst zoomGroup = this.svg.querySelector('g.zoom') as SVGGElement\n\t\tif (zoomGroup) {\n\t\t\tzoomGroup.setAttribute('transform', `scale(${currentZoom}) translate(0, 0)`)\n\t\t\tupdatePanningOptimized(this)\n\t\t}\n\t\t\n\t\t// Clear view state so this reset is not overridden\n\t\tclearViewState(this)\n\t\t\n\t\t// Reset the skip auto fit flag after reset is complete\n\t\tthis._skipAutoFit = false\n\t}\n\t\n\t// Check if auto-fit should be skipped (used by React useEffect)\n\tshouldSkipAutoFit(): boolean {\n\t\treturn this._skipAutoFit\n\t}\n\n\t// Reset view to default state: 100% zoom, centered at origin\n\tresetView() {\n\t\tconst zoomGroup = this.svg.querySelector('g.zoom') as SVGGElement\n\t\tif (zoomGroup) {\n\t\t\t// Reset to 100% zoom, centered at origin\n\t\t\tzoomGroup.setAttribute('transform', 'scale(1) translate(0, 0)')\n\t\t\tupdatePanning(this)\n\t\t}\n\t\t\n\t\t// Clear any saved view state so this reset position is not overridden\n\t\tclearViewState(this)\n\t}\n\n\t//redraw connected edges\n\tprivate redrawEdges(n: Node) {\n\t\tthis.edges.forEach(e => (n == e.from || n == e.to) && this.redrawEdge(e))\n\t\tthis.updateEdgesSel()\n\t}\n\n\tredrawEdge(e: Edge) {\n\t\tconst p = e.ref.parentElement;\n\t\tp.removeChild(e.ref)\n\t\te.ref = buildEdge(e, this)\n\t\tp.append(e.ref)\n\t}\n\n\tprivate redrawGroups(node: Node) {\n\t\tthis.groupsMap.forEach(group => {\n\t\t\t//if (group.nodes.indexOf(node) == -1) return\n\t\t\tconst p = group.ref.parentElement\n\t\t\tp.removeChild(group.ref)\n\t\t\tbuildGroup(group)\n\t\t\tp.append(group.ref)\n\t\t})\n\t}\n\n\texportSVG() {\n\t\tif (!this.validatedLayout) {\n\t\t\tthis.validatedLayout = validateCurrentLayout(this)\n\t\t}\n\t\t// Get the original SVG\n\t\tconst originalSvg = this.svg\n\t\tconst elastic = originalSvg.querySelector('rect.elastic')\n\t\t\n\t\t// Clone the SVG for export (completely separate from the live one)\n\t\tconst exportSvg = originalSvg.cloneNode(true) as SVGSVGElement\n\t\t// Standalone files keep the ids saved files have always used: the root id\n\t\t// \"graph\", written before the other root attributes as in earlier files,\n\t\t// and this graph's own ids without the live idPrefix.\n\t\tconst rootAttributes = Array.from(exportSvg.attributes)\n\t\trootAttributes.forEach(attr => exportSvg.removeAttributeNode(attr))\n\t\texportSvg.setAttribute('id', 'graph')\n\t\trootAttributes.forEach(attr => exportSvg.setAttributeNode(attr))\n\t\tthis.removeIdPrefix(exportSvg)\n\n\t\t// Standalone SVGs navigate to sibling view files instead of editor routes.\n\t\texportSvg.querySelectorAll('a.nodeLink[data-export-href]').forEach(link => {\n\t\t\tlink.setAttribute('href', link.getAttribute('data-export-href') || '')\n\t\t\tlink.removeAttribute('data-export-href')\n\t\t})\n\t\t\n\t\t// Remove elastic element from export\n\t\tconst exportElastic = exportSvg.querySelector('rect.elastic')\n\t\tif (exportElastic) {\n\t\t\texportElastic.remove()\n\t\t}\n\t\t\n\t\t// Export the exact bounds that passed geometry validation. Recomputing\n\t\t// them here can omit routed relationship labels from the SVG canvas.\n\t\tconst contentBounds = this.validatedLayout.bounds\n\t\t\n\t\t// Add padding around content\n\t\tconst padding = 50\n\t\t\n\t\t// Calculate final export dimensions (always positive)\n\t\tconst exportWidth = contentBounds.width + (padding * 2)\n\t\tconst exportHeight = contentBounds.height + (padding * 2)\n\t\t\n\t\t// Calculate offset to move content to start at (padding, padding) within the export area\n\t\tconst offsetX = -contentBounds.x + padding\n\t\tconst offsetY = -contentBounds.y + padding\n\t\t\n\t\t// Apply export positioning to the cloned SVG elements\n\t\tconst exportZoomGroup = exportSvg.querySelector('g.zoom') as SVGGElement\n\t\tif (exportZoomGroup) {\n\t\t\t// Reset zoom to 1 and apply offset transform to position content properly\n\t\t\texportZoomGroup.setAttribute('transform', `scale(1) translate(${offsetX}, ${offsetY})`)\n\t\t}\n\t\t\n\t\t// Set proper viewBox and dimensions for export - viewBox always starts at (0,0)\n\t\texportSvg.setAttribute('viewBox', `0 0 ${exportWidth} ${exportHeight}`)\n\t\texportSvg.setAttribute('width', String(exportWidth))\n\t\texportSvg.setAttribute('height', String(exportHeight))\n\t\t\n\t\t// Add required SVG namespace for browser compatibility\n\t\texportSvg.setAttribute('xmlns', 'http://www.w3.org/2000/svg')\n\t\t\n\t\t// Convert inline styles to CSS custom properties for theming support\n\t\tthis.convertStylesToCustomProperties(exportSvg)\n\t\t\n\t\t// Inject metadata with current layout\n\t\tconst script = document.createElement('script')\n\t\tscript.setAttribute('type', 'application/json')\n\t\tthis.metadata.layout = this.exportLayout()\n\t\tscript.append('')\n\t\texportSvg.insertBefore(script, exportSvg.firstChild)\n\t\t\n\t\t// Get the export SVG as string\n\t\tconst src = exportSvg.outerHTML\n\t\t\n\t\t// No restoration needed since we never touched the original SVG!\n\t\treturn src\n\t}\n\n\t/**\n\t * removeIdPrefix rewrites the export copy's ids, url(#…) references, and #…\n\t * links that name this graph's own elements back to their saved names, for\n\t * example \"g2-arrow\" to \"arrow\" and \"url(#g2-arrow)\" to \"url(#arrow)\". Values\n\t * that do not start with this graph's idPrefix, such as node links and image\n\t * URLs, stay unchanged.\n\t */\n\tprivate removeIdPrefix(svg: SVGSVGElement) {\n\t\tconst prefix = this.idPrefix\n\t\tsvg.querySelectorAll('*').forEach(el => {\n\t\t\tfor (const attr of Array.from(el.attributes)) {\n\t\t\t\tif (attr.name === 'id' && attr.value.startsWith(prefix)) {\n\t\t\t\t\tattr.value = attr.value.slice(prefix.length)\n\t\t\t\t} else if (attr.value.includes(`url(#${prefix}`)) {\n\t\t\t\t\tattr.value = attr.value.split(`url(#${prefix}`).join('url(#')\n\t\t\t\t} else if (attr.localName === 'href' && attr.value.startsWith(`#${prefix}`)) {\n\t\t\t\t\tattr.value = '#' + attr.value.slice(prefix.length + 1)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\t// Convert inline fill/stroke attributes to CSS custom properties with fallbacks.\n\t// This enables theming: container pages can override colors via CSS variables.\n\tprivate convertStylesToCustomProperties(svg: SVGSVGElement) {\n\t\tif (this.colorToVarMap.size === 0) return\n\n\t\t// Process all elements with fill attribute\n\t\tsvg.querySelectorAll('[fill]').forEach(el => {\n\t\t\tconst fill = el.getAttribute('fill')\n\t\t\tif (fill && this.colorToVarMap.has(fill)) {\n\t\t\t\tel.setAttribute('fill', `var(${this.colorToVarMap.get(fill)}, ${fill})`)\n\t\t\t}\n\t\t})\n\n\t\t// Process all elements with stroke attribute\n\t\tsvg.querySelectorAll('[stroke]').forEach(el => {\n\t\t\tconst stroke = el.getAttribute('stroke')\n\t\t\tif (stroke && this.colorToVarMap.has(stroke)) {\n\t\t\t\tel.setAttribute('stroke', `var(${this.colorToVarMap.get(stroke)}, ${stroke})`)\n\t\t\t}\n\t\t})\n\t}\n\n\t// Calculate the actual bounds of all content including nodes, edges, and groups\n\tcalculateContentBounds(): BBox {\n\t\tlet minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity\n\t\t\n\t\t// Process nodes (including their actual dimensions)\n\t\tthis.nodes().forEach(node => {\n\t\t\tconst left = node.x - node.width / 2\n\t\t\tconst right = node.x + node.width / 2\n\t\t\tconst top = node.y - node.height / 2\n\t\t\tconst bottom = node.y + node.height / 2\n\t\t\t\n\t\t\tminX = Math.min(minX, left)\n\t\t\tmaxX = Math.max(maxX, right)\n\t\t\tminY = Math.min(minY, top)\n\t\t\tmaxY = Math.max(maxY, bottom)\n\t\t})\n\t\t\n\t\t// Process edge vertices (much faster than complex label calculations)\n\t\tthis.edgeVertices.forEach(vertex => {\n\t\t\tminX = Math.min(minX, vertex.x - 5)\n\t\t\tmaxX = Math.max(maxX, vertex.x + 5)\n\t\t\tminY = Math.min(minY, vertex.y - 5)\n\t\t\tmaxY = Math.max(maxY, vertex.y + 5)\n\t\t})\n\t\t\n\t\t// Process groups\n\t\tthis.groupsMap.forEach(group => {\n\t\t\tconst left = group.x - group.width / 2\n\t\t\tconst right = group.x + group.width / 2\n\t\t\tconst top = group.y - group.height / 2\n\t\t\tconst bottom = group.y + group.height / 2\n\t\t\t\n\t\t\tminX = Math.min(minX, left)\n\t\t\tmaxX = Math.max(maxX, right)\n\t\t\tminY = Math.min(minY, top)\n\t\t\tmaxY = Math.max(maxY, bottom)\n\t\t})\n\t\t\n\t\t// Process edges (simplified - just endpoints and vertices, skip complex label calculations)\n\t\tthis.edges.forEach(edge => {\n\t\t\t// Edge endpoints\n\t\t\tminX = Math.min(minX, edge.from.x - 10, edge.to.x - 10)\n\t\t\tmaxX = Math.max(maxX, edge.from.x + 10, edge.to.x + 10)\n\t\t\tminY = Math.min(minY, edge.from.y - 10, edge.to.y - 10)\n\t\t\tmaxY = Math.max(maxY, edge.from.y + 10, edge.to.y + 10)\n\t\t\t\n\t\t\t// Edge vertices (if any)\n\t\t\tif (edge.vertices) {\n\t\t\t\tedge.vertices.forEach(vertex => {\n\t\t\t\t\tminX = Math.min(minX, vertex.x - 10)\n\t\t\t\t\tmaxX = Math.max(maxX, vertex.x + 10)\n\t\t\t\t\tminY = Math.min(minY, vertex.y - 10)\n\t\t\t\t\tmaxY = Math.max(maxY, vertex.y + 10)\n\t\t\t\t})\n\t\t\t}\n\t\t\t\n\t\t\t// Simplified label bounds (avoid expensive path calculations)\n\t\t\tif (edge.label && edge.label.trim()) {\n\t\t\t\t// Just use approximate center between from and to nodes\n\t\t\t\tconst centerX = (edge.from.x + edge.to.x) / 2\n\t\t\t\tconst centerY = (edge.from.y + edge.to.y) / 2\n\t\t\t\tconst approxLabelSize = edge.label.length * 10 + 50 // Rough estimate\n\t\t\t\t\n\t\t\t\tminX = Math.min(minX, centerX - approxLabelSize)\n\t\t\t\tmaxX = Math.max(maxX, centerX + approxLabelSize)\n\t\t\t\tminY = Math.min(minY, centerY - 25)\n\t\t\t\tmaxY = Math.max(maxY, centerY + 25)\n\t\t\t}\n\t\t})\n\t\t\n\t\t// Handle empty graph\n\t\tif (minX === Infinity) {\n\t\t\treturn { x: 0, y: 0, width: 100, height: 100 }\n\t\t}\n\t\t\n\t\treturn {\n\t\t\tx: minX,\n\t\t\ty: minY,\n\t\t\twidth: maxX - minX,\n\t\t\theight: maxY - minY\n\t\t}\n\t}\n\n\n\n\t/**\n\t * @param full when true, the edges without vertices are saved too, used for undo buffer\n\t * for saving, full is false\n\t */\n\texportLayout(full = false) {\n\t\tconst ret: Layout = {}\n\t\tthis.nodes().forEach(n => ret[n.id] = {x: n.x, y: n.y})\n\t\tthis.edges.forEach(e => {\n\t\t\tif (!e.vertices) return\n\t\t\t// Save all vertices (both user and auto-generated), preserving their properties\n\t\t\tconst lst = e.vertices.map(v => ({\n\t\t\t\tx: v.x, \n\t\t\t\ty: v.y, \n\t\t\t\tlabel: v.label,\n\t\t\t\tauto: v.auto // Preserve auto flag so we know which are ELK-generated\n\t\t\t}));\n\t\t\tif (lst.length || full) {\n\t\t\t\tret[`e-${e.id}`] = lst\n\t\t\t}\n\t\t\t// Also save the userDeletedVertices flag as metadata\n\t\t\tif (e.userDeletedVertices) {\n\t\t\t\tret[`e-${e.id}-deleted`] = true\n\t\t\t}\n\t\t})\n\t\treturn ret\n\t}\n\n\tsetSaved() {\n\t\tthis._undo.setSaved()\n\t}\n\n\timportLayout(layout: Layout, rerender = false) {\n\t\tthis.clearResolvedLayout()\n\t\tfor (const [k, v] of Object.entries(layout)) {\n\t\t\tconst n = this.nodesMap.get(k)\n\t\t\tif (n) {\n\t\t\t\tconst point = requiredSavedPoint(k, v)\n\t\t\t\tn.x = point.x\n\t\t\t\tn.y = point.y\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (k.endsWith('-deleted')) {\n\t\t\t\tconst edgeId = k.slice(2, -8); // Remove 'e-' prefix and '-deleted' suffix\n\t\t\t\tconst edge = this.edges.find(candidate => candidate.id === edgeId)\n\t\t\t\tif (!edge || v !== true) {\n\t\t\t\t\tthrow new Error(`invalid deleted-edge layout entry ${k}`)\n\t\t\t\t}\n\t\t\t\tedge.userDeletedVertices = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (k.startsWith('e-')) {\n\t\t\t\tconst edge = this.edges.find(candidate => candidate.id === k.slice(2))\n\t\t\t\tif (!edge || !Array.isArray(v)) {\n\t\t\t\t\tthrow new Error(`invalid edge layout entry ${k}`)\n\t\t\t\t}\n\t\t\t\tfor (const vertex of edge.vertices ?? []) {\n\t\t\t\t\tthis.edgeVertices.delete(vertex.id)\n\t\t\t\t}\n\t\t\t\tedge.vertices = v.map((saved, index) => {\n\t\t\t\t\tconst point = requiredSavedPoint(`${k}[${index}]`, saved)\n\t\t\t\t\tconst vertex = edge.initVertex(point)\n\t\t\t\t\tvertex.label = saved.label\n\t\t\t\t\tvertex.auto = saved.auto\n\t\t\t\t\treturn vertex\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tthrow new Error(`layout contains unknown element ${k}`)\n\t\t}\n\t\tfor (const node of this.nodes()) {\n\t\t\tif (!(node.id in layout)) {\n\t\t\t\tthrow new Error(`layout is missing node ${node.id}`)\n\t\t\t}\n\t\t}\n\t\tif (rerender) {\n\t\t\tthis.nodes().forEach(n => setPosition(n.ref, n.x, n.y))\n\t\t\tthis.edges.forEach(e => this.redrawEdge(e))\n\t\t\tthis.updateEdgesSel()\n\t\t\tthis.redrawGroups(null)\n\t\t}\n\t}\n\n\tasync autoLayout(options?: LayoutOptions) {\n\t\tconst auto = await autoLayout(this, options)\n\t\tthis._undo.beforeChange()\n\n\t\tfor (const placedNode of auto.nodes) {\n\t\t\tconst node = this.nodesMap.get(placedNode.id)\n\t\t\tif (!node) {\n\t\t\t\tthrow new Error(`layout contains unknown node ${placedNode.id}`)\n\t\t\t}\n\t\t\tnode.x = placedNode.x\n\t\t\tnode.y = placedNode.y\n\t\t\tsetPosition(node.ref, node.x, node.y)\n\t\t}\n\n\t\tfor (const placedGroup of auto.groups) {\n\t\t\tconst group = this.groupsMap.get(placedGroup.id)\n\t\t\tif (!group) {\n\t\t\t\tthrow new Error(`layout contains unknown group ${placedGroup.id}`)\n\t\t\t}\n\t\t\tgroup.layoutBounds = placedGroup.bounds\n\t\t\tgroup.layoutTitleBounds = placedGroup.titleBounds\n\t\t\tgroup.x = placedGroup.bounds.x + placedGroup.bounds.width / 2\n\t\t\tgroup.y = placedGroup.bounds.y + placedGroup.bounds.height / 2\n\t\t\tgroup.width = placedGroup.bounds.width\n\t\t\tgroup.height = placedGroup.bounds.height\n\t\t}\n\n\t\tfor (const placedEdge of auto.edges) {\n\t\t\tconst edge = this.edges.find(candidate => candidate.id === placedEdge.id)\n\t\t\tif (!edge) {\n\t\t\t\tthrow new Error(`layout contains unknown edge ${placedEdge.id}`)\n\t\t\t}\n\t\t\tfor (const vertex of edge.vertices ?? []) {\n\t\t\t\tthis.edgeVertices.delete(vertex.id)\n\t\t\t}\n\t\t\tedge.layoutSections = placedEdge.sections\n\t\t\tedge.layoutLabelBounds = placedEdge.labelBounds\n\t\t\tedge.vertices = interiorRoutePoints(placedEdge.sections).map(point => {\n\t\t\t\tconst vertex = edge.initVertex(point)\n\t\t\t\tvertex.auto = true\n\t\t\t\treturn vertex\n\t\t\t})\n\t\t\tedge.userDeletedVertices = false\n\t\t}\n\n\t\tthis.validatedLayout = auto.validated\n\t\tthis.edges.forEach(edge => this.redrawEdge(edge))\n\t\tthis.redrawGroups(null)\n\t\tthis.fitToView()\n\t\tthis._undo.change()\n\t}\n\n\talignSelectionV() {\n\t\tconst lst: Point[] = this.nodes().filter(n => n.selected)\n\t\tlst.push(...Array.from(this.edgeVertices.values()).filter(v => v.selected))\n\t\tlet minY = Math.min(...lst.map(p => p.y))\n\t\tthis.nodesMap.forEach(n => n.selected && this.moveNode(n, n.x, minY, false, false))\n\t\tthis.edgeVertices.forEach(v => v.selected && this.moveEdgeVertex(v, v.x, minY, false, false))\n\t}\n\n\talignSelectionH() {\n\t\tconst lst: Point[] = this.nodes().filter(n => n.selected)\n\t\tlst.push(...Array.from(this.edgeVertices.values()).filter(v => v.selected))\n\t\tlet minX = Math.min(...lst.map(p => p.x))\n\t\tthis.nodesMap.forEach(n => n.selected && this.moveNode(n, minX, n.y, false, false))\n\t\tthis.edgeVertices.forEach(v => v.selected && this.moveEdgeVertex(v, minX, v.y, false, false))\n\t}\n\n\tdistributeSelectionH() {\n\t\tconst selectedNodes = this.nodes().filter(n => n.selected)\n\t\tconst selectedVertices = Array.from(this.edgeVertices.values()).filter(v => v.selected)\n\t\t\n\t\tif (selectedNodes.length + selectedVertices.length < 3) return // Need at least 3 elements to distribute\n\t\t\n\t\tthis._undo.beforeChange()\n\t\t\n\t\t// Combine and sort by X coordinate\n\t\tconst allElements = [...selectedNodes, ...selectedVertices]\n\t\tallElements.sort((a, b) => a.x - b.x)\n\t\t\n\t\tconst minX = allElements[0].x\n\t\tconst maxX = allElements[allElements.length - 1].x\n\t\tconst spacing = (maxX - minX) / (allElements.length - 1)\n\t\t\n\t\t// Distribute elements evenly between leftmost and rightmost\n\t\tallElements.forEach((element, index) => {\n\t\t\tconst newX = minX + (index * spacing)\n\t\t\tif ('title' in element) {\n\t\t\t\t// It's a Node\n\t\t\t\tthis.moveNode(element as Node, newX, element.y, false, true)\n\t\t\t} else {\n\t\t\t\t// It's an EdgeVertex\n\t\t\t\tthis.moveEdgeVertex(element as EdgeVertex, newX, element.y, false, true)\n\t\t\t}\n\t\t})\n\t\t\n\t\tthis._undo.change()\n\t}\n\n\tdistributeSelectionV() {\n\t\tconst selectedNodes = this.nodes().filter(n => n.selected)\n\t\tconst selectedVertices = Array.from(this.edgeVertices.values()).filter(v => v.selected)\n\t\t\n\t\tif (selectedNodes.length + selectedVertices.length < 3) return // Need at least 3 elements to distribute\n\t\t\n\t\tthis._undo.beforeChange()\n\t\t\n\t\t// Combine and sort by Y coordinate\n\t\tconst allElements = [...selectedNodes, ...selectedVertices]\n\t\tallElements.sort((a, b) => a.y - b.y)\n\t\t\n\t\tconst minY = allElements[0].y\n\t\tconst maxY = allElements[allElements.length - 1].y\n\t\tconst spacing = (maxY - minY) / (allElements.length - 1)\n\t\t\n\t\t// Distribute elements evenly between topmost and bottommost\n\t\tallElements.forEach((element, index) => {\n\t\t\tconst newY = minY + (index * spacing)\n\t\t\tif ('title' in element) {\n\t\t\t\t// It's a Node\n\t\t\t\tthis.moveNode(element as Node, element.x, newY, false, true)\n\t\t\t} else {\n\t\t\t\t// It's an EdgeVertex\n\t\t\t\tthis.moveEdgeVertex(element as EdgeVertex, element.x, newY, false, true)\n\t\t\t}\n\t\t})\n\t\t\n\t\tthis._undo.change()\n\t}\n\n\t// Set edge selection state\n\tsetEdgeSelected(edge: Edge, selected: boolean) {\n\t\t// Mark the edge as selected by selecting its connected nodes\n\t\tif (selected) {\n\t\t\tthis.setNodeSelected(edge.from, true)\n\t\t\tthis.setNodeSelected(edge.to, true)\n\t\t}\n\t\t// Update visual selection\n\t\tthis.updateEdgesSel()\n\t}\n\n\t// Fit the entire graph to the current viewport\n\tfitToView() {\n\t\tconst contentBounds = this.calculateContentBounds()\n\t\t\n\t\t// Handle edge case where there's no content\n\t\tif (contentBounds.width === 0 || contentBounds.height === 0) {\n\t\t\treturn\n\t\t}\n\t\t\n\t\t// Get viewport dimensions\n\t\tconst viewportWidth = this.svg.parentElement?.clientWidth || 800\n\t\tconst viewportHeight = this.svg.parentElement?.clientHeight || 600\n\t\t\n\t\t// Add padding around content\n\t\tconst padding = 40\n\t\t\n\t\t// Calculate zoom to fit content with padding\n\t\tconst zoomX = (viewportWidth - padding * 2) / contentBounds.width\n\t\tconst zoomY = (viewportHeight - padding * 2) / contentBounds.height\n\t\tconst optimalZoom = Math.min(zoomX, zoomY)\n\t\t\n\t\t// Clamp zoom between reasonable bounds\n\t\tconst finalZoom = Math.max(Math.min(optimalZoom, 2), 0.1)\n\t\t\n\t\t// Calculate content center in drawing coordinates\n\t\tconst contentCenterX = contentBounds.x + contentBounds.width / 2\n\t\tconst contentCenterY = contentBounds.y + contentBounds.height / 2\n\t\t\n\t\t// Calculate viewport center in screen coordinates\n\t\tconst viewportCenterX = viewportWidth / 2\n\t\tconst viewportCenterY = viewportHeight / 2\n\t\t\n\t\t// Calculate translation needed to center content in viewport\n\t\t// With translate(x,y) scale(zoom), translation is in screen coordinates\n\t\tconst translateX = viewportCenterX - (contentCenterX * finalZoom)\n\t\tconst translateY = viewportCenterY - (contentCenterY * finalZoom)\n\t\t\n\t\t// Apply zoom and translation transform\n\t\tconst zoomGroup = this.svg.querySelector('g.zoom') as SVGGElement\n\t\tif (zoomGroup) {\n\t\t\tzoomGroup.setAttribute('transform', `translate(${translateX}, ${translateY}) scale(${finalZoom})`)\n\t\t}\n\t\t\n\t\t// Update panning\n\t\tupdatePanning(this)\n\t\t\n\t\t// Save view state so this fit position is preserved after reload\n\t\tsaveViewState(this)\n\t}\n\n\t// Save current layout state for restoration\n\tprivate saveLayoutState(): Layout {\n\t\treturn this.exportLayout(true) // Include all vertices for complete state\n\t}\n\n\t// Restore layout state\n\tprivate restoreLayoutState(state: Layout) {\n\t\tthis.importLayout(state, true) // Rerender after restoring\n\t}\n\n\t// Grid functionality\n\tisGridVisible(): boolean {\n\t\treturn this._gridVisible;\n\t}\n\n\tisSnapToGrid(): boolean {\n\t\treturn this._snapToGrid;\n\t}\n\n\tgetGridSize(): number {\n\t\treturn this._gridSize;\n\t}\n\n\ttoggleGrid() {\n\t\tthis._gridVisible = !this._gridVisible;\n\t\tthis.updateGridDisplay();\n\t\t// Force toolbar update by dispatching a custom event\n\t\twindow.dispatchEvent(new CustomEvent('gridStateChanged'));\n\t}\n\n\ttoggleSnapToGrid() {\n\t\tthis._snapToGrid = !this._snapToGrid;\n\t\t// Force toolbar update by dispatching a custom event\n\t\twindow.dispatchEvent(new CustomEvent('gridStateChanged'));\n\t}\n\n\tsnapAllToGrid() {\n\t\tif (!this._snapToGrid) return;\n\t\t\n\t\tthis._undo.beforeChange();\n\t\tthis.nodes().forEach(node => {\n\t\t\tconst snappedX = Math.round(node.x / this._gridSize) * this._gridSize;\n\t\t\tconst snappedY = Math.round(node.y / this._gridSize) * this._gridSize;\n\t\t\tthis.moveNode(node, snappedX, snappedY, false, true);\n\t\t});\n\t\tthis._undo.change();\n\t}\n\n\t// Helper method to snap a point to grid\n\tprivate snapToGrid(x: number, y: number): { x: number, y: number } {\n\t\treturn {\n\t\t\tx: Math.round(x / this._gridSize) * this._gridSize,\n\t\t\ty: Math.round(y / this._gridSize) * this._gridSize\n\t\t};\n\t}\n\n\tupdateGridDisplay() {\n\t\tconst svg = this.svg;\n\n\t\t// Remove existing grid pattern and background\n\t\tconst existingGrid = svg.querySelector(`#${this.idPrefix}grid-pattern`);\n\t\tif (existingGrid) {\n\t\t\texistingGrid.remove();\n\t\t}\n\n\t\tconst existingGridRect = svg.querySelector(`#${this.idPrefix}grid-background`);\n\t\tif (existingGridRect) {\n\t\t\texistingGridRect.remove();\n\t\t}\n\n\t\tif (!this._gridVisible) return;\n\n\t\t// Create grid pattern in defs\n\t\tlet defs = svg.querySelector('defs');\n\t\tif (!defs) {\n\t\t\tdefs = document.createElementNS('http://www.w3.org/2000/svg', 'defs');\n\t\t\tsvg.insertBefore(defs, svg.firstChild);\n\t\t}\n\n\t\tconst pattern = document.createElementNS('http://www.w3.org/2000/svg', 'pattern');\n\t\tpattern.id = `${this.idPrefix}grid-pattern`;\n\t\tpattern.setAttribute('width', this._gridSize.toString());\n\t\tpattern.setAttribute('height', this._gridSize.toString());\n\t\tpattern.setAttribute('patternUnits', 'userSpaceOnUse');\n\n\t\tconst path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n\t\tpath.setAttribute('d', `M ${this._gridSize} 0 L 0 0 0 ${this._gridSize}`);\n\t\tpath.setAttribute('fill', 'none');\n\t\tpath.setAttribute('stroke', '#d0d0d0');\n\t\tpath.setAttribute('stroke-width', '1');\n\t\tpath.setAttribute('opacity', '0.8');\n\n\t\tpattern.appendChild(path);\n\t\tdefs.appendChild(pattern);\n\n\t\t// Create grid background rectangle\n\t\tconst rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\n\t\trect.id = `${this.idPrefix}grid-background`;\n\t\trect.setAttribute('x', '-10000');\n\t\trect.setAttribute('y', '-10000');\n\t\trect.setAttribute('width', '20000');\n\t\trect.setAttribute('height', '20000');\n\t\trect.setAttribute('fill', `url(#${this.idPrefix}grid-pattern)`);\n\t\trect.setAttribute('pointer-events', 'none');\n\n\t\t// Insert grid as first child of zoom group so it transforms with content\n\t\tconst zoomGroup = svg.querySelector('g.zoom');\n\t\tif (zoomGroup) {\n\t\t\tzoomGroup.insertBefore(rect, zoomGroup.firstChild);\n\t\t}\n\t}\n}\n\n/** interiorRoutePoints returns only the editable points between edge endpoints. */\nfunction interiorRoutePoints(sections: Point[][]): Point[] {\n\tconst route: Point[] = []\n\tfor (const section of sections) {\n\t\tfor (const point of section) {\n\t\t\tconst previous = route[route.length - 1]\n\t\t\tif (!previous || previous.x !== point.x || previous.y !== point.y) {\n\t\t\t\troute.push(point)\n\t\t\t}\n\t\t}\n\t}\n\treturn route.slice(1, -1)\n}\n\n/** requiredSavedPoint checks coordinates when reading saved editor layout data. */\nfunction requiredSavedPoint(\n\tid: string,\n\tvalue: Point | SavedEdgePoint | SavedEdgePoint[] | boolean,\n): SavedEdgePoint {\n\tif (\n\t\ttypeof value !== 'object' ||\n\t\tArray.isArray(value) ||\n\t\t!Number.isFinite(value.x) ||\n\t\t!Number.isFinite(value.y)\n\t) {\n\t\tthrow new Error(`layout entry ${id} must contain valid x and y coordinates`)\n\t}\n\treturn value\n}\n\nfunction escapeCdata(code: string) {\n\treturn code.replace(/]]>/g, ']]]>]> void, dragMode: 'pan' | 'select') => {\n\tconst svg = data.svg\n\tsvg.setAttribute('width', '100%')\n\tsvg.setAttribute('height', '100%')\n\tdocument.body.append(svg) // make sure svg element is connected, we will measure texts sizes\n\n\tdata.selectListener = onNodeSelect\n\n\t_buildGraph(data)\n\tconst elasticEl = create.rect(300, 300, 50, 50, 0, 'elastic')\n\tsvg.append(elasticEl)\n\n\t// Initialize grid display now that the zoom group exists\n\tdata.updateGridDisplay()\n\n\t// Call addCursorInteraction with dragMode\n\taddCursorInteraction(data, dragMode)\n\n\treturn {\n\t\tsvg,\n\t\tsetZoom: (zoom: number) => setZoom(data, zoom),\n\t}\n}\n\n/** buildGraphView draws data into its own svg without editor handling and returns that svg. */\nexport const buildGraphView = (data: GraphData) => {\n\t_buildGraph(data)\n\treturn data.svg\n}\n\nconst _buildGraph = (data: GraphData) => {\n\t// Every graph owns the reusable SVG definitions referenced by its drawn\n\t// elements, including relationship arrowheads, icons, and filters.\n\tdata.svg.innerHTML = defs(data.idPrefix)\n\n\t//toplevel groups\n\tconst zoomG = create.element('g', {}, 'zoom') as SVGGElement\n\tconst nodesG = create.element('g', {}, 'nodes') as SVGGElement\n\tconst edgesG = create.element('g', {}, 'edges') as SVGGElement\n\tconst groupsG = create.element('g', {}, 'groups') as SVGGElement\n\tzoomG.append(groupsG, edgesG, nodesG)\n\n\n\tdata.nodesMap.forEach((n) => {\n\t\tbuildNode(n, data)\n\t\tnodesG.append(n.ref)\n\t})\n\n\tdata.edges.forEach(edge => {\n\t\tedge.labelBounds = undefined\n\t})\n\tdata.edges.forEach(e => {\n\t\tbuildEdge(e, data)\n\t\tedgesG.append(e.ref)\n\t})\n\n\tdata.groupsMap.forEach((group) => {\n\t\tbuildGroup(group)\n\t\tgroupsG.append(group.ref)\n\t})\n\n\tdata.svg.append(zoomG)\n}\n\n/** buildEdge draws one relationship of data, using data's idPrefix for its ids and arrowhead. */\nfunction buildEdge(edge: Edge, data: GraphData) {\n\tconst n1 = edge.from;\n\n\tconst g = create.element('g', {}, 'edge') as SVGGElement\n\tg.setAttribute('id', data.idPrefix + edge.id)\n\tg.setAttribute('data-from', edge.from.id)\n\tg.setAttribute('data-to', edge.to.id)\n\n\tconst position = (edge.style.position || 50) / 100\n\n\tconst vertices = edge.layoutSections\n\t\t? completeRoutePoints(edge.layoutSections)\n\t\t: calculateEdgeVertices(edge)\n\tconst {bg, txt} = edge.layoutLabelBounds\n\t\t? buildPlacedEdgeLabel(edge.layoutLabelBounds, edge)\n\t\t: buildEdgeLabel(calculateLabelPlacement(vertices, position, n1), edge)\n\tg.append(bg, txt)\n\n\tconst path = createEdgePath(vertices)\n\n\tconst p = create.path(path, {'marker-end': `url(#${data.idPrefix}arrow)`}, 'edge')\n\tp.setAttribute('fill', 'none')\n\tp.setAttribute('stroke', edge.style.color)\n\tp.setAttribute('stroke-width', String(edge.style.thickness))\n\tp.setAttribute('stroke-linecap', 'round')\n\tedge.style.dashed && p.setAttribute('stroke-dasharray', '8')\n\tg.append(p)\n\t\n\t// Debug visualization removed - arrow issue fixed\n\n\t// drag handlers\n\tfor (const p of edge.vertices ?? []) {\n\t\tconst v = p as EdgeVertex\n\t\tv.ref = create.element('circle', {id: data.idPrefix + v.id, cx: p.x, cy: p.y, r: 7, fill: 'none'}, 'v-dot')\n\t\tv.selected && v.ref.classList.add('selected')\n\t\tv.auto && v.ref.classList.add('auto')\n\t\tg.append(v.ref)\n\t}\n\n\tedge.ref = g\n\treturn g\n}\n\n/** completeRoutePoints joins connected layout sections without duplicate points. */\nfunction completeRoutePoints(sections: Point[][]): Point[] {\n\tconst route: Point[] = []\n\tfor (const section of sections) {\n\t\tfor (const point of section) {\n\t\t\tconst previous = route[route.length - 1]\n\t\t\tif (!previous || previous.x !== point.x || previous.y !== point.y) {\n\t\t\t\troute.push(point)\n\t\t\t}\n\t\t}\n\t}\n\treturn route\n}\n\n/** buildPlacedEdgeLabel draws one label in the box chosen by layout. */\nfunction buildPlacedEdgeLabel(bounds: BBox, edge: Edge) {\n\tconst centerX = bounds.x + bounds.width / 2\n\tconst centerY = bounds.y + bounds.height / 2\n\tconst {txt} = create.textArea(\n\t\tedge.label,\n\t\tedge.style.width,\n\t\tedge.style.fontSize,\n\t\tfalse,\n\t\tcenterX,\n\t\tbounds.y,\n\t\t'middle',\n\t)\n\tapplyStyle(txt, SVG_STYLES.edgeText)\n\ttxt.setAttribute('stroke', 'none')\n\ttxt.setAttribute('font-size', String(edge.style.fontSize))\n\ttxt.setAttribute('fill', edge.style.color)\n\ttxt.setAttribute('data-field', 'label')\n\tconst bg = create.rect(bounds.width, bounds.height, bounds.x, bounds.y)\n\tapplyStyle(bg, SVG_STYLES.edgeRect)\n\treturn {\n\t\tbg,\n\t\ttxt,\n\t}\n}\n\n/**\n * buildEdgeLabel adapts an older saved label anchor into a complete label box.\n * It uses one fixed side and lets validation reject any resulting collision.\n */\nfunction buildEdgeLabel(placement: EdgeLabelPlacement, edge: Edge) {\n\tconst labelGap = 12;\n\tconst fontSize = edge.style.fontSize\n\tlet {txt, dy, maxW} = create.textArea(edge.label, edge.style.width, fontSize, false, placement.x, placement.y, 'middle')\n\tdy -= fontSize / 2\n\tmaxW += fontSize\n\tconst centerX = placement.orientation === 'vertical'\n\t\t? placement.x + maxW / 2 + labelGap\n\t\t: placement.x\n\tconst centerY = placement.orientation === 'vertical'\n\t\t? placement.y\n\t\t: placement.y - dy / 2 - labelGap\n\tconst bounds = {\n\t\tx: centerX - maxW / 2,\n\t\ty: centerY - dy / 2,\n\t\twidth: maxW,\n\t\theight: dy,\n\t}\n\ttxt.querySelectorAll('tspan').forEach((span: SVGTSpanElement) => {\n\t\tspan.setAttribute('x', String(centerX))\n\t})\n\ttxt.setAttribute('y', String(centerY - dy / 2))\n\n\tapplyStyle(txt, SVG_STYLES.edgeText)\n\ttxt.setAttribute('stroke', 'none')\n\ttxt.setAttribute('font-size', String(edge.style.fontSize))\n\ttxt.setAttribute('fill', edge.style.color)\n\n\tconst bg = create.rect(bounds.width, bounds.height, bounds.x, bounds.y)\n\tapplyStyle(bg, SVG_STYLES.edgeRect)\n\ttxt.setAttribute('data-field', 'label')\n\tedge.labelBounds = bounds\n\treturn {bg, txt}\n}\n\n\n/** buildNode draws one element of data, using data's idPrefix for its id. */\nfunction buildNode(n: Node, data: GraphData) {\n\tconst g = create.element('g', {}, 'node') as SVGGElement\n\tg.setAttribute('id', data.idPrefix + n.id)\n\tn.selected && g.classList.add('selected')\n\tsetPosition(g, n.x, n.y)\n\tconst link = n.link\n\t\t? create.element('a', {\n\t\t\thref: n.link.href,\n\t\t\t'data-export-href': n.link.exportHref,\n\t\t\t'aria-label': `Open ${n.title}`,\n\t\t}, 'nodeLink') as SVGAElement\n\t\t: null\n\tconst content = link || g\n\tif (link) {\n\t\tg.classList.add('linked')\n\t\tg.append(link)\n\t}\n\n\t// Ensure we use the correct shape from style, defaulting to Box\n\tconst shapeType = n.style.shape || 'Box';\n\tconst shapeFn = shapes[shapeType.toLowerCase()] || shapes.box\n\tconst shape: SVGElement = shapeFn(content, n);\n\n\tshape.classList.add('nodeBorder')\n\n\t// Apply generic styles first\n\tapplyStyle(shape, SVG_STYLES.nodeBorder)\n\t// Then apply tag-specific styles to override generic ones\n\tshape.setAttribute('fill', n.style.background)\n\tshape.setAttribute('stroke', n.style.stroke)\n\tshape.setAttribute('opacity', String(n.style.opacity))\n\tsetBorderStyle(shape, n.style.border)\n\n\tconst tg = buildNodeContent(n.contentLayout, n.style.color)\n\tconst labelOffsetY = Number(content.getAttribute('label-offset-y')) || 0\n\tsetPosition(tg, 0, labelOffsetY / 2)\n\tcontent.append(tg)\n\n\t// @ts-ignore\n\tg.__data = n;\n\tn.ref = g;\n\n\treturn g\n}\n\n\nfunction buildGroup(group: Group) {\n\tif (group.nodes.length == 0) {\n\t\treturn\n\t}\n\tconst g = create.element('g', {}, 'group') as SVGGElement\n\tif (group.layoutBounds && group.layoutTitleBounds) {\n\t\tconst bounds = group.layoutBounds\n\t\tconst title = group.layoutTitleBounds\n\t\tconst rect = create.rect(bounds.width, bounds.height, bounds.x, bounds.y)\n\t\tapplyStyle(rect, SVG_STYLES.groupRect)\n\t\tgroup.style.stroke && rect.setAttribute('stroke', group.style.stroke)\n\t\tgroup.style.background && rect.setAttribute('fill', group.style.background)\n\t\tconst text = create.text(group.name, {\n\t\t\tx: title.x,\n\t\t\ty: title.y,\n\t\t\t'dominant-baseline': 'hanging',\n\t\t})\n\t\tapplyStyle(text, SVG_STYLES.groupText)\n\t\tgroup.style.color && text.setAttribute('fill', group.style.color)\n\t\tg.append(rect, text)\n\t\tgroup.ref = g\n\t\treturn\n\t}\n\n\tlet p0: Point = {x: 1e100, y: 1e100}, p1: Point = {x: 0, y: 0}\n\tgroup.nodes.forEach(n => {\n\t\t// Calculate visual bounds accounting for shapes that extend beyond center\n\t\tconst shape = (n as Node).style?.shape?.toLowerCase() || 'box'\n\t\t\n\t\tlet topExtension = n.height / 2\n\t\tlet bottomExtension = n.height / 2\n\t\t\n\t\tif (shape === 'robot') {\n\t\t\t// Robot shape extends above with antenna\n\t\t\t// Account for antenna height (h * 0.08) plus some margin\n\t\t\tconst antennaH = n.height * 0.12\n\t\t\ttopExtension = n.height / 2 + antennaH\n\t\t\tbottomExtension = n.height / 2\n\t\t} else if (shape === 'hexagon') {\n\t\t\t// Hexagon extends to ±0.866 * (width/2) vertically\n\t\t\t// For width=280, that's ±121.24px from center\n\t\t\tconst hexHeight = n.width / 2 * 0.866\n\t\t\ttopExtension = hexHeight\n\t\t\tbottomExtension = hexHeight\n\t\t}\n\t\t\n\t\tconst b = {\n\t\t\tx: n.x - n.width / 2,\n\t\t\ty: n.y - topExtension,\n\t\t\twidth: n.width,\n\t\t\theight: topExtension + bottomExtension\n\t\t}\n\t\tp0.x = Math.min(p0.x, b.x)\n\t\tp0.y = Math.min(p0.y, b.y)\n\t\tp1.x = Math.max(p1.x, b.x + b.width)\n\t\tp1.y = Math.max(p1.y, b.y + b.height)\n\t})\n\tconst pad = 25 // Padding around content\n\tconst labelHeight = 30 // Space for the group label at bottom\n\tconst w = Math.max(p1.x - p0.x, 200)\n\tconst h = p1.y - p0.y\n\tconst bb = {\n\t\tx: p0.x - pad,\n\t\ty: p0.y - pad,\n\t\twidth: w + pad * 2,\n\t\theight: h + pad * 2 + labelHeight,\n\t}\n\tconst r = create.rect(bb.width, bb.height, bb.x, bb.y)\n\tgroup.x = bb.x + bb.width / 2\n\tgroup.y = bb.y + bb.height / 2\n\tgroup.width = bb.width\n\tgroup.height = bb.height\n\tapplyStyle(r, SVG_STYLES.groupRect)\n\tgroup.style.stroke && r.setAttribute('stroke', group.style.stroke)\n\tgroup.style.background && r.setAttribute('fill', group.style.background)\n\n\tconst txt = create.text(group.name, {x: p0.x, y: bb.y + bb.height - SVG_STYLES.groupText[\"font-size\"]})\n\tapplyStyle(txt, SVG_STYLES.groupText)\n\tgroup.style.color && txt.setAttribute('fill', group.style.color)\n\n\tg.append(r, txt)\n\tgroup.ref = g\n}\n\nfunction findClosestSegment(graph: GraphData, p: Point) {\n\t// find the closest point on a segment\n\tlet fnd = {dst: Number.POSITIVE_INFINITY, pos: -1, edge: null as Edge, prj: null as Point}\n\tgraph.edges.forEach(edge => {\n\t\tconst vertices = edge.vertices || []\n\t\tconst pts = [edge.from, ...vertices, edge.to]\n\t\tfor (let i = 1; i < pts.length; i++) {\n\t\t\tconst prj = project(p, pts[i - 1], pts[i])\n\t\t\tconst dst = cabDistance(p, prj)\n\t\t\tif (dst > 50) continue\n\t\t\tif (dst < fnd.dst) {\n\t\t\t\tfnd = {dst, pos: i, prj, edge}\n\t\t\t}\n\t\t}\n\t})\n\treturn fnd.edge ? fnd : null\n}\n\n/** mouseToDrawing converts a mouse event over data's svg to drawing coordinates. */\nfunction mouseToDrawing(data: GraphData, e: MouseEvent): Point {\n\t// transform event coords to drawing coords\n\tconst b = data.svg.getBoundingClientRect()\n\tconst z = getZoom(data)\n\t\n\t// Get current pan transform\n\tconst currentTransform = getCurrentTransform(data)\n\t\n\t// Convert screen coordinates to drawing coordinates accounting for zoom and pan\n\t// The transform values are in screen coordinates, so we need to divide by zoom and subtract\n\treturn {\n\t\tx: (e.clientX - b.x - currentTransform.x) / z,\n\t\ty: (e.clientY - b.y - currentTransform.y) / z\n\t}\n}\n\ninterface Handle extends Point {\n\tid: string\n\tselected?: boolean\n\tref?: SVGElement\n}\n\n// Custom cursor interaction that prioritizes panning over selection, on data's svg\nfunction addCustomCursorInteraction(data: GraphData, conn: {\n\tnodeFromEvent(e: MouseEvent): Handle | null;\n\tsetSelection(handles: Handle[]): void;\n\tsetDragging(dragging: boolean): void;\n\tisSelected(handle: Handle): boolean;\n\tgetSelection(): Handle[];\n\tgetZoom(): number;\n\tmoveNode(h: Handle, x: number, y: number): void;\n\tboxSelection(box: DOMRect, add: boolean): void;\n\tupdatePanning(): void;\n}, dragMode: 'pan' | 'select') {\n\tconst svg = data.svg\n\tlet ini: { x: number; y: number; n: Handle }[] = []\n\tlet elastic: any = null\n\tlet isPanning = false\n\tlet panStartX = 0\n\tlet panStartY = 0\n\tlet initialTransform = { x: 0, y: 0 }\n\tlet pendingSelectionChange: { node: Handle; shiftKey: boolean } | null = null\n\tlet pendingNavigation: string | null = null\n\tlet hasDragged = false\n\tlet suppressLinkClick = false\n\t\n\t// Store event listeners for cleanup\n\tconst eventListeners: Array<{ element: Element | Window, event: string, handler: EventListener }> = []\n\n\t// Simple elastic selection box implementation - use mouseToDrawing for proper coordinate conversion\n\tfunction createElastic() {\n\t\tlet startDrawingX = 0, startDrawingY = 0, rect: SVGRectElement | null = null\n\t\t\n\t\treturn {\n\t\t\tini(e: MouseEvent) {\n\t\t\t\t// Use mouseToDrawing to get proper drawing coordinates (accounts for zoom and pan)\n\t\t\t\tconst pt = mouseToDrawing(data, e)\n\t\t\t\tstartDrawingX = pt.x\n\t\t\t\tstartDrawingY = pt.y\n\t\t\t\t\n\t\t\t\trect = document.createElementNS(\"http://www.w3.org/2000/svg\", \"rect\")\n\t\t\t\trect.setAttribute('fill', 'rgba(0, 100, 255, 0.1)')\n\t\t\t\trect.setAttribute('stroke', 'rgba(0, 100, 255, 0.5)')\n\t\t\t\trect.setAttribute('stroke-width', '1')\n\t\t\t\trect.setAttribute('stroke-dasharray', '3,3')\n\t\t\t\trect.setAttribute('x', String(startDrawingX))\n\t\t\t\trect.setAttribute('y', String(startDrawingY))\n\t\t\t\trect.setAttribute('width', '0')\n\t\t\t\trect.setAttribute('height', '0')\n\t\t\t\t\n\t\t\t\t// Add to the zoom group so it transforms with the content\n\t\t\t\tconst zoomGroup = svg.querySelector('g.zoom')\n\t\t\t\tif (zoomGroup) {\n\t\t\t\t\tzoomGroup.appendChild(rect)\n\t\t\t\t} else {\n\t\t\t\t\tsvg.appendChild(rect)\n\t\t\t\t}\n\t\t\t},\n\t\t\tupdate(e: MouseEvent) {\n\t\t\t\tif (!rect) return\n\t\t\t\t\n\t\t\t\t// Convert current mouse position to drawing coordinates (accounts for zoom and pan)\n\t\t\t\tconst currentPt = mouseToDrawing(data, e)\n\t\t\t\tconst currentDrawingX = currentPt.x\n\t\t\t\tconst currentDrawingY = currentPt.y\n\t\t\t\t\n\t\t\t\t// Calculate rectangle bounds in drawing coordinates\n\t\t\t\tconst x = Math.min(startDrawingX, currentDrawingX)\n\t\t\t\tconst y = Math.min(startDrawingY, currentDrawingY)\n\t\t\t\tconst width = Math.abs(currentDrawingX - startDrawingX)\n\t\t\t\tconst height = Math.abs(currentDrawingY - startDrawingY)\n\t\t\t\t\n\t\t\t\trect.setAttribute('x', String(x))\n\t\t\t\trect.setAttribute('y', String(y))\n\t\t\t\trect.setAttribute('width', String(width))\n\t\t\t\trect.setAttribute('height', String(height))\n\t\t\t},\n\t\t\tend(): DOMRect | null {\n\t\t\t\tif (!rect) return null\n\t\t\t\t\n\t\t\t\t// Get final rectangle bounds in drawing coordinates\n\t\t\t\tconst x = parseFloat(rect.getAttribute('x') || '0')\n\t\t\t\tconst y = parseFloat(rect.getAttribute('y') || '0')\n\t\t\t\tconst width = parseFloat(rect.getAttribute('width') || '0')\n\t\t\t\tconst height = parseFloat(rect.getAttribute('height') || '0')\n\t\t\t\t\n\t\t\t\trect.remove()\n\t\t\t\trect = null\n\t\t\t\t\n\t\t\t\t// Return drawing coordinates directly for boxSelection since we're now working in the same coordinate system\n\t\t\t\tif (width > 5 && height > 5) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tx: x, y: y, width: width, height: height,\n\t\t\t\t\t\tleft: x, top: y, right: x + width, bottom: y + height\n\t\t\t\t\t} as DOMRect\n\t\t\t\t}\n\t\t\t\treturn null\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction getCurrentTransformLocal() {\n\t\tconst zoomGroup = svg.querySelector('g.zoom') as SVGGElement\n\t\tif (!zoomGroup) return { x: 0, y: 0 }\n\t\t\n\t\tconst transform = zoomGroup.getAttribute('transform') || ''\n\t\tconst translateMatch = transform.match(/translate\\(([^,]+),([^)]+)\\)/)\n\t\tif (translateMatch) {\n\t\t\treturn {\n\t\t\t\tx: parseFloat(translateMatch[1]) || 0,\n\t\t\t\ty: parseFloat(translateMatch[2]) || 0\n\t\t\t}\n\t\t}\n\t\treturn { x: 0, y: 0 }\n\t}\n\n\tfunction setTransform(x: number, y: number) {\n\t\tconst zoomGroup = svg.querySelector('g.zoom') as SVGGElement\n\t\tif (!zoomGroup) return\n\t\t\n\t\tconst zoom = getZoom(data)\n\t\tzoomGroup.setAttribute('transform', `translate(${x}, ${y}) scale(${zoom})`)\n\t}\n\n\tfunction onMouseDown(e: MouseEvent) {\n\t\te.preventDefault();\n\t\thasDragged = false\n\t\tpendingSelectionChange = null\n\t\tconst target = e.target\n\t\tconst link = target instanceof Element ? target.closest('a.nodeLink') : null\n\t\tpendingNavigation = e.shiftKey ? null : link?.getAttribute('href') || null\n\n\t\tconst node = conn.nodeFromEvent(e)\n\t\t\n\t\t// Determine effective mode: invert if shift is held\n\t\tconst effectiveMode = e.shiftKey ? (dragMode === 'pan' ? 'select' : 'pan') : dragMode\n\t\t\n\t\tif (!node) { // Clicked on empty space\n\t\t\tif (effectiveMode === 'pan') {\n\t\t\t\t// Pan mode: pan and deselect\n\t\t\t\tisPanning = true;\n\t\t\t\telastic = null;\n\t\t\t\tpanStartX = e.clientX;\n\t\t\t\tpanStartY = e.clientY;\n\t\t\t\tinitialTransform = getCurrentTransformLocal();\n\t\t\t\tini = [];\n\t\t\t\t// Deselect all elements when clicking empty space in pan mode\n\t\t\t\tconn.setSelection([]);\n\t\t\t} else {\n\t\t\t\t// Select mode: ONLY select, no panning\n\t\t\t\tisPanning = false;\n\t\t\t\telastic = createElastic();\n\t\t\t\tif (elastic) elastic.ini(e);\n\t\t\t\tini = [];\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Clicked on a node/vertex - behavior depends on effective mode\n\t\tif (effectiveMode === 'pan') {\n\t\t\t// Pan mode: select the element, don't pan\n\t\t\tisPanning = false;\n\t\t\telastic = null;\n\t\t\t\n\t\t\tconst nodes = conn.getSelection()\n\t\t\tif (conn.isSelected(node)) {\n\t\t\t\t// Clicking on a selected node - prepare to drag all selected elements\n\t\t\t\tini = nodes.map(n => ({ x: n.x, y: n.y, n }))\n\t\t\t\t// No selection change needed since we're clicking on already selected element\n\t\t\t} else {\n\t\t\t\t// Clicking on an unselected node - select only this element\n\t\t\t\tconn.setSelection([node]);\n\t\t\t\tini = [{ x: node.x, y: node.y, n: node }];\n\t\t\t}\n\t\t} else {\n\t\t\t// Select mode: selection/drag logic\n\t\t\tisPanning = false; // Ensure no panning if a node is clicked\n\t\t\telastic = null; // Ensure no selection box if a node is clicked\n\t\t\tconst nodes = conn.getSelection()\n\t\t\t\n\t\t\tif (e.shiftKey && dragMode === 'select') {\n\t\t\t\t// Shift+click in select mode: immediately change selection (no dragging expected)\n\t\t\t\tif (conn.isSelected(node)) {\n\t\t\t\t\tconst index = nodes.findIndex(n => n.id === node.id)\n\t\t\t\t\tif (index >= 0) nodes.splice(index, 1)\n\t\t\t\t} else {\n\t\t\t\t\tnodes.push(node)\n\t\t\t\t}\n\t\t\t\tconn.setSelection(nodes)\n\t\t\t\tini = nodes.map(n => ({ x: n.x, y: n.y, n }))\n\t\t\t} else {\n\t\t\t\t// Regular click: defer selection change until we know if it's a drag or click\n\t\t\t\tif (conn.isSelected(node)) {\n\t\t\t\t\t// Clicking on a selected node - prepare to drag all selected elements\n\t\t\t\t\tini = nodes.map(n => ({ x: n.x, y: n.y, n }))\n\t\t\t\t\t// No pending selection change needed since we're clicking on already selected element\n\t\t\t\t\tpendingSelectionChange = null\n\t\t\t\t} else {\n\t\t\t\t\t// Clicking on an unselected node - defer selection change until we determine if it's a click or drag\n\t\t\t\t\tpendingSelectionChange = { node, shiftKey: e.shiftKey }\n\t\t\t\t\t// For now, prepare to drag just the clicked node (we'll update selection when drag starts)\n\t\t\t\t\tini = [{ x: node.x, y: node.y, n: node }]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onMouseMove(e: MouseEvent, dx: number, dy: number) {\n\t\t// Check if we've moved enough to consider this a drag\n\t\tconst dragThreshold = 3 // pixels\n\t\tif (!hasDragged && (Math.abs(dx) > dragThreshold || Math.abs(dy) > dragThreshold)) {\n\t\t\thasDragged = true\n\t\t\tpendingNavigation = null\n\t\t\t\n\t\t\t// If we have a pending selection change and we're now dragging, apply it\n\t\t\tif (pendingSelectionChange) {\n\t\t\t\tconst nodes = conn.getSelection()\n\t\t\t\tnodes.length = 0\n\t\t\t\tnodes.push(pendingSelectionChange.node)\n\t\t\t\tconn.setSelection(nodes)\n\t\t\t\t// Update ini to drag only the newly selected node\n\t\t\t\tini = [{ x: pendingSelectionChange.node.x, y: pendingSelectionChange.node.y, n: pendingSelectionChange.node }]\n\t\t\t\tpendingSelectionChange = null\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (isPanning) {\n\t\t\t// Pan the view - apply mouse delta directly (no zoom division needed)\n\t\t\t// setTransform expects screen coordinates, dx/dy are already screen pixel deltas\n\t\t\tconst newX = initialTransform.x + dx\n\t\t\tconst newY = initialTransform.y + dy\n\t\t\tsetTransform(newX, newY)\n\t\t} else if (ini.length > 0 && hasDragged) {\n\t\t\t// Move selected nodes/vertices (only if we've actually started dragging)\n\t\t\t// dx, dy are screen pixel deltas, convert to drawing coordinate deltas\n\t\t\tconst zoom = conn.getZoom()\n\t\t\tconst drawingDx = dx / zoom\n\t\t\tconst drawingDy = dy / zoom\n\t\t\tini.forEach(item => {\n\t\t\t\t// item.x, item.y are initial drawing coordinates\n\t\t\t\t// Add the drawing coordinate delta to get new position\n\t\t\t\tconn.moveNode(item.n, item.x + drawingDx, item.y + drawingDy)\n\t\t\t})\n\t\t\tconn.setDragging(true)\n\t\t} else if (elastic) {\n\t\t\t// Update selection box\n\t\t\telastic.update(e)\n\t\t\tconn.setDragging(true)\n\t\t}\n\t}\n\n\tfunction onMouseUp(e: MouseEvent) {\n\t\tconn.setDragging(false)\n\t\tconst navigation = hasDragged ? null : pendingNavigation\n\t\tif (hasDragged) {\n\t\t\tsuppressLinkClick = true\n\t\t\twindow.setTimeout(() => {\n\t\t\t\tsuppressLinkClick = false\n\t\t\t}, 0)\n\t\t}\n\t\t\n\t\t// If we have a pending selection change and didn't drag, apply it now (it was just a click)\n\t\tif (pendingSelectionChange && !hasDragged) {\n\t\t\tconst nodes = conn.getSelection()\n\t\t\tnodes.length = 0\n\t\t\tnodes.push(pendingSelectionChange.node)\n\t\t\tconn.setSelection(nodes)\n\t\t}\n\t\t\n\t\tif (elastic) {\n\t\t\tconst box = elastic.end()\n\t\t\tif (box) {\n\t\t\t\tconn.boxSelection(box, e.shiftKey)\n\t\t\t} else if (!ini.length) {\n\t\t\t\t// Deselect if no box was drawn\n\t\t\t\tconn.setSelection([])\n\t\t\t}\n\t\t\telastic = null\n\t\t}\n\t\t\n\t\t// Save view state if user was panning (user-initiated view change)\n\t\tif (isPanning && hasDragged) {\n\t\t\tsaveViewState(data)\n\t\t}\n\t\t\n\t\t// Reset state\n\t\tpendingSelectionChange = null\n\t\tpendingNavigation = null\n\t\thasDragged = false\n\t\tisPanning = false\n\t\tconn.updatePanning()\n\t\tif (navigation) {\n\t\t\twindow.location.href = navigation\n\t\t}\n\t}\n\n\tfunction onClick(e: MouseEvent) {\n\t\tconst target = e.target\n\t\tif (!(target instanceof Element) || !target.closest('a.nodeLink')) return\n\t\te.preventDefault()\n\t\tif (!suppressLinkClick) return\n\t\te.stopPropagation()\n\t\tsuppressLinkClick = false\n\t}\n\n\t// Add drag and drop functionality\n\tfunction addDnd(element: SVGSVGElement) {\n\t\tlet md: { ex: number; ey: number } | null = null\n\n\t\tfunction convertEvent(e: MouseEvent | TouchEvent): MouseEvent {\n\t\t\tif ('changedTouches' in e && e.changedTouches) {\n\t\t\t\treturn e.changedTouches[0] as any\n\t\t\t}\n\t\t\treturn e as MouseEvent\n\t\t}\n\n\t\tfunction onMouseMoveHandler(e: MouseEvent | TouchEvent) {\n\t\t\tif (!md) return\n\t\t\te = convertEvent(e)\n\t\t\tonMouseMove(e, e.clientX - md.ex, e.clientY - md.ey)\n\t\t}\n\n\t\tfunction removeListeners() {\n\t\t\tdocument.removeEventListener('touchmove', onMouseMoveHandler as any)\n\t\t\tdocument.removeEventListener('mousemove', onMouseMoveHandler as any)\n\t\t\tdocument.removeEventListener('mouseup', onMouseUpHandler)\n\t\t\tdocument.removeEventListener('touchend', onMouseUpHandler)\n\t\t}\n\n\t\tfunction onMouseUpHandler(e: MouseEvent | TouchEvent) {\n\t\t\tremoveListeners()\n\t\t\tonMouseUp(convertEvent(e))\n\t\t\tmd = null\n\t\t}\n\n\t\tfunction onMouseDownHandler(e: MouseEvent | TouchEvent) {\n\t\t\te = convertEvent(e)\n\t\t\tmd = { ex: e.clientX, ey: e.clientY }\n\t\t\tonMouseDown(e)\n\t\t\tdocument.addEventListener('touchmove', onMouseMoveHandler as any)\n\t\t\tdocument.addEventListener('mousemove', onMouseMoveHandler as any)\n\t\t\tdocument.addEventListener('mouseup', onMouseUpHandler)\n\t\t\tdocument.addEventListener('touchend', onMouseUpHandler)\n\t\t}\n\n\t\telement.addEventListener('mousedown', onMouseDownHandler as any)\n\t\telement.addEventListener('touchstart', onMouseDownHandler as any)\n\t\t\n\t\t// Track these listeners for cleanup\n\t\teventListeners.push(\n\t\t\t{ element, event: 'mousedown', handler: onMouseDownHandler as any },\n\t\t\t{ element, event: 'touchstart', handler: onMouseDownHandler as any }\n\t\t)\n\t}\n\n\taddDnd(svg)\n\tsvg.addEventListener('click', onClick)\n\teventListeners.push({ element: svg, event: 'click', handler: onClick })\n\t\n\t// Return cleanup function\n\treturn () => {\n\t\teventListeners.forEach(({ element, event, handler }) => {\n\t\t\telement.removeEventListener(event, handler)\n\t\t})\n\t}\n}\n\n/**\n * addCursorInteraction attaches the editor's mouse, wheel, keyboard, and\n * unsaved-changes handling for data and its svg, replacing handlers attached by\n * an earlier call. The cleanup function is stored as the svg's\n * __cursorInteractionCleanup; the editor calls it when it removes the graph.\n */\nexport function addCursorInteraction(data: GraphData, dragMode: 'pan' | 'select') {\n\tconst svg = data.svg\n\t// Clean up any existing event listeners to prevent conflicts\n\tconst existingCleanup = (svg as any).__cursorInteractionCleanup\n\tif (existingCleanup) {\n\t\texistingCleanup()\n\t}\n\n\tfunction getData(el: SVGElement) {\n\t\t// @ts-ignore\n\t\treturn el.__data\n\t}\n\n\t// Store event listeners for cleanup\n\tconst eventListeners: Array<{ element: Element | Window, event: string, handler: EventListener }> = []\n\n\tconst beforeUnloadHandler = (e: BeforeUnloadEvent) => {\n\t\tif (!data.changed()) return\n\t\te.preventDefault()\n\t\te.returnValue = ''\n\t}\n\twindow.addEventListener(\"beforeunload\", beforeUnloadHandler)\n\teventListeners.push({ element: window, event: 'beforeunload', handler: beforeUnloadHandler })\n\n\tfunction setDotSelected(d: Handle, selected: boolean) {\n\t\td.selected = selected\n\t\tconst dotEl = svg.querySelector('#' + data.idPrefix + d.id)\n\t\td.selected ? dotEl.classList.add('selected') : dotEl.classList.remove('selected')\n\t}\n\n\t// show moving dot along edge when ALT is pressed\n\tconst mouseMoveHandler = (e: MouseEvent) => {\n\t\tif (!e.altKey) return\n\t\tconst fnd = findClosestSegment(data, mouseToDrawing(data, e))\n\t\tif (fnd) {\n\t\t\tconst {prj} = fnd\n\t\t\tconst parent = svg.querySelector('g.edges')\n\t\t\tlet dot = parent.querySelector(`#${data.idPrefix}prj`)\n\t\t\tif (!dot) {\n\t\t\t\tdot = create.element('circle', {id: `${data.idPrefix}prj`, cx: prj.x, cy: prj.y, r: 7})\n\t\t\t\tparent.append(dot)\n\t\t\t}\n\t\t\tdot.setAttribute('cx', String(prj.x))\n\t\t\tdot.setAttribute('cy', String(prj.y))\n\t\t} else {\n\t\t\tremovePrjDot()\n\t\t}\n\t}\n\tsvg.addEventListener('mousemove', mouseMoveHandler)\n\teventListeners.push({ element: svg, event: 'mousemove', handler: mouseMoveHandler })\n\n\tconst keyUpHandler = (e: KeyboardEvent) => {\n\t\tconst key = findShortcut(e, true)\n\t\tif (key == ADD_VERTEX || key == ADD_LABEL_VERTEX) return\n\t\tremovePrjDot()\n\t}\n\twindow.addEventListener('keyup', keyUpHandler)\n\teventListeners.push({ element: window, event: 'keyup', handler: keyUpHandler })\n\n\tfunction removePrjDot() {\n\t\tconst el = svg.querySelector(`g.edges #${data.idPrefix}prj`)\n\t\tel && el.parentElement.removeChild(el)\n\t}\n\n\tconst clickHandler = (e: MouseEvent) => {\n\t\tconst key = findShortcut(e, true)\n\t\tif (key != ADD_LABEL_VERTEX && key != ADD_VERTEX) return\n\t\tconst fnd = findClosestSegment(data, mouseToDrawing(data, e))\n\t\tif (fnd) {\n\t\t\tconst {edge, pos, prj} = fnd\n\t\t\t// depending on keyboard modifier, make it label position\n\t\t\tdata.insertEdgeVertex(edge, prj, pos, key == ADD_LABEL_VERTEX)\n\t\t\tremovePrjDot()\n\t\t}\n\t}\n\tsvg.addEventListener('click', clickHandler)\n\teventListeners.push({ element: svg, event: 'click', handler: clickHandler })\n\n\tconst wheelHandler = (e: WheelEvent) => {\n\t\t// Handle wheel zoom directly without relying on shortcuts\n\t\t// deltaY > 0 means scrolling down (zoom out), deltaY < 0 means scrolling up (zoom in)\n\t\tconst delta = Math.sign(e.deltaY) * 0.1 // Normalize to 0.1 zoom steps\n\t\tconst currentZoom = getZoom(data)\n\t\tconst newZoom = Math.max(0.1, Math.min(5, currentZoom - delta)) // Clamp zoom between 0.1 and 5\n\t\t\n\t\tif (newZoom !== currentZoom) {\n\t\t\t// Convert absolute screen coordinates to SVG-relative coordinates\n\t\t\tconst rect = svg.getBoundingClientRect()\n\t\t\tconst svgX = e.clientX - rect.left\n\t\t\tconst svgY = e.clientY - rect.top\n\t\t\tsetZoomCentered(data, newZoom, svgX, svgY)\n\t\t\te.preventDefault()\n\t\t\t\n\t\t\t// Save view state after user wheel zoom\n\t\t\tsaveViewState(data)\n\t\t}\n\t}\n\tsvg.addEventListener('wheel', wheelHandler)\n\teventListeners.push({ element: svg, event: 'wheel', handler: wheelHandler })\n\n\tconst keyDownHandler = (e: KeyboardEvent) => {\n\t\tconst shortcut = findShortcut(e)\n\t\t\n\t\t\n\t\tif (shortcut) {\n\t\t\te.preventDefault() // Prevent browser default for all recognized shortcuts\n\t\t}\n\t\t\n\t\tswitch (shortcut) {\n\t\t\tcase DEL_VERTEX:\n\t\t\t\tconst selectedVertices = Array.from(data.edgeVertices.values()).filter(v => v.selected);\n\t\t\t\tselectedVertices.forEach(v => {\n\t\t\t\t\tdata.deleteEdgeVertex(v)\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\tcase UNDO:\n\t\t\t\tdata.undo()\n\t\t\t\tbreak\n\t\t\tcase REDO:\n\t\t\t\tdata.redo()\n\t\t\t\tbreak\n\t\t\tcase ZOOM_IN:\n\t\t\t\tconst newZoomIn = Math.min(5, getZoom(data) * 1.2)\n\t\t\t\t// Center zoom on viewport center like mouse wheel\n\t\t\t\tsetZoomCentered(data, newZoomIn)\n\t\t\t\tsaveViewState(data) // Save after user keyboard zoom\n\t\t\t\tbreak\n\t\t\tcase ZOOM_OUT:\n\t\t\t\tconst newZoomOut = Math.max(0.1, getZoom(data) / 1.2)\n\t\t\t\t// Center zoom on viewport center like mouse wheel\n\t\t\t\tsetZoomCentered(data, newZoomOut)\n\t\t\t\tsaveViewState(data) // Save after user keyboard zoom\n\t\t\t\tbreak\n\t\t\tcase ZOOM_100:\n\t\t\t\t// Center zoom on viewport center like mouse wheel\n\t\t\t\tsetZoomCentered(data, 1)\n\t\t\t\tsaveViewState(data) // Save after user keyboard zoom\n\t\t\t\tbreak\n\t\t\tcase ZOOM_FIT:\n\t\t\t\tdata.fitToView()\n\t\t\t\t// Don't save view state here - fitToView should not be persisted\n\t\t\t\tbreak\n\t\t\tcase SELECT_ALL:\n\t\t\t\tdata.nodes().forEach(n => data.setNodeSelected(n, true))\n\t\t\t\tdata.edgeVertices.forEach(v => setDotSelected(v, true))\n\t\t\t\tbreak\n\t\t\tcase DESELECT:\n\t\t\t\tdata.nodes().forEach(n => data.setNodeSelected(n, false))\n\t\t\t\tdata.edgeVertices.forEach(v => setDotSelected(v, false))\n\t\t\t\tbreak\n\t\t}\n\t}\n\twindow.addEventListener('keydown', keyDownHandler)\n\teventListeners.push({ element: window, event: 'keydown', handler: keyDownHandler })\n\n\t// Custom cursor interaction with pan-first behavior\n\tconst customInteractionCleanup = addCustomCursorInteraction(data, {\n\t\tnodeFromEvent(e: MouseEvent): Handle {\n\t\t\te.preventDefault()\n\t\t\t// node clicked\n\t\t\tlet el = (e.target as SVGElement).closest('g.nodes g.node') as SVGElement\n\t\t\tif (el) return getData(el)\n\t\t\t// vertex dot clicked; its id is the vertex id after this graph's idPrefix\n\t\t\tel = (e.target as SVGElement).closest('g.edges g.edge .v-dot') as SVGElement\n\t\t\tif (el) {\n\t\t\t\treturn data.edgeVertices.get(el.id.slice(data.idPrefix.length))\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\t\tsetSelection(handles: Handle[]) {\n\t\t\t// nodes\n\t\t\tdata.nodes().forEach(n => data.setNodeSelected(n, handles.some(h => h.id == n.id)))\n\t\t\t// dots\n\t\t\tdata.edgeVertices.forEach(d => setDotSelected(d, handles.some(h => h.id == d.id)))\n\t\t\tdata.selectListener(data.nodes().find(n => n.selected))\n\t\t},\n\t\tsetDragging(d: boolean) {\n\t\t\tdata.dragging = d\n\t\t},\n\t\tisSelected(handle: Handle): boolean {\n\t\t\treturn handle.selected\n\t\t},\n\t\tgetSelection(): Handle[] {\n\t\t\tconst ret: Handle[] = data.nodes().filter(n => n.selected)\n\t\t\tdata.edgeVertices.forEach(d => d.selected && ret.push(d))\n\t\t\treturn ret\n\t\t},\n\t\tgetZoom: () => getZoom(data),\n\t\tmoveNode(h: Handle, x: number, y: number) {\n\t\t\tif (data.nodesMap.has(h.id))\n\t\t\t\tdata.moveNode(h as Node, x, y)\n\t\t\telse {\n\t\t\t\t(h as EdgeVertex).auto = false\n\t\t\t\tdata.moveEdgeVertex(h as EdgeVertex, x, y)\n\t\t\t}\n\t\t},\n\t\tboxSelection(box: DOMRect, add) {\n\t\t\t// Box is now already in drawing coordinates, no need to scale\n\t\t\t// nodes\n\t\t\tdata.nodesMap.forEach(n => {\n\t\t\t\tconst inBox = boxesOverlap(uncenterBox(n), box)\n\t\t\t\tif (inBox) {\n\t\t\t\t\t// Toggle selection for elements in the box\n\t\t\t\t\tdata.setNodeSelected(n, !n.selected)\n\t\t\t\t} else if (!add) {\n\t\t\t\t\t// If not holding shift and element is outside box, deselect it\n\t\t\t\t\tdata.setNodeSelected(n, false)\n\t\t\t\t}\n\t\t\t})\n\t\t\t// dots\n\t\t\tdata.edgeVertices.forEach(d => {\n\t\t\t\tconst inBox = insideBox(d, box, false)\n\t\t\t\tif (inBox) {\n\t\t\t\t\t// Toggle selection for elements in the box\n\t\t\t\t\tsetDotSelected(d, !d.selected)\n\t\t\t\t} else if (!add) {\n\t\t\t\t\t// If not holding shift and element is outside box, deselect it\n\t\t\t\t\tsetDotSelected(d, false)\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tdata.selectListener(data.nodes().find(n => n.selected))\n\t\t},\n\t\tupdatePanning: () => updatePanning(data),\n\t}, dragMode)\n\t\n\t// Store cleanup function on the SVG element for later use\n\tconst cleanup = () => {\n\t\teventListeners.forEach(({ element, event, handler }) => {\n\t\t\telement.removeEventListener(event, handler)\n\t\t})\n\t\tif (customInteractionCleanup) {\n\t\t\tcustomInteractionCleanup()\n\t\t}\n\t}\n\t\n\t// Store cleanup function on SVG element\n\t;(svg as any).__cursorInteractionCleanup = cleanup\n}\n\n/** getZoom returns data's current zoom, or 1 before data has been drawn. */\nexport function getZoom(data: GraphData) {\n\tconst el = data.svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return 1\n\t\n\t// Parse zoom from transform attribute to match how we set it\n\tconst transform = el.getAttribute('transform') || ''\n\tconst scaleMatch = transform.match(/scale\\(([^)]+)\\)/)\n\tif (scaleMatch) {\n\t\treturn parseFloat(scaleMatch[1]) || 1\n\t}\n\treturn 1\n}\n\n// svgPadding is now imported as SVG_PADDING from constants.ts\n\n/** setZoom sets data's zoom and keeps its current pan; it does nothing before data is drawn. */\nexport function setZoom(data: GraphData, zoom: number) {\n\tconst el = data.svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return\n\t\n\t// Preserve existing translation when setting zoom\n\tconst currentTransform = getCurrentTransform(data)\n\tel.setAttribute('transform', `translate(${currentTransform.x}, ${currentTransform.y}) scale(${zoom})`)\n\t\n\t// also set panning size\n\tupdatePanning(data)\n}\n\n/**\n * setZoomCentered sets data's zoom while keeping the drawing point under\n * (centerX, centerY) in place, by default the center of the svg's container.\n */\nexport function setZoomCentered(data: GraphData, newZoom: number, centerX?: number, centerY?: number) {\n\tconst svg = data.svg\n\tconst el = svg.querySelector('g.zoom') as SVGGElement\n\tconst oldZoom = getZoom(data)\n\t\n\t// If no center point provided, use viewport center\n\tif (centerX === undefined || centerY === undefined) {\n\t\t// Use the parent container's dimensions for the visible viewport\n\t\t// The SVG might be larger than the visible area due to overflow\n\t\tconst container = svg.parentElement\n\t\tif (container) {\n\t\t\tcenterX = container.clientWidth / 2\n\t\t\tcenterY = container.clientHeight / 2\n\t\t} else {\n\t\t\t// Fallback to SVG dimensions if no parent\n\t\t\tcenterX = svg.clientWidth / 2\n\t\t\tcenterY = svg.clientHeight / 2\n\t\t}\n\t}\n\t\n\t// Get current transform\n\tconst currentTransform = getCurrentTransform(data)\n\t\n\t// Convert screen coordinates to drawing coordinates\n\t// For transform order translate(tx, ty) scale(s):\n\t// screen_point = (drawing_point * scale) + translation\n\t// So: drawing_point = (screen_point - translation) / scale\n\tconst drawingX = (centerX - currentTransform.x) / oldZoom\n\tconst drawingY = (centerY - currentTransform.y) / oldZoom\n\t\n\t// Calculate new translation to keep the same drawing point at the same screen position\n\t// screen_point = (drawing_point * new_scale) + new_translation\n\t// So: new_translation = screen_point - (drawing_point * new_scale)\n\tconst newTranslateX = centerX - (drawingX * newZoom)\n\tconst newTranslateY = centerY - (drawingY * newZoom)\n\t\n\t// Apply the new transform\n\tel.setAttribute('transform', `translate(${newTranslateX}, ${newTranslateY}) scale(${newZoom})`)\n\t\n\t// Update panning\n\tupdatePanning(data)\n}\n\n/** getCurrentTransform returns data's current pan, or (0, 0) before data is drawn. */\nfunction getCurrentTransform(data: GraphData) {\n\tconst el = data.svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return { x: 0, y: 0 }\n\t\n\tconst transform = el.getAttribute('transform') || ''\n\tconst translateMatch = transform.match(/translate\\(([^,]+),([^)]+)\\)/)\n\tif (translateMatch) {\n\t\treturn {\n\t\t\tx: parseFloat(translateMatch[1]) || 0,\n\t\t\ty: parseFloat(translateMatch[2]) || 0\n\t\t}\n\t}\n\treturn { x: 0, y: 0 }\n}\n\n/** updatePanning resizes data's svg to fit its zoomed drawing; it does nothing until the svg is placed. */\nfunction updatePanning(data: GraphData) {\n\tconst svg = data.svg\n\tconst el = svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return\n\tconst bb = el.getBBox()\n\tconst zoom = getZoom(data)\n\tif (!svg.parentElement) return\n\tconst w = Math.max(svg.parentElement.clientWidth / zoom, bb.x + bb.width + SVG_PADDING)\n\tconst h = Math.max(svg.parentElement.clientHeight / zoom, bb.y + bb.height + SVG_PADDING)\n\tsvg.setAttribute('width', String(w * zoom))\n\tsvg.setAttribute('height', String(h * zoom))\n\t\n\t// Note: View state saving removed from here to prevent interference with reset/fit functions\n\t// View state is now only saved on user interactions and page unload\n}\n\n// Optimized version that uses pre-calculated content bounds instead of expensive getBBox()\nfunction updatePanningOptimized(graphData: GraphData) {\n\tconst svg = graphData.svg\n\tconst bb = graphData.calculateContentBounds() // Use already calculated bounds\n\tconst zoom = getZoom(graphData)\n\tconst w = Math.max(svg.parentElement.clientWidth / zoom, bb.x + bb.width + SVG_PADDING)\n\tconst h = Math.max(svg.parentElement.clientHeight / zoom, bb.y + bb.height + SVG_PADDING)\n\tsvg.setAttribute('width', String(w * zoom))\n\tsvg.setAttribute('height', String(h * zoom))\n}\n\n/** getZoomAuto returns the zoom that fits graphData's content in its svg's container. */\nexport const getZoomAuto = (graphData: GraphData) => {\n\t// Use proper content bounds calculation\n\tconst contentBounds = graphData.calculateContentBounds()\n\tconst viewportWidth = graphData.svg.parentElement?.clientWidth || 800\n\tconst viewportHeight = graphData.svg.parentElement?.clientHeight || 600\n\t\n\t// Add padding around content\n\tconst padding = 40\n\t\n\t// Calculate zoom to fit content with padding\n\tconst zoomX = (viewportWidth - padding * 2) / contentBounds.width\n\tconst zoomY = (viewportHeight - padding * 2) / contentBounds.height\n\tconst zoom = Math.min(zoomX, zoomY)\n\t\n\t// Clamp zoom between reasonable bounds\n\treturn Math.max(Math.min(zoom, 2), 0.1)\n}\n\nconst setBorderStyle = (el: SVGElement, style: string) => {\n\tif (style == 'Dashed') el.setAttribute('stroke-dasharray', '4')\n\telse if (style == 'Dotted') el.setAttribute('stroke-dasharray', '2')\n}\n\n// View state persistence - similar to undo cache but for zoom/pan\nconst viewStateCache = new Map();\n\n// Save data's current view state (zoom and pan) under its view id\nexport function saveViewState(data: GraphData) {\n\tconst zoom = getZoom(data);\n\tconst transform = getCurrentTransform(data);\n\t\n\tconst state = {\n\t\tzoom,\n\t\ttransform: { x: transform.x, y: transform.y }\n\t};\n\t\n\tviewStateCache.set(data.id, state);\n}\n\n// Restore the view state saved for data's view id, if it exists\nexport function restoreViewState(data: GraphData): boolean {\n\tif (!viewStateCache.has(data.id)) {\n\t\treturn false;\n\t}\n\t\n\tconst state = viewStateCache.get(data.id);\n\tif (!state) {\n\t\treturn false;\n\t}\n\t\n\t// Restore zoom and transform\n\tconst zoomGroup = data.svg.querySelector('g.zoom') as SVGGElement;\n\tif (zoomGroup) {\n\t\tzoomGroup.setAttribute('transform', `scale(${state.zoom}) translate(${state.transform.x}, ${state.transform.y})`);\n\t\tupdatePanning(data);\n\t}\n\t\n\treturn true;\n}\n\n// Clear the view state saved for data's view id\nexport function clearViewState(data: GraphData) {\n\tviewStateCache.delete(data.id);\n}\n","import fontFaces from \"../fonts.css?inline\";\nimport fontLicense from \"@fontsource/inter/LICENSE?raw\";\n\n/**\n * defs returns one graph's shared SVG definitions. Every id starts with prefix,\n * the graph's idPrefix, so definitions of graphs on the same page stay distinct.\n */\nexport const defs = (prefix: string) => `\n\n\t\n\t${fontLicense.replace(/&/g, \"&\").replace(/\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n`\n","// This file is the only owner of automatic positions. It gives ELK the exact\n// measured sizes, reads ELK's complete result, and does not repair that result.\n\nimport type {\n\tElkExtendedEdge,\n\tElkLabel,\n\tElkNode,\n\tElkPoint,\n} from \"elkjs/lib/elk-api\";\n\nimport {\n\tMeasuredDiagram,\n\tMeasuredEdge,\n\tMeasuredGroup,\n\tMeasuredNode,\n\tPoint,\n\tResolvedEdge,\n\tResolvedGroup,\n\tResolvedLayout,\n\tResolvedNode,\n} from \"./geometry\";\n\n/** AutomaticLayoutOptions are the choices a caller may make before layout. */\nexport interface AutomaticLayoutOptions {\n\tdirection: \"UP\" | \"DOWN\" | \"LEFT\" | \"RIGHT\";\n\tnodeSpacing: number;\n\tlayerSpacing: number;\n}\n\nconst defaultOptions: AutomaticLayoutOptions = {\n\tdirection: \"DOWN\",\n\tnodeSpacing: 80,\n\tlayerSpacing: 80,\n};\n\n/**\n * resolveAutomatic runs one compound ELK layout with exact measured sizes.\n * ELK errors and incomplete results are returned to the caller unchanged.\n */\nexport async function resolveAutomatic(\n\tdiagram: MeasuredDiagram,\n\toptions: Partial = {},\n): Promise {\n\tconst settings = {...defaultOptions, ...options};\n\tconst graph = buildLayoutTree(diagram, settings);\n\tconst ELK = await import(\"elkjs/lib/elk.bundled.js\").then(module => module.default);\n\tconst elk = new ELK();\n\tconst result = await elk.layout(graph);\n\treturn readResolvedLayout(diagram, result);\n}\n\n/**\n * buildLayoutTree creates one ELK tree. Nodes belong to their declared group,\n * groups belong to their declared parent, and each edge belongs to the nearest\n * group shared by both connected nodes.\n */\nfunction buildLayoutTree(\n\tdiagram: MeasuredDiagram,\n\toptions: AutomaticLayoutOptions,\n): ElkNode {\n\tconst nodes = new Map(diagram.nodes.map(node => [node.id, node]));\n\tconst groups = new Map(diagram.groups.map(group => [group.id, group]));\n\tcheckMeasuredLinks(diagram, nodes, groups);\n\n\tconst childrenByParent = new Map();\n\tfor (const node of diagram.nodes) {\n\t\tappend(childrenByParent, node.parentId, node);\n\t}\n\tconst groupsByParent = new Map();\n\tfor (const group of diagram.groups) {\n\t\tappend(groupsByParent, group.parentId, group);\n\t}\n\n\tconst elkGroups = new Map();\n\tconst buildGroup = (group: MeasuredGroup): ElkNode => {\n\t\tconst child: ElkNode = {\n\t\t\tid: group.id,\n\t\t\tchildren: [\n\t\t\t\t...(groupsByParent.get(group.id) ?? []).map(buildGroup),\n\t\t\t\t...(childrenByParent.get(group.id) ?? []).map(buildNode),\n\t\t\t],\n\t\t\tedges: [],\n\t\t\tlabels: [{\n\t\t\t\ttext: group.id,\n\t\t\t\twidth: group.titleSize.width,\n\t\t\t\theight: group.titleSize.height,\n\t\t\t}],\n\t\t\tlayoutOptions: groupLayoutOptions(options, group.titleSize.height),\n\t\t};\n\t\telkGroups.set(group.id, child);\n\t\treturn child;\n\t};\n\n\tconst root: ElkNode = {\n\t\tid: diagram.id,\n\t\tchildren: [\n\t\t\t...(groupsByParent.get(undefined) ?? []).map(buildGroup),\n\t\t\t...(childrenByParent.get(undefined) ?? []).map(buildNode),\n\t\t],\n\t\tedges: [],\n\t\tlayoutOptions: rootLayoutOptions(options),\n\t};\n\n\tfor (const edge of diagram.edges) {\n\t\tconst owner = lowestCommonGroup(edge, nodes, groups);\n\t\tconst container = owner ? elkGroups.get(owner) : root;\n\t\tif (!container) {\n\t\t\tthrow new Error(`edge ${edge.id} has missing layout group ${owner}`);\n\t\t}\n\t\tcontainer.edges?.push(buildEdge(edge));\n\t}\n\treturn root;\n}\n\n/** buildNode passes the measured node size to ELK without padding or guesses. */\nfunction buildNode(node: MeasuredNode): ElkNode {\n\treturn {\n\t\tid: node.id,\n\t\twidth: node.size.width,\n\t\theight: node.size.height,\n\t\tlayoutOptions: {\n\t\t\t\"elk.nodeSize.constraints\": \"FIXED_SIZE\",\n\t\t\t\"elk.portConstraints\": \"FREE\",\n\t\t},\n\t};\n}\n\n/** buildEdge passes the exact label size and stable endpoint IDs to ELK. */\nfunction buildEdge(edge: MeasuredEdge): ElkExtendedEdge {\n\treturn {\n\t\tid: edge.id,\n\t\tsources: [edge.sourceId],\n\t\ttargets: [edge.targetId],\n\t\tlabels: edge.labelSize ? [{\n\t\t\ttext: edge.id,\n\t\t\twidth: edge.labelSize.width,\n\t\t\theight: edge.labelSize.height,\n\t\t\tlayoutOptions: {\n\t\t\t\t\"elk.edgeLabels.inline\": \"false\",\n\t\t\t\t\"elk.edgeLabels.placement\": \"CENTER\",\n\t\t\t},\n\t\t}] : [],\n\t};\n}\n\n/** rootLayoutOptions set the rules shared by the full compound layout. */\nfunction rootLayoutOptions(options: AutomaticLayoutOptions): Record {\n\treturn {\n\t\t\"elk.algorithm\": \"layered\",\n\t\t\"elk.direction\": options.direction,\n\t\t\"elk.edgeRouting\": \"ORTHOGONAL\",\n\t\t\"elk.hierarchyHandling\": \"INCLUDE_CHILDREN\",\n\t\t\"elk.padding\": \"[top=40,left=40,bottom=40,right=40]\",\n\t\t\"elk.spacing.nodeNode\": String(options.nodeSpacing),\n\t\t\"elk.spacing.componentComponent\": String(options.nodeSpacing),\n\t\t\"elk.layered.spacing.nodeNodeBetweenLayers\": String(options.layerSpacing),\n\t\t\"elk.layered.spacing.edgeNodeBetweenLayers\": \"30\",\n\t\t\"elk.layered.spacing.edgeEdgeBetweenLayers\": \"20\",\n\t\t\"elk.layered.nodePlacement.strategy\": \"NETWORK_SIMPLEX\",\n\t\t\"elk.layered.nodePlacement.favorStraightEdges\": \"true\",\n\t\t\"elk.layered.crossingMinimization.strategy\": \"LAYER_SWEEP\",\n\t\t\"elk.layered.unnecessaryBendpoints\": \"true\",\n\t\t\"elk.edgeLabels.inline\": \"false\",\n\t\t\"elk.edgeLabels.avoidOverlap\": \"true\",\n\t\t\"elk.layered.edgeLabels.sideSelection\": \"SMART_DOWN\",\n\t\t\"elk.spacing.edgeLabel\": \"12\",\n\t};\n}\n\n/** groupLayoutOptions reserve title space and keep each group's children together. */\nfunction groupLayoutOptions(\n\toptions: AutomaticLayoutOptions,\n\ttitleHeight: number,\n): Record {\n\treturn {\n\t\t...rootLayoutOptions(options),\n\t\t\"elk.padding\": `[top=${titleHeight + 30},left=30,bottom=30,right=30]`,\n\t\t\"elk.nodeLabels.placement\": \"[H_LEFT,V_TOP,INSIDE]\",\n\t\t\"elk.spacing.labelNode\": \"10\",\n\t};\n}\n\n/**\n * checkMeasuredLinks rejects broken ownership and endpoints before calling ELK,\n * so ELK never has to guess what the model meant.\n */\nfunction checkMeasuredLinks(\n\tdiagram: MeasuredDiagram,\n\tnodes: Map,\n\tgroups: Map,\n): void {\n\tfor (const node of diagram.nodes) {\n\t\tif (node.parentId && !groups.has(node.parentId)) {\n\t\t\tthrow new Error(`node ${node.id} has missing parent group ${node.parentId}`);\n\t\t}\n\t}\n\tfor (const group of diagram.groups) {\n\t\tif (group.parentId && !groups.has(group.parentId)) {\n\t\t\tthrow new Error(`group ${group.id} has missing parent group ${group.parentId}`);\n\t\t}\n\t}\n\tfor (const edge of diagram.edges) {\n\t\tif (!nodes.has(edge.sourceId) || !nodes.has(edge.targetId)) {\n\t\t\tthrow new Error(\n\t\t\t\t`edge ${edge.id} connects missing node ${edge.sourceId} or ${edge.targetId}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** lowestCommonGroup finds the nearest boundary that contains both endpoints. */\nfunction lowestCommonGroup(\n\tedge: MeasuredEdge,\n\tnodes: Map,\n\tgroups: Map,\n): string | undefined {\n\tconst sourceGroups = parentGroups(nodes.get(edge.sourceId)?.parentId, groups);\n\tconst targetGroups = new Set(parentGroups(nodes.get(edge.targetId)?.parentId, groups));\n\treturn sourceGroups.find(group => targetGroups.has(group));\n}\n\n/** parentGroups returns parent IDs from nearest to farthest. */\nfunction parentGroups(\n\tparentId: string | undefined,\n\tgroups: Map,\n): string[] {\n\tconst result: string[] = [];\n\tlet current = parentId;\n\twhile (current) {\n\t\tresult.push(current);\n\t\tcurrent = groups.get(current)?.parentId;\n\t}\n\treturn result;\n}\n\n/** readResolvedLayout changes ELK's parent-relative values into diagram positions. */\nfunction readResolvedLayout(\n\tdiagram: MeasuredDiagram,\n\troot: ElkNode,\n): ResolvedLayout {\n\tif (root.width === undefined || root.height === undefined) {\n\t\tthrow new Error(`ELK did not size diagram ${diagram.id}`);\n\t}\n\tconst nodes: ResolvedNode[] = [];\n\tconst groups: ResolvedGroup[] = [];\n\tconst edges: ResolvedEdge[] = [];\n\tconst measuredNodes = new Map(diagram.nodes.map(node => [node.id, node]));\n\tconst measuredGroups = new Map(diagram.groups.map(group => [group.id, group]));\n\n\treadContainer(\n\t\troot,\n\t\t0,\n\t\t0,\n\t\tmeasuredNodes,\n\t\tmeasuredGroups,\n\t\tnodes,\n\t\tgroups,\n\t\tedges,\n\t);\n\treturn {\n\t\tdiagramId: diagram.id,\n\t\tbounds: {x: 0, y: 0, width: root.width, height: root.height},\n\t\tnodes,\n\t\tgroups,\n\t\tedges,\n\t};\n}\n\n/**\n * readContainer walks one ELK group, adding its parent's position exactly once\n * to each child, edge point, and label box.\n */\nfunction readContainer(\n\tcontainer: ElkNode,\n\tparentX: number,\n\tparentY: number,\n\tmeasuredNodes: Map,\n\tmeasuredGroups: Map,\n\tnodes: ResolvedNode[],\n\tgroups: ResolvedGroup[],\n\tedges: ResolvedEdge[],\n): void {\n\tconst containerX = parentX + (container.x ?? 0);\n\tconst containerY = parentY + (container.y ?? 0);\n\tfor (const child of container.children ?? []) {\n\t\tconst childX = containerX + requiredNumber(child.x, child.id, \"x\");\n\t\tconst childY = containerY + requiredNumber(child.y, child.id, \"y\");\n\t\tconst width = requiredNumber(child.width, child.id, \"width\");\n\t\tconst height = requiredNumber(child.height, child.id, \"height\");\n\t\tconst measuredNode = measuredNodes.get(child.id);\n\t\tif (measuredNode) {\n\t\t\tnodes.push({\n\t\t\t\tid: child.id,\n\t\t\t\tparentId: measuredNode.parentId,\n\t\t\t\tbounds: {x: childX, y: childY, width, height},\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst measuredGroup = measuredGroups.get(child.id);\n\t\tif (!measuredGroup) {\n\t\t\tthrow new Error(`ELK returned unknown node ${child.id}`);\n\t\t}\n\t\tconst label = requiredLabel(child.labels?.[0], child.id);\n\t\tgroups.push({\n\t\t\tid: child.id,\n\t\t\tparentId: measuredGroup.parentId,\n\t\t\tbounds: {x: childX, y: childY, width, height},\n\t\t\ttitleBounds: {\n\t\t\t\tx: childX + requiredNumber(label.x, child.id, \"title x\"),\n\t\t\t\ty: childY + requiredNumber(label.y, child.id, \"title y\"),\n\t\t\t\twidth: requiredNumber(label.width, child.id, \"title width\"),\n\t\t\t\theight: requiredNumber(label.height, child.id, \"title height\"),\n\t\t\t},\n\t\t});\n\t\treadContainer(\n\t\t\tchild,\n\t\t\tcontainerX,\n\t\t\tcontainerY,\n\t\t\tmeasuredNodes,\n\t\t\tmeasuredGroups,\n\t\t\tnodes,\n\t\t\tgroups,\n\t\t\tedges,\n\t\t);\n\t}\n\tfor (const edge of container.edges ?? []) {\n\t\tedges.push(readEdge(edge, containerX, containerY));\n\t}\n}\n\n/** readEdge copies every ELK section and label without choosing new positions. */\nfunction readEdge(edge: ElkExtendedEdge, offsetX: number, offsetY: number): ResolvedEdge {\n\tconst sections = (edge.sections ?? []).map(section => [\n\t\taddOffset(section.startPoint, offsetX, offsetY),\n\t\t...(section.bendPoints ?? []).map(point => addOffset(point, offsetX, offsetY)),\n\t\taddOffset(section.endPoint, offsetX, offsetY),\n\t]);\n\tconst label = edge.labels?.[0];\n\treturn {\n\t\tid: edge.id,\n\t\tsourceId: requiredEndpoint(edge.sources, edge.id, \"source\"),\n\t\ttargetId: requiredEndpoint(edge.targets, edge.id, \"target\"),\n\t\tsections,\n\t\tlabelBounds: label ? {\n\t\t\tx: offsetX + requiredNumber(label.x, edge.id, \"label x\"),\n\t\t\ty: offsetY + requiredNumber(label.y, edge.id, \"label y\"),\n\t\t\twidth: requiredNumber(label.width, edge.id, \"label width\"),\n\t\t\theight: requiredNumber(label.height, edge.id, \"label height\"),\n\t\t} : undefined,\n\t};\n}\n\n/** addOffset changes one parent-relative ELK point into a diagram point. */\nfunction addOffset(point: ElkPoint, offsetX: number, offsetY: number): Point {\n\treturn {x: offsetX + point.x, y: offsetY + point.y};\n}\n\n/** requiredNumber rejects incomplete ELK output instead of filling in zero. */\nfunction requiredNumber(\n\tvalue: number | undefined,\n\telementId: string,\n\tfield: string,\n): number {\n\tif (value === undefined) {\n\t\tthrow new Error(`ELK omitted ${field} for ${elementId}`);\n\t}\n\treturn value;\n}\n\n/** requiredEndpoint requires each MDL relationship to have exactly one endpoint. */\nfunction requiredEndpoint(\n\tendpoints: string[],\n\tedgeId: string,\n\tfield: string,\n): string {\n\tif (endpoints.length !== 1) {\n\t\tthrow new Error(`ELK returned ${endpoints.length} ${field}s for edge ${edgeId}`);\n\t}\n\treturn endpoints[0];\n}\n\n/** requiredLabel rejects a group whose measured title was not placed by ELK. */\nfunction requiredLabel(label: ElkLabel | undefined, groupId: string): ElkLabel {\n\tif (!label) {\n\t\tthrow new Error(`ELK omitted title for group ${groupId}`);\n\t}\n\treturn label;\n}\n\n/** append adds a child to one parent entry while keeping model order. */\nfunction append(\n\titems: Map,\n\tparentId: string | undefined,\n\titem: T,\n): void {\n\tconst siblings = items.get(parentId) ?? [];\n\tsiblings.push(item);\n\titems.set(parentId, siblings);\n}\n","// This file connects the editable graph to the layout pipeline. It measures\n// the current SVG once, asks ELK for one complete answer, validates that answer,\n// and returns positions without changing them.\n\nimport {resolveAutomatic} from \"./automatic-layout\";\nimport {\n\tMeasuredDiagram,\n\tMeasuredEdge,\n\tMeasuredGroup,\n\tMeasuredNode,\n\tRect,\n\tResolvedLayout,\n\tValidatedLayout,\n\tvalidateResolvedLayout,\n} from \"./geometry\";\nimport {Edge, GraphData, Group, LayoutDirection, Node} from \"./graph\";\nimport {calculateEdgeVertices} from \"./edge-utils\";\nimport {resolveManual} from \"./manual-layout\";\n\n/** LayoutOptions are the explicit choices available to editor and CLI callers. */\nexport interface LayoutOptions {\n\tdirection?: LayoutDirection;\n\tnodeSpacing?: number;\n\tlayerSpacing?: number;\n\tcompactLayout?: boolean;\n}\n\n/** GraphLayout carries checked positions back to the editable graph. */\nexport interface GraphLayout {\n\tvalidated: ValidatedLayout;\n\tnodes: Array<{id: string; x: number; y: number}>;\n\tgroups: Array<{id: string; bounds: Rect; titleBounds: Rect}>;\n\tedges: Array<{\n\t\tid: string;\n\t\tsections: Array>;\n\t\tlabelBounds?: Rect;\n\t}>;\n}\n\n/**\n * autoLayout measures, lays out, and validates a graph. It does not catch\n * errors because callers must not save a diagram after any failed step.\n */\nexport async function autoLayout(\n\tgraph: GraphData,\n\toptions: LayoutOptions = {},\n): Promise {\n\tawait document.fonts.ready;\n\tconst measured = measureGraph(graph);\n\tconst spacing = options.compactLayout ? 56 : 80;\n\tconst resolved = await resolveAutomatic(measured, {\n\t\tdirection: options.direction ?? graph.layoutDirection ?? \"DOWN\",\n\t\tnodeSpacing: options.nodeSpacing ?? spacing,\n\t\tlayerSpacing: options.layerSpacing ?? spacing,\n\t});\n\tconst validated = validateResolvedLayout(measured, resolved);\n\tconst measuredNodes = new Map(measured.nodes.map(node => [node.id, node]));\n\treturn {\n\t\tvalidated,\n\t\tnodes: validated.nodes.map(node => {\n\t\t\tconst measuredNode = measuredNodes.get(node.id);\n\t\t\tif (!measuredNode) {\n\t\t\t\tthrow new Error(`validated layout contains unknown node ${node.id}`);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tid: node.id,\n\t\t\t\tx: node.bounds.x + measuredNode.centerOffset.x,\n\t\t\t\ty: node.bounds.y + measuredNode.centerOffset.y,\n\t\t\t};\n\t\t}),\n\t\tgroups: validated.groups.map(group => ({\n\t\t\tid: group.id,\n\t\t\tbounds: group.bounds,\n\t\t\ttitleBounds: group.titleBounds,\n\t\t})),\n\t\tedges: validated.edges.map(edge => ({\n\t\t\tid: edge.id,\n\t\t\tsections: edge.sections,\n\t\t\tlabelBounds: edge.labelBounds,\n\t\t})),\n\t};\n}\n\n/**\n * validateCurrentLayout adapts the fully drawn editor state into the manual\n * layout contract. It never reads automatic positions to fill missing data.\n */\nexport function validateCurrentLayout(graph: GraphData): ValidatedLayout {\n\tconst measured = measureGraph(graph);\n\tconst measuredNodes = new Map(measured.nodes.map(node => [node.id, node]));\n\tconst nodes = graph.nodes().map(node => {\n\t\tconst measuredNode = measuredNodes.get(node.id);\n\t\tif (!measuredNode) {\n\t\t\tthrow new Error(`measured diagram omitted node ${node.id}`);\n\t\t}\n\t\treturn {\n\t\t\tid: node.id,\n\t\t\tparentId: measuredNode.parentId,\n\t\t\tbounds: {\n\t\t\t\tx: node.x - measuredNode.centerOffset.x,\n\t\t\t\ty: node.y - measuredNode.centerOffset.y,\n\t\t\t\t...measuredNode.size,\n\t\t\t},\n\t\t};\n\t});\n\tconst groups = Array.from(graph.groupsMap.values()).map(group => {\n\t\tif (!group.ref?.isConnected) {\n\t\t\tthrow new Error(`group ${group.id} must be drawn before saving`);\n\t\t}\n\t\tconst boundary = group.ref.querySelector(\"rect\");\n\t\tconst title = group.ref.querySelector(\"text\");\n\t\tif (!(boundary instanceof SVGGraphicsElement) || !(title instanceof SVGGraphicsElement)) {\n\t\t\tthrow new Error(`group ${group.id} is missing its boundary or title`);\n\t\t}\n\t\treturn {\n\t\t\tid: group.id,\n\t\t\tparentId: measured.groups.find(candidate => candidate.id === group.id)?.parentId,\n\t\t\tbounds: copyBox(boundary.getBBox()),\n\t\t\ttitleBounds: copyBox(title.getBBox()),\n\t\t};\n\t});\n\tconst edges = graph.edges.map(edge => {\n\t\tconst sections = edge.layoutSections ?? [calculateEdgeVertices(edge)];\n\t\tconst labelBounds = edge.layoutLabelBounds ?? edge.labelBounds;\n\t\tif (edge.label.trim().length > 0 && !labelBounds) {\n\t\t\tthrow new Error(`edge ${edge.id} is missing its label position`);\n\t\t}\n\t\treturn {\n\t\t\tid: edge.id,\n\t\t\tsourceId: edge.from.id,\n\t\t\ttargetId: edge.to.id,\n\t\t\tsections,\n\t\t\tlabelBounds: labelBounds ? {...labelBounds} : undefined,\n\t\t};\n\t});\n\tconst snapshot: ResolvedLayout = {\n\t\tdiagramId: graph.id,\n\t\tbounds: contentBounds(nodes.map(node => node.bounds), groups, edges),\n\t\tnodes,\n\t\tgroups,\n\t\tedges,\n\t};\n\treturn resolveManual(measured, snapshot);\n}\n\n/**\n * measureGraph reads the exact node and label boxes already drawn by the\n * browser. Parent IDs come only from the model's declared groups.\n */\nfunction measureGraph(graph: GraphData): MeasuredDiagram {\n\tconst {nodeParents, groupParents} = declaredParents(graph);\n\treturn {\n\t\tid: graph.id,\n\t\tnodes: graph.nodes().map(node => measureNode(node, nodeParents.get(node.id))),\n\t\tgroups: Array.from(graph.groupsMap.values()).map(group =>\n\t\t\tmeasureGroup(group, groupParents.get(group.id)),\n\t\t),\n\t\tedges: graph.edges.map(measureEdge),\n\t};\n}\n\n/** measureNode returns the complete box drawn for one node and its center. */\nfunction measureNode(node: Node, parentId: string | undefined): MeasuredNode {\n\tif (!node.ref?.isConnected) {\n\t\tthrow new Error(`node ${node.id} must be drawn before layout`);\n\t}\n\tconst bounds = node.ref.getBBox();\n\tcheckMeasuredBox(node.id, bounds);\n\treturn {\n\t\tid: node.id,\n\t\tparentId,\n\t\tsize: {width: bounds.width, height: bounds.height},\n\t\tcontentSize: {width: bounds.width, height: bounds.height},\n\t\tcenterOffset: {x: -bounds.x, y: -bounds.y},\n\t\tshape: node.style.shape ?? \"Box\",\n\t};\n}\n\n/** measureGroup reads the title box already drawn by the browser. */\nfunction measureGroup(group: Group, parentId: string | undefined): MeasuredGroup {\n\tif (!group.ref?.isConnected) {\n\t\tthrow new Error(`group ${group.id} must be drawn before layout`);\n\t}\n\tconst title = group.ref.querySelector(\"text\");\n\tif (!(title instanceof SVGGraphicsElement)) {\n\t\tthrow new Error(`group ${group.id} is missing its drawn title`);\n\t}\n\tconst bounds = title.getBBox();\n\tcheckMeasuredBox(group.id, bounds);\n\treturn {\n\t\tid: group.id,\n\t\tparentId,\n\t\ttitleSize: {width: bounds.width, height: bounds.height},\n\t};\n}\n\n/** measureEdge uses the label background that the current SVG already drew. */\nfunction measureEdge(edge: Edge): MeasuredEdge {\n\tconst hasLabel = edge.label.trim().length > 0;\n\tif (hasLabel && !edge.labelBounds) {\n\t\tthrow new Error(`edge ${edge.id} must be drawn before layout`);\n\t}\n\treturn {\n\t\tid: edge.id,\n\t\tsourceId: edge.from.id,\n\t\ttargetId: edge.to.id,\n\t\tlabelSize: hasLabel ? {\n\t\t\twidth: edge.labelBounds?.width ?? 0,\n\t\t\theight: edge.labelBounds?.height ?? 0,\n\t\t} : undefined,\n\t};\n}\n\n/**\n * declaredParents records model ownership and rejects elements that appear in\n * more than one group. Visual position never decides ownership.\n */\nfunction declaredParents(graph: GraphData): {\n\tnodeParents: Map;\n\tgroupParents: Map;\n} {\n\tconst nodeParents = new Map();\n\tconst groupParents = new Map();\n\tfor (const group of graph.groupsMap.values()) {\n\t\tfor (const member of group.nodes) {\n\t\t\tconst parents = isGroup(member) ? groupParents : nodeParents;\n\t\t\tconst existing = parents.get(member.id);\n\t\t\tif (existing && existing !== group.id) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${isGroup(member) ? \"group\" : \"node\"} ${member.id} belongs to both ` +\n\t\t\t\t\t`${existing} and ${group.id}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tparents.set(member.id, group.id);\n\t\t}\n\t}\n\treturn {nodeParents, groupParents};\n}\n\n/** checkMeasuredBox rejects missing or invalid browser measurements. */\nfunction checkMeasuredBox(id: string, box: Rect): void {\n\tif (\n\t\t!Number.isFinite(box.x) ||\n\t\t!Number.isFinite(box.y) ||\n\t\t!Number.isFinite(box.width) ||\n\t\t!Number.isFinite(box.height) ||\n\t\tbox.width <= 0 ||\n\t\tbox.height <= 0\n\t) {\n\t\tthrow new Error(`browser returned invalid measured box for ${id}`);\n\t}\n}\n\n/** contentBounds returns the smallest box that contains all drawn geometry. */\nfunction contentBounds(\n\tnodes: Rect[],\n\tgroups: Array<{bounds: Rect; titleBounds: Rect}>,\n\tedges: Array<{sections: Array>; labelBounds?: Rect}>,\n): Rect {\n\tconst boxes = [\n\t\t...nodes,\n\t\t...groups.flatMap(group => [group.bounds, group.titleBounds]),\n\t\t...edges.flatMap(edge => edge.labelBounds ? [edge.labelBounds] : []),\n\t];\n\tconst points = edges.flatMap(edge => edge.sections.flat());\n\tif (boxes.length === 0 && points.length === 0) {\n\t\treturn {x: 0, y: 0, width: 0, height: 0};\n\t}\n\tconst left = Math.min(\n\t\t...boxes.map(box => box.x),\n\t\t...points.map(point => point.x),\n\t);\n\tconst top = Math.min(\n\t\t...boxes.map(box => box.y),\n\t\t...points.map(point => point.y),\n\t);\n\tconst right = Math.max(\n\t\t...boxes.map(box => box.x + box.width),\n\t\t...points.map(point => point.x),\n\t);\n\tconst bottom = Math.max(\n\t\t...boxes.map(box => box.y + box.height),\n\t\t...points.map(point => point.y),\n\t);\n\treturn {x: left, y: top, width: right - left, height: bottom - top};\n}\n\n/** copyBox copies the browser's read-only SVG box into the layout contract. */\nfunction copyBox(box: DOMRect): Rect {\n\treturn {x: box.x, y: box.y, width: box.width, height: box.height};\n}\n\n/** isGroup tells group boundaries from nodes without using display names. */\nfunction isGroup(member: Node | Group): member is Group {\n\treturn \"nodes\" in member;\n}\n","// Manual layout has its own entry point. It never fills missing positions from\n// automatic layout and never changes the positions a user authored.\n\nimport {\n\tMeasuredDiagram,\n\tResolvedLayout,\n\tValidatedLayout,\n\tvalidateResolvedLayout,\n} from \"./geometry\";\n\n/**\n * resolveManual checks one complete saved layout against the current measured\n * diagram. Missing or old IDs, incomplete routes, and collisions are errors.\n */\nexport function resolveManual(\n\tmeasured: MeasuredDiagram,\n\tcompleteSnapshot: ResolvedLayout,\n): ValidatedLayout {\n\treturn validateResolvedLayout(measured, completeSnapshot);\n}\n","type TextAttributes = Record;\n\ninterface TextSize {\n\twidth: number;\n\theight: number;\n}\n\n/** WrappedText contains the exact lines and widest rendered line. */\nexport interface WrappedText {\n\tlines: string[];\n\tmaxW: number;\n}\n\nconst measuredText = new Map();\nlet measurementSVG: SVGSVGElement | undefined;\n\n/** loadDiagramFonts completes local font loading before text is wrapped or measured. */\nexport async function loadDiagramFonts(): Promise {\n\tawait Promise.all([400, 600, 700].map(weight => document.fonts.load(`${weight} 22px Inter`)));\n\tawait document.fonts.ready;\n}\n\n/**\n * measureSVGText returns the browser's rendered text size. Results are cached\n * because node and edge layout often measures the same words many times.\n */\nexport function measureSVGText(text: string, attrs: TextAttributes): TextSize {\n\tconst key = measurementKey(text, attrs);\n\tconst cached = measuredText.get(key);\n\tif (cached) {\n\t\treturn cached;\n\t}\n\n\tconst node = document.createElementNS(\"http://www.w3.org/2000/svg\", \"text\");\n\tnode.setAttribute(\"x\", \"0\");\n\tnode.setAttribute(\"y\", \"0\");\n\tfor (const [name, value] of Object.entries(attrs)) {\n\t\tnode.setAttribute(name, value);\n\t}\n\tnode.textContent = text;\n\n\tconst svg = getMeasurementSVG();\n\tsvg.appendChild(node);\n\tconst bounds = node.getBBox();\n\tnode.remove();\n\tconst size = {width: bounds.width, height: bounds.height};\n\tmeasuredText.set(key, size);\n\treturn size;\n}\n\n/**\n * svgTextWrap splits text into lines that fit the given width. It uses the\n * same browser text sizes that SVG drawing uses.\n */\nexport function svgTextWrap(\n\ttext: string,\n\twidth: number,\n\tattrs: TextAttributes,\n): WrappedText {\n\tlet maxW = 0;\n\tconst lines = text.trim().split(\"\\n\").flatMap(paragraph => {\n\t\tconst paragraphLines: string[] = [];\n\t\tlet currentLine: string[] = [];\n\t\tfor (const word of paragraph.trim().split(/\\s+/)) {\n\t\t\tif (measureSVGText(word, attrs).width > width) {\n\t\t\t\tif (currentLine.length > 0) {\n\t\t\t\t\tparagraphLines.push(currentLine.join(\" \"));\n\t\t\t\t\tcurrentLine = [];\n\t\t\t\t}\n\t\t\t\tconst parts = breakLongWord(word, width, attrs);\n\t\t\t\tfor (const part of parts.slice(0, -1)) {\n\t\t\t\t\tparagraphLines.push(part);\n\t\t\t\t\tmaxW = Math.max(maxW, measureSVGText(part, attrs).width);\n\t\t\t\t}\n\t\t\t\tcurrentLine = parts.slice(-1);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst nextLine = [...currentLine, word];\n\t\t\tconst size = measureSVGText(nextLine.join(\" \"), attrs);\n\t\t\tif (size.width > width && currentLine.length > 0) {\n\t\t\t\tparagraphLines.push(currentLine.join(\" \"));\n\t\t\t\tcurrentLine = [word];\n\t\t\t} else {\n\t\t\t\tmaxW = Math.max(maxW, size.width);\n\t\t\t\tcurrentLine = nextLine;\n\t\t\t}\n\t\t}\n\t\tif (currentLine.length > 0) {\n\t\t\tconst line = currentLine.join(\" \");\n\t\t\tparagraphLines.push(line);\n\t\t\tmaxW = Math.max(maxW, measureSVGText(line, attrs).width);\n\t\t}\n\t\treturn paragraphLines;\n\t});\n\treturn {lines, maxW};\n}\n\n/** getMeasurementSVG creates the single hidden SVG used for text measurement. */\nfunction getMeasurementSVG(): SVGSVGElement {\n\tif (measurementSVG?.isConnected) {\n\t\treturn measurementSVG;\n\t}\n\tmeasurementSVG = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n\tmeasurementSVG.setAttribute(\"aria-hidden\", \"true\");\n\tmeasurementSVG.style.position = \"absolute\";\n\tmeasurementSVG.style.visibility = \"hidden\";\n\tmeasurementSVG.style.pointerEvents = \"none\";\n\tdocument.body.appendChild(measurementSVG);\n\treturn measurementSVG;\n}\n\n/** measurementKey gives equal text and font settings the same cache entry. */\nfunction measurementKey(text: string, attrs: TextAttributes): string {\n\tconst attributes = Object.entries(attrs).sort(([first], [second]) =>\n\t\tfirst.localeCompare(second),\n\t);\n\treturn JSON.stringify([text, attributes]);\n}\n\n/** breakLongWord splits one word only when it cannot fit on an empty line. */\nfunction breakLongWord(\n\tword: string,\n\tmaxWidth: number,\n\tattrs: TextAttributes,\n): string[] {\n\tconst parts: string[] = [];\n\tlet currentPart = \"\";\n\tfor (const character of word) {\n\t\tconst nextPart = currentPart + character;\n\t\tif (measureSVGText(nextPart, attrs).width > maxWidth && currentPart.length > 0) {\n\t\t\tparts.push(currentPart);\n\t\t\tcurrentPart = character;\n\t\t} else {\n\t\t\tcurrentPart = nextPart;\n\t\t}\n\t}\n\tif (currentPart.length > 0) {\n\t\tparts.push(currentPart);\n\t}\n\treturn parts;\n}\n\n\n","import {GraphData, LayoutDirection, NodeLink} from \"./graph-view/graph\";\nimport {EdgeStyle, NodeStyle} from \"./graph-view/constants\";\n\n\ninterface Model {\n\tname: string\n\tdescription: string\n\tversion: string\n\tmodel: {\n\t\tenterprise: {\n\t\t\tname: string\n\t\t}\n\t\tpeople: Element[]\n\t\tsoftwareSystems: Element[]\n\t\tdeploymentNodes: Element[]\n\t}\n\tviews: {\n\t\tsystemLandscapeViews: View[]\n\t\tcontainerViews: View[]\n\t\tcomponentViews: View[]\n\t\tdynamicViews: View[]\n\t\tdeploymentViews: View[]\n\t\tstyles: {\n\t\t\telements: (NodeStyle & {tag: string})[];\n\t\t\trelationships: (EdgeStyle & {tag: string})[];\n\t\t}\n\t}\n}\n\ninterface Layouts {\n\t[key: string]: { // keyed by view key\n\t\t[key: string]: { x: number; y: number } // keyed by element id\n\t}\n}\n\ninterface Element {\n\tid: string;\n\tname: string;\n\ttechnology?: string;\n\tdescription?: string;\n\turl?: string;\n\tparent?: Element;\n\ttags?: string;\n\tlocation?: string;\n\tcontainers?: Element[];\n\tcomponents?: Element[];\n\trelationships?: Relation[];\n\tproperties?: { [key: string]: string }\n\tchildren?: Element[];\n\tinfrastructureNodes?: Element[];\n}\n\ninterface Relation {\n\tid: string;\n\tdescription: string;\n\ttags: string;\n\tsourceId: string;\n\tdestinationId: string;\n\ttechnology: string;\n\tinteractionStyle: string;\n}\n\ntype RankDirection = 'TopBottom' | 'BottomTop' | 'LeftRight' | 'RightLeft';\n\ninterface View {\n\tkey: string;\n\ttitle: string;\n\tdescription: string\n\tautomaticLayout?: {\n\t\trankDirection?: RankDirection;\n\t};\n\telements: {\n\t\tid: string\n\t}[];\n\trelationships: {\n\t\tid: string;\n\t\tvertices: { x: number; y: number }[];\n\t\trouting: string; // takes priority over style\n\t}[];\n\tsoftwareSystemId?: string;\n\tcontainerId?: string;\n\texternalContainersBoundariesVisible?: boolean;\n}\n\nconst layoutDirections: Record = {\n\tTopBottom: 'DOWN',\n\tBottomTop: 'UP',\n\tLeftRight: 'RIGHT',\n\tRightLeft: 'LEFT',\n};\n\ninterface Metadata {\n\tname: string\n\tdescription: string\n\tversion: string\n\telements: {\n\t\tid: string\n\t\ttags?: string;\n\t\tlocation?: string;\n\t\tproperties?: { [key: string]: string };\n\t\telementViewKey?: string;\n\t\ttechnology?: string;\n\t\turl?: string;\n\t}[]\n}\n\nexport type ViewsList = {\n\tkey: string;\n\ttitle: string;\n\tsection: string;\n}[]\n\nexport const parseView = (model: Model, layouts: Layouts, viewKey: string) => {\n\n\tconst elements = new Map();\n\tconst relations = new Map();\n\n\tconst collectRels = (el: Element) => {\n\t\tif (Array.isArray(el.relationships)) {\n\t\t\tel.relationships.forEach(rel => {\n\t\t\t\trelations.set(rel.id, rel)\n\t\t\t})\n\t\t}\n\t}\n\n\t// People\n\tmodel.model.people && model.model.people.forEach((el: Element) => {\n\t\telements.set(el.id, el)\n\t\tif (Array.isArray(el.relationships)) {\n\t\t\tel.relationships.forEach(rel => {\n\t\t\t\trelations.set(rel.id, rel)\n\t\t\t})\n\t\t}\n\t})\n\t// Software Systems\n\tmodel.model.softwareSystems && model.model.softwareSystems.forEach((el: Element) => {\n\t\telements.set(el.id, el)\n\t\tcollectRels(el)\n\n\t\tif (Array.isArray(el.containers)) {\n\t\t\tel.containers.forEach((el1: Element) => {\n\t\t\t\tel1.parent = el;\n\t\t\t\telements.set(el1.id, el1)\n\t\t\t\tcollectRels(el1)\n\t\t\t\tif (Array.isArray(el1.components)) {\n\t\t\t\t\tel1.components.forEach((el2: Element) => {\n\t\t\t\t\t\tel2.parent = el1;\n\t\t\t\t\t\telements.set(el2.id, el2)\n\t\t\t\t\t\tcollectRels(el2)\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t})\n\n\t// Deployment Nodes\n\tif (model.model.deploymentNodes) {\n\t\tconst containerInstances = (el: any) => {\n\t\t\tel.containerInstances && el.containerInstances.forEach((item: any) => {\n\t\t\t\tconst el1 = {...elements.get(item.containerId), id: item.id}\n\t\t\t\telements.set(el1.id, el1)\n\t\t\t\tel1.parent = el\n\t\t\t\tcollectRels(item)\n\t\t\t})\n\t\t}\n\n\t\tconst recAddNodes = (el: Element, parent: Element) => {\n\t\t\tel.parent = parent;\n\t\t\telements.set(el.id, el)\n\t\t\tcollectRels(el)\n\t\t\tcontainerInstances(el)\n\t\t\tel.children && el.children.forEach((el1: Element) => recAddNodes(el1, el))\n\t\t\tel.infrastructureNodes && el.infrastructureNodes.forEach((el1: Element) => recAddNodes(el1, el))\n\t\t}\n\n\t\tmodel.model.deploymentNodes.forEach((el: Element) => recAddNodes(el, null))\n\t}\n\n\t// Create graph from selected view\n\tconst {view, section} = getView(model, viewKey)\n\n\tif (!view) return null\n\n\tconst graph = new GraphData(view.key, view.title || view.key)\n\tconst rankDirection = view.automaticLayout?.rankDirection\n\tgraph.layoutDirection = rankDirection ? layoutDirections[rankDirection] : undefined\n\tconst metadata: Metadata = {name: graph.name, description: view.description, version: model.version, elements: []}\n\tgraph.metadata = metadata\n\n\tif (!view.elements) return graph\n\n\t//grouping rules - elements that are groups will not be nodes\n\tconst groupingIDs: { [key: string]: boolean } = {}\n\tif (section == 'deploymentViews' || section == 'containerViews') {\n\t\tview.elements.forEach(ref => {\n\t\t\tconst el = elements.get(ref.id)\n\t\t\tif (el?.parent) {\n\t\t\t\tgroupingIDs[el.parent.id] = true\n\t\t\t}\n\t\t})\n\t} else if (section === 'componentViews') {\n\t\t// Selected components belong to the view's container. Other containers\n\t\t// receive boundaries only when the view requests them.\n\t\tview.elements.forEach(ref => {\n\t\t\tconst parent = elements.get(ref.id)?.parent;\n\t\t\tif (!parent?.components) return;\n\t\t\tif (parent.id !== view.containerId && !view.externalContainersBoundariesVisible) return;\n\t\t\t// A container listed as a node keeps its own relationships; it cannot\n\t\t\t// also be replaced by a group with the same identifier.\n\t\t\tif (!view.elements.some(candidate => candidate.id === parent.id)) {\n\t\t\t\tgroupingIDs[parent.id] = true;\n\t\t\t}\n\t\t});\n\t} else if (view.softwareSystemId) {\n\t\t//don't show grouping if the element is listed in the view\n\t\tif (!view.elements.find(ref => ref.id == view.softwareSystemId))\n\t\t\tgroupingIDs[view.softwareSystemId] = true\n\t} else if (section == 'systemLandscapeViews') {\n\t\t// create a virtual parent element from enterprise\n\t\tconst p: Element = {id: '__enterprise__', ...model.model.enterprise}\n\t\telements.set(p.id, p)\n\t\tif (model.model.people) model.model.people.filter(el => el.location != 'External').forEach(el => el.parent = p)\n\t\tif (model.model.softwareSystems) model.model.softwareSystems.filter(el => el.location != 'External').forEach(el => el.parent = p)\n\t\tgroupingIDs[p.id] = true\n\t}\n\n\tconst styles = model.views.styles\n\n\t// Build color-to-variable mapping for CSS custom properties theming\n\tconst cssClassName = (tag: string) => tag.toLowerCase().replace(/[^a-z0-9-]/g, '-')\n\t\n\tif (styles?.elements) {\n\t\tstyles.elements.forEach(s => {\n\t\t\tif (s.tag) {\n\t\t\t\tconst varPrefix = `--mdl-${cssClassName(s.tag)}`\n\t\t\t\tif (s.background) graph.colorToVarMap.set(s.background as string, `${varPrefix}-bg`)\n\t\t\t\tif (s.color) graph.colorToVarMap.set(s.color as string, `${varPrefix}-color`)\n\t\t\t\tif (s.stroke) graph.colorToVarMap.set(s.stroke as string, `${varPrefix}-stroke`)\n\t\t\t}\n\t\t})\n\t}\n\n\tif (styles?.relationships) {\n\t\tstyles.relationships.forEach(s => {\n\t\t\tif (s.tag) {\n\t\t\t\tconst varPrefix = `--mdl-rel-${cssClassName(s.tag)}`\n\t\t\t\tif (s.color) graph.colorToVarMap.set(s.color as string, `${varPrefix}-color`)\n\t\t\t}\n\t\t})\n\t}\n\n\t//nodes\n\tview.elements.forEach((ref) => {\n\t\t// except grouping elements\n\t\tif (groupingIDs[ref.id]) return\n\n\t\tconst el = elements.get(ref.id)\n\t\tconst elementViewKey = el ? lookupContainerViewKey(model, el.id) : undefined\n\n\t\tlet sub = ''\n\t\tlet style = {}\n\t\tif (el) {\n\t\t\tconst tags = el.tags.split(',')\n\t\t\tsub = tags[tags.length - 1] // subtitle is []\n\t\t\tif (el.technology)\n\t\t\t\tsub += ': ' + el.technology // or [: ]\n\n\t\t\ttags.forEach(tag => {\n\t\t\t\tconst s = styles && styles.elements && styles.elements.find(s => s.tag == tag)\n\t\t\t\ts && (style = {...style, ...s})\n\t\t\t})\n\t\t}\n\n\t\tgraph.addNode(\n\t\t\tref.id,\n\t\t\tel ? (el.name || ref.id) : ref.id,\n\t\t\tsub,\n\t\t\t(el && el.description) ? el.description : '',\n\t\t\tstyle,\n\t\t\tnodeLink(el, elementViewKey)\n\t\t)\n\t\tel && metadata.elements.push({\n\t\t\tid: el.id,\n\t\t\ttags: el.tags,\n\t\t\tlocation: el.location,\n\t\t\tproperties: el.properties,\n\t\t\telementViewKey,\n\t\t\ttechnology: el.technology,\n\t\t\turl: el.url\n\t\t})\n\t})\n\t//edges\n\tif (Array.isArray(view.relationships)) {\n\t\tview.relationships.forEach(ref => {\n\t\t\tconst rel = relations.get(ref.id)\n\t\t\tif (!rel) return;\n\n\t\t\tif (!graph.nodesMap.has(rel.sourceId)) {\n\t\t\t\tif (elements.has(rel.sourceId)) {\n\t\t\t\t\tconst el = elements.get(rel.sourceId)\n\t\t\t\t\tconsole.warn('Element not found in this view: ', el.id, el.name)\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('Element not found: ', rel.sourceId)\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!graph.nodesMap.has(rel.destinationId)) {\n\t\t\t\tif (elements.has(rel.destinationId)) {\n\t\t\t\t\tconst el = elements.get(rel.destinationId)\n\t\t\t\t\tconsole.warn('Element not found in this view: ', el.id, el.name)\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('Element not found: ', rel.destinationId)\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet style: any = {}\n\t\t\trel.tags.split(',').forEach(tag => {\n\t\t\t\tconst s = styles && styles.relationships && styles.relationships.find(s => s.tag == tag)\n\t\t\t\ts && (style = {...style, ...s})\n\t\t\t})\n\t\t\tif (ref.routing) style.routing = ref.routing\n\n\t\t\tconst label = rel.technology ? `${rel.description}\\n[${rel.technology}]` : rel.description\n\t\t\tgraph.addEdge(rel.id, rel.sourceId, rel.destinationId, label, ref.vertices, style)\n\t\t})\n\t}\n\n\t//groups\n\t//sort by depth to solve dependency\n\tconst level = (el: Element) => {\n\t\tlet i = 0\n\t\tfor (let p = el.parent; p; p = p.parent) i++;\n\t\treturn i\n\t}\n\tconst gElements = Object.keys(groupingIDs)\n\t\t.map(id => elements.get(id))\n\t\t.sort((a, b) => level(a) > level(b) ? -1 : 1)\n\n\tgElements.forEach(parent => {\n\t\tlet style = {}\n\t\tif (section == 'deploymentViews') {\n\t\t\tconst el = elements.get(parent.id)\n\t\t\tconst tags = el.tags.split(',')\n\t\t\ttags.forEach(tag => {\n\t\t\t\tconst s = styles && styles.elements && styles.elements.find(s => s.tag == tag)\n\t\t\t\ts && (style = {...style, ...s})\n\t\t\t})\n\t\t}\n\t\t\n\t\t// Filter group members more carefully to respect boundaries\n\t\tconst groupMembers = view.elements\n\t\t\t.map(ref => elements.get(ref.id))\n\t\t\t.filter(el => {\n\t\t\t\tif (!el || el.parent !== parent) return false;\n\t\t\t\t\n\t\t\t\t// For system landscape views, respect the location-based grouping\n\t\t\t\tif (section === 'systemLandscapeViews' && parent.id === '__enterprise__') {\n\t\t\t\t\t// Only include elements that are explicitly non-external\n\t\t\t\t\treturn el.location !== 'External';\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// For other view types, include if parent matches\n\t\t\t\treturn true;\n\t\t\t})\n\t\t\t.map(el => el.id);\n\t\t\n\t\t// Only create group if it has members\n\t\tif (groupMembers.length > 0) {\n\t\t\tgraph.addGroup(\n\t\t\t\tparent.id,\n\t\t\t\tparent.name,\n\t\t\t\tgroupMembers,\n\t\t\t\tstyle\n\t\t\t)\n\t\t}\n\t})\n\n\t//layout if any and init graph\n\tgraph.init(layouts[graph.id])\n\treturn graph\n}\n\nfunction nodeLink(element: Element | undefined, elementViewKey: string | undefined): NodeLink | undefined {\n\tif (elementViewKey) {\n\t\tconst encodedViewKey = encodeURIComponent(elementViewKey)\n\t\treturn {\n\t\t\thref: `?id=${encodedViewKey}`,\n\t\t\texportHref: `${encodedViewKey}.svg`,\n\t\t}\n\t}\n\tif (element?.url) {\n\t\treturn {\n\t\t\thref: element.url,\n\t\t\texportHref: element.url,\n\t\t}\n\t}\n\treturn undefined\n}\n\n// lookup the view in all Views sections in the model. return the view and the section\nfunction getView(model: Model, viewKey: string) {\n\tlet view: View = null, section: string = ''\n\tObject.keys(model.views).filter(s => s.endsWith('Views')).some((s: string) => {\n\t\treturn ((model.views as any)[s]).some((v: View) => {\n\t\t\tif (v.key == viewKey) {\n\t\t\t\tview = v\n\t\t\t\tsection = s\n\t\t\t\treturn true\n\t\t\t}\n\t\t})\n\t})\n\treturn {view, section}\n}\n\n\nfunction lookupContainerViewKey(model: Model, softwareSystemId: string) {\n\tconst view = model.views.containerViews?.find(candidate => candidate.softwareSystemId == softwareSystemId)\n\treturn view?.key\n}\n\nexport const listViews = (model: any) => {\n\tconst viewsList: ViewsList = []\n\tconst sections = Object.keys(model.views).filter(section => section.endsWith('Views'))\n\tsections.forEach(s => {\n\t\tmodel.views[s].forEach((v: View) => {\n\t\t\tviewsList.push({key: v.key, title: v.title || v.key, section: s})\n\t\t})\n\t})\n\treturn viewsList;\n}\n","import React, {FC} from \"react\";\nimport { isMac, getModifierKeyName, getModifierKeyProperty } from './utils/platform';\n\ninterface Combination {\n\tctrl?: boolean;\n\tshift?: boolean;\n\talt?: boolean;\n\twheel?: boolean\n\tkey?: string;\n\tclick?: boolean;\n}\n\ninterface Shortcut {\n\tid: string,\n\thelp: string,\n\tcombinations: Combination[]\n}\n\nexport const SAVE = 'save'\n\nexport const UNDO = 'undo'\nexport const REDO = 'redo'\nexport const ADD_VERTEX = 'add-vertex'\nexport const ADD_LABEL_VERTEX = 'add-label-vertex'\nexport const DEL_VERTEX = 'del-vertex'\n\nexport const ZOOM_IN = 'zoom-in'\nexport const ZOOM_OUT = 'zoom-out'\nexport const ZOOM_FIT = 'zoom-fit'\nexport const ZOOM_100 = 'zoom-100'\n\nexport const SELECT_ALL = 'select-all'\nexport const DESELECT = 'deselect'\n\nexport const MOVE_LEFT = 'move-left'\nexport const MOVE_RIGHT = 'move-right'\nexport const MOVE_UP = 'move-up'\nexport const MOVE_DOWN = 'move-down'\nexport const MOVE_LEFT_FINE = 'move-left-fine'\nexport const MOVE_RIGHT_FINE = 'move-right-fine'\nexport const MOVE_UP_FINE = 'move-up-fine'\nexport const MOVE_DOWN_FINE = 'move-down-fine'\n\nexport const PAN_VIEW = 'pan-view'\nexport const SELECT_ELEMENT = 'select-element'\nexport const MULTI_SELECT = 'multi-select'\nexport const BOX_SELECT = 'box-select'\nexport const MOVE_ELEMENTS = 'move-elements'\n\nexport const HELP = 'help'\n\n// New shortcuts for toolbar buttons\nexport const TOGGLE_DRAG_MODE = 'toggle_drag_mode'\nexport const ALIGN_HORIZONTAL = 'align_horizontal'\nexport const ALIGN_VERTICAL = 'align_vertical'\nexport const DISTRIBUTE_HORIZONTAL = 'distribute_horizontal'\nexport const DISTRIBUTE_VERTICAL = 'distribute_vertical'\nexport const AUTO_LAYOUT = 'auto_layout'\nexport const RESET_POSITION = 'reset_position'\nexport const TOGGLE_GRID = 'toggle_grid'\nexport const TOGGLE_SNAP_TO_GRID = 'toggle_snap_to_grid'\nexport const SNAP_ALL_TO_GRID = 'snap_all_to_grid'\n\nconst shortcuts: { name: string; list: Shortcut[] }[] = [\n\t{\n\t\tname: 'Help',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: HELP,\n\t\t\t\thelp: 'Show/hide this help',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{key: '?', shift: true},\n\t\t\t\t\t{key: 'F1', shift: true}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'File',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: SAVE,\n\t\t\t\thelp: 'Save',\n\t\t\t\tcombinations: [{key: 's', ctrl: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'History',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: UNDO,\n\t\t\t\thelp: 'Undo',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, key: 'z'},\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: REDO,\n\t\t\t\thelp: 'Redo',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, shift: true, key: 'z'},\n\t\t\t\t\t{ctrl: true, key: 'y'},\n\t\t\t\t]\n\t\t\t}\n\n\t\t],\n\t},\n\t{\n\t\tname: 'Relationship editing',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: ADD_VERTEX,\n\t\t\t\thelp: 'Add relationship vertex',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{alt: true, click: true},\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ADD_LABEL_VERTEX,\n\t\t\t\thelp: 'Add label anchor relationship vertex',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{alt: true, shift: true, click: true},\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DEL_VERTEX,\n\t\t\t\thelp: 'Remove relationship vertex',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{key: 'DELETE'},\n\t\t\t\t\t{key: 'BACKSPACE'}\n\t\t\t\t]\n\t\t\t},\n\t\t]\n\t},\n\t{\n\t\tname: 'Zoom',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: ZOOM_IN,\n\t\t\t\thelp: 'Zoom in',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, key: '='}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ZOOM_OUT,\n\t\t\t\thelp: 'Zoom out',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, key: '-'}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ZOOM_FIT,\n\t\t\t\thelp: 'Zoom - fit',\n\t\t\t\tcombinations: [{ctrl: true, key: '9'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ZOOM_100,\n\t\t\t\thelp: 'Zoom 100%',\n\t\t\t\tcombinations: [{ctrl: true, key: '0'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'wheel_zoom',\n\t\t\t\thelp: 'Zoom in/out with mouse wheel',\n\t\t\t\tcombinations: [{wheel: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Mouse Interactions',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: PAN_VIEW,\n\t\t\t\thelp: 'Pan view (drag empty space)',\n\t\t\t\tcombinations: [{click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: SELECT_ELEMENT,\n\t\t\t\thelp: 'Select element',\n\t\t\t\tcombinations: [{click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MULTI_SELECT,\n\t\t\t\thelp: 'Add/remove from selection',\n\t\t\t\tcombinations: [{shift: true, click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: BOX_SELECT,\n\t\t\t\thelp: 'Box selection (drag empty space)',\n\t\t\t\tcombinations: [{shift: true, click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_ELEMENTS,\n\t\t\t\thelp: 'Move selected elements',\n\t\t\t\tcombinations: [{click: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Select',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: SELECT_ALL,\n\t\t\t\thelp: 'Select All',\n\t\t\t\tcombinations: [{ctrl: true, key: 'a'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DESELECT,\n\t\t\t\thelp: 'Deselect',\n\t\t\t\tcombinations: [{key: 'ESC'}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Move',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: MOVE_UP,\n\t\t\t\thelp: 'Move up (grid increment)',\n\t\t\t\tcombinations: [{key: 'UP'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_UP_FINE,\n\t\t\t\thelp: 'Move up (1 pixel)',\n\t\t\t\tcombinations: [{key: 'UP', shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_RIGHT,\n\t\t\t\thelp: 'Move right (grid increment)',\n\t\t\t\tcombinations: [{key: 'RIGHT'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_RIGHT_FINE,\n\t\t\t\thelp: 'Move right (1 pixel)',\n\t\t\t\tcombinations: [{key: 'RIGHT', shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_DOWN,\n\t\t\t\thelp: 'Move down (grid increment)',\n\t\t\t\tcombinations: [{key: 'DOWN'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_DOWN_FINE,\n\t\t\t\thelp: 'Move down (1 pixel)',\n\t\t\t\tcombinations: [{key: 'DOWN', shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_LEFT,\n\t\t\t\thelp: 'Move left (grid increment)',\n\t\t\t\tcombinations: [{key: 'LEFT'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_LEFT_FINE,\n\t\t\t\thelp: 'Move left (1 pixel)',\n\t\t\t\tcombinations: [{key: 'LEFT', shift: true}]\n\t\t\t},\n\t\t]\n\t},\n\t\t\t{\n\t\t\tname: 'View',\n\t\t\tlist: [\n\t\t\t\t{\n\t\t\t\t\tid: TOGGLE_DRAG_MODE,\n\t\t\t\t\thelp: 'Toggle between pan and select mode',\n\t\t\t\t\tcombinations: [{key: 't'}]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: RESET_POSITION,\n\t\t\t\t\thelp: 'Reset position and view',\n\t\t\t\t\tcombinations: [{key: 'Home', ctrl: true}]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t{\n\t\tname: 'Alignment',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: ALIGN_HORIZONTAL,\n\t\t\t\thelp: 'Align selected elements horizontally',\n\t\t\t\tcombinations: [{key: 'h', ctrl: true, shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ALIGN_VERTICAL,\n\t\t\t\thelp: 'Align selected elements vertically',\n\t\t\t\tcombinations: [{key: 'a', ctrl: true, shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DISTRIBUTE_HORIZONTAL,\n\t\t\t\thelp: 'Distribute selected elements horizontally',\n\t\t\t\tcombinations: [{key: 'h', ctrl: true, alt: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DISTRIBUTE_VERTICAL,\n\t\t\t\thelp: 'Distribute selected elements vertically',\n\t\t\t\tcombinations: [{key: 'v', ctrl: true, alt: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Layout',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: AUTO_LAYOUT,\n\t\t\t\thelp: 'Auto layout all elements',\n\t\t\t\tcombinations: [{key: 'l', ctrl: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Grid',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: TOGGLE_GRID,\n\t\t\t\thelp: 'Toggle grid visibility',\n\t\t\t\tcombinations: [{key: 'g', ctrl: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: TOGGLE_SNAP_TO_GRID,\n\t\t\t\thelp: 'Toggle snap to grid',\n\t\t\t\tcombinations: [{key: 'g', ctrl: true, shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: SNAP_ALL_TO_GRID,\n\t\t\t\thelp: 'Snap all elements to grid',\n\t\t\t\tcombinations: [{key: 'g', ctrl: true, alt: true}]\n\t\t\t}\n\t\t]\n\t}\n]\n\nconst shortcutMap = shortcuts\n\t.reduce((lst, s) => lst.concat(s.list), [] as Shortcut[])\n\t.reduce<{ [k: string]: Shortcut }>((map, s) => {\n\t\tmap[s.id] = s;\n\t\treturn map\n\t}, {})\n\nconst checkKey = (e: KeyboardEvent | MouseEvent, shortcut: Shortcut, click: boolean, wheel: boolean) => {\n\treturn shortcut.combinations.some(c => {\n\t\tif (Boolean(c.shift) != e.shiftKey) return false\n\t\t// Use platform-appropriate modifier key\n\t\tif (c.ctrl) {\n\t\t\tconst modifierKey = getModifierKeyProperty(e as KeyboardEvent);\n\t\t\tif (!modifierKey) return false;\n\t\t}\n\t\tif (Boolean(c.alt) != e.altKey) return false\n\t\tif (click) return c.click\n\t\tif (wheel) return c.wheel\n\t\tif (c.key) {\n\t\t\tconst ke = e as KeyboardEvent\n\t\t\tif (c.key == 'DELETE') return ke.key == 'Delete'\n\t\t\tif (c.key == 'BACKSPACE') return ke.key == 'Backspace'\n\t\t\tif (c.key == 'ESC') return ke.key == 'Escape'\n\t\t\tif (c.key == 'UP') return ke.key == 'ArrowUp'\n\t\t\tif (c.key == 'DOWN') return ke.key == 'ArrowDown'\n\t\t\tif (c.key == 'LEFT') return ke.key == 'ArrowLeft'\n\t\t\tif (c.key == 'RIGHT') return ke.key == 'ArrowRight'\n\t\t\treturn c.key && ke.key && c.key.toLowerCase() == ke.key.toLowerCase()\n\t\t}\n\t\treturn false\n\t})\n}\n\nexport const findShortcut = (e: KeyboardEvent | MouseEvent, click = false, wheel = false) => {\n\t// Find all matching shortcuts\n\tconst matches = Object.keys(shortcutMap).filter(k => checkKey(e, shortcutMap[k], click, wheel))\n\t\n\tif (matches.length === 0) return undefined\n\tif (matches.length === 1) return matches[0]\n\t\n\t// If multiple matches, prefer the one with more specific modifiers\n\t// Sort by number of modifiers (shift, ctrl, alt) in descending order\n\tconst sortedMatches = matches.sort((a, b) => {\n\t\tconst aShortcut = shortcutMap[a]\n\t\tconst bShortcut = shortcutMap[b]\n\t\t\n\t\tconst aModifiers = aShortcut.combinations[0]\n\t\tconst bModifiers = bShortcut.combinations[0]\n\t\t\n\t\tconst aCount = (aModifiers.shift ? 1 : 0) + (aModifiers.ctrl ? 1 : 0) + (aModifiers.alt ? 1 : 0)\n\t\tconst bCount = (bModifiers.shift ? 1 : 0) + (bModifiers.ctrl ? 1 : 0) + (bModifiers.alt ? 1 : 0)\n\t\t\n\t\treturn bCount - aCount // Descending order (more modifiers first)\n\t})\n\t\n\treturn sortedMatches[0]\n}\n\nconst comboText = (c: Combination) => {\n\treturn [\n\t\tc.ctrl && getModifierKeyName().toUpperCase(),\n\t\tc.shift && 'SHIFT',\n\t\tc.alt && 'ALT',\n\t\tc.key && (c.key.length > 1 ? c.key : `\"${c.key.toUpperCase()}\"`),\n\t\tc.click && 'CLICK',\n\t\tc.wheel && 'WHEEL'\n\t].filter(Boolean).join(' + ')\n}\n\nexport const Help: FC = () => {\n\treturn
\n\t\t

Shortcuts

\n\t\t\n\t\t\t\n\t\t\t{\n\t\t\t\tshortcuts.map(section => <>\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t{section.list.map(item => \n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t)\n\t\t\t}\n\t\t\t\n\t\t
{section.name}
{item.combinations.map(comboText).join(', ')}{item.help}
\n\t
\n}\n","/**\n * Robust platform detection utilities\n */\n\n/**\n * Detects if the user is on a Mac platform using multiple detection methods\n * for maximum compatibility across browsers and future-proofing.\n */\nexport const isMac = (): boolean => {\n if (typeof navigator === 'undefined') return false;\n \n // Method 1: Check userAgentData (modern browsers, most reliable)\n if ('userAgentData' in navigator && (navigator as any).userAgentData) {\n const platform = (navigator as any).userAgentData.platform;\n if (platform && platform.toLowerCase().includes('mac')) {\n return true;\n }\n }\n \n // Method 2: Check userAgent string (widely supported)\n const userAgent = navigator.userAgent.toLowerCase();\n if (userAgent.includes('mac os') || userAgent.includes('macintosh')) {\n return true;\n }\n \n // Method 3: Check platform (fallback, deprecated but still widely supported)\n if (navigator.platform) {\n const platform = navigator.platform.toLowerCase();\n if (platform.includes('mac') || platform.includes('darwin')) {\n return true;\n }\n }\n \n // Method 4: Check for Mac-specific features as additional validation\n try {\n const testEvent = new KeyboardEvent('keydown', { metaKey: true });\n if (testEvent.metaKey !== undefined) {\n // Additional heuristic: Mac typically has different key layouts\n return /mac|darwin|os x/i.test(navigator.userAgent);\n }\n } catch (e) {\n // Ignore errors in older browsers\n }\n \n return false;\n};\n\n/**\n * Gets the appropriate modifier key name for the current platform\n */\nexport const getModifierKeyName = (): string => {\n return isMac() ? 'Cmd' : 'Ctrl';\n};\n\n/**\n * Gets the appropriate modifier key property for keyboard events\n */\nexport const getModifierKeyProperty = (event: KeyboardEvent): boolean => {\n return isMac() ? event.metaKey : event.ctrlKey;\n};\n\n/**\n * Gets the appropriate Alt key name for the current platform\n */\nexport const getAltKeyName = (): string => {\n return isMac() ? 'Option' : 'Alt';\n}; ","// Imports\nimport ___CSS_LOADER_API_SOURCEMAP_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/sourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/api.js\";\nimport ___CSS_LOADER_GET_URL_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/getUrl.js\";\nvar ___CSS_LOADER_URL_IMPORT_0___ = new URL(\"@fontsource/inter/files/inter-latin-400-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_1___ = new URL(\"@fontsource/inter/files/inter-latin-500-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_2___ = new URL(\"@fontsource/inter/files/inter-latin-600-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_3___ = new URL(\"@fontsource/inter/files/inter-latin-700-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_SOURCEMAP_IMPORT___);\nvar ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___);\nvar ___CSS_LOADER_URL_REPLACEMENT_1___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_1___);\nvar ___CSS_LOADER_URL_REPLACEMENT_2___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_2___);\nvar ___CSS_LOADER_URL_REPLACEMENT_3___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_3___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_0___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_1___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_2___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_3___}) format(\"woff2\");\n}\n`, \"\",{\"version\":3,\"sources\":[\"webpack://./src/fonts.css\"],\"names\":[],\"mappings\":\"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF\",\"sourcesContent\":[\"/* Local Inter files keep browser text measurement identical without internet access. */\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 400;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-400-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 500;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-500-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 600;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-600-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 700;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-700-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\"],\"sourceRoot\":\"\"}]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___;\n","// Imports\nimport ___CSS_LOADER_API_SOURCEMAP_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/sourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/api.js\";\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_SOURCEMAP_IMPORT___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `html, body, #root {\n height: 100%;\n}\n\nbody {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n color: #666;\n margin: 0;\n}\n\n#root {\n display: flex;\n flex-direction: column;\n}\n#root > div.graph {\n flex: 1;\n overflow: auto;\n position: relative;\n}\n\n.toolbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 10px;\n background-color: #f0f0f0;\n border-bottom: 1px solid #cccccc;\n}\n\n.toolbar > div {\n display: flex;\n align-items: center;\n}\n\n.toolbar button {\n padding: 5px 8px;\n margin: 0 2px;\n cursor: pointer;\n}\n\n.toolbar button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Drag mode toggle button styles */\n.toolbar button.mode-toggle {\n position: relative;\n border: 1px solid #8f9fc9;\n width: 40px;\n min-height: 28px;\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\n border-color: #8f9fc9;\n color: white;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n}\n\n.toolbar button.mode-toggle:hover {\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\n border-color: #abb8db;\n}\n\n.toolbar button.mode-toggle.select-mode:active {\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\n}\n\n/* Pan mode and active toggle - darker blue */\n.toolbar button.mode-toggle.pan-mode,\n.toolbar button.active-toggle {\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n.toolbar button.mode-toggle.pan-mode:hover,\n.toolbar button.active-toggle:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\n.toolbar button.mode-toggle.pan-mode:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n/* Toggle buttons when inactive - gray styling */\n.toolbar button.inactive-toggle {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n.toolbar button.inactive-toggle:hover {\n background: #b1b1b1;\n}\n\n.toolbar button.inactive-toggle:active {\n background: #a1a1a1;\n}\n\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\n.toolbar button .fas {\n font-size: 1em;\n vertical-align: middle;\n}\n\n/* Zoom percentage display */\n.toolbar button.zoom-display {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n font-size: 11px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\n padding: 6px 8px;\n text-align: center;\n}\n\n.toolbar-group {\n display: flex;\n align-items: center;\n margin-right: 25px; /* Large space between groups */\n}\n\n.toolbar-group:last-child {\n margin-right: 0; /* Remove right margin from the last group (help button) */\n}\n\nbutton {\n border: none;\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n border-radius: 3px;\n padding: 6px 10px;\n color: #fff;\n outline: none;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n margin-right: 5px;\n min-width: 32px;\n min-height: 28px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n line-height: 1;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n position: relative;\n}\n\nbutton:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\nbutton:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n}\n\nbutton:last-child {\n margin-right: 0;\n}\n\n/* Save button when no changes - gray */\nbutton.action {\n background: #c1c1c1;\n color: #999;\n}\n\nbutton.action:active {\n background: #b1b1b1;\n}\n\n/* Save button when there are changes - orange */\nbutton.grp {\n background: linear-gradient(to bottom, #ee9564, #de7d48);\n margin-right: 0;\n}\n\nbutton.grp:active {\n background: #d67540;\n}\n\n/* Auto-arrange button with AI purple to blue gradient */\nbutton.auto-arrange {\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\n border-color: #4a4c93;\n}\n\nbutton.auto-arrange:hover {\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\n border-color: #5a5ca3;\n}\n\nbutton.auto-arrange:active {\n background: linear-gradient(135deg, #593B83, #357abd);\n border-color: #3a3c83;\n}\n\nselect {\n border: 1px solid #ccc;\n background: white;\n border-radius: 3px;\n padding: 3px 7px;\n color: #666;\n outline: none;\n margin-right: 5px;\n font-size: 12px;\n}\n\nselect:disabled {\n background: #f5f5f5;\n color: #999;\n}\n\nbutton:disabled {\n background: #c1c1c1;\n color: #999;\n}\n\n#root > div > svg {\n position: absolute;\n user-select: none;\n}\n\n\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\n stroke: #29c229;\n}\n.edge .v-dot {\n fill: transparent;\n stroke: transparent;\n stroke-width: 3px;\n cursor: pointer;\n transition: stroke 0.15s ease;\n}\n.edge .v-dot:hover {\n stroke: #999;\n fill: rgba(153, 153, 153, 0.1);\n}\n.edge .v-dot.selected {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.1);\n}\n.edge .v-dot.selected:hover {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.2);\n}\n.edge .v-dot.auto.selected {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.1);\n}\n.edge .v-dot.auto.selected:hover {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.2);\n}\ncircle#prj {\n fill: none;\n stroke: #777;\n}\n\n.nodeShadow {\n fill: none;\n stroke-width: 4px;\n stroke: rgba(0, 0, 0, 0.13);\n}\n\ng.node {\n user-select: none;\n cursor: default;\n}\n\ng.node.linked {\n cursor: pointer;\n}\n\ng.node text {\n pointer-events: none;\n}\n\n.icon {\n fill: #aaa;\n stroke: #fff;\n}\n#icon-cube {\n fill: #aaa;\n}\n\n/* Ensure all button icons are uncolored */\nbutton .icon,\nbutton svg,\nbutton path {\n fill: currentColor !important;\n stroke: none !important;\n}\n\n/* Font Awesome icon styling in buttons */\nbutton i {\n font-size: 12px;\n color: inherit;\n}\n\nrect.elastic {\n pointer-events: none;\n stroke: none;\n fill: #3bd8281f;\n display: none;\n}\nrect.elastic.on {\n display: block;\n}\n\n.popover {\n position: absolute;\n top: 50px;\n bottom: 10px;\n overflow: auto;\n right: 10px;\n background: ghostwhite;\n padding: 30px;\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\n border: solid 1px #eee;\n}\n\n.popover th {\n text-align: left;\n padding: 20px 0px 10px;\n}\n.popover td {\n padding-right: 20px;\n font-size: 14px;\n}\n\n/* Simple tooltip system with smart positioning */\n[data-tooltip] {\n position: relative;\n}\n\n[data-tooltip]:hover::after {\n content: attr(data-tooltip);\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(0, 0, 0, 0.9);\n color: white;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 12px !important;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n font-weight: normal !important;\n white-space: nowrap;\n z-index: 1000;\n pointer-events: none;\n margin-top: 5px;\n animation: tooltip-appear 0.1s ease-out;\n min-width: 120px;\n max-width: calc(100vw - 20px);\n box-sizing: border-box;\n}\n\n[data-tooltip]:hover::before {\n content: '';\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-bottom-color: rgba(0, 0, 0, 0.9);\n z-index: 1000;\n pointer-events: none;\n margin-top: 1px;\n animation: tooltip-appear 0.1s ease-out;\n}\n\n/* Special handling for rightmost elements that might overflow */\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 0;\n transform: none;\n}\n\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 16px;\n transform: none;\n}\n\n@keyframes tooltip-appear {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(-5px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\nselect {\n position: relative;\n}\n\n/* Robot shape internal elements - inherit stroke from parent node */\n.node .robot-eye-socket {\n fill: none;\n stroke: inherit;\n stroke-width: 2;\n}\n\n.node .robot-eye {\n fill: currentColor;\n stroke: none;\n}\n\n.node .robot-mouth {\n stroke: inherit;\n}\n\n.node .robot-antenna {\n stroke: inherit;\n}\n\n.node .robot-antenna-ball {\n fill: currentColor;\n stroke: inherit;\n stroke-width: 1.5;\n}\n\n.node .robot-panel {\n stroke: inherit;\n}\n\n.node .robot-indicator {\n fill: currentColor;\n stroke: none;\n}`, \"\",{\"version\":3,\"sources\":[\"webpack://./src/style.css\"],\"names\":[],\"mappings\":\"AAAA;IACI,YAAY;AAChB;;AAEA;IACI,uFAAuF;IACvF,WAAW;IACX,SAAS;AACb;;AAEA;IACI,aAAa;IACb,sBAAsB;AAC1B;AACA;IACI,OAAO;IACP,cAAc;IACd,kBAAkB;AACtB;;AAEA;IACI,aAAa;IACb,8BAA8B;IAC9B,mBAAmB;IACn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AEA;IACI,kBAAkB;IAClB,eAAe;IACf,iBAAiB;AACrB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,YAAY;AAChB\",\"sourcesContent\":[\"html, body, #root {\\n height: 100%;\\n}\\n\\nbody {\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n color: #666;\\n margin: 0;\\n}\\n\\n#root {\\n display: flex;\\n flex-direction: column;\\n}\\n#root > div.graph {\\n flex: 1;\\n overflow: auto;\\n position: relative;\\n}\\n\\n.toolbar {\\n display: flex;\\n justify-content: space-between;\\n align-items: center;\\n padding: 4px 10px;\\n background-color: #f0f0f0;\\n border-bottom: 1px solid #cccccc;\\n}\\n\\n.toolbar > div {\\n display: flex;\\n align-items: center;\\n}\\n\\n.toolbar button {\\n padding: 5px 8px;\\n margin: 0 2px;\\n cursor: pointer;\\n}\\n\\n.toolbar button:disabled {\\n opacity: 0.5;\\n cursor: not-allowed;\\n}\\n\\n/* Drag mode toggle button styles */\\n.toolbar button.mode-toggle {\\n position: relative;\\n border: 1px solid #8f9fc9;\\n width: 40px;\\n min-height: 28px;\\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\\n border-color: #8f9fc9;\\n color: white;\\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\\n}\\n\\n.toolbar button.mode-toggle:hover {\\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\\n border-color: #abb8db;\\n}\\n\\n.toolbar button.mode-toggle.select-mode:active {\\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\\n}\\n\\n/* Pan mode and active toggle - darker blue */\\n.toolbar button.mode-toggle.pan-mode,\\n.toolbar button.active-toggle {\\n background: linear-gradient(to bottom, #4a90e2, #357abd);\\n border-color: #2968a3;\\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\\n}\\n\\n.toolbar button.mode-toggle.pan-mode:hover,\\n.toolbar button.active-toggle:hover {\\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\\n}\\n\\n.toolbar button.mode-toggle.pan-mode:active {\\n background: linear-gradient(to bottom, #357abd, #2968a3);\\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\\n}\\n\\n/* Toggle buttons when inactive - gray styling */\\n.toolbar button.inactive-toggle {\\n background: #c1c1c1;\\n color: #999;\\n border-color: #c1c1c1;\\n box-shadow: none;\\n}\\n\\n.toolbar button.inactive-toggle:hover {\\n background: #b1b1b1;\\n}\\n\\n.toolbar button.inactive-toggle:active {\\n background: #a1a1a1;\\n}\\n\\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\\n background: #c1c1c1;\\n color: #999;\\n border-color: #c1c1c1;\\n box-shadow: none;\\n}\\n\\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\\n.toolbar button .fas {\\n font-size: 1em;\\n vertical-align: middle;\\n}\\n\\n/* Zoom percentage display */\\n.toolbar button.zoom-display {\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\\n font-size: 11px;\\n font-weight: 600;\\n font-variant-numeric: tabular-nums;\\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\\n padding: 6px 8px;\\n text-align: center;\\n}\\n\\n.toolbar-group {\\n display: flex;\\n align-items: center;\\n margin-right: 25px; /* Large space between groups */\\n}\\n\\n.toolbar-group:last-child {\\n margin-right: 0; /* Remove right margin from the last group (help button) */\\n}\\n\\nbutton {\\n border: none;\\n background: linear-gradient(to bottom, #4a90e2, #357abd);\\n border-color: #2968a3;\\n border-radius: 3px;\\n padding: 6px 10px;\\n color: #fff;\\n outline: none;\\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\\n margin-right: 5px;\\n min-width: 32px;\\n min-height: 28px;\\n display: inline-flex;\\n align-items: center;\\n justify-content: center;\\n font-size: 14px;\\n line-height: 1;\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n position: relative;\\n}\\n\\nbutton:hover {\\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\\n}\\n\\nbutton:active {\\n background: linear-gradient(to bottom, #357abd, #2968a3);\\n}\\n\\nbutton:last-child {\\n margin-right: 0;\\n}\\n\\n/* Save button when no changes - gray */\\nbutton.action {\\n background: #c1c1c1;\\n color: #999;\\n}\\n\\nbutton.action:active {\\n background: #b1b1b1;\\n}\\n\\n/* Save button when there are changes - orange */\\nbutton.grp {\\n background: linear-gradient(to bottom, #ee9564, #de7d48);\\n margin-right: 0;\\n}\\n\\nbutton.grp:active {\\n background: #d67540;\\n}\\n\\n/* Auto-arrange button with AI purple to blue gradient */\\nbutton.auto-arrange {\\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\\n border-color: #4a4c93;\\n}\\n\\nbutton.auto-arrange:hover {\\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\\n border-color: #5a5ca3;\\n}\\n\\nbutton.auto-arrange:active {\\n background: linear-gradient(135deg, #593B83, #357abd);\\n border-color: #3a3c83;\\n}\\n\\nselect {\\n border: 1px solid #ccc;\\n background: white;\\n border-radius: 3px;\\n padding: 3px 7px;\\n color: #666;\\n outline: none;\\n margin-right: 5px;\\n font-size: 12px;\\n}\\n\\nselect:disabled {\\n background: #f5f5f5;\\n color: #999;\\n}\\n\\nbutton:disabled {\\n background: #c1c1c1;\\n color: #999;\\n}\\n\\n#root > div > svg {\\n position: absolute;\\n user-select: none;\\n}\\n\\n\\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\\n stroke: #29c229;\\n}\\n.edge .v-dot {\\n fill: transparent;\\n stroke: transparent;\\n stroke-width: 3px;\\n cursor: pointer;\\n transition: stroke 0.15s ease;\\n}\\n.edge .v-dot:hover {\\n stroke: #999;\\n fill: rgba(153, 153, 153, 0.1);\\n}\\n.edge .v-dot.selected {\\n stroke: #29c229;\\n fill: rgba(41, 194, 41, 0.1);\\n}\\n.edge .v-dot.selected:hover {\\n stroke: #29c229;\\n fill: rgba(41, 194, 41, 0.2);\\n}\\n.edge .v-dot.auto.selected {\\n stroke: #777;\\n fill: rgba(119, 119, 119, 0.1);\\n}\\n.edge .v-dot.auto.selected:hover {\\n stroke: #777;\\n fill: rgba(119, 119, 119, 0.2);\\n}\\ncircle#prj {\\n fill: none;\\n stroke: #777;\\n}\\n\\n.nodeShadow {\\n fill: none;\\n stroke-width: 4px;\\n stroke: rgba(0, 0, 0, 0.13);\\n}\\n\\ng.node {\\n user-select: none;\\n cursor: default;\\n}\\n\\ng.node.linked {\\n cursor: pointer;\\n}\\n\\ng.node text {\\n pointer-events: none;\\n}\\n\\n.icon {\\n fill: #aaa;\\n stroke: #fff;\\n}\\n#icon-cube {\\n fill: #aaa;\\n}\\n\\n/* Ensure all button icons are uncolored */\\nbutton .icon,\\nbutton svg,\\nbutton path {\\n fill: currentColor !important;\\n stroke: none !important;\\n}\\n\\n/* Font Awesome icon styling in buttons */\\nbutton i {\\n font-size: 12px;\\n color: inherit;\\n}\\n\\nrect.elastic {\\n pointer-events: none;\\n stroke: none;\\n fill: #3bd8281f;\\n display: none;\\n}\\nrect.elastic.on {\\n display: block;\\n}\\n\\n.popover {\\n position: absolute;\\n top: 50px;\\n bottom: 10px;\\n overflow: auto;\\n right: 10px;\\n background: ghostwhite;\\n padding: 30px;\\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\\n border: solid 1px #eee;\\n}\\n\\n.popover th {\\n text-align: left;\\n padding: 20px 0px 10px;\\n}\\n.popover td {\\n padding-right: 20px;\\n font-size: 14px;\\n}\\n\\n/* Simple tooltip system with smart positioning */\\n[data-tooltip] {\\n position: relative;\\n}\\n\\n[data-tooltip]:hover::after {\\n content: attr(data-tooltip);\\n position: absolute;\\n top: 100%;\\n left: 50%;\\n transform: translateX(-50%);\\n background: rgba(0, 0, 0, 0.9);\\n color: white;\\n padding: 6px 12px;\\n border-radius: 4px;\\n font-size: 12px !important;\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\\n font-weight: normal !important;\\n white-space: nowrap;\\n z-index: 1000;\\n pointer-events: none;\\n margin-top: 5px;\\n animation: tooltip-appear 0.1s ease-out;\\n min-width: 120px;\\n max-width: calc(100vw - 20px);\\n box-sizing: border-box;\\n}\\n\\n[data-tooltip]:hover::before {\\n content: '';\\n position: absolute;\\n top: 100%;\\n left: 50%;\\n transform: translateX(-50%);\\n border: 4px solid transparent;\\n border-bottom-color: rgba(0, 0, 0, 0.9);\\n z-index: 1000;\\n pointer-events: none;\\n margin-top: 1px;\\n animation: tooltip-appear 0.1s ease-out;\\n}\\n\\n/* Special handling for rightmost elements that might overflow */\\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\\n /* Apply to last 2 toolbar groups (save and help buttons) */\\n left: auto;\\n right: 0;\\n transform: none;\\n}\\n\\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\\n /* Apply to last 2 toolbar groups (save and help buttons) */\\n left: auto;\\n right: 16px;\\n transform: none;\\n}\\n\\n@keyframes tooltip-appear {\\n from {\\n opacity: 0;\\n transform: translateX(-50%) translateY(-5px);\\n }\\n to {\\n opacity: 1;\\n transform: translateX(-50%) translateY(0);\\n }\\n}\\n\\nselect {\\n position: relative;\\n}\\n\\n/* Robot shape internal elements - inherit stroke from parent node */\\n.node .robot-eye-socket {\\n fill: none;\\n stroke: inherit;\\n stroke-width: 2;\\n}\\n\\n.node .robot-eye {\\n fill: currentColor;\\n stroke: none;\\n}\\n\\n.node .robot-mouth {\\n stroke: inherit;\\n}\\n\\n.node .robot-antenna {\\n stroke: inherit;\\n}\\n\\n.node .robot-antenna-ball {\\n fill: currentColor;\\n stroke: inherit;\\n stroke-width: 1.5;\\n}\\n\\n.node .robot-panel {\\n stroke: inherit;\\n}\\n\\n.node .robot-indicator {\\n fill: currentColor;\\n stroke: none;\\n}\"],\"sourceRoot\":\"\"}]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___;\n","// Imports\nimport ___CSS_LOADER_API_SOURCEMAP_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/sourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/api.js\";\nimport ___CSS_LOADER_GET_URL_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/getUrl.js\";\nvar ___CSS_LOADER_URL_IMPORT_0___ = new URL(\"@fontsource/inter/files/inter-latin-400-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_1___ = new URL(\"@fontsource/inter/files/inter-latin-500-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_2___ = new URL(\"@fontsource/inter/files/inter-latin-600-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_3___ = new URL(\"@fontsource/inter/files/inter-latin-700-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_SOURCEMAP_IMPORT___);\nvar ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___);\nvar ___CSS_LOADER_URL_REPLACEMENT_1___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_1___);\nvar ___CSS_LOADER_URL_REPLACEMENT_2___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_2___);\nvar ___CSS_LOADER_URL_REPLACEMENT_3___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_3___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_0___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_1___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_2___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_3___}) format(\"woff2\");\n}\n`, \"\",{\"version\":3,\"sources\":[\"webpack://./src/fonts.css\"],\"names\":[],\"mappings\":\"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF\",\"sourcesContent\":[\"/* Local Inter files keep browser text measurement identical without internet access. */\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 400;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-400-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 500;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-500-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 600;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-600-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 700;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-700-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\"],\"sourceRoot\":\"\"}]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___.toString();\n","\n import API from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\";\n import domAPI from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleDomAPI.js\";\n import insertFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertBySelector.js\";\n import setAttributes from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js\";\n import insertStyleElement from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertStyleElement.js\";\n import styleTagTransformFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleTagTransform.js\";\n import content, * as namedExport from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./fonts.css\";\n \n \n\nvar options = {};\n\noptions.styleTagTransform = styleTagTransformFn;\noptions.setAttributes = setAttributes;\noptions.insert = insertFn.bind(null, \"head\");\noptions.domAPI = domAPI;\noptions.insertStyleElement = insertStyleElement;\n\nvar update = API(content, options);\n\n\n\nexport * from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./fonts.css\";\n export default content && content.locals ? content.locals : undefined;\n","\n import API from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\";\n import domAPI from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleDomAPI.js\";\n import insertFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertBySelector.js\";\n import setAttributes from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js\";\n import insertStyleElement from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertStyleElement.js\";\n import styleTagTransformFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleTagTransform.js\";\n import content, * as namedExport from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./style.css\";\n \n \n\nvar options = {};\n\noptions.styleTagTransform = styleTagTransformFn;\noptions.setAttributes = setAttributes;\noptions.insert = insertFn.bind(null, \"head\");\noptions.domAPI = domAPI;\noptions.insertStyleElement = insertStyleElement;\n\nvar update = API(content, options);\n\n\n\nexport * from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./style.css\";\n export default content && content.locals ? content.locals : undefined;\n"],"names":["el","style","Object","entries","forEach","key","value","setAttribute","String","nodeBorder","nodeText","stroke","edgeText","edgeRect","fill","groupRect","groupText","cursor","thickness","color","opacity","fontSize","width","dashed","p1","p2","Math","sqrt","x","y","height","background","shape","metadata","description","calculateEdgeVertices","edge","n1","from","n2","to","vertices","concat","unshift","push","interior","slice","firstRoutingVertex","find","vertex","label","lastRoutingVertex","index","length","intersect","Error","id","calculateLabelPlacement","position","defaultPoint","segment","point","labelIndex","findIndex","movable","labelVertex","auto","adjacentSegments","p","q","reduce","longest","candidate","_constants__WEBPACK_IMPORTED_MODULE_0__","gd","undefined","targetLength","sum","traversed","segmentPosition","horizontalDistance","abs","verticalDistance","orientation","createEdgePath","path","Symbol","GeometryValidationError","issues","constructor","super","map","issue","message","join","this","name","validateResolvedLayout","measured","resolved","diagramId","checkUniqueIDs","nodes","node","groups","group","edges","checkCoverage","measuredNodes","Map","measuredGroups","resolvedNodes","resolvedGroups","checkFiniteRect","bounds","expected","get","nearlyEqual","size","contentSize","checkRectInBounds","titleBounds","contains","titleSize","forEachPair","first","second","overlaps","checkNodeOverlaps","checkGroupOverlaps","child","parentId","parent","checkOwnership","measuredEdges","labels","sourceId","targetId","sections","some","section","checkSectionConnections","isFinitePoint","pointInRect","values","routeIntersectsRect","inset","sourceInside","belongsToGroup","routeViolatesGroup","labelBounds","labelSize","checkEdges","ids","seen","Set","has","add","actual","expectedIDs","actualIDs","rect","Number","isFinite","isFiniteRect","samePoint","source","target","start","end","pointOnBorder","nodeId","groupId","shouldBeInside","dx","dy","minimum","maximum","origin","delta","lower","upper","EPSILON","max","min","segmentIntersectsRect","outer","inner","inclusive","amount","withinX","withinY","onVertical","onHorizontal","items","visit","code","elementIds","create","element","type","attrs","className","document","createElementNS","k","v","classList","use","setAttributeNS","d","text","t","textContent","textArea","bold","anchor","constants","M5","lines","maxW","svg_text","U2","txt","line","i","span","append","r","rx","ry","icon","expand","expanded","g","transform","setPosition","insideBox","b","centeredBox","intersectRect","box","w","h","s","q1","q2","denominator","a","numerator1","numerator2","result","onLine1","onLine2","segmentIntersection","filter","ret","intersectRectFull","intersectEllipse","ellCenter","nodeCenter","si","c","radicand_sqrt","pos","project","atob","len","dot","cabDistance","cylinderRadiusY","shapeLabelOffsetY","toLowerCase","D3Element","_el","attr","insert","el2","insertBefore","querySelector","bbox","rounded","shapeSvg","_ellipse","mobiledeviceportrait","shapes","roundedbox","component","cylinder","cy","person","circle","ellipse","hexagon","sz","n","folder","mobiledevicelandscape","mobiledevice","pipe","robot","headSize","headR","antennaH","antennaR","eyeR","eyeSpacing","earW","earH","bodyW","bodyTop","bodyH","headTop","eyeY","mouthY","mouthW","webbrowser","Undo","versions","lastSavedPos","exportDoc","importDoc","change","tmpPreviousState","func","timeout","context","clearTimeout","setTimeout","apply","debounce","saveNow","beforeChange","deepClone","currentState","splice","doc","structuredClone","JSON","parse","stringify","undo","redo","changed","setSaved","textBlock","gapAfter","field","wrapped","lineHeight","defaultEdgeStyle","Y$","defaultNodeStyle","nD","graphCount","GraphData","nodesMap","edgeVertices","groupsMap","layoutDirection","validatedLayout","colorToVarMap","svg","idPrefix","selectListener","dragging","_undo","_gridVisible","_snapToGrid","_gridSize","_skipAutoFit","exportLayout","lo","importLayout","init","layout","addNode","sub","link","nodeStyle","minimumHeight","contentLayout","title","subtitle","nodeWidth","textWidth","HORIZONTAL_PADDING","blocks","textHeight","block","VERTICAL_PADDING","ICON_SIZE","layoutNodeContent","requiredHeight","set","Array","addEdge","fromNode","toNode","initVertex","edgeID","input","charCodeAt","imul","toString","fnv1a36","stableVertexID","userDeletedVertices","addGroup","nodesOrGroups","console","error","Boolean","setNodeSelected","selected","ref","remove","updateEdgesSel","e","clearResolvedLayout","layoutSections","layoutLabelBounds","layoutBounds","layoutTitleBounds","moveNode","disableSnap","skipUndo","snapped","snapToGrid","redrawEdges","redrawGroups","moveEdgeVertex","redrawEdge","moveSelected","insertEdgeVertex","isLabel","deleteEdgeVertex","indexOf","delete","alignTopLeft","contentBounds","calculateContentBounds","offsetX","offsetY","resetPanTransform","currentZoom","getZoom","zoomGroup","graphData","bb","zoom","parentElement","clientWidth","clientHeight","updatePanningOptimized","clearViewState","shouldSkipAutoFit","resetView","updatePanning","removeChild","buildEdge","buildGroup","exportSVG","U","originalSvg","exportSvg","cloneNode","rootAttributes","attributes","removeAttributeNode","setAttributeNode","removeIdPrefix","querySelectorAll","getAttribute","removeAttribute","exportElastic","exportWidth","padding","exportHeight","exportZoomGroup","convertStylesToCustomProperties","script","createElement","replace","firstChild","outerHTML","prefix","startsWith","includes","split","localName","minX","Infinity","minY","maxX","maxY","left","right","top","bottom","trim","centerX","centerY","approxLabelSize","full","lst","rerender","requiredSavedPoint","endsWith","edgeId","isArray","saved","autoLayout","options","placedNode","placedGroup","placedEdge","interiorRoutePoints","validated","fitToView","alignSelectionV","alignSelectionH","distributeSelectionH","selectedNodes","selectedVertices","allElements","sort","spacing","newX","distributeSelectionV","newY","setEdgeSelected","viewportWidth","viewportHeight","zoomX","zoomY","optimalZoom","finalZoom","translateX","translateY","saveViewState","saveLayoutState","restoreLayoutState","state","isGridVisible","isSnapToGrid","getGridSize","toggleGrid","updateGridDisplay","window","dispatchEvent","CustomEvent","toggleSnapToGrid","snapAllToGrid","snappedX","round","snappedY","existingGrid","existingGridRect","defs","pattern","appendChild","route","previous","buildGraph","data","onNodeSelect","dragMode","body","_buildGraph","elasticEl","addCursorInteraction","setZoom","currentTransform","getCurrentTransform","buildGraphView","innerHTML","fontsinline","A","LICENSE_raw","zoomG","nodesG","edgesG","groupsG","href","exportHref","content","shapeType","AV","setBorderStyle","border","tg","iconHeight","preserveAspectRatio","buildNodeContent","__data","buildNode","completeRoutePoints","edge_utils","l","bg","buildPlacedEdgeLabel","placement","buildEdgeLabel","IW","Zr","cx","p0","topExtension","bottomExtension","hexHeight","pad","findClosestSegment","graph","fnd","dst","POSITIVE_INFINITY","prj","pts","mouseToDrawing","getBoundingClientRect","z","clientX","clientY","addCustomCursorInteraction","conn","ini","elastic","isPanning","panStartX","panStartY","initialTransform","pendingSelectionChange","pendingNavigation","hasDragged","suppressLinkClick","eventListeners","onClick","Element","closest","preventDefault","stopPropagation","md","convertEvent","changedTouches","onMouseMoveHandler","getSelection","setSelection","setTransform","drawingDx","drawingDy","item","setDragging","update","onMouseMove","ex","ey","onMouseUpHandler","removeEventListener","navigation","boxSelection","shiftKey","location","onMouseUp","onMouseDownHandler","nodeFromEvent","effectiveMode","isSelected","translateMatch","match","parseFloat","getCurrentTransformLocal","startDrawingX","startDrawingY","pt","currentPt","currentDrawingX","currentDrawingY","createElastic","onMouseDown","addEventListener","event","handler","addDnd","existingCleanup","__cursorInteractionCleanup","beforeUnloadHandler","returnValue","setDotSelected","dotEl","mouseMoveHandler","altKey","removePrjDot","keyUpHandler","shortcuts","Yp","Zj","_s","clickHandler","wheelHandler","sign","deltaY","newZoom","svgX","svgY","setZoomCentered","keyDownHandler","shortcut","bl","Ur","newZoomIn","hU","newZoomOut","i1","mD","F","Gn","customInteractionCleanup","getData","handles","handle","b1","b2","scaleMatch","oldZoom","container","newTranslateX","newTranslateY","getBBox","viewStateCache","restoreViewState","defaultOptions","direction","nodeSpacing","layerSpacing","async","resolveAutomatic","diagram","checkMeasuredLinks","childrenByParent","groupsByParent","elkGroups","children","layoutOptions","groupLayoutOptions","root","rootLayoutOptions","owner","lowestCommonGroup","buildLayoutTree","elk","__webpack_require__","then","bind","module","default","readContainer","readResolvedLayout","sources","targets","titleHeight","sourceGroups","parentGroups","targetGroups","current","parentX","parentY","containerX","containerY","childX","requiredNumber","childY","measuredNode","measuredGroup","requiredLabel","readEdge","addOffset","startPoint","bendPoints","endPoint","requiredEndpoint","elementId","endpoints","siblings","fonts","ready","measureGraph","compactLayout","geometry","centerOffset","validateCurrentLayout","isConnected","boundary","SVGGraphicsElement","copyBox","snapshot","completeSnapshot","resolveManual","nodeParents","groupParents","member","parents","isGroup","existing","declaredParents","checkMeasuredBox","measureNode","measureGroup","measureEdge","hasLabel","boxes","flatMap","points","flat","measuredText","measurementSVG","loadDiagramFonts","Promise","all","weight","load","measureSVGText","localeCompare","measurementKey","cached","visibility","pointerEvents","svgTextWrap","paragraph","paragraphLines","currentLine","word","parts","breakLongWord","part","nextLine","maxWidth","currentPart","character","nextPart","layoutDirections","TopBottom","BottomTop","LeftRight","RightLeft","model","viewsList","keys","views","layouts","viewKey","elements","relations","collectRels","relationships","rel","people","softwareSystems","containers","el1","components","deploymentNodes","containerInstances","containerId","recAddNodes","infrastructureNodes","view","getView","_graph_view_graph__WEBPACK_IMPORTED_MODULE_0__","jg","rankDirection","automaticLayout","version","groupingIDs","externalContainersBoundariesVisible","softwareSystemId","enterprise","styles","cssClassName","tag","varPrefix","elementViewKey","containerViews","lookupContainerViewKey","tags","technology","encodedViewKey","encodeURIComponent","url","nodeLink","properties","warn","destinationId","routing","level","groupMembers","ADD_VERTEX","ADD_LABEL_VERTEX","DEL_VERTEX","ZOOM_IN","ZOOM_OUT","ZOOM_FIT","ZOOM_100","SELECT_ALL","DESELECT","MOVE_LEFT","MOVE_RIGHT","MOVE_UP","MOVE_DOWN","MOVE_LEFT_FINE","MOVE_RIGHT_FINE","MOVE_UP_FINE","MOVE_DOWN_FINE","TOGGLE_DRAG_MODE","ALIGN_HORIZONTAL","ALIGN_VERTICAL","DISTRIBUTE_HORIZONTAL","DISTRIBUTE_VERTICAL","AUTO_LAYOUT","RESET_POSITION","TOGGLE_GRID","TOGGLE_SNAP_TO_GRID","SNAP_ALL_TO_GRID","list","help","combinations","shift","ctrl","alt","click","wheel","shortcutMap","comboText","_utils_platform__WEBPACK_IMPORTED_MODULE_1__","sy","toUpperCase","react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__","jsxs","jsx","Fragment","colSpan","matches","SA","ke","checkKey","aShortcut","bShortcut","aModifiers","bModifiers","aCount","isMac","navigator","userAgentData","platform","userAgent","KeyboardEvent","metaKey","test","ctrlKey","___CSS_LOADER_URL_IMPORT_0___","URL","___CSS_LOADER_URL_IMPORT_1___","___CSS_LOADER_URL_IMPORT_2___","___CSS_LOADER_URL_IMPORT_3___","___CSS_LOADER_EXPORT___","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default","___CSS_LOADER_URL_REPLACEMENT_0___","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default","___CSS_LOADER_URL_REPLACEMENT_1___","___CSS_LOADER_URL_REPLACEMENT_2___","___CSS_LOADER_URL_REPLACEMENT_3___","names","mappings","sourcesContent","sourceRoot","__WEBPACK_DEFAULT_EXPORT__","styleTagTransform","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default","setAttributes","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default","domAPI","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default","insertStyleElement","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_cjs_js_fonts_css__WEBPACK_IMPORTED_MODULE_6__","locals","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_cjs_js_style_css__WEBPACK_IMPORTED_MODULE_6__"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"286.js","mappings":"mGAwH0B,CAACA,EAAgBC,KA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,EAAO0Z,4ICbzD3d,EAAA,GAEAA,EAAAgd,kBAA4BC,IAC5Bjd,EAAAkd,cAAwBC,IACxBnd,EAAA5O,OAAiBgsB,IAAArO,KAAa,aAC9B/O,EAAAqd,OAAiBC,IACjBtd,EAAAud,mBAA6BC,IAEhBC,IAAIG,EAAA3Z,EAAOjE,GAKF4d,EAAA3Z,GAAW2Z,EAAA3Z,EAAO0Z,QAAUC,EAAA3Z,EAAO0Z","sources":["webpack://app/./src/graph-view/constants.ts","webpack://app/./src/graph-view/edge-utils.ts","webpack://app/./src/graph-view/geometry.ts","webpack://app/./src/graph-view/svg-create.ts","webpack://app/./src/graph-view/intersect.ts","webpack://app/./src/graph-view/shapes.ts","webpack://app/./src/graph-view/undo.ts","webpack://app/./src/graph-view/node-content.ts","webpack://app/./src/graph-view/graph.ts","webpack://app/./src/graph-view/defs.ts","webpack://app/./src/graph-view/automatic-layout.ts","webpack://app/./src/graph-view/layout.ts","webpack://app/./src/graph-view/manual-layout.ts","webpack://app/./src/graph-view/svg-text.ts","webpack://app/./src/parseModel.ts","webpack://app/./src/shortcuts.tsx","webpack://app/./src/utils/platform.ts","webpack://app/./src/fonts.css","webpack://app/./src/style.css","webpack://app/./src/fonts.css?0e2c","webpack://app/./src/fonts.css?a158","webpack://app/./src/style.css?dd02"],"sourcesContent":["// Constants and default configurations for the graph view\n\nexport interface Point {\n\tx: number;\n\ty: number;\n}\n\nexport interface BBox extends Point {\n\twidth: number;\n\theight: number;\n}\n\nexport interface NodeStyle {\n\t// Width of element, in pixels.\n\twidth?: number\n\t// Height of element, in pixels.\n\theight?: number\n\t// Background color of element as HTML RGB hex string (e.g. \"#ffffff\")\n\tbackground?: string\n\t// Stroke color of element as HTML RGB hex string (e.g. \"#000000\")\n\tstroke?: string\n\t// Foreground (text) color of element as HTML RGB hex string (e.g. \"#ffffff\")\n\tcolor?: string\n\t// Standard font size used to render text, in pixels.\n\tfontSize?: number\n\t// Shape used to render element.\n\tshape?: string\n\t// URL of PNG/JPG/GIF file or Base64 data URI representation.\n\ticon?: string\n\t// Type of border used to render element.\n\tborder?: string\n\t// Opacity used to render element; 0-100.\n\topacity?: number\n\t// Whether element metadata should be shown.\n\tmetadata?: boolean\n\t// Whether element description should be shown.\n\tdescription?: boolean\n}\n\nexport interface EdgeStyle {\n\t// Thickness of line, in pixels.\n\tthickness?: number\n\t// Color of line as HTML RGB hex string (e.g. \"#ffffff\").\n\tcolor?: string\n\t// Standard font size used to render relationship annotation, in pixels.\n\tfontSize?: number\n\t// Width of relationship annotation, in pixels.\n\twidth?: number\n\t// Whether line is dashed.\n\tdashed?: boolean\n\t// Position of label along edge (0-100).\n\tposition?: number\n\t// Opacity used to render relationship; 0-100.\n\topacity?: number\n\t// Arrow style for the edge.\n\tarrowStyle?: 'normal' | 'large' | 'small' | 'none'\n}\n\n// Default styles\nexport const DEFAULT_EDGE_STYLE: EdgeStyle = {\n\tthickness: 2,\n\tcolor: '#64748b',\n\topacity: 1,\n\tfontSize: 18,\n\twidth: 200,\n\tdashed: true,\n};\n\nexport const DEFAULT_NODE_STYLE: NodeStyle = {\n\twidth: 280,\n\theight: 180,\n\tbackground: '#ffffff',\n\tcolor: '#334155',\n\topacity: 1,\n\tstroke: '#8492a6',\n\tfontSize: 22,\n\tshape: 'Box',\n\tmetadata: true,\n\tdescription: true,\n};\n\n// SVG styles\nexport const SVG_STYLES = {\n\tnodeBorder: {\n\t\t'stroke-width': 1.5,\n\t},\n\tnodeText: {\n\t\t'font-family': 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',\n\t\tstroke: \"none\"\n\t},\n\tedgeText: {\n\t\t'font-family': 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',\n\t\tstroke: \"none\"\n\t},\n\tedgeRect: {\n\t\tfill: \"none\",\n\t\tstroke: \"none\",\n\t},\n\tgroupRect: {\n\t\tfill: \"none\",\n\t\tstroke: \"#8492a6\",\n\t\t'stroke-width': 1.5,\n\t\t\"stroke-dasharray\": \"6 4\",\n\t},\n\tgroupText: {\n\t\tfill: \"#475569\",\n\t\t\"font-size\": 20,\n\t\t\"font-weight\": \"600\",\n\t\t'font-family': 'Inter, -apple-system, BlinkMacSystemFont, sans-serif',\n\t\tcursor: \"default\"\n\t}\n};\n\n// Configuration constants\nexport const SVG_PADDING = 20;\nexport const DEFAULT_GRID_SIZE = 25;\nexport const EDGE_SPREAD_DISTANCE = 70;\nexport const EDGE_SPREAD_DISTANCE_X = 200;\n\n// Set presentation attributes so an author's later attributes override defaults.\nexport const applyStyle = (el: SVGElement, style: { [key: string]: string | number }) => {\n\tObject.entries(style).forEach(([key, value]) => {\n\t\tel.setAttribute(key, String(value));\n\t});\n};\n\n// Utility function to calculate distance between two points\nexport const calculateDistance = (p1: Point, p2: Point): number => {\n\treturn Math.sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));\n};\n","import { Point, calculateDistance } from './constants';\nimport { Segment } from './intersect';\n\n// Define interfaces locally since they're not exported from graph.ts\ninterface NodeStyle {\n\tbackground?: string;\n\tstroke?: string;\n\topacity?: number;\n\tfontSize?: number;\n\tshape?: string;\n\tborder?: string;\n}\n\ninterface Node extends Point {\n\tid: string;\n\ttitle: string;\n\tsub: string;\n\tdescription: string;\n\twidth: number;\n\theight: number;\n\tref?: SVGGElement;\n\tselected?: boolean;\n\tintersect: (p: Point) => Point;\n\tstyle: NodeStyle;\n}\n\ninterface EdgeVertex extends Point {\n\tid: string;\n\tselected?: boolean;\n\tref?: SVGElement;\n\tlabel?: boolean;\n\tauto?: boolean;\n}\n\ninterface EdgeStyle {\n\tcolor?: string;\n\tthickness?: number;\n\tfontSize?: number;\n\tposition?: number;\n\tdashed?: boolean;\n}\n\ninterface Edge {\n\tid: string;\n\tlabel: string;\n\tfrom: Node;\n\tto: Node;\n\tvertices?: EdgeVertex[];\n\tref?: SVGGElement;\n\tstyle: EdgeStyle;\n\tinitVertex: (p: Point) => EdgeVertex;\n\tuserDeletedVertices?: boolean; // Track if user explicitly deleted vertices\n}\n\nexport interface EdgeLabelPlacement extends Point {\n\torientation: 'horizontal' | 'vertical';\n\tsegment?: Segment;\n\tmovable: boolean;\n}\n\n/**\n * Calculate edge vertices, handling multi-edge scenarios and auto-vertices\n */\nexport function calculateEdgeVertices(edge: Edge): Point[] {\n\tconst n1 = edge.from, n2 = edge.to;\n\t\n\t\n\t// if vertices exists, follow them\n\tlet vertices: Point[] = edge.vertices ? edge.vertices.concat() : [];\n\t// Don't remove label vertices - they should be preserved for rendering\n\t// (The autoLayout process handles replacing old ones with new ones)\n\n\tvertices.unshift(n1)\n\tvertices.push(n2)\n\n\tconst interior = vertices.slice(1, -1) as EdgeVertex[];\n\tconst firstRoutingVertex = interior.find(vertex => !vertex.label) ?? n2;\n\tlet lastRoutingVertex: Point = n1;\n\tfor (let index = interior.length - 1; index >= 0; index--) {\n\t\tif (!interior[index].label) {\n\t\t\tlastRoutingVertex = interior[index];\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!n1.intersect || !n2.intersect) {\n\t\tthrow new Error(`edge ${edge.id} nodes must be drawn before routing`);\n\t}\n\tvertices[0] = n1.intersect(firstRoutingVertex);\n\tvertices[vertices.length - 1] = n2.intersect(lastRoutingVertex);\n\t\n\treturn vertices;\n}\n\n/**\n * Calculate the label anchor and the orientation of the path segment that owns\n * it. Renderers use the orientation to place text beside the relationship line\n * instead of centering text over vertical segments.\n */\nexport function calculateLabelPlacement(\n\tvertices: Point[],\n\tposition: number,\n\tdefaultPoint: Point,\n): EdgeLabelPlacement {\n\tlet point = {x: defaultPoint.x, y: defaultPoint.y};\n\tlet segment: Segment | undefined;\n\tconst labelIndex = vertices.findIndex(vertex => (vertex as EdgeVertex).label);\n\tlet movable = true;\n\n\tif (labelIndex >= 0) {\n\t\tconst labelVertex = vertices[labelIndex] as EdgeVertex;\n\t\tpoint = labelVertex;\n\t\tmovable = labelVertex.auto === true;\n\t\tconst adjacentSegments: Segment[] = [];\n\t\tif (labelIndex > 0) {\n\t\t\tadjacentSegments.push({p: vertices[labelIndex - 1], q: point});\n\t\t}\n\t\tif (labelIndex < vertices.length - 1) {\n\t\t\tadjacentSegments.push({p: point, q: vertices[labelIndex + 1]});\n\t\t}\n\t\tsegment = adjacentSegments.reduce((longest, candidate) => {\n\t\t\tif (!longest) {\n\t\t\t\treturn candidate;\n\t\t\t}\n\t\t\treturn calculateDistance(candidate.p, candidate.q) >\n\t\t\t\tcalculateDistance(longest.p, longest.q)\n\t\t\t\t? candidate\n\t\t\t\t: longest;\n\t\t}, undefined);\n\t} else {\n\t\tconst totalLength = vertices.slice(1).reduce(\n\t\t\t(sum, vertex, index) => sum + calculateDistance(vertices[index], vertex),\n\t\t\t0,\n\t\t);\n\t\tconst targetLength = totalLength * position;\n\t\tlet traversed = 0;\n\t\tfor (let index = 1; index < vertices.length; index++) {\n\t\t\tconst candidate = {p: vertices[index - 1], q: vertices[index]};\n\t\t\tconst length = calculateDistance(candidate.p, candidate.q);\n\t\t\tif (length > 0 && traversed + length >= targetLength) {\n\t\t\t\tconst segmentPosition = (targetLength - traversed) / length;\n\t\t\t\tpoint = {\n\t\t\t\t\tx: candidate.p.x + (candidate.q.x - candidate.p.x) * segmentPosition,\n\t\t\t\t\ty: candidate.p.y + (candidate.q.y - candidate.p.y) * segmentPosition,\n\t\t\t\t};\n\t\t\t\tsegment = candidate;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ttraversed += length;\n\t\t}\n\t}\n\n\tconst horizontalDistance = segment ? Math.abs(segment.q.x - segment.p.x) : 0;\n\tconst verticalDistance = segment ? Math.abs(segment.q.y - segment.p.y) : 0;\n\treturn {\n\t\t...point,\n\t\torientation: verticalDistance > horizontalDistance ? 'vertical' : 'horizontal',\n\t\tsegment,\n\t\tmovable,\n\t};\n}\n\n/** createEdgePath draws the given points without cutting or moving the route. */\nexport function createEdgePath(vertices: Point[]): string {\n\tif (vertices.length < 2) {\n\t\tthrow new Error(\"edge route must contain at least two points\");\n\t}\n\treturn vertices.slice(1).reduce(\n\t\t(path, point) => `${path} L${point.x},${point.y}`,\n\t\t`M${vertices[0].x},${vertices[0].y}`,\n\t);\n}","// This file defines the diagram sizes and positions shared by layout and SVG\n// drawing. Automatic and manual layout both produce ResolvedLayout. The SVG\n// drawing code accepts a layout only after this file has checked it.\n\n/** Point is one position in the diagram. */\nexport interface Point {\n\tx: number;\n\ty: number;\n}\n\n/** Size is a width and height. Both values must be zero or greater. */\nexport interface Size {\n\twidth: number;\n\theight: number;\n}\n\n/** Rect is a box that does not rotate. */\nexport interface Rect extends Point, Size {}\n\n/** MeasuredNode holds the exact box and text sizes needed before layout. */\nexport interface MeasuredNode {\n\tid: string;\n\tparentId?: string;\n\tsize: Size;\n\tcontentSize: Size;\n\tcenterOffset: Point;\n\tshape: string;\n}\n\n/** MeasuredGroup describes a boundary that must contain its children and title. */\nexport interface MeasuredGroup {\n\tid: string;\n\tparentId?: string;\n\ttitleSize: Size;\n}\n\n/** MeasuredEdge names the two connected nodes and the exact label size. */\nexport interface MeasuredEdge {\n\tid: string;\n\tsourceId: string;\n\ttargetId: string;\n\tlabelSize?: Size;\n}\n\n/**\n * MeasuredDiagram is the complete input to automatic or manual layout.\n * It contains sizes, but no positions.\n */\nexport interface MeasuredDiagram {\n\tid: string;\n\tnodes: MeasuredNode[];\n\tgroups: MeasuredGroup[];\n\tedges: MeasuredEdge[];\n}\n\n/** ResolvedNode is one measured node placed in the diagram. */\nexport interface ResolvedNode {\n\tid: string;\n\tparentId?: string;\n\tbounds: Rect;\n}\n\n/** ResolvedGroup is one placed boundary and its title box. */\nexport interface ResolvedGroup {\n\tid: string;\n\tparentId?: string;\n\tbounds: Rect;\n\ttitleBounds: Rect;\n}\n\n/**\n * ResolvedEdge contains a complete route. Each section is an ordered list of\n * points. labelBounds is the final label box chosen by layout.\n */\nexport interface ResolvedEdge {\n\tid: string;\n\tsourceId: string;\n\ttargetId: string;\n\tsections: Point[][];\n\tlabelBounds?: Rect;\n}\n\n/**\n * ResolvedLayout is the unchecked result of automatic or manual layout.\n * Drawing code must not use it directly.\n */\nexport interface ResolvedLayout {\n\tdiagramId: string;\n\tbounds: Rect;\n\tnodes: ResolvedNode[];\n\tgroups: ResolvedGroup[];\n\tedges: ResolvedEdge[];\n}\n\n/** GeometryIssueCode names one rule that the layout broke. */\nexport type GeometryIssueCode =\n\t| \"duplicate_id\"\n\t| \"missing_element\"\n\t| \"unexpected_element\"\n\t| \"non_finite\"\n\t| \"size_mismatch\"\n\t| \"content_overflow\"\n\t| \"node_overlap\"\n\t| \"group_overlap\"\n\t| \"false_containment\"\n\t| \"edge_through_node\"\n\t| \"edge_through_group\"\n\t| \"label_node_overlap\"\n\t| \"label_label_overlap\"\n\t| \"label_edge_overlap\"\n\t| \"label_title_overlap\"\n\t| \"out_of_bounds\"\n\t| \"disconnected_edge\";\n\n/** GeometryIssue reports the stable IDs of the affected diagram elements. */\nexport interface GeometryIssue {\n\tcode: GeometryIssueCode;\n\telementIds: string[];\n\tmessage: string;\n}\n\nconst validatedLayoutBrand: unique symbol = Symbol(\"ValidatedLayout\");\n\n/**\n * ValidatedLayout is the only layout the SVG drawing code accepts. The private\n * marker prevents other code from creating one without running the checks.\n */\nexport type ValidatedLayout = ResolvedLayout & {\n\treadonly [validatedLayoutBrand]: true;\n};\n\n/** GeometryValidationError reports every layout problem found in one check. */\nexport class GeometryValidationError extends Error {\n\treadonly issues: GeometryIssue[];\n\n\tconstructor(issues: GeometryIssue[]) {\n\t\tsuper(issues.map(issue => issue.message).join(\"\\n\"));\n\t\tthis.name = \"GeometryValidationError\";\n\t\tthis.issues = issues;\n\t}\n}\n\n/**\n * validateResolvedLayout checks that every element is present, every number is\n * valid, boundaries show true ownership, elements do not collide, and all\n * content stays inside the diagram.\n */\nexport function validateResolvedLayout(\n\tmeasured: MeasuredDiagram,\n\tresolved: ResolvedLayout,\n): ValidatedLayout {\n\tconst issues: GeometryIssue[] = [];\n\tif (measured.id !== resolved.diagramId) {\n\t\tissues.push(issue(\n\t\t\t\"missing_element\",\n\t\t\t[measured.id, resolved.diagramId],\n\t\t\t`layout ${resolved.diagramId} does not resolve measured diagram ${measured.id}`,\n\t\t));\n\t}\n\n\tcheckUniqueIDs(\"measured node\", measured.nodes.map(node => node.id), issues);\n\tcheckUniqueIDs(\"measured group\", measured.groups.map(group => group.id), issues);\n\tcheckUniqueIDs(\"measured edge\", measured.edges.map(edge => edge.id), issues);\n\tcheckUniqueIDs(\"resolved node\", resolved.nodes.map(node => node.id), issues);\n\tcheckUniqueIDs(\"resolved group\", resolved.groups.map(group => group.id), issues);\n\tcheckUniqueIDs(\"resolved edge\", resolved.edges.map(edge => edge.id), issues);\n\n\tcheckCoverage(\n\t\t\"node\",\n\t\tmeasured.nodes.map(node => node.id),\n\t\tresolved.nodes.map(node => node.id),\n\t\tissues,\n\t);\n\tcheckCoverage(\n\t\t\"group\",\n\t\tmeasured.groups.map(group => group.id),\n\t\tresolved.groups.map(group => group.id),\n\t\tissues,\n\t);\n\tcheckCoverage(\n\t\t\"edge\",\n\t\tmeasured.edges.map(edge => edge.id),\n\t\tresolved.edges.map(edge => edge.id),\n\t\tissues,\n\t);\n\n\tconst measuredNodes = new Map(measured.nodes.map(node => [node.id, node]));\n\tconst measuredGroups = new Map(measured.groups.map(group => [group.id, group]));\n\tconst resolvedNodes = new Map(resolved.nodes.map(node => [node.id, node]));\n\tconst resolvedGroups = new Map(resolved.groups.map(group => [group.id, group]));\n\n\tcheckFiniteRect(\"diagram\", resolved.diagramId, resolved.bounds, issues);\n\tfor (const node of resolved.nodes) {\n\t\tcheckFiniteRect(\"node\", node.id, node.bounds, issues);\n\t\tconst expected = measuredNodes.get(node.id);\n\t\tif (expected && (\n\t\t\t!nearlyEqual(expected.size.width, node.bounds.width) ||\n\t\t\t!nearlyEqual(expected.size.height, node.bounds.height)\n\t\t)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"size_mismatch\",\n\t\t\t\t[node.id],\n\t\t\t\t`node ${node.id} size changed after measurement`,\n\t\t\t));\n\t\t}\n\t\tif (expected && (\n\t\t\texpected.contentSize.width > node.bounds.width ||\n\t\t\texpected.contentSize.height > node.bounds.height\n\t\t)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"content_overflow\",\n\t\t\t\t[node.id],\n\t\t\t\t`node ${node.id} content exceeds its resolved bounds`,\n\t\t\t));\n\t\t}\n\t\tcheckRectInBounds(\"node\", node.id, node.bounds, resolved.bounds, issues);\n\t}\n\tfor (const group of resolved.groups) {\n\t\tcheckFiniteRect(\"group\", group.id, group.bounds, issues);\n\t\tcheckFiniteRect(\"group title\", group.id, group.titleBounds, issues);\n\t\tcheckRectInBounds(\"group\", group.id, group.bounds, resolved.bounds, issues);\n\t\tif (!contains(group.bounds, group.titleBounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[group.id],\n\t\t\t\t`group ${group.id} does not contain its title`,\n\t\t\t));\n\t\t}\n\t\tconst expected = measuredGroups.get(group.id);\n\t\tif (expected && (\n\t\t\t!nearlyEqual(expected.titleSize.width, group.titleBounds.width) ||\n\t\t\t!nearlyEqual(expected.titleSize.height, group.titleBounds.height)\n\t\t)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"size_mismatch\",\n\t\t\t\t[group.id],\n\t\t\t\t`group ${group.id} title size changed after measurement`,\n\t\t\t));\n\t\t}\n\t}\n\n\tcheckNodeOverlaps(resolved.nodes, issues);\n\tcheckGroupOverlaps(resolved.groups, issues);\n\tcheckOwnership(\n\t\tmeasured.nodes,\n\t\tmeasured.groups,\n\t\tresolvedNodes,\n\t\tresolvedGroups,\n\t\tissues,\n\t);\n\tcheckEdges(\n\t\tmeasured,\n\t\tresolved,\n\t\tresolvedNodes,\n\t\tresolvedGroups,\n\t\tmeasuredNodes,\n\t\tmeasuredGroups,\n\t\tissues,\n\t);\n\n\tif (issues.length > 0) {\n\t\tthrow new GeometryValidationError(issues);\n\t}\n\treturn resolved as ValidatedLayout;\n}\n\n/** checkUniqueIDs requires each model ID to appear only once. */\nfunction checkUniqueIDs(label: string, ids: string[], issues: GeometryIssue[]): void {\n\tconst seen = new Set();\n\tfor (const id of ids) {\n\t\tif (seen.has(id)) {\n\t\t\tissues.push(issue(\"duplicate_id\", [id], `${label} ${id} is duplicated`));\n\t\t}\n\t\tseen.add(id);\n\t}\n}\n\n/** checkCoverage rejects missing elements and old elements left in a layout. */\nfunction checkCoverage(\n\tlabel: string,\n\texpected: string[],\n\tactual: string[],\n\tissues: GeometryIssue[],\n): void {\n\tconst expectedIDs = new Set(expected);\n\tconst actualIDs = new Set(actual);\n\tfor (const id of expectedIDs) {\n\t\tif (!actualIDs.has(id)) {\n\t\t\tissues.push(issue(\"missing_element\", [id], `${label} ${id} is missing from resolved layout`));\n\t\t}\n\t}\n\tfor (const id of actualIDs) {\n\t\tif (!expectedIDs.has(id)) {\n\t\t\tissues.push(issue(\"unexpected_element\", [id], `${label} ${id} is not in the measured diagram`));\n\t\t}\n\t}\n}\n\n/** checkFiniteRect rejects invalid numbers and negative sizes. */\nfunction checkFiniteRect(\n\tlabel: string,\n\tid: string,\n\trect: Rect,\n\tissues: GeometryIssue[],\n): void {\n\tif (!isFiniteRect(rect) || rect.width < 0 || rect.height < 0) {\n\t\tissues.push(issue(\"non_finite\", [id], `${label} ${id} has invalid geometry`));\n\t}\n}\n\n/** checkRectInBounds requires the whole box to fit inside the diagram. */\nfunction checkRectInBounds(\n\tlabel: string,\n\tid: string,\n\trect: Rect,\n\tbounds: Rect,\n\tissues: GeometryIssue[],\n): void {\n\tif (!contains(bounds, rect)) {\n\t\tissues.push(issue(\"out_of_bounds\", [id], `${label} ${id} lies outside the resolved view bounds`));\n\t}\n}\n\n/** checkNodeOverlaps prevents two nodes from sharing the same area. */\nfunction checkNodeOverlaps(nodes: ResolvedNode[], issues: GeometryIssue[]): void {\n\tforEachPair(nodes, (first, second) => {\n\t\tif (overlaps(first.bounds, second.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"node_overlap\",\n\t\t\t\t[first.id, second.id],\n\t\t\t\t`nodes ${first.id} and ${second.id} overlap`,\n\t\t\t));\n\t\t}\n\t});\n}\n\n/**\n * checkGroupOverlaps allows one real boundary inside another, but rejects\n * boundaries that partly cover each other and suggest false ownership.\n */\nfunction checkGroupOverlaps(groups: ResolvedGroup[], issues: GeometryIssue[]): void {\n\tforEachPair(groups, (first, second) => {\n\t\tif (\n\t\t\toverlaps(first.bounds, second.bounds) &&\n\t\t\t!contains(first.bounds, second.bounds) &&\n\t\t\t!contains(second.bounds, first.bounds)\n\t\t) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"group_overlap\",\n\t\t\t\t[first.id, second.id],\n\t\t\t\t`groups ${first.id} and ${second.id} partially overlap`,\n\t\t\t));\n\t\t}\n\t});\n}\n\n/**\n * checkOwnership requires each child to be inside the parent named by the\n * model. Visual overlap never creates ownership.\n */\nfunction checkOwnership(\n\tnodes: MeasuredNode[],\n\tgroups: MeasuredGroup[],\n\tresolvedNodes: Map,\n\tresolvedGroups: Map,\n\tissues: GeometryIssue[],\n): void {\n\tfor (const node of nodes) {\n\t\tconst child = resolvedNodes.get(node.id);\n\t\tif (child && child.parentId !== node.parentId) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[node.id],\n\t\t\t\t`node ${node.id} has the wrong parent ID`,\n\t\t\t));\n\t\t}\n\t\tif (!node.parentId) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst parent = resolvedGroups.get(node.parentId);\n\t\tif (child && parent && !contains(parent.bounds, child.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[node.id, node.parentId],\n\t\t\t\t`node ${node.id} lies outside owning group ${node.parentId}`,\n\t\t\t));\n\t\t}\n\t}\n\tfor (const group of groups) {\n\t\tconst child = resolvedGroups.get(group.id);\n\t\tif (child && child.parentId !== group.parentId) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[group.id],\n\t\t\t\t`group ${group.id} has the wrong parent ID`,\n\t\t\t));\n\t\t}\n\t\tif (!group.parentId) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst parent = resolvedGroups.get(group.parentId);\n\t\tif (child && parent && !contains(parent.bounds, child.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"false_containment\",\n\t\t\t\t[group.id, group.parentId],\n\t\t\t\t`group ${group.id} lies outside owning group ${group.parentId}`,\n\t\t\t));\n\t\t}\n\t}\n}\n\n/**\n * checkEdges checks connected node IDs, complete routes, crossings, labels,\n * and boundary crossings for every relationship.\n */\nfunction checkEdges(\n\tmeasured: MeasuredDiagram,\n\tresolved: ResolvedLayout,\n\tnodes: Map,\n\tgroups: Map,\n\tmeasuredNodes: Map,\n\tmeasuredGroups: Map,\n\tissues: GeometryIssue[],\n): void {\n\tconst measuredEdges = new Map(measured.edges.map(edge => [edge.id, edge]));\n\tconst labels: Array<{id: string; bounds: Rect}> = [];\n\tfor (const edge of resolved.edges) {\n\t\tconst expected = measuredEdges.get(edge.id);\n\t\tif (!expected) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\tedge.sourceId !== expected.sourceId ||\n\t\t\tedge.targetId !== expected.targetId\n\t\t) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"disconnected_edge\",\n\t\t\t\t[edge.id, edge.sourceId, edge.targetId],\n\t\t\t\t`edge ${edge.id} endpoints do not match its measured contract`,\n\t\t\t));\n\t\t}\n\t\tif (edge.sections.length === 0 || edge.sections.some(section => section.length < 2)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"disconnected_edge\",\n\t\t\t\t[edge.id],\n\t\t\t\t`edge ${edge.id} has no complete route section`,\n\t\t\t));\n\t\t\tcontinue;\n\t\t}\n\t\tcheckSectionConnections(edge, nodes, issues);\n\t\tfor (const section of edge.sections) {\n\t\t\tfor (const point of section) {\n\t\t\t\tif (!isFinitePoint(point) || !pointInRect(point, resolved.bounds, true)) {\n\t\t\t\t\tissues.push(issue(\n\t\t\t\t\t\t\"out_of_bounds\",\n\t\t\t\t\t\t[edge.id],\n\t\t\t\t\t\t`edge ${edge.id} has a route point outside the resolved view`,\n\t\t\t\t\t));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const node of nodes.values()) {\n\t\t\tif (node.id === edge.sourceId || node.id === edge.targetId) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (routeIntersectsRect(edge.sections, inset(node.bounds, 0.5))) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"edge_through_node\",\n\t\t\t\t\t[edge.id, node.id],\n\t\t\t\t\t`edge ${edge.id} crosses unrelated node ${node.id}`,\n\t\t\t\t));\n\t\t\t}\n\t\t}\n\t\tfor (const group of groups.values()) {\n\t\t\tconst sourceInside = belongsToGroup(\n\t\t\t\tedge.sourceId,\n\t\t\t\tgroup.id,\n\t\t\t\tmeasuredNodes,\n\t\t\t\tmeasuredGroups,\n\t\t\t);\n\t\t\tconst targetInside = belongsToGroup(\n\t\t\t\tedge.targetId,\n\t\t\t\tgroup.id,\n\t\t\t\tmeasuredNodes,\n\t\t\t\tmeasuredGroups,\n\t\t\t);\n\t\t\tif (\n\t\t\t\tsourceInside === targetInside &&\n\t\t\t\trouteViolatesGroup(edge.sections, group.bounds, sourceInside)\n\t\t\t) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"edge_through_group\",\n\t\t\t\t\t[edge.id, group.id],\n\t\t\t\t\t`edge ${edge.id} violates group ${group.id} boundary`,\n\t\t\t\t));\n\t\t\t}\n\t\t}\n\t\tif (edge.labelBounds) {\n\t\t\tcheckFiniteRect(\"edge label\", edge.id, edge.labelBounds, issues);\n\t\t\tcheckRectInBounds(\"edge label\", edge.id, edge.labelBounds, resolved.bounds, issues);\n\t\t\tif (expected.labelSize && (\n\t\t\t\t!nearlyEqual(expected.labelSize.width, edge.labelBounds.width) ||\n\t\t\t\t!nearlyEqual(expected.labelSize.height, edge.labelBounds.height)\n\t\t\t)) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"size_mismatch\",\n\t\t\t\t\t[edge.id],\n\t\t\t\t\t`edge ${edge.id} label size changed after measurement`,\n\t\t\t\t));\n\t\t\t}\n\t\t\tfor (const node of nodes.values()) {\n\t\t\t\tif (overlaps(edge.labelBounds, node.bounds)) {\n\t\t\t\t\tissues.push(issue(\n\t\t\t\t\t\t\"label_node_overlap\",\n\t\t\t\t\t\t[edge.id, node.id],\n\t\t\t\t\t\t`edge ${edge.id} label overlaps node ${node.id}`,\n\t\t\t\t\t));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const group of groups.values()) {\n\t\t\t\tif (overlaps(edge.labelBounds, group.titleBounds)) {\n\t\t\t\t\tissues.push(issue(\n\t\t\t\t\t\t\"label_title_overlap\",\n\t\t\t\t\t\t[edge.id, group.id],\n\t\t\t\t\t\t`edge ${edge.id} label overlaps group ${group.id} title`,\n\t\t\t\t\t));\n\t\t\t\t}\n\t\t\t}\n\t\t\tlabels.push({id: edge.id, bounds: edge.labelBounds});\n\t\t} else if (expected.labelSize) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"missing_element\",\n\t\t\t\t[edge.id],\n\t\t\t\t`edge ${edge.id} is missing its measured label`,\n\t\t\t));\n\t\t}\n\t}\n\tforEachPair(labels, (first, second) => {\n\t\tif (overlaps(first.bounds, second.bounds)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"label_label_overlap\",\n\t\t\t\t[first.id, second.id],\n\t\t\t\t`edge labels ${first.id} and ${second.id} overlap`,\n\t\t\t));\n\t\t}\n\t});\n\tfor (const label of labels) {\n\t\tfor (const edge of resolved.edges) {\n\t\t\tif (routeIntersectsRect(edge.sections, inset(label.bounds, 0.5))) {\n\t\t\t\tissues.push(issue(\n\t\t\t\t\t\"label_edge_overlap\",\n\t\t\t\t\t[label.id, edge.id],\n\t\t\t\t\t`edge ${edge.id} crosses label ${label.id}`,\n\t\t\t\t));\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * checkSectionConnections requires one ordered route from the source border to\n * the target border. Separate or reversed sections are not a complete route.\n */\nfunction checkSectionConnections(\n\tedge: ResolvedEdge,\n\tnodes: Map,\n\tissues: GeometryIssue[],\n): void {\n\tfor (let index = 1; index < edge.sections.length; index++) {\n\t\tconst previous = edge.sections[index - 1].slice(-1)[0];\n\t\tconst current = edge.sections[index][0];\n\t\tif (!samePoint(previous, current)) {\n\t\t\tissues.push(issue(\n\t\t\t\t\"disconnected_edge\",\n\t\t\t\t[edge.id],\n\t\t\t\t`edge ${edge.id} has disconnected route sections`,\n\t\t\t));\n\t\t\treturn;\n\t\t}\n\t}\n\tconst source = nodes.get(edge.sourceId);\n\tconst target = nodes.get(edge.targetId);\n\tconst start = edge.sections[0][0];\n\tconst end = edge.sections.slice(-1)[0].slice(-1)[0];\n\tif (\n\t\t!source ||\n\t\t!target ||\n\t\t!pointOnBorder(start, source.bounds) ||\n\t\t!pointOnBorder(end, target.bounds)\n\t) {\n\t\tissues.push(issue(\n\t\t\t\"disconnected_edge\",\n\t\t\t[edge.id, edge.sourceId, edge.targetId],\n\t\t\t`edge ${edge.id} does not connect both node borders`,\n\t\t));\n\t}\n}\n\n/** belongsToGroup follows parent IDs to decide whether a node belongs to a group. */\nfunction belongsToGroup(\n\tnodeId: string,\n\tgroupId: string,\n\tnodes: Map,\n\tgroups: Map,\n): boolean {\n\tlet parent = nodes.get(nodeId)?.parentId;\n\twhile (parent) {\n\t\tif (parent === groupId) {\n\t\t\treturn true;\n\t\t}\n\t\tparent = groups.get(parent)?.parentId;\n\t}\n\treturn false;\n}\n\n/**\n * routeViolatesGroup checks the middle of each line. When both connected nodes\n * are inside a group, the line must stay inside it. When both are outside, the\n * line must stay outside it.\n */\nfunction routeViolatesGroup(\n\tsections: Point[][],\n\tgroup: Rect,\n\tshouldBeInside: boolean,\n): boolean {\n\tfor (const section of sections) {\n\t\tfor (let index = 1; index < section.length; index++) {\n\t\t\tconst midpoint = {\n\t\t\t\tx: (section[index - 1].x + section[index].x) / 2,\n\t\t\t\ty: (section[index - 1].y + section[index].y) / 2,\n\t\t\t};\n\t\t\tif (pointInRect(midpoint, group, false) !== shouldBeInside) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\n/** routeIntersectsRect reports whether any part of a route enters a box. */\nfunction routeIntersectsRect(sections: Point[][], rect: Rect): boolean {\n\treturn sections.some(section => section.some((point, index) =>\n\t\tindex > 0 && segmentIntersectsRect(section[index - 1], point, rect),\n\t));\n}\n\n/**\n * segmentIntersectsRect checks both straight and diagonal lines. A line may\n * touch the box border, but it may not enter the box.\n */\nfunction segmentIntersectsRect(start: Point, end: Point, rect: Rect): boolean {\n\tconst dx = end.x - start.x;\n\tconst dy = end.y - start.y;\n\tlet minimum = 0;\n\tlet maximum = 1;\n\tfor (const [origin, delta, lower, upper] of [\n\t\t[start.x, dx, rect.x, rect.x + rect.width],\n\t\t[start.y, dy, rect.y, rect.y + rect.height],\n\t] as const) {\n\t\tif (Math.abs(delta) < Number.EPSILON) {\n\t\t\tif (origin <= lower || origin >= upper) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst first = (lower - origin) / delta;\n\t\tconst second = (upper - origin) / delta;\n\t\tminimum = Math.max(minimum, Math.min(first, second));\n\t\tmaximum = Math.min(maximum, Math.max(first, second));\n\t\tif (minimum >= maximum) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn maximum > 0 && minimum < 1;\n}\n\n/** overlaps treats touching borders as contact, not shared area. */\nfunction overlaps(first: Rect, second: Rect): boolean {\n\treturn (\n\t\tfirst.x < second.x + second.width &&\n\t\tsecond.x < first.x + first.width &&\n\t\tfirst.y < second.y + second.height &&\n\t\tsecond.y < first.y + first.height\n\t);\n}\n\n/** contains requires the whole inner box to be inside the outer box. */\nfunction contains(outer: Rect, inner: Rect): boolean {\n\treturn (\n\t\touter.x <= inner.x &&\n\t\touter.y <= inner.y &&\n\t\touter.x + outer.width >= inner.x + inner.width &&\n\t\touter.y + outer.height >= inner.y + inner.height\n\t);\n}\n\n/** pointInRect can include or exclude points that only touch the border. */\nfunction pointInRect(point: Point, rect: Rect, inclusive: boolean): boolean {\n\tif (inclusive) {\n\t\treturn (\n\t\t\tpoint.x >= rect.x &&\n\t\t\tpoint.y >= rect.y &&\n\t\t\tpoint.x <= rect.x + rect.width &&\n\t\t\tpoint.y <= rect.y + rect.height\n\t\t);\n\t}\n\treturn (\n\t\tpoint.x > rect.x &&\n\t\tpoint.y > rect.y &&\n\t\tpoint.x < rect.x + rect.width &&\n\t\tpoint.y < rect.y + rect.height\n\t);\n}\n\n/** inset makes a box smaller so touching its border does not count as crossing it. */\nfunction inset(rect: Rect, amount: number): Rect {\n\treturn {\n\t\tx: rect.x + amount,\n\t\ty: rect.y + amount,\n\t\twidth: Math.max(0, rect.width - amount * 2),\n\t\theight: Math.max(0, rect.height - amount * 2),\n\t};\n}\n\n/** isFinitePoint accepts only real numbers that SVG can draw. */\nfunction isFinitePoint(point: Point): boolean {\n\treturn Number.isFinite(point.x) && Number.isFinite(point.y);\n}\n\n/** isFiniteRect checks all four numbers in a box. */\nfunction isFiniteRect(rect: Rect): boolean {\n\treturn isFinitePoint(rect) && Number.isFinite(rect.width) && Number.isFinite(rect.height);\n}\n\n/** samePoint compares route points while allowing tiny browser number changes. */\nfunction samePoint(first: Point, second: Point): boolean {\n\treturn nearlyEqual(first.x, second.x) && nearlyEqual(first.y, second.y);\n}\n\n/** pointOnBorder checks that a route endpoint touches one side of a node box. */\nfunction pointOnBorder(point: Point, rect: Rect): boolean {\n\tconst withinX = point.x >= rect.x - 0.1 && point.x <= rect.x + rect.width + 0.1;\n\tconst withinY = point.y >= rect.y - 0.1 && point.y <= rect.y + rect.height + 0.1;\n\tconst onVertical = nearlyEqual(point.x, rect.x) ||\n\t\tnearlyEqual(point.x, rect.x + rect.width);\n\tconst onHorizontal = nearlyEqual(point.y, rect.y) ||\n\t\tnearlyEqual(point.y, rect.y + rect.height);\n\treturn (withinY && onVertical) || (withinX && onHorizontal);\n}\n\n/** nearlyEqual hides only browser rounding smaller than one tenth of a unit. */\nfunction nearlyEqual(first: number, second: number): boolean {\n\treturn Math.abs(first - second) <= 0.1;\n}\n\n/** forEachPair compares each pair once. */\nfunction forEachPair(items: T[], visit: (first: T, second: T) => void): void {\n\tfor (let first = 0; first < items.length; first++) {\n\t\tfor (let second = first + 1; second < items.length; second++) {\n\t\t\tvisit(items[first], items[second]);\n\t\t}\n\t}\n}\n\n/** issue creates one layout problem report. */\nfunction issue(\n\tcode: GeometryIssueCode,\n\telementIds: string[],\n\tmessage: string,\n): GeometryIssue {\n\treturn {code, elementIds, message};\n}\n","import {svgTextWrap} from \"./svg-text\";\nimport {SVG_STYLES} from \"./constants\";\n\nexport const create = {\n\telement(type: string, attrs: Record = {}, className?: string) {\n\t\tconst el = document.createElementNS('http://www.w3.org/2000/svg', type);\n\t\tObject.entries(attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n\t\tif (className) el.classList.add(className);\n\t\treturn el;\n\t},\n\n\tuse(id: string, attrs: Record = {}) {\n\t\tconst el = this.element('use', attrs);\n\t\tel.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#' + id);\n\t\treturn el;\n\t},\n\n\tpath(path: string, attrs: Record = {}, className?: string) {\n\t\tconst p = this.element(\"path\", {...attrs, d: path}, className);\n\t\treturn p;\n\t},\n\n\ttext(text: string, attrs: Record = {}) {\n\t\tconst t = this.element('text', attrs) as SVGTextElement;\n\t\tif (text) t.textContent = text;\n\t\treturn t;\n\t},\n\n\ttextArea(text: string, width: number, fontSize: number, bold: boolean, x = 0, y = 0, anchor = '') {\n\t\tconst attrs: Record = {\n\t\t\t'font-family': SVG_STYLES.edgeText['font-family'],\n\t\t\t'font-size': `${fontSize}px`,\n\t\t\t'font-weight': bold ? 'bold' : 'normal'\n\t\t};\n\t\tconst {lines, maxW} = svgTextWrap(text, width, attrs);\n\t\tconst txt = this.text('', {x: 0, y, 'text-anchor': anchor || undefined});\n\t\t\n\t\tlines.forEach((line, i) => {\n\t\t\tconst span = this.element('tspan', {x, dy: `${fontSize + 2}px`, ...attrs});\n\t\t\tspan.textContent = line;\n\t\t\ttxt.append(span);\n\t\t});\n\t\t\n\t\treturn {txt, dy: (lines.length + 1) * (fontSize + 2), maxW};\n\t},\n\n\trect(width: number, height: number, x = 0, y = 0, r = 0, className?: string) {\n\t\treturn this.element('rect', {x, y, rx: r, ry: r, width, height}, className) as SVGRectElement;\n\t},\n\n\ticon(icon: string, x = 0, y = 0) {\n\t\treturn this.use(icon, {x, y});\n\t},\n\n\texpand(x: number, y: number, expanded: boolean) {\n\t\tconst g = this.element('g', {transform: `translate(${x},${y})`}, 'expand') as SVGGElement;\n\t\tg.append(\n\t\t\tthis.rect(19, 19, 0, 0, 1),\n\t\t\tthis.text(expanded ? '-' : '+', {x: 10, y: 14, 'text-anchor': 'middle'})\n\t\t);\n\t\treturn g;\n\t}\n};\n\nexport function setPosition(g: SVGGElement, x: number, y: number) {\n\tg.setAttribute('transform', `translate(${x},${y})`);\n}\n","interface Point {\n\tx: number;\n\ty: number;\n}\n\ninterface BBox extends Point {\n\twidth: number;\n\theight: number;\n}\n\n\nexport function insideBox(p: Point, b: BBox, centeredBox = true): boolean {\n\treturn centeredBox ?\n\t\t(p.x > b.x - b.width / 2 && p.x < b.x + b.width / 2 && p.y > b.y - b.height / 2 && p.y < b.y + b.height / 2) :\n\t\t(p.x > b.x && p.x < b.x + b.width && p.y > b.y && p.y < b.y + b.height)\n}\n\nexport function boxesOverlap(b1: BBox, b2: BBox): boolean {\n\treturn b1.x < b2.x + b2.width && b1.y < b2.y + b2.height && b1.x + b1.width > b2.x && b1.y + b1.height > b2.y\n}\n\nexport function uncenterBox(b: BBox): BBox {\n\treturn {x: b.x - b.width / 2, y: b.y - b.height / 2, width: b.width, height: b.height}\n}\n\nexport function scaleBox(b: BBox, sc: number): BBox {\n\treturn {x: b.x * sc, y: b.y * sc, width: b.width * sc, height: b.height * sc}\n}\n\n// intersect 2 segments (p1->q1) with (p2, q2)\n// if the lines intersect, the result contains the x and y of the intersection (treating the lines as infinite)\n// and booleans for whether line segment 1 or line segment 2 contain the point\nfunction segmentIntersection(p1: Point, q1: Point, p2: Point, q2: Point) {\n\tlet denominator, a, b, numerator1, numerator2,\n\t\tresult: { x: number, y: number, onLine1: boolean, onLine2: boolean } = {\n\t\t\tx: null,\n\t\t\ty: null,\n\t\t\tonLine1: false,\n\t\t\tonLine2: false\n\t\t};\n\tdenominator = (q2.y - p2.y) * (q1.x - p1.x) - (q2.x - p2.x) * (q1.y - p1.y);\n\tif (denominator == 0) {\n\t\treturn result;\n\t}\n\ta = p1.y - p2.y;\n\tb = p1.x - p2.x;\n\tnumerator1 = ((q2.x - p2.x) * a) - ((q2.y - p2.y) * b);\n\tnumerator2 = ((q1.x - p1.x) * a) - ((q1.y - p1.y) * b);\n\ta = numerator1 / denominator;\n\tb = numerator2 / denominator;\n\n\t// if we cast these lines infinitely in both directions, they intersect here:\n\tresult.x = p1.x + (a * (q1.x - p1.x));\n\tresult.y = p1.y + (a * (q1.y - p1.y));\n\n\t// if line1 is a segment and line2 is infinite, they intersect if:\n\tif (a > 0 && a < 1) {\n\t\tresult.onLine1 = true;\n\t}\n\t// if line2 is a segment and line1 is infinite, they intersect if:\n\tif (b >= 0 && b <= 1) {\n\t\tresult.onLine2 = true;\n\t}\n\t// if line1 and line2 are segments, they intersect if both of the above are true\n\treturn result;\n}\n\n// intersects a segment (p1->p2) with a box\nexport function intersectRectFull(p1: Point, p2: Point, box: BBox): Point[] {\n\tconst w = box.width / 2\n\tconst h = box.height / 2\n\tconst segs: { p: Point; q: Point }[] = [\n\t\t{p: {x: box.x - w, y: box.y - h}, q: {x: box.x - w, y: box.y + h}},\n\t\t{p: {x: box.x - w, y: box.y - h}, q: {x: box.x + w, y: box.y - h}},\n\t\t{p: {x: box.x + w, y: box.y - h}, q: {x: box.x + w, y: box.y + h}},\n\t\t{p: {x: box.x - w, y: box.y + h}, q: {x: box.x + w, y: box.y + h}},\n\t]\n\treturn segs.map(s => segmentIntersection(p1, p2, s.p, s.q)).filter(ret => ret.onLine1 && ret.onLine2)\n}\n\n// intersects a line that goes from p to the center of the box\nexport function intersectRect(box: BBox, p: Point): Point {\n\tif (insideBox(p, box)) return {x: box.x, y: box.y}\n\treturn intersectRectFull(box, p, box)[0] || {x: box.x, y: box.y}\n}\n\nexport function intersectEllipse(ellCenter: Point, rx: number, ry: number, nodeCenter: Point, point: Point) {\n\n\t//translate all to center ellipse\n\tconst p1 = {x: point.x - ellCenter.x, y: point.y - ellCenter.y}\n\tconst p2 = {x: nodeCenter.x - ellCenter.x, y: nodeCenter.y - ellCenter.y}\n\n\tif (p2.x == p1.x) { //hack to avoid singularity\n\t\tp1.x += .0000001\n\t}\n\n\tconst s = (p2.y - p1.y) / (p2.x - p1.x);\n\tconst si = p2.y - (s * p2.x);\n\tconst a = (ry * ry) + (rx * rx * s * s);\n\tconst b = 2 * rx * rx * si * s;\n\tconst c = rx * rx * si * si - rx * rx * ry * ry;\n\n\tconst radicand_sqrt = Math.sqrt((b * b) - (4 * a * c));\n\tconst x = p1.x > p2.x ?\n\t\t(-b + radicand_sqrt) / (2 * a) :\n\t\t(-b - radicand_sqrt) / (2 * a)\n\tconst pos = {\n\t\tx: x,\n\t\ty: s * x + si\n\t}\n\t//translate back\n\tpos.x += ellCenter.x;\n\tpos.y += ellCenter.y\n\n\treturn pos;\n}\n\nexport interface Segment {\n\tp: Point;\n\tq: Point;\n}\n\n// given a polyline as a list of segments, interrupt it over the box so no line is inside the box\nexport function intersectPolylineBox(segments: Segment[], box: BBox) {\n\tfor (let i = 0; i < segments.length; i++) {\n\t\tconst s = segments[i]\n\t\tif (insideBox(s.p, box)) {\n\t\t\tif (insideBox(s.q, box)) { // segment both ends inside box\n\t\t\t\tsegments.splice(i, 1)\n\t\t\t\ti -= 1\n\t\t\t} else { // segment start inside box\n\t\t\t\ts.p = intersectRectFull(s.p, s.q, box)[0]\n\t\t\t}\n\t\t} else {\n\t\t\tif (insideBox(s.q, box)) { // segment end inside box\n\t\t\t\ts.q = intersectRectFull(s.p, s.q, box)[0]\n\t\t\t} else { // both ends outside\n\t\t\t\tconst ret = intersectRectFull(s.p, s.q, box)\n\t\t\t\tif (ret.length == 2) { // intersects the box, splice segment\n\t\t\t\t\t// order the intersection points, closest first\n\t\t\t\t\tconst dst1 = Math.abs(ret[0].x - s.p.x) + Math.abs(ret[0].y - s.p.y)\n\t\t\t\t\tconst dst2 = Math.abs(ret[1].x - s.p.x) + Math.abs(ret[1].y - s.p.y)\n\t\t\t\t\tif (dst1 > dst2) ret.reverse()\n\t\t\t\t\t// split the segment in 2\n\t\t\t\t\tconst s2 = {p: ret[1], q: s.q}\n\t\t\t\t\ts.q = ret[0]\n\t\t\t\t\tsegments.splice(i + 1, 0, s2)\n\t\t\t\t\ti += 1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function project(p: Point, a: Point, b: Point): Point {\n\tlet atob = {x: b.x - a.x, y: b.y - a.y};\n\tlet atop = {x: p.x - a.x, y: p.y - a.y};\n\tlet len = atob.x * atob.x + atob.y * atob.y;\n\tlet dot = atop.x * atob.x + atop.y * atob.y;\n\tlet t = Math.min(1, Math.max(0, dot / len));\n\treturn {\n\t\tx: a.x + atob.x * t,\n\t\ty: a.y + atob.y * t\n\t};\n}\n\nexport function cabDistance(p1: Point, p2: Point): number {\n\treturn Math.abs(p2.x - p1.x) + Math.abs(p2.y - p1.y)\n}","import {intersectEllipse, intersectRect} from \"./intersect\";\n\ninterface Point {\n\tx: number;\n\ty: number;\n}\n\ninterface BBox extends Point {\n\twidth: number;\n\theight: number;\n}\n\ninterface D3Node extends BBox {\n\tintersect: (p: Point) => Point\n}\n\nfunction cylinderRadiusY(width: number) {\n\treturn width / 2 / (5.5 + width / 70);\n}\n\nexport function shapeLabelOffsetY(shape: string, width: number, height: number) {\n\tswitch (shape.toLowerCase()) {\n\t\tcase \"cylinder\":\n\t\t\treturn 2 * cylinderRadiusY(width);\n\t\tcase \"person\":\n\t\t\treturn height * 0.4;\n\t\tcase \"folder\":\n\t\t\treturn width / 10;\n\t\tcase \"robot\":\n\t\t\treturn height * 0.35;\n\t\tcase \"webbrowser\":\n\t\t\treturn height / 8;\n\t\tdefault:\n\t\t\treturn 0;\n\t}\n}\n\nclass D3Element {\n\tprivate readonly _el: SVGElement\n\n\tconstructor(el: SVGElement) {\n\t\tthis._el = el;\n\t}\n\n\tnode() {\n\t\treturn this._el;\n\t}\n\n\tattr(name: string, value: string | number) {\n\t\tthis._el.setAttribute(name, String(value))\n\t\treturn this;\n\t}\n\n\tinsert(type: string, pos: string) {\n\t\tconst el = document.createElementNS('http://www.w3.org/2000/svg', type)\n\t\tconst el2 = this._el.insertBefore(el, this._el.querySelector(pos))\n\t\treturn new D3Element(el2)\n\t}\n}\n\n\nfunction rect(parent: D3Element, bbox: BBox, node: D3Node, rounded = false) {\n\tconst shapeSvg = parent.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", rounded ? node.width / 8 : 3)\n\t\t.attr(\"ry\", rounded ? node.width / 8 : 3)\n\t\t.attr(\"x\", -bbox.width / 2)\n\t\t.attr(\"y\", -bbox.height / 2)\n\t\t.attr(\"width\", bbox.width)\n\t\t.attr(\"height\", bbox.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect(node, point);\n\t};\n\n\treturn shapeSvg;\n}\n\n\nfunction cylinder(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = bbox.width;\n\tconst rx = w / 2;\n\tconst ry = cylinderRadiusY(w);\n\tconst h = bbox.height;\n\n\tconst shape =\n\t\t`M 0,${ry} a${rx},${ry} 0,0,0 ${w} 0 a ${rx},${ry} 0,0,0 ${-w} 0 l 0,${h - 2 * ry} a ${rx},${ry} 0,0,0 ${w} 0 l 0,${-h + 2 * ry}`;\n\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"cylinder\", w, h))\n\t\t.insert('path', ':first-child')\n\t\t.attr('d', shape)\n\t\t.attr('transform', 'translate(' + -w / 2 + ',' + -(h / 2) + ')');\n\n\tnode.intersect = function (point: Point) {\n\t\tconst pos = intersectRect(node, point)\n\t\tlet cy = node.y + node.height / 2 - ry\n\t\tif (pos.y > cy)\n\t\t\treturn intersectEllipse({x: node.x, y: cy}, rx, ry, node, point)\n\n\t\tcy = node.y - node.height / 2 + ry\n\t\tif (pos.y < cy)\n\t\t\treturn intersectEllipse({x: node.x, y: cy}, rx, ry, node, point)\n\n\t\treturn pos;\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction person(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = bbox.width;\n\tconst h = bbox.height;\n\n\tconst shape =\n\t\t`M ${.38 * w},${h / 3} A${w / 2},${h / 2} 0,0,0 0 ${h / 2}\n\t\tL${w / 11},${h} L${w - w / 11},${h} L${w},${h / 2}\n\t\tA${w / 2},${h / 2} 0,0,0 ${w - .38 * w} ${h / 3} \n\t\tA${w / 6},${w / 6} 0,1,0 ${.38 * w} ${h / 3}`;\n\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"person\", w, h))\n\t\t.insert('path', ':first-child')\n\t\t.attr('d', shape)\n\t\t.attr('transform', 'translate(' + -w / 2 + ',' + -(h / 2) + ')');\n\n\tnode.intersect = function (point: Point) {\n\t\tconst pos = intersectRect(node, point)\n\t\treturn pos;\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction _ellipse(parent: D3Element, bbox: BBox, node: D3Node, rx: number, ry: number) {\n\tconst shapeSvg = parent.insert(\"ellipse\", \":first-child\")\n\t\t.attr(\"cx\", 0)\n\t\t.attr(\"cy\", 0)\n\t\t.attr('rx', rx)\n\t\t.attr('ry', ry)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectEllipse(node, rx, ry, node, point)\n\t};\n\treturn shapeSvg;\n}\n\nfunction circle(parent: D3Element, bbox: BBox, node: D3Node) {\n\treturn _ellipse(parent, bbox, node, node.width / 2, node.width / 2)\n}\n\nfunction ellipse(parent: D3Element, bbox: BBox, node: D3Node) {\n\treturn _ellipse(parent, bbox, node, node.width * .55, node.width * .45)\n}\n\nfunction hexagon(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst sz = node.width / 2\n\t// drawing a hexagon from polar coords\n\t// [0,1,2,3,4,5,6].map(i=>`${Math.sin(Math.PI/3*i+Math.PI/6).toFixed(4)},${Math.cos(Math.PI/3*i+Math.PI/6).toFixed(4)}`).join(',')\n\tconst shapeSvg = parent.insert(\"polygon\", \":first-child\")\n\t\t.attr(\"points\",\n\t\t\t[0.5000, 0.8660, 1.0000, 0.0000, 0.5000, -0.8660, -0.5000, -0.8660, -1.0000, -0.0000, -0.5000, 0.8660, 0.5000, 0.8660].map(n => n * sz).join(','))\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectEllipse(node, node.width / 2, node.width / 2, node, point)\n\t};\n\treturn shapeSvg;\n}\n\nfunction component(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dx = node.width / 10\n\tconst shapeSvg = parent.insert('g', ':first-child')\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2 - dx)\n\t\t.attr(\"y\", -node.height / 2 + dx)\n\t\t.attr(\"width\", dx * 2)\n\t\t.attr(\"height\", dx);\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2 - dx)\n\t\t.attr(\"y\", -node.height / 2 + dx * 2.5)\n\t\t.attr(\"width\", dx * 2)\n\t\t.attr(\"height\", dx);\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2)\n\t\t.attr(\"y\", -node.height / 2)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x - dx / 2, y: node.y, width: node.width + dx, height: node.height}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction folder(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dy = node.width / 20\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"folder\", node.width, node.height))\n\t\t.insert('g', ':first-child')\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2)\n\t\t.attr(\"y\", -node.height / 2 + dy * 2)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height - dy * 2);\n\tshapeSvg.insert(\"path\", \":first-child\")\n\t\t.attr('d', `M0,${-node.height / 2 + 2 * dy} l${dy},${-2 * dy} h${node.width / 2 - dy * 2} v${dy * 2}`)\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x, y: node.y + dy / 2, width: node.width, height: node.height + dy}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction mobiledevicelandscape(parent: D3Element, bbox: BBox, node: D3Node, rounded = false) {\n\tconst dx = node.width / 8\n\tconst r = node.width / 14\n\tconst shapeSvg = parent.insert('g', ':first-child')\n\tshapeSvg.insert('path', ':first-child')\n\t\t.attr('d', `M${-node.width / 2},${-node.height / 2} l0,${node.height} M${node.width / 2},${-node.height / 2} l0,${node.height}`)\n\tshapeSvg.insert('circle', ':first-child')\n\t\t.attr('cx', -node.width / 2 - dx / 2)\n\t\t.attr('cy', 0)\n\t\t.attr('r', r * .4)\n\tshapeSvg.insert('rect', ':first-child')\n\t\t.attr('x', node.width / 2 + dx / 2 - r * .2)\n\t\t.attr('y', -r)\n\t\t.attr('width', r * .4)\n\t\t.attr('height', r * 2)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", r)\n\t\t.attr(\"ry\", r)\n\t\t.attr(\"x\", -bbox.width / 2 - dx)\n\t\t.attr(\"y\", -bbox.height / 2)\n\t\t.attr(\"width\", bbox.width + 2 * dx)\n\t\t.attr(\"height\", bbox.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x, y: node.y, width: node.width + 2 * dx, height: node.height}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction mobiledeviceportrait(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dy = node.width / 8\n\tconst r = node.width / 14\n\tconst shapeSvg = parent.insert('g', ':first-child')\n\tshapeSvg.insert('path', ':first-child')\n\t\t.attr('d', `M${-node.width / 2},${-node.height / 2} l${node.width},0 M${-node.width / 2},${node.height / 2} l${node.width},0`)\n\tshapeSvg.insert('circle', ':first-child')\n\t\t.attr('cx', 0)\n\t\t.attr('cy', node.height / 2 + dy / 2)\n\t\t.attr('r', r * .4)\n\tshapeSvg.insert('rect', ':first-child')\n\t\t.attr('x', -r)\n\t\t.attr('y', -node.height / 2 - dy / 2 - r * .2)\n\t\t.attr('width', r * 2)\n\t\t.attr('height', r * .4)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", r)\n\t\t.attr(\"ry\", r)\n\t\t.attr(\"x\", -bbox.width / 2)\n\t\t.attr(\"y\", -bbox.height / 2 - dy)\n\t\t.attr(\"width\", bbox.width)\n\t\t.attr(\"height\", bbox.height + 2 * dy);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect({x: node.x, y: node.y, width: node.width, height: node.height + 2 * dy}, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction pipe(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = node.width;\n\tconst h = node.height;\n\tconst ry = h / 2;\n\tconst rx = ry / (2.5 + w / 70);\n\n\tconst shape =\n\t\t`M${-rx},0\n\t\ta${rx},${ry} 0,0,1 0,${h}\n\t\ta${rx},${ry} 0,0,1 0,${-h}\n\t\tl${w},0\n\t\ta${rx},${ry} 0,0,1 0,${h}\n\t\tl${-w},0`;\n\n\tconst shapeSvg = parent\n\t\t.insert('path', ':first-child')\n\t\t.attr('d', shape)\n\t\t.attr('transform', 'translate(' + -w / 2 + ',' + -(h / 2) + ')');\n\n\tnode.intersect = function (point: Point) {\n\t\treturn intersectRect({x: node.x - rx, y: node.y, width: node.width + 2 * rx, height: node.height}, point)\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction robot(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst w = node.width\n\tconst h = node.height\n\t\n\t// Small head at top (like person shape but robot-styled)\n\tconst headSize = Math.min(w * 0.28, h * 0.25)\n\tconst headR = headSize * 0.2\n\tconst antennaH = headSize * 0.25\n\tconst antennaR = headSize * 0.08\n\t\n\t// Eye dimensions\n\tconst eyeR = headSize * 0.12\n\tconst eyeSpacing = headSize * 0.22\n\t\n\t// Ear dimensions \n\tconst earW = headSize * 0.12\n\tconst earH = headSize * 0.3\n\t\n\t// Body fills most of the space for text\n\tconst bodyW = w\n\tconst bodyTop = -h / 2 + antennaH + headSize\n\tconst bodyH = h - antennaH - headSize\n\tconst bodyR = 3\n\t\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"robot\", w, h))\n\t\t.insert('g', ':first-child')\n\t\n\t// Body - main rectangle for text (draw first so it's behind)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", bodyR)\n\t\t.attr(\"ry\", bodyR)\n\t\t.attr('x', -bodyW / 2)\n\t\t.attr('y', bodyTop)\n\t\t.attr('width', bodyW)\n\t\t.attr('height', bodyH)\n\t\n\t// Head\n\tconst headTop = -h / 2 + antennaH\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", headR)\n\t\t.attr(\"ry\", headR)\n\t\t.attr('x', -headSize / 2)\n\t\t.attr('y', headTop)\n\t\t.attr('width', headSize)\n\t\t.attr('height', headSize)\n\t\n\t// Antenna\n\tshapeSvg.insert(\"line\", \":first-child\")\n\t\t.attr('class', 'robot-antenna')\n\t\t.attr('x1', 0)\n\t\t.attr('y1', headTop)\n\t\t.attr('x2', 0)\n\t\t.attr('y2', -h / 2 + antennaR * 2)\n\t\t.attr('stroke-width', antennaR * 0.6)\n\t\t.attr('stroke-linecap', 'round')\n\t\n\t// Antenna ball\n\tshapeSvg.insert(\"circle\", \":first-child\")\n\t\t.attr('class', 'robot-antenna-ball')\n\t\t.attr('cx', 0)\n\t\t.attr('cy', -h / 2 + antennaR * 2)\n\t\t.attr('r', antennaR * 1.2)\n\t\n\t// Eyes\n\tconst eyeY = headTop + headSize * 0.4\n\tshapeSvg.insert(\"circle\", \":first-child\")\n\t\t.attr('class', 'robot-eye')\n\t\t.attr('cx', -eyeSpacing)\n\t\t.attr('cy', eyeY)\n\t\t.attr('r', eyeR)\n\tshapeSvg.insert(\"circle\", \":first-child\")\n\t\t.attr('class', 'robot-eye')\n\t\t.attr('cx', eyeSpacing)\n\t\t.attr('cy', eyeY)\n\t\t.attr('r', eyeR)\n\t\n\t// Mouth - simple smile\n\tconst mouthY = headTop + headSize * 0.7\n\tconst mouthW = headSize * 0.28\n\tshapeSvg.insert(\"path\", \":first-child\")\n\t\t.attr('class', 'robot-mouth')\n\t\t.attr('d', `M${-mouthW / 2},${mouthY} Q0,${mouthY + mouthW * 0.3} ${mouthW / 2},${mouthY}`)\n\t\t.attr('fill', 'none')\n\t\t.attr('stroke-width', antennaR * 0.5)\n\t\t.attr('stroke-linecap', 'round')\n\t\n\t// Ears\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", earW * 0.25)\n\t\t.attr(\"ry\", earW * 0.25)\n\t\t.attr('x', -headSize / 2 - earW - 1)\n\t\t.attr('y', eyeY - earH / 2)\n\t\t.attr('width', earW)\n\t\t.attr('height', earH)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", earW * 0.25)\n\t\t.attr(\"ry\", earW * 0.25)\n\t\t.attr('x', headSize / 2 + 1)\n\t\t.attr('y', eyeY - earH / 2)\n\t\t.attr('width', earW)\n\t\t.attr('height', earH)\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect(node, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nfunction webbrowser(parent: D3Element, bbox: BBox, node: D3Node) {\n\tconst dy = node.height / 8\n\tconst shapeSvg = parent\n\t\t.attr('label-offset-y', shapeLabelOffsetY(\"webbrowser\", node.width, node.height))\n\t\t.insert('g', ':first-child')\n\tshapeSvg.insert(\"path\", \":first-child\")\n\t\t.attr('d', `\n\t\t\tM${-node.width / 2},${-node.height / 2 + dy} h${node.width}\n\t\t\tM${-node.width / 2 + dy / 4},${-node.height / 2 + dy / 4} h${dy / 2} v${dy / 2} h${-dy / 2} z\n\t\t\tM${-node.width / 2 + dy},${-node.height / 2 + dy / 4} h${node.width - dy - dy / 4} v${dy / 2} h${-node.width + dy + dy / 4} z\n\t\t`)\n\tshapeSvg.insert(\"rect\", \":first-child\")\n\t\t.attr(\"rx\", 3).attr(\"ry\", 3)\n\t\t.attr(\"x\", -node.width / 2)\n\t\t.attr(\"y\", -node.height / 2)\n\t\t.attr(\"width\", node.width)\n\t\t.attr(\"height\", node.height);\n\n\tnode.intersect = function (point) {\n\t\treturn intersectRect(node, point);\n\t};\n\n\treturn shapeSvg;\n}\n\nexport const shapes: { [key: string]: (parent: SVGElement, node: D3Node) => SVGElement } = {\n\tbox: (parent: SVGElement, node: D3Node) => rect(new D3Element(parent), node, node).node(),\n\troundedbox: (parent: SVGElement, node: D3Node) => rect(new D3Element(parent), node, node, true).node(),\n\tcomponent: (parent: SVGElement, node: D3Node) => component(new D3Element(parent), node, node).node(),\n\tcylinder: (parent: SVGElement, node: D3Node) => cylinder(new D3Element(parent), node, node).node(),\n\tperson: (parent: SVGElement, node: D3Node) => person(new D3Element(parent), node, node).node(),\n\tcircle: (parent: SVGElement, node: D3Node) => circle(new D3Element(parent), node, node).node(),\n\tellipse: (parent: SVGElement, node: D3Node) => ellipse(new D3Element(parent), node, node).node(),\n\thexagon: (parent: SVGElement, node: D3Node) => hexagon(new D3Element(parent), node, node).node(),\n\tfolder: (parent: SVGElement, node: D3Node) => folder(new D3Element(parent), node, node).node(),\n\tmobiledevicelandscape: (parent: SVGElement, node: D3Node) => mobiledevicelandscape(new D3Element(parent), node, node).node(),\n\tmobiledeviceportrait: (parent: SVGElement, node: D3Node) => mobiledeviceportrait(new D3Element(parent), node, node).node(),\n\tmobiledevice: (parent: SVGElement, node: D3Node) => mobiledeviceportrait(new D3Element(parent), node, node).node(),\n\tpipe: (parent: SVGElement, node: D3Node) => pipe(new D3Element(parent), node, node).node(),\n\trobot: (parent: SVGElement, node: D3Node) => robot(new D3Element(parent), node, node).node(),\n\twebbrowser: (parent: SVGElement, node: D3Node) => webbrowser(new D3Element(parent), node, node).node(),\n}\n","/**\n * Undo functionality\n * at every change in the document, Undo can save a new version\n * so the user can \"undo\" and \"redo\" changes by reverting to an\n * older version of the document\n */\n\nexport class Undo {\n\tprivate readonly versions: Doc[] = [];\n\tprivate pos: number = 0;\n\tprivate lastSavedPos: number = 0;\n\tprivate readonly exportDoc: () => Doc;\n\tprivate readonly importDoc: (d: Doc) => void;\n\tchange: () => void;\n\tprivate tmpPreviousState: Doc | null = null;\n\n\tconstructor(id: string, exportDoc: () => Doc, importDoc: (d: Doc) => void) {\n\t\tthis.exportDoc = exportDoc;\n\t\tthis.importDoc = importDoc;\n\t\tthis.change = debounce(() => this.saveNow(), 300);\n\t}\n\n\t// Store the state previous to the changes collected in the debounce period\n\tbeforeChange() {\n\t\tif (!this.tmpPreviousState) {\n\t\t\tthis.tmpPreviousState = this.deepClone(this.exportDoc());\n\t\t}\n\t}\n\n\tlength() {\n\t\treturn this.versions.length;\n\t}\n\n\tcurrentState() {\n\t\treturn this.deepClone(this.versions[this.pos - 1]);\n\t}\n\n\tprivate saveNow() {\n\t\tif (!this.tmpPreviousState) {\n\t\t\tthrow Error(\"undo.change() was called without previously calling undo.beforeChange()!\");\n\t\t}\n\t\t\n\t\tthis.versions[this.pos] = this.deepClone(this.exportDoc());\n\t\tthis.versions[this.pos - 1] = this.tmpPreviousState;\n\t\tthis.tmpPreviousState = null;\n\t\tthis.pos += 1;\n\t\t\n\t\t// Remove anything that might be on top of this version\n\t\tthis.versions.splice(this.pos);\n\t}\n\n\tprivate deepClone(doc: Doc): Doc {\n\t\t// Use modern structuredClone if available, fallback to JSON\n\t\tif (typeof structuredClone !== 'undefined') {\n\t\t\treturn structuredClone(doc);\n\t\t}\n\t\treturn JSON.parse(JSON.stringify(doc));\n\t}\n\n\tundo() {\n\t\tif (this.pos < 2) return;\n\t\tthis.pos -= 1;\n\t\tconst doc = this.versions[this.pos - 1];\n\t\tthis.importDoc(this.deepClone(doc));\n\t}\n\n\tredo() {\n\t\tif (this.pos > this.versions.length - 1) return;\n\t\tconst doc = this.versions[this.pos];\n\t\tthis.importDoc(this.deepClone(doc));\n\t\tthis.pos += 1;\n\t}\n\n\tchanged() {\n\t\treturn this.pos !== this.lastSavedPos;\n\t}\n\n\tsetSaved() {\n\t\tthis.lastSavedPos = this.pos;\n\t}\n}\n\nfunction debounce(func: () => void, wait: number) {\n\tlet timeout: ReturnType;\n\treturn function () {\n\t\tconst context = this;\n\t\tconst later = function () {\n\t\t\ttimeout = null;\n\t\t\tfunc.apply(context);\n\t\t};\n\t\tclearTimeout(timeout);\n\t\ttimeout = setTimeout(later, wait);\n\t};\n}","import {applyStyle, NodeStyle, SVG_STYLES} from \"./constants\";\nimport {create} from \"./svg-create\";\nimport {svgTextWrap} from \"./svg-text\";\n\ninterface TextBlockLayout {\n\tlines: string[];\n\tfontSize: number;\n\tlineHeight: number;\n\tbold: boolean;\n\tfield?: string;\n\tgapAfter: number;\n}\n\nexport interface NodeContentLayout {\n\tblocks: TextBlockLayout[];\n\ttextHeight: number;\n\tminimumHeight: number;\n\t// The icon shares the content stack so text never draws over it.\n\ticon?: string;\n}\n\nconst HORIZONTAL_PADDING = 18;\nconst VERTICAL_PADDING = 18;\nconst TITLE_GAP = 6;\nconst METADATA_GAP = 10;\nconst ICON_SIZE = 32;\nconst ICON_GAP = 12;\n\nfunction textBlock(\n\ttext: string,\n\twidth: number,\n\tfontSize: number,\n\tbold: boolean,\n\tgapAfter: number,\n\tfield?: string,\n): TextBlockLayout {\n\tconst attrs = {\n\t\t\"font-family\": String(SVG_STYLES.nodeText[\"font-family\"]),\n\t\t\"font-size\": `${fontSize}px`,\n\t\t\"font-weight\": bold ? \"bold\" : \"normal\",\n\t};\n\tconst wrapped = svgTextWrap(text, width, attrs);\n\tconst lines = wrapped.lines.length > 0 ? wrapped.lines : [\"\"];\n\n\treturn {\n\t\tlines,\n\t\tfontSize,\n\t\tlineHeight: fontSize + 2,\n\t\tbold,\n\t\tfield,\n\t\tgapAfter,\n\t};\n}\n\nexport function layoutNodeContent(\n\ttitle: string,\n\tsubtitle: string,\n\tdescription: string,\n\tnodeWidth: number,\n\tfontSize: number,\n\tstyle: NodeStyle,\n): NodeContentLayout {\n\tconst textWidth = Math.max(nodeWidth - HORIZONTAL_PADDING * 2, 80);\n\tconst blocks = [textBlock(title, textWidth, fontSize, true, TITLE_GAP, \"name\")];\n\tif (style.metadata !== false && subtitle) {\n\t\tblocks.push(textBlock(`[${subtitle}]`, textWidth, fontSize * 0.7, false, METADATA_GAP));\n\t}\n\tif (style.description !== false && description) {\n\t\tblocks.push(textBlock(description, textWidth, Math.min(fontSize * 0.8, 16), false, 0, \"description\"));\n\t}\n\tblocks[blocks.length - 1].gapAfter = 0;\n\tconst textHeight = blocks.reduce(\n\t\t(height, block) => height + block.lines.length * block.lineHeight + block.gapAfter,\n\t\t0,\n\t);\n\n\treturn {\n\t\tblocks,\n\t\ttextHeight,\n\t\tminimumHeight: textHeight + VERTICAL_PADDING * 2 + (style.icon ? ICON_SIZE + ICON_GAP : 0),\n\t\ticon: style.icon,\n\t};\n}\n\nexport function buildNodeContent(layout: NodeContentLayout, color?: string): SVGGElement {\n\tconst group = create.element(\"g\") as SVGGElement;\n\tconst iconHeight = layout.icon ? ICON_SIZE + ICON_GAP : 0;\n\tlet top = -(layout.textHeight + iconHeight) / 2;\n\tif (layout.icon) {\n\t\tgroup.append(create.element(\"image\", {\n\t\t\thref: layout.icon,\n\t\t\tx: -ICON_SIZE / 2,\n\t\t\ty: top,\n\t\t\twidth: ICON_SIZE,\n\t\t\theight: ICON_SIZE,\n\t\t\tpreserveAspectRatio: \"xMidYMid meet\",\n\t\t}, \"nodeIcon\"));\n\t\ttop += iconHeight;\n\t}\n\n\tlayout.blocks.forEach((block) => {\n\t\tconst text = create.text(\"\", {\"text-anchor\": \"middle\"});\n\t\tapplyStyle(text, SVG_STYLES.nodeText);\n\t\tif (color) {\n\t\t\ttext.setAttribute(\"fill\", color);\n\t\t}\n\t\tif (block.field) {\n\t\t\ttext.setAttribute(\"data-field\", block.field);\n\t\t}\n\n\t\tblock.lines.forEach((line, index) => {\n\t\t\tconst span = create.element(\"tspan\", {\n\t\t\t\tx: 0,\n\t\t\t\ty: top + block.fontSize + index * block.lineHeight,\n\t\t\t\t\"font-size\": `${block.fontSize}px`,\n\t\t\t\t\"font-weight\": block.bold ? \"bold\" : \"normal\",\n\t\t\t});\n\t\t\tspan.textContent = line;\n\t\t\ttext.append(span);\n\t\t});\n\n\t\tgroup.append(text);\n\t\ttop += block.lines.length * block.lineHeight + block.gapAfter;\n\t});\n\n\treturn group;\n}\n","import {defs} from \"./defs\";\nimport {create, setPosition} from \"./svg-create\";\nimport {cursorInteraction} from \"svg-editor-tools/lib/cursor-interaction\";\nimport {shapeLabelOffsetY, shapes} from \"./shapes\";\nimport {\n\tboxesOverlap,\n\tcabDistance,\n\tinsideBox,\n\tintersectPolylineBox,\n\tproject,\n\tscaleBox,\n\tSegment,\n\tuncenterBox\n} from \"./intersect\";\nimport {autoLayout, LayoutOptions, validateCurrentLayout} from \"./layout\";\nimport {Undo} from \"./undo\";\nimport {\n\tADD_LABEL_VERTEX,\n\tADD_VERTEX,\n\tDEL_VERTEX,\n\tDESELECT,\n\tfindShortcut,\n\tREDO,\n\tSELECT_ALL,\n\tUNDO,\n\tZOOM_100,\n\tZOOM_FIT,\n\tZOOM_IN,\n\tZOOM_OUT\n} from \"../shortcuts\";\nimport {\n\tPoint,\n\tBBox,\n\tNodeStyle,\n\tEdgeStyle,\n\tDEFAULT_EDGE_STYLE,\n\tDEFAULT_NODE_STYLE,\n\tSVG_STYLES,\n\tSVG_PADDING,\n\tDEFAULT_GRID_SIZE,\n\tapplyStyle\n} from \"./constants\";\nimport {\n\tcalculateEdgeVertices,\n\tcalculateLabelPlacement,\n\tcreateEdgePath,\n\tEdgeLabelPlacement\n} from \"./edge-utils\";\nimport {\n\tbuildNodeContent,\n\tlayoutNodeContent,\n\tNodeContentLayout\n} from \"./node-content\";\nimport {ValidatedLayout} from \"./geometry\";\n\n\n// Point and BBox interfaces are now imported from constants\n\nexport interface Group extends BBox {\n\tid: string;\n\tname: string;\n\tnodes: (Node | Group)[];\n\tref?: SVGGElement;\n\tstyle: NodeStyle;\n\tlayoutBounds?: BBox;\n\tlayoutTitleBounds?: BBox;\n}\n\nexport interface NodeLink {\n\thref: string;\n\texportHref: string;\n}\n\nexport type LayoutDirection = 'UP' | 'DOWN' | 'LEFT' | 'RIGHT';\n\nexport interface Node extends BBox {\n\tid: string;\n\ttitle: string;\n\tsub: string;\n\tdescription: string;\n\n\tref?: SVGGElement;\n\tselected?: boolean;\n\n\tintersect: (p: Point) => Point\n\n\tstyle: NodeStyle\n\tlink?: NodeLink\n\tcontentLayout: NodeContentLayout\n}\n\n// NodeStyle interface is now imported from constants\n\n// EdgeStyle interface is now imported from constants\n\n// Default styles are now imported from constants\nconst defaultEdgeStyle = DEFAULT_EDGE_STYLE;\nconst defaultNodeStyle = DEFAULT_NODE_STYLE;\n\n// Edge and EdgeVertex interfaces are now defined in edge-utils.ts\n// Using local interfaces for compatibility with existing code\nexport interface Edge {\n\tid: string;\n\tlabel: string;\n\tfrom: Node;\n\tto: Node;\n\tvertices?: EdgeVertex[];\n\tref?: SVGGElement;\n\tstyle: EdgeStyle;\n\tinitVertex: (p: Point) => EdgeVertex;\n\tuserDeletedVertices?: boolean; // Track if user explicitly deleted vertices\n\tlabelVertex?: EdgeVertex; // ELK-calculated label position (separate from routing vertices)\n\tlabelBounds?: BBox;\n\tlayoutSections?: Point[][];\n\tlayoutLabelBounds?: BBox;\n}\n\ninterface EdgeVertex extends Point {\n\tid: string\n\tselected?: boolean\n\tedge: Edge\n\tref?: SVGElement\n\tlabel?: boolean\n\tauto?: boolean\n}\n\ninterface SavedEdgePoint extends Point {\n\tlabel?: boolean;\n\tauto?: boolean;\n}\n\ninterface Layout {\n\t[k: string]: Point | SavedEdgePoint[] | boolean\n}\n\n/** graphCount numbers the graphs created in this page; each GraphData uses it once for its idPrefix. */\nlet graphCount = 0\n\nexport class GraphData {\n\tid: string;\n\tname: string;\n\tnodesMap: Map;\n\tedges: Edge[];\n\tedgeVertices: Map\n\tgroupsMap: Map;\n\tmetadata: any;\n\tlayoutDirection?: LayoutDirection;\n\tvalidatedLayout?: ValidatedLayout;\n\tcolorToVarMap: Map = new Map(); // For CSS custom properties theming\n\t/**\n\t * svg is the element this graph draws into. Each graph has its own element,\n\t * so several graphs on one page never change each other's drawing, zoom, or\n\t * export. It carries no document-wide id; exportSVG adds id \"graph\" to the copy.\n\t */\n\treadonly svg: SVGSVGElement;\n\t/**\n\t * idPrefix starts every id this graph writes into its live svg, for example\n\t * \"g2-arrow\" or \"g2-\" plus a model element id, so two graphs in one page never\n\t * share an id. exportSVG removes it, so saved files keep the plain ids.\n\t */\n\treadonly idPrefix: string;\n\t/** selectListener receives the selected node in the editor; buildGraph sets it. */\n\tselectListener: (n: Node) => void;\n\tprivate _undo: Undo;\n\tprivate _gridVisible: boolean = false;\n\tprivate _snapToGrid: boolean = true;\n\tprivate _gridSize: number = 25;\n\tprivate _skipAutoFit: boolean = false;\n\n\tconstructor(id?: string, name?: string) {\n\t\tthis.id = id;\n\t\tthis.name = name;\n\n\t\tthis.edges = [];\n\t\tthis.edgeVertices = new Map;\n\t\tthis.nodesMap = new Map;\n\t\tthis.groupsMap = new Map;\n\t\tthis.svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n\t\tthis.idPrefix = `g${++graphCount}-`;\n\n\t\tthis._undo = new Undo(\n\t\t\tthis.id,\n\t\t\t() => this.exportLayout(true),\n\t\t\t(lo) => this.importLayout(lo, true)\n\t\t)\n\t}\n\n\t// after the graph model is build using addNode, addEdge etc, initialize\n\tinit(layout?: Layout) {\n\t\tlayout && this.importLayout(layout)\n\t\tthis._undo = new Undo(\n\t\t\tthis.id,\n\t\t\t() => this.exportLayout(true),\n\t\t\t(lo) => this.importLayout(lo, true)\n\t\t)\n\t\tif (this._undo.length()) {\n\t\t\tthis.importLayout(this._undo.currentState())\n\t\t}\n\t\t\n\t\t// Save initial state so first action is undoable\n\t\tthis._undo.beforeChange()\n\t\tthis._undo.change()\n\t}\n\n\taddNode(id: string, label: string, sub: string, description: string, style: NodeStyle, link?: NodeLink) {\n\t\tif (this.nodesMap.has(id)) throw Error('duplicate node: ' + id)\n\t\tconst nodeStyle = {...defaultNodeStyle, ...style};\n\t\tconst shape = (nodeStyle.shape || 'Box').toLowerCase();\n\t\tconst minimumWidth = 280;\n\t\tconst minimumHeight = shape === 'person' ? 240 : 180;\n\t\tconst width = Math.max(minimumWidth, nodeStyle.width || 0);\n\t\tconst fontSize = nodeStyle.fontSize || 22;\n\t\tconst contentLayout = layoutNodeContent(label, sub, description, width, fontSize, nodeStyle);\n\t\tlet height = Math.max(minimumHeight, nodeStyle.height || 0, contentLayout.minimumHeight);\n\n\t\t// Some shapes shift labels down to reserve visual space for an icon,\n\t\t// header, or curved edge. Grow until the shifted content also fits.\n\t\tfor (let i = 0; i < 20; i++) {\n\t\t\tconst requiredHeight = contentLayout.minimumHeight +\n\t\t\t\tMath.abs(shapeLabelOffsetY(shape, width, height));\n\t\t\tif (requiredHeight <= height + 0.1) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\theight = requiredHeight;\n\t\t}\n\n\t\tconst n: Node = {\n\t\t\tid, title: label, sub, description, style: nodeStyle,\n\t\t\tx: 0, y: 0, width, height, intersect: null, link, contentLayout\n\t\t}\n\t\tthis.nodesMap.set(n.id, n)\n\t}\n\n\tnodes() {\n\t\treturn Array.from(this.nodesMap.values())\n\t}\n\n\taddEdge(id: string, fromNode: string, toNode: string, label: string, vertices: Point[], style: EdgeStyle) {\n\t\tvertices && vertices.forEach((p, i) => {\n\t\t\tconst v = p as EdgeVertex\n\t\t\tv.id = `v-${id}-${i}`\n\t\t\tthis.edgeVertices.set(v.id, v)\n\t\t})\n\t\t// Deterministic vertex IDs.\n\t\t//\n\t\t// `mdl svg` renders diagrams headlessly and saves the resulting SVG. If we\n\t\t// generate random vertex IDs, the SVG changes on every run even when the\n\t\t// underlying model and layout are unchanged. Use a stable hash instead.\n\t\tconst fnv1a36 = (input: string) => {\n\t\t\tlet h = 0x811c9dc5\n\t\t\tfor (let i = 0; i < input.length; i++) {\n\t\t\t\th ^= input.charCodeAt(i)\n\t\t\t\th = Math.imul(h, 0x01000193)\n\t\t\t}\n\t\t\treturn (h >>> 0).toString(36)\n\t\t}\n\t\tconst stableVertexID = (edgeID: string, p: Point) => {\n\t\t\tconst x = (p as any).x\n\t\t\tconst y = (p as any).y\n\t\t\treturn `v-${edgeID}-a-${fnv1a36(`${edgeID}:${x}:${y}`)}`\n\t\t}\n\t\tconst initVertex = (p: Point) => {\n\t\t\tconst v = p as EdgeVertex\n\t\t\tif (!v.id) {\n\t\t\t\tv.id = stableVertexID(edge.id, p)\n\t\t\t\tthis.edgeVertices.set(v.id, v)\n\t\t\t}\n\t\t\tv.edge = edge\n\t\t\treturn p as EdgeVertex\n\t\t}\n\t\tconst edge = {\n\t\t\tid,\n\t\t\tfrom: this.nodesMap.get(fromNode),\n\t\t\tto: this.nodesMap.get(toNode),\n\t\t\tlabel,\n\t\t\tvertices: null as EdgeVertex[],\n\t\t\tstyle: {...defaultEdgeStyle, ...style},\n\t\t\tinitVertex,\n\t\t\tuserDeletedVertices: false\n\t\t}\n\t\tthis.edges.push(edge)\n\t\tif (vertices) {\n\t\t\tedge.vertices = vertices.map(p => edge.initVertex(p))\n\t\t}\n\t}\n\n\taddGroup(id: string, name: string, nodesOrGroups: string[], style: NodeStyle) {\n\t\tif (this.groupsMap.has(id)) {\n\t\t\tconsole.error(`Group exists: ${id} ${name}`)\n\t\t\treturn\n\t\t}\n\t\tconst group: Group = {\n\t\t\tid, name, x: null, y: null, width: null, height: null,\n\t\t\tnodes: nodesOrGroups.map(k => {\n\t\t\t\tconst n = this.nodesMap.get(k) || this.groupsMap.get(k)\n\t\t\t\tif (!n) console.error(`Node or group ${k} not found for group ${id} \"${name}\"`)\n\t\t\t\treturn n\n\t\t\t}).filter(Boolean),\n\t\t\tstyle\n\t\t}\n\t\tthis.groupsMap.set(id, group)\n\t}\n\n\t// private rebuildNode(node: Node) {\n\t// \tconst p = node.ref.parentElement;\n\t// \tp.removeChild(node.ref)\n\t// \tnode.ref = buildNode(node, this)\n\t// \tp.appendChild(node.ref)\n\t// \tthis.redrawEdges(node)\n\t// \tthis.redrawGroups(node)\n\t// }\n\n\tsetNodeSelected(node: Node, selected: boolean) {\n\t\tnode.selected = selected\n\t\tselected ?\n\t\t\tnode.ref.classList.add('selected') :\n\t\t\tnode.ref.classList.remove('selected')\n\t\tthis.updateEdgesSel()\n\t}\n\n\tprivate updateEdgesSel() {\n\t\tthis.edges.forEach(e => {\n\t\t\tif (e.to.selected || e.from.selected) {\n\t\t\t\te.ref.classList.add('selected')\n\t\t\t} else {\n\t\t\t\te.ref.classList.remove('selected')\n\t\t\t}\n\t\t})\n\t}\n\n\t/** clearResolvedLayout returns drawing to manual mode after any user edit. */\n\tprivate clearResolvedLayout() {\n\t\tthis.validatedLayout = undefined\n\t\tthis.edges.forEach(edge => {\n\t\t\tedge.layoutSections = undefined\n\t\t\tedge.layoutLabelBounds = undefined\n\t\t})\n\t\tthis.groupsMap.forEach(group => {\n\t\t\tgroup.layoutBounds = undefined\n\t\t\tgroup.layoutTitleBounds = undefined\n\t\t})\n\t}\n\n\tmoveNode(n: Node, x: number, y: number, disableSnap: boolean = false, skipUndo: boolean = false) {\n\t\tif (!n) return\n\t\t\n\t\t// Apply snap-to-grid if enabled and not explicitly disabled\n\t\tif (this._snapToGrid && !disableSnap) {\n\t\t\tconst snapped = this.snapToGrid(x, y);\n\t\t\tx = snapped.x;\n\t\t\ty = snapped.y;\n\t\t}\n\t\t\n\t\tif (n.x == x && n.y == y) return\n\t\t\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.beforeChange()\n\t\t}\n\t\tthis.clearResolvedLayout()\n\t\tn.x = x;\n\t\tn.y = y;\n\t\tsetPosition(n.ref, x, y)\n\t\tthis.redrawEdges(n);\n\t\tthis.redrawGroups(n)\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.change()\n\t\t}\n\t}\n\n\tmoveEdgeVertex(v: EdgeVertex, x: number, y: number, disableSnap: boolean = false, skipUndo: boolean = false) {\n\t\t\n\t\tif (this._snapToGrid && !disableSnap) {\n\t\t\tconst snapped = this.snapToGrid(x, y);\n\t\t\tx = snapped.x;\n\t\t\ty = snapped.y;\n\t\t}\n\t\t// Use exact coordinates (no rounding needed with modern grid system)\n\t\t\n\t\tif (v.x == x && v.y == y) return\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.beforeChange()\n\t\t}\n\t\tthis.clearResolvedLayout()\n\t\tv.x = x;\n\t\tv.y = y;\n\t\tthis.redrawEdge(v.edge)\n\t\tif (!skipUndo) {\n\t\t\tthis._undo.change()\n\t\t}\n\t}\n\n\tmoveSelected(dx: number, dy: number, disableSnap: boolean = false) {\n\t\tthis.nodes().forEach(n => n.selected && this.moveNode(n, n.x + dx, n.y + dy, disableSnap, false))\n\t\tthis.edgeVertices.forEach(v => v.selected && this.moveEdgeVertex(v, v.x + dx, v.y + dy, disableSnap, false))\n\t}\n\n\tinsertEdgeVertex(edge: Edge, p: Point, pos: number, isLabel: boolean) {\n\t\tthis._undo.beforeChange()\n\t\tthis.clearResolvedLayout()\n\t\tconst v = edge.initVertex(p)\n\t\tv.selected = true\n\t\tif (isLabel) { // when shift down, make it label position\n\t\t\tedge.vertices.forEach(v => v.label = false)\n\t\t\tv.label = true\n\t\t}\n\t\tedge.vertices.splice(pos - 1, 0, v)\n\t\tthis.redrawEdge(edge)\n\t\tthis._undo.change()\n\t}\n\n\tdeleteEdgeVertex(v: EdgeVertex) {\n\t\tthis._undo.beforeChange()\n\t\tthis.clearResolvedLayout()\n\t\t\n\t\tconst index = v.edge.vertices.indexOf(v)\n\t\tif (index >= 0) {\n\t\t\tv.edge.vertices.splice(index, 1)\n\t\t\tthis.edgeVertices.delete(v.id)\n\t\t\t\n\t\t\t// Mark that user explicitly deleted vertices from this edge\n\t\t\tv.edge.userDeletedVertices = true\n\t\t}\n\t\t\n\t\tthis.redrawEdge(v.edge)\n\t\tthis._undo.change()\n\t}\n\n\tchanged() {\n\t\treturn this._undo.changed()\n\t}\n\n\tundo() {\n\t\tthis._undo.undo()\n\t}\n\n\tredo() {\n\t\tthis._undo.redo()\n\t}\n\n\t// moves the entire graph to be aligned top-left of the drawing area\n\t// used to bring back to visible the nodes that end up at negative coordinates\n\talignTopLeft() {\n\t\tconst contentBounds = this.calculateContentBounds()\n\t\tconst padding = 100 // Reasonable padding for viewport\n\t\t\n\t\tconst offsetX = -contentBounds.x + padding\n\t\tconst offsetY = -contentBounds.y + padding\n\t\t\n\t\t// Set flag to prevent React useEffect from calling fitToView during this operation\n\t\tthis._skipAutoFit = true\n\t\t\n\t\tthis._undo.beforeChange()\n\t\t\n\t\tthis.nodesMap.forEach(node => {\n\t\t\tthis.moveNode(node, node.x + offsetX, node.y + offsetY, true, true) // Disable snap and undo during reset\n\t\t})\n\t\t\n\t\tthis.edgeVertices.forEach(vertex => {\n\t\t\tthis.moveEdgeVertex(vertex, vertex.x + offsetX, vertex.y + offsetY, true, true) // Disable snap and undo during reset\n\t\t})\n\t\t\n\t\tthis._undo.change()\n\t\t\n\t\t// DON'T clear view state here - let resetPanTransform handle it to avoid React useEffect recursion\n\t}\n\t\n\t// Reset pan transform to (0,0) while preserving zoom\n\tresetPanTransform() {\n\t\tconst currentZoom = getZoom(this)\n\t\tconst zoomGroup = this.svg.querySelector('g.zoom') as SVGGElement\n\t\tif (zoomGroup) {\n\t\t\tzoomGroup.setAttribute('transform', `scale(${currentZoom}) translate(0, 0)`)\n\t\t\tupdatePanningOptimized(this)\n\t\t}\n\t\t\n\t\t// Clear view state so this reset is not overridden\n\t\tclearViewState(this)\n\t\t\n\t\t// Reset the skip auto fit flag after reset is complete\n\t\tthis._skipAutoFit = false\n\t}\n\t\n\t// Check if auto-fit should be skipped (used by React useEffect)\n\tshouldSkipAutoFit(): boolean {\n\t\treturn this._skipAutoFit\n\t}\n\n\t// Reset view to default state: 100% zoom, centered at origin\n\tresetView() {\n\t\tconst zoomGroup = this.svg.querySelector('g.zoom') as SVGGElement\n\t\tif (zoomGroup) {\n\t\t\t// Reset to 100% zoom, centered at origin\n\t\t\tzoomGroup.setAttribute('transform', 'scale(1) translate(0, 0)')\n\t\t\tupdatePanning(this)\n\t\t}\n\t\t\n\t\t// Clear any saved view state so this reset position is not overridden\n\t\tclearViewState(this)\n\t}\n\n\t//redraw connected edges\n\tprivate redrawEdges(n: Node) {\n\t\tthis.edges.forEach(e => (n == e.from || n == e.to) && this.redrawEdge(e))\n\t\tthis.updateEdgesSel()\n\t}\n\n\tredrawEdge(e: Edge) {\n\t\tconst p = e.ref.parentElement;\n\t\tp.removeChild(e.ref)\n\t\te.ref = buildEdge(e, this)\n\t\tp.append(e.ref)\n\t}\n\n\tprivate redrawGroups(node: Node) {\n\t\tthis.groupsMap.forEach(group => {\n\t\t\t//if (group.nodes.indexOf(node) == -1) return\n\t\t\tconst p = group.ref.parentElement\n\t\t\tp.removeChild(group.ref)\n\t\t\tbuildGroup(group)\n\t\t\tp.append(group.ref)\n\t\t})\n\t}\n\n\texportSVG() {\n\t\tif (!this.validatedLayout) {\n\t\t\tthis.validatedLayout = validateCurrentLayout(this)\n\t\t}\n\t\t// Get the original SVG\n\t\tconst originalSvg = this.svg\n\t\tconst elastic = originalSvg.querySelector('rect.elastic')\n\t\t\n\t\t// Clone the SVG for export (completely separate from the live one)\n\t\tconst exportSvg = originalSvg.cloneNode(true) as SVGSVGElement\n\t\t// Standalone files keep the ids saved files have always used: the root id\n\t\t// \"graph\", written before the other root attributes as in earlier files,\n\t\t// and this graph's own ids without the live idPrefix.\n\t\tconst rootAttributes = Array.from(exportSvg.attributes)\n\t\trootAttributes.forEach(attr => exportSvg.removeAttributeNode(attr))\n\t\texportSvg.setAttribute('id', 'graph')\n\t\trootAttributes.forEach(attr => exportSvg.setAttributeNode(attr))\n\t\tthis.removeIdPrefix(exportSvg)\n\n\t\t// Standalone SVGs navigate to sibling view files instead of editor routes.\n\t\texportSvg.querySelectorAll('a.nodeLink[data-export-href]').forEach(link => {\n\t\t\tlink.setAttribute('href', link.getAttribute('data-export-href') || '')\n\t\t\tlink.removeAttribute('data-export-href')\n\t\t})\n\t\t\n\t\t// Remove elastic element from export\n\t\tconst exportElastic = exportSvg.querySelector('rect.elastic')\n\t\tif (exportElastic) {\n\t\t\texportElastic.remove()\n\t\t}\n\t\t\n\t\t// Export the exact bounds that passed geometry validation. Recomputing\n\t\t// them here can omit routed relationship labels from the SVG canvas.\n\t\tconst contentBounds = this.validatedLayout.bounds\n\t\t\n\t\t// Add padding around content\n\t\tconst padding = 50\n\t\t\n\t\t// Calculate final export dimensions (always positive)\n\t\tconst exportWidth = contentBounds.width + (padding * 2)\n\t\tconst exportHeight = contentBounds.height + (padding * 2)\n\t\t\n\t\t// Calculate offset to move content to start at (padding, padding) within the export area\n\t\tconst offsetX = -contentBounds.x + padding\n\t\tconst offsetY = -contentBounds.y + padding\n\t\t\n\t\t// Apply export positioning to the cloned SVG elements\n\t\tconst exportZoomGroup = exportSvg.querySelector('g.zoom') as SVGGElement\n\t\tif (exportZoomGroup) {\n\t\t\t// Reset zoom to 1 and apply offset transform to position content properly\n\t\t\texportZoomGroup.setAttribute('transform', `scale(1) translate(${offsetX}, ${offsetY})`)\n\t\t}\n\t\t\n\t\t// Set proper viewBox and dimensions for export - viewBox always starts at (0,0)\n\t\texportSvg.setAttribute('viewBox', `0 0 ${exportWidth} ${exportHeight}`)\n\t\texportSvg.setAttribute('width', String(exportWidth))\n\t\texportSvg.setAttribute('height', String(exportHeight))\n\t\t\n\t\t// Add required SVG namespace for browser compatibility\n\t\texportSvg.setAttribute('xmlns', 'http://www.w3.org/2000/svg')\n\t\t\n\t\t// Convert inline styles to CSS custom properties for theming support\n\t\tthis.convertStylesToCustomProperties(exportSvg)\n\t\t\n\t\t// Inject metadata with current layout\n\t\tconst script = document.createElement('script')\n\t\tscript.setAttribute('type', 'application/json')\n\t\tthis.metadata.layout = this.exportLayout()\n\t\tscript.append('')\n\t\texportSvg.insertBefore(script, exportSvg.firstChild)\n\t\t\n\t\t// Get the export SVG as string\n\t\tconst src = exportSvg.outerHTML\n\t\t\n\t\t// No restoration needed since we never touched the original SVG!\n\t\treturn src\n\t}\n\n\t/**\n\t * removeIdPrefix rewrites the export copy's ids and url(#…) references that\n\t * name this graph's own elements back to their saved names, for example\n\t * \"g2-arrow\" to \"arrow\" and \"url(#g2-arrow)\" to \"url(#arrow)\". The renderer\n\t * writes no #… links, so href values (image URLs) are never rewritten, and\n\t * user-authored node links (a.nodeLink) are left exactly as written.\n\t */\n\tprivate removeIdPrefix(svg: SVGSVGElement) {\n\t\tconst prefix = this.idPrefix\n\t\tconst reference = `url(#${prefix}`\n\t\tsvg.querySelectorAll('*').forEach(el => {\n\t\t\tif (el.matches('a.nodeLink')) return\n\t\t\tfor (const attr of Array.from(el.attributes)) {\n\t\t\t\tif (attr.name === 'id' && attr.value.startsWith(prefix)) {\n\t\t\t\t\tattr.value = attr.value.slice(prefix.length)\n\t\t\t\t} else if (attr.localName !== 'href' && attr.value.startsWith(reference)) {\n\t\t\t\t\tattr.value = 'url(#' + attr.value.slice(reference.length)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\t// Convert inline fill/stroke attributes to CSS custom properties with fallbacks.\n\t// This enables theming: container pages can override colors via CSS variables.\n\tprivate convertStylesToCustomProperties(svg: SVGSVGElement) {\n\t\tif (this.colorToVarMap.size === 0) return\n\n\t\t// Process all elements with fill attribute\n\t\tsvg.querySelectorAll('[fill]').forEach(el => {\n\t\t\tconst fill = el.getAttribute('fill')\n\t\t\tif (fill && this.colorToVarMap.has(fill)) {\n\t\t\t\tel.setAttribute('fill', `var(${this.colorToVarMap.get(fill)}, ${fill})`)\n\t\t\t}\n\t\t})\n\n\t\t// Process all elements with stroke attribute\n\t\tsvg.querySelectorAll('[stroke]').forEach(el => {\n\t\t\tconst stroke = el.getAttribute('stroke')\n\t\t\tif (stroke && this.colorToVarMap.has(stroke)) {\n\t\t\t\tel.setAttribute('stroke', `var(${this.colorToVarMap.get(stroke)}, ${stroke})`)\n\t\t\t}\n\t\t})\n\t}\n\n\t// Calculate the actual bounds of all content including nodes, edges, and groups\n\tcalculateContentBounds(): BBox {\n\t\tlet minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity\n\t\t\n\t\t// Process nodes (including their actual dimensions)\n\t\tthis.nodes().forEach(node => {\n\t\t\tconst left = node.x - node.width / 2\n\t\t\tconst right = node.x + node.width / 2\n\t\t\tconst top = node.y - node.height / 2\n\t\t\tconst bottom = node.y + node.height / 2\n\t\t\t\n\t\t\tminX = Math.min(minX, left)\n\t\t\tmaxX = Math.max(maxX, right)\n\t\t\tminY = Math.min(minY, top)\n\t\t\tmaxY = Math.max(maxY, bottom)\n\t\t})\n\t\t\n\t\t// Process edge vertices (much faster than complex label calculations)\n\t\tthis.edgeVertices.forEach(vertex => {\n\t\t\tminX = Math.min(minX, vertex.x - 5)\n\t\t\tmaxX = Math.max(maxX, vertex.x + 5)\n\t\t\tminY = Math.min(minY, vertex.y - 5)\n\t\t\tmaxY = Math.max(maxY, vertex.y + 5)\n\t\t})\n\t\t\n\t\t// Process groups\n\t\tthis.groupsMap.forEach(group => {\n\t\t\tconst left = group.x - group.width / 2\n\t\t\tconst right = group.x + group.width / 2\n\t\t\tconst top = group.y - group.height / 2\n\t\t\tconst bottom = group.y + group.height / 2\n\t\t\t\n\t\t\tminX = Math.min(minX, left)\n\t\t\tmaxX = Math.max(maxX, right)\n\t\t\tminY = Math.min(minY, top)\n\t\t\tmaxY = Math.max(maxY, bottom)\n\t\t})\n\t\t\n\t\t// Process edges (simplified - just endpoints and vertices, skip complex label calculations)\n\t\tthis.edges.forEach(edge => {\n\t\t\t// Edge endpoints\n\t\t\tminX = Math.min(minX, edge.from.x - 10, edge.to.x - 10)\n\t\t\tmaxX = Math.max(maxX, edge.from.x + 10, edge.to.x + 10)\n\t\t\tminY = Math.min(minY, edge.from.y - 10, edge.to.y - 10)\n\t\t\tmaxY = Math.max(maxY, edge.from.y + 10, edge.to.y + 10)\n\t\t\t\n\t\t\t// Edge vertices (if any)\n\t\t\tif (edge.vertices) {\n\t\t\t\tedge.vertices.forEach(vertex => {\n\t\t\t\t\tminX = Math.min(minX, vertex.x - 10)\n\t\t\t\t\tmaxX = Math.max(maxX, vertex.x + 10)\n\t\t\t\t\tminY = Math.min(minY, vertex.y - 10)\n\t\t\t\t\tmaxY = Math.max(maxY, vertex.y + 10)\n\t\t\t\t})\n\t\t\t}\n\t\t\t\n\t\t\t// Simplified label bounds (avoid expensive path calculations)\n\t\t\tif (edge.label && edge.label.trim()) {\n\t\t\t\t// Just use approximate center between from and to nodes\n\t\t\t\tconst centerX = (edge.from.x + edge.to.x) / 2\n\t\t\t\tconst centerY = (edge.from.y + edge.to.y) / 2\n\t\t\t\tconst approxLabelSize = edge.label.length * 10 + 50 // Rough estimate\n\t\t\t\t\n\t\t\t\tminX = Math.min(minX, centerX - approxLabelSize)\n\t\t\t\tmaxX = Math.max(maxX, centerX + approxLabelSize)\n\t\t\t\tminY = Math.min(minY, centerY - 25)\n\t\t\t\tmaxY = Math.max(maxY, centerY + 25)\n\t\t\t}\n\t\t})\n\t\t\n\t\t// Handle empty graph\n\t\tif (minX === Infinity) {\n\t\t\treturn { x: 0, y: 0, width: 100, height: 100 }\n\t\t}\n\t\t\n\t\treturn {\n\t\t\tx: minX,\n\t\t\ty: minY,\n\t\t\twidth: maxX - minX,\n\t\t\theight: maxY - minY\n\t\t}\n\t}\n\n\n\n\t/**\n\t * @param full when true, the edges without vertices are saved too, used for undo buffer\n\t * for saving, full is false\n\t */\n\texportLayout(full = false) {\n\t\tconst ret: Layout = {}\n\t\tthis.nodes().forEach(n => ret[n.id] = {x: n.x, y: n.y})\n\t\tthis.edges.forEach(e => {\n\t\t\tif (!e.vertices) return\n\t\t\t// Save all vertices (both user and auto-generated), preserving their properties\n\t\t\tconst lst = e.vertices.map(v => ({\n\t\t\t\tx: v.x, \n\t\t\t\ty: v.y, \n\t\t\t\tlabel: v.label,\n\t\t\t\tauto: v.auto // Preserve auto flag so we know which are ELK-generated\n\t\t\t}));\n\t\t\tif (lst.length || full) {\n\t\t\t\tret[`e-${e.id}`] = lst\n\t\t\t}\n\t\t\t// Also save the userDeletedVertices flag as metadata\n\t\t\tif (e.userDeletedVertices) {\n\t\t\t\tret[`e-${e.id}-deleted`] = true\n\t\t\t}\n\t\t})\n\t\treturn ret\n\t}\n\n\tsetSaved() {\n\t\tthis._undo.setSaved()\n\t}\n\n\timportLayout(layout: Layout, rerender = false) {\n\t\tthis.clearResolvedLayout()\n\t\tfor (const [k, v] of Object.entries(layout)) {\n\t\t\tconst n = this.nodesMap.get(k)\n\t\t\tif (n) {\n\t\t\t\tconst point = requiredSavedPoint(k, v)\n\t\t\t\tn.x = point.x\n\t\t\t\tn.y = point.y\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (k.endsWith('-deleted')) {\n\t\t\t\tconst edgeId = k.slice(2, -8); // Remove 'e-' prefix and '-deleted' suffix\n\t\t\t\tconst edge = this.edges.find(candidate => candidate.id === edgeId)\n\t\t\t\tif (!edge || v !== true) {\n\t\t\t\t\tthrow new Error(`invalid deleted-edge layout entry ${k}`)\n\t\t\t\t}\n\t\t\t\tedge.userDeletedVertices = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (k.startsWith('e-')) {\n\t\t\t\tconst edge = this.edges.find(candidate => candidate.id === k.slice(2))\n\t\t\t\tif (!edge || !Array.isArray(v)) {\n\t\t\t\t\tthrow new Error(`invalid edge layout entry ${k}`)\n\t\t\t\t}\n\t\t\t\tfor (const vertex of edge.vertices ?? []) {\n\t\t\t\t\tthis.edgeVertices.delete(vertex.id)\n\t\t\t\t}\n\t\t\t\tedge.vertices = v.map((saved, index) => {\n\t\t\t\t\tconst point = requiredSavedPoint(`${k}[${index}]`, saved)\n\t\t\t\t\tconst vertex = edge.initVertex(point)\n\t\t\t\t\tvertex.label = saved.label\n\t\t\t\t\tvertex.auto = saved.auto\n\t\t\t\t\treturn vertex\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tthrow new Error(`layout contains unknown element ${k}`)\n\t\t}\n\t\tfor (const node of this.nodes()) {\n\t\t\tif (!(node.id in layout)) {\n\t\t\t\tthrow new Error(`layout is missing node ${node.id}`)\n\t\t\t}\n\t\t}\n\t\tif (rerender) {\n\t\t\tthis.nodes().forEach(n => setPosition(n.ref, n.x, n.y))\n\t\t\tthis.edges.forEach(e => this.redrawEdge(e))\n\t\t\tthis.updateEdgesSel()\n\t\t\tthis.redrawGroups(null)\n\t\t}\n\t}\n\n\tasync autoLayout(options?: LayoutOptions) {\n\t\tconst auto = await autoLayout(this, options)\n\t\tthis._undo.beforeChange()\n\n\t\tfor (const placedNode of auto.nodes) {\n\t\t\tconst node = this.nodesMap.get(placedNode.id)\n\t\t\tif (!node) {\n\t\t\t\tthrow new Error(`layout contains unknown node ${placedNode.id}`)\n\t\t\t}\n\t\t\tnode.x = placedNode.x\n\t\t\tnode.y = placedNode.y\n\t\t\tsetPosition(node.ref, node.x, node.y)\n\t\t}\n\n\t\tfor (const placedGroup of auto.groups) {\n\t\t\tconst group = this.groupsMap.get(placedGroup.id)\n\t\t\tif (!group) {\n\t\t\t\tthrow new Error(`layout contains unknown group ${placedGroup.id}`)\n\t\t\t}\n\t\t\tgroup.layoutBounds = placedGroup.bounds\n\t\t\tgroup.layoutTitleBounds = placedGroup.titleBounds\n\t\t\tgroup.x = placedGroup.bounds.x + placedGroup.bounds.width / 2\n\t\t\tgroup.y = placedGroup.bounds.y + placedGroup.bounds.height / 2\n\t\t\tgroup.width = placedGroup.bounds.width\n\t\t\tgroup.height = placedGroup.bounds.height\n\t\t}\n\n\t\tfor (const placedEdge of auto.edges) {\n\t\t\tconst edge = this.edges.find(candidate => candidate.id === placedEdge.id)\n\t\t\tif (!edge) {\n\t\t\t\tthrow new Error(`layout contains unknown edge ${placedEdge.id}`)\n\t\t\t}\n\t\t\tfor (const vertex of edge.vertices ?? []) {\n\t\t\t\tthis.edgeVertices.delete(vertex.id)\n\t\t\t}\n\t\t\tedge.layoutSections = placedEdge.sections\n\t\t\tedge.layoutLabelBounds = placedEdge.labelBounds\n\t\t\tedge.vertices = interiorRoutePoints(placedEdge.sections).map(point => {\n\t\t\t\tconst vertex = edge.initVertex(point)\n\t\t\t\tvertex.auto = true\n\t\t\t\treturn vertex\n\t\t\t})\n\t\t\tedge.userDeletedVertices = false\n\t\t}\n\n\t\tthis.validatedLayout = auto.validated\n\t\tthis.edges.forEach(edge => this.redrawEdge(edge))\n\t\tthis.redrawGroups(null)\n\t\tthis.fitToView()\n\t\tthis._undo.change()\n\t}\n\n\talignSelectionV() {\n\t\tconst lst: Point[] = this.nodes().filter(n => n.selected)\n\t\tlst.push(...Array.from(this.edgeVertices.values()).filter(v => v.selected))\n\t\tlet minY = Math.min(...lst.map(p => p.y))\n\t\tthis.nodesMap.forEach(n => n.selected && this.moveNode(n, n.x, minY, false, false))\n\t\tthis.edgeVertices.forEach(v => v.selected && this.moveEdgeVertex(v, v.x, minY, false, false))\n\t}\n\n\talignSelectionH() {\n\t\tconst lst: Point[] = this.nodes().filter(n => n.selected)\n\t\tlst.push(...Array.from(this.edgeVertices.values()).filter(v => v.selected))\n\t\tlet minX = Math.min(...lst.map(p => p.x))\n\t\tthis.nodesMap.forEach(n => n.selected && this.moveNode(n, minX, n.y, false, false))\n\t\tthis.edgeVertices.forEach(v => v.selected && this.moveEdgeVertex(v, minX, v.y, false, false))\n\t}\n\n\tdistributeSelectionH() {\n\t\tconst selectedNodes = this.nodes().filter(n => n.selected)\n\t\tconst selectedVertices = Array.from(this.edgeVertices.values()).filter(v => v.selected)\n\t\t\n\t\tif (selectedNodes.length + selectedVertices.length < 3) return // Need at least 3 elements to distribute\n\t\t\n\t\tthis._undo.beforeChange()\n\t\t\n\t\t// Combine and sort by X coordinate\n\t\tconst allElements = [...selectedNodes, ...selectedVertices]\n\t\tallElements.sort((a, b) => a.x - b.x)\n\t\t\n\t\tconst minX = allElements[0].x\n\t\tconst maxX = allElements[allElements.length - 1].x\n\t\tconst spacing = (maxX - minX) / (allElements.length - 1)\n\t\t\n\t\t// Distribute elements evenly between leftmost and rightmost\n\t\tallElements.forEach((element, index) => {\n\t\t\tconst newX = minX + (index * spacing)\n\t\t\tif ('title' in element) {\n\t\t\t\t// It's a Node\n\t\t\t\tthis.moveNode(element as Node, newX, element.y, false, true)\n\t\t\t} else {\n\t\t\t\t// It's an EdgeVertex\n\t\t\t\tthis.moveEdgeVertex(element as EdgeVertex, newX, element.y, false, true)\n\t\t\t}\n\t\t})\n\t\t\n\t\tthis._undo.change()\n\t}\n\n\tdistributeSelectionV() {\n\t\tconst selectedNodes = this.nodes().filter(n => n.selected)\n\t\tconst selectedVertices = Array.from(this.edgeVertices.values()).filter(v => v.selected)\n\t\t\n\t\tif (selectedNodes.length + selectedVertices.length < 3) return // Need at least 3 elements to distribute\n\t\t\n\t\tthis._undo.beforeChange()\n\t\t\n\t\t// Combine and sort by Y coordinate\n\t\tconst allElements = [...selectedNodes, ...selectedVertices]\n\t\tallElements.sort((a, b) => a.y - b.y)\n\t\t\n\t\tconst minY = allElements[0].y\n\t\tconst maxY = allElements[allElements.length - 1].y\n\t\tconst spacing = (maxY - minY) / (allElements.length - 1)\n\t\t\n\t\t// Distribute elements evenly between topmost and bottommost\n\t\tallElements.forEach((element, index) => {\n\t\t\tconst newY = minY + (index * spacing)\n\t\t\tif ('title' in element) {\n\t\t\t\t// It's a Node\n\t\t\t\tthis.moveNode(element as Node, element.x, newY, false, true)\n\t\t\t} else {\n\t\t\t\t// It's an EdgeVertex\n\t\t\t\tthis.moveEdgeVertex(element as EdgeVertex, element.x, newY, false, true)\n\t\t\t}\n\t\t})\n\t\t\n\t\tthis._undo.change()\n\t}\n\n\t// Set edge selection state\n\tsetEdgeSelected(edge: Edge, selected: boolean) {\n\t\t// Mark the edge as selected by selecting its connected nodes\n\t\tif (selected) {\n\t\t\tthis.setNodeSelected(edge.from, true)\n\t\t\tthis.setNodeSelected(edge.to, true)\n\t\t}\n\t\t// Update visual selection\n\t\tthis.updateEdgesSel()\n\t}\n\n\t// Fit the entire graph to the current viewport\n\tfitToView() {\n\t\tconst contentBounds = this.calculateContentBounds()\n\t\t\n\t\t// Handle edge case where there's no content\n\t\tif (contentBounds.width === 0 || contentBounds.height === 0) {\n\t\t\treturn\n\t\t}\n\t\t\n\t\t// Get viewport dimensions\n\t\tconst viewportWidth = this.svg.parentElement?.clientWidth || 800\n\t\tconst viewportHeight = this.svg.parentElement?.clientHeight || 600\n\t\t\n\t\t// Add padding around content\n\t\tconst padding = 40\n\t\t\n\t\t// Calculate zoom to fit content with padding\n\t\tconst zoomX = (viewportWidth - padding * 2) / contentBounds.width\n\t\tconst zoomY = (viewportHeight - padding * 2) / contentBounds.height\n\t\tconst optimalZoom = Math.min(zoomX, zoomY)\n\t\t\n\t\t// Clamp zoom between reasonable bounds\n\t\tconst finalZoom = Math.max(Math.min(optimalZoom, 2), 0.1)\n\t\t\n\t\t// Calculate content center in drawing coordinates\n\t\tconst contentCenterX = contentBounds.x + contentBounds.width / 2\n\t\tconst contentCenterY = contentBounds.y + contentBounds.height / 2\n\t\t\n\t\t// Calculate viewport center in screen coordinates\n\t\tconst viewportCenterX = viewportWidth / 2\n\t\tconst viewportCenterY = viewportHeight / 2\n\t\t\n\t\t// Calculate translation needed to center content in viewport\n\t\t// With translate(x,y) scale(zoom), translation is in screen coordinates\n\t\tconst translateX = viewportCenterX - (contentCenterX * finalZoom)\n\t\tconst translateY = viewportCenterY - (contentCenterY * finalZoom)\n\t\t\n\t\t// Apply zoom and translation transform\n\t\tconst zoomGroup = this.svg.querySelector('g.zoom') as SVGGElement\n\t\tif (zoomGroup) {\n\t\t\tzoomGroup.setAttribute('transform', `translate(${translateX}, ${translateY}) scale(${finalZoom})`)\n\t\t}\n\t\t\n\t\t// Update panning\n\t\tupdatePanning(this)\n\t\t\n\t\t// Save view state so this fit position is preserved after reload\n\t\tsaveViewState(this)\n\t}\n\n\t// Save current layout state for restoration\n\tprivate saveLayoutState(): Layout {\n\t\treturn this.exportLayout(true) // Include all vertices for complete state\n\t}\n\n\t// Restore layout state\n\tprivate restoreLayoutState(state: Layout) {\n\t\tthis.importLayout(state, true) // Rerender after restoring\n\t}\n\n\t// Grid functionality\n\tisGridVisible(): boolean {\n\t\treturn this._gridVisible;\n\t}\n\n\tisSnapToGrid(): boolean {\n\t\treturn this._snapToGrid;\n\t}\n\n\tgetGridSize(): number {\n\t\treturn this._gridSize;\n\t}\n\n\ttoggleGrid() {\n\t\tthis._gridVisible = !this._gridVisible;\n\t\tthis.updateGridDisplay();\n\t\t// Force toolbar update by dispatching a custom event\n\t\twindow.dispatchEvent(new CustomEvent('gridStateChanged'));\n\t}\n\n\ttoggleSnapToGrid() {\n\t\tthis._snapToGrid = !this._snapToGrid;\n\t\t// Force toolbar update by dispatching a custom event\n\t\twindow.dispatchEvent(new CustomEvent('gridStateChanged'));\n\t}\n\n\tsnapAllToGrid() {\n\t\tif (!this._snapToGrid) return;\n\t\t\n\t\tthis._undo.beforeChange();\n\t\tthis.nodes().forEach(node => {\n\t\t\tconst snappedX = Math.round(node.x / this._gridSize) * this._gridSize;\n\t\t\tconst snappedY = Math.round(node.y / this._gridSize) * this._gridSize;\n\t\t\tthis.moveNode(node, snappedX, snappedY, false, true);\n\t\t});\n\t\tthis._undo.change();\n\t}\n\n\t// Helper method to snap a point to grid\n\tprivate snapToGrid(x: number, y: number): { x: number, y: number } {\n\t\treturn {\n\t\t\tx: Math.round(x / this._gridSize) * this._gridSize,\n\t\t\ty: Math.round(y / this._gridSize) * this._gridSize\n\t\t};\n\t}\n\n\tupdateGridDisplay() {\n\t\tconst svg = this.svg;\n\n\t\t// Remove existing grid pattern and background\n\t\tconst existingGrid = svg.querySelector(`#${this.idPrefix}grid-pattern`);\n\t\tif (existingGrid) {\n\t\t\texistingGrid.remove();\n\t\t}\n\n\t\tconst existingGridRect = svg.querySelector(`#${this.idPrefix}grid-background`);\n\t\tif (existingGridRect) {\n\t\t\texistingGridRect.remove();\n\t\t}\n\n\t\tif (!this._gridVisible) return;\n\n\t\t// Create grid pattern in defs\n\t\tlet defs = svg.querySelector('defs');\n\t\tif (!defs) {\n\t\t\tdefs = document.createElementNS('http://www.w3.org/2000/svg', 'defs');\n\t\t\tsvg.insertBefore(defs, svg.firstChild);\n\t\t}\n\n\t\tconst pattern = document.createElementNS('http://www.w3.org/2000/svg', 'pattern');\n\t\tpattern.id = `${this.idPrefix}grid-pattern`;\n\t\tpattern.setAttribute('width', this._gridSize.toString());\n\t\tpattern.setAttribute('height', this._gridSize.toString());\n\t\tpattern.setAttribute('patternUnits', 'userSpaceOnUse');\n\n\t\tconst path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n\t\tpath.setAttribute('d', `M ${this._gridSize} 0 L 0 0 0 ${this._gridSize}`);\n\t\tpath.setAttribute('fill', 'none');\n\t\tpath.setAttribute('stroke', '#d0d0d0');\n\t\tpath.setAttribute('stroke-width', '1');\n\t\tpath.setAttribute('opacity', '0.8');\n\n\t\tpattern.appendChild(path);\n\t\tdefs.appendChild(pattern);\n\n\t\t// Create grid background rectangle\n\t\tconst rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\n\t\trect.id = `${this.idPrefix}grid-background`;\n\t\trect.setAttribute('x', '-10000');\n\t\trect.setAttribute('y', '-10000');\n\t\trect.setAttribute('width', '20000');\n\t\trect.setAttribute('height', '20000');\n\t\trect.setAttribute('fill', `url(#${this.idPrefix}grid-pattern)`);\n\t\trect.setAttribute('pointer-events', 'none');\n\n\t\t// Insert grid as first child of zoom group so it transforms with content\n\t\tconst zoomGroup = svg.querySelector('g.zoom');\n\t\tif (zoomGroup) {\n\t\t\tzoomGroup.insertBefore(rect, zoomGroup.firstChild);\n\t\t}\n\t}\n}\n\n/** interiorRoutePoints returns only the editable points between edge endpoints. */\nfunction interiorRoutePoints(sections: Point[][]): Point[] {\n\tconst route: Point[] = []\n\tfor (const section of sections) {\n\t\tfor (const point of section) {\n\t\t\tconst previous = route[route.length - 1]\n\t\t\tif (!previous || previous.x !== point.x || previous.y !== point.y) {\n\t\t\t\troute.push(point)\n\t\t\t}\n\t\t}\n\t}\n\treturn route.slice(1, -1)\n}\n\n/** requiredSavedPoint checks coordinates when reading saved editor layout data. */\nfunction requiredSavedPoint(\n\tid: string,\n\tvalue: Point | SavedEdgePoint | SavedEdgePoint[] | boolean,\n): SavedEdgePoint {\n\tif (\n\t\ttypeof value !== 'object' ||\n\t\tArray.isArray(value) ||\n\t\t!Number.isFinite(value.x) ||\n\t\t!Number.isFinite(value.y)\n\t) {\n\t\tthrow new Error(`layout entry ${id} must contain valid x and y coordinates`)\n\t}\n\treturn value\n}\n\nfunction escapeCdata(code: string) {\n\treturn code.replace(/]]>/g, ']]]>]> void, dragMode: 'pan' | 'select') => {\n\tconst svg = data.svg\n\tsvg.setAttribute('width', '100%')\n\tsvg.setAttribute('height', '100%')\n\tdocument.body.append(svg) // make sure svg element is connected, we will measure texts sizes\n\n\tdata.selectListener = onNodeSelect\n\n\t_buildGraph(data)\n\tconst elasticEl = create.rect(300, 300, 50, 50, 0, 'elastic')\n\tsvg.append(elasticEl)\n\n\t// Initialize grid display now that the zoom group exists\n\tdata.updateGridDisplay()\n\n\t// Call addCursorInteraction with dragMode\n\taddCursorInteraction(data, dragMode)\n\n\treturn {\n\t\tsvg,\n\t\tsetZoom: (zoom: number) => setZoom(data, zoom),\n\t}\n}\n\n/** buildGraphView draws data into its own svg without editor handling and returns that svg. */\nexport const buildGraphView = (data: GraphData) => {\n\t_buildGraph(data)\n\treturn data.svg\n}\n\nconst _buildGraph = (data: GraphData) => {\n\t// Every graph owns the reusable SVG definitions referenced by its drawn\n\t// elements, including relationship arrowheads, icons, and filters.\n\tdata.svg.innerHTML = defs(data.idPrefix)\n\n\t//toplevel groups\n\tconst zoomG = create.element('g', {}, 'zoom') as SVGGElement\n\tconst nodesG = create.element('g', {}, 'nodes') as SVGGElement\n\tconst edgesG = create.element('g', {}, 'edges') as SVGGElement\n\tconst groupsG = create.element('g', {}, 'groups') as SVGGElement\n\tzoomG.append(groupsG, edgesG, nodesG)\n\n\n\tdata.nodesMap.forEach((n) => {\n\t\tbuildNode(n, data)\n\t\tnodesG.append(n.ref)\n\t})\n\n\tdata.edges.forEach(edge => {\n\t\tedge.labelBounds = undefined\n\t})\n\tdata.edges.forEach(e => {\n\t\tbuildEdge(e, data)\n\t\tedgesG.append(e.ref)\n\t})\n\n\tdata.groupsMap.forEach((group) => {\n\t\tbuildGroup(group)\n\t\tgroupsG.append(group.ref)\n\t})\n\n\tdata.svg.append(zoomG)\n}\n\n/** buildEdge draws one relationship of data, using data's idPrefix for its ids and arrowhead. */\nfunction buildEdge(edge: Edge, data: GraphData) {\n\tconst n1 = edge.from;\n\n\tconst g = create.element('g', {}, 'edge') as SVGGElement\n\tg.setAttribute('id', data.idPrefix + edge.id)\n\tg.setAttribute('data-from', edge.from.id)\n\tg.setAttribute('data-to', edge.to.id)\n\n\tconst position = (edge.style.position || 50) / 100\n\n\tconst vertices = edge.layoutSections\n\t\t? completeRoutePoints(edge.layoutSections)\n\t\t: calculateEdgeVertices(edge)\n\tconst {bg, txt} = edge.layoutLabelBounds\n\t\t? buildPlacedEdgeLabel(edge.layoutLabelBounds, edge)\n\t\t: buildEdgeLabel(calculateLabelPlacement(vertices, position, n1), edge)\n\tg.append(bg, txt)\n\n\tconst path = createEdgePath(vertices)\n\n\tconst p = create.path(path, {'marker-end': `url(#${data.idPrefix}arrow)`}, 'edge')\n\tp.setAttribute('fill', 'none')\n\tp.setAttribute('stroke', edge.style.color)\n\tp.setAttribute('stroke-width', String(edge.style.thickness))\n\tp.setAttribute('stroke-linecap', 'round')\n\tedge.style.dashed && p.setAttribute('stroke-dasharray', '8')\n\tg.append(p)\n\t\n\t// Debug visualization removed - arrow issue fixed\n\n\t// drag handlers\n\tfor (const p of edge.vertices ?? []) {\n\t\tconst v = p as EdgeVertex\n\t\tv.ref = create.element('circle', {id: data.idPrefix + v.id, cx: p.x, cy: p.y, r: 7, fill: 'none'}, 'v-dot')\n\t\tv.selected && v.ref.classList.add('selected')\n\t\tv.auto && v.ref.classList.add('auto')\n\t\tg.append(v.ref)\n\t}\n\n\tedge.ref = g\n\treturn g\n}\n\n/** completeRoutePoints joins connected layout sections without duplicate points. */\nfunction completeRoutePoints(sections: Point[][]): Point[] {\n\tconst route: Point[] = []\n\tfor (const section of sections) {\n\t\tfor (const point of section) {\n\t\t\tconst previous = route[route.length - 1]\n\t\t\tif (!previous || previous.x !== point.x || previous.y !== point.y) {\n\t\t\t\troute.push(point)\n\t\t\t}\n\t\t}\n\t}\n\treturn route\n}\n\n/** buildPlacedEdgeLabel draws one label in the box chosen by layout. */\nfunction buildPlacedEdgeLabel(bounds: BBox, edge: Edge) {\n\tconst centerX = bounds.x + bounds.width / 2\n\tconst centerY = bounds.y + bounds.height / 2\n\tconst {txt} = create.textArea(\n\t\tedge.label,\n\t\tedge.style.width,\n\t\tedge.style.fontSize,\n\t\tfalse,\n\t\tcenterX,\n\t\tbounds.y,\n\t\t'middle',\n\t)\n\tapplyStyle(txt, SVG_STYLES.edgeText)\n\ttxt.setAttribute('stroke', 'none')\n\ttxt.setAttribute('font-size', String(edge.style.fontSize))\n\ttxt.setAttribute('fill', edge.style.color)\n\ttxt.setAttribute('data-field', 'label')\n\tconst bg = create.rect(bounds.width, bounds.height, bounds.x, bounds.y)\n\tapplyStyle(bg, SVG_STYLES.edgeRect)\n\treturn {\n\t\tbg,\n\t\ttxt,\n\t}\n}\n\n/**\n * buildEdgeLabel adapts an older saved label anchor into a complete label box.\n * It uses one fixed side and lets validation reject any resulting collision.\n */\nfunction buildEdgeLabel(placement: EdgeLabelPlacement, edge: Edge) {\n\tconst labelGap = 12;\n\tconst fontSize = edge.style.fontSize\n\tlet {txt, dy, maxW} = create.textArea(edge.label, edge.style.width, fontSize, false, placement.x, placement.y, 'middle')\n\tdy -= fontSize / 2\n\tmaxW += fontSize\n\tconst centerX = placement.orientation === 'vertical'\n\t\t? placement.x + maxW / 2 + labelGap\n\t\t: placement.x\n\tconst centerY = placement.orientation === 'vertical'\n\t\t? placement.y\n\t\t: placement.y - dy / 2 - labelGap\n\tconst bounds = {\n\t\tx: centerX - maxW / 2,\n\t\ty: centerY - dy / 2,\n\t\twidth: maxW,\n\t\theight: dy,\n\t}\n\ttxt.querySelectorAll('tspan').forEach((span: SVGTSpanElement) => {\n\t\tspan.setAttribute('x', String(centerX))\n\t})\n\ttxt.setAttribute('y', String(centerY - dy / 2))\n\n\tapplyStyle(txt, SVG_STYLES.edgeText)\n\ttxt.setAttribute('stroke', 'none')\n\ttxt.setAttribute('font-size', String(edge.style.fontSize))\n\ttxt.setAttribute('fill', edge.style.color)\n\n\tconst bg = create.rect(bounds.width, bounds.height, bounds.x, bounds.y)\n\tapplyStyle(bg, SVG_STYLES.edgeRect)\n\ttxt.setAttribute('data-field', 'label')\n\tedge.labelBounds = bounds\n\treturn {bg, txt}\n}\n\n\n/** buildNode draws one element of data, using data's idPrefix for its id. */\nfunction buildNode(n: Node, data: GraphData) {\n\tconst g = create.element('g', {}, 'node') as SVGGElement\n\tg.setAttribute('id', data.idPrefix + n.id)\n\tn.selected && g.classList.add('selected')\n\tsetPosition(g, n.x, n.y)\n\tconst link = n.link\n\t\t? create.element('a', {\n\t\t\thref: n.link.href,\n\t\t\t'data-export-href': n.link.exportHref,\n\t\t\t'aria-label': `Open ${n.title}`,\n\t\t}, 'nodeLink') as SVGAElement\n\t\t: null\n\tconst content = link || g\n\tif (link) {\n\t\tg.classList.add('linked')\n\t\tg.append(link)\n\t}\n\n\t// Ensure we use the correct shape from style, defaulting to Box\n\tconst shapeType = n.style.shape || 'Box';\n\tconst shapeFn = shapes[shapeType.toLowerCase()] || shapes.box\n\tconst shape: SVGElement = shapeFn(content, n);\n\n\tshape.classList.add('nodeBorder')\n\n\t// Apply generic styles first\n\tapplyStyle(shape, SVG_STYLES.nodeBorder)\n\t// Then apply tag-specific styles to override generic ones\n\tshape.setAttribute('fill', n.style.background)\n\tshape.setAttribute('stroke', n.style.stroke)\n\tshape.setAttribute('opacity', String(n.style.opacity))\n\tsetBorderStyle(shape, n.style.border)\n\n\tconst tg = buildNodeContent(n.contentLayout, n.style.color)\n\tconst labelOffsetY = Number(content.getAttribute('label-offset-y')) || 0\n\tsetPosition(tg, 0, labelOffsetY / 2)\n\tcontent.append(tg)\n\n\t// @ts-ignore\n\tg.__data = n;\n\tn.ref = g;\n\n\treturn g\n}\n\n\nfunction buildGroup(group: Group) {\n\tif (group.nodes.length == 0) {\n\t\treturn\n\t}\n\tconst g = create.element('g', {}, 'group') as SVGGElement\n\tif (group.layoutBounds && group.layoutTitleBounds) {\n\t\tconst bounds = group.layoutBounds\n\t\tconst title = group.layoutTitleBounds\n\t\tconst rect = create.rect(bounds.width, bounds.height, bounds.x, bounds.y)\n\t\tapplyStyle(rect, SVG_STYLES.groupRect)\n\t\tgroup.style.stroke && rect.setAttribute('stroke', group.style.stroke)\n\t\tgroup.style.background && rect.setAttribute('fill', group.style.background)\n\t\tconst text = create.text(group.name, {\n\t\t\tx: title.x,\n\t\t\ty: title.y,\n\t\t\t'dominant-baseline': 'hanging',\n\t\t})\n\t\tapplyStyle(text, SVG_STYLES.groupText)\n\t\tgroup.style.color && text.setAttribute('fill', group.style.color)\n\t\tg.append(rect, text)\n\t\tgroup.ref = g\n\t\treturn\n\t}\n\n\tlet p0: Point = {x: 1e100, y: 1e100}, p1: Point = {x: 0, y: 0}\n\tgroup.nodes.forEach(n => {\n\t\t// Calculate visual bounds accounting for shapes that extend beyond center\n\t\tconst shape = (n as Node).style?.shape?.toLowerCase() || 'box'\n\t\t\n\t\tlet topExtension = n.height / 2\n\t\tlet bottomExtension = n.height / 2\n\t\t\n\t\tif (shape === 'robot') {\n\t\t\t// Robot shape extends above with antenna\n\t\t\t// Account for antenna height (h * 0.08) plus some margin\n\t\t\tconst antennaH = n.height * 0.12\n\t\t\ttopExtension = n.height / 2 + antennaH\n\t\t\tbottomExtension = n.height / 2\n\t\t} else if (shape === 'hexagon') {\n\t\t\t// Hexagon extends to ±0.866 * (width/2) vertically\n\t\t\t// For width=280, that's ±121.24px from center\n\t\t\tconst hexHeight = n.width / 2 * 0.866\n\t\t\ttopExtension = hexHeight\n\t\t\tbottomExtension = hexHeight\n\t\t}\n\t\t\n\t\tconst b = {\n\t\t\tx: n.x - n.width / 2,\n\t\t\ty: n.y - topExtension,\n\t\t\twidth: n.width,\n\t\t\theight: topExtension + bottomExtension\n\t\t}\n\t\tp0.x = Math.min(p0.x, b.x)\n\t\tp0.y = Math.min(p0.y, b.y)\n\t\tp1.x = Math.max(p1.x, b.x + b.width)\n\t\tp1.y = Math.max(p1.y, b.y + b.height)\n\t})\n\tconst pad = 25 // Padding around content\n\tconst labelHeight = 30 // Space for the group label at bottom\n\tconst w = Math.max(p1.x - p0.x, 200)\n\tconst h = p1.y - p0.y\n\tconst bb = {\n\t\tx: p0.x - pad,\n\t\ty: p0.y - pad,\n\t\twidth: w + pad * 2,\n\t\theight: h + pad * 2 + labelHeight,\n\t}\n\tconst r = create.rect(bb.width, bb.height, bb.x, bb.y)\n\tgroup.x = bb.x + bb.width / 2\n\tgroup.y = bb.y + bb.height / 2\n\tgroup.width = bb.width\n\tgroup.height = bb.height\n\tapplyStyle(r, SVG_STYLES.groupRect)\n\tgroup.style.stroke && r.setAttribute('stroke', group.style.stroke)\n\tgroup.style.background && r.setAttribute('fill', group.style.background)\n\n\tconst txt = create.text(group.name, {x: p0.x, y: bb.y + bb.height - SVG_STYLES.groupText[\"font-size\"]})\n\tapplyStyle(txt, SVG_STYLES.groupText)\n\tgroup.style.color && txt.setAttribute('fill', group.style.color)\n\n\tg.append(r, txt)\n\tgroup.ref = g\n}\n\nfunction findClosestSegment(graph: GraphData, p: Point) {\n\t// find the closest point on a segment\n\tlet fnd = {dst: Number.POSITIVE_INFINITY, pos: -1, edge: null as Edge, prj: null as Point}\n\tgraph.edges.forEach(edge => {\n\t\tconst vertices = edge.vertices || []\n\t\tconst pts = [edge.from, ...vertices, edge.to]\n\t\tfor (let i = 1; i < pts.length; i++) {\n\t\t\tconst prj = project(p, pts[i - 1], pts[i])\n\t\t\tconst dst = cabDistance(p, prj)\n\t\t\tif (dst > 50) continue\n\t\t\tif (dst < fnd.dst) {\n\t\t\t\tfnd = {dst, pos: i, prj, edge}\n\t\t\t}\n\t\t}\n\t})\n\treturn fnd.edge ? fnd : null\n}\n\n/** mouseToDrawing converts a mouse event over data's svg to drawing coordinates. */\nfunction mouseToDrawing(data: GraphData, e: MouseEvent): Point {\n\t// transform event coords to drawing coords\n\tconst b = data.svg.getBoundingClientRect()\n\tconst z = getZoom(data)\n\t\n\t// Get current pan transform\n\tconst currentTransform = getCurrentTransform(data)\n\t\n\t// Convert screen coordinates to drawing coordinates accounting for zoom and pan\n\t// The transform values are in screen coordinates, so we need to divide by zoom and subtract\n\treturn {\n\t\tx: (e.clientX - b.x - currentTransform.x) / z,\n\t\ty: (e.clientY - b.y - currentTransform.y) / z\n\t}\n}\n\ninterface Handle extends Point {\n\tid: string\n\tselected?: boolean\n\tref?: SVGElement\n}\n\n// Custom cursor interaction that prioritizes panning over selection, on data's svg\nfunction addCustomCursorInteraction(data: GraphData, conn: {\n\tnodeFromEvent(e: MouseEvent): Handle | null;\n\tsetSelection(handles: Handle[]): void;\n\tisSelected(handle: Handle): boolean;\n\tgetSelection(): Handle[];\n\tgetZoom(): number;\n\tmoveNode(h: Handle, x: number, y: number): void;\n\tboxSelection(box: DOMRect, add: boolean): void;\n\tupdatePanning(): void;\n}, dragMode: 'pan' | 'select') {\n\tconst svg = data.svg\n\tlet ini: { x: number; y: number; n: Handle }[] = []\n\tlet elastic: any = null\n\tlet isPanning = false\n\tlet panStartX = 0\n\tlet panStartY = 0\n\tlet initialTransform = { x: 0, y: 0 }\n\tlet pendingSelectionChange: { node: Handle; shiftKey: boolean } | null = null\n\tlet pendingNavigation: string | null = null\n\tlet hasDragged = false\n\tlet suppressLinkClick = false\n\t\n\t// Store event listeners for cleanup\n\tconst eventListeners: Array<{ element: Element | Window, event: string, handler: EventListener }> = []\n\n\t// Simple elastic selection box implementation - use mouseToDrawing for proper coordinate conversion\n\tfunction createElastic() {\n\t\tlet startDrawingX = 0, startDrawingY = 0, rect: SVGRectElement | null = null\n\t\t\n\t\treturn {\n\t\t\tini(e: MouseEvent) {\n\t\t\t\t// Use mouseToDrawing to get proper drawing coordinates (accounts for zoom and pan)\n\t\t\t\tconst pt = mouseToDrawing(data, e)\n\t\t\t\tstartDrawingX = pt.x\n\t\t\t\tstartDrawingY = pt.y\n\t\t\t\t\n\t\t\t\trect = document.createElementNS(\"http://www.w3.org/2000/svg\", \"rect\")\n\t\t\t\trect.setAttribute('fill', 'rgba(0, 100, 255, 0.1)')\n\t\t\t\trect.setAttribute('stroke', 'rgba(0, 100, 255, 0.5)')\n\t\t\t\trect.setAttribute('stroke-width', '1')\n\t\t\t\trect.setAttribute('stroke-dasharray', '3,3')\n\t\t\t\trect.setAttribute('x', String(startDrawingX))\n\t\t\t\trect.setAttribute('y', String(startDrawingY))\n\t\t\t\trect.setAttribute('width', '0')\n\t\t\t\trect.setAttribute('height', '0')\n\t\t\t\t\n\t\t\t\t// Add to the zoom group so it transforms with the content\n\t\t\t\tconst zoomGroup = svg.querySelector('g.zoom')\n\t\t\t\tif (zoomGroup) {\n\t\t\t\t\tzoomGroup.appendChild(rect)\n\t\t\t\t} else {\n\t\t\t\t\tsvg.appendChild(rect)\n\t\t\t\t}\n\t\t\t},\n\t\t\tupdate(e: MouseEvent) {\n\t\t\t\tif (!rect) return\n\t\t\t\t\n\t\t\t\t// Convert current mouse position to drawing coordinates (accounts for zoom and pan)\n\t\t\t\tconst currentPt = mouseToDrawing(data, e)\n\t\t\t\tconst currentDrawingX = currentPt.x\n\t\t\t\tconst currentDrawingY = currentPt.y\n\t\t\t\t\n\t\t\t\t// Calculate rectangle bounds in drawing coordinates\n\t\t\t\tconst x = Math.min(startDrawingX, currentDrawingX)\n\t\t\t\tconst y = Math.min(startDrawingY, currentDrawingY)\n\t\t\t\tconst width = Math.abs(currentDrawingX - startDrawingX)\n\t\t\t\tconst height = Math.abs(currentDrawingY - startDrawingY)\n\t\t\t\t\n\t\t\t\trect.setAttribute('x', String(x))\n\t\t\t\trect.setAttribute('y', String(y))\n\t\t\t\trect.setAttribute('width', String(width))\n\t\t\t\trect.setAttribute('height', String(height))\n\t\t\t},\n\t\t\tend(): DOMRect | null {\n\t\t\t\tif (!rect) return null\n\t\t\t\t\n\t\t\t\t// Get final rectangle bounds in drawing coordinates\n\t\t\t\tconst x = parseFloat(rect.getAttribute('x') || '0')\n\t\t\t\tconst y = parseFloat(rect.getAttribute('y') || '0')\n\t\t\t\tconst width = parseFloat(rect.getAttribute('width') || '0')\n\t\t\t\tconst height = parseFloat(rect.getAttribute('height') || '0')\n\t\t\t\t\n\t\t\t\trect.remove()\n\t\t\t\trect = null\n\t\t\t\t\n\t\t\t\t// Return drawing coordinates directly for boxSelection since we're now working in the same coordinate system\n\t\t\t\tif (width > 5 && height > 5) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tx: x, y: y, width: width, height: height,\n\t\t\t\t\t\tleft: x, top: y, right: x + width, bottom: y + height\n\t\t\t\t\t} as DOMRect\n\t\t\t\t}\n\t\t\t\treturn null\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction getCurrentTransformLocal() {\n\t\tconst zoomGroup = svg.querySelector('g.zoom') as SVGGElement\n\t\tif (!zoomGroup) return { x: 0, y: 0 }\n\t\t\n\t\tconst transform = zoomGroup.getAttribute('transform') || ''\n\t\tconst translateMatch = transform.match(/translate\\(([^,]+),([^)]+)\\)/)\n\t\tif (translateMatch) {\n\t\t\treturn {\n\t\t\t\tx: parseFloat(translateMatch[1]) || 0,\n\t\t\t\ty: parseFloat(translateMatch[2]) || 0\n\t\t\t}\n\t\t}\n\t\treturn { x: 0, y: 0 }\n\t}\n\n\tfunction setTransform(x: number, y: number) {\n\t\tconst zoomGroup = svg.querySelector('g.zoom') as SVGGElement\n\t\tif (!zoomGroup) return\n\t\t\n\t\tconst zoom = getZoom(data)\n\t\tzoomGroup.setAttribute('transform', `translate(${x}, ${y}) scale(${zoom})`)\n\t}\n\n\tfunction onMouseDown(e: MouseEvent) {\n\t\te.preventDefault();\n\t\thasDragged = false\n\t\tpendingSelectionChange = null\n\t\tconst target = e.target\n\t\tconst link = target instanceof Element ? target.closest('a.nodeLink') : null\n\t\tpendingNavigation = e.shiftKey ? null : link?.getAttribute('href') || null\n\n\t\tconst node = conn.nodeFromEvent(e)\n\t\t\n\t\t// Determine effective mode: invert if shift is held\n\t\tconst effectiveMode = e.shiftKey ? (dragMode === 'pan' ? 'select' : 'pan') : dragMode\n\t\t\n\t\tif (!node) { // Clicked on empty space\n\t\t\tif (effectiveMode === 'pan') {\n\t\t\t\t// Pan mode: pan and deselect\n\t\t\t\tisPanning = true;\n\t\t\t\telastic = null;\n\t\t\t\tpanStartX = e.clientX;\n\t\t\t\tpanStartY = e.clientY;\n\t\t\t\tinitialTransform = getCurrentTransformLocal();\n\t\t\t\tini = [];\n\t\t\t\t// Deselect all elements when clicking empty space in pan mode\n\t\t\t\tconn.setSelection([]);\n\t\t\t} else {\n\t\t\t\t// Select mode: ONLY select, no panning\n\t\t\t\tisPanning = false;\n\t\t\t\telastic = createElastic();\n\t\t\t\tif (elastic) elastic.ini(e);\n\t\t\t\tini = [];\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Clicked on a node/vertex - behavior depends on effective mode\n\t\tif (effectiveMode === 'pan') {\n\t\t\t// Pan mode: select the element, don't pan\n\t\t\tisPanning = false;\n\t\t\telastic = null;\n\t\t\t\n\t\t\tconst nodes = conn.getSelection()\n\t\t\tif (conn.isSelected(node)) {\n\t\t\t\t// Clicking on a selected node - prepare to drag all selected elements\n\t\t\t\tini = nodes.map(n => ({ x: n.x, y: n.y, n }))\n\t\t\t\t// No selection change needed since we're clicking on already selected element\n\t\t\t} else {\n\t\t\t\t// Clicking on an unselected node - select only this element\n\t\t\t\tconn.setSelection([node]);\n\t\t\t\tini = [{ x: node.x, y: node.y, n: node }];\n\t\t\t}\n\t\t} else {\n\t\t\t// Select mode: selection/drag logic\n\t\t\tisPanning = false; // Ensure no panning if a node is clicked\n\t\t\telastic = null; // Ensure no selection box if a node is clicked\n\t\t\tconst nodes = conn.getSelection()\n\t\t\t\n\t\t\tif (e.shiftKey && dragMode === 'select') {\n\t\t\t\t// Shift+click in select mode: immediately change selection (no dragging expected)\n\t\t\t\tif (conn.isSelected(node)) {\n\t\t\t\t\tconst index = nodes.findIndex(n => n.id === node.id)\n\t\t\t\t\tif (index >= 0) nodes.splice(index, 1)\n\t\t\t\t} else {\n\t\t\t\t\tnodes.push(node)\n\t\t\t\t}\n\t\t\t\tconn.setSelection(nodes)\n\t\t\t\tini = nodes.map(n => ({ x: n.x, y: n.y, n }))\n\t\t\t} else {\n\t\t\t\t// Regular click: defer selection change until we know if it's a drag or click\n\t\t\t\tif (conn.isSelected(node)) {\n\t\t\t\t\t// Clicking on a selected node - prepare to drag all selected elements\n\t\t\t\t\tini = nodes.map(n => ({ x: n.x, y: n.y, n }))\n\t\t\t\t\t// No pending selection change needed since we're clicking on already selected element\n\t\t\t\t\tpendingSelectionChange = null\n\t\t\t\t} else {\n\t\t\t\t\t// Clicking on an unselected node - defer selection change until we determine if it's a click or drag\n\t\t\t\t\tpendingSelectionChange = { node, shiftKey: e.shiftKey }\n\t\t\t\t\t// For now, prepare to drag just the clicked node (we'll update selection when drag starts)\n\t\t\t\t\tini = [{ x: node.x, y: node.y, n: node }]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onMouseMove(e: MouseEvent, dx: number, dy: number) {\n\t\t// Check if we've moved enough to consider this a drag\n\t\tconst dragThreshold = 3 // pixels\n\t\tif (!hasDragged && (Math.abs(dx) > dragThreshold || Math.abs(dy) > dragThreshold)) {\n\t\t\thasDragged = true\n\t\t\tpendingNavigation = null\n\t\t\t\n\t\t\t// If we have a pending selection change and we're now dragging, apply it\n\t\t\tif (pendingSelectionChange) {\n\t\t\t\tconst nodes = conn.getSelection()\n\t\t\t\tnodes.length = 0\n\t\t\t\tnodes.push(pendingSelectionChange.node)\n\t\t\t\tconn.setSelection(nodes)\n\t\t\t\t// Update ini to drag only the newly selected node\n\t\t\t\tini = [{ x: pendingSelectionChange.node.x, y: pendingSelectionChange.node.y, n: pendingSelectionChange.node }]\n\t\t\t\tpendingSelectionChange = null\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (isPanning) {\n\t\t\t// Pan the view - apply mouse delta directly (no zoom division needed)\n\t\t\t// setTransform expects screen coordinates, dx/dy are already screen pixel deltas\n\t\t\tconst newX = initialTransform.x + dx\n\t\t\tconst newY = initialTransform.y + dy\n\t\t\tsetTransform(newX, newY)\n\t\t} else if (ini.length > 0 && hasDragged) {\n\t\t\t// Move selected nodes/vertices (only if we've actually started dragging)\n\t\t\t// dx, dy are screen pixel deltas, convert to drawing coordinate deltas\n\t\t\tconst zoom = conn.getZoom()\n\t\t\tconst drawingDx = dx / zoom\n\t\t\tconst drawingDy = dy / zoom\n\t\t\tini.forEach(item => {\n\t\t\t\t// item.x, item.y are initial drawing coordinates\n\t\t\t\t// Add the drawing coordinate delta to get new position\n\t\t\t\tconn.moveNode(item.n, item.x + drawingDx, item.y + drawingDy)\n\t\t\t})\n\t\t} else if (elastic) {\n\t\t\t// Update selection box\n\t\t\telastic.update(e)\n\t\t}\n\t}\n\n\tfunction onMouseUp(e: MouseEvent) {\n\t\tconst navigation = hasDragged ? null : pendingNavigation\n\t\tif (hasDragged) {\n\t\t\tsuppressLinkClick = true\n\t\t\twindow.setTimeout(() => {\n\t\t\t\tsuppressLinkClick = false\n\t\t\t}, 0)\n\t\t}\n\t\t\n\t\t// If we have a pending selection change and didn't drag, apply it now (it was just a click)\n\t\tif (pendingSelectionChange && !hasDragged) {\n\t\t\tconst nodes = conn.getSelection()\n\t\t\tnodes.length = 0\n\t\t\tnodes.push(pendingSelectionChange.node)\n\t\t\tconn.setSelection(nodes)\n\t\t}\n\t\t\n\t\tif (elastic) {\n\t\t\tconst box = elastic.end()\n\t\t\tif (box) {\n\t\t\t\tconn.boxSelection(box, e.shiftKey)\n\t\t\t} else if (!ini.length) {\n\t\t\t\t// Deselect if no box was drawn\n\t\t\t\tconn.setSelection([])\n\t\t\t}\n\t\t\telastic = null\n\t\t}\n\t\t\n\t\t// Save view state if user was panning (user-initiated view change)\n\t\tif (isPanning && hasDragged) {\n\t\t\tsaveViewState(data)\n\t\t}\n\t\t\n\t\t// Reset state\n\t\tpendingSelectionChange = null\n\t\tpendingNavigation = null\n\t\thasDragged = false\n\t\tisPanning = false\n\t\tconn.updatePanning()\n\t\tif (navigation) {\n\t\t\twindow.location.href = navigation\n\t\t}\n\t}\n\n\tfunction onClick(e: MouseEvent) {\n\t\tconst target = e.target\n\t\tif (!(target instanceof Element) || !target.closest('a.nodeLink')) return\n\t\te.preventDefault()\n\t\tif (!suppressLinkClick) return\n\t\te.stopPropagation()\n\t\tsuppressLinkClick = false\n\t}\n\n\t// Add drag and drop functionality\n\tfunction addDnd(element: SVGSVGElement) {\n\t\tlet md: { ex: number; ey: number } | null = null\n\n\t\tfunction convertEvent(e: MouseEvent | TouchEvent): MouseEvent {\n\t\t\tif ('changedTouches' in e && e.changedTouches) {\n\t\t\t\treturn e.changedTouches[0] as any\n\t\t\t}\n\t\t\treturn e as MouseEvent\n\t\t}\n\n\t\tfunction onMouseMoveHandler(e: MouseEvent | TouchEvent) {\n\t\t\tif (!md) return\n\t\t\te = convertEvent(e)\n\t\t\tonMouseMove(e, e.clientX - md.ex, e.clientY - md.ey)\n\t\t}\n\n\t\tfunction removeListeners() {\n\t\t\tdocument.removeEventListener('touchmove', onMouseMoveHandler as any)\n\t\t\tdocument.removeEventListener('mousemove', onMouseMoveHandler as any)\n\t\t\tdocument.removeEventListener('mouseup', onMouseUpHandler)\n\t\t\tdocument.removeEventListener('touchend', onMouseUpHandler)\n\t\t}\n\n\t\tfunction onMouseUpHandler(e: MouseEvent | TouchEvent) {\n\t\t\tremoveListeners()\n\t\t\tonMouseUp(convertEvent(e))\n\t\t\tmd = null\n\t\t}\n\n\t\tfunction onMouseDownHandler(e: MouseEvent | TouchEvent) {\n\t\t\te = convertEvent(e)\n\t\t\tmd = { ex: e.clientX, ey: e.clientY }\n\t\t\tonMouseDown(e)\n\t\t\tdocument.addEventListener('touchmove', onMouseMoveHandler as any)\n\t\t\tdocument.addEventListener('mousemove', onMouseMoveHandler as any)\n\t\t\tdocument.addEventListener('mouseup', onMouseUpHandler)\n\t\t\tdocument.addEventListener('touchend', onMouseUpHandler)\n\t\t}\n\n\t\telement.addEventListener('mousedown', onMouseDownHandler as any)\n\t\telement.addEventListener('touchstart', onMouseDownHandler as any)\n\t\t\n\t\t// Track these listeners for cleanup\n\t\teventListeners.push(\n\t\t\t{ element, event: 'mousedown', handler: onMouseDownHandler as any },\n\t\t\t{ element, event: 'touchstart', handler: onMouseDownHandler as any }\n\t\t)\n\t}\n\n\taddDnd(svg)\n\tsvg.addEventListener('click', onClick)\n\teventListeners.push({ element: svg, event: 'click', handler: onClick })\n\t\n\t// Return cleanup function\n\treturn () => {\n\t\teventListeners.forEach(({ element, event, handler }) => {\n\t\t\telement.removeEventListener(event, handler)\n\t\t})\n\t}\n}\n\n/**\n * addCursorInteraction attaches the editor's mouse, wheel, keyboard, and\n * unsaved-changes handling for data and its svg, replacing handlers attached by\n * an earlier call. The cleanup function is stored as the svg's\n * __cursorInteractionCleanup; the editor calls it when it removes the graph.\n */\nexport function addCursorInteraction(data: GraphData, dragMode: 'pan' | 'select') {\n\tconst svg = data.svg\n\t// Clean up any existing event listeners to prevent conflicts\n\tconst existingCleanup = (svg as any).__cursorInteractionCleanup\n\tif (existingCleanup) {\n\t\texistingCleanup()\n\t}\n\n\tfunction getData(el: SVGElement) {\n\t\t// @ts-ignore\n\t\treturn el.__data\n\t}\n\n\t// Store event listeners for cleanup\n\tconst eventListeners: Array<{ element: Element | Window, event: string, handler: EventListener }> = []\n\n\tconst beforeUnloadHandler = (e: BeforeUnloadEvent) => {\n\t\tif (!data.changed()) return\n\t\te.preventDefault()\n\t\te.returnValue = ''\n\t}\n\twindow.addEventListener(\"beforeunload\", beforeUnloadHandler)\n\teventListeners.push({ element: window, event: 'beforeunload', handler: beforeUnloadHandler })\n\n\tfunction setDotSelected(d: Handle, selected: boolean) {\n\t\td.selected = selected\n\t\tconst dotEl = svg.querySelector('#' + data.idPrefix + d.id)\n\t\td.selected ? dotEl.classList.add('selected') : dotEl.classList.remove('selected')\n\t}\n\n\t// show moving dot along edge when ALT is pressed\n\tconst mouseMoveHandler = (e: MouseEvent) => {\n\t\tif (!e.altKey) return\n\t\tconst fnd = findClosestSegment(data, mouseToDrawing(data, e))\n\t\tif (fnd) {\n\t\t\tconst {prj} = fnd\n\t\t\tconst parent = svg.querySelector('g.edges')\n\t\t\tlet dot = parent.querySelector(`#${data.idPrefix}prj`)\n\t\t\tif (!dot) {\n\t\t\t\tdot = create.element('circle', {id: `${data.idPrefix}prj`, cx: prj.x, cy: prj.y, r: 7}, 'prj')\n\t\t\t\tparent.append(dot)\n\t\t\t}\n\t\t\tdot.setAttribute('cx', String(prj.x))\n\t\t\tdot.setAttribute('cy', String(prj.y))\n\t\t} else {\n\t\t\tremovePrjDot()\n\t\t}\n\t}\n\tsvg.addEventListener('mousemove', mouseMoveHandler)\n\teventListeners.push({ element: svg, event: 'mousemove', handler: mouseMoveHandler })\n\n\tconst keyUpHandler = (e: KeyboardEvent) => {\n\t\tconst key = findShortcut(e, true)\n\t\tif (key == ADD_VERTEX || key == ADD_LABEL_VERTEX) return\n\t\tremovePrjDot()\n\t}\n\twindow.addEventListener('keyup', keyUpHandler)\n\teventListeners.push({ element: window, event: 'keyup', handler: keyUpHandler })\n\n\tfunction removePrjDot() {\n\t\tconst el = svg.querySelector(`g.edges #${data.idPrefix}prj`)\n\t\tel && el.parentElement.removeChild(el)\n\t}\n\n\tconst clickHandler = (e: MouseEvent) => {\n\t\tconst key = findShortcut(e, true)\n\t\tif (key != ADD_LABEL_VERTEX && key != ADD_VERTEX) return\n\t\tconst fnd = findClosestSegment(data, mouseToDrawing(data, e))\n\t\tif (fnd) {\n\t\t\tconst {edge, pos, prj} = fnd\n\t\t\t// depending on keyboard modifier, make it label position\n\t\t\tdata.insertEdgeVertex(edge, prj, pos, key == ADD_LABEL_VERTEX)\n\t\t\tremovePrjDot()\n\t\t}\n\t}\n\tsvg.addEventListener('click', clickHandler)\n\teventListeners.push({ element: svg, event: 'click', handler: clickHandler })\n\n\tconst wheelHandler = (e: WheelEvent) => {\n\t\t// Handle wheel zoom directly without relying on shortcuts\n\t\t// deltaY > 0 means scrolling down (zoom out), deltaY < 0 means scrolling up (zoom in)\n\t\tconst delta = Math.sign(e.deltaY) * 0.1 // Normalize to 0.1 zoom steps\n\t\tconst currentZoom = getZoom(data)\n\t\tconst newZoom = Math.max(0.1, Math.min(5, currentZoom - delta)) // Clamp zoom between 0.1 and 5\n\t\t\n\t\tif (newZoom !== currentZoom) {\n\t\t\t// Convert absolute screen coordinates to SVG-relative coordinates\n\t\t\tconst rect = svg.getBoundingClientRect()\n\t\t\tconst svgX = e.clientX - rect.left\n\t\t\tconst svgY = e.clientY - rect.top\n\t\t\tsetZoomCentered(data, newZoom, svgX, svgY)\n\t\t\te.preventDefault()\n\t\t\t\n\t\t\t// Save view state after user wheel zoom\n\t\t\tsaveViewState(data)\n\t\t}\n\t}\n\tsvg.addEventListener('wheel', wheelHandler)\n\teventListeners.push({ element: svg, event: 'wheel', handler: wheelHandler })\n\n\tconst keyDownHandler = (e: KeyboardEvent) => {\n\t\tconst shortcut = findShortcut(e)\n\t\t\n\t\t\n\t\tif (shortcut) {\n\t\t\te.preventDefault() // Prevent browser default for all recognized shortcuts\n\t\t}\n\t\t\n\t\tswitch (shortcut) {\n\t\t\tcase DEL_VERTEX:\n\t\t\t\tconst selectedVertices = Array.from(data.edgeVertices.values()).filter(v => v.selected);\n\t\t\t\tselectedVertices.forEach(v => {\n\t\t\t\t\tdata.deleteEdgeVertex(v)\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\tcase UNDO:\n\t\t\t\tdata.undo()\n\t\t\t\tbreak\n\t\t\tcase REDO:\n\t\t\t\tdata.redo()\n\t\t\t\tbreak\n\t\t\tcase ZOOM_IN:\n\t\t\t\tconst newZoomIn = Math.min(5, getZoom(data) * 1.2)\n\t\t\t\t// Center zoom on viewport center like mouse wheel\n\t\t\t\tsetZoomCentered(data, newZoomIn)\n\t\t\t\tsaveViewState(data) // Save after user keyboard zoom\n\t\t\t\tbreak\n\t\t\tcase ZOOM_OUT:\n\t\t\t\tconst newZoomOut = Math.max(0.1, getZoom(data) / 1.2)\n\t\t\t\t// Center zoom on viewport center like mouse wheel\n\t\t\t\tsetZoomCentered(data, newZoomOut)\n\t\t\t\tsaveViewState(data) // Save after user keyboard zoom\n\t\t\t\tbreak\n\t\t\tcase ZOOM_100:\n\t\t\t\t// Center zoom on viewport center like mouse wheel\n\t\t\t\tsetZoomCentered(data, 1)\n\t\t\t\tsaveViewState(data) // Save after user keyboard zoom\n\t\t\t\tbreak\n\t\t\tcase ZOOM_FIT:\n\t\t\t\tdata.fitToView()\n\t\t\t\t// Don't save view state here - fitToView should not be persisted\n\t\t\t\tbreak\n\t\t\tcase SELECT_ALL:\n\t\t\t\tdata.nodes().forEach(n => data.setNodeSelected(n, true))\n\t\t\t\tdata.edgeVertices.forEach(v => setDotSelected(v, true))\n\t\t\t\tbreak\n\t\t\tcase DESELECT:\n\t\t\t\tdata.nodes().forEach(n => data.setNodeSelected(n, false))\n\t\t\t\tdata.edgeVertices.forEach(v => setDotSelected(v, false))\n\t\t\t\tbreak\n\t\t}\n\t}\n\twindow.addEventListener('keydown', keyDownHandler)\n\teventListeners.push({ element: window, event: 'keydown', handler: keyDownHandler })\n\n\t// Custom cursor interaction with pan-first behavior\n\tconst customInteractionCleanup = addCustomCursorInteraction(data, {\n\t\tnodeFromEvent(e: MouseEvent): Handle {\n\t\t\te.preventDefault()\n\t\t\t// node clicked\n\t\t\tlet el = (e.target as SVGElement).closest('g.nodes g.node') as SVGElement\n\t\t\tif (el) return getData(el)\n\t\t\t// vertex dot clicked; its id is the vertex id after this graph's idPrefix\n\t\t\tel = (e.target as SVGElement).closest('g.edges g.edge .v-dot') as SVGElement\n\t\t\tif (el) {\n\t\t\t\treturn data.edgeVertices.get(el.id.slice(data.idPrefix.length))\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\t\tsetSelection(handles: Handle[]) {\n\t\t\t// nodes\n\t\t\tdata.nodes().forEach(n => data.setNodeSelected(n, handles.some(h => h.id == n.id)))\n\t\t\t// dots\n\t\t\tdata.edgeVertices.forEach(d => setDotSelected(d, handles.some(h => h.id == d.id)))\n\t\t\tdata.selectListener(data.nodes().find(n => n.selected))\n\t\t},\n\t\tisSelected(handle: Handle): boolean {\n\t\t\treturn handle.selected\n\t\t},\n\t\tgetSelection(): Handle[] {\n\t\t\tconst ret: Handle[] = data.nodes().filter(n => n.selected)\n\t\t\tdata.edgeVertices.forEach(d => d.selected && ret.push(d))\n\t\t\treturn ret\n\t\t},\n\t\tgetZoom: () => getZoom(data),\n\t\tmoveNode(h: Handle, x: number, y: number) {\n\t\t\tif (data.nodesMap.has(h.id))\n\t\t\t\tdata.moveNode(h as Node, x, y)\n\t\t\telse {\n\t\t\t\t(h as EdgeVertex).auto = false\n\t\t\t\tdata.moveEdgeVertex(h as EdgeVertex, x, y)\n\t\t\t}\n\t\t},\n\t\tboxSelection(box: DOMRect, add) {\n\t\t\t// Box is now already in drawing coordinates, no need to scale\n\t\t\t// nodes\n\t\t\tdata.nodesMap.forEach(n => {\n\t\t\t\tconst inBox = boxesOverlap(uncenterBox(n), box)\n\t\t\t\tif (inBox) {\n\t\t\t\t\t// Toggle selection for elements in the box\n\t\t\t\t\tdata.setNodeSelected(n, !n.selected)\n\t\t\t\t} else if (!add) {\n\t\t\t\t\t// If not holding shift and element is outside box, deselect it\n\t\t\t\t\tdata.setNodeSelected(n, false)\n\t\t\t\t}\n\t\t\t})\n\t\t\t// dots\n\t\t\tdata.edgeVertices.forEach(d => {\n\t\t\t\tconst inBox = insideBox(d, box, false)\n\t\t\t\tif (inBox) {\n\t\t\t\t\t// Toggle selection for elements in the box\n\t\t\t\t\tsetDotSelected(d, !d.selected)\n\t\t\t\t} else if (!add) {\n\t\t\t\t\t// If not holding shift and element is outside box, deselect it\n\t\t\t\t\tsetDotSelected(d, false)\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tdata.selectListener(data.nodes().find(n => n.selected))\n\t\t},\n\t\tupdatePanning: () => updatePanning(data),\n\t}, dragMode)\n\t\n\t// Store cleanup function on the SVG element for later use\n\tconst cleanup = () => {\n\t\teventListeners.forEach(({ element, event, handler }) => {\n\t\t\telement.removeEventListener(event, handler)\n\t\t})\n\t\tif (customInteractionCleanup) {\n\t\t\tcustomInteractionCleanup()\n\t\t}\n\t}\n\t\n\t// Store cleanup function on SVG element\n\t;(svg as any).__cursorInteractionCleanup = cleanup\n}\n\n/** getZoom returns data's current zoom, or 1 before data has been drawn. */\nexport function getZoom(data: GraphData) {\n\tconst el = data.svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return 1\n\t\n\t// Parse zoom from transform attribute to match how we set it\n\tconst transform = el.getAttribute('transform') || ''\n\tconst scaleMatch = transform.match(/scale\\(([^)]+)\\)/)\n\tif (scaleMatch) {\n\t\treturn parseFloat(scaleMatch[1]) || 1\n\t}\n\treturn 1\n}\n\n// svgPadding is now imported as SVG_PADDING from constants.ts\n\n/** setZoom sets data's zoom and keeps its current pan; it does nothing before data is drawn. */\nexport function setZoom(data: GraphData, zoom: number) {\n\tconst el = data.svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return\n\t\n\t// Preserve existing translation when setting zoom\n\tconst currentTransform = getCurrentTransform(data)\n\tel.setAttribute('transform', `translate(${currentTransform.x}, ${currentTransform.y}) scale(${zoom})`)\n\t\n\t// also set panning size\n\tupdatePanning(data)\n}\n\n/**\n * setZoomCentered sets data's zoom while keeping the drawing point under\n * (centerX, centerY) in place, by default the center of the svg's container.\n */\nexport function setZoomCentered(data: GraphData, newZoom: number, centerX?: number, centerY?: number) {\n\tconst svg = data.svg\n\tconst el = svg.querySelector('g.zoom') as SVGGElement\n\tconst oldZoom = getZoom(data)\n\t\n\t// If no center point provided, use viewport center\n\tif (centerX === undefined || centerY === undefined) {\n\t\t// Use the parent container's dimensions for the visible viewport\n\t\t// The SVG might be larger than the visible area due to overflow\n\t\tconst container = svg.parentElement\n\t\tif (container) {\n\t\t\tcenterX = container.clientWidth / 2\n\t\t\tcenterY = container.clientHeight / 2\n\t\t} else {\n\t\t\t// Fallback to SVG dimensions if no parent\n\t\t\tcenterX = svg.clientWidth / 2\n\t\t\tcenterY = svg.clientHeight / 2\n\t\t}\n\t}\n\t\n\t// Get current transform\n\tconst currentTransform = getCurrentTransform(data)\n\t\n\t// Convert screen coordinates to drawing coordinates\n\t// For transform order translate(tx, ty) scale(s):\n\t// screen_point = (drawing_point * scale) + translation\n\t// So: drawing_point = (screen_point - translation) / scale\n\tconst drawingX = (centerX - currentTransform.x) / oldZoom\n\tconst drawingY = (centerY - currentTransform.y) / oldZoom\n\t\n\t// Calculate new translation to keep the same drawing point at the same screen position\n\t// screen_point = (drawing_point * new_scale) + new_translation\n\t// So: new_translation = screen_point - (drawing_point * new_scale)\n\tconst newTranslateX = centerX - (drawingX * newZoom)\n\tconst newTranslateY = centerY - (drawingY * newZoom)\n\t\n\t// Apply the new transform\n\tel.setAttribute('transform', `translate(${newTranslateX}, ${newTranslateY}) scale(${newZoom})`)\n\t\n\t// Update panning\n\tupdatePanning(data)\n}\n\n/** getCurrentTransform returns data's current pan, or (0, 0) before data is drawn. */\nfunction getCurrentTransform(data: GraphData) {\n\tconst el = data.svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return { x: 0, y: 0 }\n\t\n\tconst transform = el.getAttribute('transform') || ''\n\tconst translateMatch = transform.match(/translate\\(([^,]+),([^)]+)\\)/)\n\tif (translateMatch) {\n\t\treturn {\n\t\t\tx: parseFloat(translateMatch[1]) || 0,\n\t\t\ty: parseFloat(translateMatch[2]) || 0\n\t\t}\n\t}\n\treturn { x: 0, y: 0 }\n}\n\n/** updatePanning resizes data's svg to fit its zoomed drawing; it does nothing until the svg is placed. */\nfunction updatePanning(data: GraphData) {\n\tconst svg = data.svg\n\tconst el = svg.querySelector('g.zoom') as SVGGElement\n\tif (!el) return\n\tconst bb = el.getBBox()\n\tconst zoom = getZoom(data)\n\tif (!svg.parentElement) return\n\tconst w = Math.max(svg.parentElement.clientWidth / zoom, bb.x + bb.width + SVG_PADDING)\n\tconst h = Math.max(svg.parentElement.clientHeight / zoom, bb.y + bb.height + SVG_PADDING)\n\tsvg.setAttribute('width', String(w * zoom))\n\tsvg.setAttribute('height', String(h * zoom))\n\t\n\t// Note: View state saving removed from here to prevent interference with reset/fit functions\n\t// View state is now only saved on user interactions and page unload\n}\n\n// Optimized version that uses pre-calculated content bounds instead of expensive getBBox()\nfunction updatePanningOptimized(graphData: GraphData) {\n\tconst svg = graphData.svg\n\tconst bb = graphData.calculateContentBounds() // Use already calculated bounds\n\tconst zoom = getZoom(graphData)\n\tconst w = Math.max(svg.parentElement.clientWidth / zoom, bb.x + bb.width + SVG_PADDING)\n\tconst h = Math.max(svg.parentElement.clientHeight / zoom, bb.y + bb.height + SVG_PADDING)\n\tsvg.setAttribute('width', String(w * zoom))\n\tsvg.setAttribute('height', String(h * zoom))\n}\n\n/** getZoomAuto returns the zoom that fits graphData's content in its svg's container. */\nexport const getZoomAuto = (graphData: GraphData) => {\n\t// Use proper content bounds calculation\n\tconst contentBounds = graphData.calculateContentBounds()\n\tconst viewportWidth = graphData.svg.parentElement?.clientWidth || 800\n\tconst viewportHeight = graphData.svg.parentElement?.clientHeight || 600\n\t\n\t// Add padding around content\n\tconst padding = 40\n\t\n\t// Calculate zoom to fit content with padding\n\tconst zoomX = (viewportWidth - padding * 2) / contentBounds.width\n\tconst zoomY = (viewportHeight - padding * 2) / contentBounds.height\n\tconst zoom = Math.min(zoomX, zoomY)\n\t\n\t// Clamp zoom between reasonable bounds\n\treturn Math.max(Math.min(zoom, 2), 0.1)\n}\n\nconst setBorderStyle = (el: SVGElement, style: string) => {\n\tif (style == 'Dashed') el.setAttribute('stroke-dasharray', '4')\n\telse if (style == 'Dotted') el.setAttribute('stroke-dasharray', '2')\n}\n\n// View state persistence - similar to undo cache but for zoom/pan\nconst viewStateCache = new Map();\n\n// Save data's current view state (zoom and pan) under its view id\nexport function saveViewState(data: GraphData) {\n\tconst zoom = getZoom(data);\n\tconst transform = getCurrentTransform(data);\n\t\n\tconst state = {\n\t\tzoom,\n\t\ttransform: { x: transform.x, y: transform.y }\n\t};\n\t\n\tviewStateCache.set(data.id, state);\n}\n\n// Restore the view state saved for data's view id, if it exists\nexport function restoreViewState(data: GraphData): boolean {\n\tif (!viewStateCache.has(data.id)) {\n\t\treturn false;\n\t}\n\t\n\tconst state = viewStateCache.get(data.id);\n\tif (!state) {\n\t\treturn false;\n\t}\n\t\n\t// Restore zoom and transform\n\tconst zoomGroup = data.svg.querySelector('g.zoom') as SVGGElement;\n\tif (zoomGroup) {\n\t\tzoomGroup.setAttribute('transform', `scale(${state.zoom}) translate(${state.transform.x}, ${state.transform.y})`);\n\t\tupdatePanning(data);\n\t}\n\t\n\treturn true;\n}\n\n// Clear the view state saved for data's view id\nexport function clearViewState(data: GraphData) {\n\tviewStateCache.delete(data.id);\n}\n","import fontFaces from \"../fonts.css?inline\";\nimport fontLicense from \"@fontsource/inter/LICENSE?raw\";\n\n/**\n * defs returns one graph's shared SVG definitions. Every id starts with prefix,\n * the graph's idPrefix, so definitions of graphs on the same page stay distinct.\n */\nexport const defs = (prefix: string) => `\n\n\t\n\t${fontLicense.replace(/&/g, \"&\").replace(/\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n`\n","// This file is the only owner of automatic positions. It gives ELK the exact\n// measured sizes, reads ELK's complete result, and does not repair that result.\n\nimport type {\n\tElkExtendedEdge,\n\tElkLabel,\n\tElkNode,\n\tElkPoint,\n} from \"elkjs/lib/elk-api\";\n\nimport {\n\tMeasuredDiagram,\n\tMeasuredEdge,\n\tMeasuredGroup,\n\tMeasuredNode,\n\tPoint,\n\tResolvedEdge,\n\tResolvedGroup,\n\tResolvedLayout,\n\tResolvedNode,\n} from \"./geometry\";\n\n/** AutomaticLayoutOptions are the choices a caller may make before layout. */\nexport interface AutomaticLayoutOptions {\n\tdirection: \"UP\" | \"DOWN\" | \"LEFT\" | \"RIGHT\";\n\tnodeSpacing: number;\n\tlayerSpacing: number;\n}\n\nconst defaultOptions: AutomaticLayoutOptions = {\n\tdirection: \"DOWN\",\n\tnodeSpacing: 80,\n\tlayerSpacing: 80,\n};\n\n/**\n * resolveAutomatic runs one compound ELK layout with exact measured sizes.\n * ELK errors and incomplete results are returned to the caller unchanged.\n */\nexport async function resolveAutomatic(\n\tdiagram: MeasuredDiagram,\n\toptions: Partial = {},\n): Promise {\n\tconst settings = {...defaultOptions, ...options};\n\tconst graph = buildLayoutTree(diagram, settings);\n\tconst ELK = await import(\"elkjs/lib/elk.bundled.js\").then(module => module.default);\n\tconst elk = new ELK();\n\tconst result = await elk.layout(graph);\n\treturn readResolvedLayout(diagram, result);\n}\n\n/**\n * buildLayoutTree creates one ELK tree. Nodes belong to their declared group,\n * groups belong to their declared parent, and each edge belongs to the nearest\n * group shared by both connected nodes.\n */\nfunction buildLayoutTree(\n\tdiagram: MeasuredDiagram,\n\toptions: AutomaticLayoutOptions,\n): ElkNode {\n\tconst nodes = new Map(diagram.nodes.map(node => [node.id, node]));\n\tconst groups = new Map(diagram.groups.map(group => [group.id, group]));\n\tcheckMeasuredLinks(diagram, nodes, groups);\n\n\tconst childrenByParent = new Map();\n\tfor (const node of diagram.nodes) {\n\t\tappend(childrenByParent, node.parentId, node);\n\t}\n\tconst groupsByParent = new Map();\n\tfor (const group of diagram.groups) {\n\t\tappend(groupsByParent, group.parentId, group);\n\t}\n\n\tconst elkGroups = new Map();\n\tconst buildGroup = (group: MeasuredGroup): ElkNode => {\n\t\tconst child: ElkNode = {\n\t\t\tid: group.id,\n\t\t\tchildren: [\n\t\t\t\t...(groupsByParent.get(group.id) ?? []).map(buildGroup),\n\t\t\t\t...(childrenByParent.get(group.id) ?? []).map(buildNode),\n\t\t\t],\n\t\t\tedges: [],\n\t\t\tlabels: [{\n\t\t\t\ttext: group.id,\n\t\t\t\twidth: group.titleSize.width,\n\t\t\t\theight: group.titleSize.height,\n\t\t\t}],\n\t\t\tlayoutOptions: groupLayoutOptions(options, group.titleSize.height),\n\t\t};\n\t\telkGroups.set(group.id, child);\n\t\treturn child;\n\t};\n\n\tconst root: ElkNode = {\n\t\tid: diagram.id,\n\t\tchildren: [\n\t\t\t...(groupsByParent.get(undefined) ?? []).map(buildGroup),\n\t\t\t...(childrenByParent.get(undefined) ?? []).map(buildNode),\n\t\t],\n\t\tedges: [],\n\t\tlayoutOptions: rootLayoutOptions(options),\n\t};\n\n\tfor (const edge of diagram.edges) {\n\t\tconst owner = lowestCommonGroup(edge, nodes, groups);\n\t\tconst container = owner ? elkGroups.get(owner) : root;\n\t\tif (!container) {\n\t\t\tthrow new Error(`edge ${edge.id} has missing layout group ${owner}`);\n\t\t}\n\t\tcontainer.edges?.push(buildEdge(edge));\n\t}\n\treturn root;\n}\n\n/** buildNode passes the measured node size to ELK without padding or guesses. */\nfunction buildNode(node: MeasuredNode): ElkNode {\n\treturn {\n\t\tid: node.id,\n\t\twidth: node.size.width,\n\t\theight: node.size.height,\n\t\tlayoutOptions: {\n\t\t\t\"elk.nodeSize.constraints\": \"FIXED_SIZE\",\n\t\t\t\"elk.portConstraints\": \"FREE\",\n\t\t},\n\t};\n}\n\n/** buildEdge passes the exact label size and stable endpoint IDs to ELK. */\nfunction buildEdge(edge: MeasuredEdge): ElkExtendedEdge {\n\treturn {\n\t\tid: edge.id,\n\t\tsources: [edge.sourceId],\n\t\ttargets: [edge.targetId],\n\t\tlabels: edge.labelSize ? [{\n\t\t\ttext: edge.id,\n\t\t\twidth: edge.labelSize.width,\n\t\t\theight: edge.labelSize.height,\n\t\t\tlayoutOptions: {\n\t\t\t\t\"elk.edgeLabels.inline\": \"false\",\n\t\t\t\t\"elk.edgeLabels.placement\": \"CENTER\",\n\t\t\t},\n\t\t}] : [],\n\t};\n}\n\n/** rootLayoutOptions set the rules shared by the full compound layout. */\nfunction rootLayoutOptions(options: AutomaticLayoutOptions): Record {\n\treturn {\n\t\t\"elk.algorithm\": \"layered\",\n\t\t\"elk.direction\": options.direction,\n\t\t\"elk.edgeRouting\": \"ORTHOGONAL\",\n\t\t\"elk.hierarchyHandling\": \"INCLUDE_CHILDREN\",\n\t\t\"elk.padding\": \"[top=40,left=40,bottom=40,right=40]\",\n\t\t\"elk.spacing.nodeNode\": String(options.nodeSpacing),\n\t\t\"elk.spacing.componentComponent\": String(options.nodeSpacing),\n\t\t\"elk.layered.spacing.nodeNodeBetweenLayers\": String(options.layerSpacing),\n\t\t\"elk.layered.spacing.edgeNodeBetweenLayers\": \"30\",\n\t\t\"elk.layered.spacing.edgeEdgeBetweenLayers\": \"20\",\n\t\t\"elk.layered.nodePlacement.strategy\": \"NETWORK_SIMPLEX\",\n\t\t\"elk.layered.nodePlacement.favorStraightEdges\": \"true\",\n\t\t\"elk.layered.crossingMinimization.strategy\": \"LAYER_SWEEP\",\n\t\t\"elk.layered.unnecessaryBendpoints\": \"true\",\n\t\t\"elk.edgeLabels.inline\": \"false\",\n\t\t\"elk.edgeLabels.avoidOverlap\": \"true\",\n\t\t\"elk.layered.edgeLabels.sideSelection\": \"SMART_DOWN\",\n\t\t\"elk.spacing.edgeLabel\": \"12\",\n\t};\n}\n\n/** groupLayoutOptions reserve title space and keep each group's children together. */\nfunction groupLayoutOptions(\n\toptions: AutomaticLayoutOptions,\n\ttitleHeight: number,\n): Record {\n\treturn {\n\t\t...rootLayoutOptions(options),\n\t\t\"elk.padding\": `[top=${titleHeight + 30},left=30,bottom=30,right=30]`,\n\t\t\"elk.nodeLabels.placement\": \"[H_LEFT,V_TOP,INSIDE]\",\n\t\t\"elk.spacing.labelNode\": \"10\",\n\t};\n}\n\n/**\n * checkMeasuredLinks rejects broken ownership and endpoints before calling ELK,\n * so ELK never has to guess what the model meant.\n */\nfunction checkMeasuredLinks(\n\tdiagram: MeasuredDiagram,\n\tnodes: Map,\n\tgroups: Map,\n): void {\n\tfor (const node of diagram.nodes) {\n\t\tif (node.parentId && !groups.has(node.parentId)) {\n\t\t\tthrow new Error(`node ${node.id} has missing parent group ${node.parentId}`);\n\t\t}\n\t}\n\tfor (const group of diagram.groups) {\n\t\tif (group.parentId && !groups.has(group.parentId)) {\n\t\t\tthrow new Error(`group ${group.id} has missing parent group ${group.parentId}`);\n\t\t}\n\t}\n\tfor (const edge of diagram.edges) {\n\t\tif (!nodes.has(edge.sourceId) || !nodes.has(edge.targetId)) {\n\t\t\tthrow new Error(\n\t\t\t\t`edge ${edge.id} connects missing node ${edge.sourceId} or ${edge.targetId}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** lowestCommonGroup finds the nearest boundary that contains both endpoints. */\nfunction lowestCommonGroup(\n\tedge: MeasuredEdge,\n\tnodes: Map,\n\tgroups: Map,\n): string | undefined {\n\tconst sourceGroups = parentGroups(nodes.get(edge.sourceId)?.parentId, groups);\n\tconst targetGroups = new Set(parentGroups(nodes.get(edge.targetId)?.parentId, groups));\n\treturn sourceGroups.find(group => targetGroups.has(group));\n}\n\n/** parentGroups returns parent IDs from nearest to farthest. */\nfunction parentGroups(\n\tparentId: string | undefined,\n\tgroups: Map,\n): string[] {\n\tconst result: string[] = [];\n\tlet current = parentId;\n\twhile (current) {\n\t\tresult.push(current);\n\t\tcurrent = groups.get(current)?.parentId;\n\t}\n\treturn result;\n}\n\n/** readResolvedLayout changes ELK's parent-relative values into diagram positions. */\nfunction readResolvedLayout(\n\tdiagram: MeasuredDiagram,\n\troot: ElkNode,\n): ResolvedLayout {\n\tif (root.width === undefined || root.height === undefined) {\n\t\tthrow new Error(`ELK did not size diagram ${diagram.id}`);\n\t}\n\tconst nodes: ResolvedNode[] = [];\n\tconst groups: ResolvedGroup[] = [];\n\tconst edges: ResolvedEdge[] = [];\n\tconst measuredNodes = new Map(diagram.nodes.map(node => [node.id, node]));\n\tconst measuredGroups = new Map(diagram.groups.map(group => [group.id, group]));\n\n\treadContainer(\n\t\troot,\n\t\t0,\n\t\t0,\n\t\tmeasuredNodes,\n\t\tmeasuredGroups,\n\t\tnodes,\n\t\tgroups,\n\t\tedges,\n\t);\n\treturn {\n\t\tdiagramId: diagram.id,\n\t\tbounds: {x: 0, y: 0, width: root.width, height: root.height},\n\t\tnodes,\n\t\tgroups,\n\t\tedges,\n\t};\n}\n\n/**\n * readContainer walks one ELK group, adding its parent's position exactly once\n * to each child, edge point, and label box.\n */\nfunction readContainer(\n\tcontainer: ElkNode,\n\tparentX: number,\n\tparentY: number,\n\tmeasuredNodes: Map,\n\tmeasuredGroups: Map,\n\tnodes: ResolvedNode[],\n\tgroups: ResolvedGroup[],\n\tedges: ResolvedEdge[],\n): void {\n\tconst containerX = parentX + (container.x ?? 0);\n\tconst containerY = parentY + (container.y ?? 0);\n\tfor (const child of container.children ?? []) {\n\t\tconst childX = containerX + requiredNumber(child.x, child.id, \"x\");\n\t\tconst childY = containerY + requiredNumber(child.y, child.id, \"y\");\n\t\tconst width = requiredNumber(child.width, child.id, \"width\");\n\t\tconst height = requiredNumber(child.height, child.id, \"height\");\n\t\tconst measuredNode = measuredNodes.get(child.id);\n\t\tif (measuredNode) {\n\t\t\tnodes.push({\n\t\t\t\tid: child.id,\n\t\t\t\tparentId: measuredNode.parentId,\n\t\t\t\tbounds: {x: childX, y: childY, width, height},\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst measuredGroup = measuredGroups.get(child.id);\n\t\tif (!measuredGroup) {\n\t\t\tthrow new Error(`ELK returned unknown node ${child.id}`);\n\t\t}\n\t\tconst label = requiredLabel(child.labels?.[0], child.id);\n\t\tgroups.push({\n\t\t\tid: child.id,\n\t\t\tparentId: measuredGroup.parentId,\n\t\t\tbounds: {x: childX, y: childY, width, height},\n\t\t\ttitleBounds: {\n\t\t\t\tx: childX + requiredNumber(label.x, child.id, \"title x\"),\n\t\t\t\ty: childY + requiredNumber(label.y, child.id, \"title y\"),\n\t\t\t\twidth: requiredNumber(label.width, child.id, \"title width\"),\n\t\t\t\theight: requiredNumber(label.height, child.id, \"title height\"),\n\t\t\t},\n\t\t});\n\t\treadContainer(\n\t\t\tchild,\n\t\t\tcontainerX,\n\t\t\tcontainerY,\n\t\t\tmeasuredNodes,\n\t\t\tmeasuredGroups,\n\t\t\tnodes,\n\t\t\tgroups,\n\t\t\tedges,\n\t\t);\n\t}\n\tfor (const edge of container.edges ?? []) {\n\t\tedges.push(readEdge(edge, containerX, containerY));\n\t}\n}\n\n/** readEdge copies every ELK section and label without choosing new positions. */\nfunction readEdge(edge: ElkExtendedEdge, offsetX: number, offsetY: number): ResolvedEdge {\n\tconst sections = (edge.sections ?? []).map(section => [\n\t\taddOffset(section.startPoint, offsetX, offsetY),\n\t\t...(section.bendPoints ?? []).map(point => addOffset(point, offsetX, offsetY)),\n\t\taddOffset(section.endPoint, offsetX, offsetY),\n\t]);\n\tconst label = edge.labels?.[0];\n\treturn {\n\t\tid: edge.id,\n\t\tsourceId: requiredEndpoint(edge.sources, edge.id, \"source\"),\n\t\ttargetId: requiredEndpoint(edge.targets, edge.id, \"target\"),\n\t\tsections,\n\t\tlabelBounds: label ? {\n\t\t\tx: offsetX + requiredNumber(label.x, edge.id, \"label x\"),\n\t\t\ty: offsetY + requiredNumber(label.y, edge.id, \"label y\"),\n\t\t\twidth: requiredNumber(label.width, edge.id, \"label width\"),\n\t\t\theight: requiredNumber(label.height, edge.id, \"label height\"),\n\t\t} : undefined,\n\t};\n}\n\n/** addOffset changes one parent-relative ELK point into a diagram point. */\nfunction addOffset(point: ElkPoint, offsetX: number, offsetY: number): Point {\n\treturn {x: offsetX + point.x, y: offsetY + point.y};\n}\n\n/** requiredNumber rejects incomplete ELK output instead of filling in zero. */\nfunction requiredNumber(\n\tvalue: number | undefined,\n\telementId: string,\n\tfield: string,\n): number {\n\tif (value === undefined) {\n\t\tthrow new Error(`ELK omitted ${field} for ${elementId}`);\n\t}\n\treturn value;\n}\n\n/** requiredEndpoint requires each MDL relationship to have exactly one endpoint. */\nfunction requiredEndpoint(\n\tendpoints: string[],\n\tedgeId: string,\n\tfield: string,\n): string {\n\tif (endpoints.length !== 1) {\n\t\tthrow new Error(`ELK returned ${endpoints.length} ${field}s for edge ${edgeId}`);\n\t}\n\treturn endpoints[0];\n}\n\n/** requiredLabel rejects a group whose measured title was not placed by ELK. */\nfunction requiredLabel(label: ElkLabel | undefined, groupId: string): ElkLabel {\n\tif (!label) {\n\t\tthrow new Error(`ELK omitted title for group ${groupId}`);\n\t}\n\treturn label;\n}\n\n/** append adds a child to one parent entry while keeping model order. */\nfunction append(\n\titems: Map,\n\tparentId: string | undefined,\n\titem: T,\n): void {\n\tconst siblings = items.get(parentId) ?? [];\n\tsiblings.push(item);\n\titems.set(parentId, siblings);\n}\n","// This file connects the editable graph to the layout pipeline. It measures\n// the current SVG once, asks ELK for one complete answer, validates that answer,\n// and returns positions without changing them.\n\nimport {resolveAutomatic} from \"./automatic-layout\";\nimport {\n\tMeasuredDiagram,\n\tMeasuredEdge,\n\tMeasuredGroup,\n\tMeasuredNode,\n\tRect,\n\tResolvedLayout,\n\tValidatedLayout,\n\tvalidateResolvedLayout,\n} from \"./geometry\";\nimport {Edge, GraphData, Group, LayoutDirection, Node} from \"./graph\";\nimport {calculateEdgeVertices} from \"./edge-utils\";\nimport {resolveManual} from \"./manual-layout\";\n\n/** LayoutOptions are the explicit choices available to editor and CLI callers. */\nexport interface LayoutOptions {\n\tdirection?: LayoutDirection;\n\tnodeSpacing?: number;\n\tlayerSpacing?: number;\n\tcompactLayout?: boolean;\n}\n\n/** GraphLayout carries checked positions back to the editable graph. */\nexport interface GraphLayout {\n\tvalidated: ValidatedLayout;\n\tnodes: Array<{id: string; x: number; y: number}>;\n\tgroups: Array<{id: string; bounds: Rect; titleBounds: Rect}>;\n\tedges: Array<{\n\t\tid: string;\n\t\tsections: Array>;\n\t\tlabelBounds?: Rect;\n\t}>;\n}\n\n/**\n * autoLayout measures, lays out, and validates a graph. It does not catch\n * errors because callers must not save a diagram after any failed step.\n */\nexport async function autoLayout(\n\tgraph: GraphData,\n\toptions: LayoutOptions = {},\n): Promise {\n\tawait document.fonts.ready;\n\tconst measured = measureGraph(graph);\n\tconst spacing = options.compactLayout ? 56 : 80;\n\tconst resolved = await resolveAutomatic(measured, {\n\t\tdirection: options.direction ?? graph.layoutDirection ?? \"DOWN\",\n\t\tnodeSpacing: options.nodeSpacing ?? spacing,\n\t\tlayerSpacing: options.layerSpacing ?? spacing,\n\t});\n\tconst validated = validateResolvedLayout(measured, resolved);\n\tconst measuredNodes = new Map(measured.nodes.map(node => [node.id, node]));\n\treturn {\n\t\tvalidated,\n\t\tnodes: validated.nodes.map(node => {\n\t\t\tconst measuredNode = measuredNodes.get(node.id);\n\t\t\tif (!measuredNode) {\n\t\t\t\tthrow new Error(`validated layout contains unknown node ${node.id}`);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tid: node.id,\n\t\t\t\tx: node.bounds.x + measuredNode.centerOffset.x,\n\t\t\t\ty: node.bounds.y + measuredNode.centerOffset.y,\n\t\t\t};\n\t\t}),\n\t\tgroups: validated.groups.map(group => ({\n\t\t\tid: group.id,\n\t\t\tbounds: group.bounds,\n\t\t\ttitleBounds: group.titleBounds,\n\t\t})),\n\t\tedges: validated.edges.map(edge => ({\n\t\t\tid: edge.id,\n\t\t\tsections: edge.sections,\n\t\t\tlabelBounds: edge.labelBounds,\n\t\t})),\n\t};\n}\n\n/**\n * validateCurrentLayout adapts the fully drawn editor state into the manual\n * layout contract. It never reads automatic positions to fill missing data.\n */\nexport function validateCurrentLayout(graph: GraphData): ValidatedLayout {\n\tconst measured = measureGraph(graph);\n\tconst measuredNodes = new Map(measured.nodes.map(node => [node.id, node]));\n\tconst nodes = graph.nodes().map(node => {\n\t\tconst measuredNode = measuredNodes.get(node.id);\n\t\tif (!measuredNode) {\n\t\t\tthrow new Error(`measured diagram omitted node ${node.id}`);\n\t\t}\n\t\treturn {\n\t\t\tid: node.id,\n\t\t\tparentId: measuredNode.parentId,\n\t\t\tbounds: {\n\t\t\t\tx: node.x - measuredNode.centerOffset.x,\n\t\t\t\ty: node.y - measuredNode.centerOffset.y,\n\t\t\t\t...measuredNode.size,\n\t\t\t},\n\t\t};\n\t});\n\tconst groups = Array.from(graph.groupsMap.values()).map(group => {\n\t\tif (!group.ref?.isConnected) {\n\t\t\tthrow new Error(`group ${group.id} must be drawn before saving`);\n\t\t}\n\t\tconst boundary = group.ref.querySelector(\"rect\");\n\t\tconst title = group.ref.querySelector(\"text\");\n\t\tif (!(boundary instanceof SVGGraphicsElement) || !(title instanceof SVGGraphicsElement)) {\n\t\t\tthrow new Error(`group ${group.id} is missing its boundary or title`);\n\t\t}\n\t\treturn {\n\t\t\tid: group.id,\n\t\t\tparentId: measured.groups.find(candidate => candidate.id === group.id)?.parentId,\n\t\t\tbounds: copyBox(boundary.getBBox()),\n\t\t\ttitleBounds: copyBox(title.getBBox()),\n\t\t};\n\t});\n\tconst edges = graph.edges.map(edge => {\n\t\tconst sections = edge.layoutSections ?? [calculateEdgeVertices(edge)];\n\t\tconst labelBounds = edge.layoutLabelBounds ?? edge.labelBounds;\n\t\tif (edge.label.trim().length > 0 && !labelBounds) {\n\t\t\tthrow new Error(`edge ${edge.id} is missing its label position`);\n\t\t}\n\t\treturn {\n\t\t\tid: edge.id,\n\t\t\tsourceId: edge.from.id,\n\t\t\ttargetId: edge.to.id,\n\t\t\tsections,\n\t\t\tlabelBounds: labelBounds ? {...labelBounds} : undefined,\n\t\t};\n\t});\n\tconst snapshot: ResolvedLayout = {\n\t\tdiagramId: graph.id,\n\t\tbounds: contentBounds(nodes.map(node => node.bounds), groups, edges),\n\t\tnodes,\n\t\tgroups,\n\t\tedges,\n\t};\n\treturn resolveManual(measured, snapshot);\n}\n\n/**\n * measureGraph reads the exact node and label boxes already drawn by the\n * browser. Parent IDs come only from the model's declared groups.\n */\nfunction measureGraph(graph: GraphData): MeasuredDiagram {\n\tconst {nodeParents, groupParents} = declaredParents(graph);\n\treturn {\n\t\tid: graph.id,\n\t\tnodes: graph.nodes().map(node => measureNode(node, nodeParents.get(node.id))),\n\t\tgroups: Array.from(graph.groupsMap.values()).map(group =>\n\t\t\tmeasureGroup(group, groupParents.get(group.id)),\n\t\t),\n\t\tedges: graph.edges.map(measureEdge),\n\t};\n}\n\n/** measureNode returns the complete box drawn for one node and its center. */\nfunction measureNode(node: Node, parentId: string | undefined): MeasuredNode {\n\tif (!node.ref?.isConnected) {\n\t\tthrow new Error(`node ${node.id} must be drawn before layout`);\n\t}\n\tconst bounds = node.ref.getBBox();\n\tcheckMeasuredBox(node.id, bounds);\n\treturn {\n\t\tid: node.id,\n\t\tparentId,\n\t\tsize: {width: bounds.width, height: bounds.height},\n\t\tcontentSize: {width: bounds.width, height: bounds.height},\n\t\tcenterOffset: {x: -bounds.x, y: -bounds.y},\n\t\tshape: node.style.shape ?? \"Box\",\n\t};\n}\n\n/** measureGroup reads the title box already drawn by the browser. */\nfunction measureGroup(group: Group, parentId: string | undefined): MeasuredGroup {\n\tif (!group.ref?.isConnected) {\n\t\tthrow new Error(`group ${group.id} must be drawn before layout`);\n\t}\n\tconst title = group.ref.querySelector(\"text\");\n\tif (!(title instanceof SVGGraphicsElement)) {\n\t\tthrow new Error(`group ${group.id} is missing its drawn title`);\n\t}\n\tconst bounds = title.getBBox();\n\tcheckMeasuredBox(group.id, bounds);\n\treturn {\n\t\tid: group.id,\n\t\tparentId,\n\t\ttitleSize: {width: bounds.width, height: bounds.height},\n\t};\n}\n\n/** measureEdge uses the label background that the current SVG already drew. */\nfunction measureEdge(edge: Edge): MeasuredEdge {\n\tconst hasLabel = edge.label.trim().length > 0;\n\tif (hasLabel && !edge.labelBounds) {\n\t\tthrow new Error(`edge ${edge.id} must be drawn before layout`);\n\t}\n\treturn {\n\t\tid: edge.id,\n\t\tsourceId: edge.from.id,\n\t\ttargetId: edge.to.id,\n\t\tlabelSize: hasLabel ? {\n\t\t\twidth: edge.labelBounds?.width ?? 0,\n\t\t\theight: edge.labelBounds?.height ?? 0,\n\t\t} : undefined,\n\t};\n}\n\n/**\n * declaredParents records model ownership and rejects elements that appear in\n * more than one group. Visual position never decides ownership.\n */\nfunction declaredParents(graph: GraphData): {\n\tnodeParents: Map;\n\tgroupParents: Map;\n} {\n\tconst nodeParents = new Map();\n\tconst groupParents = new Map();\n\tfor (const group of graph.groupsMap.values()) {\n\t\tfor (const member of group.nodes) {\n\t\t\tconst parents = isGroup(member) ? groupParents : nodeParents;\n\t\t\tconst existing = parents.get(member.id);\n\t\t\tif (existing && existing !== group.id) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${isGroup(member) ? \"group\" : \"node\"} ${member.id} belongs to both ` +\n\t\t\t\t\t`${existing} and ${group.id}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tparents.set(member.id, group.id);\n\t\t}\n\t}\n\treturn {nodeParents, groupParents};\n}\n\n/** checkMeasuredBox rejects missing or invalid browser measurements. */\nfunction checkMeasuredBox(id: string, box: Rect): void {\n\tif (\n\t\t!Number.isFinite(box.x) ||\n\t\t!Number.isFinite(box.y) ||\n\t\t!Number.isFinite(box.width) ||\n\t\t!Number.isFinite(box.height) ||\n\t\tbox.width <= 0 ||\n\t\tbox.height <= 0\n\t) {\n\t\tthrow new Error(`browser returned invalid measured box for ${id}`);\n\t}\n}\n\n/** contentBounds returns the smallest box that contains all drawn geometry. */\nfunction contentBounds(\n\tnodes: Rect[],\n\tgroups: Array<{bounds: Rect; titleBounds: Rect}>,\n\tedges: Array<{sections: Array>; labelBounds?: Rect}>,\n): Rect {\n\tconst boxes = [\n\t\t...nodes,\n\t\t...groups.flatMap(group => [group.bounds, group.titleBounds]),\n\t\t...edges.flatMap(edge => edge.labelBounds ? [edge.labelBounds] : []),\n\t];\n\tconst points = edges.flatMap(edge => edge.sections.flat());\n\tif (boxes.length === 0 && points.length === 0) {\n\t\treturn {x: 0, y: 0, width: 0, height: 0};\n\t}\n\tconst left = Math.min(\n\t\t...boxes.map(box => box.x),\n\t\t...points.map(point => point.x),\n\t);\n\tconst top = Math.min(\n\t\t...boxes.map(box => box.y),\n\t\t...points.map(point => point.y),\n\t);\n\tconst right = Math.max(\n\t\t...boxes.map(box => box.x + box.width),\n\t\t...points.map(point => point.x),\n\t);\n\tconst bottom = Math.max(\n\t\t...boxes.map(box => box.y + box.height),\n\t\t...points.map(point => point.y),\n\t);\n\treturn {x: left, y: top, width: right - left, height: bottom - top};\n}\n\n/** copyBox copies the browser's read-only SVG box into the layout contract. */\nfunction copyBox(box: DOMRect): Rect {\n\treturn {x: box.x, y: box.y, width: box.width, height: box.height};\n}\n\n/** isGroup tells group boundaries from nodes without using display names. */\nfunction isGroup(member: Node | Group): member is Group {\n\treturn \"nodes\" in member;\n}\n","// Manual layout has its own entry point. It never fills missing positions from\n// automatic layout and never changes the positions a user authored.\n\nimport {\n\tMeasuredDiagram,\n\tResolvedLayout,\n\tValidatedLayout,\n\tvalidateResolvedLayout,\n} from \"./geometry\";\n\n/**\n * resolveManual checks one complete saved layout against the current measured\n * diagram. Missing or old IDs, incomplete routes, and collisions are errors.\n */\nexport function resolveManual(\n\tmeasured: MeasuredDiagram,\n\tcompleteSnapshot: ResolvedLayout,\n): ValidatedLayout {\n\treturn validateResolvedLayout(measured, completeSnapshot);\n}\n","type TextAttributes = Record;\n\ninterface TextSize {\n\twidth: number;\n\theight: number;\n}\n\n/** WrappedText contains the exact lines and widest rendered line. */\nexport interface WrappedText {\n\tlines: string[];\n\tmaxW: number;\n}\n\nconst measuredText = new Map();\nlet measurementSVG: SVGSVGElement | undefined;\n\n/** loadDiagramFonts completes local font loading before text is wrapped or measured. */\nexport async function loadDiagramFonts(): Promise {\n\tawait Promise.all([400, 600, 700].map(weight => document.fonts.load(`${weight} 22px Inter`)));\n\tawait document.fonts.ready;\n}\n\n/**\n * measureSVGText returns the browser's rendered text size. Results are cached\n * because node and edge layout often measures the same words many times.\n */\nexport function measureSVGText(text: string, attrs: TextAttributes): TextSize {\n\tconst key = measurementKey(text, attrs);\n\tconst cached = measuredText.get(key);\n\tif (cached) {\n\t\treturn cached;\n\t}\n\n\tconst node = document.createElementNS(\"http://www.w3.org/2000/svg\", \"text\");\n\tnode.setAttribute(\"x\", \"0\");\n\tnode.setAttribute(\"y\", \"0\");\n\tfor (const [name, value] of Object.entries(attrs)) {\n\t\tnode.setAttribute(name, value);\n\t}\n\tnode.textContent = text;\n\n\tconst svg = getMeasurementSVG();\n\tsvg.appendChild(node);\n\tconst bounds = node.getBBox();\n\tnode.remove();\n\tconst size = {width: bounds.width, height: bounds.height};\n\tmeasuredText.set(key, size);\n\treturn size;\n}\n\n/**\n * svgTextWrap splits text into lines that fit the given width. It uses the\n * same browser text sizes that SVG drawing uses.\n */\nexport function svgTextWrap(\n\ttext: string,\n\twidth: number,\n\tattrs: TextAttributes,\n): WrappedText {\n\tlet maxW = 0;\n\tconst lines = text.trim().split(\"\\n\").flatMap(paragraph => {\n\t\tconst paragraphLines: string[] = [];\n\t\tlet currentLine: string[] = [];\n\t\tfor (const word of paragraph.trim().split(/\\s+/)) {\n\t\t\tif (measureSVGText(word, attrs).width > width) {\n\t\t\t\tif (currentLine.length > 0) {\n\t\t\t\t\tparagraphLines.push(currentLine.join(\" \"));\n\t\t\t\t\tcurrentLine = [];\n\t\t\t\t}\n\t\t\t\tconst parts = breakLongWord(word, width, attrs);\n\t\t\t\tfor (const part of parts.slice(0, -1)) {\n\t\t\t\t\tparagraphLines.push(part);\n\t\t\t\t\tmaxW = Math.max(maxW, measureSVGText(part, attrs).width);\n\t\t\t\t}\n\t\t\t\tcurrentLine = parts.slice(-1);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst nextLine = [...currentLine, word];\n\t\t\tconst size = measureSVGText(nextLine.join(\" \"), attrs);\n\t\t\tif (size.width > width && currentLine.length > 0) {\n\t\t\t\tparagraphLines.push(currentLine.join(\" \"));\n\t\t\t\tcurrentLine = [word];\n\t\t\t} else {\n\t\t\t\tmaxW = Math.max(maxW, size.width);\n\t\t\t\tcurrentLine = nextLine;\n\t\t\t}\n\t\t}\n\t\tif (currentLine.length > 0) {\n\t\t\tconst line = currentLine.join(\" \");\n\t\t\tparagraphLines.push(line);\n\t\t\tmaxW = Math.max(maxW, measureSVGText(line, attrs).width);\n\t\t}\n\t\treturn paragraphLines;\n\t});\n\treturn {lines, maxW};\n}\n\n/** getMeasurementSVG creates the single hidden SVG used for text measurement. */\nfunction getMeasurementSVG(): SVGSVGElement {\n\tif (measurementSVG?.isConnected) {\n\t\treturn measurementSVG;\n\t}\n\tmeasurementSVG = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n\tmeasurementSVG.setAttribute(\"aria-hidden\", \"true\");\n\tmeasurementSVG.style.position = \"absolute\";\n\tmeasurementSVG.style.visibility = \"hidden\";\n\tmeasurementSVG.style.pointerEvents = \"none\";\n\tdocument.body.appendChild(measurementSVG);\n\treturn measurementSVG;\n}\n\n/** measurementKey gives equal text and font settings the same cache entry. */\nfunction measurementKey(text: string, attrs: TextAttributes): string {\n\tconst attributes = Object.entries(attrs).sort(([first], [second]) =>\n\t\tfirst.localeCompare(second),\n\t);\n\treturn JSON.stringify([text, attributes]);\n}\n\n/** breakLongWord splits one word only when it cannot fit on an empty line. */\nfunction breakLongWord(\n\tword: string,\n\tmaxWidth: number,\n\tattrs: TextAttributes,\n): string[] {\n\tconst parts: string[] = [];\n\tlet currentPart = \"\";\n\tfor (const character of word) {\n\t\tconst nextPart = currentPart + character;\n\t\tif (measureSVGText(nextPart, attrs).width > maxWidth && currentPart.length > 0) {\n\t\t\tparts.push(currentPart);\n\t\t\tcurrentPart = character;\n\t\t} else {\n\t\t\tcurrentPart = nextPart;\n\t\t}\n\t}\n\tif (currentPart.length > 0) {\n\t\tparts.push(currentPart);\n\t}\n\treturn parts;\n}\n\n\n","import {GraphData, LayoutDirection, NodeLink} from \"./graph-view/graph\";\nimport {EdgeStyle, NodeStyle} from \"./graph-view/constants\";\n\n\ninterface Model {\n\tname: string\n\tdescription: string\n\tversion: string\n\tmodel: {\n\t\tenterprise: {\n\t\t\tname: string\n\t\t}\n\t\tpeople: Element[]\n\t\tsoftwareSystems: Element[]\n\t\tdeploymentNodes: Element[]\n\t}\n\tviews: {\n\t\tsystemLandscapeViews: View[]\n\t\tcontainerViews: View[]\n\t\tcomponentViews: View[]\n\t\tdynamicViews: View[]\n\t\tdeploymentViews: View[]\n\t\tstyles: {\n\t\t\telements: (NodeStyle & {tag: string})[];\n\t\t\trelationships: (EdgeStyle & {tag: string})[];\n\t\t}\n\t}\n}\n\ninterface Layouts {\n\t[key: string]: { // keyed by view key\n\t\t[key: string]: { x: number; y: number } // keyed by element id\n\t}\n}\n\ninterface Element {\n\tid: string;\n\tname: string;\n\ttechnology?: string;\n\tdescription?: string;\n\turl?: string;\n\tparent?: Element;\n\ttags?: string;\n\tlocation?: string;\n\tcontainers?: Element[];\n\tcomponents?: Element[];\n\trelationships?: Relation[];\n\tproperties?: { [key: string]: string }\n\tchildren?: Element[];\n\tinfrastructureNodes?: Element[];\n}\n\ninterface Relation {\n\tid: string;\n\tdescription: string;\n\ttags: string;\n\tsourceId: string;\n\tdestinationId: string;\n\ttechnology: string;\n\tinteractionStyle: string;\n}\n\ntype RankDirection = 'TopBottom' | 'BottomTop' | 'LeftRight' | 'RightLeft';\n\ninterface View {\n\tkey: string;\n\ttitle: string;\n\tdescription: string\n\tautomaticLayout?: {\n\t\trankDirection?: RankDirection;\n\t};\n\telements: {\n\t\tid: string\n\t}[];\n\trelationships: {\n\t\tid: string;\n\t\tvertices: { x: number; y: number }[];\n\t\trouting: string; // takes priority over style\n\t}[];\n\tsoftwareSystemId?: string;\n\tcontainerId?: string;\n\texternalContainersBoundariesVisible?: boolean;\n}\n\nconst layoutDirections: Record = {\n\tTopBottom: 'DOWN',\n\tBottomTop: 'UP',\n\tLeftRight: 'RIGHT',\n\tRightLeft: 'LEFT',\n};\n\ninterface Metadata {\n\tname: string\n\tdescription: string\n\tversion: string\n\telements: {\n\t\tid: string\n\t\ttags?: string;\n\t\tlocation?: string;\n\t\tproperties?: { [key: string]: string };\n\t\telementViewKey?: string;\n\t\ttechnology?: string;\n\t\turl?: string;\n\t}[]\n}\n\nexport type ViewsList = {\n\tkey: string;\n\ttitle: string;\n\tsection: string;\n}[]\n\nexport const parseView = (model: Model, layouts: Layouts, viewKey: string) => {\n\n\tconst elements = new Map();\n\tconst relations = new Map();\n\n\tconst collectRels = (el: Element) => {\n\t\tif (Array.isArray(el.relationships)) {\n\t\t\tel.relationships.forEach(rel => {\n\t\t\t\trelations.set(rel.id, rel)\n\t\t\t})\n\t\t}\n\t}\n\n\t// People\n\tmodel.model.people && model.model.people.forEach((el: Element) => {\n\t\telements.set(el.id, el)\n\t\tif (Array.isArray(el.relationships)) {\n\t\t\tel.relationships.forEach(rel => {\n\t\t\t\trelations.set(rel.id, rel)\n\t\t\t})\n\t\t}\n\t})\n\t// Software Systems\n\tmodel.model.softwareSystems && model.model.softwareSystems.forEach((el: Element) => {\n\t\telements.set(el.id, el)\n\t\tcollectRels(el)\n\n\t\tif (Array.isArray(el.containers)) {\n\t\t\tel.containers.forEach((el1: Element) => {\n\t\t\t\tel1.parent = el;\n\t\t\t\telements.set(el1.id, el1)\n\t\t\t\tcollectRels(el1)\n\t\t\t\tif (Array.isArray(el1.components)) {\n\t\t\t\t\tel1.components.forEach((el2: Element) => {\n\t\t\t\t\t\tel2.parent = el1;\n\t\t\t\t\t\telements.set(el2.id, el2)\n\t\t\t\t\t\tcollectRels(el2)\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t})\n\n\t// Deployment Nodes\n\tif (model.model.deploymentNodes) {\n\t\tconst containerInstances = (el: any) => {\n\t\t\tel.containerInstances && el.containerInstances.forEach((item: any) => {\n\t\t\t\tconst el1 = {...elements.get(item.containerId), id: item.id}\n\t\t\t\telements.set(el1.id, el1)\n\t\t\t\tel1.parent = el\n\t\t\t\tcollectRels(item)\n\t\t\t})\n\t\t}\n\n\t\tconst recAddNodes = (el: Element, parent: Element) => {\n\t\t\tel.parent = parent;\n\t\t\telements.set(el.id, el)\n\t\t\tcollectRels(el)\n\t\t\tcontainerInstances(el)\n\t\t\tel.children && el.children.forEach((el1: Element) => recAddNodes(el1, el))\n\t\t\tel.infrastructureNodes && el.infrastructureNodes.forEach((el1: Element) => recAddNodes(el1, el))\n\t\t}\n\n\t\tmodel.model.deploymentNodes.forEach((el: Element) => recAddNodes(el, null))\n\t}\n\n\t// Create graph from selected view\n\tconst {view, section} = getView(model, viewKey)\n\n\tif (!view) return null\n\n\tconst graph = new GraphData(view.key, view.title || view.key)\n\tconst rankDirection = view.automaticLayout?.rankDirection\n\tgraph.layoutDirection = rankDirection ? layoutDirections[rankDirection] : undefined\n\tconst metadata: Metadata = {name: graph.name, description: view.description, version: model.version, elements: []}\n\tgraph.metadata = metadata\n\n\tif (!view.elements) return graph\n\n\t//grouping rules - elements that are groups will not be nodes\n\tconst groupingIDs: { [key: string]: boolean } = {}\n\tif (section == 'deploymentViews' || section == 'containerViews') {\n\t\tview.elements.forEach(ref => {\n\t\t\tconst el = elements.get(ref.id)\n\t\t\tif (el?.parent) {\n\t\t\t\tgroupingIDs[el.parent.id] = true\n\t\t\t}\n\t\t})\n\t} else if (section === 'componentViews') {\n\t\t// Selected components belong to the view's container. Other containers\n\t\t// receive boundaries only when the view requests them.\n\t\tview.elements.forEach(ref => {\n\t\t\tconst parent = elements.get(ref.id)?.parent;\n\t\t\tif (!parent?.components) return;\n\t\t\tif (parent.id !== view.containerId && !view.externalContainersBoundariesVisible) return;\n\t\t\t// A container listed as a node keeps its own relationships; it cannot\n\t\t\t// also be replaced by a group with the same identifier.\n\t\t\tif (!view.elements.some(candidate => candidate.id === parent.id)) {\n\t\t\t\tgroupingIDs[parent.id] = true;\n\t\t\t}\n\t\t});\n\t} else if (view.softwareSystemId) {\n\t\t//don't show grouping if the element is listed in the view\n\t\tif (!view.elements.find(ref => ref.id == view.softwareSystemId))\n\t\t\tgroupingIDs[view.softwareSystemId] = true\n\t} else if (section == 'systemLandscapeViews') {\n\t\t// create a virtual parent element from enterprise\n\t\tconst p: Element = {id: '__enterprise__', ...model.model.enterprise}\n\t\telements.set(p.id, p)\n\t\tif (model.model.people) model.model.people.filter(el => el.location != 'External').forEach(el => el.parent = p)\n\t\tif (model.model.softwareSystems) model.model.softwareSystems.filter(el => el.location != 'External').forEach(el => el.parent = p)\n\t\tgroupingIDs[p.id] = true\n\t}\n\n\tconst styles = model.views.styles\n\n\t// Build color-to-variable mapping for CSS custom properties theming\n\tconst cssClassName = (tag: string) => tag.toLowerCase().replace(/[^a-z0-9-]/g, '-')\n\t\n\tif (styles?.elements) {\n\t\tstyles.elements.forEach(s => {\n\t\t\tif (s.tag) {\n\t\t\t\tconst varPrefix = `--mdl-${cssClassName(s.tag)}`\n\t\t\t\tif (s.background) graph.colorToVarMap.set(s.background as string, `${varPrefix}-bg`)\n\t\t\t\tif (s.color) graph.colorToVarMap.set(s.color as string, `${varPrefix}-color`)\n\t\t\t\tif (s.stroke) graph.colorToVarMap.set(s.stroke as string, `${varPrefix}-stroke`)\n\t\t\t}\n\t\t})\n\t}\n\n\tif (styles?.relationships) {\n\t\tstyles.relationships.forEach(s => {\n\t\t\tif (s.tag) {\n\t\t\t\tconst varPrefix = `--mdl-rel-${cssClassName(s.tag)}`\n\t\t\t\tif (s.color) graph.colorToVarMap.set(s.color as string, `${varPrefix}-color`)\n\t\t\t}\n\t\t})\n\t}\n\n\t//nodes\n\tview.elements.forEach((ref) => {\n\t\t// except grouping elements\n\t\tif (groupingIDs[ref.id]) return\n\n\t\tconst el = elements.get(ref.id)\n\t\tconst elementViewKey = el ? lookupContainerViewKey(model, el.id) : undefined\n\n\t\tlet sub = ''\n\t\tlet style = {}\n\t\tif (el) {\n\t\t\tconst tags = el.tags.split(',')\n\t\t\tsub = tags[tags.length - 1] // subtitle is []\n\t\t\tif (el.technology)\n\t\t\t\tsub += ': ' + el.technology // or [: ]\n\n\t\t\ttags.forEach(tag => {\n\t\t\t\tconst s = styles && styles.elements && styles.elements.find(s => s.tag == tag)\n\t\t\t\ts && (style = {...style, ...s})\n\t\t\t})\n\t\t}\n\n\t\tgraph.addNode(\n\t\t\tref.id,\n\t\t\tel ? (el.name || ref.id) : ref.id,\n\t\t\tsub,\n\t\t\t(el && el.description) ? el.description : '',\n\t\t\tstyle,\n\t\t\tnodeLink(el, elementViewKey)\n\t\t)\n\t\tel && metadata.elements.push({\n\t\t\tid: el.id,\n\t\t\ttags: el.tags,\n\t\t\tlocation: el.location,\n\t\t\tproperties: el.properties,\n\t\t\telementViewKey,\n\t\t\ttechnology: el.technology,\n\t\t\turl: el.url\n\t\t})\n\t})\n\t//edges\n\tif (Array.isArray(view.relationships)) {\n\t\tview.relationships.forEach(ref => {\n\t\t\tconst rel = relations.get(ref.id)\n\t\t\tif (!rel) return;\n\n\t\t\tif (!graph.nodesMap.has(rel.sourceId)) {\n\t\t\t\tif (elements.has(rel.sourceId)) {\n\t\t\t\t\tconst el = elements.get(rel.sourceId)\n\t\t\t\t\tconsole.warn('Element not found in this view: ', el.id, el.name)\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('Element not found: ', rel.sourceId)\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!graph.nodesMap.has(rel.destinationId)) {\n\t\t\t\tif (elements.has(rel.destinationId)) {\n\t\t\t\t\tconst el = elements.get(rel.destinationId)\n\t\t\t\t\tconsole.warn('Element not found in this view: ', el.id, el.name)\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('Element not found: ', rel.destinationId)\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet style: any = {}\n\t\t\trel.tags.split(',').forEach(tag => {\n\t\t\t\tconst s = styles && styles.relationships && styles.relationships.find(s => s.tag == tag)\n\t\t\t\ts && (style = {...style, ...s})\n\t\t\t})\n\t\t\tif (ref.routing) style.routing = ref.routing\n\n\t\t\tconst label = rel.technology ? `${rel.description}\\n[${rel.technology}]` : rel.description\n\t\t\tgraph.addEdge(rel.id, rel.sourceId, rel.destinationId, label, ref.vertices, style)\n\t\t})\n\t}\n\n\t//groups\n\t//sort by depth to solve dependency\n\tconst level = (el: Element) => {\n\t\tlet i = 0\n\t\tfor (let p = el.parent; p; p = p.parent) i++;\n\t\treturn i\n\t}\n\tconst gElements = Object.keys(groupingIDs)\n\t\t.map(id => elements.get(id))\n\t\t.sort((a, b) => level(a) > level(b) ? -1 : 1)\n\n\tgElements.forEach(parent => {\n\t\tlet style = {}\n\t\tif (section == 'deploymentViews') {\n\t\t\tconst el = elements.get(parent.id)\n\t\t\tconst tags = el.tags.split(',')\n\t\t\ttags.forEach(tag => {\n\t\t\t\tconst s = styles && styles.elements && styles.elements.find(s => s.tag == tag)\n\t\t\t\ts && (style = {...style, ...s})\n\t\t\t})\n\t\t}\n\t\t\n\t\t// Filter group members more carefully to respect boundaries\n\t\tconst groupMembers = view.elements\n\t\t\t.map(ref => elements.get(ref.id))\n\t\t\t.filter(el => {\n\t\t\t\tif (!el || el.parent !== parent) return false;\n\t\t\t\t\n\t\t\t\t// For system landscape views, respect the location-based grouping\n\t\t\t\tif (section === 'systemLandscapeViews' && parent.id === '__enterprise__') {\n\t\t\t\t\t// Only include elements that are explicitly non-external\n\t\t\t\t\treturn el.location !== 'External';\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// For other view types, include if parent matches\n\t\t\t\treturn true;\n\t\t\t})\n\t\t\t.map(el => el.id);\n\t\t\n\t\t// Only create group if it has members\n\t\tif (groupMembers.length > 0) {\n\t\t\tgraph.addGroup(\n\t\t\t\tparent.id,\n\t\t\t\tparent.name,\n\t\t\t\tgroupMembers,\n\t\t\t\tstyle\n\t\t\t)\n\t\t}\n\t})\n\n\t//layout if any and init graph\n\tgraph.init(layouts[graph.id])\n\treturn graph\n}\n\nfunction nodeLink(element: Element | undefined, elementViewKey: string | undefined): NodeLink | undefined {\n\tif (elementViewKey) {\n\t\tconst encodedViewKey = encodeURIComponent(elementViewKey)\n\t\treturn {\n\t\t\thref: `?id=${encodedViewKey}`,\n\t\t\texportHref: `${encodedViewKey}.svg`,\n\t\t}\n\t}\n\tif (element?.url) {\n\t\treturn {\n\t\t\thref: element.url,\n\t\t\texportHref: element.url,\n\t\t}\n\t}\n\treturn undefined\n}\n\n// lookup the view in all Views sections in the model. return the view and the section\nfunction getView(model: Model, viewKey: string) {\n\tlet view: View = null, section: string = ''\n\tObject.keys(model.views).filter(s => s.endsWith('Views')).some((s: string) => {\n\t\treturn ((model.views as any)[s]).some((v: View) => {\n\t\t\tif (v.key == viewKey) {\n\t\t\t\tview = v\n\t\t\t\tsection = s\n\t\t\t\treturn true\n\t\t\t}\n\t\t})\n\t})\n\treturn {view, section}\n}\n\n\nfunction lookupContainerViewKey(model: Model, softwareSystemId: string) {\n\tconst view = model.views.containerViews?.find(candidate => candidate.softwareSystemId == softwareSystemId)\n\treturn view?.key\n}\n\nexport const listViews = (model: any) => {\n\tconst viewsList: ViewsList = []\n\tconst sections = Object.keys(model.views).filter(section => section.endsWith('Views'))\n\tsections.forEach(s => {\n\t\tmodel.views[s].forEach((v: View) => {\n\t\t\tviewsList.push({key: v.key, title: v.title || v.key, section: s})\n\t\t})\n\t})\n\treturn viewsList;\n}\n","import React, {FC} from \"react\";\nimport { isMac, getModifierKeyName, getModifierKeyProperty } from './utils/platform';\n\ninterface Combination {\n\tctrl?: boolean;\n\tshift?: boolean;\n\talt?: boolean;\n\twheel?: boolean\n\tkey?: string;\n\tclick?: boolean;\n}\n\ninterface Shortcut {\n\tid: string,\n\thelp: string,\n\tcombinations: Combination[]\n}\n\nexport const SAVE = 'save'\n\nexport const UNDO = 'undo'\nexport const REDO = 'redo'\nexport const ADD_VERTEX = 'add-vertex'\nexport const ADD_LABEL_VERTEX = 'add-label-vertex'\nexport const DEL_VERTEX = 'del-vertex'\n\nexport const ZOOM_IN = 'zoom-in'\nexport const ZOOM_OUT = 'zoom-out'\nexport const ZOOM_FIT = 'zoom-fit'\nexport const ZOOM_100 = 'zoom-100'\n\nexport const SELECT_ALL = 'select-all'\nexport const DESELECT = 'deselect'\n\nexport const MOVE_LEFT = 'move-left'\nexport const MOVE_RIGHT = 'move-right'\nexport const MOVE_UP = 'move-up'\nexport const MOVE_DOWN = 'move-down'\nexport const MOVE_LEFT_FINE = 'move-left-fine'\nexport const MOVE_RIGHT_FINE = 'move-right-fine'\nexport const MOVE_UP_FINE = 'move-up-fine'\nexport const MOVE_DOWN_FINE = 'move-down-fine'\n\nexport const PAN_VIEW = 'pan-view'\nexport const SELECT_ELEMENT = 'select-element'\nexport const MULTI_SELECT = 'multi-select'\nexport const BOX_SELECT = 'box-select'\nexport const MOVE_ELEMENTS = 'move-elements'\n\nexport const HELP = 'help'\n\n// New shortcuts for toolbar buttons\nexport const TOGGLE_DRAG_MODE = 'toggle_drag_mode'\nexport const ALIGN_HORIZONTAL = 'align_horizontal'\nexport const ALIGN_VERTICAL = 'align_vertical'\nexport const DISTRIBUTE_HORIZONTAL = 'distribute_horizontal'\nexport const DISTRIBUTE_VERTICAL = 'distribute_vertical'\nexport const AUTO_LAYOUT = 'auto_layout'\nexport const RESET_POSITION = 'reset_position'\nexport const TOGGLE_GRID = 'toggle_grid'\nexport const TOGGLE_SNAP_TO_GRID = 'toggle_snap_to_grid'\nexport const SNAP_ALL_TO_GRID = 'snap_all_to_grid'\n\nconst shortcuts: { name: string; list: Shortcut[] }[] = [\n\t{\n\t\tname: 'Help',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: HELP,\n\t\t\t\thelp: 'Show/hide this help',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{key: '?', shift: true},\n\t\t\t\t\t{key: 'F1', shift: true}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'File',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: SAVE,\n\t\t\t\thelp: 'Save',\n\t\t\t\tcombinations: [{key: 's', ctrl: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'History',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: UNDO,\n\t\t\t\thelp: 'Undo',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, key: 'z'},\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: REDO,\n\t\t\t\thelp: 'Redo',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, shift: true, key: 'z'},\n\t\t\t\t\t{ctrl: true, key: 'y'},\n\t\t\t\t]\n\t\t\t}\n\n\t\t],\n\t},\n\t{\n\t\tname: 'Relationship editing',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: ADD_VERTEX,\n\t\t\t\thelp: 'Add relationship vertex',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{alt: true, click: true},\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ADD_LABEL_VERTEX,\n\t\t\t\thelp: 'Add label anchor relationship vertex',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{alt: true, shift: true, click: true},\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DEL_VERTEX,\n\t\t\t\thelp: 'Remove relationship vertex',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{key: 'DELETE'},\n\t\t\t\t\t{key: 'BACKSPACE'}\n\t\t\t\t]\n\t\t\t},\n\t\t]\n\t},\n\t{\n\t\tname: 'Zoom',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: ZOOM_IN,\n\t\t\t\thelp: 'Zoom in',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, key: '='}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ZOOM_OUT,\n\t\t\t\thelp: 'Zoom out',\n\t\t\t\tcombinations: [\n\t\t\t\t\t{ctrl: true, key: '-'}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ZOOM_FIT,\n\t\t\t\thelp: 'Zoom - fit',\n\t\t\t\tcombinations: [{ctrl: true, key: '9'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ZOOM_100,\n\t\t\t\thelp: 'Zoom 100%',\n\t\t\t\tcombinations: [{ctrl: true, key: '0'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'wheel_zoom',\n\t\t\t\thelp: 'Zoom in/out with mouse wheel',\n\t\t\t\tcombinations: [{wheel: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Mouse Interactions',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: PAN_VIEW,\n\t\t\t\thelp: 'Pan view (drag empty space)',\n\t\t\t\tcombinations: [{click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: SELECT_ELEMENT,\n\t\t\t\thelp: 'Select element',\n\t\t\t\tcombinations: [{click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MULTI_SELECT,\n\t\t\t\thelp: 'Add/remove from selection',\n\t\t\t\tcombinations: [{shift: true, click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: BOX_SELECT,\n\t\t\t\thelp: 'Box selection (drag empty space)',\n\t\t\t\tcombinations: [{shift: true, click: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_ELEMENTS,\n\t\t\t\thelp: 'Move selected elements',\n\t\t\t\tcombinations: [{click: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Select',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: SELECT_ALL,\n\t\t\t\thelp: 'Select All',\n\t\t\t\tcombinations: [{ctrl: true, key: 'a'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DESELECT,\n\t\t\t\thelp: 'Deselect',\n\t\t\t\tcombinations: [{key: 'ESC'}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Move',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: MOVE_UP,\n\t\t\t\thelp: 'Move up (grid increment)',\n\t\t\t\tcombinations: [{key: 'UP'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_UP_FINE,\n\t\t\t\thelp: 'Move up (1 pixel)',\n\t\t\t\tcombinations: [{key: 'UP', shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_RIGHT,\n\t\t\t\thelp: 'Move right (grid increment)',\n\t\t\t\tcombinations: [{key: 'RIGHT'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_RIGHT_FINE,\n\t\t\t\thelp: 'Move right (1 pixel)',\n\t\t\t\tcombinations: [{key: 'RIGHT', shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_DOWN,\n\t\t\t\thelp: 'Move down (grid increment)',\n\t\t\t\tcombinations: [{key: 'DOWN'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_DOWN_FINE,\n\t\t\t\thelp: 'Move down (1 pixel)',\n\t\t\t\tcombinations: [{key: 'DOWN', shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_LEFT,\n\t\t\t\thelp: 'Move left (grid increment)',\n\t\t\t\tcombinations: [{key: 'LEFT'}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: MOVE_LEFT_FINE,\n\t\t\t\thelp: 'Move left (1 pixel)',\n\t\t\t\tcombinations: [{key: 'LEFT', shift: true}]\n\t\t\t},\n\t\t]\n\t},\n\t\t\t{\n\t\t\tname: 'View',\n\t\t\tlist: [\n\t\t\t\t{\n\t\t\t\t\tid: TOGGLE_DRAG_MODE,\n\t\t\t\t\thelp: 'Toggle between pan and select mode',\n\t\t\t\t\tcombinations: [{key: 't'}]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: RESET_POSITION,\n\t\t\t\t\thelp: 'Reset position and view',\n\t\t\t\t\tcombinations: [{key: 'Home', ctrl: true}]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t{\n\t\tname: 'Alignment',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: ALIGN_HORIZONTAL,\n\t\t\t\thelp: 'Align selected elements horizontally',\n\t\t\t\tcombinations: [{key: 'h', ctrl: true, shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ALIGN_VERTICAL,\n\t\t\t\thelp: 'Align selected elements vertically',\n\t\t\t\tcombinations: [{key: 'a', ctrl: true, shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DISTRIBUTE_HORIZONTAL,\n\t\t\t\thelp: 'Distribute selected elements horizontally',\n\t\t\t\tcombinations: [{key: 'h', ctrl: true, alt: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: DISTRIBUTE_VERTICAL,\n\t\t\t\thelp: 'Distribute selected elements vertically',\n\t\t\t\tcombinations: [{key: 'v', ctrl: true, alt: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Layout',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: AUTO_LAYOUT,\n\t\t\t\thelp: 'Auto layout all elements',\n\t\t\t\tcombinations: [{key: 'l', ctrl: true}]\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\tname: 'Grid',\n\t\tlist: [\n\t\t\t{\n\t\t\t\tid: TOGGLE_GRID,\n\t\t\t\thelp: 'Toggle grid visibility',\n\t\t\t\tcombinations: [{key: 'g', ctrl: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: TOGGLE_SNAP_TO_GRID,\n\t\t\t\thelp: 'Toggle snap to grid',\n\t\t\t\tcombinations: [{key: 'g', ctrl: true, shift: true}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: SNAP_ALL_TO_GRID,\n\t\t\t\thelp: 'Snap all elements to grid',\n\t\t\t\tcombinations: [{key: 'g', ctrl: true, alt: true}]\n\t\t\t}\n\t\t]\n\t}\n]\n\nconst shortcutMap = shortcuts\n\t.reduce((lst, s) => lst.concat(s.list), [] as Shortcut[])\n\t.reduce<{ [k: string]: Shortcut }>((map, s) => {\n\t\tmap[s.id] = s;\n\t\treturn map\n\t}, {})\n\nconst checkKey = (e: KeyboardEvent | MouseEvent, shortcut: Shortcut, click: boolean, wheel: boolean) => {\n\treturn shortcut.combinations.some(c => {\n\t\tif (Boolean(c.shift) != e.shiftKey) return false\n\t\t// Use platform-appropriate modifier key\n\t\tif (c.ctrl) {\n\t\t\tconst modifierKey = getModifierKeyProperty(e as KeyboardEvent);\n\t\t\tif (!modifierKey) return false;\n\t\t}\n\t\tif (Boolean(c.alt) != e.altKey) return false\n\t\tif (click) return c.click\n\t\tif (wheel) return c.wheel\n\t\tif (c.key) {\n\t\t\tconst ke = e as KeyboardEvent\n\t\t\tif (c.key == 'DELETE') return ke.key == 'Delete'\n\t\t\tif (c.key == 'BACKSPACE') return ke.key == 'Backspace'\n\t\t\tif (c.key == 'ESC') return ke.key == 'Escape'\n\t\t\tif (c.key == 'UP') return ke.key == 'ArrowUp'\n\t\t\tif (c.key == 'DOWN') return ke.key == 'ArrowDown'\n\t\t\tif (c.key == 'LEFT') return ke.key == 'ArrowLeft'\n\t\t\tif (c.key == 'RIGHT') return ke.key == 'ArrowRight'\n\t\t\treturn c.key && ke.key && c.key.toLowerCase() == ke.key.toLowerCase()\n\t\t}\n\t\treturn false\n\t})\n}\n\nexport const findShortcut = (e: KeyboardEvent | MouseEvent, click = false, wheel = false) => {\n\t// Find all matching shortcuts\n\tconst matches = Object.keys(shortcutMap).filter(k => checkKey(e, shortcutMap[k], click, wheel))\n\t\n\tif (matches.length === 0) return undefined\n\tif (matches.length === 1) return matches[0]\n\t\n\t// If multiple matches, prefer the one with more specific modifiers\n\t// Sort by number of modifiers (shift, ctrl, alt) in descending order\n\tconst sortedMatches = matches.sort((a, b) => {\n\t\tconst aShortcut = shortcutMap[a]\n\t\tconst bShortcut = shortcutMap[b]\n\t\t\n\t\tconst aModifiers = aShortcut.combinations[0]\n\t\tconst bModifiers = bShortcut.combinations[0]\n\t\t\n\t\tconst aCount = (aModifiers.shift ? 1 : 0) + (aModifiers.ctrl ? 1 : 0) + (aModifiers.alt ? 1 : 0)\n\t\tconst bCount = (bModifiers.shift ? 1 : 0) + (bModifiers.ctrl ? 1 : 0) + (bModifiers.alt ? 1 : 0)\n\t\t\n\t\treturn bCount - aCount // Descending order (more modifiers first)\n\t})\n\t\n\treturn sortedMatches[0]\n}\n\nconst comboText = (c: Combination) => {\n\treturn [\n\t\tc.ctrl && getModifierKeyName().toUpperCase(),\n\t\tc.shift && 'SHIFT',\n\t\tc.alt && 'ALT',\n\t\tc.key && (c.key.length > 1 ? c.key : `\"${c.key.toUpperCase()}\"`),\n\t\tc.click && 'CLICK',\n\t\tc.wheel && 'WHEEL'\n\t].filter(Boolean).join(' + ')\n}\n\nexport const Help: FC = () => {\n\treturn
\n\t\t

Shortcuts

\n\t\t\n\t\t\t\n\t\t\t{\n\t\t\t\tshortcuts.map(section => <>\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t{section.list.map(item => \n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t)\n\t\t\t}\n\t\t\t\n\t\t
{section.name}
{item.combinations.map(comboText).join(', ')}{item.help}
\n\t
\n}\n","/**\n * Robust platform detection utilities\n */\n\n/**\n * Detects if the user is on a Mac platform using multiple detection methods\n * for maximum compatibility across browsers and future-proofing.\n */\nexport const isMac = (): boolean => {\n if (typeof navigator === 'undefined') return false;\n \n // Method 1: Check userAgentData (modern browsers, most reliable)\n if ('userAgentData' in navigator && (navigator as any).userAgentData) {\n const platform = (navigator as any).userAgentData.platform;\n if (platform && platform.toLowerCase().includes('mac')) {\n return true;\n }\n }\n \n // Method 2: Check userAgent string (widely supported)\n const userAgent = navigator.userAgent.toLowerCase();\n if (userAgent.includes('mac os') || userAgent.includes('macintosh')) {\n return true;\n }\n \n // Method 3: Check platform (fallback, deprecated but still widely supported)\n if (navigator.platform) {\n const platform = navigator.platform.toLowerCase();\n if (platform.includes('mac') || platform.includes('darwin')) {\n return true;\n }\n }\n \n // Method 4: Check for Mac-specific features as additional validation\n try {\n const testEvent = new KeyboardEvent('keydown', { metaKey: true });\n if (testEvent.metaKey !== undefined) {\n // Additional heuristic: Mac typically has different key layouts\n return /mac|darwin|os x/i.test(navigator.userAgent);\n }\n } catch (e) {\n // Ignore errors in older browsers\n }\n \n return false;\n};\n\n/**\n * Gets the appropriate modifier key name for the current platform\n */\nexport const getModifierKeyName = (): string => {\n return isMac() ? 'Cmd' : 'Ctrl';\n};\n\n/**\n * Gets the appropriate modifier key property for keyboard events\n */\nexport const getModifierKeyProperty = (event: KeyboardEvent): boolean => {\n return isMac() ? event.metaKey : event.ctrlKey;\n};\n\n/**\n * Gets the appropriate Alt key name for the current platform\n */\nexport const getAltKeyName = (): string => {\n return isMac() ? 'Option' : 'Alt';\n}; ","// Imports\nimport ___CSS_LOADER_API_SOURCEMAP_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/sourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/api.js\";\nimport ___CSS_LOADER_GET_URL_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/getUrl.js\";\nvar ___CSS_LOADER_URL_IMPORT_0___ = new URL(\"@fontsource/inter/files/inter-latin-400-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_1___ = new URL(\"@fontsource/inter/files/inter-latin-500-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_2___ = new URL(\"@fontsource/inter/files/inter-latin-600-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_3___ = new URL(\"@fontsource/inter/files/inter-latin-700-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_SOURCEMAP_IMPORT___);\nvar ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___);\nvar ___CSS_LOADER_URL_REPLACEMENT_1___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_1___);\nvar ___CSS_LOADER_URL_REPLACEMENT_2___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_2___);\nvar ___CSS_LOADER_URL_REPLACEMENT_3___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_3___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_0___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_1___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_2___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_3___}) format(\"woff2\");\n}\n`, \"\",{\"version\":3,\"sources\":[\"webpack://./src/fonts.css\"],\"names\":[],\"mappings\":\"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF\",\"sourcesContent\":[\"/* Local Inter files keep browser text measurement identical without internet access. */\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 400;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-400-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 500;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-500-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 600;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-600-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 700;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-700-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\"],\"sourceRoot\":\"\"}]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___;\n","// Imports\nimport ___CSS_LOADER_API_SOURCEMAP_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/sourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/api.js\";\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_SOURCEMAP_IMPORT___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `html, body, #root {\n height: 100%;\n}\n\nbody {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n color: #666;\n margin: 0;\n}\n\n#root {\n display: flex;\n flex-direction: column;\n}\n#root > div.graph {\n flex: 1;\n overflow: auto;\n position: relative;\n}\n\n.toolbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 4px 10px;\n background-color: #f0f0f0;\n border-bottom: 1px solid #cccccc;\n}\n\n.toolbar > div {\n display: flex;\n align-items: center;\n}\n\n.toolbar button {\n padding: 5px 8px;\n margin: 0 2px;\n cursor: pointer;\n}\n\n.toolbar button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Drag mode toggle button styles */\n.toolbar button.mode-toggle {\n position: relative;\n border: 1px solid #8f9fc9;\n width: 40px;\n min-height: 28px;\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\n border-color: #8f9fc9;\n color: white;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n}\n\n.toolbar button.mode-toggle:hover {\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\n border-color: #abb8db;\n}\n\n.toolbar button.mode-toggle.select-mode:active {\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\n}\n\n/* Pan mode and active toggle - darker blue */\n.toolbar button.mode-toggle.pan-mode,\n.toolbar button.active-toggle {\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n.toolbar button.mode-toggle.pan-mode:hover,\n.toolbar button.active-toggle:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\n.toolbar button.mode-toggle.pan-mode:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\n}\n\n/* Toggle buttons when inactive - gray styling */\n.toolbar button.inactive-toggle {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n.toolbar button.inactive-toggle:hover {\n background: #b1b1b1;\n}\n\n.toolbar button.inactive-toggle:active {\n background: #a1a1a1;\n}\n\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\n background: #c1c1c1;\n color: #999;\n border-color: #c1c1c1;\n box-shadow: none;\n}\n\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\n.toolbar button .fas {\n font-size: 1em;\n vertical-align: middle;\n}\n\n/* Zoom percentage display */\n.toolbar button.zoom-display {\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n font-size: 11px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\n padding: 6px 8px;\n text-align: center;\n}\n\n.toolbar-group {\n display: flex;\n align-items: center;\n margin-right: 25px; /* Large space between groups */\n}\n\n.toolbar-group:last-child {\n margin-right: 0; /* Remove right margin from the last group (help button) */\n}\n\nbutton {\n border: none;\n background: linear-gradient(to bottom, #4a90e2, #357abd);\n border-color: #2968a3;\n border-radius: 3px;\n padding: 6px 10px;\n color: #fff;\n outline: none;\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\n margin-right: 5px;\n min-width: 32px;\n min-height: 28px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n line-height: 1;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n position: relative;\n}\n\nbutton:hover {\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\n}\n\nbutton:active {\n background: linear-gradient(to bottom, #357abd, #2968a3);\n}\n\nbutton:last-child {\n margin-right: 0;\n}\n\n/* Save button when no changes - gray */\nbutton.action {\n background: #c1c1c1;\n color: #999;\n}\n\nbutton.action:active {\n background: #b1b1b1;\n}\n\n/* Save button when there are changes - orange */\nbutton.grp {\n background: linear-gradient(to bottom, #ee9564, #de7d48);\n margin-right: 0;\n}\n\nbutton.grp:active {\n background: #d67540;\n}\n\n/* Auto-arrange button with AI purple to blue gradient */\nbutton.auto-arrange {\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\n border-color: #4a4c93;\n}\n\nbutton.auto-arrange:hover {\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\n border-color: #5a5ca3;\n}\n\nbutton.auto-arrange:active {\n background: linear-gradient(135deg, #593B83, #357abd);\n border-color: #3a3c83;\n}\n\nselect {\n border: 1px solid #ccc;\n background: white;\n border-radius: 3px;\n padding: 3px 7px;\n color: #666;\n outline: none;\n margin-right: 5px;\n font-size: 12px;\n}\n\nselect:disabled {\n background: #f5f5f5;\n color: #999;\n}\n\nbutton:disabled {\n background: #c1c1c1;\n color: #999;\n}\n\n#root > div > svg {\n position: absolute;\n user-select: none;\n}\n\n\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\n stroke: #29c229;\n}\n.edge .v-dot {\n fill: transparent;\n stroke: transparent;\n stroke-width: 3px;\n cursor: pointer;\n transition: stroke 0.15s ease;\n}\n.edge .v-dot:hover {\n stroke: #999;\n fill: rgba(153, 153, 153, 0.1);\n}\n.edge .v-dot.selected {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.1);\n}\n.edge .v-dot.selected:hover {\n stroke: #29c229;\n fill: rgba(41, 194, 41, 0.2);\n}\n.edge .v-dot.auto.selected {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.1);\n}\n.edge .v-dot.auto.selected:hover {\n stroke: #777;\n fill: rgba(119, 119, 119, 0.2);\n}\ncircle.prj {\n fill: none;\n stroke: #777;\n}\n\n.nodeShadow {\n fill: none;\n stroke-width: 4px;\n stroke: rgba(0, 0, 0, 0.13);\n}\n\ng.node {\n user-select: none;\n cursor: default;\n}\n\ng.node.linked {\n cursor: pointer;\n}\n\ng.node text {\n pointer-events: none;\n}\n\n.icon {\n fill: #aaa;\n stroke: #fff;\n}\n\n/* Ensure all button icons are uncolored */\nbutton .icon,\nbutton svg,\nbutton path {\n fill: currentColor !important;\n stroke: none !important;\n}\n\n/* Font Awesome icon styling in buttons */\nbutton i {\n font-size: 12px;\n color: inherit;\n}\n\nrect.elastic {\n pointer-events: none;\n stroke: none;\n fill: #3bd8281f;\n display: none;\n}\nrect.elastic.on {\n display: block;\n}\n\n.popover {\n position: absolute;\n top: 50px;\n bottom: 10px;\n overflow: auto;\n right: 10px;\n background: ghostwhite;\n padding: 30px;\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\n border: solid 1px #eee;\n}\n\n.popover th {\n text-align: left;\n padding: 20px 0px 10px;\n}\n.popover td {\n padding-right: 20px;\n font-size: 14px;\n}\n\n/* Simple tooltip system with smart positioning */\n[data-tooltip] {\n position: relative;\n}\n\n[data-tooltip]:hover::after {\n content: attr(data-tooltip);\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n background: rgba(0, 0, 0, 0.9);\n color: white;\n padding: 6px 12px;\n border-radius: 4px;\n font-size: 12px !important;\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n font-weight: normal !important;\n white-space: nowrap;\n z-index: 1000;\n pointer-events: none;\n margin-top: 5px;\n animation: tooltip-appear 0.1s ease-out;\n min-width: 120px;\n max-width: calc(100vw - 20px);\n box-sizing: border-box;\n}\n\n[data-tooltip]:hover::before {\n content: '';\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-bottom-color: rgba(0, 0, 0, 0.9);\n z-index: 1000;\n pointer-events: none;\n margin-top: 1px;\n animation: tooltip-appear 0.1s ease-out;\n}\n\n/* Special handling for rightmost elements that might overflow */\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 0;\n transform: none;\n}\n\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\n /* Apply to last 2 toolbar groups (save and help buttons) */\n left: auto;\n right: 16px;\n transform: none;\n}\n\n@keyframes tooltip-appear {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(-5px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\nselect {\n position: relative;\n}\n\n/* Robot shape internal elements - inherit stroke from parent node */\n.node .robot-eye-socket {\n fill: none;\n stroke: inherit;\n stroke-width: 2;\n}\n\n.node .robot-eye {\n fill: currentColor;\n stroke: none;\n}\n\n.node .robot-mouth {\n stroke: inherit;\n}\n\n.node .robot-antenna {\n stroke: inherit;\n}\n\n.node .robot-antenna-ball {\n fill: currentColor;\n stroke: inherit;\n stroke-width: 1.5;\n}\n\n.node .robot-panel {\n stroke: inherit;\n}\n\n.node .robot-indicator {\n fill: currentColor;\n stroke: none;\n}`, \"\",{\"version\":3,\"sources\":[\"webpack://./src/style.css\"],\"names\":[],\"mappings\":\"AAAA;IACI,YAAY;AAChB;;AAEA;IACI,uFAAuF;IACvF,WAAW;IACX,SAAS;AACb;;AAEA;IACI,aAAa;IACb,sBAAsB;AAC1B;AACA;IACI,OAAO;IACP,cAAc;IACd,kBAAkB;AACtB;;AAEA;IACI,aAAa;IACb,8BAA8B;IAC9B,mBAAmB;IACnB,iBAAiB;IACjB,yBAAyB;IACzB,gCAAgC;AACpC;;AAEA;IACI,aAAa;IACb,mBAAmB;AACvB;;AAEA;IACI,gBAAgB;IAChB,aAAa;IACb,eAAe;AACnB;;AAEA;IACI,YAAY;IACZ,mBAAmB;AACvB;;AAEA,mCAAmC;AACnC;IACI,kBAAkB;IAClB,yBAAyB;IACzB,WAAW;IACX,gBAAgB;IAChB,wDAAwD;IACxD,qBAAqB;IACrB,YAAY;IACZ,yCAAyC;AAC7C;;AAEA;IACI,wDAAwD;IACxD,qBAAqB;AACzB;;AAEA;IACI,wDAAwD;AAC5D;;AAEA,6CAA6C;AAC7C;;IAEI,wDAAwD;IACxD,qBAAqB;IACrB,2CAA2C;AAC/C;;AAEA;;IAEI,wDAAwD;AAC5D;;AAEA;IACI,wDAAwD;IACxD,2CAA2C;AAC/C;;AAEA,gDAAgD;AAChD;IACI,mBAAmB;IACnB,WAAW;IACX,qBAAqB;IACrB,gBAAgB;AACpB;;AAEA;IAC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AAgB;IAChB,6BAA6B;IAC7B,sBAAsB;AAC1B;;AAEA;IACI,WAAW;IACX,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,2BAA2B;IAC3B,6BAA6B;IAC7B,uCAAuC;IACvC,aAAa;IACb,oBAAoB;IACpB,eAAe;IACf,uCAAuC;AAC3C;;AAEA,gEAAgE;AAChE;IACI,2DAA2D;IAC3D,UAAU;IACV,QAAQ;IACR,eAAe;AACnB;;AAEA;IACI,2DAA2D;IAC3D,UAAU;IACV,WAAW;IACX,eAAe;AACnB;;AAEA;IACI;QACI,UAAU;QACV,4CAA4C;IAChD;IACA;QACI,UAAU;QACV,yCAAyC;IAC7C;AACJ;;AAEA;IACI,kBAAkB;AACtB;;AAEA,oEAAoE;AACpE;IACI,UAAU;IACV,eAAe;IACf,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,YAAY;AAChB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,eAAe;IACf,iBAAiB;AACrB;;AAEA;IACI,eAAe;AACnB;;AAEA;IACI,kBAAkB;IAClB,YAAY;AAChB\",\"sourcesContent\":[\"html, body, #root {\\n height: 100%;\\n}\\n\\nbody {\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n color: #666;\\n margin: 0;\\n}\\n\\n#root {\\n display: flex;\\n flex-direction: column;\\n}\\n#root > div.graph {\\n flex: 1;\\n overflow: auto;\\n position: relative;\\n}\\n\\n.toolbar {\\n display: flex;\\n justify-content: space-between;\\n align-items: center;\\n padding: 4px 10px;\\n background-color: #f0f0f0;\\n border-bottom: 1px solid #cccccc;\\n}\\n\\n.toolbar > div {\\n display: flex;\\n align-items: center;\\n}\\n\\n.toolbar button {\\n padding: 5px 8px;\\n margin: 0 2px;\\n cursor: pointer;\\n}\\n\\n.toolbar button:disabled {\\n opacity: 0.5;\\n cursor: not-allowed;\\n}\\n\\n/* Drag mode toggle button styles */\\n.toolbar button.mode-toggle {\\n position: relative;\\n border: 1px solid #8f9fc9;\\n width: 40px;\\n min-height: 28px;\\n background: linear-gradient(to bottom, #abb8db, #8f9fc9);\\n border-color: #8f9fc9;\\n color: white;\\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\\n}\\n\\n.toolbar button.mode-toggle:hover {\\n background: linear-gradient(to bottom, #bcc7e0, #abb8db);\\n border-color: #abb8db;\\n}\\n\\n.toolbar button.mode-toggle.select-mode:active {\\n background: linear-gradient(to bottom, #8f9fc9, #7a8bb5);\\n}\\n\\n/* Pan mode and active toggle - darker blue */\\n.toolbar button.mode-toggle.pan-mode,\\n.toolbar button.active-toggle {\\n background: linear-gradient(to bottom, #4a90e2, #357abd);\\n border-color: #2968a3;\\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\\n}\\n\\n.toolbar button.mode-toggle.pan-mode:hover,\\n.toolbar button.active-toggle:hover {\\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\\n}\\n\\n.toolbar button.mode-toggle.pan-mode:active {\\n background: linear-gradient(to bottom, #357abd, #2968a3);\\n box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);\\n}\\n\\n/* Toggle buttons when inactive - gray styling */\\n.toolbar button.inactive-toggle {\\n background: #c1c1c1;\\n color: #999;\\n border-color: #c1c1c1;\\n box-shadow: none;\\n}\\n\\n.toolbar button.inactive-toggle:hover {\\n background: #b1b1b1;\\n}\\n\\n.toolbar button.inactive-toggle:active {\\n background: #a1a1a1;\\n}\\n\\n/* Toggle buttons when disabled and not active - gray like other disabled buttons */\\n.toolbar button.mode-toggle:disabled:not(.pan-mode):not(.active-toggle),\\n.toolbar button.active-toggle:disabled:not(.active-toggle) {\\n background: #c1c1c1;\\n color: #999;\\n border-color: #c1c1c1;\\n box-shadow: none;\\n}\\n\\n/* Ensure Font Awesome icons are sized appropriately if not already handled */\\n.toolbar button .fas {\\n font-size: 1em;\\n vertical-align: middle;\\n}\\n\\n/* Zoom percentage display */\\n.toolbar button.zoom-display {\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\\n font-size: 11px;\\n font-weight: 600;\\n font-variant-numeric: tabular-nums;\\n min-width: 50px; /* Wider to prevent size change between 99% and 100% */\\n padding: 6px 8px;\\n text-align: center;\\n}\\n\\n.toolbar-group {\\n display: flex;\\n align-items: center;\\n margin-right: 25px; /* Large space between groups */\\n}\\n\\n.toolbar-group:last-child {\\n margin-right: 0; /* Remove right margin from the last group (help button) */\\n}\\n\\nbutton {\\n border: none;\\n background: linear-gradient(to bottom, #4a90e2, #357abd);\\n border-color: #2968a3;\\n border-radius: 3px;\\n padding: 6px 10px;\\n color: #fff;\\n outline: none;\\n box-shadow: 2px 2px 2px rgba(0, 0, 0, .2);\\n margin-right: 5px;\\n min-width: 32px;\\n min-height: 28px;\\n display: inline-flex;\\n align-items: center;\\n justify-content: center;\\n font-size: 14px;\\n line-height: 1;\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n position: relative;\\n}\\n\\nbutton:hover {\\n background: linear-gradient(to bottom, #5ba0f2, #4585c7);\\n}\\n\\nbutton:active {\\n background: linear-gradient(to bottom, #357abd, #2968a3);\\n}\\n\\nbutton:last-child {\\n margin-right: 0;\\n}\\n\\n/* Save button when no changes - gray */\\nbutton.action {\\n background: #c1c1c1;\\n color: #999;\\n}\\n\\nbutton.action:active {\\n background: #b1b1b1;\\n}\\n\\n/* Save button when there are changes - orange */\\nbutton.grp {\\n background: linear-gradient(to bottom, #ee9564, #de7d48);\\n margin-right: 0;\\n}\\n\\nbutton.grp:active {\\n background: #d67540;\\n}\\n\\n/* Auto-arrange button with AI purple to blue gradient */\\nbutton.auto-arrange {\\n background: linear-gradient(135deg, #6A4C93, #4a90e2);\\n border-color: #4a4c93;\\n}\\n\\nbutton.auto-arrange:hover {\\n background: linear-gradient(135deg, #7B5DAD, #5ba0f2);\\n border-color: #5a5ca3;\\n}\\n\\nbutton.auto-arrange:active {\\n background: linear-gradient(135deg, #593B83, #357abd);\\n border-color: #3a3c83;\\n}\\n\\nselect {\\n border: 1px solid #ccc;\\n background: white;\\n border-radius: 3px;\\n padding: 3px 7px;\\n color: #666;\\n outline: none;\\n margin-right: 5px;\\n font-size: 12px;\\n}\\n\\nselect:disabled {\\n background: #f5f5f5;\\n color: #999;\\n}\\n\\nbutton:disabled {\\n background: #c1c1c1;\\n color: #999;\\n}\\n\\n#root > div > svg {\\n position: absolute;\\n user-select: none;\\n}\\n\\n\\n.node.selected .nodeBorder, .edge.selected path, .edge.selected rect {\\n stroke: #29c229;\\n}\\n.edge .v-dot {\\n fill: transparent;\\n stroke: transparent;\\n stroke-width: 3px;\\n cursor: pointer;\\n transition: stroke 0.15s ease;\\n}\\n.edge .v-dot:hover {\\n stroke: #999;\\n fill: rgba(153, 153, 153, 0.1);\\n}\\n.edge .v-dot.selected {\\n stroke: #29c229;\\n fill: rgba(41, 194, 41, 0.1);\\n}\\n.edge .v-dot.selected:hover {\\n stroke: #29c229;\\n fill: rgba(41, 194, 41, 0.2);\\n}\\n.edge .v-dot.auto.selected {\\n stroke: #777;\\n fill: rgba(119, 119, 119, 0.1);\\n}\\n.edge .v-dot.auto.selected:hover {\\n stroke: #777;\\n fill: rgba(119, 119, 119, 0.2);\\n}\\ncircle.prj {\\n fill: none;\\n stroke: #777;\\n}\\n\\n.nodeShadow {\\n fill: none;\\n stroke-width: 4px;\\n stroke: rgba(0, 0, 0, 0.13);\\n}\\n\\ng.node {\\n user-select: none;\\n cursor: default;\\n}\\n\\ng.node.linked {\\n cursor: pointer;\\n}\\n\\ng.node text {\\n pointer-events: none;\\n}\\n\\n.icon {\\n fill: #aaa;\\n stroke: #fff;\\n}\\n\\n/* Ensure all button icons are uncolored */\\nbutton .icon,\\nbutton svg,\\nbutton path {\\n fill: currentColor !important;\\n stroke: none !important;\\n}\\n\\n/* Font Awesome icon styling in buttons */\\nbutton i {\\n font-size: 12px;\\n color: inherit;\\n}\\n\\nrect.elastic {\\n pointer-events: none;\\n stroke: none;\\n fill: #3bd8281f;\\n display: none;\\n}\\nrect.elastic.on {\\n display: block;\\n}\\n\\n.popover {\\n position: absolute;\\n top: 50px;\\n bottom: 10px;\\n overflow: auto;\\n right: 10px;\\n background: ghostwhite;\\n padding: 30px;\\n box-shadow: 3px 3px 5px rgba(0,0,0, .2);\\n border: solid 1px #eee;\\n}\\n\\n.popover th {\\n text-align: left;\\n padding: 20px 0px 10px;\\n}\\n.popover td {\\n padding-right: 20px;\\n font-size: 14px;\\n}\\n\\n/* Simple tooltip system with smart positioning */\\n[data-tooltip] {\\n position: relative;\\n}\\n\\n[data-tooltip]:hover::after {\\n content: attr(data-tooltip);\\n position: absolute;\\n top: 100%;\\n left: 50%;\\n transform: translateX(-50%);\\n background: rgba(0, 0, 0, 0.9);\\n color: white;\\n padding: 6px 12px;\\n border-radius: 4px;\\n font-size: 12px !important;\\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\\n font-weight: normal !important;\\n white-space: nowrap;\\n z-index: 1000;\\n pointer-events: none;\\n margin-top: 5px;\\n animation: tooltip-appear 0.1s ease-out;\\n min-width: 120px;\\n max-width: calc(100vw - 20px);\\n box-sizing: border-box;\\n}\\n\\n[data-tooltip]:hover::before {\\n content: '';\\n position: absolute;\\n top: 100%;\\n left: 50%;\\n transform: translateX(-50%);\\n border: 4px solid transparent;\\n border-bottom-color: rgba(0, 0, 0, 0.9);\\n z-index: 1000;\\n pointer-events: none;\\n margin-top: 1px;\\n animation: tooltip-appear 0.1s ease-out;\\n}\\n\\n/* Special handling for rightmost elements that might overflow */\\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::after {\\n /* Apply to last 2 toolbar groups (save and help buttons) */\\n left: auto;\\n right: 0;\\n transform: none;\\n}\\n\\n.toolbar-group:nth-last-child(-n+2) button[data-tooltip]:hover::before {\\n /* Apply to last 2 toolbar groups (save and help buttons) */\\n left: auto;\\n right: 16px;\\n transform: none;\\n}\\n\\n@keyframes tooltip-appear {\\n from {\\n opacity: 0;\\n transform: translateX(-50%) translateY(-5px);\\n }\\n to {\\n opacity: 1;\\n transform: translateX(-50%) translateY(0);\\n }\\n}\\n\\nselect {\\n position: relative;\\n}\\n\\n/* Robot shape internal elements - inherit stroke from parent node */\\n.node .robot-eye-socket {\\n fill: none;\\n stroke: inherit;\\n stroke-width: 2;\\n}\\n\\n.node .robot-eye {\\n fill: currentColor;\\n stroke: none;\\n}\\n\\n.node .robot-mouth {\\n stroke: inherit;\\n}\\n\\n.node .robot-antenna {\\n stroke: inherit;\\n}\\n\\n.node .robot-antenna-ball {\\n fill: currentColor;\\n stroke: inherit;\\n stroke-width: 1.5;\\n}\\n\\n.node .robot-panel {\\n stroke: inherit;\\n}\\n\\n.node .robot-indicator {\\n fill: currentColor;\\n stroke: none;\\n}\"],\"sourceRoot\":\"\"}]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___;\n","// Imports\nimport ___CSS_LOADER_API_SOURCEMAP_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/sourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/api.js\";\nimport ___CSS_LOADER_GET_URL_IMPORT___ from \"../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/runtime/getUrl.js\";\nvar ___CSS_LOADER_URL_IMPORT_0___ = new URL(\"@fontsource/inter/files/inter-latin-400-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_1___ = new URL(\"@fontsource/inter/files/inter-latin-500-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_2___ = new URL(\"@fontsource/inter/files/inter-latin-600-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_URL_IMPORT_3___ = new URL(\"@fontsource/inter/files/inter-latin-700-normal.woff2\", import.meta.url);\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_SOURCEMAP_IMPORT___);\nvar ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___);\nvar ___CSS_LOADER_URL_REPLACEMENT_1___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_1___);\nvar ___CSS_LOADER_URL_REPLACEMENT_2___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_2___);\nvar ___CSS_LOADER_URL_REPLACEMENT_3___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_3___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `/* Local Inter files keep browser text measurement identical without internet access. */\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 400;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_0___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 500;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_1___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 600;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_2___}) format(\"woff2\");\n}\n\n@font-face {\n\tfont-family: \"Inter\";\n\tfont-style: normal;\n\tfont-display: swap;\n\tfont-weight: 700;\n\tsrc: url(${___CSS_LOADER_URL_REPLACEMENT_3___}) format(\"woff2\");\n}\n`, \"\",{\"version\":3,\"sources\":[\"webpack://./src/fonts.css\"],\"names\":[],\"mappings\":\"AAAA,uFAAuF;AACvF;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF;;AAEA;CACC,oBAAoB;CACpB,kBAAkB;CAClB,kBAAkB;CAClB,gBAAgB;CAChB,4DAAgF;AACjF\",\"sourcesContent\":[\"/* Local Inter files keep browser text measurement identical without internet access. */\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 400;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-400-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 500;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-500-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 600;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-600-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\\n@font-face {\\n\\tfont-family: \\\"Inter\\\";\\n\\tfont-style: normal;\\n\\tfont-display: swap;\\n\\tfont-weight: 700;\\n\\tsrc: url(\\\"@fontsource/inter/files/inter-latin-700-normal.woff2\\\") format(\\\"woff2\\\");\\n}\\n\"],\"sourceRoot\":\"\"}]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___.toString();\n","\n import API from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\";\n import domAPI from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleDomAPI.js\";\n import insertFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertBySelector.js\";\n import setAttributes from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js\";\n import insertStyleElement from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertStyleElement.js\";\n import styleTagTransformFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleTagTransform.js\";\n import content, * as namedExport from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./fonts.css\";\n \n \n\nvar options = {};\n\noptions.styleTagTransform = styleTagTransformFn;\noptions.setAttributes = setAttributes;\noptions.insert = insertFn.bind(null, \"head\");\noptions.domAPI = domAPI;\noptions.insertStyleElement = insertStyleElement;\n\nvar update = API(content, options);\n\n\n\nexport * from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./fonts.css\";\n export default content && content.locals ? content.locals : undefined;\n","\n import API from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\";\n import domAPI from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleDomAPI.js\";\n import insertFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertBySelector.js\";\n import setAttributes from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js\";\n import insertStyleElement from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/insertStyleElement.js\";\n import styleTagTransformFn from \"!../node_modules/.pnpm/style-loader@4.0.0_webpack@5.109.2/node_modules/style-loader/dist/runtime/styleTagTransform.js\";\n import content, * as namedExport from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./style.css\";\n \n \n\nvar options = {};\n\noptions.styleTagTransform = styleTagTransformFn;\noptions.setAttributes = setAttributes;\noptions.insert = insertFn.bind(null, \"head\");\noptions.domAPI = domAPI;\noptions.insertStyleElement = insertStyleElement;\n\nvar update = API(content, options);\n\n\n\nexport * from \"!!../node_modules/.pnpm/css-loader@7.1.4_webpack@5.109.2/node_modules/css-loader/dist/cjs.js!./style.css\";\n export default content && content.locals ? content.locals : undefined;\n"],"names":["el","style","Object","entries","forEach","key","value","setAttribute","String","nodeBorder","nodeText","stroke","edgeText","edgeRect","fill","groupRect","groupText","cursor","thickness","color","opacity","fontSize","width","dashed","p1","p2","Math","sqrt","x","y","height","background","shape","metadata","description","calculateEdgeVertices","edge","n1","from","n2","to","vertices","concat","unshift","push","interior","slice","firstRoutingVertex","find","vertex","label","lastRoutingVertex","index","length","intersect","Error","id","calculateLabelPlacement","position","defaultPoint","segment","point","labelIndex","findIndex","movable","labelVertex","auto","adjacentSegments","p","q","reduce","longest","candidate","_constants__WEBPACK_IMPORTED_MODULE_0__","gd","undefined","targetLength","sum","traversed","segmentPosition","horizontalDistance","abs","verticalDistance","orientation","createEdgePath","path","Symbol","GeometryValidationError","issues","constructor","super","map","issue","message","join","this","name","validateResolvedLayout","measured","resolved","diagramId","checkUniqueIDs","nodes","node","groups","group","edges","checkCoverage","measuredNodes","Map","measuredGroups","resolvedNodes","resolvedGroups","checkFiniteRect","bounds","expected","get","nearlyEqual","size","contentSize","checkRectInBounds","titleBounds","contains","titleSize","forEachPair","first","second","overlaps","checkNodeOverlaps","checkGroupOverlaps","child","parentId","parent","checkOwnership","measuredEdges","labels","sourceId","targetId","sections","some","section","checkSectionConnections","isFinitePoint","pointInRect","values","routeIntersectsRect","inset","sourceInside","belongsToGroup","routeViolatesGroup","labelBounds","labelSize","checkEdges","ids","seen","Set","has","add","actual","expectedIDs","actualIDs","rect","Number","isFinite","isFiniteRect","samePoint","source","target","start","end","pointOnBorder","nodeId","groupId","shouldBeInside","dx","dy","minimum","maximum","origin","delta","lower","upper","EPSILON","max","min","segmentIntersectsRect","outer","inner","inclusive","amount","withinX","withinY","onVertical","onHorizontal","items","visit","code","elementIds","create","element","type","attrs","className","document","createElementNS","k","v","classList","use","setAttributeNS","d","text","t","textContent","textArea","bold","anchor","constants","M5","lines","maxW","svg_text","U2","txt","line","i","span","append","r","rx","ry","icon","expand","expanded","g","transform","setPosition","insideBox","b","centeredBox","intersectRect","box","w","h","s","q1","q2","denominator","a","numerator1","numerator2","result","onLine1","onLine2","segmentIntersection","filter","ret","intersectRectFull","intersectEllipse","ellCenter","nodeCenter","si","c","radicand_sqrt","pos","project","atob","len","dot","cabDistance","cylinderRadiusY","shapeLabelOffsetY","toLowerCase","D3Element","_el","attr","insert","el2","insertBefore","querySelector","bbox","rounded","shapeSvg","_ellipse","mobiledeviceportrait","shapes","roundedbox","component","cylinder","cy","person","circle","ellipse","hexagon","sz","n","folder","mobiledevicelandscape","mobiledevice","pipe","robot","headSize","headR","antennaH","antennaR","eyeR","eyeSpacing","earW","earH","bodyW","bodyTop","bodyH","headTop","eyeY","mouthY","mouthW","webbrowser","Undo","versions","lastSavedPos","exportDoc","importDoc","change","tmpPreviousState","func","timeout","context","clearTimeout","setTimeout","apply","debounce","saveNow","beforeChange","deepClone","currentState","splice","doc","structuredClone","JSON","parse","stringify","undo","redo","changed","setSaved","textBlock","gapAfter","field","wrapped","lineHeight","defaultEdgeStyle","Y$","defaultNodeStyle","nD","graphCount","GraphData","nodesMap","edgeVertices","groupsMap","layoutDirection","validatedLayout","colorToVarMap","svg","idPrefix","selectListener","_undo","_gridVisible","_snapToGrid","_gridSize","_skipAutoFit","exportLayout","lo","importLayout","init","layout","addNode","sub","link","nodeStyle","minimumHeight","contentLayout","title","subtitle","nodeWidth","textWidth","HORIZONTAL_PADDING","blocks","textHeight","block","VERTICAL_PADDING","ICON_SIZE","layoutNodeContent","requiredHeight","set","Array","addEdge","fromNode","toNode","initVertex","edgeID","input","charCodeAt","imul","toString","fnv1a36","stableVertexID","userDeletedVertices","addGroup","nodesOrGroups","console","error","Boolean","setNodeSelected","selected","ref","remove","updateEdgesSel","e","clearResolvedLayout","layoutSections","layoutLabelBounds","layoutBounds","layoutTitleBounds","moveNode","disableSnap","skipUndo","snapped","snapToGrid","redrawEdges","redrawGroups","moveEdgeVertex","redrawEdge","moveSelected","insertEdgeVertex","isLabel","deleteEdgeVertex","indexOf","delete","alignTopLeft","contentBounds","calculateContentBounds","offsetX","offsetY","resetPanTransform","currentZoom","getZoom","zoomGroup","graphData","bb","zoom","parentElement","clientWidth","clientHeight","updatePanningOptimized","clearViewState","shouldSkipAutoFit","resetView","updatePanning","removeChild","buildEdge","buildGroup","exportSVG","U","originalSvg","exportSvg","cloneNode","rootAttributes","attributes","removeAttributeNode","setAttributeNode","removeIdPrefix","querySelectorAll","getAttribute","removeAttribute","exportElastic","exportWidth","padding","exportHeight","exportZoomGroup","convertStylesToCustomProperties","script","createElement","replace","firstChild","outerHTML","prefix","reference","matches","startsWith","localName","minX","Infinity","minY","maxX","maxY","left","right","top","bottom","trim","centerX","centerY","approxLabelSize","full","lst","rerender","requiredSavedPoint","endsWith","edgeId","isArray","saved","autoLayout","options","placedNode","placedGroup","placedEdge","interiorRoutePoints","validated","fitToView","alignSelectionV","alignSelectionH","distributeSelectionH","selectedNodes","selectedVertices","allElements","sort","spacing","newX","distributeSelectionV","newY","setEdgeSelected","viewportWidth","viewportHeight","zoomX","zoomY","optimalZoom","finalZoom","translateX","translateY","saveViewState","saveLayoutState","restoreLayoutState","state","isGridVisible","isSnapToGrid","getGridSize","toggleGrid","updateGridDisplay","window","dispatchEvent","CustomEvent","toggleSnapToGrid","snapAllToGrid","snappedX","round","snappedY","existingGrid","existingGridRect","defs","pattern","appendChild","route","previous","buildGraph","data","onNodeSelect","dragMode","body","_buildGraph","elasticEl","addCursorInteraction","setZoom","currentTransform","getCurrentTransform","buildGraphView","innerHTML","fontsinline","A","LICENSE_raw","zoomG","nodesG","edgesG","groupsG","href","exportHref","content","shapeType","AV","setBorderStyle","border","tg","iconHeight","preserveAspectRatio","buildNodeContent","__data","buildNode","completeRoutePoints","edge_utils","l","bg","buildPlacedEdgeLabel","placement","buildEdgeLabel","IW","Zr","cx","p0","topExtension","bottomExtension","hexHeight","pad","findClosestSegment","graph","fnd","dst","POSITIVE_INFINITY","prj","pts","mouseToDrawing","getBoundingClientRect","z","clientX","clientY","addCustomCursorInteraction","conn","ini","elastic","isPanning","panStartX","panStartY","initialTransform","pendingSelectionChange","pendingNavigation","hasDragged","suppressLinkClick","eventListeners","onClick","Element","closest","preventDefault","stopPropagation","md","convertEvent","changedTouches","onMouseMoveHandler","getSelection","setSelection","setTransform","drawingDx","drawingDy","item","update","onMouseMove","ex","ey","onMouseUpHandler","removeEventListener","navigation","boxSelection","shiftKey","location","onMouseUp","onMouseDownHandler","nodeFromEvent","effectiveMode","isSelected","translateMatch","match","parseFloat","getCurrentTransformLocal","startDrawingX","startDrawingY","pt","currentPt","currentDrawingX","currentDrawingY","createElastic","onMouseDown","addEventListener","event","handler","addDnd","existingCleanup","__cursorInteractionCleanup","beforeUnloadHandler","returnValue","setDotSelected","dotEl","mouseMoveHandler","altKey","removePrjDot","keyUpHandler","shortcuts","Yp","Zj","_s","clickHandler","wheelHandler","sign","deltaY","newZoom","svgX","svgY","setZoomCentered","keyDownHandler","shortcut","bl","Ur","newZoomIn","hU","newZoomOut","i1","mD","F","Gn","customInteractionCleanup","getData","handles","handle","b1","b2","scaleMatch","oldZoom","container","newTranslateX","newTranslateY","getBBox","viewStateCache","restoreViewState","defaultOptions","direction","nodeSpacing","layerSpacing","async","resolveAutomatic","diagram","checkMeasuredLinks","childrenByParent","groupsByParent","elkGroups","children","layoutOptions","groupLayoutOptions","root","rootLayoutOptions","owner","lowestCommonGroup","buildLayoutTree","elk","__webpack_require__","then","bind","module","default","readContainer","readResolvedLayout","sources","targets","titleHeight","sourceGroups","parentGroups","targetGroups","current","parentX","parentY","containerX","containerY","childX","requiredNumber","childY","measuredNode","measuredGroup","requiredLabel","readEdge","addOffset","startPoint","bendPoints","endPoint","requiredEndpoint","elementId","endpoints","siblings","fonts","ready","measureGraph","compactLayout","geometry","centerOffset","validateCurrentLayout","isConnected","boundary","SVGGraphicsElement","copyBox","snapshot","completeSnapshot","resolveManual","nodeParents","groupParents","member","parents","isGroup","existing","declaredParents","checkMeasuredBox","measureNode","measureGroup","measureEdge","hasLabel","boxes","flatMap","points","flat","measuredText","measurementSVG","loadDiagramFonts","Promise","all","weight","load","measureSVGText","localeCompare","measurementKey","cached","visibility","pointerEvents","svgTextWrap","split","paragraph","paragraphLines","currentLine","word","parts","breakLongWord","part","nextLine","maxWidth","currentPart","character","nextPart","layoutDirections","TopBottom","BottomTop","LeftRight","RightLeft","model","viewsList","keys","views","layouts","viewKey","elements","relations","collectRels","relationships","rel","people","softwareSystems","containers","el1","components","deploymentNodes","containerInstances","containerId","recAddNodes","infrastructureNodes","view","getView","_graph_view_graph__WEBPACK_IMPORTED_MODULE_0__","jg","rankDirection","automaticLayout","version","groupingIDs","externalContainersBoundariesVisible","softwareSystemId","enterprise","styles","cssClassName","tag","varPrefix","elementViewKey","containerViews","lookupContainerViewKey","tags","technology","encodedViewKey","encodeURIComponent","url","nodeLink","properties","warn","destinationId","routing","level","groupMembers","ADD_VERTEX","ADD_LABEL_VERTEX","DEL_VERTEX","ZOOM_IN","ZOOM_OUT","ZOOM_FIT","ZOOM_100","SELECT_ALL","DESELECT","MOVE_LEFT","MOVE_RIGHT","MOVE_UP","MOVE_DOWN","MOVE_LEFT_FINE","MOVE_RIGHT_FINE","MOVE_UP_FINE","MOVE_DOWN_FINE","TOGGLE_DRAG_MODE","ALIGN_HORIZONTAL","ALIGN_VERTICAL","DISTRIBUTE_HORIZONTAL","DISTRIBUTE_VERTICAL","AUTO_LAYOUT","RESET_POSITION","TOGGLE_GRID","TOGGLE_SNAP_TO_GRID","SNAP_ALL_TO_GRID","list","help","combinations","shift","ctrl","alt","click","wheel","shortcutMap","comboText","_utils_platform__WEBPACK_IMPORTED_MODULE_1__","sy","toUpperCase","react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__","jsxs","jsx","Fragment","colSpan","SA","ke","checkKey","aShortcut","bShortcut","aModifiers","bModifiers","aCount","isMac","navigator","userAgentData","platform","includes","userAgent","KeyboardEvent","metaKey","test","ctrlKey","___CSS_LOADER_URL_IMPORT_0___","URL","___CSS_LOADER_URL_IMPORT_1___","___CSS_LOADER_URL_IMPORT_2___","___CSS_LOADER_URL_IMPORT_3___","___CSS_LOADER_EXPORT___","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default","___CSS_LOADER_URL_REPLACEMENT_0___","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default","___CSS_LOADER_URL_REPLACEMENT_1___","___CSS_LOADER_URL_REPLACEMENT_2___","___CSS_LOADER_URL_REPLACEMENT_3___","names","mappings","sourcesContent","sourceRoot","__WEBPACK_DEFAULT_EXPORT__","styleTagTransform","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default","setAttributes","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default","domAPI","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default","insertStyleElement","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default","_node_modules_pnpm_style_loader_4_0_0_webpack_5_109_2_node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_cjs_js_fonts_css__WEBPACK_IMPORTED_MODULE_6__","locals","_node_modules_pnpm_css_loader_7_1_4_webpack_5_109_2_node_modules_css_loader_dist_cjs_js_style_css__WEBPACK_IMPORTED_MODULE_6__"],"sourceRoot":""} \ No newline at end of file diff --git a/cmd/mdl/webapp/src/graph-view/graph.ts b/cmd/mdl/webapp/src/graph-view/graph.ts index 53cd50dc..fb50ce0a 100644 --- a/cmd/mdl/webapp/src/graph-view/graph.ts +++ b/cmd/mdl/webapp/src/graph-view/graph.ts @@ -161,8 +161,6 @@ export class GraphData { readonly idPrefix: string; /** selectListener receives the selected node in the editor; buildGraph sets it. */ selectListener: (n: Node) => void; - /** dragging is true while the editor user drags this graph's nodes or selection box. */ - dragging = false; private _undo: Undo; private _gridVisible: boolean = false; private _snapToGrid: boolean = true; @@ -602,22 +600,22 @@ export class GraphData { } /** - * removeIdPrefix rewrites the export copy's ids, url(#…) references, and #… - * links that name this graph's own elements back to their saved names, for - * example "g2-arrow" to "arrow" and "url(#g2-arrow)" to "url(#arrow)". Values - * that do not start with this graph's idPrefix, such as node links and image - * URLs, stay unchanged. + * removeIdPrefix rewrites the export copy's ids and url(#…) references that + * name this graph's own elements back to their saved names, for example + * "g2-arrow" to "arrow" and "url(#g2-arrow)" to "url(#arrow)". The renderer + * writes no #… links, so href values (image URLs) are never rewritten, and + * user-authored node links (a.nodeLink) are left exactly as written. */ private removeIdPrefix(svg: SVGSVGElement) { const prefix = this.idPrefix + const reference = `url(#${prefix}` svg.querySelectorAll('*').forEach(el => { + if (el.matches('a.nodeLink')) return for (const attr of Array.from(el.attributes)) { if (attr.name === 'id' && attr.value.startsWith(prefix)) { attr.value = attr.value.slice(prefix.length) - } else if (attr.value.includes(`url(#${prefix}`)) { - attr.value = attr.value.split(`url(#${prefix}`).join('url(#') - } else if (attr.localName === 'href' && attr.value.startsWith(`#${prefix}`)) { - attr.value = '#' + attr.value.slice(prefix.length + 1) + } else if (attr.localName !== 'href' && attr.value.startsWith(reference)) { + attr.value = 'url(#' + attr.value.slice(reference.length) } } }) @@ -1522,7 +1520,6 @@ interface Handle extends Point { function addCustomCursorInteraction(data: GraphData, conn: { nodeFromEvent(e: MouseEvent): Handle | null; setSelection(handles: Handle[]): void; - setDragging(dragging: boolean): void; isSelected(handle: Handle): boolean; getSelection(): Handle[]; getZoom(): number; @@ -1759,16 +1756,13 @@ function addCustomCursorInteraction(data: GraphData, conn: { // Add the drawing coordinate delta to get new position conn.moveNode(item.n, item.x + drawingDx, item.y + drawingDy) }) - conn.setDragging(true) } else if (elastic) { // Update selection box elastic.update(e) - conn.setDragging(true) } } function onMouseUp(e: MouseEvent) { - conn.setDragging(false) const navigation = hasDragged ? null : pendingNavigation if (hasDragged) { suppressLinkClick = true @@ -1928,7 +1922,7 @@ export function addCursorInteraction(data: GraphData, dragMode: 'pan' | 'select' const parent = svg.querySelector('g.edges') let dot = parent.querySelector(`#${data.idPrefix}prj`) if (!dot) { - dot = create.element('circle', {id: `${data.idPrefix}prj`, cx: prj.x, cy: prj.y, r: 7}) + dot = create.element('circle', {id: `${data.idPrefix}prj`, cx: prj.x, cy: prj.y, r: 7}, 'prj') parent.append(dot) } dot.setAttribute('cx', String(prj.x)) @@ -2065,9 +2059,6 @@ export function addCursorInteraction(data: GraphData, dragMode: 'pan' | 'select' data.edgeVertices.forEach(d => setDotSelected(d, handles.some(h => h.id == d.id))) data.selectListener(data.nodes().find(n => n.selected)) }, - setDragging(d: boolean) { - data.dragging = d - }, isSelected(handle: Handle): boolean { return handle.selected }, diff --git a/cmd/mdl/webapp/src/style.css b/cmd/mdl/webapp/src/style.css index 162985ca..406ab48b 100644 --- a/cmd/mdl/webapp/src/style.css +++ b/cmd/mdl/webapp/src/style.css @@ -260,7 +260,7 @@ button:disabled { stroke: #777; fill: rgba(119, 119, 119, 0.2); } -circle#prj { +circle.prj { fill: none; stroke: #777; } @@ -288,9 +288,6 @@ g.node text { fill: #aaa; stroke: #fff; } -#icon-cube { - fill: #aaa; -} /* Ensure all button icons are uncolored */ button .icon,