From 29fb671e69f90ad3b04c6fa8d746caf857f89e77 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Tue, 22 Sep 2026 11:25:05 -0700 Subject: Add shared graph viewer to all chapters --- graph/README.md | 97 +- graph/graph.mk | 11 + .../java/com/seaofnodes/graph/GraphCapture.java | 31 +- .../java/com/seaofnodes/graph/GraphViewer.java | 45 +- graph/test_browser.py | 40 +- graph/test_transport.py | 53 +- graph/web/index.html | 5 +- graph/web/legacy.js | 25 - graph/web/vendor/d3-graphviz.js | 2014 -------------------- graph/web/vendor/graphviz.umd.js | 7 - graph/web/viewer.js | 42 +- 11 files changed, 167 insertions(+), 2203 deletions(-) create mode 100644 graph/graph.mk delete mode 100644 graph/web/legacy.js delete mode 100644 graph/web/vendor/d3-graphviz.js delete mode 100644 graph/web/vendor/graphviz.umd.js (limited to 'graph') diff --git a/graph/README.md b/graph/README.md index e9cef3aa..21ee0d07 100644 --- a/graph/README.md +++ b/graph/README.md @@ -1,22 +1,20 @@ # Shared graph viewer -The browser application lives in `web/` and is shared by chapters 4 and 18–25. +The browser application lives in `web/` and is shared by chapters 1–25. `web/index.html` contains the page and `web/viewer.js` manages playback. `web/layout.js` runs ELK layout in a browser worker; `web/render.js` draws SVG -and handles selection, pan and zoom. `web/legacy.js` loads Graphviz on demand -for earlier chapters. Libraries live in `web/vendor/`, with one checked-in +and handles selection, pan and zoom. Libraries live in `web/vendor/`, with one checked-in copy of each; chapters do not copy them during builds. -From a chapter directory, run `make view`. For chapters 4 and 25, the shared -`GraphViewer` finds +From a chapter directory, run `make view`. The shared `GraphViewer` finds `graph/web/index.html` by walking up from the working directory, serves its directory through the JDK's HTTP server on a local ephemeral port, and opens that web address in the browser. This works from a chapter directory, the repository root, or the root of a linearized checkout. Java launches from elsewhere can specify `-Dsimple.graph.url=` before the main class. -The viewer uses a WebSocket connection. Chapters 4 and 25 send structured -JSON snapshots in each frame; chapters 18–24 still send bare DOT. +The viewer uses a WebSocket connection. Every chapter sends structured +JSON snapshots in each frame. No JavaScript package installation, frontend build, or separate server process is required. For development over HTTP, run this from the repository root: @@ -32,7 +30,7 @@ The initial program compiles on connection. For another program, click **Compile or press **Ctrl+Enter** (**Cmd+Enter** on macOS), then use the arrows to step through the captured frames. Keep `make view` running while using the tab. -In chapters 4 and 25, scroll to zoom, drag to pan, and use **Fit** to show the whole +Scroll to zoom, drag to pan, and use **Fit** to show the whole graph again. Clicking a node shows its full label, type and input slots, and highlights its edges. Selection follows that node's ID across frames; Escape clears it. **Associations** shows scope bindings and lifetime edges, which are @@ -70,23 +68,24 @@ for Firefox testing. Test logs/screenshots are written under `build/graph-browse ## Boundary between chapters and the viewer -Chapters 4 and 25 share the Java viewer plumbing as well as the browser: +All chapters share the Java viewer plumbing as well as the browser: -- `GraphViewer` owns asset discovery, the source/compile loop, frame serialization, - and session shutdown. A chapter's `JSViewer` subclass only invokes its compiler - and attaches/detaches its observer. +- `GraphViewer` owns asset discovery, the source/compile loop and session shutdown. + Each chapter launches it from `SimpleGraphObserver.main`; no separate launcher + class is needed. - `GraphSocket` serves local assets, opens the browser, and handles WebSocket messages. One buffered stream handles both the upgrade and frames. Payloads use exact reads and their advertised length, including 64-bit lengths; continuation frames assemble UTF-8 before decoding, and PING data is echoed. - `GraphCapture` owns nested attempts, buffered snapshots, event numbering, - neighborhood accumulation and disconnect handling. It extends `GraphObserver`. - Chapter subclasses supply roots, phase, parser position and observer detachment. + neighborhood accumulation, serialization and disconnect handling. It extends + `GraphObserver`. Chapter subclasses compile source, attach/detach the observer, + and supply roots, phase and parser position. Each compilation gets fresh capture + state and a new compilation key, even when the previous compilation failed. - `GraphAdapter` supplies node facts and indexed graph/dependency access. Dependency access defaults to an empty set in chapters without those lists. -Chapter 25's private WebSocket implementation is removed. Chapters 18–24 retain -their old transport until migrated. Shared Java has no dependency on chapter classes. +Shared Java has no dependency on chapter classes. The WebSocket listener and built-in asset server bind to 127.0.0.1. The connection messages are: @@ -95,8 +94,7 @@ The connection messages are: | --- | --- | --- | | Compiler to browser | `!` | Request the source program | | Browser to compiler | Source text | Compile and capture a new sequence | -| Compiler to browser | `digraph ...` | One complete DOT snapshot | -| Compiler to browser | JSON `{snap, pos, evt}` | Chapters 4/25's complete graph, parser position and event | +| Compiler to browser | JSON `{snap, pos, evt}` | Complete graph, parser position and event | | Compiler to browser | JSON `{error}` | Compilation failed; the session accepts another program | | Browser to compiler | `+` | Acknowledge/request another frame | | Compiler to browser | `#` | End of sequence | @@ -134,10 +132,7 @@ edges have stable SVG IDs within a compilation. There is no animation yet. One `+` acknowledges the whole frame. The shared writer sends UTF-8 bytes and supports WebSocket's 64-bit length header for frames larger than 65535 bytes. -Legacy chapters' DOT frames may contain a `// POS:` comment identifying the -parser position. The browser owns frame history and backward/forward playback. - -Chapter 25 no longer generates DOT for the interactive viewer. The browser +The browser owns frame history and backward/forward playback. It uses ELK's layered layout with fixed input ports and orthogonal routing. Layout follows def-to-use flow downward, while the displayed arrows point from use to def, matching Simple's edges. Control edges get a higher layout @@ -157,7 +152,7 @@ ELK runs locally from the pinned elkjs 0.12.0 worker; see No npm or Maven step is needed to use it. The linearization workflow includes this directory as a shared root resource. -Chapters 4 and 25 compile the shared Java sources from this directory; the +All chapters compile the shared Java sources from this directory; the interactive viewer also loads the web assets from this checkout. ## Chapter adapters @@ -177,9 +172,8 @@ root deduplication; no boxed integer lists, sets or map keys are needed. Indexed edge access reads each chapter's native storage without copying it into a different collection type. -Both chapters implement `com.seaofnodes.simple.print.SimpleGraphAdapter`, -extending `GraphAdapter`. No changes to `Node` or its subclasses are -needed. The chapter owns classification and extraction; the base owns traversal +Every chapter implements `com.seaofnodes.simple.print.SimpleGraphAdapter`, +extending `GraphAdapter`. The chapter owns classification and extraction; the base owns traversal and snapshot assembly. No new Java interface is involved. For chapter 4: @@ -223,7 +217,7 @@ Functions and compilation-unit boundaries. These are existing IR facts, not computed region membership or a SESE hierarchy. Scope bindings and constant lifetime edges are associations, so they need not constrain CFG layout. Types may be absent on newly constructed nodes. Source locations, grouping, -and delta encoding remain follow-up work. Both chapters use the observer events +and delta encoding remain follow-up work. All chapters use the observer events described below. Make compiles these shared sources directly into each participating chapter's @@ -237,28 +231,28 @@ make -C chapter25 build `build` compiles the compiler and adapter without running tests or opening a browser. Shared source changes trigger recompilation. No Maven executable, Maven-built artifacts, generated source copies or separately installed graph -JARs are needed. Existing `make tests`, `make release` and chapter 25's -`make view` also include the shared sources through their normal prerequisites. -Chapter 4's `make view` depends on `build` and runs the same shared viewer. +JARs are needed. Every `make view` depends on `build` through `graph/graph.mk`. Existing +`make tests` and `make release` also include the shared sources through their +normal prerequisites. For the existing Maven/CI build path, `build-helper:add-source` describes the -same source directory. The two chapter POMs select `../graph`, while the root +same source directory. Chapter POMs select `../graph`, while the root POM defaults to `graph` for linearized checkouts. These entries are independent of the Make build. ## Peephole observers `GraphObserver` is a shared abstract base for `before`, `after`, `phase`, and -`dep` callbacks. Chapter 25's `CodeGen._obs` and chapter 4's `Parser._obs` own the -optional observer. Chapter 4 uses `Parser.PARSER` as its current compilation -context, alongside its existing global `START`. Normal compilation +`dep` callbacks. `Parser._obs` (chapters 2–17) or `CodeGen._obs` (chapters 18–25) owns the +optional observer. Parser-only chapters use `Parser.PARSER` as their current +compilation context, alongside the existing global `START`. Normal compilation leaves it null, so it does no snapshot capture or serialization. Assertions that probe peepholes with `_midAssert` set do not generate observer calls. -Neither `Node` nor `IterPeeps` refers to `JSViewer`. +Compiler hooks refer only to the shared observer base. `GraphCapture` supplies capture and neighborhood logic. Each chapter's small -`SimpleGraphObserver` supplies its compilation context. `JSViewer` installs one -for each compilation and forwards frames to `GraphViewer`. +`SimpleGraphObserver` supplies its compilation context. The shared capture base +resets its state before each compilation and detaches the observer afterward. An I/O failure disables the observer and allows optimization to continue. The observer is detached in a `finally` block when compilation finishes or fails. @@ -269,7 +263,7 @@ The event kinds distinguish the actual capture boundaries: | `BEFORE` | Graph before an attempt that made progress, or contained a nested rewrite | | `RETURN` | Recursive `Node.peephole()` finished, including its local DCE; the caller has not yet attached the returned node | | `APPLY` | A worklist attempt finished after substitution, dependency draining, and unused-node cleanup | -| `PHASE` | Parse completed in chapter 4; Parse, Iter, or Opto completed in chapter 25, including work outside individual peepholes | +| `PHASE` | Parse, Iter, or Opto completed, including work outside individual peepholes | `peep` identifies an attempt; `up` identifies its enclosing attempt, or zero. `node` and `repl` identify the original and result nodes. A zero `repl` on @@ -282,7 +276,7 @@ progress are discarded unless they contain a visible child rewrite. Ancestor before frames are emitted before their children; after frames close the nested attempts. Frame steps are assigned consecutively on emission, while attempt IDs may have gaps. A failed compilation can leave an unfinished attempt; the next -compilation gets a fresh observer and compilation key. +compilation starts with empty capture state and a new compilation key. Capture includes the active attempts and returned node as extra roots, so nodes not yet attached by the parser remain visible. Dead originals are not added as @@ -309,15 +303,16 @@ Actual graph diffs and explicit rule annotations can refine this later. The browser keeps the event alongside its snapshot and layout. It labels and highlights the current step, but does not yet collapse nested rewrites or move the camera to their neighborhoods. Chapter 4 uses the same event model, with -defs/uses for its neighborhoods and no worklist or dependency lists. Its parser -retains the final Return as a root after scope cleanup. - -Chapter 25's parser no longer accepts `#showGraph;`; use the browser to inspect -the graph and **Save SVG** for a static figure. Earlier chapters retain their -directive until migrated. Chapter 25 still supports the independent `--dot` -dump option; it and `GraphVisualizer` can be retired separately. - -Constant-folding peepholes already exist in chapter02. Chapters 03 and 04 add -variables and algebraic rewrites, respectively, and are useful next adapters. -They should not need the later chapters' `CodeGen`, worklist, or type hierarchy -to use the shared display. +defs/uses for its neighborhoods and no worklist or dependency lists. It retains the final Return as a root after scope cleanup. + +The compiler DOT dump flag, parser graph directive, Java DOT generators and old +viewer/transport classes have been removed from all chapters. Use **Save SVG** +for new documentation figures. Existing `.gv` sources, their checked-in SVGs +and the documentation Make rules for regenerating those SVGs remain. + +Chapter 1 has no peepholes and supplies one completed parse snapshot. Chapter 2 +shows constant folding; chapters 3 and 4 add variables and algebraic rewrites. +Chapters 9–17 also capture worklist application and dependency neighborhoods; +chapters 18–25 use their CodeGen phase/context. Each chapter retains only its +`SimpleGraphAdapter`, `SimpleGraphObserver`, an optional observer field and the +compiler callbacks/accessors needed by those two classes. diff --git a/graph/graph.mk b/graph/graph.mk new file mode 100644 index 00000000..1d5eb95a --- /dev/null +++ b/graph/graph.mk @@ -0,0 +1,11 @@ +# Include after defining chapter source variables. Works in linearized checkouts too. +GRAPH_DIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) +graph_javas := $(wildcard $(GRAPH_DIR)/src/main/java/com/seaofnodes/graph/*.java) +main_javas += $(graph_javas) + +# Defining view here must not change the chapter's default target. +graph_goal := $(.DEFAULT_GOAL) +.PHONY: view +view: build + java -ea -cp "$(CLZDIR)/main" com.seaofnodes.simple.print.SimpleGraphObserver +.DEFAULT_GOAL := $(graph_goal) diff --git a/graph/src/main/java/com/seaofnodes/graph/GraphCapture.java b/graph/src/main/java/com/seaofnodes/graph/GraphCapture.java index 0e2f538d..6fc40b5f 100644 --- a/graph/src/main/java/com/seaofnodes/graph/GraphCapture.java +++ b/graph/src/main/java/com/seaofnodes/graph/GraphCapture.java @@ -5,23 +5,43 @@ import java.util.ArrayList; import java.util.BitSet; import java.util.UUID; -/** Shared capture, event nesting and neighborhoods. Chapter hooks only read the IR. */ +/** Shared compilation lifecycle, capture, event nesting and neighborhoods. */ public abstract class GraphCapture extends GraphObserver { private final GraphAdapter _graph; - private final String _comp = UUID.randomUUID().toString(); + private String _comp; + private GraphSocket _server; private final ArrayList _peeps = new ArrayList<>(); private long _next, _step; - private boolean _off; + private boolean _off = true; protected GraphCapture(GraphAdapter graph) { _graph = graph; } + // Create the chapter's compiler, attach this observer, and run its phases. + protected abstract void compile(String src); + // The remaining hooks only inspect context, except detach which clears it. protected abstract String phase(); protected abstract int pos(); protected abstract void roots(ArrayList roots); protected abstract void detach(); - protected abstract void frame(GraphSnapshot snap, int pos, GraphEvent evt) throws IOException; + final void run(String src, GraphSocket server) { + _comp = UUID.randomUUID().toString(); + _next = _step = 0; + _server = server; + _off = false; + try { + compile(src); + } finally { + _off = true; + try { + detach(); + } finally { + _peeps.clear(); + _server = null; + } + } + } private class Peep { final N node; @@ -114,11 +134,10 @@ public abstract class GraphCapture extends GraphObserver { // Assign steps on emission; attempts without progress do not consume frames. snap = new GraphSnapshot(snap.ver(), _comp, _step++, snap.roots(), snap.nodes()); try { - frame(snap, pos, evt); + _server.put(GraphJson.frame(snap, pos, evt)); } catch( IOException e ) { // A disconnected display must not interrupt optimization. _off = true; - detach(); System.err.println("Graph viewer disconnected: " + e.getMessage()); } } diff --git a/graph/src/main/java/com/seaofnodes/graph/GraphViewer.java b/graph/src/main/java/com/seaofnodes/graph/GraphViewer.java index dcb2e337..e70a12cf 100644 --- a/graph/src/main/java/com/seaofnodes/graph/GraphViewer.java +++ b/graph/src/main/java/com/seaofnodes/graph/GraphViewer.java @@ -5,16 +5,9 @@ import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; -/** Shared launcher and source/compile loop. Subclasses supply their compiler. */ -public abstract class GraphViewer implements AutoCloseable { - private final GraphSocket _server; - - protected GraphViewer() throws IOException { _server = new GraphSocket(viewerURI(), 12345); } - protected abstract void compile(String src); - - protected final void frame(GraphSnapshot snap, int pos, GraphEvent evt) throws IOException { - _server.put(GraphJson.frame(snap, pos, evt)); - } +/** Shared launcher and source/compile loop. Chapter observers supply their compiler. */ +public final class GraphViewer { + private GraphViewer() {} private static URI viewerURI() throws IOException { String url = System.getProperty("simple.graph.url"); @@ -27,23 +20,23 @@ public abstract class GraphViewer implements AutoCloseable { + "or set -Dsimple.graph.url="); } - public final void run() throws IOException { - _server.put("!"); - while( true ) { - String src = _server.get(); - if( src == null || src.equals("null") ) return; - if( src.equals("+") ) continue; // Frames are currently sent eagerly. - System.out.println(src); - try { - compile(src); - } catch( RuntimeException e ) { - System.err.println(e); - _server.put(GraphJson.error(e.toString())); - } finally { - _server.put("#"); + public static void run(GraphCapture obs) throws IOException { + try( var server = new GraphSocket(viewerURI(), 12345) ) { + server.put("!"); + while( true ) { + String src = server.get(); + if( src == null || src.equals("null") ) return; + if( src.equals("+") ) continue; // Frames are currently sent eagerly. + System.out.println(src); + try { + obs.run(src, server); + } catch( RuntimeException e ) { + System.err.println(e); + server.put(GraphJson.error(e.toString())); + } finally { + server.put("#"); + } } } } - - @Override public final void close() throws IOException { _server.close(); } } diff --git a/graph/test_browser.py b/graph/test_browser.py index 90223119..52cb5fa6 100644 --- a/graph/test_browser.py +++ b/graph/test_browser.py @@ -23,14 +23,14 @@ from playwright.sync_api import sync_playwright def check(chapter, browser_name): number = int(chapter.removeprefix("chapter")) - package = "com.seaofnodes.simple." + ("print." if number == 4 or number >= 20 else "") + package = "com.seaofnodes.simple.print." artifacts = ROOT / "build/graph-browser" / (chapter + "-" + browser_name) artifacts.mkdir(parents=True, exist_ok=True) log = artifacts / "compiler.log" with log.open("w") as output: process = subprocess.Popen([ "java", "-ea", "-Dsimple.graph.open=false", "-cp", "build/classes/main", - package + "JSViewer"], cwd=ROOT/chapter, stdout=output, stderr=subprocess.STDOUT) + package + "SimpleGraphObserver"], cwd=ROOT/chapter, stdout=output, stderr=subprocess.STDOUT) try: for _ in range(200): text = log.read_text() @@ -49,12 +49,15 @@ def check(chapter, browser_name): page.wait_for_function("done && current === 0 && !rendering", timeout=15000) assert page.locator("#graph svg g.node").count() > 0 assert page.locator("#doPrev").is_disabled() - page.locator("#doNext").click() - page.wait_for_function("current === 1 && !rendering") - page.locator("#doPrev").click() - page.wait_for_function("current === 0 && !rendering") - sources = ("return 1 + 2;", "int x=arg+1; return x+x+2;" if number == 4 else - "int x=0; while(x 1: + page.locator("#doNext").click() + page.wait_for_function("current === 1 && !rendering") + page.locator("#doPrev").click() + page.wait_for_function("current === 0 && !rendering") + sources = (("return 1;", "return 2;") if number == 1 else + ("return 1 + 2;", "return 3 * 4;") if number == 2 else + ("return 1 + 2;", "int x=arg+1; return x+x+2;") if number <= 5 else + ("return 1 + 2;", "int x=0; while(x generation > previous && done && current === 0 && !rendering", arg=previous, timeout=15000) total = int(page.locator("#len").inner_text()) - assert total > 1 - for index in range(1, total): - page.locator("#doNext").click() + assert total >= 1 + # Later chapters also parse library code. Sample long histories. + steps = (range(1, total) if total <= 100 else + sorted({1, total // 4, total // 2, 3 * total // 4, total - 2, total - 1})) + print(chapter, total, "frames captured; rendering", len(steps) + 1, flush=True) + prev = 0 + for index in steps: + if index == prev + 1: + page.locator("#doNext").click() + else: + page.evaluate("index => render(index)", index) page.wait_for_function("index => current === index && !rendering", arg=index) + prev = index assert page.locator("#doNext").is_disabled() assert "error" not in page.locator("#status").inner_text().lower() - if number in (4, 25): + if total > 1: assert page.locator("#elk g.node").count() == page.evaluate("frames[current].snap.nodes.length") # Revisit cached geometry and keep the selected node across steps. page.evaluate("""() => { @@ -86,7 +98,7 @@ def check(chapter, browser_name): page.evaluate("delete layout.run") assert page.locator("#detail").is_visible() page.keyboard.press("Escape") - print(chapter, browser_name, total, "frames rendered:", source, flush=True) + print(chapter, browser_name, "playback passed:", source, flush=True) assert not errors, errors page.screenshot(path=str(artifacts / "viewer.png")) page.locator("#doExit").click() @@ -117,7 +129,7 @@ def check(chapter, browser_name): if process.poll() is None: process.terminate() process.wait(timeout=5) - print(chapter, browser_name, "startup, forward/back, recompile, all frames, disconnect, and offline startup passed") + print(chapter, browser_name, "startup, forward/back, recompile, playback, disconnect, and offline startup passed") if __name__ == "__main__": diff --git a/graph/test_transport.py b/graph/test_transport.py index d0026b97..f1834403 100644 --- a/graph/test_transport.py +++ b/graph/test_transport.py @@ -46,15 +46,15 @@ def compile_frames(stream): def check(chapter): root = Path(__file__).resolve().parent.parent number = int(chapter.removeprefix("chapter")) - assert number == 4 or 18 <= number <= 25 + assert 1 <= number <= 25 chapter_dir = root / chapter - package = "com.seaofnodes.simple." + ("print." if number == 4 or number >= 20 else "") + package = "com.seaofnodes.simple.print." log = root / "build" / "graph-transport" / (chapter + ".log") log.parent.mkdir(parents=True, exist_ok=True) with log.open("w") as output: process = subprocess.Popen( ["java", "-ea", "-Dsimple.graph.open=false", "-cp", - "build/classes/main", package + "JSViewer"], + "build/classes/main", package + "SimpleGraphObserver"], cwd=chapter_dir, stdout=output, stderr=subprocess.STDOUT) try: deadline = time.monotonic() + 10 @@ -69,9 +69,8 @@ def check(chapter): time.sleep(.05) assert url and url.startswith("http://127.0.0.1:"), log.read_text() # The browser must be able to load all assets before connecting. - for asset in ("index.html", "viewer.js", "layout.js", "render.js", "legacy.js", - "vendor/elk-api.js", "vendor/elk-worker.min.js", "vendor/d3.v7.min.js", - "vendor/d3-graphviz.js", "vendor/graphviz.umd.js"): + for asset in ("index.html", "viewer.js", "layout.js", "render.js", + "vendor/elk-api.js", "vendor/elk-worker.min.js", "vendor/d3.v7.min.js"): with urllib.request.urlopen(url.rsplit("/", 1)[0] + "/" + asset, timeout=3) as response: assert response.status == 200 @@ -93,9 +92,8 @@ def check(chapter): else: raise AssertionError("Responded before headers ended: " + repr(early)) client.settimeout(3) - shared = number in (4, 25) # A frame in the same write as the upgrade must not get lost in a reader buffer. - client.sendall(b"\r\n" + (packet(b'hello', op=9) if shared else b'')) + client.sendall(b"\r\n" + packet(b'hello', op=9)) with client.makefile("rb") as stream: assert stream.readline() == b"HTTP/1.1 101 Switching Protocols\r\n" headers = [] @@ -107,25 +105,24 @@ def check(chapter): headers.append(line) assert b"Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n" in headers assert stream.read(3) == b"\x81\x01!", "Missing source request" - if shared: - assert frame(stream) == (10, b'hello') - # Larger than both the old 1 KB buffer and the 16-bit length field. - data = packet(b' ' * 70000 + b'return 3;') - client.sendall(data[:3]) - time.sleep(.05) - for start in range(3, len(data), 509): - client.sendall(data[start:start + 509]) - frames = compile_frames(stream) - assert frames and all('snap' in f for f in frames) - # Split a UTF-8 code point across fragments, with an interleaved PING. - client.sendall(packet(b'\xc3', fin=False) + packet(b'ping', op=9) + packet(b'\xa9', op=0)) - assert frame(stream) == (10, b'ping') - errors = compile_frames(stream) - assert any('error' in f for f in errors) - assert '\u00e9' in log.read_text() - client.sendall(packet(b'return 4;')) - frames = compile_frames(stream) - assert frames and all('snap' in f for f in frames) + assert frame(stream) == (10, b'hello') + # Larger than both the old 1 KB buffer and the 16-bit length field. + data = packet(b' ' * 70000 + b'return 3;') + client.sendall(data[:3]) + time.sleep(.05) + for start in range(3, len(data), 509): + client.sendall(data[start:start + 509]) + frames = compile_frames(stream) + assert frames and all('snap' in f for f in frames) + # Split a UTF-8 code point across fragments, with an interleaved PING. + client.sendall(packet(b'return 3; \xc3', fin=False) + packet(b'ping', op=9) + packet(b'\xa9', op=0)) + assert frame(stream) == (10, b'ping') + errors = compile_frames(stream) + assert any('error' in f for f in errors) + assert '\u00e9' in log.read_text() + client.sendall(packet(b'return 4;')) + frames = compile_frames(stream) + assert frames and all('snap' in f for f in frames) # Masked 'null' asks the compiler to exit normally. mask = b"abcd" payload = bytes(byte ^ mask[i % 4] for i, byte in enumerate(b"null")) @@ -144,7 +141,7 @@ def check(chapter): process.terminate() process.wait(timeout=5) print(chapter + ": HTTP assets, fragmented upgrade, greeting, and shutdown passed" + - ("; large frames, UTF-8 fragments, ping, and compile-error recovery passed" if number in (4, 25) else "")) + "; large frames, UTF-8 fragments, ping, and compile-error recovery passed") if __name__ == "__main__": diff --git a/graph/web/index.html b/graph/web/index.html index f91f1710..771d3d4a 100644 --- a/graph/web/index.html +++ b/graph/web/index.html @@ -11,7 +11,7 @@ #program { width:min(600px,80vw); vertical-align:middle; } #status { margin-top:4px; } #graph { min-height:0; overflow:hidden; position:relative; background:#fafbfc; } - #elk, #dot { width:100%; height:100%; } + #elk { width:100%; height:100%; } #graph svg { display:block; } .tools { display:flex; flex-wrap:wrap; align-items:center; gap:14px; margin-top:8px; font-size:12px; } .hint { color:#616c78; } @@ -42,7 +42,6 @@ -
@@ -61,7 +60,7 @@
-
+
0 diff --git a/graph/web/legacy.js b/graph/web/legacy.js deleted file mode 100644 index 4c1b7ef8..00000000 --- a/graph/web/legacy.js +++ /dev/null @@ -1,25 +0,0 @@ -// Only earlier chapters need Graphviz. Load it on the first bare-DOT frame. -let dotView; -async function drawDot(dot) { - if (!dotView) { - dotView = (async () => { - for (const src of ["vendor/graphviz.umd.js", "vendor/d3-graphviz.js"]) { - await new Promise((resolve, reject) => { - const script = document.createElement("script"); - script.src = src; script.onload = resolve; - script.onerror = () => reject(new Error("Cannot load " + src)); - document.head.append(script); - }); - } - return new Promise((resolve, reject) => { - const view = d3.select("#dot").graphviz({useWorker: false, fit: true}) - .onerror(reject).on("initEnd", () => resolve(view)) - .transition(() => d3.transition("main").ease(d3.easeLinear).duration(500)); - }); - })(); - } - const view = await dotView; - const host = document.getElementById("dot"); - view.width(host.clientWidth).height(host.clientHeight); - await new Promise((resolve, reject) => view.onerror(reject).renderDot(dot, resolve)); -} diff --git a/graph/web/vendor/d3-graphviz.js b/graph/web/vendor/d3-graphviz.js deleted file mode 100644 index 7439ba65..00000000 --- a/graph/web/vendor/d3-graphviz.js +++ /dev/null @@ -1,2014 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-selection'), require('d3-dispatch'), require('d3-transition'), require('d3-timer'), require('d3-interpolate'), require('d3-zoom'), require('d3-format'), require('d3-path')) : - typeof define === 'function' && define.amd ? define(['exports', 'd3-selection', 'd3-dispatch', 'd3-transition', 'd3-timer', 'd3-interpolate', 'd3-zoom', 'd3-format', 'd3-path'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["d3-graphviz"] = {}, global.d3, global.d3, global.d3, global.d3, global.d3, global.d3, global.d3, global.d3)); -})(this, (function (exports, d3, d3Dispatch, d3Transition, d3Timer, d3Interpolate, d3Zoom, d3Format, d3Path) { 'use strict'; - - function _interopNamespaceDefault(e) { - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { return e[k]; } - }); - } - }); - } - n.default = e; - return Object.freeze(n); - } - - var d3__namespace = /*#__PURE__*/_interopNamespaceDefault(d3); - - function _arrayLikeToArray(r, a) { - (null == a || a > r.length) && (a = r.length); - for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; - return n; - } - function _arrayWithoutHoles(r) { - if (Array.isArray(r)) return _arrayLikeToArray(r); - } - function _defineProperty(e, r, t) { - return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { - value: t, - enumerable: !0, - configurable: !0, - writable: !0 - }) : e[r] = t, e; - } - function _iterableToArray(r) { - if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); - } - function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - function _toConsumableArray(r) { - return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); - } - function _toPrimitive(t, r) { - if ("object" != typeof t || !t) return t; - var e = t[Symbol.toPrimitive]; - if (void 0 !== e) { - var i = e.call(t, r || "default"); - if ("object" != typeof i) return i; - throw new TypeError("@@toPrimitive must return a primitive value."); - } - return ("string" === r ? String : Number)(t); - } - function _toPropertyKey(t) { - var i = _toPrimitive(t, "string"); - return "symbol" == typeof i ? i : i + ""; - } - function _unsupportedIterableToArray(r, a) { - if (r) { - if ("string" == typeof r) return _arrayLikeToArray(r, a); - var t = {}.toString.call(r).slice(8, -1); - return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; - } - } - - function extractElementData(element) { - var datum = {}; - var tag = element.node().nodeName; - datum.tag = tag; - if (tag == '#text') { - datum.text = element.text(); - } else if (tag == '#comment') { - datum.comment = element.text(); - } - datum.attributes = {}; - var attributes = element.node().attributes; - if (attributes) { - for (var i = 0; i < attributes.length; i++) { - var attribute = attributes[i]; - var name = attribute.name; - var value = attribute.value; - datum.attributes[name] = value; - } - } - var transform = element.node().transform; - if (transform && transform.baseVal.numberOfItems != 0) { - var matrix = transform.baseVal.consolidate().matrix; - datum.translation = { - x: matrix.e, - y: matrix.f - }; - datum.scale = matrix.a; - } - if (tag == 'ellipse') { - datum.center = { - x: datum.attributes.cx, - y: datum.attributes.cy - }; - } - if (tag == 'polygon') { - var points = element.attr('points').split(' '); - var x = points.map(function (p) { - return p.split(',')[0]; - }); - var y = points.map(function (p) { - return p.split(',')[1]; - }); - var xmin = Math.min.apply(null, x); - var xmax = Math.max.apply(null, x); - var ymin = Math.min.apply(null, y); - var ymax = Math.max.apply(null, y); - var bbox = { - x: xmin, - y: ymin, - width: xmax - xmin, - height: ymax - ymin - }; - datum.bbox = bbox; - datum.center = { - x: (xmin + xmax) / 2, - y: (ymin + ymax) / 2 - }; - } - if (tag == 'path') { - var d = element.attr('d'); - var points = d.split(/[A-Z ]/); - points.shift(); - var x = points.map(function (p) { - return +p.split(',')[0]; - }); - var y = points.map(function (p) { - return +p.split(',')[1]; - }); - var xmin = Math.min.apply(null, x); - var xmax = Math.max.apply(null, x); - var ymin = Math.min.apply(null, y); - var ymax = Math.max.apply(null, y); - var bbox = { - x: xmin, - y: ymin, - width: xmax - xmin, - height: ymax - ymin - }; - datum.bbox = bbox; - datum.center = { - x: (xmin + xmax) / 2, - y: (ymin + ymax) / 2 - }; - datum.totalLength = element.node().getTotalLength(); - } - if (tag == 'text') { - datum.center = { - x: element.attr('x'), - y: element.attr('y') - }; - } - if (tag == '#text') { - datum.text = element.text(); - } else if (tag == '#comment') { - datum.comment = element.text(); - } - return datum; - } - function extractAllElementsData(element) { - var datum = extractElementData(element); - datum.children = []; - var children = d3__namespace.selectAll(element.node().childNodes); - children.each(function () { - var childData = extractAllElementsData(d3__namespace.select(this)); - childData.parent = datum; - datum.children.push(childData); - }); - return datum; - } - function createElement(data) { - if (data.tag == '#text') { - return document.createTextNode(""); - } else if (data.tag == '#comment') { - return document.createComment(data.comment); - } else { - return document.createElementNS('http://www.w3.org/2000/svg', data.tag); - } - } - function createElementWithAttributes(data) { - var elementNode = createElement(data); - var element = d3__namespace.select(elementNode); - var attributes = data.attributes; - for (var _i = 0, _Object$keys = Object.keys(attributes); _i < _Object$keys.length; _i++) { - var attributeName = _Object$keys[_i]; - var attributeValue = attributes[attributeName]; - element.attr(attributeName, attributeValue); - } - return elementNode; - } - function replaceElement(element, data) { - var parent = d3__namespace.select(element.node().parentNode); - var newElementNode = createElementWithAttributes(data); - var newElement = parent.insert(function () { - return newElementNode; - }, function () { - return element.node(); - }); - element.remove(); - return newElement; - } - function insertElementData(element, datum) { - element.datum(datum); - element.data([datum], function (d) { - return d.key; - }); - } - function insertAllElementsData(element, datum) { - insertElementData(element, datum); - var children = d3__namespace.selectAll(element.node().childNodes); - children.each(function (d, i) { - insertAllElementsData(d3__namespace.select(this), datum.children[i]); - }); - } - function insertChildren(element, index) { - var children = element.selectAll(function () { - return element.node().childNodes; - }); - children = children.data(function (d) { - return d.children; - }, function (d) { - return d.tag + '-' + index; - }); - var childrenEnter = children.enter().append(function (d) { - return createElement(d); - }); - var childrenExit = children.exit(); - childrenExit = childrenExit.remove(); - children = childrenEnter.merge(children); - var childTagIndexes = {}; - children.each(function (childData) { - var childTag = childData.tag; - if (childTagIndexes[childTag] == null) { - childTagIndexes[childTag] = 0; - } - var childIndex = childTagIndexes[childTag]++; - attributeElement.call(this, childData, childIndex); - }); - } - function attributeElement(data) { - var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - var element = d3__namespace.select(this); - data.tag; - var attributes = data.attributes; - var currentAttributes = element.node().attributes; - if (currentAttributes) { - for (var i = 0; i < currentAttributes.length; i++) { - var currentAttribute = currentAttributes[i]; - var name = currentAttribute.name; - if (name.split(':')[0] != 'xmlns' && currentAttribute.namespaceURI) { - var namespaceURIParts = currentAttribute.namespaceURI.split('/'); - var namespace = namespaceURIParts[namespaceURIParts.length - 1]; - name = namespace + ':' + name; - } - if (!(name in attributes)) { - attributes[name] = null; - } - } - } - for (var _i2 = 0, _Object$keys2 = Object.keys(attributes); _i2 < _Object$keys2.length; _i2++) { - var attributeName = _Object$keys2[_i2]; - element.attr(attributeName, attributes[attributeName]); - } - if (data.text) { - element.text(data.text); - } - insertChildren(element, index); - } - - function zoom (enable) { - this._options.zoom = enable; - if (this._options.zoom && !this._zoomBehavior) { - createZoomBehavior.call(this); - } else if (!this._options.zoom && this._zoomBehavior) { - this._zoomSelection.on(".zoom", null); - this._zoomBehavior = null; - } - return this; - } - function createZoomBehavior() { - var graphvizInstance = this; - function zoomed(event) { - var g = d3__namespace.select(svg.node().querySelector("g")); - g.attr('transform', event.transform); - graphvizInstance._dispatch.call('zoom', graphvizInstance); - } - var root = this._selection; - var svg = d3__namespace.select(root.node().querySelector("svg")); - if (svg.size() == 0) { - return this; - } - this._zoomSelection = svg; - var zoomBehavior = d3Zoom.zoom().scaleExtent(this._options.zoomScaleExtent).translateExtent(this._options.zoomTranslateExtent).interpolate(d3Interpolate.interpolate).on("zoom", zoomed); - this._zoomBehavior = zoomBehavior; - var g = d3__namespace.select(svg.node().querySelector("g")); - svg.call(zoomBehavior); - if (!this._active) { - translateZoomBehaviorTransform.call(this, g); - } - this._originalTransform = d3Zoom.zoomTransform(svg.node()); - return this; - } - function getTranslatedZoomTransform(selection) { - // Get the current zoom transform for the top level svg and - // translate it uniformly with the given selection, using the - // difference between the translation specified in the selection's - // data and it's saved previous translation. The selection is - // normally the top level g element of the graph. - var oldTranslation = this._translation; - var oldScale = this._scale; - var newTranslation = selection.datum().translation; - var newScale = selection.datum().scale; - var t = d3Zoom.zoomTransform(this._zoomSelection.node()); - if (oldTranslation) { - t = t.scale(1 / oldScale); - t = t.translate(-oldTranslation.x, -oldTranslation.y); - } - t = t.translate(newTranslation.x, newTranslation.y); - t = t.scale(newScale); - return t; - } - function translateZoomBehaviorTransform(selection) { - // Translate the current zoom transform for the top level svg - // uniformly with the given selection, using the difference - // between the translation specified in the selection's data and - // it's saved previous translation. The selection is normally the - // top level g element of the graph. - this._zoomBehavior.transform(this._zoomSelection, getTranslatedZoomTransform.call(this, selection)); - - // Save the selections's new translation and scale. - this._translation = selection.datum().translation; - this._scale = selection.datum().scale; - - // Set the original zoom transform to the translation and scale specified in - // the selection's data. - this._originalTransform = d3Zoom.zoomIdentity.translate(selection.datum().translation.x, selection.datum().translation.y).scale(selection.datum().scale); - } - function resetZoom(transition) { - // Reset the zoom transform to the original zoom transform. - var selection = this._zoomSelection; - if (transition) { - selection = selection.transition(transition); - } - selection.call(this._zoomBehavior.transform, this._originalTransform); - return this; - } - function zoomScaleExtent(extent) { - this._options.zoomScaleExtent = extent; - return this; - } - function zoomTranslateExtent(extent) { - this._options.zoomTranslateExtent = extent; - return this; - } - function zoomBehavior() { - return this._zoomBehavior || null; - } - function zoomSelection() { - return this._zoomSelection || null; - } - - function pathTween(points, d1) { - return function () { - var pointInterpolators = points.map(function (p) { - return d3Interpolate.interpolate([p[0][0], p[0][1]], [p[1][0], p[1][1]]); - }); - return function (t) { - return t < 1 ? "M" + pointInterpolators.map(function (p) { - return p(t); - }).join("L") : d1; - }; - }; - } - function pathTweenPoints(node, d1, precision, precisionIsRelative) { - var path0 = node; - var path1 = path0.cloneNode(); - var n0 = path0.getTotalLength(); - var n1 = (path1.setAttribute("d", d1), path1).getTotalLength(); - - // Uniform sampling of distance based on specified precision. - var distances = [0]; - var i = 0; - var dt = precisionIsRelative ? precision : precision / Math.max(n0, n1); - while ((i += dt) < 1) { - distances.push(i); - } - distances.push(1); - - // Compute point-interpolators at each distance. - var points = distances.map(function (t) { - var p0 = path0.getPointAtLength(t * n0); - var p1 = path1.getPointAtLength(t * n1); - return [[p0.x, p0.y], [p1.x, p1.y]]; - }); - return points; - } - - function data () { - return this._data || null; - } - function isEdgeElementParent(datum) { - return datum.attributes["class"] == 'edge' || datum.tag == 'a' && datum.parent.tag == 'g' && datum.parent.parent.attributes["class"] == 'edge'; - } - function isEdgeElement(datum) { - return datum.parent && isEdgeElementParent(datum.parent); - } - function getEdgeGroup(datum) { - if (datum.parent.attributes["class"] == 'edge') { - return datum.parent; - } else { - // datum.parent.tag == 'g' && datum.parent.parent.tag == 'g' && datum.parent.parent.parent.attributes.class == 'edge' - return datum.parent.parent.parent; - } - } - function getEdgeTitle(datum) { - return getEdgeGroup(datum).children.find(function (e) { - return e.tag == 'title'; - }); - } - - function render (callback) { - if (this._busy) { - this._queue.push(this.render.bind(this, callback)); - return this; - } - this._dispatch.call('renderStart', this); - if (this._transitionFactory) { - d3Timer.timeout(function () { - // Decouple from time spent. See https://github.com/d3/d3-timer/issues/27 - this._transition = d3Transition.transition(this._transitionFactory()); - _render.call(this, callback); - }.bind(this), 0); - } else { - _render.call(this, callback); - } - return this; - } - function _render(callback) { - var transitionInstance = this._transition; - var fade = this._options.fade && transitionInstance != null; - var tweenPaths = this._options.tweenPaths; - var tweenShapes = this._options.tweenShapes; - var convertEqualSidedPolygons = this._options.convertEqualSidedPolygons; - var growEnteringEdges = this._options.growEnteringEdges && transitionInstance != null; - var attributer = this._attributer; - var graphvizInstance = this; - function insertChildren(element) { - var children = element.selectAll(function () { - return element.node().childNodes; - }); - children = children.data(function (d) { - return d.children; - }, function (d) { - return d.key; - }); - var childrenEnter = children.enter().append(function (d) { - var element = createElement(d); - if (d.tag == '#text' && fade) { - element.nodeValue = d.text; - } - return element; - }); - if (fade || growEnteringEdges && isEdgeElementParent(element.datum())) { - var childElementsEnter = childrenEnter.filter(function (d) { - return d.tag[0] == '#' ? null : this; - }).each(function (d) { - var childEnter = d3__namespace.select(this); - for (var _i = 0, _Object$keys = Object.keys(d.attributes); _i < _Object$keys.length; _i++) { - var attributeName = _Object$keys[_i]; - var attributeValue = d.attributes[attributeName]; - childEnter.attr(attributeName, attributeValue); - } - }); - childElementsEnter.filter(function (d) { - return d.tag == 'svg' || d.tag == 'g' ? null : this; - }).style("opacity", 0.0); - } - var childrenExit = children.exit(); - if (attributer) { - childrenExit.each(attributer); - } - if (transitionInstance) { - childrenExit = childrenExit.transition(transitionInstance); - if (fade) { - childrenExit.filter(function (d) { - return d.tag[0] == '#' ? null : this; - }).style("opacity", 0.0); - } - } - childrenExit = childrenExit.remove(); - children = childrenEnter.merge(children).order(); - children.each(attributeElement); - } - function attributeElement(data) { - var element = d3__namespace.select(this); - if (data.tag == "svg") { - var options = graphvizInstance._options; - if (options.width != null || options.height != null) { - var width = options.width; - var height = options.height; - if (width == null) { - width = data.attributes.width.replace('pt', '') * 4 / 3; - } else { - element.attr("width", width); - data.attributes.width = width; - } - if (height == null) { - height = data.attributes.height.replace('pt', '') * 4 / 3; - } else { - element.attr("height", height); - data.attributes.height = height; - } - if (!options.fit) { - element.attr("viewBox", "0 0 ".concat(width * 3 / 4 / options.scale, " ").concat(height * 3 / 4 / options.scale)); - data.attributes.viewBox = "0 0 ".concat(width * 3 / 4 / options.scale, " ").concat(height * 3 / 4 / options.scale); - } - } - if (options.scale != 1 && (options.fit || options.width == null && options.height == null)) { - width = data.attributes.viewBox.split(' ')[2]; - height = data.attributes.viewBox.split(' ')[3]; - element.attr("viewBox", "0 0 ".concat(width / options.scale, " ").concat(height / options.scale)); - data.attributes.viewBox = "0 0 ".concat(width / options.scale, " ").concat(height / options.scale); - } - } - if (attributer) { - element.each(attributer); - } - var tag = data.tag; - var attributes = data.attributes; - var currentAttributes = element.node().attributes; - if (currentAttributes) { - for (var i = 0; i < currentAttributes.length; i++) { - var currentAttribute = currentAttributes[i]; - var name = currentAttribute.name; - if (name.split(':')[0] != 'xmlns' && currentAttribute.namespaceURI) { - var namespaceURIParts = currentAttribute.namespaceURI.split('/'); - var namespace = namespaceURIParts[namespaceURIParts.length - 1]; - name = namespace + ':' + name; - } - if (!(name in attributes)) { - attributes[name] = null; - } - } - } - var convertShape = false; - var convertPrevShape = false; - if (tweenShapes && transitionInstance) { - if ((this.nodeName == 'polygon' || this.nodeName == 'ellipse') && data.alternativeOld) { - convertPrevShape = true; - } - if ((tag == 'polygon' || tag == 'ellipse') && data.alternativeNew) { - convertShape = true; - } - if (this.nodeName == 'polygon' && tag == 'polygon' && data.alternativeOld) { - var prevData = extractElementData(element); - var prevPoints = prevData.attributes.points; - if (!convertEqualSidedPolygons) { - var nPrevPoints = prevPoints.split(' ').length; - var points = data.attributes.points; - var nPoints = points.split(' ').length; - if (nPoints == nPrevPoints) { - convertShape = false; - convertPrevShape = false; - } - } - } - if (convertPrevShape) { - var prevPathData = data.alternativeOld; - var pathElement = replaceElement(element, prevPathData); - pathElement.data([data], function () { - return data.key; - }); - element = pathElement; - } - if (convertShape) { - var newPathData = data.alternativeNew; - tag = 'path'; - attributes = newPathData.attributes; - } - } - var elementTransition = element; - if (transitionInstance) { - elementTransition = elementTransition.transition(transitionInstance); - if (fade) { - elementTransition.filter(function (d) { - return d.tag[0] == '#' ? null : this; - }).style("opacity", 1.0); - } - elementTransition.filter(function (d) { - return d.tag[0] == '#' ? null : this; - }).on("end", function (d) { - d3__namespace.select(this).attr('style', d && d.attributes && d.attributes.style || null); - }); - } - var growThisPath = growEnteringEdges && tag == 'path' && data.offset; - if (growThisPath) { - var totalLength = data.totalLength; - element.attr("stroke-dasharray", totalLength + " " + totalLength).attr("stroke-dashoffset", totalLength).attr('transform', 'translate(' + data.offset.x + ',' + data.offset.y + ')'); - attributes["stroke-dashoffset"] = 0; - attributes['transform'] = 'translate(0,0)'; - elementTransition.attr("stroke-dashoffset", attributes["stroke-dashoffset"]).attr('transform', attributes['transform']).on("start", function () { - d3__namespace.select(this).style('opacity', null); - }).on("end", function () { - d3__namespace.select(this).attr('stroke-dashoffset', null).attr('stroke-dasharray', null).attr('transform', null); - }); - } - var moveThisPolygon = growEnteringEdges && tag == 'polygon' && isEdgeElement(data) && data.offset && data.parent.children[3].tag == 'path'; - if (moveThisPolygon) { - var edgePath = d3__namespace.select(element.node().parentNode.querySelector("path")); - var p0 = edgePath.node().getPointAtLength(0); - var p1 = edgePath.node().getPointAtLength(data.totalLength); - var p2 = edgePath.node().getPointAtLength(data.totalLength - 1); - var angle1 = Math.atan2(p1.y - p2.y, p1.x - p2.x) * 180 / Math.PI; - var x = p0.x - p1.x + data.offset.x; - var y = p0.y - p1.y + data.offset.y; - element.attr('transform', 'translate(' + x + ',' + y + ')'); - elementTransition.attrTween("transform", function () { - return function (t) { - var p = edgePath.node().getPointAtLength(data.totalLength * t); - var p2 = edgePath.node().getPointAtLength(data.totalLength * t + 1); - var angle = Math.atan2(p2.y - p.y, p2.x - p.x) * 180 / Math.PI - angle1; - x = p.x - p1.x + data.offset.x * (1 - t); - y = p.y - p1.y + data.offset.y * (1 - t); - return 'translate(' + x + ',' + y + ') rotate(' + angle + ' ' + p1.x + ' ' + p1.y + ')'; - }; - }).on("start", function () { - d3__namespace.select(this).style('opacity', null); - }).on("end", function () { - d3__namespace.select(this).attr('transform', null); - }); - } - var tweenThisPath = tweenPaths && transitionInstance && tag == 'path' && element.attr('d') != null; - for (var _i2 = 0, _Object$keys2 = Object.keys(attributes); _i2 < _Object$keys2.length; _i2++) { - var attributeName = _Object$keys2[_i2]; - var attributeValue = attributes[attributeName]; - if (tweenThisPath && attributeName == 'd') { - var points = (data.alternativeOld || data).points; - if (points) { - elementTransition.attrTween("d", pathTween(points, attributeValue)); - } - } else { - if (attributeName == 'transform' && data.translation) { - if (transitionInstance) { - var onEnd = elementTransition.on("end"); - elementTransition.on("start", function () { - if (graphvizInstance._zoomBehavior) { - // Update the transform to transition to, just before the transition starts - // in order to catch changes between the transition scheduling to its start. - elementTransition.tween("attr.transform", function () { - var node = this; - return function (t) { - node.setAttribute("transform", d3Interpolate.interpolateTransformSvg(d3Zoom.zoomTransform(graphvizInstance._zoomSelection.node()).toString(), getTranslatedZoomTransform.call(graphvizInstance, element).toString())(t)); - }; - }); - } - }).on("end", function () { - onEnd.call(this); - // Update the zoom transform to the new translated transform - if (graphvizInstance._zoomBehavior) { - translateZoomBehaviorTransform.call(graphvizInstance, element); - } - }); - } else { - if (graphvizInstance._zoomBehavior) { - // Update the transform attribute to set with the current pan translation - translateZoomBehaviorTransform.call(graphvizInstance, element); - attributeValue = getTranslatedZoomTransform.call(graphvizInstance, element).toString(); - } - } - } - elementTransition.attr(attributeName, attributeValue); - } - } - if (convertShape) { - elementTransition.on("end", function (d, i, nodes) { - pathElement = d3__namespace.select(this); - var newElement = replaceElement(pathElement, d); - newElement.data([d], function () { - return d.key; - }); - }); - } - if (data.text) { - elementTransition.text(data.text); - } - insertChildren(element); - } - var root = this._selection; - if (transitionInstance != null) { - // Ensure original SVG shape elements are restored after transition before rendering new graph - var jobs = this._jobs; - if (graphvizInstance._active) { - jobs.push(null); - return this; - } else { - root.transition(transitionInstance).transition().duration(0).on("end", function () { - graphvizInstance._active = false; - if (jobs.length != 0) { - jobs.shift(); - graphvizInstance.render(); - } - }); - this._active = true; - } - } - if (transitionInstance != null) { - root.transition(transitionInstance).on("start", function () { - graphvizInstance._dispatch.call('transitionStart', graphvizInstance); - }).on("end", function () { - graphvizInstance._dispatch.call('transitionEnd', graphvizInstance); - }).transition().duration(0).on("start", function () { - graphvizInstance._dispatch.call('restoreEnd', graphvizInstance); - graphvizInstance._dispatch.call('end', graphvizInstance); - if (callback) { - callback.call(graphvizInstance); - } - }); - } - var data = this._data; - var svg = root.selectAll("svg").data([data], function (d) { - return d.key; - }); - svg = svg.enter().append("svg").merge(svg); - attributeElement.call(svg.node(), data); - if (this._options.zoom && !this._zoomBehavior) { - createZoomBehavior.call(this); - } - graphvizInstance._dispatch.call('renderEnd', graphvizInstance); - if (transitionInstance == null) { - this._dispatch.call('end', this); - if (callback) { - callback.call(this); - } - } - return this; - } - - function graphvizVersion () { - return this._graphvizVersion; - } - - var io=ArrayBuffer,H=Uint8Array,Qe=Uint16Array,so=Int16Array,qe=Int32Array,pr=function(p,c,d){if(H.prototype.slice)return H.prototype.slice.call(p,c,d);(c==null||c<0)&&(c=0),(d==null||d>p.length)&&(d=p.length);var s=new H(d-c);return s.set(p.subarray(c,d)),s},Ye=function(p,c,d,s){if(H.prototype.fill)return H.prototype.fill.call(p,c,d,s);for((d==null||d<0)&&(d=0),(s==null||s>p.length)&&(s=p.length);dp.length)&&(s=p.length);d2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],T=function(p,c,d){var s=new Error(c||po[p]);if(s.code=p,Error.captureStackTrace&&Error.captureStackTrace(s,T),!d)throw s;return s},jr=function(p,c,d){for(var s=0,f=0;s>>0},co=function(p,c){var d=p[0]|p[1]<<8|p[2]<<16;if(d==3126568&&p[3]==253){var s=p[4],f=s>>5&1,m=s>>2&1,_=s&3,h=s>>6;s&8&&T(0);var M=6-f,I=_==3?4:_,Q=jr(p,M,I);M+=I;var Z=h?1<>3);z=q+(q>>3)*(p[5]&7);}z>2145386496&&T(1);var X=new H((c==1?Y||z:c?0:z)+12);return X[0]=1,X[4]=4,X[8]=8,{b:M+Z,y:0,l:0,d:Q,w:c&&c!=1?c:X.subarray(12),e:z,o:new qe(X.buffer,0,3),u:Y,c:m,m:Math.min(131072,z)}}else if((d>>4|p[3]<<20)==25481893)return lo(p,4)+8;T(0);},Xe=function(p){for(var c=0;1<d&&T(3);for(var m=1<0;){var S=Xe(_+1),P=s>>3,ae=(1<>(s&7)&ae,w=(1<w&&(J-=j)),Y[++h]=--J,J==-1?(_+=J,V[--Q]=h):_-=J,!J)do{var ie=s>>3;M=(p[ie]|p[ie+1]<<8)>>(s&7)&3,s+=2,h+=M;}while(M==3)}(h>255||_)&&T(0);for(var b=0,k=(m>>1)+(m>>3)+3,se=m-1,oe=0;oe<=h;++oe){var K=Y[oe];if(K<1){z[oe]=-K;continue}for(I=0;I=Q)}}for(b&&T(0),I=0;I>3,{b:f,s:V,n:re,t:q}]},fo=function(p,c){var d=0,s=-1,f=new H(292),m=p[c],_=f.subarray(0,256),h=f.subarray(256,268),M=new Qe(f.buffer,268);if(m<128){var I=je(p,c+1,6),Q=I[0],Z=I[1];c+=m;var Y=Q<<3,z=p[c];z||T(0);for(var q=0,X=0,V=Z.b,re=V,S=(++c<<3)-8+Xe(z);S-=V,!(S>3;if(q+=(p[P]|p[P+1]<<8)>>(S&7)&(1<>3,X+=(p[P]|p[P+1]<<8)>>(S&7)&(1<255&&T(0);}else {for(s=m-127;d>4,_[d+1]=ae&15;}++c;}var J=0;for(d=0;d11&&T(0),J+=w&&1<0;--d){var oe=M[d];Ye(se,d,oe,M[d-1]=oe+h[d]*(1<h&&Z>3,z=(p[Y]|p[Y+1]<<8|p[Y+2]<<16)>>(Q&7);M=(M<>2,_=m<<1,h=m+_;Ze(p.subarray(s,s+=p[0]|p[1]<<8),c.subarray(0,m),d),Ze(p.subarray(s,s+=p[2]|p[3]<<8),c.subarray(m,_),d),Ze(p.subarray(s,s+=p[4]|p[5]<<8),c.subarray(_,h),d),Ze(p.subarray(s),c.subarray(h),d);},yo=function(p,c,d){var s,f=c.b,m=p[f],_=m>>1&3;c.l=m&1;var h=m>>3|p[f+1]<<5|p[f+2]<<13,M=(f+=3)+h;if(_==1)return f>=p.length?void 0:(c.b=f+1,d?(Ye(d,p[f],c.y,c.y+=h),d):Ye(new H(h),p[f]));if(!(M>p.length)){if(_==0)return c.b=M,d?(d.set(p.subarray(f,M),c.y),c.y+=h,d):pr(p,f,M);if(_==2){var I=p[f],Q=I&3,Z=I>>2&3,Y=I>>4,z=0,q=0;Q<2?Z&1?Y|=p[++f]<<4|(Z&2&&p[++f]<<12):Y=I>>3:(q=Z,Z<2?(Y|=(p[++f]&63)<<4,z=p[f]>>6|p[++f]<<2):Z==2?(Y|=p[++f]<<4|(p[++f]&3)<<12,z=p[f]>>2|p[++f]<<6):(Y|=p[++f]<<4|(p[++f]&63)<<12,z=p[f]>>6|p[++f]<<2|p[++f]<<10)),++f;var X=d?d.subarray(c.y,c.y+c.m):new H(c.m),V=X.length-Y;if(Q==0)X.set(p.subarray(f,f+=Y),V);else if(Q==1)Ye(X,p[f++],V);else {var re=c.h;if(Q==2){var S=fo(p,f);z+=f-(f=S[0]),c.h=re=S[1];}else re||T(0);(q?wo:Ze)(p.subarray(f,f+=z),X.subarray(V),re);}var P=p[f++];if(P){P==255?P=(p[f++]|p[f++]<<8)+32512:P>127&&(P=P-128<<8|p[f++]);var ae=p[f++];ae&3&&T(0);for(var J=[mo,_o,vo],w=2;w>-1;--w){var j=ae>>(w<<1)+2&3;if(j==1){var W=new H([0,0,p[f++]]);J[w]={s:W.subarray(2,3),n:W.subarray(0,1),t:new Qe(W.buffer,0,1),b:0};}else j==2?(s=je(p,f,9-(w&1)),f=s[0],J[w]=s[1]):j==3&&(c.t||T(0),J[w]=c.t[w]);}var ie=c.t=J,b=ie[0],k=ie[1],se=ie[2],oe=p[M-1];oe||T(0);var K=(M<<3)-8+Xe(oe)-se.b,L=K>>3,A=0,Le=(p[L]|p[L+1]<<8)>>(K&7)&(1<>3;var Be=(p[L]|p[L+1]<<8)>>(K&7)&(1<>3;var Re=(p[L]|p[L+1]<<8)>>(K&7)&(1<>3;var $e=1<>>(K&7)&$e-1);L=(K-=dr[Ve])>>3;var me=ho[Ve]+((p[L]|p[L+1]<<8|p[L+2]<<16)>>(K&7)&(1<>3;var _e=go[Ne]+((p[L]|p[L+1]<<8|p[L+2]<<16)>>(K&7)&(1<>3,Le=se.t[Le]+((p[L]|p[L+1]<<8)>>(K&7)&(1<>3,Re=b.t[Re]+((p[L]|p[L+1]<<8)>>(K&7)&(1<>3,Be=k.t[Be]+((p[L]|p[L+1]<<8)>>(K&7)&(1<3)c.o[2]=c.o[1],c.o[1]=c.o[0],c.o[0]=ce-=3;else {var Ge=ce-(_e!=0);Ge?(ce=Ge==3?c.o[0]-1:c.o[Ge],Ge>1&&(c.o[2]=c.o[1]),c.o[1]=c.o[0],c.o[0]=ce):ce=c.o[0];}for(var w=0;w<_e;++w)X[A+w]=X[V+w];A+=_e,V+=_e;var Ee=A-ce;if(Ee<0){var De=-Ee,We=c.e+Ee;De>me&&(De=me);for(var w=0;w{typeof document<"u"?document.currentScript?.src:void 0;return function(c={}){var d,s=c,f,m,_=new Promise((e,r)=>{f=e,m=r;}),M=Object.assign({},s),I="./this.program",Q=(e,r)=>{throw r},Z="";function Y(e){return Z+e}var z,q,X=console.log.bind(console),V=console.error.bind(console);Object.assign(s,M),M=null;var re;s.wasmBinary&&(re=s.wasmBinary);var S,P=!1;function J(e,r){e||_e(r);}var w,j,W,b,k,oe;function K(){var e=S.buffer;s.HEAP8=w=new Int8Array(e),s.HEAP16=W=new Int16Array(e),s.HEAPU8=j=new Uint8Array(e),s.HEAPU16=new Uint16Array(e),s.HEAP32=b=new Int32Array(e),s.HEAPU32=k=new Uint32Array(e),s.HEAPF32=new Float32Array(e),s.HEAPF64=oe=new Float64Array(e);}var L=[],A=[],Le=[];function Re(){Ae(L);}function Ne(){!s.noFSInit&&!o.init.initialized&&o.init(),o.ignorePermissions=!1,Ae(A);}function Pe(){Ae(Le);}function Ve(e){A.unshift(e);}var ye=0,be=null;function ce(e){ye++;}function me(e){if(ye--,ye==0&&(be)){var r=be;be=null,r();}}function _e(e){e="Aborted("+e+")",V(e),P=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw m(r),r}var Ge="data:application/octet-stream;base64,",Ee=e=>e.startsWith(Ge),De=e=>e.startsWith("file://");function We(){var e="graphvizlib.wasm";return Ee(e)?e:Y(e)}var Je;function fr(e){if(e==Je&&re)return new Uint8Array(re);throw "both async and sync fetching of the wasm failed"}function Jr(e){return re?Promise.resolve().then(()=>fr(e)):z(e).then(r=>new Uint8Array(r),()=>fr(e))}function vr(e,r,t){return Jr(e).then(n=>WebAssembly.instantiate(n,r)).then(t,n=>{V(`failed to asynchronously prepare wasm: ${n}`),_e(n);})}function Sr(e,r,t,n){return !e&&typeof WebAssembly.instantiateStreaming=="function"&&!Ee(r)&&!De(r)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(a=>{var i=WebAssembly.instantiateStreaming(a,t);return i.then(n,function(u){return V(`wasm streaming compile failed: ${u}`),V("falling back to ArrayBuffer instantiation"),vr(r,t,n)})}):vr(r,t,n)}function Hr(){return {a:Qt}}function Tr(){var e=Hr();function r(n,a){return N=n.exports,S=N.B,K(),Ve(N.C),me(),N}ce();function t(n){r(n.instance);}return Je||(Je=We()),Sr(re,Je,e,t).catch(m),{}}var R,$,Qr={172808:(e,r)=>{var t=ue(e),n=ue(r);o.createPath("/",C.dirname(t)),o.writeFile(C.join("/",t),n);}};function qr(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e;}var Ae=e=>{for(;e.length>0;)e.shift()(s);};class $r{constructor(r){this.excPtr=r,this.ptr=r-24;}set_type(r){k[this.ptr+4>>2]=r;}get_type(){return k[this.ptr+4>>2]}set_destructor(r){k[this.ptr+8>>2]=r;}get_destructor(){return k[this.ptr+8>>2]}set_caught(r){r=r?1:0,w[this.ptr+12]=r;}get_caught(){return w[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,w[this.ptr+13]=r;}get_rethrown(){return w[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t);}set_adjusted_ptr(r){k[this.ptr+16>>2]=r;}get_adjusted_ptr(){return k[this.ptr+16>>2]}get_exception_ptr(){var r=Yr(this.get_type());if(r)return k[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var mr=0,Ar=(e,r,t)=>{var n=new $r(e);throw n.init(r,t),mr=e,mr},C={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var a=e[n];a==="."?e.splice(n,1):a===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--);}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=C.isAbs(e),t=e.substr(-1)==="/";return e=C.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=C.splitPath(e),t=r[0],n=r[1];return !t&&!n?".":(n&&(n=n.substr(0,n.length-1)),t+n)},basename:e=>{if(e==="/")return "/";e=C.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:(...e)=>C.normalize(e.join("/")),join2:(e,r)=>C.normalize(e+"/"+r)},et=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return e=>crypto.getRandomValues(e);_e("initRandomDevice");},_r=e=>(_r=et())(e),he={resolve:(...e)=>{for(var r="",t=!1,n=e.length-1;n>=-1&&!t;n--){var a=n>=0?e[n]:o.cwd();if(typeof a!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!a)return "";r=a+"/"+r,t=C.isAbs(a);}return r=C.normalizeArray(r.split("/").filter(i=>!!i),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=he.resolve(e).substr(1),r=he.resolve(r).substr(1);function t(E){for(var G=0;G=0&&E[x]==="";x--);return G>x?[]:E.slice(G,x-G+1)}for(var n=t(e.split("/")),a=t(r.split("/")),i=Math.min(n.length,a.length),u=i,l=0;l{for(var n=r+t,a=r;e[a]&&!(a>=n);)++a;if(a-r>16&&e.buffer&&gr)return gr.decode(e.subarray(r,a));for(var i="";r>10,56320|E&1023);}}return i},er=[],rr=e=>{for(var r=0,t=0;t=55296&&n<=57343?(r+=4,++t):r+=3;}return r},tr=(e,r,t,n)=>{if(!(n>0))return 0;for(var a=t,i=t+n-1,u=0;u=55296&&l<=57343){var v=e.charCodeAt(++u);l=65536+((l&1023)<<10)|v&1023;}if(l<=127){if(t>=i)break;r[t++]=l;}else if(l<=2047){if(t+1>=i)break;r[t++]=192|l>>6,r[t++]=128|l&63;}else if(l<=65535){if(t+2>=i)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63;}else {if(t+3>=i)break;r[t++]=240|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63;}}return r[t]=0,t-a};function or(e,r,t){var n=rr(e)+1,a=new Array(n),i=tr(e,a,0,a.length);return r&&(a.length=i),a}var rt=()=>{if(!er.length){var e=null;if(!e)return null;er=or(e,!0);}return er.shift()},Me={ttys:[],init(){},shutdown(){},register(e,r){Me.ttys[e]={input:[],output:[],ops:r},o.registerDevice(e,Me.stream_ops);},stream_ops:{open(e){var r=Me.ttys[e.node.rdev];if(!r)throw new o.ErrnoError(43);e.tty=r,e.seekable=!1;},close(e){e.tty.ops.fsync(e.tty);},fsync(e){e.tty.ops.fsync(e.tty);},read(e,r,t,n,a){if(!e.tty||!e.tty.ops.get_char)throw new o.ErrnoError(60);for(var i=0,u=0;u0&&(X(Fe(e.output,0)),e.output=[]);},ioctl_tcgets(e){return {c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,r,t){return 0},ioctl_tiocgwinsz(e){return [24,80]}},default_tty1_ops:{put_char(e,r){r===null||r===10?(V(Fe(e.output,0)),e.output=[]):r!=0&&e.output.push(r);},fsync(e){e.output&&e.output.length>0&&(V(Fe(e.output,0)),e.output=[]);}}},tt=(e,r)=>(j.fill(0,e,e+r),e),hr=(e,r)=>Math.ceil(e/r)*r,wr=e=>{e=hr(e,65536);var r=Zr(65536,e);return r?tt(r,e):0},D={ops_table:null,mount(e){return D.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(o.isBlkdev(t)||o.isFIFO(t))throw new o.ErrnoError(63);D.ops_table||={dir:{node:{getattr:D.node_ops.getattr,setattr:D.node_ops.setattr,lookup:D.node_ops.lookup,mknod:D.node_ops.mknod,rename:D.node_ops.rename,unlink:D.node_ops.unlink,rmdir:D.node_ops.rmdir,readdir:D.node_ops.readdir,symlink:D.node_ops.symlink},stream:{llseek:D.stream_ops.llseek}},file:{node:{getattr:D.node_ops.getattr,setattr:D.node_ops.setattr},stream:{llseek:D.stream_ops.llseek,read:D.stream_ops.read,write:D.stream_ops.write,allocate:D.stream_ops.allocate,mmap:D.stream_ops.mmap,msync:D.stream_ops.msync}},link:{node:{getattr:D.node_ops.getattr,setattr:D.node_ops.setattr,readlink:D.node_ops.readlink},stream:{}},chrdev:{node:{getattr:D.node_ops.getattr,setattr:D.node_ops.setattr},stream:o.chrdev_stream_ops}};var a=o.createNode(e,r,t,n);return o.isDir(a.mode)?(a.node_ops=D.ops_table.dir.node,a.stream_ops=D.ops_table.dir.stream,a.contents={}):o.isFile(a.mode)?(a.node_ops=D.ops_table.file.node,a.stream_ops=D.ops_table.file.stream,a.usedBytes=0,a.contents=null):o.isLink(a.mode)?(a.node_ops=D.ops_table.link.node,a.stream_ops=D.ops_table.link.stream):o.isChrdev(a.mode)&&(a.node_ops=D.ops_table.chrdev.node,a.stream_ops=D.ops_table.chrdev.stream),a.timestamp=Date.now(),e&&(e.contents[r]=a,e.timestamp=a.timestamp),a},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var n=1048576;r=Math.max(r,t*(t>>0),t!=0&&(r=Math.max(r,256));var a=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(a.subarray(0,e.usedBytes),0);}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)e.contents=null,e.usedBytes=0;else {var t=e.contents;e.contents=new Uint8Array(r),t&&e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r;}},node_ops:{getattr(e){var r={};return r.dev=o.isChrdev(e.mode)?e.id:1,r.ino=e.id,r.mode=e.mode,r.nlink=1,r.uid=0,r.gid=0,r.rdev=e.rdev,o.isDir(e.mode)?r.size=4096:o.isFile(e.mode)?r.size=e.usedBytes:o.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&D.resizeFileStorage(e,r.size);},lookup(e,r){throw o.genericErrors[44]},mknod(e,r,t,n){return D.createNode(e,r,t,n)},rename(e,r,t){if(o.isDir(e.mode)){var n;try{n=o.lookupNode(r,t);}catch{}if(n)for(var a in n.contents)throw new o.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp;},unlink(e,r){delete e.contents[r],e.timestamp=Date.now();},rmdir(e,r){var t=o.lookupNode(e,r);for(var n in t.contents)throw new o.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now();},readdir(e){var r=[".",".."];for(var t of Object.keys(e.contents))r.push(t);return r},symlink(e,r,t){var n=D.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!o.isLink(e.mode))throw new o.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,a){var i=e.node.contents;if(a>=e.node.usedBytes)return 0;var u=Math.min(e.node.usedBytes-a,n);if(u>8&&i.subarray)r.set(i.subarray(a,a+u),t);else for(var l=0;l0||t+r{var a=`al ${e}`;z(e).then(i=>{r(new Uint8Array(i)),a&&me();},i=>{if(t)t();else throw `Loading data file "${e}" failed.`}),a&&ce();},nt=(e,r,t,n,a,i)=>{o.createDataFile(e,r,t,n,a,i);},at=[],it=(e,r,t,n)=>{typeof Browser<"u"&&Browser.init();var a=!1;return at.forEach(i=>{a||i.canHandle(r)&&(i.handle(e,r,t,n),a=!0);}),a},st=(e,r,t,n,a,i,u,l,v,E)=>{var G=r?he.resolve(C.join2(e,r)):e;function B(y){function O(te){E?.(),l||nt(e,r,te,n,a,v),i?.(),me();}it(y,G,O,()=>{u?.(),me();})||O(y);}ce(),typeof t=="string"?ot(t,B,u):B(t);},ut=e=>{var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t},nr=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},o={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:class{constructor(e){this.name="ErrnoError",this.errno=e;}},genericErrors:{},filesystems:null,syncFSRequests:0,FSStream:class{constructor(){this.shared={};}get object(){return this.node}set object(e){this.node=e;}get isRead(){return (this.flags&2097155)!==1}get isWrite(){return (this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e;}get position(){return this.shared.position}set position(e){this.shared.position=e;}},FSNode:class{constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=o.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n,this.readMode=365,this.writeMode=146;}get read(){return (this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode;}get write(){return (this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode;}get isFolder(){return o.isDir(this.mode)}get isDevice(){return o.isChrdev(this.mode)}},lookupPath(e,r={}){if(e=he.resolve(e),!e)return {path:"",node:null};var t={follow_mount:!0,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new o.ErrnoError(32);for(var n=e.split("/").filter(x=>!!x),a=o.root,i="/",u=0;u40)throw new o.ErrnoError(32)}}return {path:i,node:a}},getPath(e){for(var r;;){if(o.isRoot(e)){var t=e.mount.mountpoint;return r?t[t.length-1]!=="/"?`${t}/${r}`:t+r:t}r=r?`${e.name}/${r}`:e.name,e=e.parent;}},hashName(e,r){for(var t=0,n=0;n>>0)%o.nameTable.length},hashAddNode(e){var r=o.hashName(e.parent.id,e.name);e.name_next=o.nameTable[r],o.nameTable[r]=e;},hashRemoveNode(e){var r=o.hashName(e.parent.id,e.name);if(o.nameTable[r]===e)o.nameTable[r]=e.name_next;else for(var t=o.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next;}},lookupNode(e,r){var t=o.mayLookup(e);if(t)throw new o.ErrnoError(t);for(var n=o.hashName(e.id,r),a=o.nameTable[n];a;a=a.name_next){var i=a.name;if(a.parent.id===e.id&&i===r)return a}return o.lookup(e,r)},createNode(e,r,t,n){var a=new o.FSNode(e,r,t,n);return o.hashAddNode(a),a},destroyNode(e){o.hashRemoveNode(e);},isRoot(e){return e===e.parent},isMountpoint(e){return !!e.mounted},isFile(e){return (e&61440)===32768},isDir(e){return (e&61440)===16384},isLink(e){return (e&61440)===40960},isChrdev(e){return (e&61440)===8192},isBlkdev(e){return (e&61440)===24576},isFIFO(e){return (e&61440)===4096},isSocket(e){return (e&49152)===49152},flagsToPermissionString(e){var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions(e,r){return o.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!o.isDir(e.mode))return 54;var r=o.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){try{var t=o.lookupNode(e,r);return 20}catch{}return o.nodePermissions(e,"wx")},mayDelete(e,r,t){var n;try{n=o.lookupNode(e,r);}catch(i){return i.errno}var a=o.nodePermissions(e,"wx");if(a)return a;if(t){if(!o.isDir(n.mode))return 54;if(o.isRoot(n)||o.getPath(n)===o.cwd())return 10}else if(o.isDir(n.mode))return 31;return 0},mayOpen(e,r){return e?o.isLink(e.mode)?32:o.isDir(e.mode)&&(o.flagsToPermissionString(r)!=="r"||r&512)?31:o.nodePermissions(e,o.flagsToPermissionString(r)):44},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=o.MAX_OPEN_FDS;e++)if(!o.streams[e])return e;throw new o.ErrnoError(33)},getStreamChecked(e){var r=o.getStream(e);if(!r)throw new o.ErrnoError(8);return r},getStream:e=>o.streams[e],createStream(e,r=-1){return e=Object.assign(new o.FSStream,e),r==-1&&(r=o.nextfd()),e.fd=r,o.streams[r]=e,e},closeStream(e){o.streams[e]=null;},dupStream(e,r=-1){var t=o.createStream(e,r);return t.stream_ops?.dup?.(t),t},chrdev_stream_ops:{open(e){var r=o.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open?.(e);},llseek(){throw new o.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){o.devices[e]={stream_ops:r};},getDevice:e=>o.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push(...n.mounts);}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=!1),o.syncFSRequests++,o.syncFSRequests>1&&V(`warning: ${o.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=o.getMounts(o.root.mount),n=0;function a(u){return o.syncFSRequests--,r(u)}function i(u){if(u)return i.errored?void 0:(i.errored=!0,a(u));++n>=t.length&&a(null);}t.forEach(u=>{if(!u.type.syncfs)return i(null);u.type.syncfs(u,e,i);});},mount(e,r,t){var n=t==="/",a=!t,i;if(n&&o.root)throw new o.ErrnoError(10);if(!n&&!a){var u=o.lookupPath(t,{follow_mount:!1});if(t=u.path,i=u.node,o.isMountpoint(i))throw new o.ErrnoError(10);if(!o.isDir(i.mode))throw new o.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},v=e.mount(l);return v.mount=l,l.root=v,n?o.root=v:i&&(i.mounted=l,i.mount&&i.mount.mounts.push(l)),v},unmount(e){var r=o.lookupPath(e,{follow_mount:!1});if(!o.isMountpoint(r.node))throw new o.ErrnoError(28);var t=r.node,n=t.mounted,a=o.getMounts(n);Object.keys(o.nameTable).forEach(u=>{for(var l=o.nameTable[u];l;){var v=l.name_next;a.includes(l.mount)&&o.destroyNode(l),l=v;}}),t.mounted=null;var i=t.mount.mounts.indexOf(n);t.mount.mounts.splice(i,1);},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=o.lookupPath(e,{parent:!0}),a=n.node,i=C.basename(e);if(!i||i==="."||i==="..")throw new o.ErrnoError(28);var u=o.mayCreate(a,i);if(u)throw new o.ErrnoError(u);if(!a.node_ops.mknod)throw new o.ErrnoError(63);return a.node_ops.mknod(a,i,r,t)},create(e,r){return r=r!==void 0?r:438,r&=4095,r|=32768,o.mknod(e,r,0)},mkdir(e,r){return r=r!==void 0?r:511,r&=1023,r|=16384,o.mknod(e,r,0)},mkdirTree(e,r){for(var t=e.split("/"),n="",a=0;a"u"&&(t=r,r=438),r|=8192,o.mknod(e,r,t)},symlink(e,r){if(!he.resolve(e))throw new o.ErrnoError(44);var t=o.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new o.ErrnoError(44);var a=C.basename(r),i=o.mayCreate(n,a);if(i)throw new o.ErrnoError(i);if(!n.node_ops.symlink)throw new o.ErrnoError(63);return n.node_ops.symlink(n,a,e)},rename(e,r){var t=C.dirname(e),n=C.dirname(r),a=C.basename(e),i=C.basename(r),u,l,v;if(u=o.lookupPath(e,{parent:!0}),l=u.node,u=o.lookupPath(r,{parent:!0}),v=u.node,!l||!v)throw new o.ErrnoError(44);if(l.mount!==v.mount)throw new o.ErrnoError(75);var E=o.lookupNode(l,a),G=he.relative(e,n);if(G.charAt(0)!==".")throw new o.ErrnoError(28);if(G=he.relative(r,t),G.charAt(0)!==".")throw new o.ErrnoError(55);var x;try{x=o.lookupNode(v,i);}catch{}if(E!==x){var B=o.isDir(E.mode),y=o.mayDelete(l,a,B);if(y)throw new o.ErrnoError(y);if(y=x?o.mayDelete(v,i,B):o.mayCreate(v,i),y)throw new o.ErrnoError(y);if(!l.node_ops.rename)throw new o.ErrnoError(63);if(o.isMountpoint(E)||x&&o.isMountpoint(x))throw new o.ErrnoError(10);if(v!==l&&(y=o.nodePermissions(l,"w"),y))throw new o.ErrnoError(y);o.hashRemoveNode(E);try{l.node_ops.rename(E,v,i),E.parent=v;}catch(O){throw O}finally{o.hashAddNode(E);}}},rmdir(e){var r=o.lookupPath(e,{parent:!0}),t=r.node,n=C.basename(e),a=o.lookupNode(t,n),i=o.mayDelete(t,n,!0);if(i)throw new o.ErrnoError(i);if(!t.node_ops.rmdir)throw new o.ErrnoError(63);if(o.isMountpoint(a))throw new o.ErrnoError(10);t.node_ops.rmdir(t,n),o.destroyNode(a);},readdir(e){var r=o.lookupPath(e,{follow:!0}),t=r.node;if(!t.node_ops.readdir)throw new o.ErrnoError(54);return t.node_ops.readdir(t)},unlink(e){var r=o.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new o.ErrnoError(44);var n=C.basename(e),a=o.lookupNode(t,n),i=o.mayDelete(t,n,!1);if(i)throw new o.ErrnoError(i);if(!t.node_ops.unlink)throw new o.ErrnoError(63);if(o.isMountpoint(a))throw new o.ErrnoError(10);t.node_ops.unlink(t,n),o.destroyNode(a);},readlink(e){var r=o.lookupPath(e),t=r.node;if(!t)throw new o.ErrnoError(44);if(!t.node_ops.readlink)throw new o.ErrnoError(28);return he.resolve(o.getPath(t.parent),t.node_ops.readlink(t))},stat(e,r){var t=o.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new o.ErrnoError(44);if(!n.node_ops.getattr)throw new o.ErrnoError(63);return n.node_ops.getattr(n)},lstat(e){return o.stat(e,!0)},chmod(e,r,t){var n;if(typeof e=="string"){var a=o.lookupPath(e,{follow:!t});n=a.node;}else n=e;if(!n.node_ops.setattr)throw new o.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()});},lchmod(e,r){o.chmod(e,r,!0);},fchmod(e,r){var t=o.getStreamChecked(e);o.chmod(t.node,r);},chown(e,r,t,n){var a;if(typeof e=="string"){var i=o.lookupPath(e,{follow:!n});a=i.node;}else a=e;if(!a.node_ops.setattr)throw new o.ErrnoError(63);a.node_ops.setattr(a,{timestamp:Date.now()});},lchown(e,r,t){o.chown(e,r,t,!0);},fchown(e,r,t){var n=o.getStreamChecked(e);o.chown(n.node,r,t);},truncate(e,r){if(r<0)throw new o.ErrnoError(28);var t;if(typeof e=="string"){var n=o.lookupPath(e,{follow:!0});t=n.node;}else t=e;if(!t.node_ops.setattr)throw new o.ErrnoError(63);if(o.isDir(t.mode))throw new o.ErrnoError(31);if(!o.isFile(t.mode))throw new o.ErrnoError(28);var a=o.nodePermissions(t,"w");if(a)throw new o.ErrnoError(a);t.node_ops.setattr(t,{size:r,timestamp:Date.now()});},ftruncate(e,r){var t=o.getStreamChecked(e);if(!(t.flags&2097155))throw new o.ErrnoError(28);o.truncate(t.node,r);},utime(e,r,t){var n=o.lookupPath(e,{follow:!0}),a=n.node;a.node_ops.setattr(a,{timestamp:Math.max(r,t)});},open(e,r,t){if(e==="")throw new o.ErrnoError(44);r=typeof r=="string"?ut(r):r,r&64?(t=typeof t>"u"?438:t,t=t&4095|32768):t=0;var n;if(typeof e=="object")n=e;else {e=C.normalize(e);try{var a=o.lookupPath(e,{follow:!(r&131072)});n=a.node;}catch{}}var i=!1;if(r&64)if(n){if(r&128)throw new o.ErrnoError(20)}else n=o.mknod(e,t,0),i=!0;if(!n)throw new o.ErrnoError(44);if(o.isChrdev(n.mode)&&(r&=-513),r&65536&&!o.isDir(n.mode))throw new o.ErrnoError(54);if(!i){var u=o.mayOpen(n,r);if(u)throw new o.ErrnoError(u)}r&512&&!i&&o.truncate(n,0),r&=-131713;var l=o.createStream({node:n,path:o.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return l.stream_ops.open&&l.stream_ops.open(l),s.logReadFiles&&!(r&1)&&(o.readFiles||(o.readFiles={}),e in o.readFiles||(o.readFiles[e]=1)),l},close(e){if(o.isClosed(e))throw new o.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e);}catch(r){throw r}finally{o.closeStream(e.fd);}e.fd=null;},isClosed(e){return e.fd===null},llseek(e,r,t){if(o.isClosed(e))throw new o.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new o.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new o.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,n,a){if(n<0||a<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if((e.flags&2097155)===1)throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.read)throw new o.ErrnoError(28);var i=typeof a<"u";if(!i)a=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var u=e.stream_ops.read(e,r,t,n,a);return i||(e.position+=u),u},write(e,r,t,n,a,i){if(n<0||a<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if(!(e.flags&2097155))throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.write)throw new o.ErrnoError(28);e.seekable&&e.flags&1024&&o.llseek(e,0,2);var u=typeof a<"u";if(!u)a=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var l=e.stream_ops.write(e,r,t,n,a,i);return u||(e.position+=l),l},allocate(e,r,t){if(o.isClosed(e))throw new o.ErrnoError(8);if(r<0||t<=0)throw new o.ErrnoError(28);if(!(e.flags&2097155))throw new o.ErrnoError(8);if(!o.isFile(e.node.mode)&&!o.isDir(e.node.mode))throw new o.ErrnoError(43);if(!e.stream_ops.allocate)throw new o.ErrnoError(138);e.stream_ops.allocate(e,r,t);},mmap(e,r,t,n,a){if(n&2&&!(a&2)&&(e.flags&2097155)!==2)throw new o.ErrnoError(2);if((e.flags&2097155)===1)throw new o.ErrnoError(2);if(!e.stream_ops.mmap)throw new o.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,a)},msync(e,r,t,n,a){return e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,a):0},ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new o.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){if(r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error(`Invalid encoding type "${r.encoding}"`);var t,n=o.open(e,r.flags),a=o.stat(e),i=a.size,u=new Uint8Array(i);return o.read(n,u,0,i,0),r.encoding==="utf8"?t=Fe(u,0):r.encoding==="binary"&&(t=u),o.close(n),t},writeFile(e,r,t={}){t.flags=t.flags||577;var n=o.open(e,t.flags,t.mode);if(typeof r=="string"){var a=new Uint8Array(rr(r)+1),i=tr(r,a,0,a.length);o.write(n,a,0,i,void 0,t.canOwn);}else if(ArrayBuffer.isView(r))o.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");o.close(n);},cwd:()=>o.currentPath,chdir(e){var r=o.lookupPath(e,{follow:!0});if(r.node===null)throw new o.ErrnoError(44);if(!o.isDir(r.node.mode))throw new o.ErrnoError(54);var t=o.nodePermissions(r.node,"x");if(t)throw new o.ErrnoError(t);o.currentPath=r.path;},createDefaultDirectories(){o.mkdir("/tmp"),o.mkdir("/home"),o.mkdir("/home/web_user");},createDefaultDevices(){o.mkdir("/dev"),o.registerDevice(o.makedev(1,3),{read:()=>0,write:(n,a,i,u,l)=>u}),o.mkdev("/dev/null",o.makedev(1,3)),Me.register(o.makedev(5,0),Me.default_tty_ops),Me.register(o.makedev(6,0),Me.default_tty1_ops),o.mkdev("/dev/tty",o.makedev(5,0)),o.mkdev("/dev/tty1",o.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(r=_r(e).byteLength),e[--r]);o.createDevice("/dev","random",t),o.createDevice("/dev","urandom",t),o.mkdir("/dev/shm"),o.mkdir("/dev/shm/tmp");},createSpecialDirectories(){o.mkdir("/proc");var e=o.mkdir("/proc/self");o.mkdir("/proc/self/fd"),o.mount({mount(){var r=o.createNode(e,"fd",16895,73);return r.node_ops={lookup(t,n){var a=+n,i=o.getStreamChecked(a),u={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return u.parent=u,u}},r}},{},"/proc/self/fd");},createStandardStreams(){s.stdin?o.createDevice("/dev","stdin",s.stdin):o.symlink("/dev/tty","/dev/stdin"),s.stdout?o.createDevice("/dev","stdout",null,s.stdout):o.symlink("/dev/tty","/dev/stdout"),s.stderr?o.createDevice("/dev","stderr",null,s.stderr):o.symlink("/dev/tty1","/dev/stderr");o.open("/dev/stdin",0);o.open("/dev/stdout",1);o.open("/dev/stderr",1);},staticInit(){[44].forEach(e=>{o.genericErrors[e]=new o.ErrnoError(e),o.genericErrors[e].stack="";}),o.nameTable=new Array(4096),o.mount(D,{},"/"),o.createDefaultDirectories(),o.createDefaultDevices(),o.createSpecialDirectories(),o.filesystems={MEMFS:D};},init(e,r,t){o.init.initialized=!0,s.stdin=e||s.stdin,s.stdout=r||s.stdout,s.stderr=t||s.stderr,o.createStandardStreams();},quit(){o.init.initialized=!1;for(var e=0;ethis.length-1||y<0)){var O=y%this.chunkSize,te=y/this.chunkSize|0;return this.getter(te)[O]}}setDataGetter(y){this.getter=y;}cacheLength(){var y=new XMLHttpRequest;if(y.open("HEAD",t,!1),y.send(null),!(y.status>=200&&y.status<300||y.status===304))throw new Error("Couldn't load "+t+". Status: "+y.status);var O=Number(y.getResponseHeader("Content-length")),te,de=(te=y.getResponseHeader("Accept-Ranges"))&&te==="bytes",ne=(te=y.getResponseHeader("Content-Encoding"))&&te==="gzip",fe=1024*1024;de||(fe=O);var ve=(ge,xe)=>{if(ge>xe)throw new Error("invalid range ("+ge+", "+xe+") or no bytes requested!");if(xe>O-1)throw new Error("only "+O+" bytes available! programmer error!");var ee=new XMLHttpRequest;if(ee.open("GET",t,!1),O!==fe&&ee.setRequestHeader("Range","bytes="+ge+"-"+xe),ee.responseType="arraybuffer",ee.overrideMimeType&&ee.overrideMimeType("text/plain; charset=x-user-defined"),ee.send(null),!(ee.status>=200&&ee.status<300||ee.status===304))throw new Error("Couldn't load "+t+". Status: "+ee.status);return ee.response!==void 0?new Uint8Array(ee.response||[]):or(ee.responseText||"",!0)},Ie=this;Ie.setDataGetter(ge=>{var xe=ge*fe,ee=(ge+1)*fe-1;if(ee=Math.min(ee,O-1),typeof Ie.chunks[ge]>"u"&&(Ie.chunks[ge]=ve(xe,ee)),typeof Ie.chunks[ge]>"u")throw new Error("doXHR failed!");return Ie.chunks[ge]}),(ne||!O)&&(fe=O=1,O=this.getter(0).length,fe=O,X("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=O,this._chunkSize=fe,this.lengthKnown=!0;}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest<"u"){throw "Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var u=new i,l={isDevice:!1,contents:u};}else var l={isDevice:!1,url:t};var v=o.createFile(e,r,l,n,a);l.contents?v.contents=l.contents:l.url&&(v.contents=null,v.url=l.url),Object.defineProperties(v,{usedBytes:{get:function(){return this.contents.length}}});var E={},G=Object.keys(v.stream_ops);G.forEach(B=>{var y=v.stream_ops[B];E[B]=(...O)=>(o.forceLoadFile(v),y(...O));});function x(B,y,O,te,de){var ne=B.node.contents;if(de>=ne.length)return 0;var fe=Math.min(ne.length-de,te);if(ne.slice)for(var ve=0;ve(o.forceLoadFile(v),x(B,y,O,te,de)),E.mmap=(B,y,O,te,de)=>{o.forceLoadFile(v);var ne=wr(y);if(!ne)throw new o.ErrnoError(48);return x(B,w,ne,y,O),{ptr:ne,allocated:!0}},v.stream_ops=E,v}},ue=(e,r)=>e?Fe(j,e,r):"",U={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(C.isAbs(r))return r;var n;if(e===-100)n=o.cwd();else {var a=U.getStreamFromFD(e);n=a.path;}if(r.length==0){if(!t)throw new o.ErrnoError(44);return n}return C.join2(n,r)},doStat(e,r,t){var n=e(r);b[t>>2]=n.dev,b[t+4>>2]=n.mode,k[t+8>>2]=n.nlink,b[t+12>>2]=n.uid,b[t+16>>2]=n.gid,b[t+20>>2]=n.rdev,$=[n.size>>>0,(R=n.size,+Math.abs(R)>=1?R>0?+Math.floor(R/4294967296)>>>0:~~+Math.ceil((R-+(~~R>>>0))/4294967296)>>>0:0)],b[t+24>>2]=$[0],b[t+28>>2]=$[1],b[t+32>>2]=4096,b[t+36>>2]=n.blocks;var a=n.atime.getTime(),i=n.mtime.getTime(),u=n.ctime.getTime();return $=[Math.floor(a/1e3)>>>0,(R=Math.floor(a/1e3),+Math.abs(R)>=1?R>0?+Math.floor(R/4294967296)>>>0:~~+Math.ceil((R-+(~~R>>>0))/4294967296)>>>0:0)],b[t+40>>2]=$[0],b[t+44>>2]=$[1],k[t+48>>2]=a%1e3*1e3,$=[Math.floor(i/1e3)>>>0,(R=Math.floor(i/1e3),+Math.abs(R)>=1?R>0?+Math.floor(R/4294967296)>>>0:~~+Math.ceil((R-+(~~R>>>0))/4294967296)>>>0:0)],b[t+56>>2]=$[0],b[t+60>>2]=$[1],k[t+64>>2]=i%1e3*1e3,$=[Math.floor(u/1e3)>>>0,(R=Math.floor(u/1e3),+Math.abs(R)>=1?R>0?+Math.floor(R/4294967296)>>>0:~~+Math.ceil((R-+(~~R>>>0))/4294967296)>>>0:0)],b[t+72>>2]=$[0],b[t+76>>2]=$[1],k[t+80>>2]=u%1e3*1e3,$=[n.ino>>>0,(R=n.ino,+Math.abs(R)>=1?R>0?+Math.floor(R/4294967296)>>>0:~~+Math.ceil((R-+(~~R>>>0))/4294967296)>>>0:0)],b[t+88>>2]=$[0],b[t+92>>2]=$[1],0},doMsync(e,r,t,n,a){if(!o.isFile(r.node.mode))throw new o.ErrnoError(43);if(n&2)return 0;var i=j.slice(e,e+t);o.msync(r,i,a,t,n);},getStreamFromFD(e){var r=o.getStreamChecked(e);return r},varargs:void 0,getStr(e){var r=ue(e);return r}};function pt(e,r,t,n){try{if(r=U.getStr(r),r=U.calculateAt(e,r),t&-8)return -28;var a=o.lookupPath(r,{follow:!0}),i=a.node;if(!i)return -44;var u="";return t&4&&(u+="r"),t&2&&(u+="w"),t&1&&(u+="x"),u&&o.nodePermissions(i,u)?-2:0}catch(l){if(typeof o>"u"||l.name!=="ErrnoError")throw l;return -l.errno}}function Se(){var e=b[+U.varargs>>2];return U.varargs+=4,e}var Oe=Se;function lt(e,r,t){U.varargs=t;try{var n=U.getStreamFromFD(e);switch(r){case 0:{var a=Se();if(a<0)return -28;for(;o.streams[a];)a++;var i;return i=o.dupStream(n,a),i.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var a=Se();return n.flags|=a,0}case 12:{var a=Oe(),u=0;return W[a+u>>1]=2,0}case 13:case 14:return 0}return -28}catch(l){if(typeof o>"u"||l.name!=="ErrnoError")throw l;return -l.errno}}function ct(e,r){try{var t=U.getStreamFromFD(e);return U.doStat(o.stat,t.path,r)}catch(n){if(typeof o>"u"||n.name!=="ErrnoError")throw n;return -n.errno}}function dt(e,r,t){U.varargs=t;try{var n=U.getStreamFromFD(e);switch(r){case 21509:return n.tty?0:-59;case 21505:{if(!n.tty)return -59;if(n.tty.ops.ioctl_tcgets){var a=n.tty.ops.ioctl_tcgets(n),i=Oe();b[i>>2]=a.c_iflag||0,b[i+4>>2]=a.c_oflag||0,b[i+8>>2]=a.c_cflag||0,b[i+12>>2]=a.c_lflag||0;for(var u=0;u<32;u++)w[i+u+17]=a.c_cc[u]||0;return 0}return 0}case 21510:case 21511:case 21512:return n.tty?0:-59;case 21506:case 21507:case 21508:{if(!n.tty)return -59;if(n.tty.ops.ioctl_tcsets){for(var i=Oe(),l=b[i>>2],v=b[i+4>>2],E=b[i+8>>2],G=b[i+12>>2],x=[],u=0;u<32;u++)x.push(w[i+u+17]);return n.tty.ops.ioctl_tcsets(n.tty,r,{c_iflag:l,c_oflag:v,c_cflag:E,c_lflag:G,c_cc:x})}return 0}case 21519:{if(!n.tty)return -59;var i=Oe();return b[i>>2]=0,0}case 21520:return n.tty?-28:-59;case 21531:{var i=Oe();return o.ioctl(n,r,i)}case 21523:{if(!n.tty)return -59;if(n.tty.ops.ioctl_tiocgwinsz){var B=n.tty.ops.ioctl_tiocgwinsz(n.tty),i=Oe();W[i>>1]=B[0],W[i+2>>1]=B[1];}return 0}case 21524:return n.tty?0:-59;case 21515:return n.tty?0:-59;default:return -28}}catch(y){if(typeof o>"u"||y.name!=="ErrnoError")throw y;return -y.errno}}function ft(e,r,t,n){try{r=U.getStr(r);var a=n&256,i=n&4096;return n=n&-6401,r=U.calculateAt(e,r,i),U.doStat(a?o.lstat:o.stat,r,t)}catch(u){if(typeof o>"u"||u.name!=="ErrnoError")throw u;return -u.errno}}function vt(e,r,t,n){U.varargs=n;try{r=U.getStr(r),r=U.calculateAt(e,r);var a=n?Se():0;return o.open(r,t,a).fd}catch(i){if(typeof o>"u"||i.name!=="ErrnoError")throw i;return -i.errno}}var Ke=(e,r,t)=>tr(e,j,r,t);function mt(e,r,t,n){try{if(r=U.getStr(r),r=U.calculateAt(e,r),n<=0)return -28;var a=o.readlink(r),i=Math.min(n,rr(a)),u=w[t+i];return Ke(a,t,n+1),w[t+i]=u,i}catch(l){if(typeof o>"u"||l.name!=="ErrnoError")throw l;return -l.errno}}function _t(e){try{return e=U.getStr(e),o.rmdir(e),0}catch(r){if(typeof o>"u"||r.name!=="ErrnoError")throw r;return -r.errno}}function gt(e,r){try{return e=U.getStr(e),U.doStat(o.stat,e,r)}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return -t.errno}}function ht(e,r,t){try{return r=U.getStr(r),r=U.calculateAt(e,r),t===0?o.unlink(r):t===512?o.rmdir(r):_e("Invalid flags passed to unlinkat"),0}catch(n){if(typeof o>"u"||n.name!=="ErrnoError")throw n;return -n.errno}}var wt=()=>{_e("");},yt=1,bt=()=>yt,Et=(e,r,t)=>j.copyWithin(e,r,r+t),ar=(e,r)=>r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN;function Mt(e,r,t,n,a,i,u,l){var v=ar(a,i);try{if(isNaN(v))return 61;var E=U.getStreamFromFD(n),G=o.mmap(E,e,v,r,t),x=G.ptr;return b[u>>2]=G.allocated,k[l>>2]=x,0}catch(B){if(typeof o>"u"||B.name!=="ErrnoError")throw B;return -B.errno}}function Dt(e,r,t,n,a,i,u){var l=ar(i,u);try{var v=U.getStreamFromFD(a);t&2&&U.doMsync(e,v,r,n,l);}catch(E){if(typeof o>"u"||E.name!=="ErrnoError")throw E;return -E.errno}}var Xt=(e,r,t,n)=>{var a=new Date().getFullYear(),i=new Date(a,0,1),u=new Date(a,6,1),l=i.getTimezoneOffset(),v=u.getTimezoneOffset(),E=Math.max(l,v);k[e>>2]=E*60,b[r>>2]=+(l!=v);var G=y=>{var O=y>=0?"-":"+",te=Math.abs(y),de=String(Math.floor(te/60)).padStart(2,"0"),ne=String(te%60).padStart(2,"0");return `UTC${O}${de}${ne}`},x=G(l),B=G(v);v{ir.length=0;for(var t;t=j[e++];){var n=t!=105;n&=t!=112,r+=n&&r%8?4:0,ir.push(t==112?k[r>>2]:t==105?b[r>>2]:oe[r>>3]),r+=n?8:4;}return ir},Bt=(e,r,t)=>{var n=Lt(r,t);return Qr[e](...n)},Rt=(e,r,t)=>Bt(e,r,t),kt=()=>Date.now();var Ft=()=>2147483648,Ot=e=>{var r=S.buffer,t=(e-r.byteLength+65535)/65536;try{return S.grow(t),K(),1}catch{}},xt=e=>{var r=j.length;e>>>=0;var t=Ft();if(e>t)return !1;for(var n=(v,E)=>v+(E-v%E)%E,a=1;a<=4;a*=2){var i=r*(1+.2/a);i=Math.min(i,e+100663296);var u=Math.min(t,n(Math.max(e,i),65536)),l=Ot(u);if(l)return !0}return !1},sr={},Ut=()=>I,Ce=()=>{if(!Ce.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Ut()};for(var t in sr)sr[t]===void 0?delete r[t]:r[t]=sr[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Ce.strings=n;}return Ce.strings},Nt=(e,r)=>{for(var t=0;t{var t=0;return Ce().forEach((n,a)=>{var i=r+t;k[e+a*4>>2]=i,Nt(n,i),t+=n.length+1;}),0},Kt=(e,r)=>{var t=Ce();k[e>>2]=t.length;var n=0;return t.forEach(a=>n+=a.length+1),k[r>>2]=n,0},Zt=e=>{(P=!0),Q(e,new qr(e));},Yt=(e,r)=>{Zt(e);},zt=Yt;function jt(e){try{var r=U.getStreamFromFD(e);return o.close(r),0}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var Pt=(e,r,t,n)=>{for(var a=0,i=0;i>2],l=k[r+4>>2];r+=8;var v=o.read(e,w,u,l,n);if(v<0)return -1;if(a+=v,v>2]=i,0}catch(u){if(typeof o>"u"||u.name!=="ErrnoError")throw u;return u.errno}}function St(e,r,t,n,a){var i=ar(r,t);try{if(isNaN(i))return 61;var u=U.getStreamFromFD(e);return o.llseek(u,i,n),$=[u.position>>>0,(R=u.position,+Math.abs(R)>=1?R>0?+Math.floor(R/4294967296)>>>0:~~+Math.ceil((R-+(~~R>>>0))/4294967296)>>>0:0)],b[a>>2]=$[0],b[a+4>>2]=$[1],u.getdents&&i===0&&n===0&&(u.getdents=null),0}catch(l){if(typeof o>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var Ht=(e,r,t,n)=>{for(var a=0,i=0;i>2],l=k[r+4>>2];r+=8;var v=o.write(e,w,u,l,n);if(v<0)return -1;a+=v;}return a};function Tt(e,r,t,n){try{var a=U.getStreamFromFD(e),i=Ht(a,r,t);return k[n>>2]=i,0}catch(u){if(typeof o>"u"||u.name!=="ErrnoError")throw u;return u.errno}}o.createPreloadedFile=st,o.staticInit();var Qt={a:Ar,k:pt,h:lt,y:ct,z:dt,w:ft,d:vt,r:mt,s:_t,x:gt,t:ht,l:wt,i:bt,j:Et,m:Mt,n:Dt,p:Xt,A:Rt,b:kt,q:xt,u:Vt,v:Kt,e:zt,c:jt,f:Jt,o:St,g:Tt},N=Tr();s._webidl_free=e=>(s._webidl_free=N.D)(e);s._free=e=>(s._free=N.E)(e);s._webidl_malloc=e=>(s._webidl_malloc=N.F)(e);s._malloc=e=>(s._malloc=N.G)(e);var yr=s._emscripten_bind_VoidPtr___destroy___0=e=>(yr=s._emscripten_bind_VoidPtr___destroy___0=N.H)(e),br=s._emscripten_bind_Graphviz_Graphviz_2=(e,r)=>(br=s._emscripten_bind_Graphviz_Graphviz_2=N.I)(e,r),Er=s._emscripten_bind_Graphviz_version_0=()=>(Er=s._emscripten_bind_Graphviz_version_0=N.J)(),Mr=s._emscripten_bind_Graphviz_lastError_0=()=>(Mr=s._emscripten_bind_Graphviz_lastError_0=N.K)(),Dr=s._emscripten_bind_Graphviz_createFile_2=(e,r,t)=>(Dr=s._emscripten_bind_Graphviz_createFile_2=N.L)(e,r,t),Xr=s._emscripten_bind_Graphviz_layout_3=(e,r,t,n)=>(Xr=s._emscripten_bind_Graphviz_layout_3=N.M)(e,r,t,n),Lr=s._emscripten_bind_Graphviz_acyclic_3=(e,r,t,n)=>(Lr=s._emscripten_bind_Graphviz_acyclic_3=N.N)(e,r,t,n),Br=s._emscripten_bind_Graphviz_tred_3=(e,r,t,n)=>(Br=s._emscripten_bind_Graphviz_tred_3=N.O)(e,r,t,n),Rr=s._emscripten_bind_Graphviz_unflatten_4=(e,r,t,n,a)=>(Rr=s._emscripten_bind_Graphviz_unflatten_4=N.P)(e,r,t,n,a),kr=s._emscripten_bind_Graphviz_get_layout_result_0=e=>(kr=s._emscripten_bind_Graphviz_get_layout_result_0=N.Q)(e),Gr=s._emscripten_bind_Graphviz_set_layout_result_1=(e,r)=>(Gr=s._emscripten_bind_Graphviz_set_layout_result_1=N.R)(e,r),Fr=s._emscripten_bind_Graphviz_get_acyclic_outFile_0=e=>(Fr=s._emscripten_bind_Graphviz_get_acyclic_outFile_0=N.S)(e),Or=s._emscripten_bind_Graphviz_set_acyclic_outFile_1=(e,r)=>(Or=s._emscripten_bind_Graphviz_set_acyclic_outFile_1=N.T)(e,r),xr=s._emscripten_bind_Graphviz_get_acyclic_num_rev_0=e=>(xr=s._emscripten_bind_Graphviz_get_acyclic_num_rev_0=N.U)(e),Ur=s._emscripten_bind_Graphviz_set_acyclic_num_rev_1=(e,r)=>(Ur=s._emscripten_bind_Graphviz_set_acyclic_num_rev_1=N.V)(e,r),Nr=s._emscripten_bind_Graphviz_get_tred_out_0=e=>(Nr=s._emscripten_bind_Graphviz_get_tred_out_0=N.W)(e),Vr=s._emscripten_bind_Graphviz_set_tred_out_1=(e,r)=>(Vr=s._emscripten_bind_Graphviz_set_tred_out_1=N.X)(e,r),Kr=s._emscripten_bind_Graphviz_get_tred_err_0=e=>(Kr=s._emscripten_bind_Graphviz_get_tred_err_0=N.Y)(e),Cr=s._emscripten_bind_Graphviz_set_tred_err_1=(e,r)=>(Cr=s._emscripten_bind_Graphviz_set_tred_err_1=N.Z)(e,r),Ir=s._emscripten_bind_Graphviz___destroy___0=e=>(Ir=s._emscripten_bind_Graphviz___destroy___0=N._)(e),Zr=(e,r)=>(Zr=N.aa)(e,r),Yr=e=>(Yr=N.ba)(e);s.UTF8ToString=ue;var He;be=function e(){He||zr(),He||(be=e);};function zr(){if(ye>0||(Re(),ye>0))return;function e(){He||(He=!0,s.calledRun=!0,!P&&(Ne(),f(s),Pe()));}e();}zr();function pe(){}pe.prototype=Object.create(pe.prototype),pe.prototype.constructor=pe,pe.prototype.__class__=pe,pe.__cache__={},s.WrapperObject=pe;function Te(e){return (e||pe).__cache__}s.getCache=Te;function ur(e,r){var t=Te(r),n=t[e];return n||(n=Object.create((r||pe).prototype),n.ptr=e,t[e]=n)}s.wrapPointer=ur;function ro(e,r){return ur(e.ptr,r)}s.castObject=ro,s.NULL=ur(0);function to(e){if(!e.__destroy__)throw "Error: Cannot destroy object. (Did you create it yourself?)";e.__destroy__(),delete Te(e.__class__)[e.ptr];}s.destroy=to;function oo(e,r){return e.ptr===r.ptr}s.compare=oo;function no(e){return e.ptr}s.getPointer=no;function ao(e){return e.__class__}s.getClass=ao;var F={buffer:0,size:0,pos:0,temps:[],needed:0,prepare(){if(F.needed){for(var e=0;e=F.size?(J(n>0),F.needed+=n,a=s._webidl_malloc(n),F.temps.push(a)):(a=F.buffer+F.pos,F.pos+=n),a},copy(e,r,t){t/=r.BYTES_PER_ELEMENT;for(var n=0;n?@[]^_`{|}~"';function Lo(p){let c=p.length,d=[],s=0,f=0,m=-1;for(let _=0;_88?13:14;do d.push(s&255),s>>=8,f-=8;while(f>7);m=-1;}}return m>-1&&d.push((s|m< - -`}}function Fo(p){return p.map(Go)}function Oo(p,c){let d={images:[],files:[],...c};[...d.files,...Fo(d.images)].forEach(s=>p.createFile(s.path,s.data));}var xo=class Ue{constructor(c){this._module=c;}static load(){return Ro().then(c=>new Ue(c))}static unload(){ko();}version(){return this._module.Graphviz.prototype.version()}layout(c,d="svg",s="dot",f){if(!c)return "";let m=new this._module.Graphviz(f?.yInvert?1:0,f?.nop?f?.nop:0),_="",h="";try{Oo(m,f);try{_=m.layout(c,d,s);}catch(M){h=M.message;}h=m.lastError()||h;}finally{this._module.destroy(m);}if(!_&&h)throw Ue.unload(),new Error(h);return _}acyclic(c,d=!1,s=!1){if(!c)return {acyclic:!1,num_rev:0,outFile:""};let f=new this._module.Graphviz,m=!1,_=0,h="",M="";try{try{m=f.acyclic(c,d,s),_=f.acyclic_num_rev,h=f.acyclic_outFile;}catch(I){M=I.message;}M=f.lastError()||M;}finally{this._module.destroy(f);}if(M)throw Ue.unload(),new Error(M);return {acyclic:m,num_rev:_,outFile:h}}tred(c,d=!1,s=!1){if(!c)return {out:"",err:""};let f=new this._module.Graphviz,m="",_="",h="";try{try{f.tred(c,d,s),m=f.tred_out,_=f.tred_err;}catch(M){h=M.message;}h=f.lastError()||h;}finally{this._module.destroy(f);}if(!m&&h)throw Ue.unload(),new Error(h);return {out:m,err:_}}unflatten(c,d=0,s=!1,f=0){if(!c)return "";let m=new this._module.Graphviz,_="",h="";try{try{_=m.unflatten(c,d,s,f);}catch(M){h=M.message;}h=m.lastError()||h;}finally{this._module.destroy(m);}if(!_&&h)throw Ue.unload(),new Error(h);return _}circo(c,d="svg",s){return this.layout(c,d,"circo",s)}dot(c,d="svg",s){return this.layout(c,d,"dot",s)}fdp(c,d="svg",s){return this.layout(c,d,"fdp",s)}sfdp(c,d="svg",s){return this.layout(c,d,"sfdp",s)}neato(c,d="svg",s){return this.layout(c,d,"neato",s)}osage(c,d="svg",s){return this.layout(c,d,"osage",s)}patchwork(c,d="svg",s){return this.layout(c,d,"patchwork",s)}twopi(c,d="svg",s){return this.layout(c,d,"twopi",s)}nop(c){return this.layout(c,"dot","nop")}nop2(c){return this.layout(c,"dot","nop2")}}; - - function shallowCopyObject(obj) { - return Object.assign({}, obj); - } - function roundTo2Decimals(x) { - return Math.round(x * 100.0) / 100.0; - } - - function convertToPathData(originalData, guideData) { - if (originalData.tag == 'polygon') { - var newData = shallowCopyObject(originalData); - newData.tag = 'path'; - var originalAttributes = originalData.attributes; - var newAttributes = shallowCopyObject(originalAttributes); - var newPointsString = originalAttributes.points; - if (guideData.tag == 'polygon') { - var bbox = originalData.bbox; - bbox.cx = bbox.x + bbox.width / 2; - bbox.cy = bbox.y + bbox.height / 2; - var pointsString = originalAttributes.points; - var pointStrings = pointsString.split(' '); - var normPoints = pointStrings.map(function (p) { - var xy = p.split(','); - return [xy[0] - bbox.cx, xy[1] - bbox.cy]; - }); - var x0 = normPoints[normPoints.length - 1][0]; - var y0 = normPoints[normPoints.length - 1][1]; - for (var i = 0; i < normPoints.length; i++, x0 = x1, y0 = y1) { - var x1 = normPoints[i][0]; - var y1 = normPoints[i][1]; - var dx = x1 - x0; - var dy = y1 - y0; - if (dy == 0) { - continue; - } else { - var x2 = x0 - y0 * dx / dy; - } - if (0 <= x2 && x2 < Infinity && (x0 <= x2 && x2 <= x1 || x1 <= x2 && x2 <= x0)) { - break; - } - } - var newPointStrings = [[bbox.cx + x2, bbox.cy + 0].join(',')]; - newPointStrings = newPointStrings.concat(pointStrings.slice(i)); - newPointStrings = newPointStrings.concat(pointStrings.slice(0, i)); - newPointsString = newPointStrings.join(' '); - } - newAttributes['d'] = 'M' + newPointsString + 'z'; - delete newAttributes.points; - newData.attributes = newAttributes; - } else /* if (originalData.tag == 'ellipse') */{ - var newData = shallowCopyObject(originalData); - newData.tag = 'path'; - var originalAttributes = originalData.attributes; - var newAttributes = shallowCopyObject(originalAttributes); - var cx = originalAttributes.cx; - var cy = originalAttributes.cy; - var rx = originalAttributes.rx; - var ry = originalAttributes.ry; - if (guideData.tag == 'polygon') { - var bbox = guideData.bbox; - bbox.cx = bbox.x + bbox.width / 2; - bbox.cy = bbox.y + bbox.height / 2; - var p = guideData.attributes.points.split(' ')[0].split(','); - var sx = p[0]; - var sy = p[1]; - var dx = sx - bbox.cx; - var dy = sy - bbox.cy; - var l = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); - var cosA = dx / l; - var sinA = -dy / l; - } else { - // if (guideData.tag == 'path') { - // FIXME: add support for getting start position from path - var cosA = 1; - var sinA = 0; - } - var x1 = rx * cosA; - var y1 = -ry * sinA; - var x2 = rx * -cosA; - var y2 = -ry * -sinA; - var dx = x2 - x1; - var dy = y2 - y1; - newAttributes['d'] = 'M ' + cx + ' ' + cy + ' m ' + x1 + ',' + y1 + ' a ' + rx + ',' + ry + ' 0 1,0 ' + dx + ',' + dy + ' a ' + rx + ',' + ry + ' 0 1,0 ' + -dx + ',' + -dy + 'z'; - delete newAttributes.cx; - delete newAttributes.cy; - delete newAttributes.rx; - delete newAttributes.ry; - newData.attributes = newAttributes; - } - return newData; - } - function translatePointsAttribute(pointsString, x, y) { - var pointStrings = pointsString.split(' '); - var points = pointStrings.map(function (p) { - return p.split(','); - }); - var points = pointStrings.map(function (p) { - return [roundTo2Decimals(+x + +p.split(',')[0]), roundTo2Decimals(+y + +p.split(',')[1])]; - }); - var pointStrings = points.map(function (p) { - return p.join(','); - }); - var pointsString = pointStrings.join(' '); - return pointsString; - } - function translateDAttribute(d, x, y) { - var pointStrings = d.split(/[A-Z ]/); - pointStrings.shift(); - var commands = d.split(/[^[A-Z ]+/); - var points = pointStrings.map(function (p) { - return p.split(','); - }); - var points = pointStrings.map(function (p) { - return [roundTo2Decimals(+x + +p.split(',')[0]), roundTo2Decimals(+y + +p.split(',')[1])]; - }); - var pointStrings = points.map(function (p) { - return p.join(','); - }); - d = commands.reduce(function (arr, v, i) { - return arr.concat(v, pointStrings[i]); - }, []).join(''); - return d; - } - - function initViz() { - var _this = this; - // force JIT compilation of @hpcc-js/wasm - try { - xo.load().then(function (graphviz) { - graphviz.layout("", "svg", "dot"); - _this.layoutSync = graphviz.layout.bind(graphviz); - if (_this._worker == null) { - _this._dispatch.call("initEnd", _this); - } - if (_this._afterInit) { - _this._afterInit(); - } - }); - // after the port to ESM modules, we don't know how to trigger this so - // we just disable it from coverage - /* c8 ignore start */ - } catch (error) { - // we end up here when the the script tag type used to load - // the "@hpcc-js/wasm" script is not "application/javascript" - // or "text/javascript", but typically "javascript/worker". In - // this case the browser does not load the script since it's - // unnecessary because it's loaded by the web worker - // instead. This is expected so we just ignore the error. - } - /* c8 ignore stop */ - if (this._worker != null) { - var vizURL = this._vizURL; - var graphvizInstance = this; - this._workerPort.onmessage = function (event) { - var callback = graphvizInstance._workerCallbacks.shift(); - callback.call(graphvizInstance, event); - }; - if (!vizURL.match(/^https?:\/\/|^\/\//i)) { - // Local URL. Prepend with local domain to be usable in web worker - vizURL = new window.URL(vizURL, document.location.href).href; - } - postMessage.call(this, { - type: "layout", - dot: "", - engine: 'dot', - vizURL: vizURL - }, function (event) { - switch (event.data.type) { - } - }); - postMessage.call(this, { - type: "version" - }, function (event) { - switch (event.data.type) { - case "version": - graphvizInstance._graphvizVersion = event.data.version; - graphvizInstance._dispatch.call("initEnd", this); - break; - } - }); - } - } - function postMessage(message, callback) { - this._workerCallbacks.push(callback); - this._workerPort.postMessage(message); - } - function layout(src, engine, vizOptions, callback) { - if (this._worker) { - postMessage.call(this, { - type: "layout", - dot: src, - engine: engine, - options: vizOptions - }, function (event) { - callback.call(this, event.data); - }); - } else { - try { - var svgDoc = this.layoutSync(src, "svg", engine, vizOptions); - callback.call(this, { - type: 'done', - svg: svgDoc - }); - } catch (error) { - callback.call(this, { - type: 'error', - error: error.message - }); - } - } - } - function dot (src, callback) { - var graphvizInstance = this; - this._worker; - var engine = this._options.engine; - var images = this._images; - this._dispatch.call("start", this); - this._busy = true; - this._dispatch.call("layoutStart", this); - var vizOptions = { - images: images - }; - if (!this._worker && this.layoutSync == null) { - this._afterInit = this.dot.bind(this, src, callback); - return this; - } - this.layout(src, engine, vizOptions, function (data) { - switch (data.type) { - case "error": - if (graphvizInstance._onerror) { - graphvizInstance._onerror(data.error); - } else { - throw data.error.message; - } - break; - case "done": - var svgDoc = data.svg; - layoutDone.call(this, svgDoc, callback); - break; - } - }); - return this; - } - function layoutDone(svgDoc, callback) { - var keyMode = this._options.keyMode; - var tweenPaths = this._options.tweenPaths; - var tweenShapes = this._options.tweenShapes; - if (typeof this._options.tweenPrecision == 'string' && this._options.tweenPrecision.includes('%')) { - var tweenPrecision = +this._options.tweenPrecision.split('%')[0] / 100; - var tweenPrecisionIsRelative = this._options.tweenPrecision.includes('%'); - } else { - var tweenPrecision = this._options.tweenPrecision; - var tweenPrecisionIsRelative = false; - } - var growEnteringEdges = this._options.growEnteringEdges; - var dictionary = {}; - var prevDictionary = this._dictionary || {}; - var nodeDictionary = {}; - var prevNodeDictionary = this._nodeDictionary || {}; - function setKey(datum, index) { - var tag = datum.tag; - if (keyMode == 'index') { - datum.key = index; - } else if (tag[0] != '#') { - if (keyMode == 'id') { - datum.key = datum.attributes.id; - } else if (keyMode == 'title') { - var title = datum.children.find(function (childData) { - return childData.tag == 'title'; - }); - if (title) { - if (title.children.length > 0) { - datum.key = title.children[0].text; - } else { - datum.key = ''; - } - } - } - } - if (datum.key == null) { - if (tweenShapes) { - if (tag == 'ellipse' || tag == 'polygon') { - tag = 'path'; - } - } - datum.key = tag + '-' + index; - } - } - function setId(datum, parentData) { - var id = (parentData ? parentData.id + '.' : '') + datum.key; - datum.id = id; - } - function addToDictionary(datum) { - dictionary[datum.id] = datum; - } - function calculateAlternativeShapeData(datum, prevDatum) { - if (tweenShapes && datum.id in prevDictionary) { - if ((prevDatum.tag == 'polygon' || prevDatum.tag == 'ellipse' || prevDatum.tag == 'path') && (prevDatum.tag != datum.tag || datum.tag == 'polygon')) { - if (prevDatum.tag != 'path') { - datum.alternativeOld = convertToPathData(prevDatum, datum); - } - if (datum.tag != 'path') { - datum.alternativeNew = convertToPathData(datum, prevDatum); - } - } - } - } - function calculatePathTweenPoints(datum, prevDatum) { - if (tweenPaths && prevDatum && (prevDatum.tag == 'path' || datum.alternativeOld && datum.alternativeOld.tag == 'path')) { - var attribute_d = (datum.alternativeNew || datum).attributes.d; - if (datum.alternativeOld) { - var oldNode = createElementWithAttributes(datum.alternativeOld); - } else { - var oldNode = createElementWithAttributes(prevDatum); - } - (datum.alternativeOld || (datum.alternativeOld = {})).points = pathTweenPoints(oldNode, attribute_d, tweenPrecision, tweenPrecisionIsRelative); - } - } - function postProcessDataPass1Local(datum) { - var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - var parentData = arguments.length > 2 ? arguments[2] : undefined; - setKey(datum, index); - setId(datum, parentData); - var id = datum.id; - var prevDatum = prevDictionary[id]; - addToDictionary(datum); - calculateAlternativeShapeData(datum, prevDatum); - calculatePathTweenPoints(datum, prevDatum); - var childTagIndexes = {}; - datum.children.forEach(function (childData) { - var childTag = childData.tag; - if (childTag == 'ellipse' || childTag == 'polygon') { - childTag = 'path'; - } - if (childTagIndexes[childTag] == null) { - childTagIndexes[childTag] = 0; - } - var childIndex = childTagIndexes[childTag]++; - postProcessDataPass1Local(childData, childIndex, datum); - }); - } - function addToNodeDictionary(datum) { - var tag = datum.tag; - if (growEnteringEdges && datum.parent) { - if (datum.parent.attributes["class"] == 'node') { - if (tag == 'title') { - if (datum.children.length > 0) { - var child = datum.children[0]; - var nodeId = child.text; - } else { - var nodeId = ''; - } - nodeDictionary[nodeId] = datum.parent; - } - } - } - } - function extractGrowingEdgesData(datum) { - var id = datum.id; - var tag = datum.tag; - var prevDatum = prevDictionary[id]; - if (growEnteringEdges && !prevDatum && datum.parent) { - if (isEdgeElement(datum)) { - if (tag == 'path' || tag == 'polygon') { - if (tag == 'polygon') { - var path = datum.parent.children.find(function (e) { - return e.tag == 'path'; - }); - if (path) { - datum.totalLength = path.totalLength; - } - } - var title = getEdgeTitle(datum); - var child = title.children[0]; - var nodeIds = child.text.split('->'); - if (nodeIds.length != 2) { - nodeIds = child.text.split('--'); - } - var startNodeId = nodeIds[0]; - var startNode = nodeDictionary[startNodeId]; - if (Object.hasOwn(prevNodeDictionary, startNodeId)) { - var prevStartNode = prevNodeDictionary[startNodeId]; - var i = startNode.children.findIndex(function (element, index) { - return element.tag == 'g'; - }); - if (i >= 0) { - var j = startNode.children[i].children.findIndex(function (element, index) { - return element.tag == 'a'; - }); - startNode = startNode.children[i].children[j]; - } - var i = prevStartNode.children.findIndex(function (element, index) { - return element.tag == 'g'; - }); - if (i >= 0) { - var j = prevStartNode.children[i].children.findIndex(function (element, index) { - return element.tag == 'a'; - }); - prevStartNode = prevStartNode.children[i].children[j]; - } - var startShapes = startNode.children; - for (var i = 0; i < startShapes.length; i++) { - if (startShapes[i].tag == 'polygon' || startShapes[i].tag == 'ellipse' || startShapes[i].tag == 'path' || startShapes[i].tag == 'text') { - var startShape = startShapes[i]; - break; - } - } - var prevStartShapes = prevStartNode.children; - for (var i = 0; i < prevStartShapes.length; i++) { - if (prevStartShapes[i].tag == 'polygon' || prevStartShapes[i].tag == 'ellipse' || prevStartShapes[i].tag == 'path' || prevStartShapes[i].tag == 'text') { - var prevStartShape = prevStartShapes[i]; - break; - } - } - if (prevStartShape && startShape) { - datum.offset = { - x: prevStartShape.center.x - startShape.center.x, - y: prevStartShape.center.y - startShape.center.y - }; - } else { - datum.offset = { - x: 0, - y: 0 - }; - } - } - } - } - } - } - function postProcessDataPass2Global(datum) { - addToNodeDictionary(datum); - extractGrowingEdgesData(datum); - datum.children.forEach(function (childData) { - postProcessDataPass2Global(childData); - }); - } - this._dispatch.call("layoutEnd", this); - var newDoc = d3__namespace.select(document.createDocumentFragment()).append('div'); - var parser = new window.DOMParser(); - var doc = parser.parseFromString(svgDoc, "image/svg+xml"); - newDoc.append(function () { - return doc.documentElement; - }); - var newSvg = newDoc.select('svg'); - var data = extractAllElementsData(newSvg); - this._dispatch.call('dataExtractEnd', this); - postProcessDataPass1Local(data); - this._dispatch.call('dataProcessPass1End', this); - postProcessDataPass2Global(data); - this._dispatch.call('dataProcessPass2End', this); - this._data = data; - this._dictionary = dictionary; - this._nodeDictionary = nodeDictionary; - this._extractData = function (element, childIndex, parentData) { - var data = extractAllElementsData(element); - postProcessDataPass1Local(data, childIndex, parentData); - postProcessDataPass2Global(data); - return data; - }; - this._busy = false; - this._dispatch.call('dataProcessEnd', this); - if (callback) { - callback.call(this); - } - if (this._queue.length > 0) { - var job = this._queue.shift(); - job.call(this); - } - } - - function renderDot (src, callback) { - var graphvizInstance = this; - this.dot(src, render); - function render() { - graphvizInstance.render(callback); - } - return this; - } - - function transition (name) { - if (name instanceof Function) { - this._transitionFactory = name; - } else { - this._transition = d3Transition.transition(name); - } - return this; - } - function active(name) { - var root = this._selection; - var svg = root.selectWithoutDataPropagation("svg"); - if (svg.size() != 0) { - return d3Transition.active(svg.node(), name); - } else { - return null; - } - } - - function options (options) { - if (typeof options == 'undefined') { - return Object.assign({}, this._options); - } else { - for (var _i = 0, _Object$keys = Object.keys(options); _i < _Object$keys.length; _i++) { - var option = _Object$keys[_i]; - this._options[option] = options[option]; - } - return this; - } - } - - function width (width) { - this._options.width = width; - return this; - } - - function height (height) { - this._options.height = height; - return this; - } - - function scale (scale) { - this._options.scale = scale; - return this; - } - - function fit (fit) { - this._options.fit = fit; - return this; - } - - function attributer (callback) { - this._attributer = callback; - return this; - } - - function engine (engine) { - this._options.engine = engine; - return this; - } - - function images (path, width, height) { - this._images.push({ - path: path, - width: width, - height: height - }); - return this; - } - - function keyMode (keyMode) { - if (!this._keyModes.has(keyMode)) { - throw Error('Illegal keyMode: ' + keyMode); - } - if (keyMode != this._options.keyMode && this._data != null) { - throw Error('Too late to change keyMode'); - } - this._options.keyMode = keyMode; - return this; - } - - function fade (enable) { - this._options.fade = enable; - return this; - } - - function tweenPaths (enable) { - this._options.tweenPaths = enable; - return this; - } - - function tweenShapes (enable) { - this._options.tweenShapes = enable; - if (enable) { - this._options.tweenPaths = true; - } - return this; - } - - function convertEqualSidedPolygons (enable) { - this._options.convertEqualSidedPolygons = enable; - return this; - } - - function tweenPrecision (precision) { - this._options.tweenPrecision = precision; - return this; - } - - function growEnteringEdges (enable) { - this._options.growEnteringEdges = enable; - return this; - } - - function on (typenames, callback) { - this._dispatch.on(typenames, callback); - return this; - } - - function onerror (callback) { - this._onerror = callback; - return this; - } - - function logEvents (enable) { - var _this = this; - var t0 = Date.now(); - var times = {}; - var eventTypes = this._eventTypes; - var maxEventTypeLength = Math.max.apply(Math, _toConsumableArray(eventTypes.map(function (eventType) { - return eventType.length; - }))); - var _loop = function _loop(i) { - var eventType = eventTypes[i]; - times[eventType] = []; - graphvizInstance = _this; - _this.on(eventType + '.log', enable ? function () { - var t = Date.now(); - var seqNo = times[eventType].length; - times[eventType].push(t); - var string = ''; - string += 'Event '; - string += d3Format.format(' >2')(i) + ' '; - string += eventType + ' '.repeat(maxEventTypeLength - eventType.length); - string += d3Format.format(' >5')(t - t0) + ' '; - if (eventType != 'initEnd') { - string += d3Format.format(' >5')(t - times['start'][seqNo]); - } - if (eventType == 'dataProcessEnd') { - string += ' prepare ' + d3Format.format(' >5')(t - times['layoutEnd'][seqNo]); - } - if (eventType == 'renderEnd' && graphvizInstance._transition) { - string += ' transition start margin ' + d3Format.format(' >5')(graphvizInstance._transition.delay() - (t - times['renderStart'][seqNo])); - expectedDelay = graphvizInstance._transition.delay(); - expectedDuration = graphvizInstance._transition.duration(); - } - if (eventType == 'transitionStart') { - var actualDelay = t - times['renderStart'][seqNo]; - string += ' transition delay ' + d3Format.format(' >5')(t - times['renderStart'][seqNo]); - string += ' expected ' + d3Format.format(' >5')(expectedDelay); - string += ' diff ' + d3Format.format(' >5')(actualDelay - expectedDelay); - } - if (eventType == 'transitionEnd') { - var actualDuration = t - times['transitionStart'][seqNo]; - string += ' transition duration ' + d3Format.format(' >5')(actualDuration); - string += ' expected ' + d3Format.format(' >5')(expectedDuration); - string += ' diff ' + d3Format.format(' >5')(actualDuration - expectedDuration); - } - console.log(string); - t0 = t; - } : null); - }, - graphvizInstance, - expectedDelay, - expectedDuration; - for (var i = 0; i < eventTypes.length; i++) { - _loop(i); - } - return this; - } - - function destroy () { - delete this._selection.node().__graphviz__; - if (this._worker) { - this._workerPortClose(); - } - return this; - } - - function rotate(x, y, cosA, sinA) { - // (x + j * y) * (cosA + j * sinA) = x * cosA - y * sinA + j * (x * sinA + y * cosA) - y = -y; - sinA = -sinA; - var _ref = [x * cosA - y * sinA, x * sinA + y * cosA]; - x = _ref[0]; - y = _ref[1]; - y = -y; - return [x, y]; - } - - function drawEdge(x1, y1, x2, y2, attributes) { - var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {}; - attributes = Object.assign({}, attributes); - if (attributes.style && attributes.style.includes('invis')) { - var newEdge = d3__namespace.select(null); - } else { - var root = this._selection; - var svg = root.selectWithoutDataPropagation("svg"); - var graph0 = svg.selectWithoutDataPropagation("g"); - var newEdge0 = createEdge.call(this, attributes); - var edgeData = extractAllElementsData(newEdge0); - var newEdge = graph0.append('g').data([edgeData]); - attributeElement.call(newEdge.node(), edgeData); - _updateEdge.call(this, newEdge, x1, y1, x2, y2, attributes, options); - } - this._drawnEdge = { - g: newEdge, - x1: x1, - y1: y1, - x2: x2, - y2: y2, - attributes: attributes - }; - return this; - } - function updateDrawnEdge(x1, y1, x2, y2) { - var attributes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}; - var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {}; - if (!this._drawnEdge) { - throw Error('No edge has been drawn'); - } - var edge = this._drawnEdge.g; - attributes = Object.assign(this._drawnEdge.attributes, attributes); - this._drawnEdge.x1 = x1; - this._drawnEdge.y1 = y1; - this._drawnEdge.x2 = x2; - this._drawnEdge.y2 = y2; - if (edge.empty() && !(attributes.style && attributes.style.includes('invis'))) { - var root = this._selection; - var svg = root.selectWithoutDataPropagation("svg"); - var graph0 = svg.selectWithoutDataPropagation("g"); - var edge = graph0.append('g'); - this._drawnEdge.g = edge; - } - if (!edge.empty()) { - _updateEdge.call(this, edge, x1, y1, x2, y2, attributes, options); - } - return this; - } - function _updateEdge(edge, x1, y1, x2, y2, attributes, options) { - var newEdge = createEdge.call(this, attributes); - var edgeData = extractAllElementsData(newEdge); - edge.data([edgeData]); - attributeElement.call(edge.node(), edgeData); - _moveEdge(edge, x1, y1, x2, y2, attributes, options); - } - function _moveEdge(edge, x1, y1, x2, y2, attributes, options) { - var shortening = options.shortening || 0; - var arrowHeadLength = 10; - var arrowHeadWidth = 7; - var margin = 0.1; - var arrowHeadPoints = [[0, -arrowHeadWidth / 2], [arrowHeadLength, 0], [0, arrowHeadWidth / 2], [0, -arrowHeadWidth / 2]]; - var dx = x2 - x1; - var dy = y2 - y1; - var length = Math.sqrt(dx * dx + dy * dy); - if (length == 0) { - var cosA = 1; - var sinA = 0; - } else { - var cosA = dx / length; - var sinA = dy / length; - } - x2 = x1 + (length - shortening - arrowHeadLength - margin) * cosA; - y2 = y1 + (length - shortening - arrowHeadLength - margin) * sinA; - if (attributes.URL || attributes.tooltip) { - var a = edge.selectWithoutDataPropagation("g").selectWithoutDataPropagation("a"); - var line = a.selectWithoutDataPropagation("path"); - var arrowHead = a.selectWithoutDataPropagation("polygon"); - } else { - var line = edge.selectWithoutDataPropagation("path"); - var arrowHead = edge.selectWithoutDataPropagation("polygon"); - } - var path1 = d3Path.path(); - path1.moveTo(x1, y1); - path1.lineTo(x2, y2); - line.attr("d", path1); - x2 = x1 + (length - shortening - arrowHeadLength) * cosA; - y2 = y1 + (length - shortening - arrowHeadLength) * sinA; - for (var i = 0; i < arrowHeadPoints.length; i++) { - var point = arrowHeadPoints[i]; - arrowHeadPoints[i] = rotate(point[0], point[1], cosA, sinA); - } - for (var i = 0; i < arrowHeadPoints.length; i++) { - var point = arrowHeadPoints[i]; - arrowHeadPoints[i] = [x2 + point[0], y2 + point[1]]; - } - var allPoints = []; - for (var i = 0; i < arrowHeadPoints.length; i++) { - var point = arrowHeadPoints[i]; - allPoints.push(point.join(',')); - } - var pointsAttr = allPoints.join(' '); - arrowHead.attr("points", pointsAttr); - return this; - } - function moveDrawnEdgeEndPoint(x2, y2) { - var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - if (!this._drawnEdge) { - throw Error('No edge has been drawn'); - } - var edge = this._drawnEdge.g; - var x1 = this._drawnEdge.x1; - var y1 = this._drawnEdge.y1; - var attributes = this._drawnEdge.attributes; - this._drawnEdge.x2 = x2; - this._drawnEdge.y2 = y2; - _moveEdge(edge, x1, y1, x2, y2, attributes, options); - return this; - } - function removeDrawnEdge() { - if (!this._drawnEdge) { - return this; - } - var edge = this._drawnEdge.g; - edge.remove(); - this._drawnEdge = null; - return this; - } - function insertDrawnEdge(name) { - if (!this._drawnEdge) { - throw Error('No edge has been drawn'); - } - var edge = this._drawnEdge.g; - if (edge.empty()) { - return this; - } - this._drawnEdge.attributes; - var title = edge.selectWithoutDataPropagation("title"); - title.text(name); - var root = this._selection; - var svg = root.selectWithoutDataPropagation("svg"); - var graph0 = svg.selectWithoutDataPropagation("g"); - var graph0Datum = graph0.datum(); - var edgeData = this._extractData(edge, graph0Datum.children.length, graph0.datum()); - graph0Datum.children.push(edgeData); - insertAllElementsData(edge, edgeData); - this._drawnEdge = null; - return this; - } - function drawnEdgeSelection() { - if (this._drawnEdge) { - return this._drawnEdge.g; - } else { - return d3__namespace.select(null); - } - } - function createEdge(attributes) { - var attributesString = ''; - for (var _i = 0, _Object$keys = Object.keys(attributes); _i < _Object$keys.length; _i++) { - var name = _Object$keys[_i]; - if (attributes[name] != null) { - attributesString += ' "' + name + '"="' + attributes[name] + '"'; - } - } - var dotSrc = 'digraph {a -> b [' + attributesString + ']}'; - var svgDoc = this.layoutSync(dotSrc, 'svg', 'dot'); - var parser = new window.DOMParser(); - var doc = parser.parseFromString(svgDoc, "image/svg+xml"); - var newDoc = d3__namespace.select(document.createDocumentFragment()).append(function () { - return doc.documentElement; - }); - var edge = newDoc.select('.edge'); - return edge; - } - - function drawNode(x, y, nodeId) { - var attributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; - var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}; - attributes = Object.assign({}, attributes); - if (attributes.style && attributes.style.includes('invis')) { - var newNode = d3__namespace.select(null); - } else { - var root = this._selection; - var svg = root.selectWithoutDataPropagation("svg"); - var graph0 = svg.selectWithoutDataPropagation("g"); - var newNode0 = createNode.call(this, nodeId, attributes); - var nodeData = extractAllElementsData(newNode0); - var newNode = graph0.append('g').data([nodeData]); - attributeElement.call(newNode.node(), nodeData); - _updateNode.call(this, newNode, x, y, nodeId, attributes, options); - } - this._drawnNode = { - g: newNode, - nodeId: nodeId, - x: x, - y: y, - attributes: attributes - }; - return this; - } - function updateDrawnNode(x, y, nodeId) { - var attributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; - var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}; - if (!this._drawnNode) { - throw Error('No node has been drawn'); - } - var node = this._drawnNode.g; - if (nodeId == null) { - nodeId = this._drawnNode.nodeId; - } - attributes = Object.assign(this._drawnNode.attributes, attributes); - this._drawnNode.nodeId = nodeId; - this._drawnNode.x = x; - this._drawnNode.y = y; - if (node.empty() && !(attributes.style && attributes.style.includes('invis'))) { - var root = this._selection; - var svg = root.selectWithoutDataPropagation("svg"); - var graph0 = svg.selectWithoutDataPropagation("g"); - var node = graph0.append('g'); - this._drawnNode.g = node; - } - if (!node.empty()) { - _updateNode.call(this, node, x, y, nodeId, attributes, options); - } - return this; - } - function _updateNode(node, x, y, nodeId, attributes, options) { - var newNode = createNode.call(this, nodeId, attributes); - var nodeData = extractAllElementsData(newNode); - node.data([nodeData]); - attributeElement.call(node.node(), nodeData); - _moveNode(node, x, y, attributes); - return this; - } - function _moveNode(node, x, y, attributes, options) { - if (attributes.URL || attributes.tooltip) { - var subParent = node.selectWithoutDataPropagation("g").selectWithoutDataPropagation("a"); - } else { - var subParent = node; - } - var svgElements = subParent.selectAll('ellipse,polygon,path,polyline'); - var text = node.selectWithoutDataPropagation("text"); - if (svgElements.size() != 0) { - var bbox = svgElements.node().getBBox(); - bbox.cx = bbox.x + bbox.width / 2; - bbox.cy = bbox.y + bbox.height / 2; - } else if (text.size() != 0) { - bbox = { - x: +text.attr('x'), - y: +text.attr('y'), - width: 0, - height: 0, - cx: +text.attr('x'), - cy: +text.attr('y') - }; - } - svgElements.each(function (data, index) { - var svgElement = d3__namespace.select(this); - if (svgElement.attr("cx")) { - svgElement.attr("cx", roundTo2Decimals(x)).attr("cy", roundTo2Decimals(y)); - } else if (svgElement.attr("points")) { - var pointsString = svgElement.attr('points').trim(); - svgElement.attr("points", translatePointsAttribute(pointsString, x - bbox.cx, y - bbox.cy)); - } else { - var d = svgElement.attr('d'); - svgElement.attr("d", translateDAttribute(d, x - bbox.cx, y - bbox.cy)); - } - }); - if (text.size() != 0) { - text.attr("x", roundTo2Decimals(+text.attr("x") + x - bbox.cx)).attr("y", roundTo2Decimals(+text.attr("y") + y - bbox.cy)); - } - return this; - } - function moveDrawnNode(x, y) { - if (!this._drawnNode) { - throw Error('No node has been drawn'); - } - var node = this._drawnNode.g; - var attributes = this._drawnNode.attributes; - this._drawnNode.x = x; - this._drawnNode.y = y; - if (!node.empty()) { - _moveNode(node, x, y, attributes); - } - return this; - } - function removeDrawnNode() { - if (!this._drawnNode) { - return this; - } - var node = this._drawnNode.g; - if (!node.empty()) { - node.remove(); - } - this._drawnNode = null; - return this; - } - function insertDrawnNode(nodeId) { - if (!this._drawnNode) { - throw Error('No node has been drawn'); - } - if (nodeId == null) { - nodeId = this._drawnNode.nodeId; - } - var node = this._drawnNode.g; - if (node.empty()) { - return this; - } - var attributes = this._drawnNode.attributes; - var title = node.selectWithoutDataPropagation("title"); - title.text(nodeId); - if (attributes.URL || attributes.tooltip) { - var ga = node.selectWithoutDataPropagation("g"); - var a = ga.selectWithoutDataPropagation("a"); - a.selectWithoutDataPropagation('ellipse,polygon,path,polyline'); - var text = a.selectWithoutDataPropagation('text'); - } else { - node.selectWithoutDataPropagation('ellipse,polygon,path,polyline'); - var text = node.selectWithoutDataPropagation('text'); - } - text.text(attributes.label || nodeId); - var root = this._selection; - var svg = root.selectWithoutDataPropagation("svg"); - var graph0 = svg.selectWithoutDataPropagation("g"); - var graph0Datum = graph0.datum(); - var nodeData = this._extractData(node, graph0Datum.children.length, graph0.datum()); - graph0Datum.children.push(nodeData); - insertAllElementsData(node, nodeData); - this._drawnNode = null; - return this; - } - function drawnNodeSelection() { - if (this._drawnNode) { - return this._drawnNode.g; - } else { - return d3__namespace.select(null); - } - } - function createNode(nodeId, attributes) { - var attributesString = ''; - for (var _i = 0, _Object$keys = Object.keys(attributes); _i < _Object$keys.length; _i++) { - var name = _Object$keys[_i]; - if (attributes[name] != null) { - attributesString += ' "' + name + '"="' + attributes[name] + '"'; - } - } - var dotSrc = 'graph {"' + nodeId + '" [' + attributesString + ']}'; - var svgDoc = this.layoutSync(dotSrc, 'svg', 'dot'); - var parser = new window.DOMParser(); - var doc = parser.parseFromString(svgDoc, "image/svg+xml"); - var newDoc = d3__namespace.select(document.createDocumentFragment()).append(function () { - return doc.documentElement; - }); - var node = newDoc.select('.node'); - return node; - } - - /* This file is excluded from coverage because the instrumented code - * translates "self" which gives a reference error. - */ - - /* c8 ignore start */ - - function workerCodeBody(port) { - self.document = {}; // Workaround for "ReferenceError: document is not defined" in hpccWasm - - port.addEventListener('message', function (event) { - var hpccWasm = self["@hpcc-js/wasm"]; - if (hpccWasm == undefined && event.data.vizURL) { - importScripts(event.data.vizURL); - hpccWasm = self["@hpcc-js/wasm"]; - // This is an alternative workaround where wasmFolder() is not needed - // document = {currentScript: {src: event.data.vizURL}}; - } - if (event.data.type == "version") { - hpccWasm.Graphviz.load().then(function (graphviz) { - port.postMessage({ - type: "version", - version: graphviz.version() - }); - }); - return; - } - hpccWasm.Graphviz.load().then(function (graphviz) { - var svg = graphviz.layout(event.data.dot, "svg", event.data.engine, event.data.options); - if (svg) { - port.postMessage({ - type: "done", - svg: svg - }); - } else if (event.data.vizURL) { - port.postMessage({ - type: "init" - }); - } else { - port.postMessage({ - type: "skip" - }); - } - })["catch"](function (error) { - port.postMessage({ - type: "error", - error: error.message - }); - }); - }); - } - function workerCode() { - var port = self; - workerCodeBody(port); - } - function sharedWorkerCode() { - self.onconnect = function (e) { - var port = e.ports[0]; - workerCodeBody(port); - port.start(); - }; - } - - /* c8 ignore stop */ - - var _graphviz$prototype; - function Graphviz(selection, options) { - var _this = this; - this._options = { - useWorker: true, - useSharedWorker: false, - engine: 'dot', - keyMode: 'title', - fade: true, - tweenPaths: true, - tweenShapes: true, - convertEqualSidedPolygons: true, - tweenPrecision: 1, - growEnteringEdges: true, - zoom: true, - zoomScaleExtent: [0.1, 10], - zoomTranslateExtent: [[-Infinity, -Infinity], [+Infinity, +Infinity]], - width: null, - height: null, - scale: 1, - fit: false - }; - if (options instanceof Object) { - for (var _i = 0, _Object$keys = Object.keys(options); _i < _Object$keys.length; _i++) { - var option = _Object$keys[_i]; - this._options[option] = options[option]; - } - } else if (typeof options == 'boolean') { - this._options.useWorker = options; - } - var useWorker = this._options.useWorker; - var useSharedWorker = this._options.useSharedWorker; - if (typeof Worker == 'undefined') { - useWorker = false; - } - if (typeof SharedWorker == 'undefined') { - useSharedWorker = false; - } - if (useWorker || useSharedWorker) { - var scripts = d3__namespace.selectAll('script'); - var vizScript = scripts.filter(function () { - return d3__namespace.select(this).attr('type') == 'javascript/worker' || d3__namespace.select(this).attr('src') && d3__namespace.select(this).attr('src').match(/.*\/@hpcc-js\/wasm/); - }); - if (vizScript.size() == 0) { - console.warn('No script tag of type "javascript/worker" was found and "useWorker" is true. Not using web worker.'); - useWorker = false; - useSharedWorker = false; - } else { - this._vizURL = vizScript.attr('src'); - if (!this._vizURL) { - console.warn('No "src" attribute of was found on the "javascript/worker" script tag and "useWorker" is true. Not using web worker.'); - useWorker = false; - useSharedWorker = false; - } - } - } - if (useSharedWorker) { - var url = 'data:application/javascript;base64,' + btoa(workerCodeBody.toString() + '(' + sharedWorkerCode.toString() + ')()'); - this._worker = this._worker = new SharedWorker(url); - this._workerPort = this._worker.port; - this._workerPortClose = this._worker.port.close.bind(this._workerPort); - this._worker.port.start(); - this._workerCallbacks = []; - } else if (useWorker) { - var blob = new Blob([workerCodeBody.toString() + '(' + workerCode.toString() + ')()']); - var blobURL = window.URL.createObjectURL(blob); - this._worker = new Worker(blobURL); - this._workerPort = this._worker; - this._workerPortClose = this._worker.terminate.bind(this._worker); - this._workerCallbacks = []; - } else { - xo.load().then(function (graphviz) { - _this._graphvizVersion = graphviz.version(); - }.bind(this)); - } - this._selection = selection; - this._active = false; - this._busy = false; - this._jobs = []; - this._queue = []; - this._keyModes = new Set(['title', 'id', 'tag-index', 'index']); - this._images = []; - this._translation = undefined; - this._scale = undefined; - this._eventTypes = ['initEnd', 'start', 'layoutStart', 'layoutEnd', 'dataExtractEnd', 'dataProcessPass1End', 'dataProcessPass2End', 'dataProcessEnd', 'renderStart', 'renderEnd', 'transitionStart', 'transitionEnd', 'restoreEnd', 'end', 'zoom']; - this._dispatch = d3Dispatch.dispatch.apply(void 0, _toConsumableArray(this._eventTypes)); - initViz.call(this); - selection.node().__graphviz__ = this; - } - function graphviz(selector, options) { - var g = d3__namespace.select(selector).graphviz(options); - return g; - } - Graphviz.prototype = graphviz.prototype = (_graphviz$prototype = { - constructor: Graphviz, - engine: engine, - addImage: images, - keyMode: keyMode, - fade: fade, - tweenPaths: tweenPaths, - tweenShapes: tweenShapes, - convertEqualSidedPolygons: convertEqualSidedPolygons, - tweenPrecision: tweenPrecision, - growEnteringEdges: growEnteringEdges, - zoom: zoom, - resetZoom: resetZoom, - zoomBehavior: zoomBehavior, - zoomSelection: zoomSelection, - zoomScaleExtent: zoomScaleExtent, - zoomTranslateExtent: zoomTranslateExtent, - render: render, - layout: layout, - dot: dot, - data: data, - renderDot: renderDot, - transition: transition, - active: active, - options: options, - width: width, - height: height, - scale: scale, - fit: fit, - attributer: attributer, - on: on, - onerror: onerror, - logEvents: logEvents, - destroy: destroy, - drawEdge: drawEdge, - updateDrawnEdge: updateDrawnEdge, - moveDrawnEdgeEndPoint: moveDrawnEdgeEndPoint, - insertDrawnEdge: insertDrawnEdge, - removeDrawnEdge: removeDrawnEdge - }, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_graphviz$prototype, "removeDrawnEdge", removeDrawnEdge), "drawnEdgeSelection", drawnEdgeSelection), "drawnEdgeSelection", drawnEdgeSelection), "drawNode", drawNode), "updateDrawnNode", updateDrawnNode), "moveDrawnNode", moveDrawnNode), "insertDrawnNode", insertDrawnNode), "removeDrawnNode", removeDrawnNode), "removeDrawnNode", removeDrawnNode), "drawnNodeSelection", drawnNodeSelection), _defineProperty(_defineProperty(_graphviz$prototype, "drawnNodeSelection", drawnNodeSelection), "graphvizVersion", graphvizVersion)); - - function selection_graphviz (options) { - var g = this.node().__graphviz__; - if (g) { - g.options(options); - // Ensure a possible new initEnd event handler is attached before calling it - d3Timer.timeout(function () { - g._dispatch.call("initEnd", this); - }.bind(this), 0); - } else { - g = new Graphviz(this, options); - } - return g; - } - - function selection_selectWithoutDataPropagation (name) { - return d3__namespace.select(this.size() > 0 ? this.node().querySelector(name) : null); - } - - d3.selection.prototype.graphviz = selection_graphviz; - d3.selection.prototype.selectWithoutDataPropagation = selection_selectWithoutDataPropagation; - - exports.graphviz = graphviz; - -})); -//# sourceMappingURL=d3-graphviz.js.map diff --git a/graph/web/vendor/graphviz.umd.js b/graph/web/vendor/graphviz.umd.js deleted file mode 100644 index 622b4d34..00000000 --- a/graph/web/vendor/graphviz.umd.js +++ /dev/null @@ -1,7 +0,0 @@ -(function(g,f){if(typeof exports=="object"&&typeof module<"u"){module.exports=f()}else if("function"==typeof define && define.amd){define("@hpcc-js/wasm",f)}else {g["@hpcc-js/wasm"]=f()}}(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : this,function(){var exports={};var __exports=exports;var module={exports}; -"use strict";var pr=Object.defineProperty;var so=Object.getOwnPropertyDescriptor;var uo=Object.getOwnPropertyNames;var po=Object.prototype.hasOwnProperty;var lo=(p,l)=>{for(var d in l)pr(p,d,{get:l[d],enumerable:!0})},co=(p,l,d,i)=>{if(l&&typeof l=="object"||typeof l=="function")for(let f of uo(l))!po.call(p,f)&&f!==d&&pr(p,f,{get:()=>l[f],enumerable:!(i=so(l,f))||i.enumerable});return p};var fo=p=>co(pr({},"__esModule",{value:!0}),p);var Yo={};lo(Yo,{Graphviz:()=>Zo});module.exports=fo(Yo);var vo=ArrayBuffer,H=Uint8Array,Qe=Uint16Array,mo=Int16Array,qe=Int32Array,lr=function(p,l,d){if(H.prototype.slice)return H.prototype.slice.call(p,l,d);(l==null||l<0)&&(l=0),(d==null||d>p.length)&&(d=p.length);var i=new H(d-l);return i.set(p.subarray(l,d)),i},Ye=function(p,l,d,i){if(H.prototype.fill)return H.prototype.fill.call(p,l,d,i);for((d==null||d<0)&&(d=0),(i==null||i>p.length)&&(i=p.length);dp.length)&&(i=p.length);d2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],T=function(p,l,d){var i=new Error(l||go[p]);if(i.code=p,Error.captureStackTrace&&Error.captureStackTrace(i,T),!d)throw i;return i},Pr=function(p,l,d){for(var i=0,f=0;i>>0},wo=function(p,l){var d=p[0]|p[1]<<8|p[2]<<16;if(d==3126568&&p[3]==253){var i=p[4],f=i>>5&1,m=i>>2&1,_=i&3,h=i>>6;i&8&&T(0);var M=6-f,I=_==3?4:_,Q=Pr(p,M,I);M+=I;var Z=h?1<>3);z=q+(q>>3)*(p[5]&7)}z>2145386496&&T(1);var X=new H((l==1?Y||z:l?0:z)+12);return X[0]=1,X[4]=4,X[8]=8,{b:M+Z,y:0,l:0,d:Q,w:l&&l!=1?l:X.subarray(12),e:z,o:new qe(X.buffer,0,3),u:Y,c:m,m:Math.min(131072,z)}}else if((d>>4|p[3]<<20)==25481893)return ho(p,4)+8;T(0)},Xe=function(p){for(var l=0;1<d&&T(3);for(var m=1<0;){var S=Xe(_+1),P=i>>3,ae=(1<>(i&7)&ae,w=(1<w&&(J-=j)),Y[++h]=--J,J==-1?(_+=J,V[--Q]=h):_-=J,!J)do{var ie=i>>3;M=(p[ie]|p[ie+1]<<8)>>(i&7)&3,i+=2,h+=M}while(M==3)}(h>255||_)&&T(0);for(var b=0,k=(m>>1)+(m>>3)+3,se=m-1,oe=0;oe<=h;++oe){var K=Y[oe];if(K<1){z[oe]=-K;continue}for(I=0;I=Q)}}for(b&&T(0),I=0;I>3,{b:f,s:V,n:re,t:q}]},yo=function(p,l){var d=0,i=-1,f=new H(292),m=p[l],_=f.subarray(0,256),h=f.subarray(256,268),M=new Qe(f.buffer,268);if(m<128){var I=je(p,l+1,6),Q=I[0],Z=I[1];l+=m;var Y=Q<<3,z=p[l];z||T(0);for(var q=0,X=0,V=Z.b,re=V,S=(++l<<3)-8+Xe(z);S-=V,!(S>3;if(q+=(p[P]|p[P+1]<<8)>>(S&7)&(1<>3,X+=(p[P]|p[P+1]<<8)>>(S&7)&(1<255&&T(0)}else{for(i=m-127;d>4,_[d+1]=ae&15}++l}var J=0;for(d=0;d11&&T(0),J+=w&&1<0;--d){var oe=M[d];Ye(se,d,oe,M[d-1]=oe+h[d]*(1<h&&Z>3,z=(p[Y]|p[Y+1]<<8|p[Y+2]<<16)>>(Q&7);M=(M<>2,_=m<<1,h=m+_;Ze(p.subarray(i,i+=p[0]|p[1]<<8),l.subarray(0,m),d),Ze(p.subarray(i,i+=p[2]|p[3]<<8),l.subarray(m,_),d),Ze(p.subarray(i,i+=p[4]|p[5]<<8),l.subarray(_,h),d),Ze(p.subarray(i),l.subarray(h),d)},Bo=function(p,l,d){var i,f=l.b,m=p[f],_=m>>1&3;l.l=m&1;var h=m>>3|p[f+1]<<5|p[f+2]<<13,M=(f+=3)+h;if(_==1)return f>=p.length?void 0:(l.b=f+1,d?(Ye(d,p[f],l.y,l.y+=h),d):Ye(new H(h),p[f]));if(!(M>p.length)){if(_==0)return l.b=M,d?(d.set(p.subarray(f,M),l.y),l.y+=h,d):lr(p,f,M);if(_==2){var I=p[f],Q=I&3,Z=I>>2&3,Y=I>>4,z=0,q=0;Q<2?Z&1?Y|=p[++f]<<4|(Z&2&&p[++f]<<12):Y=I>>3:(q=Z,Z<2?(Y|=(p[++f]&63)<<4,z=p[f]>>6|p[++f]<<2):Z==2?(Y|=p[++f]<<4|(p[++f]&3)<<12,z=p[f]>>2|p[++f]<<6):(Y|=p[++f]<<4|(p[++f]&63)<<12,z=p[f]>>6|p[++f]<<2|p[++f]<<10)),++f;var X=d?d.subarray(l.y,l.y+l.m):new H(l.m),V=X.length-Y;if(Q==0)X.set(p.subarray(f,f+=Y),V);else if(Q==1)Ye(X,p[f++],V);else{var re=l.h;if(Q==2){var S=yo(p,f);z+=f-(f=S[0]),l.h=re=S[1]}else re||T(0);(q?Lo:Ze)(p.subarray(f,f+=z),X.subarray(V),re)}var P=p[f++];if(P){P==255?P=(p[f++]|p[f++]<<8)+32512:P>127&&(P=P-128<<8|p[f++]);var ae=p[f++];ae&3&&T(0);for(var J=[Eo,Mo,bo],w=2;w>-1;--w){var j=ae>>(w<<1)+2&3;if(j==1){var W=new H([0,0,p[f++]]);J[w]={s:W.subarray(2,3),n:W.subarray(0,1),t:new Qe(W.buffer,0,1),b:0}}else j==2?(i=je(p,f,9-(w&1)),f=i[0],J[w]=i[1]):j==3&&(l.t||T(0),J[w]=l.t[w])}var ie=l.t=J,b=ie[0],k=ie[1],se=ie[2],oe=p[M-1];oe||T(0);var K=(M<<3)-8+Xe(oe)-se.b,L=K>>3,A=0,Le=(p[L]|p[L+1]<<8)>>(K&7)&(1<>3;var Be=(p[L]|p[L+1]<<8)>>(K&7)&(1<>3;var Re=(p[L]|p[L+1]<<8)>>(K&7)&(1<>3;var $e=1<>>(K&7)&$e-1);L=(K-=fr[Ve])>>3;var me=Xo[Ve]+((p[L]|p[L+1]<<8|p[L+2]<<16)>>(K&7)&(1<>3;var _e=Do[Ne]+((p[L]|p[L+1]<<8|p[L+2]<<16)>>(K&7)&(1<>3,Le=se.t[Le]+((p[L]|p[L+1]<<8)>>(K&7)&(1<>3,Re=b.t[Re]+((p[L]|p[L+1]<<8)>>(K&7)&(1<>3,Be=k.t[Be]+((p[L]|p[L+1]<<8)>>(K&7)&(1<3)l.o[2]=l.o[1],l.o[1]=l.o[0],l.o[0]=ce-=3;else{var Ge=ce-(_e!=0);Ge?(ce=Ge==3?l.o[0]-1:l.o[Ge],Ge>1&&(l.o[2]=l.o[1]),l.o[1]=l.o[0],l.o[0]=ce):ce=l.o[0]}for(var w=0;w<_e;++w)X[A+w]=X[V+w];A+=_e,V+=_e;var Ee=A-ce;if(Ee<0){var De=-Ee,We=l.e+Ee;De>me&&(De=me);for(var w=0;w{var p=typeof document<"u"?document.currentScript?.src:void 0;return function(l={}){var d,i=l,f,m,_=new Promise((e,r)=>{f=e,m=r}),h=!1,M=Object.assign({},i),I="./this.program",Q=(e,r)=>{throw r},Z="";function Y(e){return Z+e}var z,q,X=console.log.bind(console),V=console.error.bind(console);Object.assign(i,M),M=null;var re;i.wasmBinary&&(re=i.wasmBinary);var S,P=!1,ae;function J(e,r){e||_e(r)}var w,j,W,ie,b,k,se,oe;function K(){var e=S.buffer;i.HEAP8=w=new Int8Array(e),i.HEAP16=W=new Int16Array(e),i.HEAPU8=j=new Uint8Array(e),i.HEAPU16=ie=new Uint16Array(e),i.HEAP32=b=new Int32Array(e),i.HEAPU32=k=new Uint32Array(e),i.HEAPF32=se=new Float32Array(e),i.HEAPF64=oe=new Float64Array(e)}var L=[],A=[],Le=[],Be=!1;function Re(){Ae(L)}function Ne(){Be=!0,!i.noFSInit&&!o.init.initialized&&o.init(),o.ignorePermissions=!1,Me.init(),Ae(A)}function Pe(){Ae(Le)}function Ve(e){A.unshift(e)}var ye=0,ke=null,be=null;function $e(e){return e}function ce(e){ye++}function me(e){if(ye--,ye==0&&(ke!==null&&(clearInterval(ke),ke=null),be)){var r=be;be=null,r()}}function _e(e){e="Aborted("+e+")",V(e),P=!0,ae=1,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw m(r),r}var Ge="data:application/octet-stream;base64,",Ee=e=>e.startsWith(Ge),De=e=>e.startsWith("file://");function We(){var e="graphvizlib.wasm";return Ee(e)?e:Y(e)}var Je;function vr(e){if(e==Je&&re)return new Uint8Array(re);if(q)return q(e);throw"both async and sync fetching of the wasm failed"}function Sr(e){return re?Promise.resolve().then(()=>vr(e)):z(e).then(r=>new Uint8Array(r),()=>vr(e))}function mr(e,r,t){return Sr(e).then(n=>WebAssembly.instantiate(n,r)).then(t,n=>{V(`failed to asynchronously prepare wasm: ${n}`),_e(n)})}function Hr(e,r,t,n){return!e&&typeof WebAssembly.instantiateStreaming=="function"&&!Ee(r)&&!De(r)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(a=>{var s=WebAssembly.instantiateStreaming(a,t);return s.then(n,function(u){return V(`wasm streaming compile failed: ${u}`),V("falling back to ArrayBuffer instantiation"),mr(r,t,n)})}):mr(r,t,n)}function Tr(){return{a:qt}}function Qr(){var e=Tr();function r(n,a){return N=n.exports,S=N.B,K(),Ve(N.C),me("wasm-instantiate"),N}ce("wasm-instantiate");function t(n){r(n.instance)}return Je||(Je=We()),Hr(re,Je,e,t).catch(m),{}}var R,$,qr={172808:(e,r)=>{var t=ue(e),n=ue(r);o.createPath("/",C.dirname(t)),o.writeFile(C.join("/",t),n)}};function $r(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var Ae=e=>{for(;e.length>0;)e.shift()(i)};class Wr{constructor(r){this.excPtr=r,this.ptr=r-24}set_type(r){k[this.ptr+4>>2]=r}get_type(){return k[this.ptr+4>>2]}set_destructor(r){k[this.ptr+8>>2]=r}get_destructor(){return k[this.ptr+8>>2]}set_caught(r){r=r?1:0,w[this.ptr+12]=r}get_caught(){return w[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,w[this.ptr+13]=r}get_rethrown(){return w[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)}set_adjusted_ptr(r){k[this.ptr+16>>2]=r}get_adjusted_ptr(){return k[this.ptr+16>>2]}get_exception_ptr(){var r=zr(this.get_type());if(r)return k[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var _r=0,Ar=0,et=(e,r,t)=>{var n=new Wr(e);throw n.init(r,t),_r=e,Ar++,_r},C={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var a=e[n];a==="."?e.splice(n,1):a===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=C.isAbs(e),t=e.substr(-1)==="/";return e=C.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=C.splitPath(e),t=r[0],n=r[1];return!t&&!n?".":(n&&(n=n.substr(0,n.length-1)),t+n)},basename:e=>{if(e==="/")return"/";e=C.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:(...e)=>C.normalize(e.join("/")),join2:(e,r)=>C.normalize(e+"/"+r)},rt=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return e=>crypto.getRandomValues(e);_e("initRandomDevice")},gr=e=>(gr=rt())(e),he={resolve:(...e)=>{for(var r="",t=!1,n=e.length-1;n>=-1&&!t;n--){var a=n>=0?e[n]:o.cwd();if(typeof a!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!a)return"";r=a+"/"+r,t=C.isAbs(a)}return r=C.normalizeArray(r.split("/").filter(s=>!!s),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=he.resolve(e).substr(1),r=he.resolve(r).substr(1);function t(E){for(var G=0;G=0&&E[x]==="";x--);return G>x?[]:E.slice(G,x-G+1)}for(var n=t(e.split("/")),a=t(r.split("/")),s=Math.min(n.length,a.length),u=s,c=0;c{for(var n=r+t,a=r;e[a]&&!(a>=n);)++a;if(a-r>16&&e.buffer&&hr)return hr.decode(e.subarray(r,a));for(var s="";r>10,56320|E&1023)}}return s},er=[],rr=e=>{for(var r=0,t=0;t=55296&&n<=57343?(r+=4,++t):r+=3}return r},tr=(e,r,t,n)=>{if(!(n>0))return 0;for(var a=t,s=t+n-1,u=0;u=55296&&c<=57343){var v=e.charCodeAt(++u);c=65536+((c&1023)<<10)|v&1023}if(c<=127){if(t>=s)break;r[t++]=c}else if(c<=2047){if(t+1>=s)break;r[t++]=192|c>>6,r[t++]=128|c&63}else if(c<=65535){if(t+2>=s)break;r[t++]=224|c>>12,r[t++]=128|c>>6&63,r[t++]=128|c&63}else{if(t+3>=s)break;r[t++]=240|c>>18,r[t++]=128|c>>12&63,r[t++]=128|c>>6&63,r[t++]=128|c&63}}return r[t]=0,t-a};function or(e,r,t){var n=t>0?t:rr(e)+1,a=new Array(n),s=tr(e,a,0,a.length);return r&&(a.length=s),a}var tt=()=>{if(!er.length){var e=null;if(!e)return null;er=or(e,!0)}return er.shift()},Me={ttys:[],init(){},shutdown(){},register(e,r){Me.ttys[e]={input:[],output:[],ops:r},o.registerDevice(e,Me.stream_ops)},stream_ops:{open(e){var r=Me.ttys[e.node.rdev];if(!r)throw new o.ErrnoError(43);e.tty=r,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,r,t,n,a){if(!e.tty||!e.tty.ops.get_char)throw new o.ErrnoError(60);for(var s=0,u=0;u0&&(X(Fe(e.output,0)),e.output=[])},ioctl_tcgets(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,r,t){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,r){r===null||r===10?(V(Fe(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output&&e.output.length>0&&(V(Fe(e.output,0)),e.output=[])}}},ot=(e,r)=>(j.fill(0,e,e+r),e),wr=(e,r)=>Math.ceil(e/r)*r,yr=e=>{e=wr(e,65536);var r=Yr(65536,e);return r?ot(r,e):0},D={ops_table:null,mount(e){return D.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(o.isBlkdev(t)||o.isFIFO(t))throw new o.ErrnoError(63);D.ops_table||={dir:{node:{getattr:D.node_ops.getattr,setattr:D.node_ops.setattr,lookup:D.node_ops.lookup,mknod:D.node_ops.mknod,rename:D.node_ops.rename,unlink:D.node_ops.unlink,rmdir:D.node_ops.rmdir,readdir:D.node_ops.readdir,symlink:D.node_ops.symlink},stream:{llseek:D.stream_ops.llseek}},file:{node:{getattr:D.node_ops.getattr,setattr:D.node_ops.setattr},stream:{llseek:D.stream_ops.llseek,read:D.stream_ops.read,write:D.stream_ops.write,allocate:D.stream_ops.allocate,mmap:D.stream_ops.mmap,msync:D.stream_ops.msync}},link:{node:{getattr:D.node_ops.getattr,setattr:D.node_ops.setattr,readlink:D.node_ops.readlink},stream:{}},chrdev:{node:{getattr:D.node_ops.getattr,setattr:D.node_ops.setattr},stream:o.chrdev_stream_ops}};var a=o.createNode(e,r,t,n);return o.isDir(a.mode)?(a.node_ops=D.ops_table.dir.node,a.stream_ops=D.ops_table.dir.stream,a.contents={}):o.isFile(a.mode)?(a.node_ops=D.ops_table.file.node,a.stream_ops=D.ops_table.file.stream,a.usedBytes=0,a.contents=null):o.isLink(a.mode)?(a.node_ops=D.ops_table.link.node,a.stream_ops=D.ops_table.link.stream):o.isChrdev(a.mode)&&(a.node_ops=D.ops_table.chrdev.node,a.stream_ops=D.ops_table.chrdev.stream),a.timestamp=Date.now(),e&&(e.contents[r]=a,e.timestamp=a.timestamp),a},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var n=1048576;r=Math.max(r,t*(t>>0),t!=0&&(r=Math.max(r,256));var a=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(a.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)e.contents=null,e.usedBytes=0;else{var t=e.contents;e.contents=new Uint8Array(r),t&&e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr(e){var r={};return r.dev=o.isChrdev(e.mode)?e.id:1,r.ino=e.id,r.mode=e.mode,r.nlink=1,r.uid=0,r.gid=0,r.rdev=e.rdev,o.isDir(e.mode)?r.size=4096:o.isFile(e.mode)?r.size=e.usedBytes:o.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&D.resizeFileStorage(e,r.size)},lookup(e,r){throw o.genericErrors[44]},mknod(e,r,t,n){return D.createNode(e,r,t,n)},rename(e,r,t){if(o.isDir(e.mode)){var n;try{n=o.lookupNode(r,t)}catch{}if(n)for(var a in n.contents)throw new o.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp},unlink(e,r){delete e.contents[r],e.timestamp=Date.now()},rmdir(e,r){var t=o.lookupNode(e,r);for(var n in t.contents)throw new o.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now()},readdir(e){var r=[".",".."];for(var t of Object.keys(e.contents))r.push(t);return r},symlink(e,r,t){var n=D.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!o.isLink(e.mode))throw new o.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,a){var s=e.node.contents;if(a>=e.node.usedBytes)return 0;var u=Math.min(e.node.usedBytes-a,n);if(u>8&&s.subarray)r.set(s.subarray(a,a+u),t);else for(var c=0;c0||t+r{var a=n?"":`al ${e}`;z(e).then(s=>{r(new Uint8Array(s)),a&&me(a)},s=>{if(t)t();else throw`Loading data file "${e}" failed.`}),a&&ce(a)},at=(e,r,t,n,a,s)=>{o.createDataFile(e,r,t,n,a,s)},it=[],st=(e,r,t,n)=>{typeof Browser<"u"&&Browser.init();var a=!1;return it.forEach(s=>{a||s.canHandle(r)&&(s.handle(e,r,t,n),a=!0)}),a},ut=(e,r,t,n,a,s,u,c,v,E)=>{var G=r?he.resolve(C.join2(e,r)):e,x=`cp ${G}`;function B(y){function O(te){E?.(),c||at(e,r,te,n,a,v),s?.(),me(x)}st(y,G,O,()=>{u?.(),me(x)})||O(y)}ce(x),typeof t=="string"?nt(t,B,u):B(t)},pt=e=>{var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t},nr=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},o={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:class{constructor(e){this.name="ErrnoError",this.errno=e}},genericErrors:{},filesystems:null,syncFSRequests:0,FSStream:class{constructor(){this.shared={}}get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=o.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n,this.readMode=365,this.writeMode=146}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return o.isDir(this.mode)}get isDevice(){return o.isChrdev(this.mode)}},lookupPath(e,r={}){if(e=he.resolve(e),!e)return{path:"",node:null};var t={follow_mount:!0,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new o.ErrnoError(32);for(var n=e.split("/").filter(x=>!!x),a=o.root,s="/",u=0;u40)throw new o.ErrnoError(32)}}return{path:s,node:a}},getPath(e){for(var r;;){if(o.isRoot(e)){var t=e.mount.mountpoint;return r?t[t.length-1]!=="/"?`${t}/${r}`:t+r:t}r=r?`${e.name}/${r}`:e.name,e=e.parent}},hashName(e,r){for(var t=0,n=0;n>>0)%o.nameTable.length},hashAddNode(e){var r=o.hashName(e.parent.id,e.name);e.name_next=o.nameTable[r],o.nameTable[r]=e},hashRemoveNode(e){var r=o.hashName(e.parent.id,e.name);if(o.nameTable[r]===e)o.nameTable[r]=e.name_next;else for(var t=o.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode(e,r){var t=o.mayLookup(e);if(t)throw new o.ErrnoError(t);for(var n=o.hashName(e.id,r),a=o.nameTable[n];a;a=a.name_next){var s=a.name;if(a.parent.id===e.id&&s===r)return a}return o.lookup(e,r)},createNode(e,r,t,n){var a=new o.FSNode(e,r,t,n);return o.hashAddNode(a),a},destroyNode(e){o.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)===32768},isDir(e){return(e&61440)===16384},isLink(e){return(e&61440)===40960},isChrdev(e){return(e&61440)===8192},isBlkdev(e){return(e&61440)===24576},isFIFO(e){return(e&61440)===4096},isSocket(e){return(e&49152)===49152},flagsToPermissionString(e){var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions(e,r){return o.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!o.isDir(e.mode))return 54;var r=o.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){try{var t=o.lookupNode(e,r);return 20}catch{}return o.nodePermissions(e,"wx")},mayDelete(e,r,t){var n;try{n=o.lookupNode(e,r)}catch(s){return s.errno}var a=o.nodePermissions(e,"wx");if(a)return a;if(t){if(!o.isDir(n.mode))return 54;if(o.isRoot(n)||o.getPath(n)===o.cwd())return 10}else if(o.isDir(n.mode))return 31;return 0},mayOpen(e,r){return e?o.isLink(e.mode)?32:o.isDir(e.mode)&&(o.flagsToPermissionString(r)!=="r"||r&512)?31:o.nodePermissions(e,o.flagsToPermissionString(r)):44},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=o.MAX_OPEN_FDS;e++)if(!o.streams[e])return e;throw new o.ErrnoError(33)},getStreamChecked(e){var r=o.getStream(e);if(!r)throw new o.ErrnoError(8);return r},getStream:e=>o.streams[e],createStream(e,r=-1){return e=Object.assign(new o.FSStream,e),r==-1&&(r=o.nextfd()),e.fd=r,o.streams[r]=e,e},closeStream(e){o.streams[e]=null},dupStream(e,r=-1){var t=o.createStream(e,r);return t.stream_ops?.dup?.(t),t},chrdev_stream_ops:{open(e){var r=o.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new o.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){o.devices[e]={stream_ops:r}},getDevice:e=>o.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push(...n.mounts)}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=!1),o.syncFSRequests++,o.syncFSRequests>1&&V(`warning: ${o.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=o.getMounts(o.root.mount),n=0;function a(u){return o.syncFSRequests--,r(u)}function s(u){if(u)return s.errored?void 0:(s.errored=!0,a(u));++n>=t.length&&a(null)}t.forEach(u=>{if(!u.type.syncfs)return s(null);u.type.syncfs(u,e,s)})},mount(e,r,t){var n=t==="/",a=!t,s;if(n&&o.root)throw new o.ErrnoError(10);if(!n&&!a){var u=o.lookupPath(t,{follow_mount:!1});if(t=u.path,s=u.node,o.isMountpoint(s))throw new o.ErrnoError(10);if(!o.isDir(s.mode))throw new o.ErrnoError(54)}var c={type:e,opts:r,mountpoint:t,mounts:[]},v=e.mount(c);return v.mount=c,c.root=v,n?o.root=v:s&&(s.mounted=c,s.mount&&s.mount.mounts.push(c)),v},unmount(e){var r=o.lookupPath(e,{follow_mount:!1});if(!o.isMountpoint(r.node))throw new o.ErrnoError(28);var t=r.node,n=t.mounted,a=o.getMounts(n);Object.keys(o.nameTable).forEach(u=>{for(var c=o.nameTable[u];c;){var v=c.name_next;a.includes(c.mount)&&o.destroyNode(c),c=v}}),t.mounted=null;var s=t.mount.mounts.indexOf(n);t.mount.mounts.splice(s,1)},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=o.lookupPath(e,{parent:!0}),a=n.node,s=C.basename(e);if(!s||s==="."||s==="..")throw new o.ErrnoError(28);var u=o.mayCreate(a,s);if(u)throw new o.ErrnoError(u);if(!a.node_ops.mknod)throw new o.ErrnoError(63);return a.node_ops.mknod(a,s,r,t)},create(e,r){return r=r!==void 0?r:438,r&=4095,r|=32768,o.mknod(e,r,0)},mkdir(e,r){return r=r!==void 0?r:511,r&=1023,r|=16384,o.mknod(e,r,0)},mkdirTree(e,r){for(var t=e.split("/"),n="",a=0;a"u"&&(t=r,r=438),r|=8192,o.mknod(e,r,t)},symlink(e,r){if(!he.resolve(e))throw new o.ErrnoError(44);var t=o.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new o.ErrnoError(44);var a=C.basename(r),s=o.mayCreate(n,a);if(s)throw new o.ErrnoError(s);if(!n.node_ops.symlink)throw new o.ErrnoError(63);return n.node_ops.symlink(n,a,e)},rename(e,r){var t=C.dirname(e),n=C.dirname(r),a=C.basename(e),s=C.basename(r),u,c,v;if(u=o.lookupPath(e,{parent:!0}),c=u.node,u=o.lookupPath(r,{parent:!0}),v=u.node,!c||!v)throw new o.ErrnoError(44);if(c.mount!==v.mount)throw new o.ErrnoError(75);var E=o.lookupNode(c,a),G=he.relative(e,n);if(G.charAt(0)!==".")throw new o.ErrnoError(28);if(G=he.relative(r,t),G.charAt(0)!==".")throw new o.ErrnoError(55);var x;try{x=o.lookupNode(v,s)}catch{}if(E!==x){var B=o.isDir(E.mode),y=o.mayDelete(c,a,B);if(y)throw new o.ErrnoError(y);if(y=x?o.mayDelete(v,s,B):o.mayCreate(v,s),y)throw new o.ErrnoError(y);if(!c.node_ops.rename)throw new o.ErrnoError(63);if(o.isMountpoint(E)||x&&o.isMountpoint(x))throw new o.ErrnoError(10);if(v!==c&&(y=o.nodePermissions(c,"w"),y))throw new o.ErrnoError(y);o.hashRemoveNode(E);try{c.node_ops.rename(E,v,s),E.parent=v}catch(O){throw O}finally{o.hashAddNode(E)}}},rmdir(e){var r=o.lookupPath(e,{parent:!0}),t=r.node,n=C.basename(e),a=o.lookupNode(t,n),s=o.mayDelete(t,n,!0);if(s)throw new o.ErrnoError(s);if(!t.node_ops.rmdir)throw new o.ErrnoError(63);if(o.isMountpoint(a))throw new o.ErrnoError(10);t.node_ops.rmdir(t,n),o.destroyNode(a)},readdir(e){var r=o.lookupPath(e,{follow:!0}),t=r.node;if(!t.node_ops.readdir)throw new o.ErrnoError(54);return t.node_ops.readdir(t)},unlink(e){var r=o.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new o.ErrnoError(44);var n=C.basename(e),a=o.lookupNode(t,n),s=o.mayDelete(t,n,!1);if(s)throw new o.ErrnoError(s);if(!t.node_ops.unlink)throw new o.ErrnoError(63);if(o.isMountpoint(a))throw new o.ErrnoError(10);t.node_ops.unlink(t,n),o.destroyNode(a)},readlink(e){var r=o.lookupPath(e),t=r.node;if(!t)throw new o.ErrnoError(44);if(!t.node_ops.readlink)throw new o.ErrnoError(28);return he.resolve(o.getPath(t.parent),t.node_ops.readlink(t))},stat(e,r){var t=o.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new o.ErrnoError(44);if(!n.node_ops.getattr)throw new o.ErrnoError(63);return n.node_ops.getattr(n)},lstat(e){return o.stat(e,!0)},chmod(e,r,t){var n;if(typeof e=="string"){var a=o.lookupPath(e,{follow:!t});n=a.node}else n=e;if(!n.node_ops.setattr)throw new o.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()})},lchmod(e,r){o.chmod(e,r,!0)},fchmod(e,r){var t=o.getStreamChecked(e);o.chmod(t.node,r)},chown(e,r,t,n){var a;if(typeof e=="string"){var s=o.lookupPath(e,{follow:!n});a=s.node}else a=e;if(!a.node_ops.setattr)throw new o.ErrnoError(63);a.node_ops.setattr(a,{timestamp:Date.now()})},lchown(e,r,t){o.chown(e,r,t,!0)},fchown(e,r,t){var n=o.getStreamChecked(e);o.chown(n.node,r,t)},truncate(e,r){if(r<0)throw new o.ErrnoError(28);var t;if(typeof e=="string"){var n=o.lookupPath(e,{follow:!0});t=n.node}else t=e;if(!t.node_ops.setattr)throw new o.ErrnoError(63);if(o.isDir(t.mode))throw new o.ErrnoError(31);if(!o.isFile(t.mode))throw new o.ErrnoError(28);var a=o.nodePermissions(t,"w");if(a)throw new o.ErrnoError(a);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate(e,r){var t=o.getStreamChecked(e);if(!(t.flags&2097155))throw new o.ErrnoError(28);o.truncate(t.node,r)},utime(e,r,t){var n=o.lookupPath(e,{follow:!0}),a=n.node;a.node_ops.setattr(a,{timestamp:Math.max(r,t)})},open(e,r,t){if(e==="")throw new o.ErrnoError(44);r=typeof r=="string"?pt(r):r,r&64?(t=typeof t>"u"?438:t,t=t&4095|32768):t=0;var n;if(typeof e=="object")n=e;else{e=C.normalize(e);try{var a=o.lookupPath(e,{follow:!(r&131072)});n=a.node}catch{}}var s=!1;if(r&64)if(n){if(r&128)throw new o.ErrnoError(20)}else n=o.mknod(e,t,0),s=!0;if(!n)throw new o.ErrnoError(44);if(o.isChrdev(n.mode)&&(r&=-513),r&65536&&!o.isDir(n.mode))throw new o.ErrnoError(54);if(!s){var u=o.mayOpen(n,r);if(u)throw new o.ErrnoError(u)}r&512&&!s&&o.truncate(n,0),r&=-131713;var c=o.createStream({node:n,path:o.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return c.stream_ops.open&&c.stream_ops.open(c),i.logReadFiles&&!(r&1)&&(o.readFiles||(o.readFiles={}),e in o.readFiles||(o.readFiles[e]=1)),c},close(e){if(o.isClosed(e))throw new o.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{o.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,r,t){if(o.isClosed(e))throw new o.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new o.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new o.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,n,a){if(n<0||a<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if((e.flags&2097155)===1)throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.read)throw new o.ErrnoError(28);var s=typeof a<"u";if(!s)a=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var u=e.stream_ops.read(e,r,t,n,a);return s||(e.position+=u),u},write(e,r,t,n,a,s){if(n<0||a<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if(!(e.flags&2097155))throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.write)throw new o.ErrnoError(28);e.seekable&&e.flags&1024&&o.llseek(e,0,2);var u=typeof a<"u";if(!u)a=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var c=e.stream_ops.write(e,r,t,n,a,s);return u||(e.position+=c),c},allocate(e,r,t){if(o.isClosed(e))throw new o.ErrnoError(8);if(r<0||t<=0)throw new o.ErrnoError(28);if(!(e.flags&2097155))throw new o.ErrnoError(8);if(!o.isFile(e.node.mode)&&!o.isDir(e.node.mode))throw new o.ErrnoError(43);if(!e.stream_ops.allocate)throw new o.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap(e,r,t,n,a){if(n&2&&!(a&2)&&(e.flags&2097155)!==2)throw new o.ErrnoError(2);if((e.flags&2097155)===1)throw new o.ErrnoError(2);if(!e.stream_ops.mmap)throw new o.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,a)},msync(e,r,t,n,a){return e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,a):0},ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new o.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){if(r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error(`Invalid encoding type "${r.encoding}"`);var t,n=o.open(e,r.flags),a=o.stat(e),s=a.size,u=new Uint8Array(s);return o.read(n,u,0,s,0),r.encoding==="utf8"?t=Fe(u,0):r.encoding==="binary"&&(t=u),o.close(n),t},writeFile(e,r,t={}){t.flags=t.flags||577;var n=o.open(e,t.flags,t.mode);if(typeof r=="string"){var a=new Uint8Array(rr(r)+1),s=tr(r,a,0,a.length);o.write(n,a,0,s,void 0,t.canOwn)}else if(ArrayBuffer.isView(r))o.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");o.close(n)},cwd:()=>o.currentPath,chdir(e){var r=o.lookupPath(e,{follow:!0});if(r.node===null)throw new o.ErrnoError(44);if(!o.isDir(r.node.mode))throw new o.ErrnoError(54);var t=o.nodePermissions(r.node,"x");if(t)throw new o.ErrnoError(t);o.currentPath=r.path},createDefaultDirectories(){o.mkdir("/tmp"),o.mkdir("/home"),o.mkdir("/home/web_user")},createDefaultDevices(){o.mkdir("/dev"),o.registerDevice(o.makedev(1,3),{read:()=>0,write:(n,a,s,u,c)=>u}),o.mkdev("/dev/null",o.makedev(1,3)),Me.register(o.makedev(5,0),Me.default_tty_ops),Me.register(o.makedev(6,0),Me.default_tty1_ops),o.mkdev("/dev/tty",o.makedev(5,0)),o.mkdev("/dev/tty1",o.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(r=gr(e).byteLength),e[--r]);o.createDevice("/dev","random",t),o.createDevice("/dev","urandom",t),o.mkdir("/dev/shm"),o.mkdir("/dev/shm/tmp")},createSpecialDirectories(){o.mkdir("/proc");var e=o.mkdir("/proc/self");o.mkdir("/proc/self/fd"),o.mount({mount(){var r=o.createNode(e,"fd",16895,73);return r.node_ops={lookup(t,n){var a=+n,s=o.getStreamChecked(a),u={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>s.path}};return u.parent=u,u}},r}},{},"/proc/self/fd")},createStandardStreams(){i.stdin?o.createDevice("/dev","stdin",i.stdin):o.symlink("/dev/tty","/dev/stdin"),i.stdout?o.createDevice("/dev","stdout",null,i.stdout):o.symlink("/dev/tty","/dev/stdout"),i.stderr?o.createDevice("/dev","stderr",null,i.stderr):o.symlink("/dev/tty1","/dev/stderr");var e=o.open("/dev/stdin",0),r=o.open("/dev/stdout",1),t=o.open("/dev/stderr",1)},staticInit(){[44].forEach(e=>{o.genericErrors[e]=new o.ErrnoError(e),o.genericErrors[e].stack=""}),o.nameTable=new Array(4096),o.mount(D,{},"/"),o.createDefaultDirectories(),o.createDefaultDevices(),o.createSpecialDirectories(),o.filesystems={MEMFS:D}},init(e,r,t){o.init.initialized=!0,i.stdin=e||i.stdin,i.stdout=r||i.stdout,i.stderr=t||i.stderr,o.createStandardStreams()},quit(){o.init.initialized=!1;for(var e=0;ethis.length-1||y<0)){var O=y%this.chunkSize,te=y/this.chunkSize|0;return this.getter(te)[O]}}setDataGetter(y){this.getter=y}cacheLength(){var y=new XMLHttpRequest;if(y.open("HEAD",t,!1),y.send(null),!(y.status>=200&&y.status<300||y.status===304))throw new Error("Couldn't load "+t+". Status: "+y.status);var O=Number(y.getResponseHeader("Content-length")),te,de=(te=y.getResponseHeader("Accept-Ranges"))&&te==="bytes",ne=(te=y.getResponseHeader("Content-Encoding"))&&te==="gzip",fe=1024*1024;de||(fe=O);var ve=(ge,xe)=>{if(ge>xe)throw new Error("invalid range ("+ge+", "+xe+") or no bytes requested!");if(xe>O-1)throw new Error("only "+O+" bytes available! programmer error!");var ee=new XMLHttpRequest;if(ee.open("GET",t,!1),O!==fe&&ee.setRequestHeader("Range","bytes="+ge+"-"+xe),ee.responseType="arraybuffer",ee.overrideMimeType&&ee.overrideMimeType("text/plain; charset=x-user-defined"),ee.send(null),!(ee.status>=200&&ee.status<300||ee.status===304))throw new Error("Couldn't load "+t+". Status: "+ee.status);return ee.response!==void 0?new Uint8Array(ee.response||[]):or(ee.responseText||"",!0)},Ie=this;Ie.setDataGetter(ge=>{var xe=ge*fe,ee=(ge+1)*fe-1;if(ee=Math.min(ee,O-1),typeof Ie.chunks[ge]>"u"&&(Ie.chunks[ge]=ve(xe,ee)),typeof Ie.chunks[ge]>"u")throw new Error("doXHR failed!");return Ie.chunks[ge]}),(ne||!O)&&(fe=O=1,O=this.getter(0).length,fe=O,X("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=O,this._chunkSize=fe,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest<"u"){if(!h)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var u=new s,c={isDevice:!1,contents:u}}else var c={isDevice:!1,url:t};var v=o.createFile(e,r,c,n,a);c.contents?v.contents=c.contents:c.url&&(v.contents=null,v.url=c.url),Object.defineProperties(v,{usedBytes:{get:function(){return this.contents.length}}});var E={},G=Object.keys(v.stream_ops);G.forEach(B=>{var y=v.stream_ops[B];E[B]=(...O)=>(o.forceLoadFile(v),y(...O))});function x(B,y,O,te,de){var ne=B.node.contents;if(de>=ne.length)return 0;var fe=Math.min(ne.length-de,te);if(ne.slice)for(var ve=0;ve(o.forceLoadFile(v),x(B,y,O,te,de)),E.mmap=(B,y,O,te,de)=>{o.forceLoadFile(v);var ne=yr(y);if(!ne)throw new o.ErrnoError(48);return x(B,w,ne,y,O),{ptr:ne,allocated:!0}},v.stream_ops=E,v}},ue=(e,r)=>e?Fe(j,e,r):"",U={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(C.isAbs(r))return r;var n;if(e===-100)n=o.cwd();else{var a=U.getStreamFromFD(e);n=a.path}if(r.length==0){if(!t)throw new o.ErrnoError(44);return n}return C.join2(n,r)},doStat(e,r,t){var n=e(r);b[t>>2]=n.dev,b[t+4>>2]=n.mode,k[t+8>>2]=n.nlink,b[t+12>>2]=n.uid,b[t+16>>2]=n.gid,b[t+20>>2]=n.rdev,$=[n.size>>>0,(R=n.size,+Math.abs(R)>=1?R>0?+Math.floor(R/4294967296)>>>0:~~+Math.ceil((R-+(~~R>>>0))/4294967296)>>>0:0)],b[t+24>>2]=$[0],b[t+28>>2]=$[1],b[t+32>>2]=4096,b[t+36>>2]=n.blocks;var a=n.atime.getTime(),s=n.mtime.getTime(),u=n.ctime.getTime();return $=[Math.floor(a/1e3)>>>0,(R=Math.floor(a/1e3),+Math.abs(R)>=1?R>0?+Math.floor(R/4294967296)>>>0:~~+Math.ceil((R-+(~~R>>>0))/4294967296)>>>0:0)],b[t+40>>2]=$[0],b[t+44>>2]=$[1],k[t+48>>2]=a%1e3*1e3,$=[Math.floor(s/1e3)>>>0,(R=Math.floor(s/1e3),+Math.abs(R)>=1?R>0?+Math.floor(R/4294967296)>>>0:~~+Math.ceil((R-+(~~R>>>0))/4294967296)>>>0:0)],b[t+56>>2]=$[0],b[t+60>>2]=$[1],k[t+64>>2]=s%1e3*1e3,$=[Math.floor(u/1e3)>>>0,(R=Math.floor(u/1e3),+Math.abs(R)>=1?R>0?+Math.floor(R/4294967296)>>>0:~~+Math.ceil((R-+(~~R>>>0))/4294967296)>>>0:0)],b[t+72>>2]=$[0],b[t+76>>2]=$[1],k[t+80>>2]=u%1e3*1e3,$=[n.ino>>>0,(R=n.ino,+Math.abs(R)>=1?R>0?+Math.floor(R/4294967296)>>>0:~~+Math.ceil((R-+(~~R>>>0))/4294967296)>>>0:0)],b[t+88>>2]=$[0],b[t+92>>2]=$[1],0},doMsync(e,r,t,n,a){if(!o.isFile(r.node.mode))throw new o.ErrnoError(43);if(n&2)return 0;var s=j.slice(e,e+t);o.msync(r,s,a,t,n)},getStreamFromFD(e){var r=o.getStreamChecked(e);return r},varargs:void 0,getStr(e){var r=ue(e);return r}};function lt(e,r,t,n){try{if(r=U.getStr(r),r=U.calculateAt(e,r),t&-8)return-28;var a=o.lookupPath(r,{follow:!0}),s=a.node;if(!s)return-44;var u="";return t&4&&(u+="r"),t&2&&(u+="w"),t&1&&(u+="x"),u&&o.nodePermissions(s,u)?-2:0}catch(c){if(typeof o>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function Se(){var e=b[+U.varargs>>2];return U.varargs+=4,e}var Oe=Se;function ct(e,r,t){U.varargs=t;try{var n=U.getStreamFromFD(e);switch(r){case 0:{var a=Se();if(a<0)return-28;for(;o.streams[a];)a++;var s;return s=o.dupStream(n,a),s.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var a=Se();return n.flags|=a,0}case 12:{var a=Oe(),u=0;return W[a+u>>1]=2,0}case 13:case 14:return 0}return-28}catch(c){if(typeof o>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function dt(e,r){try{var t=U.getStreamFromFD(e);return U.doStat(o.stat,t.path,r)}catch(n){if(typeof o>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}function ft(e,r,t){U.varargs=t;try{var n=U.getStreamFromFD(e);switch(r){case 21509:return n.tty?0:-59;case 21505:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcgets){var a=n.tty.ops.ioctl_tcgets(n),s=Oe();b[s>>2]=a.c_iflag||0,b[s+4>>2]=a.c_oflag||0,b[s+8>>2]=a.c_cflag||0,b[s+12>>2]=a.c_lflag||0;for(var u=0;u<32;u++)w[s+u+17]=a.c_cc[u]||0;return 0}return 0}case 21510:case 21511:case 21512:return n.tty?0:-59;case 21506:case 21507:case 21508:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcsets){for(var s=Oe(),c=b[s>>2],v=b[s+4>>2],E=b[s+8>>2],G=b[s+12>>2],x=[],u=0;u<32;u++)x.push(w[s+u+17]);return n.tty.ops.ioctl_tcsets(n.tty,r,{c_iflag:c,c_oflag:v,c_cflag:E,c_lflag:G,c_cc:x})}return 0}case 21519:{if(!n.tty)return-59;var s=Oe();return b[s>>2]=0,0}case 21520:return n.tty?-28:-59;case 21531:{var s=Oe();return o.ioctl(n,r,s)}case 21523:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tiocgwinsz){var B=n.tty.ops.ioctl_tiocgwinsz(n.tty),s=Oe();W[s>>1]=B[0],W[s+2>>1]=B[1]}return 0}case 21524:return n.tty?0:-59;case 21515:return n.tty?0:-59;default:return-28}}catch(y){if(typeof o>"u"||y.name!=="ErrnoError")throw y;return-y.errno}}function vt(e,r,t,n){try{r=U.getStr(r);var a=n&256,s=n&4096;return n=n&-6401,r=U.calculateAt(e,r,s),U.doStat(a?o.lstat:o.stat,r,t)}catch(u){if(typeof o>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}function mt(e,r,t,n){U.varargs=n;try{r=U.getStr(r),r=U.calculateAt(e,r);var a=n?Se():0;return o.open(r,t,a).fd}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}var Ke=(e,r,t)=>tr(e,j,r,t);function _t(e,r,t,n){try{if(r=U.getStr(r),r=U.calculateAt(e,r),n<=0)return-28;var a=o.readlink(r),s=Math.min(n,rr(a)),u=w[t+s];return Ke(a,t,n+1),w[t+s]=u,s}catch(c){if(typeof o>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function gt(e){try{return e=U.getStr(e),o.rmdir(e),0}catch(r){if(typeof o>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function ht(e,r){try{return e=U.getStr(e),U.doStat(o.stat,e,r)}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}function wt(e,r,t){try{return r=U.getStr(r),r=U.calculateAt(e,r),t===0?o.unlink(r):t===512?o.rmdir(r):_e("Invalid flags passed to unlinkat"),0}catch(n){if(typeof o>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}var yt=()=>{_e("")},bt=1,Et=()=>bt,Mt=(e,r,t)=>j.copyWithin(e,r,r+t),ar=(e,r)=>r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN;function Dt(e,r,t,n,a,s,u,c){var v=ar(a,s);try{if(isNaN(v))return 61;var E=U.getStreamFromFD(n),G=o.mmap(E,e,v,r,t),x=G.ptr;return b[u>>2]=G.allocated,k[c>>2]=x,0}catch(B){if(typeof o>"u"||B.name!=="ErrnoError")throw B;return-B.errno}}function Xt(e,r,t,n,a,s,u){var c=ar(s,u);try{var v=U.getStreamFromFD(a);t&2&&U.doMsync(e,v,r,n,c)}catch(E){if(typeof o>"u"||E.name!=="ErrnoError")throw E;return-E.errno}}var Lt=(e,r,t,n)=>{var a=new Date().getFullYear(),s=new Date(a,0,1),u=new Date(a,6,1),c=s.getTimezoneOffset(),v=u.getTimezoneOffset(),E=Math.max(c,v);k[e>>2]=E*60,b[r>>2]=+(c!=v);var G=y=>{var O=y>=0?"-":"+",te=Math.abs(y),de=String(Math.floor(te/60)).padStart(2,"0"),ne=String(te%60).padStart(2,"0");return`UTC${O}${de}${ne}`},x=G(c),B=G(v);v{ir.length=0;for(var t;t=j[e++];){var n=t!=105;n&=t!=112,r+=n&&r%8?4:0,ir.push(t==112?k[r>>2]:t==105?b[r>>2]:oe[r>>3]),r+=n?8:4}return ir},Rt=(e,r,t)=>{var n=Bt(r,t);return qr[e](...n)},kt=(e,r,t)=>Rt(e,r,t),Gt=()=>Date.now(),Ft;Ft=()=>performance.now();var Ot=()=>2147483648,xt=e=>{var r=S.buffer,t=(e-r.byteLength+65535)/65536;try{return S.grow(t),K(),1}catch{}},Ut=e=>{var r=j.length;e>>>=0;var t=Ot();if(e>t)return!1;for(var n=(v,E)=>v+(E-v%E)%E,a=1;a<=4;a*=2){var s=r*(1+.2/a);s=Math.min(s,e+100663296);var u=Math.min(t,n(Math.max(e,s),65536)),c=xt(u);if(c)return!0}return!1},sr={},Nt=()=>I||"./this.program",Ce=()=>{if(!Ce.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Nt()};for(var t in sr)sr[t]===void 0?delete r[t]:r[t]=sr[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Ce.strings=n}return Ce.strings},Vt=(e,r)=>{for(var t=0;t{var t=0;return Ce().forEach((n,a)=>{var s=r+t;k[e+a*4>>2]=s,Vt(n,s),t+=n.length+1}),0},Ct=(e,r)=>{var t=Ce();k[e>>2]=t.length;var n=0;return t.forEach(a=>n+=a.length+1),k[r>>2]=n,0},It=0,Zt=()=>It>0,Yt=e=>{ae=e,Zt()||(P=!0),Q(e,new $r(e))},zt=(e,r)=>{ae=e,Yt(e)},jt=zt;function Pt(e){try{var r=U.getStreamFromFD(e);return o.close(r),0}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var Jt=(e,r,t,n)=>{for(var a=0,s=0;s>2],c=k[r+4>>2];r+=8;var v=o.read(e,w,u,c,n);if(v<0)return-1;if(a+=v,v>2]=s,0}catch(u){if(typeof o>"u"||u.name!=="ErrnoError")throw u;return u.errno}}function Ht(e,r,t,n,a){var s=ar(r,t);try{if(isNaN(s))return 61;var u=U.getStreamFromFD(e);return o.llseek(u,s,n),$=[u.position>>>0,(R=u.position,+Math.abs(R)>=1?R>0?+Math.floor(R/4294967296)>>>0:~~+Math.ceil((R-+(~~R>>>0))/4294967296)>>>0:0)],b[a>>2]=$[0],b[a+4>>2]=$[1],u.getdents&&s===0&&n===0&&(u.getdents=null),0}catch(c){if(typeof o>"u"||c.name!=="ErrnoError")throw c;return c.errno}}var Tt=(e,r,t,n)=>{for(var a=0,s=0;s>2],c=k[r+4>>2];r+=8;var v=o.write(e,w,u,c,n);if(v<0)return-1;a+=v,typeof n<"u"&&(n+=v)}return a};function Qt(e,r,t,n){try{var a=U.getStreamFromFD(e),s=Tt(a,r,t);return k[n>>2]=s,0}catch(u){if(typeof o>"u"||u.name!=="ErrnoError")throw u;return u.errno}}o.createPreloadedFile=ut,o.staticInit();var qt={a:et,k:lt,h:ct,y:dt,z:ft,w:vt,d:mt,r:_t,s:gt,x:ht,t:wt,l:yt,i:Et,j:Mt,m:Dt,n:Xt,p:Lt,A:kt,b:Gt,q:Ut,u:Kt,v:Ct,e:jt,c:Pt,f:St,o:Ht,g:Qt},N=Qr(),$t=()=>($t=N.C)(),Wt=i._webidl_free=e=>(Wt=i._webidl_free=N.D)(e),At=i._free=e=>(At=i._free=N.E)(e),eo=i._webidl_malloc=e=>(eo=i._webidl_malloc=N.F)(e),ro=i._malloc=e=>(ro=i._malloc=N.G)(e),br=i._emscripten_bind_VoidPtr___destroy___0=e=>(br=i._emscripten_bind_VoidPtr___destroy___0=N.H)(e),Er=i._emscripten_bind_Graphviz_Graphviz_2=(e,r)=>(Er=i._emscripten_bind_Graphviz_Graphviz_2=N.I)(e,r),Mr=i._emscripten_bind_Graphviz_version_0=()=>(Mr=i._emscripten_bind_Graphviz_version_0=N.J)(),Dr=i._emscripten_bind_Graphviz_lastError_0=()=>(Dr=i._emscripten_bind_Graphviz_lastError_0=N.K)(),Xr=i._emscripten_bind_Graphviz_createFile_2=(e,r,t)=>(Xr=i._emscripten_bind_Graphviz_createFile_2=N.L)(e,r,t),Lr=i._emscripten_bind_Graphviz_layout_3=(e,r,t,n)=>(Lr=i._emscripten_bind_Graphviz_layout_3=N.M)(e,r,t,n),Br=i._emscripten_bind_Graphviz_acyclic_3=(e,r,t,n)=>(Br=i._emscripten_bind_Graphviz_acyclic_3=N.N)(e,r,t,n),Rr=i._emscripten_bind_Graphviz_tred_3=(e,r,t,n)=>(Rr=i._emscripten_bind_Graphviz_tred_3=N.O)(e,r,t,n),kr=i._emscripten_bind_Graphviz_unflatten_4=(e,r,t,n,a)=>(kr=i._emscripten_bind_Graphviz_unflatten_4=N.P)(e,r,t,n,a),Gr=i._emscripten_bind_Graphviz_get_layout_result_0=e=>(Gr=i._emscripten_bind_Graphviz_get_layout_result_0=N.Q)(e),Fr=i._emscripten_bind_Graphviz_set_layout_result_1=(e,r)=>(Fr=i._emscripten_bind_Graphviz_set_layout_result_1=N.R)(e,r),Or=i._emscripten_bind_Graphviz_get_acyclic_outFile_0=e=>(Or=i._emscripten_bind_Graphviz_get_acyclic_outFile_0=N.S)(e),xr=i._emscripten_bind_Graphviz_set_acyclic_outFile_1=(e,r)=>(xr=i._emscripten_bind_Graphviz_set_acyclic_outFile_1=N.T)(e,r),Ur=i._emscripten_bind_Graphviz_get_acyclic_num_rev_0=e=>(Ur=i._emscripten_bind_Graphviz_get_acyclic_num_rev_0=N.U)(e),Nr=i._emscripten_bind_Graphviz_set_acyclic_num_rev_1=(e,r)=>(Nr=i._emscripten_bind_Graphviz_set_acyclic_num_rev_1=N.V)(e,r),Vr=i._emscripten_bind_Graphviz_get_tred_out_0=e=>(Vr=i._emscripten_bind_Graphviz_get_tred_out_0=N.W)(e),Kr=i._emscripten_bind_Graphviz_set_tred_out_1=(e,r)=>(Kr=i._emscripten_bind_Graphviz_set_tred_out_1=N.X)(e,r),Cr=i._emscripten_bind_Graphviz_get_tred_err_0=e=>(Cr=i._emscripten_bind_Graphviz_get_tred_err_0=N.Y)(e),Ir=i._emscripten_bind_Graphviz_set_tred_err_1=(e,r)=>(Ir=i._emscripten_bind_Graphviz_set_tred_err_1=N.Z)(e,r),Zr=i._emscripten_bind_Graphviz___destroy___0=e=>(Zr=i._emscripten_bind_Graphviz___destroy___0=N._)(e),Yr=(e,r)=>(Yr=N.aa)(e,r),zr=e=>(zr=N.ba)(e);i.UTF8ToString=ue;var He;be=function e(){He||jr(),He||(be=e)};function jr(){if(ye>0||(Re(),ye>0))return;function e(){He||(He=!0,i.calledRun=!0,!P&&(Ne(),f(i),Pe()))}e()}jr();function pe(){}pe.prototype=Object.create(pe.prototype),pe.prototype.constructor=pe,pe.prototype.__class__=pe,pe.__cache__={},i.WrapperObject=pe;function Te(e){return(e||pe).__cache__}i.getCache=Te;function ur(e,r){var t=Te(r),n=t[e];return n||(n=Object.create((r||pe).prototype),n.ptr=e,t[e]=n)}i.wrapPointer=ur;function to(e,r){return ur(e.ptr,r)}i.castObject=to,i.NULL=ur(0);function oo(e){if(!e.__destroy__)throw"Error: Cannot destroy object. (Did you create it yourself?)";e.__destroy__(),delete Te(e.__class__)[e.ptr]}i.destroy=oo;function no(e,r){return e.ptr===r.ptr}i.compare=no;function ao(e){return e.ptr}i.getPointer=ao;function io(e){return e.__class__}i.getClass=io;var F={buffer:0,size:0,pos:0,temps:[],needed:0,prepare(){if(F.needed){for(var e=0;e=F.size?(J(n>0),F.needed+=n,a=i._webidl_malloc(n),F.temps.push(a)):(a=F.buffer+F.pos,F.pos+=n),a},copy(e,r,t){t/=r.BYTES_PER_ELEMENT;for(var n=0;n?@[]^_`{|}~"';function xo(p){let l=p.length,d=[],i=0,f=0,m=-1;for(let _=0;_88?13:14;do d.push(i&255),i>>=8,f-=8;while(f>7);m=-1}}return m>-1&&d.push((i|m< - -`}}function Co(p){return p.map(Ko)}function Io(p,l){let d={images:[],files:[],...l};[...d.files,...Co(d.images)].forEach(i=>p.createFile(i.path,i.data))}var Zo=class Ue{constructor(l){this._module=l}static load(){return No().then(l=>new Ue(l))}static unload(){Vo()}version(){return this._module.Graphviz.prototype.version()}layout(l,d="svg",i="dot",f){if(!l)return"";let m=new this._module.Graphviz(f?.yInvert?1:0,f?.nop?f?.nop:0),_="",h="";try{Io(m,f);try{_=m.layout(l,d,i)}catch(M){h=M.message}h=m.lastError()||h}finally{this._module.destroy(m)}if(!_&&h)throw Ue.unload(),new Error(h);return _}acyclic(l,d=!1,i=!1){if(!l)return{acyclic:!1,num_rev:0,outFile:""};let f=new this._module.Graphviz,m=!1,_=0,h="",M="";try{try{m=f.acyclic(l,d,i),_=f.acyclic_num_rev,h=f.acyclic_outFile}catch(I){M=I.message}M=f.lastError()||M}finally{this._module.destroy(f)}if(M)throw Ue.unload(),new Error(M);return{acyclic:m,num_rev:_,outFile:h}}tred(l,d=!1,i=!1){if(!l)return{out:"",err:""};let f=new this._module.Graphviz,m="",_="",h="";try{try{f.tred(l,d,i),m=f.tred_out,_=f.tred_err}catch(M){h=M.message}h=f.lastError()||h}finally{this._module.destroy(f)}if(!m&&h)throw Ue.unload(),new Error(h);return{out:m,err:_}}unflatten(l,d=0,i=!1,f=0){if(!l)return"";let m=new this._module.Graphviz,_="",h="";try{try{_=m.unflatten(l,d,i,f)}catch(M){h=M.message}h=m.lastError()||h}finally{this._module.destroy(m)}if(!_&&h)throw Ue.unload(),new Error(h);return _}circo(l,d="svg",i){return this.layout(l,d,"circo",i)}dot(l,d="svg",i){return this.layout(l,d,"dot",i)}fdp(l,d="svg",i){return this.layout(l,d,"fdp",i)}sfdp(l,d="svg",i){return this.layout(l,d,"sfdp",i)}neato(l,d="svg",i){return this.layout(l,d,"neato",i)}osage(l,d="svg",i){return this.layout(l,d,"osage",i)}patchwork(l,d="svg",i){return this.layout(l,d,"patchwork",i)}twopi(l,d="svg",i){return this.layout(l,d,"twopi",i)}nop(l){return this.layout(l,"dot","nop")}nop2(l){return this.layout(l,"dot","nop2")}}; - -if(__exports != exports)module.exports = exports;return module.exports})); -//# sourceMappingURL=graphviz.umd.js.map diff --git a/graph/web/viewer.js b/graph/web/viewer.js index ed14651f..c36c369c 100644 --- a/graph/web/viewer.js +++ b/graph/web/viewer.js @@ -79,20 +79,13 @@ async function render(index) { const frameGeneration = generation; rendering = true; const frame = frames[index]; - busy = frame.snap && !frame.layout ? "Laying out frame " + (index + 1) + "..." : "Drawing..."; + busy = !frame.layout ? "Laying out frame " + (index + 1) + "..." : "Drawing..."; updateUI(); if (frame.pos >= 0) program.setSelectionRange(frame.pos, frame.pos + 1); try { - document.getElementById("elk").hidden = !frame.snap; - document.getElementById("dot").hidden = !!frame.snap; - if (frame.snap) { - if (!layout) layout = new GraphLayout(); - if (!frame.layout) frame.layout = await layout.run(frame.snap); - if (generation === frameGeneration) renderer.show(frame.snap, frame.layout, frame.evt); - } else { - document.getElementById("detail").hidden = true; - await drawDot(frame.dot); - } + if (!layout) layout = new GraphLayout(); + if (!frame.layout) frame.layout = await layout.run(frame.snap); + if (generation === frameGeneration) renderer.show(frame.snap, frame.layout, frame.evt); rendering = false; busy = ""; if (generation === frameGeneration) current = index; @@ -117,8 +110,8 @@ program.addEventListener("keydown", event => { }); document.getElementById("compile").addEventListener("click", get_program); document.getElementById("fit").addEventListener("click", () => { - if (frames[current]?.snap) { renderer.auto = true; renderer.fit(); } - else render(current); + renderer.auto = true; + renderer.fit(); }); document.getElementById("assocs").addEventListener("change", event => renderer.assocs(event.target.checked)); document.getElementById("near").addEventListener("change", () => renderer.mark()); @@ -143,22 +136,16 @@ try { done = true; compiling = false; updateUI(); - } else if (message.startsWith("{") || message.startsWith("digraph")) { + } else if (message.startsWith("{")) { let frame; try { - if (message.startsWith("{")) { - frame = JSON.parse(message); - if (frame.error) { - failure = "Compile error: " + frame.error; - updateUI(); - return; - } - if (frame.snap.ver !== 1) throw new Error("Unsupported graph version: " + frame.snap.ver); - } else { - // Earlier chapters still send bare DOT. - const pos = message.match(/\/\/ POS:\s*(\d+)/); - frame = {dot: message, pos: pos ? Number(pos[1]) : -1}; + frame = JSON.parse(message); + if (frame.error) { + failure = "Compile error: " + frame.error; + updateUI(); + return; } + if (frame.snap.ver !== 1) throw new Error("Unsupported graph version: " + frame.snap.ver); } catch (error) { reportError(error); return; @@ -181,9 +168,6 @@ try { updateUI(); }; - window.addEventListener("resize", () => { - if (current >= 0 && !frames[current].snap) render(current); - }); } catch (error) { reportError(error); } -- cgit v1.2.3