@hardikg/mdview 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +2 -2
- package/bin/mdview.mjs +60 -26
- package/dist/client/assets/2DXBBFLN-BxPqHNSN.js +5 -0
- package/dist/client/assets/46IJ22JX-u_jvQJNg.js +2 -0
- package/dist/client/assets/4TTDE5I4-BgbNAVNj.js +3 -0
- package/dist/client/assets/4UF3HTLV-DNbPxlOE.js +2 -0
- package/dist/client/assets/5THPTBWS-D57irc_4.js +1 -0
- package/dist/client/assets/7WLXJQOR-CHhKreq0.js +1 -0
- package/dist/client/assets/AAXQQPKT-CsAJqrOC.js +5 -0
- package/dist/client/assets/AKE5O7KZ-MSuBOjCG.js +2 -0
- package/dist/client/assets/BNMLP6AG-Ca3zyKQY.js +3 -0
- package/dist/client/assets/DKTLEL5E-B7ILCVTH.js +1 -0
- package/dist/client/assets/DR6PKOQU-Bw7cHvYp.js +2 -0
- package/dist/client/assets/E4RJ7UJB-CYB5C4K7.js +2 -0
- package/dist/client/assets/ELSXBIJH-DG0MW5dC.js +1 -0
- package/dist/client/assets/ERTIBQVS-BMWumWfk.js +2 -0
- package/dist/client/assets/F653G4FO-FI8M9Mc0.js +12 -0
- package/dist/client/assets/FKCDD66M-BPFkyrwI.js +1 -0
- package/dist/client/assets/FP7KDXVC-BLEBNkCO.js +2 -0
- package/dist/client/assets/FT5I3RHX-j5YoMicq.js +6 -0
- package/dist/client/assets/FTXIJQGB-nrHdCfp7.js +1 -0
- package/dist/client/assets/G3MDBVQH-EkdejvdW.js +1 -0
- package/dist/client/assets/GY35JXOZ-3ovTGxgz.js +2 -0
- package/dist/client/assets/H5EEJPP2-CNVQBEB3.js +1 -0
- package/dist/client/assets/HWDLEDTA-C_JcdBMO.js +1 -0
- package/dist/client/assets/JZWSX6AR-OwVPptYv.js +1 -0
- package/dist/client/assets/KQOEJWJY-DKTXya68.js +2 -0
- package/dist/client/assets/KS3BB3KE-QkpqVdmA.js +1 -0
- package/dist/client/assets/KXJRRZHI-BQRjeGWj.js +2 -0
- package/dist/client/assets/MFVI5XKI-DrRaRE9X.js +1 -0
- package/dist/client/assets/MWY2J62P-AbEgJnzK.js +12 -0
- package/dist/client/assets/MXGNCBL2-DG3CZR8g.js +2 -0
- package/dist/client/assets/N6DAJLIZ-BsZQKTyT.js +3 -0
- package/dist/client/assets/NU5M23IW-CvtpIovv.js +2 -0
- package/dist/client/assets/NV4XNBIS-nS8wAx3h.js +8 -0
- package/dist/client/assets/OGLU4SIR-DoTUWhkz.js +2 -0
- package/dist/client/assets/OUNS5N76-BwVLonT4.js +8 -0
- package/dist/client/assets/PU4ISKXV-BYX7eA_r.js +2 -0
- package/dist/client/assets/PUZGS23X-n6IKOr7S.js +1 -0
- package/dist/client/assets/Q3IYVLG5-hWt1rVyh.js +4 -0
- package/dist/client/assets/QYHQDLKZ-CjGeJM7R.js +4 -0
- package/dist/client/assets/RVARI57O-CXmrUIiS.js +1 -0
- package/dist/client/assets/RZSVICHU-BiwjruZZ.js +4 -0
- package/dist/client/assets/UEXXS2NB-Dkz_tz-N.js +2 -0
- package/dist/client/assets/UHTQJXKL-lvl-7QeT.js +5 -0
- package/dist/client/assets/URA2L2QI-B8pYKxOk.js +1 -0
- package/dist/client/assets/UXCHDUKG-BGy3ZRLM.js +2 -0
- package/dist/client/assets/VKNV3BUX-DZnoX4IV.js +5 -0
- package/dist/client/assets/VMV7XPHP-6QkisQwm.js +4 -0
- package/dist/client/assets/WEVWDWVA-nohBBhTA.js +2 -0
- package/dist/client/assets/XRRJ35LF-BE7gSN1k.js +2 -0
- package/dist/client/assets/YFKBLVVN-CVTPpei6.js +6 -0
- package/dist/client/assets/YHRE5QGZ-Bs7dUKjj.js +4 -0
- package/dist/client/assets/ZF3OVT4B-6LaC6iLs.js +3 -0
- package/dist/client/assets/index-392ivruk.js +2 -0
- package/dist/client/assets/{index-BP_8buXC.css → index-CGQuEJ_w.css} +1 -1
- package/dist/client/assets/lazy-CKqR1774.js +43 -0
- package/dist/client/index.html +2 -2
- package/package.json +4 -3
- package/dist/client/assets/abnfDiagram-VCTEODGH-BJQEGN-7.js +0 -1
- package/dist/client/assets/arc-C6Oi4WlG.js +0 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CvFdvi3K.js +0 -36
- package/dist/client/assets/blockDiagram-NRAW4CY4-D8P8a3XW.js +0 -129
- package/dist/client/assets/c4Diagram-UCG6FXSJ-WcmmjfHX.js +0 -38
- package/dist/client/assets/channel-UA4WTF8Q.js +0 -1
- package/dist/client/assets/chunk-2Q5K7J3B-LeZsbe9d.js +0 -1
- package/dist/client/assets/chunk-5VM5RSS4-COq9euGx.js +0 -15
- package/dist/client/assets/chunk-F27PBJKO-BxcjnaqW.js +0 -1
- package/dist/client/assets/chunk-G27WJ6UU-CscpPXiS.js +0 -231
- package/dist/client/assets/chunk-JWPE2WC7-DD0M0JL-.js +0 -1
- package/dist/client/assets/chunk-LCL6LL3I-DXhJ59Qq.js +0 -206
- package/dist/client/assets/chunk-POPQ4Y6H-Bj3eKHA8.js +0 -1
- package/dist/client/assets/chunk-SVP7TREG-CDQ9vZv1.js +0 -88
- package/dist/client/assets/chunk-XXDRQBXY-91VBn0TQ.js +0 -1
- package/dist/client/assets/classDiagram-DTDB5LWJ-Ch3MnxRH.js +0 -1
- package/dist/client/assets/classDiagram-v2-JRS7N3AN-Ch3MnxRH.js +0 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-BaQN6N6K.js +0 -1
- package/dist/client/assets/cynefin-OW5HDTMX-DFpC3uqz.js +0 -178
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CSeSIxw6.js +0 -62
- package/dist/client/assets/cytoscape.esm-BjAbmLdb.js +0 -331
- package/dist/client/assets/dagre-3AP2YEHR-BBkMnw1s.js +0 -4
- package/dist/client/assets/defaultLocale-DX6XiGOO.js +0 -1
- package/dist/client/assets/diagram-S7CK7UJ4-BRdjuShi.js +0 -30
- package/dist/client/assets/diagram-UQ7AKVKN-D-RaNNET.js +0 -41
- package/dist/client/assets/diagram-VSXAHHWV-eL5_j9pa.js +0 -3
- package/dist/client/assets/diagram-VX7I27RA-nlUjCwlX.js +0 -24
- package/dist/client/assets/diagram-Z3DM3KII-DvhXGz8M.js +0 -24
- package/dist/client/assets/ebnfDiagram-PWID7BFC-LgynLQ4Z.js +0 -1
- package/dist/client/assets/erDiagram-SSCWMZ5O-Bc2j9FRV.js +0 -99
- package/dist/client/assets/flowDiagram-A5DVABFB-ClpDS0y_.js +0 -168
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-_RmNHCQH.js +0 -292
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-F1UGJQ4d.js +0 -106
- package/dist/client/assets/index-DqIihcNP.js +0 -2
- package/dist/client/assets/infoDiagram-RXCK75RN-BR20W1yx.js +0 -2
- package/dist/client/assets/init-Gi6I4Gst.js +0 -1
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-D6bgpoOj.js +0 -70
- package/dist/client/assets/journeyDiagram-EYS64GPL-CBjB_0Bx.js +0 -139
- package/dist/client/assets/kanban-definition-3QL26DDD-Bz0HhYZd.js +0 -89
- package/dist/client/assets/layout-BmTy4KT7.js +0 -1
- package/dist/client/assets/linear-Cgk2Kw-d.js +0 -1
- package/dist/client/assets/mermaid.core-Dq2piIpp.js +0 -312
- package/dist/client/assets/mindmap-definition-FBJOCRG2-BSbZ3zKk.js +0 -96
- package/dist/client/assets/ordinal-Cboi1Yqb.js +0 -1
- package/dist/client/assets/pegDiagram-XKGWAZYB-BLsHBZ_O.js +0 -1
- package/dist/client/assets/pieDiagram-E7YTZNPT-BTtaojGC.js +0 -39
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-W-VPz1gZ.js +0 -7
- package/dist/client/assets/railroadDiagram-O6MQD6OU-CstXUJhE.js +0 -1
- package/dist/client/assets/requirementDiagram-EFPCY7ZU-DPpI_Lvd.js +0 -84
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-B3HiW1sY.js +0 -40
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-CfpZAY9b.js +0 -162
- package/dist/client/assets/sizeCapture-X5ZJPWSS-Dsdx6W_J.js +0 -1
- package/dist/client/assets/stateDiagram-HBIQ2CUA-DPm-o7Ee.js +0 -1
- package/dist/client/assets/stateDiagram-v2-4QOOHH4V-DDqXMzve.js +0 -1
- package/dist/client/assets/swimlanes-XN3QIQJK-BPdZeRls.js +0 -1
- package/dist/client/assets/swimlanesDiagram-VK2B7HYN-BHORPcrU.js +0 -8
- package/dist/client/assets/timeline-definition-24CTP7MA-1bs3iV0k.js +0 -120
- package/dist/client/assets/vennDiagram-4TSXK5OY-vYOlmqTL.js +0 -34
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-DTPUMRNL.js +0 -78
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-M5kqQyt7.js +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.10.0] — 2026-10-19
|
|
11
|
+
|
|
12
|
+
A security fix for front matter, and a lighter diagram renderer that follows
|
|
13
|
+
your palette. Upgrade if you open markdown you did not write: in 0.9.1 and
|
|
14
|
+
earlier, a file could run code on your machine.
|
|
15
|
+
|
|
16
|
+
### Security
|
|
17
|
+
- **Front matter is now parsed as YAML only.** Previously a file that began `---js` (or `---javascript`) had its front matter evaluated as JavaScript inside the server process when you opened it, so an untrusted `.md` file could run code on your machine. That path is gone.
|
|
18
|
+
- **YAML aliases can no longer expand a small front matter block into a huge response.** A few hundred bytes of nested aliases could produce hundreds of MB of JSON, or a cycle, and take the server down. The parsed front matter is now bounded at 10,000 nodes; a block over that is treated as plain text.
|
|
19
|
+
- **`gray-matter` is replaced by `js-yaml` 4.** This drops `js-yaml` 3, `argparse` 1 and `sprintf-js`, which `npm audit` flagged, so `npm audit --omit=dev` reports 0 vulnerabilities again.
|
|
20
|
+
- **`img-src` no longer allows `blob:`.** Only the old diagram output needed it.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- **Only a bare `---` line opens front matter.** A `---js`, `---json` or `---yaml` opening line is now body text. A front matter block that is a list or a single value is still removed from the page, but shows no metadata.
|
|
24
|
+
- **Mermaid diagrams now render with pele instead of the mermaid library.** The lazy diagram code drops from about 899 kB to about 287 kB gzipped across all chunks, and a page loads only the diagram types it uses. Diagrams follow the active palette and light/dark through CSS variables, with no re-render on a switch. Diagrams look different, because pele has its own layout and visual style. A left-to-right flowchart too wide for the text column now switches to a top-down layout at full text size, where it used to shrink to fit.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
- **External-link marking no longer breaks on SVG links.** An inline SVG anchor has read-only `target` and `rel` properties, so assigning them threw and stopped the marking of every later link. SVG anchors are now skipped.
|
|
28
|
+
|
|
10
29
|
## [0.9.1] — 2026-10-04
|
|
11
30
|
|
|
12
31
|
A file tree that keeps deep paths readable, and a dependency refresh.
|
package/README.md
CHANGED
|
@@ -186,7 +186,7 @@ Click the keyboard icon in the header anytime to see the full list.
|
|
|
186
186
|
**Rendering**
|
|
187
187
|
- CommonMark + GFM (tables, task lists, strikethrough, autolinks).
|
|
188
188
|
- Server-side syntax highlighting via Shiki, palette-aware: two variants per token, light and dark, for whichever palette is active. Zero client highlighter bundle, and the light/dark toggle repaints with no request.
|
|
189
|
-
- Mermaid diagrams, lazy-loaded only when a doc contains a `mermaid` fence.
|
|
189
|
+
- Mermaid diagrams, rendered with [pele](https://github.com/obsidianmd/pele) and lazy-loaded only when a doc contains a `mermaid` fence. Colours follow the active palette and light/dark.
|
|
190
190
|
- Math via KaTeX (`$inline$` and `$$block$$`), lazy-loaded only when a doc contains math.
|
|
191
191
|
- Custom-styled task list checkboxes (filled accent when checked, hollow when unchecked).
|
|
192
192
|
- Front matter detected and shown as a small collapsible metadata block.
|
|
@@ -240,7 +240,7 @@ mdview config ignore rm deps # remove one or more basenames
|
|
|
240
240
|
|
|
241
241
|
## Stack
|
|
242
242
|
|
|
243
|
-
Node 20+, TypeScript, Fastify 5, markdown-it 14, Shiki 1,
|
|
243
|
+
Node 20+, TypeScript, Fastify 5, markdown-it 14, Shiki 1, js-yaml 4, chokidar 4, Preact 10 + @preact/signals, KaTeX 0.16, pele (lazy), JetBrains Mono via @fontsource, Vite 6, tsup 8, vitest 2.
|
|
244
244
|
|
|
245
245
|
## Documentation
|
|
246
246
|
|
package/bin/mdview.mjs
CHANGED
|
@@ -880,40 +880,74 @@ function registerApiAsset(app, roots) {
|
|
|
880
880
|
import { readFile as readFile3, stat as stat2 } from "fs/promises";
|
|
881
881
|
|
|
882
882
|
// src/render/frontmatter.ts
|
|
883
|
-
import
|
|
883
|
+
import { load } from "js-yaml";
|
|
884
|
+
var MAX_NODES = 1e4;
|
|
885
|
+
function unparsed(raw) {
|
|
886
|
+
return { data: null, body: raw, bodyStartLine: 0 };
|
|
887
|
+
}
|
|
884
888
|
function parseFrontmatter(raw) {
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
889
|
+
const block = locateBlock(raw);
|
|
890
|
+
if (!block) return unparsed(raw);
|
|
891
|
+
let loaded;
|
|
888
892
|
try {
|
|
889
|
-
|
|
890
|
-
const body = parsed.content.replace(/^(?:\r?\n)+/, "");
|
|
891
|
-
const bodyStartLine = computeBodyStartLine(raw);
|
|
892
|
-
return {
|
|
893
|
-
data: parsed.data ?? null,
|
|
894
|
-
body,
|
|
895
|
-
bodyStartLine
|
|
896
|
-
};
|
|
893
|
+
loaded = load(block.yaml);
|
|
897
894
|
} catch {
|
|
898
|
-
return
|
|
895
|
+
return unparsed(raw);
|
|
899
896
|
}
|
|
897
|
+
if (!withinBudget(loaded)) return unparsed(raw);
|
|
898
|
+
return {
|
|
899
|
+
// An empty or comment-only block loads as `undefined`; it is still a
|
|
900
|
+
// front matter block with no keys.
|
|
901
|
+
data: loaded === void 0 ? {} : isPlainObject(loaded) ? loaded : null,
|
|
902
|
+
// CRLF-safe strip so the body and the bodyStartLine offset stay aligned for
|
|
903
|
+
// both LF- and CRLF-authored sources.
|
|
904
|
+
body: block.body.replace(/^(?:\r?\n)+/, ""),
|
|
905
|
+
bodyStartLine: block.bodyStartLine
|
|
906
|
+
};
|
|
900
907
|
}
|
|
901
|
-
function
|
|
902
|
-
const
|
|
903
|
-
|
|
908
|
+
function locateBlock(raw) {
|
|
909
|
+
const parts = raw.split(/(\r?\n)/);
|
|
910
|
+
const lineAt = (i) => parts[i * 2];
|
|
911
|
+
const lineCount = Math.ceil(parts.length / 2);
|
|
912
|
+
if (lineAt(0) !== "---") return null;
|
|
904
913
|
let closingIdx = -1;
|
|
905
|
-
for (let i = 1; i <
|
|
906
|
-
if (
|
|
914
|
+
for (let i = 1; i < lineCount; i++) {
|
|
915
|
+
if (lineAt(i) === "---") {
|
|
907
916
|
closingIdx = i;
|
|
908
917
|
break;
|
|
909
918
|
}
|
|
910
919
|
}
|
|
911
|
-
if (closingIdx < 0) return
|
|
912
|
-
let
|
|
913
|
-
while (
|
|
914
|
-
|
|
920
|
+
if (closingIdx < 0) return null;
|
|
921
|
+
let bodyStartLine = closingIdx + 1;
|
|
922
|
+
while (bodyStartLine < lineCount && lineAt(bodyStartLine) === "") {
|
|
923
|
+
bodyStartLine++;
|
|
915
924
|
}
|
|
916
|
-
|
|
925
|
+
const yaml = [];
|
|
926
|
+
for (let i = 1; i < closingIdx; i++) yaml.push(lineAt(i) ?? "");
|
|
927
|
+
return {
|
|
928
|
+
yaml: yaml.join("\n"),
|
|
929
|
+
body: parts.slice((closingIdx + 1) * 2).join(""),
|
|
930
|
+
bodyStartLine
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
function withinBudget(root) {
|
|
934
|
+
const stack = [root];
|
|
935
|
+
let visited = 0;
|
|
936
|
+
while (stack.length > 0) {
|
|
937
|
+
const node = stack.pop();
|
|
938
|
+
if (++visited > MAX_NODES) return false;
|
|
939
|
+
if (Array.isArray(node)) {
|
|
940
|
+
for (const child of node) stack.push(child);
|
|
941
|
+
} else if (isPlainObject(node)) {
|
|
942
|
+
for (const child of Object.values(node)) stack.push(child);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
return true;
|
|
946
|
+
}
|
|
947
|
+
function isPlainObject(value) {
|
|
948
|
+
if (typeof value !== "object" || value === null) return false;
|
|
949
|
+
const proto = Object.getPrototypeOf(value);
|
|
950
|
+
return proto === Object.prototype || proto === null;
|
|
917
951
|
}
|
|
918
952
|
|
|
919
953
|
// src/render/links.ts
|
|
@@ -1675,10 +1709,10 @@ function buildCspHtml(embedMode) {
|
|
|
1675
1709
|
const directives = [
|
|
1676
1710
|
"default-src 'self'",
|
|
1677
1711
|
"script-src 'self'",
|
|
1678
|
-
// KaTeX
|
|
1679
|
-
// the policy is strict.
|
|
1712
|
+
// KaTeX and the diagram renderer set inline style attributes on their
|
|
1713
|
+
// output; the rest of the policy is strict.
|
|
1680
1714
|
"style-src 'self' 'unsafe-inline'",
|
|
1681
|
-
"img-src 'self' data:
|
|
1715
|
+
"img-src 'self' data:",
|
|
1682
1716
|
"font-src 'self' data:",
|
|
1683
1717
|
"connect-src 'self'",
|
|
1684
1718
|
"base-uri 'none'",
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var ct=Object.defineProperty;var pt=(e,t,n)=>t in e?ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var D=(e,t,n)=>pt(e,typeof t!="symbol"?t+"":t,n);import{p as ut,h as ft}from"./DKTLEL5E-B7ILCVTH.js";import{x as dt,D as ht,Y as $t,z as mt,U as xt,H as gt,G as yt,O as bt,P as kt}from"./VMV7XPHP-6QkisQwm.js";import{_ as Et,y as Ie,x as l,b as J,f as wt,$ as vt,p as Mt,a as Ge}from"./RZSVICHU-BiwjruZZ.js";import{x as At,H as Rt,$ as _t}from"./lazy-CKqR1774.js";import"./index-392ivruk.js";function Xe(e){return e===32||e>=9&&e<=13||e>127&&/\s/.test(String.fromCharCode(e))}function Pt(){let e=1/0;return(t,n)=>{if(!t.startsWith("accDescr",n))return-1;let r=t.length,a=n+8;for(;a<r&&(t.charCodeAt(a)===32||t.charCodeAt(a)===9);)a++;if(t.charCodeAt(a)===58){for(a++;a<r;a++){let i=t.charCodeAt(a);if(i===10||i===13||i===37&&t.charCodeAt(a+1)===37)break}return a}for(;a<r&&Xe(t.charCodeAt(a));)a++;if(t.charCodeAt(a)!==123||a>=e)return-1;let o=t.indexOf("}",a+1);return o===-1&&(e=a),o+1||-1}}var je="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",le={name:"TITLE",pattern:/title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:"t"},oe={name:"ACC_TITLE",pattern:/accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:"a"},se={name:"ACC_DESCR",pattern:/accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:"a",scanner:Pt};function s(e,t){return{name:e,pattern:e,longer:t}}function ce(e,t){return{...gt(e),longer:[t]}}function Re(e){return{name:e,pattern:/[A-Z_a-z][\w-]*/y,first:je+"_"}}function _e(e){return{name:e,pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`}}function pe(e){return[{name:e+"_WHITESPACE",pattern:/[\t \r\n]+/y,hidden:!0,first:` \r
|
|
2
|
+
`},{...yt,name:e+"_YAML",first:"-"},{...bt,name:e+"_DIRECTIVE",first:" %"},{...kt,name:e+"_SINGLE_LINE_COMMENT",first:" %"}]}function j(e){if(!e.includes("\\"))return e.slice(1,-1);let t=e.length-1,n="";for(let r=1;r<t;r++){let a=e[r];a==="\\"&&r+1<t?(a=e[++r],n+=a==="n"?`
|
|
3
|
+
`:a==="r"?"\r":a==="t"?" ":a):n+=a}return n}function ue(e,t,n,r,a,o){let i=new dt(ht(e,t,"railroad"),t,"railroad"),p={$type:n,rules:[]};for(i.expect(0);;){let c=i.kind;if(c===r){let y=$t(i.take()),f=y[0];p.title=(f==='"'||f==="'")&&y.endsWith(f)?a(y):y}else if(c===r+1)p.accTitle=mt(i.take());else if(c===r+2)p.accDescr=xt(i.take());else break}for(;i.kind!==-1;)p.rules.push(o(i));return p}var Qe=[];function Me(e){let t=e,n=t.element??t.primary??t.suffix,r=t.alternatives??t.elements??(n?[n]:Qe);if(t.base){r=[t.base];for(let a of t.postfixes)a.except&&r.push(a.except)}return r}var ee=e=>({type:"terminal",value:e}),fe=e=>({type:"nonterminal",name:e}),ae=e=>({type:"special",text:e}),X=e=>({type:"optional",element:e}),te=(e,t,n=1/0)=>({type:"repetition",element:e,min:t,max:n});function de(e){return e.length===1?e[0]:{type:"sequence",elements:e}}function he(e){return e.length===1?e[0]:{type:"choice",alternatives:e}}function $e(e,t){return e.rules.map(n=>({name:n.name,definition:Je(n.definition,Me,t)}))}function Je(e,t,n){let r=[e],a=[t(e)],o=[[]];for(;;){let i=r.length-1,p=o[i];if(p.length<a[i].length){let c=a[i][p.length];r.push(c),a.push(t(c)),o.push([])}else{let c=n(r[i],p);if(i===0)return c;r.pop(),a.pop(),o.pop(),o[i-1].push(c)}}}var Fe="0123456789",Le={name:"ABNF_RULENAME",pattern:/[A-Za-z][A-Za-z0-9-]*/y,first:je},Be={name:"ABNF_COMMENT",pattern:/;[^\n\r]*/y,hidden:!0,first:";"},et=[ce("railroad-abnf-beta",Le),s("="),s(";",[Be]),s("/"),s("("),s(")"),s("["),s("]"),le,oe,se,Le,{name:"ABNF_STRING",pattern:/"[^"]*"/y,first:'"'},{name:"ABNF_NUMVAL",pattern:/%[xXdDbB][0-9A-Fa-f]+(?:-[0-9A-Fa-f]+|\.[0-9A-Fa-f]+)*/y,first:"%"},{name:"ABNF_REPEAT",pattern:/[0-9]*\*[0-9]*/y,first:Fe+"*"},{name:"ABNF_EXACT_REPEAT",pattern:/[0-9]+/y,first:Fe},...pe("ABNF"),Be];function ze(e,t,n,r){let a={$type:"AbnfConcatenation",elements:[]};return t.alternatives.push(a),{alternation:t,concatenation:a,node:e,close:n,repeat:r}}function Ct(e){let t=[],n=ze(void 0,{$type:"AbnfAlternation",alternatives:[]},-2,void 0);for(;;){let r=e.kind===14||e.kind===15?e.take():void 0,a,o=e.kind;switch(o){case 12:a={$type:"AbnfStringLiteral",value:e.take().slice(1,-1)};break;case 13:a={$type:"AbnfNumVal",value:e.take()};break;case 11:a={$type:"AbnfRuleName",name:e.take()};break;case 4:case 6:{e.i++;let i={$type:"AbnfAlternation",alternatives:[]};t.push(n),n=ze({$type:o===4?"AbnfGroup":"AbnfOptionalGroup",element:i},i,o+1,r);continue}default:e.fail("a string, a number, a name, or an opening bracket")}for(;;){n.concatenation.elements.push(r===void 0?{$type:"AbnfElement",primary:a}:{$type:"AbnfElement",repeat:r,primary:a});let i=e.kind;if(i===n.close){e.i++,a=n.node,r=n.repeat,n=t.pop();continue}if(i===3)e.i++,n.concatenation={$type:"AbnfConcatenation",elements:[]},n.alternation.alternatives.push(n.concatenation);else if(i!==12&&i!==13&&i!==11&&i!==4&&i!==6&&i!==14&&i!==15){if(t.length===0)return n.alternation;e.fail(`token of type '${et[n.close].name}'`)}break}}}function Nt(e){return ue(e,et,"RailroadAbnf",8,t=>t.slice(1,-1),t=>{let n=t.expect(11);t.expect(1);let r=Ct(t);return t.expect(2),{$type:"AbnfRule",name:n,definition:r}})}function Tt(e,t){switch(e.$type){case"AbnfAlternation":return he(t);case"AbnfConcatenation":return de(t);case"AbnfElement":{let n=e.repeat;if(!n)return t[0];let r=n.indexOf("*"),a=r===-1,o=r>0||a?parseInt(n,10):0,i=a?o:r<n.length-1?parseInt(n.slice(r+1),10):1/0;return o===0&&i===1?X(t[0]):te(t[0],o,i)}case"AbnfStringLiteral":case"AbnfNumVal":return ee(e.value);case"AbnfRuleName":return fe(e.name);case"AbnfGroup":return t[0];case"AbnfOptionalGroup":return X(t[0])}}var St=e=>$e(e,Tt);function Ot(e,t){if(e.charCodeAt(t)!==63)return-1;let n=!1;for(let r=t+1;r<e.length;r++){let a=e.charCodeAt(r);if(a===63)return n?r+1:-1;if(a===59)return-1;n||(n=!Xe(a))}return-1}var De=Re("EBNF_ID"),He={name:"EBNF_SPECIAL_SEQUENCE",pattern:/\?(?=[^?;]*[^?\s;][^?;]*\?)[^?;]*\?/y,first:"?",scanner:()=>Ot},Ve=pe("EBNF"),We={name:"EBNF_ISO_COMMENT",pattern:/\(\*[\s\S]*?\*\)/y,hidden:!0,first:"(",opener:/\(\*/y},tt=[ce("railroad-ebnf-beta",De),s("::="),s("="),s(";"),s("|"),s(","),s("(",[We]),s(")"),s("["),s("]"),s("{"),s("}"),s("?",[He]),s("*"),s("+"),s("-",[Ve[1]]),le,oe,se,De,_e("EBNF_STRING"),He,...Ve,{name:"EBNF_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y},We];function Ue(e,t,n,r){let a={$type:"EbnfSequence",elements:[]};return t.alternatives.push(a),{choice:t,sequence:a,term:void 0,node:e,close:n,except:r}}var qt=["EbnfGroup","EbnfOptional","EbnfRepetition"];function It(e){let t=[],n=Ue(void 0,{$type:"EbnfChoice",alternatives:[]},-2,!1),r=!1;for(;;){let a,o=e.kind;switch(o){case 20:a={$type:"EbnfTerminal",value:j(e.take())};break;case 19:a={$type:"EbnfNonTerminal",name:e.take()};break;case 21:a={$type:"EbnfSpecial",text:e.take().slice(1,-1).trim()};break;case 6:case 8:case 10:{e.i++;let i={$type:"EbnfChoice",alternatives:[]};t.push(n),n=Ue({$type:qt[o-6>>1],element:i},i,o+1,r),r=!1;continue}default:e.fail("a terminal, a name, or an opening bracket")}for(;;){r?(n.term.postfixes.push({$type:"EbnfExceptionPostfix",except:a}),r=!1):(n.term={$type:"EbnfTerm",base:a,postfixes:[]},n.sequence.elements.push(n.term));let i=n.term.postfixes;for(;;){let c=e.kind;if(c===12)i.push({$type:"EbnfOptionalPostfix",operator:e.take()});else if(c===13)i.push({$type:"EbnfZeroOrMorePostfix",operator:e.take()});else if(c===14)i.push({$type:"EbnfOneOrMorePostfix",operator:e.take()});else break}let p=e.kind;if(p===n.close){e.i++,a=n.node,r=n.except,n=t.pop();continue}if(p===15)e.i++,r=!0;else if(p===5)e.i++;else if(p===4)e.i++,n.sequence={$type:"EbnfSequence",elements:[]},n.choice.alternatives.push(n.sequence);else if(p!==20&&p!==19&&p!==21&&p!==6&&p!==8&&p!==10){if(t.length===0)return n.choice;e.fail(`token of type '${tt[n.close].name}'`)}break}}}function Gt(e){return ue(e,tt,"RailroadEbnf",16,j,t=>{let n=t.expect(19);t.accept(2)||t.expect(1);let r={$type:"EbnfRule",name:n,definition:It(t)};return t.expect(3),r})}function Ft(e,t){switch(e.$type){case"EbnfChoice":return he(t);case"EbnfSequence":return de(t);case"EbnfTerm":{let n=t[0],r=1;for(let a of e.postfixes)a.$type==="EbnfOptionalPostfix"?n=X(n):a.$type==="EbnfExceptionPostfix"?n={type:"sequence",elements:[n,ee("-"),t[r++]]}:n=te(n,a.$type==="EbnfOneOrMorePostfix"?1:0);return n}case"EbnfTerminal":return ee(e.value);case"EbnfNonTerminal":return fe(e.name);case"EbnfSpecial":return ae(e.text);case"EbnfGroup":return t[0];case"EbnfOptional":return X(t[0]);case"EbnfRepetition":return te(t[0],0)}}var Lt=e=>$e(e,Ft),Ae=Re("RR_ID"),H=e=>s(e,[Ae]),Bt=[ce("railroad-beta",Ae),H("nonterminal"),H("zeroOrMore"),H("oneOrMore"),H("sequence"),H("optional"),H("terminal"),H("special"),H("choice"),s("="),s(";"),s("("),s(","),s(")"),le,oe,se,Ae,_e("RR_STRING"),...pe("RR"),{name:"RR_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y}];function ke(e){e.i++,e.expect(11);let t=j(e.expect(18));return e.expect(13),t}function Ee(e){return{$type:e,element:void 0}}function zt(e){let t=[];for(;;){let n;switch(e.kind){case 6:n={$type:"RailroadTerminalExpr",value:ke(e)};break;case 1:n={$type:"RailroadNonTerminalExpr",name:ke(e)};break;case 7:n={$type:"RailroadSpecialExpr",text:ke(e)};break;case 4:n={$type:"RailroadSequenceExpr",elements:[]};break;case 8:n={$type:"RailroadChoiceExpr",alternatives:[]};break;case 5:n=Ee("RailroadOptionalExpr");break;case 3:n=Ee("RailroadOneOrMoreExpr");break;case 2:n=Ee("RailroadZeroOrMoreExpr");break;default:e.fail("an expression")}if("elements"in n||"alternatives"in n||"element"in n){e.i++,e.expect(11),t.push(n);continue}for(;;){let r=t[t.length-1];if(r===void 0)return n;if("element"in r)r.element=n;else if(("elements"in r?r.elements:r.alternatives).push(n),e.accept(12))break;e.expect(13),t.pop(),n=r}}}function Dt(e){return ue(e,Bt,"Railroad",14,j,t=>{let n=t.expect(17);t.expect(9);let r=zt(t);return t.expect(10),{$type:"RailroadRule",name:n,definition:r}})}function Ht(e,t){switch(e.$type){case"RailroadTerminalExpr":return ee(e.value);case"RailroadNonTerminalExpr":return fe(e.name);case"RailroadSpecialExpr":return ae(e.text);case"RailroadSequenceExpr":return de(t);case"RailroadChoiceExpr":return he(t);case"RailroadOptionalExpr":return X(t[0]);default:return te(t[0],e.$type==="RailroadOneOrMoreExpr"?1:0)}}var Vt=e=>$e(e,Ht),Ze=Re("PEG_ID"),Wt=[ce("railroad-peg-beta",Ze),s("<-"),s(";"),s("/"),s("&"),s("!"),s("?"),s("*"),s("+"),s("("),s(")"),s("."),le,oe,se,Ze,_e("PEG_STRING"),...pe("PEG"),{name:"PEG_LINE_COMMENT",pattern:/#[^\n\r]*/y,hidden:!0,first:"#"}];function Ye(e,t,n){let r={$type:"PegSequence",elements:[]};return t.alternatives.push(r),{choice:t,sequence:r,node:e,operator:n}}function Ut(e){let t=[],n=Ye(void 0,{$type:"PegOrderedChoice",alternatives:[]},void 0);for(;;){let r=e.kind===4||e.kind===5?e.take():void 0,a;switch(e.kind){case 16:a={$type:"PegLiteral",value:j(e.take())};break;case 15:a={$type:"PegIdentifier",name:e.take()};break;case 11:a={$type:"PegAny",dot:e.take()};break;case 9:{e.i++;let o={$type:"PegOrderedChoice",alternatives:[]};t.push(n),n=Ye({$type:"PegGroup",element:o},o,r);continue}default:e.fail("a literal, a name, a dot, or an opening parenthesis")}for(;;){let o={$type:"PegSuffix",primary:a};(e.kind===6||e.kind===7||e.kind===8)&&(o.operator=e.take()),n.sequence.elements.push(r===void 0?{$type:"PegPrefix",suffix:o}:{$type:"PegPrefix",operator:r,suffix:o});let i=e.kind;if(i===10&&t.length>0){e.i++,a=n.node,r=n.operator,n=t.pop();continue}if(i===3)e.i++,n.sequence={$type:"PegSequence",elements:[]},n.choice.alternatives.push(n.sequence);else if(i!==4&&i!==5&&i!==16&&i!==15&&i!==11&&i!==9){if(t.length===0)return n.choice;e.fail("token of type ')'")}break}}}function Zt(e){return ue(e,Wt,"RailroadPeg",12,j,t=>{let n=t.expect(15);t.expect(1);let r={$type:"PegRule",name:n,definition:Ut(t)};return t.expect(2),r})}function Yt(e){switch(e.type){case"terminal":return`"${e.value}"`;case"nonterminal":return e.name;case"special":return e.text;default:return"(...)"}}function Kt(e,t){let n=t[0];switch(e.$type){case"PegOrderedChoice":return he(t);case"PegSequence":return de(t);case"PegPrefix":return e.operator?ae(e.operator+Yt(n)):n;case"PegSuffix":return e.operator?e.operator==="?"?X(n):te(n,e.operator==="+"?1:0):n;case"PegLiteral":return ee(e.value);case"PegIdentifier":return fe(e.name);case"PegAny":return ae(e.dot);case"PegGroup":return n}}var Xt=e=>$e(e,Kt),jt=class{constructor(){D(this,"type","railroad");D(this,"notation","railroad");D(this,"title");D(this,"accTitle");D(this,"accDescr");D(this,"rules",[]);D(this,"byName",new Map)}setTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
4
|
+
`)}addRule(e){this.rules.push(e),this.byName.set(e.name,e)}getRule(e){return this.byName.get(e)}},Qt=/^\s*railroad-(ebnf-|abnf-|peg-)?beta/i;function Jt(e){var r;let t=Qt.exec(e);if(t===null)return;let n=(r=t[1])==null?void 0:r.toLowerCase();return n==="ebnf-"?"ebnf":n==="abnf-"?"abnf":n==="peg-"?"peg":"railroad"}function en(e,t){switch(t){case"ebnf":{let n=Gt(e);return[n,Lt(n)]}case"abnf":{let n=Nt(e);return[n,St(n)]}case"peg":{let n=Zt(e);return[n,Xt(n)]}default:{let n=Dt(e);return[n,Vt(n)]}}}function tn(e,t,n){let[r,a]=en(t,n);e.notation=n,r.accDescr&&e.setAccDescription(r.accDescr),r.accTitle&&e.setAccTitle(r.accTitle),r.title&&e.setTitle(r.title);for(let o of a)e.addRule(o)}function nn(e,t){let n=Jt(e);if(n===void 0)throw new At("No railroad diagram keyword found.","syntax",{type:"railroad"});let r=new jt;return t&&(r.title=t),tn(r,e,n),r}var we=12,rn=6,an=18,ie=12,N=7;function U(e,t,n,r){var o;let a=(o=e.railroad)==null?void 0:o[t];return typeof a=="number"&&a>=0?Math.min(a,r):n}var ln=/[\n\r\t]/g;function re(e){return(e.includes("¶ß")?_t(e.replace(/&/g,"&")):e).replace(ln,t=>t===`
|
|
5
|
+
`?"\\n":t==="\r"?"\\r":"\\t")}function ne(e,t){for(let n=t,r=e.length-1;n<r;n++,r--){let a=e[n];e[n]=e[r],e[r]=a}}function Pe(e){return Math.ceil(e/2)*2}function ve(e,t,n,r,a){let o=a.height/2,i=Math.max(Pe(a.measurer.width(t,a.size,r)+2*a.padding),a.height);return{kind:e,width:i,up:o,down:o,kids:Qe,text:t,id:n,reach:0}}function on(e,t){if(t===1/0&&e<=1)return"";let n=r=>Number.isFinite(r)?String(r):"∞";return e===t?n(e)+"×":t===1/0?"≥"+n(e)+"×":e===0?"≤"+n(t)+"×":n(e)+"–"+n(t)+"×"}function nt(e,t,n,r){return Math.max(e+t.down+r.sep+n.up,2*r.arc)}function Ke(e,t){let n=Math.max(e.up+t.sep,2*t.arc);return{kind:5,width:e.width+4*t.arc,up:n,down:e.down,kids:[e],text:"",id:"",reach:n}}function sn(e,t,n=1/0){let r=new Map,a=[[e,n]];for(let o=0;n!==1/0&&o<a.length;o++){let[i,p]=a[o];r.set(i,p);let c=i.type==="choice"||i.type==="optional"?4*t.arc:i.type==="repetition"?(i.min===0?6:2)*t.arc:i.type==="sequence"?6*t.arc:0;for(let y of Me(i))a.push([y,Math.max(40,p-c)])}return Je(e,Me,(o,i)=>{let p=r.get(o)??1/0;switch(o.type){case"terminal":{let c=re(o.value);return ve(0,/^ +$/.test(c)?"␣".repeat(c.length):c,"",4,t)}case"nonterminal":return ve(1,re(o.name),o.name,0,t);case"special":return ve(2,"? "+re(o.text)+" ?","",2,t);case"sequence":{let c=Math.max(0,i.length-1)*t.gap,y=0,f=0;for(let x of i)c+=x.width,y=Math.max(y,x.up),f=Math.max(f,x.down);let $={kind:3,width:c,up:y,down:f,kids:i,text:"",id:"",reach:0};if(c<=p||i.length<2)return $;let w=[],A=[],k=0,d=()=>{let x=0,V=0;for(let Z of A)x=Math.max(x,Z.up),V=Math.max(V,Z.down);w.push({kind:3,width:k,up:x,down:V,kids:A,text:"",id:"",reach:0}),A=[],k=0};for(let x of i)A.length&&k+t.gap+x.width>Math.max(40,p-6*t.arc)&&d(),k+=(A.length?t.gap:0)+x.width,A.push(x);if(d(),w.length<2)return $;let L=0,q=0;for(let x=0;x<w.length;x++)L=Math.max(L,w[x].width),x&&(q+=w[x-1].down+Math.max(t.sep,2*t.arc)+w[x].up);return{kind:7,width:L+6*t.arc,up:w[0].up,down:q+w[w.length-1].down,kids:w,text:"",id:"",reach:0}}case"choice":{let c=0,y=0;for(let $=0;$<i.length;$++)c=Math.max(c,i[$].width),$>0&&(y=nt(y,i[$-1],i[$],t));let f=i[i.length-1];return{kind:4,width:c+4*t.arc,up:i.length>0?i[0].up:0,down:f?y+f.down:0,kids:i,text:"",id:"",reach:0}}case"optional":return Ke(i[0],t);case"repetition":{let{min:c,max:y}=o,f=i[0];if(c===1&&y===1)return f;let $=on(c,y),w=Math.max(f.down+t.sep,2*t.arc),A=$===""?0:Pe(t.measurer.width($,ie,0)),k={kind:6,width:Math.max(f.width,A)+2*t.arc,up:f.up,down:w+($===""?N/2+1:ie+6),kids:[f],text:$,id:"",reach:w};return c===0?Ke(k,t):k}}})}function cn(e,t,n){return ut(n,r=>pn(e,t,n,r))}function pn(e,t,n,r){var Oe;let a=n.fontSize??16,o=U(t,"fontSize",0,200),i=o||Math.round(a*.875),p=o||a,c=U(t,"padding",-1,200),y=Math.round(i*1.5),f={measurer:n.measurer??Rt(n.fontFamily,n.fontFamilyMono),size:i,padding:c<0?12:c,height:Pe(y+(c<0?9:2*c)),gap:Math.min(U(t,"horizontalSeparation",16,500),r?12:1/0),sep:U(t,"verticalSeparation",10,500),arc:Math.min(U(t,"arcRadius",10,200),r?6:1/0)},$=((Oe=t.railroad)==null?void 0:Oe.showMarkers)===!1?0:U(t,"markerRadius",4,50),w=U(t,"strokeWidth",0,20),A=w>0?` stroke-width="${l(w)}"`:"",k=n.padding??8,{arc:d}=f,L=l(d),q=(S,P,I)=>`a${L},${L} 0 0 ${S} ${P}${L},${I}${L}`,x=q(1,"",""),V=q(0,"",""),Z=q(0,"","-"),Ce=q(1,"","-"),rt=q(0,"-",""),at=q(0,"-","-"),Y=Et(e.title,!1,f.measurer,a,r?ft(n):4e3,1),it=Y.height>0?Y.height+16:0,Ne=Math.round(p*1.5),lt=i*.35,Te=f.height/2,B="",Q="",K="",T=(S,P,I)=>{I>S&&(B+=`M${l(S)},${l(P)}H${l(I)}`)},ot=(S,P,I)=>{let E=[S],_=[P,I];for(;E.length>0;){let g=E.pop(),u=_.pop(),b=_.pop(),R=g.kids,O=b+g.width;switch(g.kind){case 3:{let h=O;for(let m=R.length-1;m>=0;m--)h-=R[m].width,E.push(R[m]),_.push(h,u),m>0&&T(h-f.gap,u,h),h-=f.gap;break}case 7:{let h=b+2*d,m=E.length,M=0;T(b,u,h);for(let v=0;v<R.length;v++){let G=R[v],C=u+M;if(E.push(G),_.push(C,h),v+1<R.length){let W=R[v+1],z=M+G.down+Math.max(f.sep,2*d)+W.up,F=u+M+G.down+Math.max(f.sep,2*d)/2;B+=`M${l(h+G.width)},${l(C)}H${l(O-2*d)}V${l(F)}H${l(b+d)}V${l(u+z)}H${l(h)}`,Q+=`M${l(h-N)},${l(u+z-N/2)}l${N},${N/2}l${-N},${N/2}z`,M=z}else B+=`M${l(h+G.width)},${l(C)}H${l(O-d)}V${l(u)}H${l(O)}`}ne(E,m),ne(_,2*m);break}case 4:{let h=g.width-4*d,m=b+d,M=O-d,v=E.length,G=0;for(let C=0;C<R.length;C++){let W=R[C];C>0&&(G=nt(G,R[C-1],W,f));let z=u+G,F=b+2*d+(h-W.width)/2,qe=C===R.length-1;C===0?(T(b,u,F),T(F+W.width,u,O)):B+=(qe?`M${l(b)},${l(u)}${x}V${l(z-d)}`:`M${l(m)},${l(z-d)}`)+V+(F>m+d?`H${l(F)}`:"")+`M${l(F+W.width)},${l(z)}`+(F>m+d?`H${l(M-d)}`:"")+Z+(qe?`V${l(u+d)}${Ce}`:""),E.push(W),_.push(z,F)}ne(E,v),ne(_,2*v);break}case 5:{let h=R[0],m=b+2*d;T(b,u,m),T(m+h.width,u,O),B+=`M${l(b)},${l(u)}${Z}V${l(u-g.reach+d)}${Ce}H${l(O-2*d)}${x}V${l(u-d)}${V}`,E.push(h),_.push(m,u);break}case 6:{let h=R[0],m=b+(g.width-h.width)/2,M=u+g.reach,v=b+g.width/2;T(b,u,m),T(m+h.width,u,O),B+=`M${l(b+d)},${l(u)}${rt}V${l(M-d)}${V}H${l(O-d)}${Z}V${l(u+d)}${at}`,Q+=`M${l(v-N/2)},${l(M)}l${N},${-N/2}v${N}z`,g.text!==""&&(K+=`<text class="pele-edge-label pele-count" x="${l(v)}" y="${l(M+ie+3)}" font-size="${ie}" fill="var(--_m)">${J(g.text)}</text>`),E.push(h),_.push(m,u);break}default:{let h=g.text,m=h.startsWith(" ")||h.endsWith(" ")||h.includes(" ")?' xml:space="preserve"':"",M=`<rect x="${l(b)}" y="${l(u-Te)}" width="${l(g.width)}" height="${l(f.height)}"`,v=`<text x="${l(b+g.width/2)}" y="${l(u+lt)}"${m}`;g.kind===0?K+=`<g class="pele-node pele-terminal">${M} rx="${l(Te)}" fill="var(--_s)" stroke="var(--_b)"${A}/>${v} font-family="${Mt}">${J(h)}</text></g>`:g.kind===1?K+=`<g class="pele-node pele-nonterminal" data-id="${Ie(g.id)}">${M} rx="${Ge}" fill="var(--_bg)" stroke="var(--_b)"${A}/>${v}>${J(h)}</text></g>`:K+=`<g class="pele-node pele-special">${M} rx="${Ge}" fill="var(--_bg)" stroke="var(--_b)" stroke-dasharray="4 3"${A}/>${v} font-style="italic"><tspan fill="var(--_m)">? </tspan>${J(h.slice(2,-2))}<tspan fill="var(--_m)"> ?</tspan></text></g>`}}}},me="",xe=Y.width,ge=k+it,ye=k+Y.height;for(let S of e.rules){let P=sn(S.definition,f,r?Math.max(80,(n.maxWidth??320)-2*k-4*$-2*we-1):1/0),I=re(S.name),E=ge+Ne+rn+P.up,_=k+2*$,g=_+we,u=g+P.width+we;B="",Q="",K="",T(_,E,g),T(g+P.width,E,u),ot(P,g,E);let b=$>0?`<circle class="pele-marker pele-start" cx="${l(k+$)}" cy="${l(E)}" r="${l($)}" fill="var(--_l)"/><circle class="pele-marker pele-end" cx="${l(u+$)}" cy="${l(E)}" r="${l($)}" fill="var(--_l)"/>`:"";me+=`<g class="pele-rule" data-id="${Ie(S.name)}"><text class="pele-rule-name" x="${l(k)}" y="${l(ge+Ne/2+p*.35)}" font-size="${l(p)}" font-weight="var(--_hw)" text-anchor="start">${J(I)}</text><path class="pele-edge pele-track" d="${B}" fill="none" stroke="var(--_l)"${A}/>`+(Q?`<path class="pele-marker" d="${Q}" fill="var(--_l)"/>`:"")+b+K+"</g>",xe=Math.max(xe,u+2*$-k,f.measurer.width(I,p,1)),ye=E+P.down,ge=ye+f.sep+an}let be=Math.ceil(xe+2*k),Se=Math.ceil(ye+k),st=wt(Y,be/2,k+Y.height/2,' class="pele-title" font-weight="var(--_tw)"')+(me?`<g class="pele-rules" transform="translate(0.5,0.5)" font-size="${l(i)}" text-anchor="middle">${me}</g>`:"");return{svg:vt("railroad",be,Se,a,n,e,st),width:be,height:Se,links:[]}}var xn={type:"railroad",parse:(e,t,n)=>nn(e,n),render:cn};export{xn as railroad};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var qt=Object.defineProperty;var Vt=(t,a,s)=>a in t?qt(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s;var D=(t,a,s)=>Vt(t,typeof a!="symbol"?a+"":a,s);import{E as Qt,P as Gt,V as Ut}from"./URA2L2QI-B8pYKxOk.js";import{x as _t,L as Et,e as kt,i as nt,H as Jt}from"./lazy-CKqR1774.js";import{p as Zt,h as vt}from"./DKTLEL5E-B7ILCVTH.js";import{D as Dt,S as Xt,w as ft}from"./HWDLEDTA-C_JcdBMO.js";import{_ as rt,h as te,y as Lt,a as ee,x as A,f as Mt,$ as ae,g as Ot}from"./RZSVICHU-BiwjruZZ.js";import"./index-392ivruk.js";var Nt=1e5;function re(t){switch(t){case"[]":return"square";case"()":return"round";case"(())":return"circle";case">]":return"rect_left_inv_arrow";case"{}":return"diamond";case"{{}}":return"hexagon";case"([])":return"stadium";case"[[]]":return"subroutine";case"[()]":return"cylinder";case"((()))":return"doublecircle";case"[//]":return"lean_right";case"[\\\\]":return"lean_left";case"[/\\]":return"trapezoid";case"[\\/]":return"inv_trapezoid";case"<[]>":return"block_arrow";default:return"na"}}function se(t){switch(t.trim().slice(-1)){case"x":return"arrow_cross";case"o":return"arrow_circle";case">":return"arrow_point";default:return""}}function le(t){switch(t.trim().charAt(0)){case"x":return"arrow_cross";case"o":return"arrow_circle";case"<":return"arrow_point";default:return"arrow_open"}}function ie(t){return t.includes("==")?"thick":"normal"}function he(t){return t.includes(".-")?"dotted":"solid"}function Rt(t,a){let s=t.flat(),l=-1;for(let r of s)if(r.type==="column-setting"){l=r.columns??-1;break}return{list:s,at:0,parent:a,children:[],columns:l}}var ne=class{constructor(t={}){D(this,"type","block");D(this,"title");D(this,"root",{id:"root",type:"composite",children:[],columns:-1});D(this,"blocks",[]);D(this,"edges",[]);D(this,"classes",new Map);D(this,"byId",new Map);D(this,"typeStr2Type",re);D(this,"edgeStrToEdgeData",se);D(this,"edgeStrToEdgeStartData",le);D(this,"edgeStrToThickness",ie);D(this,"edgeStrToPattern",he);D(this,"warn");D(this,"pending",new Set);D(this,"edgeCount",new Map);D(this,"ids",0);D(this,"colors",0);D(this,"spaces",0);this.warn=t.warn}generateId(){return"id-"+ ++this.ids}addStyleClass(t,a=""){let s=this.classes.get(t);s||(s={id:t,styles:[],textStyles:[]},this.classes.set(t,s));for(let l of a.split(",")){let r=l.indexOf(";"),i=(r===-1?l:l.slice(0,r)+l.slice(r+1)).trim();l.includes("color")&&s.textStyles.push(i.replace("fill","bgFill").replace("color","fill")),s.styles.push(i)}}addStyle2Node(t,a=""){this.named(t).styles=a.split(",")}setCssClass(t,a){var s;for(let l of t.split(","))((s=this.named(l.trim())).classes??(s.classes=[])).push(a)}named(t){let a=this.byId.get(t);return a===void 0&&(a={id:t,type:"na",children:[]},this.byId.set(t,a),this.pending.add(t)),a}setHierarchy(t){var s;let a=[Rt(t,this.root)];for(;a.length>0;){let l=a[a.length-1];if(l.at===l.list.length){l.parent.children=l.children,a.pop();continue}let r=l.list[l.at++];switch(l.columns>0&&r.type!=="column-setting"&&typeof r.widthInColumns=="number"&&r.widthInColumns>l.columns&&((s=this.warn)==null||s.call(this,`Block ${r.id} width ${r.widthInColumns} exceeds configured column width ${l.columns}`)),r.type){case"classDef":this.addStyleClass(r.id,r.css);continue;case"applyClass":this.setCssClass(r.id,r.styleClass??"");continue;case"applyStyles":r.stylesStr&&this.addStyle2Node(r.id,r.stylesStr);continue;case"column-setting":l.parent.columns=r.columns??-1;continue;case"edge":{let g=(this.edgeCount.get(r.id)??0)+1;this.edgeCount.set(r.id,g),r.id=g+"-"+r.id,this.edges.push(r);continue}}r.id??(r.id=this.generateId()),r.label||(r.label=r.type==="composite"?"":r.id);let i=this.byId.get(r.id),h=i===void 0||this.pending.delete(r.id);h?(i&&(r.classes=i.classes,r.styles=i.styles),r.type==="composite"&&(r.colorIndex=this.colors++),this.byId.set(r.id,r)):(r.type!=="na"&&(i.type=r.type),r.label!==r.id&&(i.label=r.label));let e=r.children;if(r.children=[],r.type==="space"){let g=r.width??1;if(!(g<=Nt-this.spaces))throw new _t(`A block diagram can hold at most ${Nt} space blocks.`,"limit",{type:"block"});this.spaces+=Math.max(g,0);for(let u=0;u<g;u++){let d={...r,id:r.id+"-"+u,children:[]};this.byId.set(d.id,d),l.children.push(d)}}else h&&l.children.push(r);e&&e.length>0&&a.push(Rt(e,r))}this.blocks=this.root.children??[]}},Pt=["$end","INVALID","BLOCK_DIAGRAM_KEY","id-block","COLUMNS","MD_STR","STR","SPACE_BLOCK","DEFAULT","LINKSTYLE","INTERPOLATE","classDef","DEFAULT_CLASSDEF_ID","CLASSDEF_ID","CLASSDEF_STYLEOPTS","class","CLASSENTITY_IDS","STYLECLASS","style","STYLE_ENTITY_IDS","STYLE_DEFINITION_DATA","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","end","NODE_DSTART","NODE_DEND","BLOCK_ARROW_START","BLOCK_ARROW_END","DIR","NODE_ID","LINK","START_LINK","LINK_LABEL","SIZE","EOF"],ce=["right","left","x","y","up","down"],$t=new Uint8Array(128);for(let t of[9,10,11,12,13,32,40,41,45,58,60,61,62,91,123,125])$t[t]=1;function oe(t){let a=t.length,s=[],l=[],r=[],i=[],h=0,e=0,g=(b,o,n)=>(s.push(b),l.push(o),r.push(e),e=n,!0),u=(b,o)=>g(b,t.slice(e,o),o),d=b=>{i.push(h),h=b},f=()=>{i.length>0&&(h=i.pop())},c=b=>{for(;b<a&&kt(t.charCodeAt(b));)b++;return b},x=b=>{for(;b<a;){let o=t.charCodeAt(b);if(o<48||o>57)break;b++}return b},m=b=>{for(;b<a&&nt(t.charCodeAt(b));)b++;return b},k=b=>t.startsWith(b,e)&&!nt(t.charCodeAt(e+b.length)),I=()=>(t.charCodeAt(e+1)===96?(d(2),e+=2):(d(1),e++),!0),N=b=>{if(t.charCodeAt(b)!==46)return-1;do b++;while(t.charCodeAt(b)===46);if(t.charCodeAt(b)!==45)return-1;let o=t.charCodeAt(b+1);return o===120||o===111||o===62?b+2:b+1},T=b=>{let o=t.charCodeAt(b);(o===120||o===111||o===60)&&b++;let n=t.charCodeAt(b);if(n===46)return N(b);if(n!==45&&n!==61)return-1;let y=b+1;for(;t.charCodeAt(y)===n;)y++;if(y-b===1)return n===45?N(y):-1;let M=t.charCodeAt(y);return M===120||M===111||M===62?y+1:y-b>=3?y:-1},R=()=>{let b=T(e);if(b>=0)return u(33,c(b));let o=t.charCodeAt(e)===60?e+1:e,n=t.charCodeAt(o),y=t.charCodeAt(o+1);return n===45&&(y===45||y===46)||n===61&&y===61?(d(6),u(34,c(o+2))):!1},L=b=>{let o=t.indexOf(`
|
|
2
|
+
`,e);return o===-1&&(o=a),f(),u(b,o)},P=(b,o)=>{let n=m(e);if(n===e)return!1;for(;t.charCodeAt(n)===44;){let y=c(n+1),M=m(y);if(M===y)break;n=M}return h=o,u(b,n)},F=b=>{if(kt(b))return e=c(e+1),!0;let o;switch(b){case 98:if(t.startsWith("block",e)){if(k("block-beta"))return u(2,e+10);if(t.charCodeAt(e+5)===58)return u(3,e+6);if(!nt(t.charCodeAt(e+5)))return u(2,e+5)}break;case 99:if(t.startsWith("columns",e)){if(o=c(e+7),o>e+7){if(t.startsWith("auto",o)&&!nt(t.charCodeAt(o+4)))return g(4,"-1",o+4);let n=x(o);if(n>o)return g(4,t.slice(o,n),n)}}else if(t.startsWith("class",e)){let n=t.startsWith("Def",e+5),y=n?e+8:e+5;if(o=c(y),o>y)return d(n?7:9),u(n?11:15,o)}break;case 34:return I();case 115:if(t.startsWith("space",e)){if(t.charCodeAt(e+5)===58){let n=x(e+6);if(n>e+6)return g(7,t.slice(e+6,n),n)}if(!nt(t.charCodeAt(e+5)))return g(7,"1",e+5)}else if(t.startsWith("style",e)&&(o=c(e+5),o>e+5))return d(11),u(18,o);break;case 100:if(k("default"))return u(8,e+7);break;case 108:if(k("linkStyle"))return u(9,e+9);break;case 105:if(k("interpolate"))return u(10,e+11);break;case 97:if(t.startsWith("accTitle",e)){if(o=c(e+8),t.charCodeAt(o)===58)return d(13),u(21,c(o+1))}else if(t.startsWith("accDescr",e)){o=c(e+8);let n=t.charCodeAt(o);if(n===58)return d(14),u(23,c(o+1));if(n===123)return d(15),e=c(o+1),!0}break;case 101:if(k("end"))return u(26,c(e+3));break;case 45:return t.charCodeAt(e+1)===41?(d(3),u(27,e+2)):R();case 61:return R();case 60:return t.charCodeAt(e+1)===91?(d(4),u(29,e+2)):R();case 40:{let n=t.charCodeAt(e+1),y=n===45||n===91?2:n===40?t.charCodeAt(e+2)===40?3:2:1;return d(3),u(27,e+y)}case 41:case 123:return d(3),u(27,t.charCodeAt(e+1)===b?e+2:e+1);case 62:return d(3),u(27,e+1);case 91:{let n=t.charCodeAt(e+1);return d(3),u(27,n===91||n===124||n===40||n===92||n===47?e+2:e+1)}case 58:{let n=x(e+1);return n>e+1?g(36,t.slice(e+1,n),n):!1}}for(o=e;o<a;){let n=t.charCodeAt(o);if(n<128?$t[n]===1:kt(n))break;o++}return o>e&&u(32,o)},z=b=>{let o=t.charCodeAt(e+1),n=0;switch(b){case 34:return I();case 40:n=o===45?2:o===40?t.charCodeAt(e+2)===40?3:2:1;break;case 41:n=o===41?t.charCodeAt(e+2)===41?3:2:o===93?2:1;break;case 125:n=o===125?2:1;break;case 45:n=o===41?2:0;break;case 93:n=o===93||o===41||o===62?2:1;break;case 92:case 47:n=o===93?2:0;break}return n===0?!1:(f(),u(28,e+n))},q=b=>{if(b===41)return f(),f(),g(30,"]>",c(e+1));let o=c(b===44?e+1:e);for(let n of ce)if(t.startsWith(n,o)){let y=c(o+n.length);return g(31,t.slice(b===44?o:e,y),y)}return!1};for(;;){if(e>=a){let n=-1;switch(h){case 0:n=37;break;case 1:n=6;break;case 8:n=14;break;case 10:n=17;break;case 12:n=20;break;case 13:n=22;break;case 14:n=24;break;case 15:n=25;break}e=a,n!==-1&&g(n,"",a);break}let b=t.charCodeAt(e),o=!0;switch(h){case 0:o=F(b);break;case 1:if(b===34)f(),e++;else{let n=t.indexOf('"',e);u(6,n===-1?a:n)}break;case 2:if(b===96)o=t.charCodeAt(e+1)===34,o&&(f(),e+=2);else if(b===34)o=!1;else{let n=e+1;for(;n<a;){let y=t.charCodeAt(n);if(y===96||y===34)break;n++}u(5,n)}break;case 3:o=z(b);break;case 4:if(b===34)I();else if(b===93&&t.charCodeAt(e+1)===62){let n=c(e+2);o=t.charCodeAt(n)===40,o&&(d(5),e=n+1)}else o=!1;break;case 5:o=q(b);break;case 6:if(b===34)t.charCodeAt(e+1)===96?I():(u(35,e+1),d(1));else{let n=T(c(e));o=n>=0,o&&(f(),u(33,c(n)))}break;case 7:{let n=12,y=t.startsWith("DEFAULT",e)?e+7:e,M=c(y);(y===e||M===y)&&(n=13,y=m(e),M=c(y)),o=y>e&&M>y,o&&(h=8,u(n,M));break}case 8:L(14);break;case 9:o=P(16,10);break;case 10:L(17);break;case 11:o=P(19,12);break;case 12:L(20);break;case 13:L(22);break;case 14:L(24);break;case 15:if(b===125)f(),e++;else{let n=t.indexOf("}",e);u(25,n===-1?a:n)}break}if(!o)return s.push(1),l.push(""),r.push(e),{types:s,texts:l,starts:r}}return s.push(0),l.push(""),r.push(a),{types:s,texts:l,starts:r}}var ct="'NODE_ID', 'COLUMNS', 'SPACE_BLOCK', 'BLOCK_DIAGRAM_KEY', 'id-block', 'classDef', 'class', 'style'";function Kt(t){let a=t[t.length-1];return Array.isArray(a)?(t.pop(),t.concat(a)):t}function de(t,a){let{types:s,texts:l,starts:r}=oe(t),i=0,h=c=>{let x=s[i];throw x===1?Et("block",t,r[i],"",!0):Et("block",t,r[i],`Expecting ${c}, got '${Pt[x]}'`)},e=c=>(s[i]!==c&&h(`'${Pt[c]}'`),l[i++]),g=()=>{let c=e(32);if(s[i]===27){let x=l[i++],m=e(6);return{id:c,label:m,typeStr:x+e(28)}}if(s[i]===29){let x=l[i++],m=e(6),k=[e(31)];for(;s[i]===31;)k.push(l[i++]);return{id:c,label:m,typeStr:x+e(30),directions:k}}return{id:c}},u=()=>{let c=g(),x=s[i]===36?parseInt(l[i++],10):1,m={id:c.id,label:c.label,type:a.typeStr2Type(c.typeStr),directions:c.directions,widthInColumns:x},k;for(;s[i]===33||s[i]===34;){let I="";s[i++]===34&&(e(35),I=e(6),e(33));let N=l[i-1],T=g(),R=a.edgeStrToEdgeData(N),L=a.edgeStrToEdgeStartData(N),P=a.edgeStrToThickness(N),F=a.edgeStrToPattern(N);k??(k=[{id:m.id,label:m.label,type:m.type,directions:m.directions}]),m={id:T.id,label:T.label,type:a.typeStr2Type(T.typeStr),directions:T.directions},k.push({id:k[k.length-1].id+"-"+T.id,start:k[k.length-1].id,end:T.id,label:I,type:"edge",thickness:P,pattern:F,directions:T.directions,arrowTypeEnd:R,arrowTypeStart:L},m)}return k??m};e(2);let d=[],f=[];for(;;)switch(s[i]){case 32:f.push(u());break;case 4:f.push({type:"column-setting",columns:parseInt(l[i++],10)});break;case 7:{let c=parseInt(l[i++],10);f.push({id:a.generateId(),type:"space",label:"",width:c,children:[]});break}case 2:i++,d.push({list:f,header:void 0}),f=[];break;case 3:i++,s[i]!==32&&h("'NODE_ID'"),d.push({list:f,header:u()}),f=[];break;case 26:{let c=d.pop();if(c===void 0||f.length===0)return h(ct);i++;let x=a.generateId(),m=Kt(f);f=c.list,f.push(c.header===void 0?{id:x,type:"composite",label:"",children:m}:{...c.header,type:"composite",children:m});break}case 11:{i++;let c=e(13).trim();f.push({type:"classDef",id:c,css:e(14).trim()});break}case 15:{i++;let c=e(16).trim();f.push({type:"applyClass",id:c,styleClass:e(17).trim()});break}case 18:{i++;let c=e(19).trim();f.push({type:"applyStyles",id:c,stylesStr:e(20).trim()});break}case 37:d.length>0&&h(ct+", 'end'"),f.length===0&&h(ct),a.setHierarchy(Kt(f));return;default:h(f.length===0?ct:ct+(d.length>0?", 'end'":", 'EOF'"))}}var Q=1,G=2,J=4,Z=8,it=7,pt=20,et=12;function ue(t){let a=0;if(t)for(let s of t)switch(s.trim()){case"right":a|=Q;break;case"left":a|=G;break;case"up":a|=J;break;case"down":a|=Z;break;case"x":a|=Q|G;break;case"y":a|=J|Z;break}return a}var tt=(t,a)=>t&a?1:0;function bt(t){return t!==0&&(t&(J|Z))===0?"x":t!==0&&(t&(Q|G))===0?"y":""}function Wt(t,a,s){let l=bt(t),r=tt(t,G)-tt(t,Q),i=tt(t,J)-tt(t,Z);if(l==="x"){let h=Math.max(s+8,14)+2*it,e=Math.min(h/2,pt);return{w:Math.max(a+12,16)+e*(t===(Q|G)?2:1),h,dx:r*e/2,dy:0}}if(l==="y"){let h=Math.max(a+16,14)+2*it,e=Math.min(h/2,pt);return{w:h,h:Math.max(s+8,16)+e*(t===(J|Z)?2:1),dx:0,dy:i*e/2}}return{w:Math.max(a+16,24)+et*(tt(t,G)+tt(t,Q)),h:Math.max(s+8,24)+et*(tt(t,J)+tt(t,Z)),dx:r*et/2,dy:i*et/2}}function fe(t,a,s,l){let r=bt(t),i=a/2,h=s/2,e;if(r==="x"){let u=Math.min(h,pt),d=h-it,f=t&G?-i+u:-i,c=t&Q?i-u:i;e=[f,-d,c,-d],t&Q&&e.push(c,-h,i,0,c,h),e.push(c,d,f,d),t&G&&e.push(f,h,-i,0,f,-h)}else if(r==="y"){let u=Math.min(i,pt),d=i-it,f=t&J?-h+u:-h,c=t&Z?h-u:h;e=[d,f,d,c],t&Z&&e.push(i,c,0,h,-i,c),e.push(-d,c,-d,f),t&J&&e.push(-i,f,0,-h,i,f)}else{let u=t&G?-i+et:-i,d=t&Q?i-et:i,f=t&J?-h+et:-h,c=t&Z?h-et:h,x=(u+d)/2,m=(f+c)/2,k=Math.min(10,(d-u)/2),I=Math.min(10,(c-f)/2);e=[u,f],t&J&&e.push(x-k,f,x,-h,x+k,f),e.push(d,f),t&Q&&e.push(d,m-I,i,m,d,m+I),e.push(d,c),t&Z&&e.push(x+k,c,x,h,x-k,c),e.push(u,c),t&G&&e.push(u,m+I,-i,m,u,m-I)}let g="";for(let u=0;u<e.length;u+=2)g+=(u?" ":"")+A(e[u])+","+A(e[u+1]);return`<polygon points="${g}" stroke-linejoin="round"${l}/>`}var pe=1e3;function be(t,a){if(t===0||!Number.isInteger(t))throw new _t("Columns must be an integer !== 0.","semantic",{type:"block"});if(a<0||!Number.isInteger(a))throw new _t("Position must be a non-negative integer."+a,"semantic",{type:"block"});return t<0?{px:a,py:0}:{px:a%t,py:Math.floor(a/t)}}function ye(t,a,s){let l=t.columns,r=[],i=0,h=0,e=0,g=0;for(let d of t.children){let{px:f,py:c}=be(l,i),x=d.span>=1?Math.min(d.span,pe):1;if(l>0&&x>l-f&&(x=l-f),d.span=x,d.col=f,d.row=c,i+=x,f+x>h&&(h=f+x),c===r.length&&r.push(0),d.children.length===0?r[c]=-1:r[c]>=0&&d.nh>r[c]&&(r[c]=d.nh),d.space)continue;let m=(d.nw-a*(x-1))/x;m>e&&(e=m),d.nh>g&&(g=d.nh)}let u=(r.length-1)*a;for(let d=0;d<r.length;d++)r[d]<0&&(r[d]=g),u+=r[d];t.cols=h,t.heights=r,t.nw=Math.max(t.nw,h*e+(h-1)*a+2*s),t.nh=u+2*s+t.head}function ge(t,a,s){let{cols:l,heights:r}=t,i=r.length,h=(t.w-2*s-(l-1)*a)/l,e=t.h-2*s-t.head-(i-1)*a,g=0;for(let m of r)g+=m;let u=g>0?e/g:0,d=g>0?0:e/i,f=t.x-t.w/2+s,c=t.y-t.h/2+s+t.head,x=0;for(let m of t.children){for(;x<m.row;x++)c+=r[x]*u+d+a;m.w=h*m.span+a*(m.span-1),m.h=r[x]*u+d,m.x=f+m.col*(h+a)+m.w/2,m.y=c+m.h/2}}function we(t,a){let s=[t];for(let l=0;l<s.length;l++)for(let r of s[l].children)s.push(r);for(let l=s.length-1;l>=0;l--){let r=s[l];r.children.length>0&&ye(r,a,l===0?0:a)}t.w=t.nw,t.h=t.nh,t.x=t.w/2,t.y=t.h/2;for(let l=0;l<s.length;l++){let r=s[l];r.children.length>0&&ge(r,a,l===0?0:a)}return{width:t.w,height:t.h}}var me=12,Bt=200,xe=8,Ft=' fill="var(--_s)" stroke="var(--_b)"',ke=' stroke="var(--_b)"',Yt=[],Me=[],Se=[],_e=["default"],Ce=2e6,Ae=new Map([["square","rect"],["round","rounded"],["circle","circle"],["doublecircle","dbl-circ"],["diamond","diam"],["hexagon","hex"],["stadium","stadium"],["subroutine","fr-rect"],["cylinder","cyl"],["rect_left_inv_arrow","odd"],["lean_right","lean-r"],["lean_left","lean-l"],["trapezoid","trap-b"],["inv_trapezoid","trap-t"]]),Ie=new Set(["circle","dbl-circ","diam"]),Te=new Set(["stadium","hex","odd","lean-r","lean-l","trap-b","trap-t"]);function yt(t){return t.kind===0&&(t.shape==="circle"||t.shape==="dbl-circ")}function st(t,a,s){let l=t.bw/2,r=t.bh/2,i=Math.abs(a-t.x),h=r;return yt(t)?h=Math.sqrt(Math.max(l*l-i*i,0)):t.kind===0&&t.shape==="diam"?h=r*Math.max(1-i/l,0):t.kind===0?h=r-Ut(t.shape,t.bw,t.bh,s>0?2:0):t.kind===1&&bt(t.mask)==="x"&&(h=r-it),t.y+s*h}function lt(t,a,s){let l=t.bw/2,r=t.bh/2,i=Math.abs(a-t.y),h=l;return yt(t)?h=Math.sqrt(Math.max(r*r-i*i,0)):t.kind===0&&t.shape==="diam"?h=l*Math.max(1-i/r,0):t.kind===0?h=l-Ut(t.shape,t.bw,t.bh,s>0?1:3):t.kind===1&&bt(t.mask)==="y"&&(h=l-it),t.x+s*h}function zt(t,a,s,l){let r=a-t.x,i=s-t.y,h=t.bw/2,e=t.bh/2,g;yt(t)?g=h/(Math.hypot(r,i)||1):t.kind===0&&t.shape==="diam"?g=1/(Math.abs(r)/h+Math.abs(i)/e||1):g=Math.min(r===0?1/0:h/Math.abs(r),i===0?1/0:e/Math.abs(i)),g===1/0&&(g=0),l.push(t.x+r*g,t.y+i*g)}function Ee(t,a,s,l,r){let i=r.x-r.bw/2+1,h=r.x+r.bw/2-1,e=r.y-r.bh/2+1,g=r.y+r.bh/2-1;if(t<i&&s<i||t>h&&s>h||a<e&&l<e||a>g&&l>g)return!1;if(t===s||a===l)return!0;let u=s-t,d=l-a,f=(x,m)=>Math.sign(u*(m-a)-d*(x-t)),c=f(i,e);return c===0||f(h,e)!==c||f(h,g)!==c||f(i,g)!==c}function St(t,a,s,l){let r=0;for(let i of l)if(!(i===a||i===s)){for(let h=0;h+3<t.length;h+=2)if(Ee(t[h],t[h+1],t[h+2],t[h+3],i)){r++;break}}return r}function ve(t,a,s,l){let r=t.x-t.bw/2,i=t.x+t.bw/2,h=t.y-t.bh/2,e=t.y+t.bh/2,g=a.x-a.bw/2,u=a.x+a.bw/2,d=a.y-a.bh/2,f=a.y+a.bh/2,c=Math.max(r,g),x=Math.min(i,u),m=Math.max(h,d),k=Math.min(e,f),I=x-c>6,N=k-m>6;if(I&&N){let y=t.bw*t.bh<=a.bw*a.bh?t:a,M=y===t?a:t,U=y.y-y.bh/2-(M.y-M.bh/2),X=M.y+M.bh/2-(y.y+y.bh/2),ot=y.x-y.bw/2-(M.x-M.bw/2),ht=M.x+M.bw/2-(y.x+y.bw/2),at=Math.min(U,X,ot,ht),B;return at===X?B=[y.x,st(y,y.x,1),y.x,M.y+M.bh/2]:at===U?B=[y.x,st(y,y.x,-1),y.x,M.y-M.bh/2]:at===ht?B=[lt(y,y.y,1),y.y,M.x+M.bw/2,y.y]:B=[lt(y,y.y,-1),y.y,M.x-M.bw/2,y.y],y===t?B:[B[2],B[3],B[0],B[1]]}if(I){let y=Math.min(6,(x-c)/2),M=Math.min(Math.max((c+x)/2+s,c+y),x-y),U=a.y>t.y?1:-1;return[M,st(t,M,U),M,st(a,M,-U)]}if(N){let y=Math.min(6,(k-m)/2),M=Math.min(Math.max((m+k)/2+s,m+y),k-y),U=a.x>t.x?1:-1;return[lt(t,M,U),M,lt(a,M,-U),M]}let T=a.x>t.x?1:-1,R=a.y>t.y?1:-1,L=[lt(t,t.y,T),t.y,a.x,t.y,a.x,st(a,a.x,-R)],P=[t.x,st(t,t.x,R),t.x,a.y,lt(a,a.y,-T),a.y],F=Math.abs(a.x-t.x)>=Math.abs(a.y-t.y),z=F?L:P;if(l===void 0)return z;let q=St(z,t,a,l);if(q===0)return z;let b=F?P:L,o=St(b,t,a,l);if(o<q&&(z=b,q=o),q===0)return z;let n=[];return zt(t,a.x,a.y,n),zt(a,t.x,t.y,n),St(n,t,a,l)<q?n:z}function De(t,a,s){let l=t.length,r=t[0],i=t[1],h=t[l-2],e=t[l-1],g=t[2]-r,u=t[3]-i,d=Math.hypot(g,u);g/=d||1,u/=d||1;let f=h-t[l-4],c=e-t[l-3],x=Math.hypot(f,c);if(f/=x||1,c/=x||1,l===4&&a+s>d){let k=d/(a+s);a*=k,s*=k}a=Math.min(a,d),s=Math.min(s,x);let m=`M${A(r+g*a)},${A(i+u*a)}`;if(l===6){let k=Math.max(0,Math.min(xe,d-a,x-s));m+=`L${A(t[2]-g*k)},${A(t[3]-u*k)}Q${A(t[2])},${A(t[3])} ${A(t[2]+f*k)},${A(t[3]+c*k)}`}return m+=`L${A(h-f*s)},${A(e-c*s)}`,{d:m,sx:r,sy:i,sdx:-g,sdy:-u,ex:h,ey:e,edx:f,edy:c}}function Ht(t,a){let s=t.bw/2,l=t.bh/2,r=Math.max(1,Math.min(10+5*(a-1),s,l));if(yt(t)){let i=t.x+s*Math.SQRT1_2,h=t.y-s*Math.SQRT1_2,e=2*Math.asin(Math.min(1,r/(2*s))),g=u=>Math.atan2(t.y-s*Math.sin(u)-h,t.x+s*Math.cos(u)-i);return[i,h,r,g(Math.PI/4+e),g(Math.PI/4-e)]}if(t.kind===0&&t.shape==="diam"){let i=Math.atan2(l,s);return[t.x+s/2,t.y-l/2,r,i+Math.PI,i]}return[t.x+s,t.y-l,r,Math.PI,Math.PI/2]}function Le(t,a,s,l){let[r,i,h,e,g]=Ht(t,a),u=e+s/h,d=g-l/h,f=(d-u)%(2*Math.PI);f<=0&&(f+=2*Math.PI);let c=r+h*Math.cos(u),x=i+h*Math.sin(u),m=r+h*Math.cos(d),k=i+h*Math.sin(d),I=r+h*Math.cos(e),N=i+h*Math.sin(e),T=r+h*Math.cos(g),R=i+h*Math.sin(g),L=Math.hypot(I-c,N-x),P=Math.hypot(T-m,R-k);return{d:`M${A(c)},${A(x)}A${A(h)},${A(h)} 0 ${f>Math.PI?1:0} 1 ${A(m)},${A(k)}`,sx:I,sy:N,sdx:L>0?(I-c)/L:Math.sin(e),sdy:L>0?(N-x)/L:-Math.cos(e),ex:T,ey:R,edx:P>0?(T-m)/P:-Math.sin(g),edy:P>0?(R-k)/P:Math.cos(g)}}var Oe=[.5,.3,.7,.15,.85];function Ne(t,a,s,l,r,i,h){if(h===void 0)return .5;for(let e of Oe){let g=t[a]+(t[a+2]-t[a])*e,u=t[a+1]+(t[a+3]-t[a+1])*e,d=!0;for(let f of h)if(f!==r&&f!==i&&Math.abs(g-f.x)<(s+f.bw)/2&&Math.abs(u-f.y)<(l+f.bh)/2){d=!1;break}if(d)return e}return .5}function Re(t,a,s){return Zt(s,l=>Pe(t,a,s,l))}function Pe(t,a,s,l){var It;let r=s.fontSize??16,i=Math.round(r*.875),h=s.measurer??Jt(s.fontFamily),e=s.padding??8,g=s.icons,u=(It=a.block)==null?void 0:It.padding,d=Math.min(typeof u=="number"&&u>=0?Math.min(u,200):me,l?6:1/0),f=l?80:Bt,c=p=>{let w=[],S=C=>{for(let K of C)for(let O of K.split(";"))w.push(O)};for(let C of p.classes&&p.classes.length>0?p.classes:_e){let K=t.classes.get(C);K&&S(K.styles)}return p.styles&&S(p.styles),Ot(w)},x=(p,w)=>{let S=p.type,C=S==="space"?Ot(Yt):c(p),K=(C.bold?1:0)|(C.italic?2:0),O=C.fontSize??r,v=0,_="",E,W=0,$=0,Y=0,H=0,dt=0,j=0;if(S==="space")v=3,E=rt(void 0,!1,h,O,f);else if(S==="composite")v=2,E=rt(p.label,!1,h,O,l?vt(s):4e3,K),Y=E.height>0?E.height+4:0,W=E.width+2*d,$=Y+2*d;else if(S==="block_arrow"){v=1,E=rt(p.label,!1,h,O,f,K);let V=!0;for(let jt of E.lines)for(let Tt of jt)(Tt.icon!==void 0||Tt.text.trim()!=="")&&(V=!1);H=ue(p.directions);let ut=V?Wt(H,0,0):Wt(H,E.width,E.height);W=ut.w,$=ut.h,dt=ut.dx,j=ut.dy}else{_=Ae.get(S??"")??"rect",E=rt(p.label,!1,h,O,f,K);let V=Gt(_,E.width,E.height);W=V.w,$=_==="cyl"?Math.max(V.h,E.height+40):V.h,j=V.dy}return{children:[],columns:v===2?p.columns??-1:-1,span:v===3?1:p.widthInColumns??1,space:v===3,head:Y,nw:W,nh:$,col:0,row:0,cols:0,heights:Se,x:0,y:0,w:0,h:0,block:p,kind:v,index:w,shape:_,label:E,style:C,mask:H,dx:dt,dy:j,bw:0,bh:0}},m=x(t.root,0);m.nw=0,m.nh=0;let k=[m],I=new Map;for(let p=0;p<k.length;p++){let w=k[p];if(w.kind===2)for(let S of w.block.children??Me){let C=x(S,k.length);w.children.push(C),k.push(C),C.kind!==3&&I.set(S.id,C)}}let N=we(m,d),T=[];for(let p of k)p.kind===0&&Ie.has(p.shape)?(p.bw=p.nw,p.bh=p.nh):p.kind===1?(p.bw=p.span>1?p.w:p.nw,p.bh=p.nh):(p.bw=p.w,p.bh=p.kind===0&&Te.has(p.shape)?p.nh:p.h),p.kind===0&&p.shape==="cyl"&&(p.dy=Math.min(12,Math.max(6,p.bw/14))/2),(p.kind===0||p.kind===1)&&T.push(p);let R=new Map,L=new Set,P=[],F=[];for(let p of t.edges){let w=I.get(p.start??""),S=I.get(p.end??"");if(w===void 0||S===void 0)continue;let C=Math.min(w.index,S.index)*k.length+Math.max(w.index,S.index);R.set(C,(R.get(C)??0)+1),p.label&&L.add(C),P.push([w,S]),F.push(p)}let z=F.length*T.length<=Ce?T:void 0,q=new Map,b=[],o=0,n=0,y=N.width,M=N.height,U=(p,w,S,C)=>{p-S/2<o&&(o=p-S/2),p+S/2>y&&(y=p+S/2),w-C/2<n&&(n=w-C/2),w+C/2>M&&(M=w+C/2)};for(let p=0;p<F.length;p++){let[w,S]=P[p],C=Math.min(w.index,S.index)*k.length+Math.max(w.index,S.index),K=R.get(C)??1,O=q.get(C)??0;q.set(C,O+1);let v=rt(F[p].label,!1,h,i,Bt),_,E,W;if(w===S){let[$,Y,H]=Ht(w,O+1);_=[],U($,Y,2*H+2,2*H+2),E=$+H+6+v.width/2,W=Y-H/2}else{let $=L.has(C)?Math.round(i*1.5)+2:14;_=ve(w,S,(O-(K-1)/2)*$,z);let Y=_.length,H=Math.abs(_[2]-_[0])+Math.abs(_[3]-_[1]),dt=Math.abs(_[Y-2]-_[Y-4])+Math.abs(_[Y-1]-_[Y-3]),j=Y===6&&dt>H?2:0,V=v.width>0?Ne(_,j,v.width+8,v.height,w,S,z):.5;E=_[j]+(_[j+2]-_[j])*V,W=_[j+1]+(_[j+3]-_[j+1])*V}v.width>0&&U(E,W,v.width+8,v.height),b.push({edge:F[p],points:_,loop:w===S?O+1:0,label:v,lx:E,ly:W})}let X=rt(t.title,!1,h,r,l?vt(s):4e3,1),ot=X.height>0?X.height+12:0,ht=Math.max(y-o,X.width),at=e-o+(ht-(y-o))/2,B=e+ot-n;for(let p of k)p.x+=at,p.y+=B;let gt=Math.ceil(ht+2*e),Ct=Math.ceil(M-n+ot+2*e),wt="",At="";for(let p=1;p<k.length;p++){let w=k[p];if(w.kind===3)continue;let S=te((w.block.classes??Yt).join(" ")),C=Lt(w.block.id);if(w.kind===2){let O=w.y-w.h/2;wt+=`<g class="pele-cluster${S}" data-id="${C}"><rect x="${A(w.x-w.w/2)}" y="${A(O)}" width="${A(w.w)}" height="${A(w.h)}" rx="${ee}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${w.style.shape}/>`+Mt(w.label,w.x,O+(w.head+d)/2+2,` class="pele-cluster-label" fill="var(--_m)"${w.style.text}`,g)+"</g>";continue}let K=w.kind===1;At+=`<g class="pele-node pele-shape-${K?"block-arrow":w.shape}${S}" data-id="${C}" transform="translate(${A(w.x)},${A(w.y)})">`+(K?fe(w.mask,w.bw,w.bh,Ft+w.style.shape):Qt(w.shape,w.bw,w.bh,Ft+w.style.shape,ke+w.style.line))+Mt(w.label,w.dx,w.dy,` class="pele-label"${w.style.text}`,g)+"</g>"}let mt="",xt="";for(let p=0;p<b.length;p++){let{edge:w,points:S,loop:C,label:K}=b[p],O=w.arrowTypeStart??"",v=w.arrowTypeEnd??"",_;if(C>0)_=Le(P[p][0],C,ft(O),ft(v));else{for(let W=0;W<S.length;W+=2)S[W]+=at,S[W+1]+=B;_=De(S,ft(O),ft(v))}let E=Lt(w.id);if(mt+=`<g class="pele-edge" data-id="${E}"><path d="${_.d}"${w.thickness==="thick"?' stroke-width="2.5"':""}${w.pattern==="dotted"?' stroke-dasharray="3 4"':""}/>`+Dt(O,_.sx,_.sy,_.sdx,_.sdy,"var(--_l)")+Dt(v,_.ex,_.ey,_.edx,_.edy,"var(--_l)")+"</g>",K.width>0){let W=b[p].lx+at,$=b[p].ly+B;xt+=Xt(w.id,K,W,$,"",g)}}return{svg:ae("block",gt,Ct,r,s,t,Mt(X,gt/2,e+X.height/2,' class="pele-title" font-weight="var(--_tw)"')+(wt?`<g class="pele-clusters">${wt}</g>`:"")+(mt?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${mt}</g>`:"")+`<g class="pele-nodes">${At}</g>`+(xt?`<g class="pele-edge-labels" font-size="${i}">${xt}</g>`:"")),width:gt,height:Ct,links:[]}}var $e={type:"block",parse(t,a,s){let l=new ne;return l.title=s,de(t,l),l},render:Re};export{$e as block};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var Pe=Object.defineProperty;var Fe=(t,i,l)=>i in t?Pe(t,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[i]=l;var I=(t,i,l)=>Fe(t,typeof i!="symbol"?i+"":i,l);import{s as et}from"./RVARI57O-CXmrUIiS.js";import{x as Qe,H as Ve,t as dt,u as ge,e as Ae,L as $e,i as We}from"./lazy-CKqR1774.js";import{l as je}from"./DKTLEL5E-B7ILCVTH.js";import{_ as Me,x as f,m as be,y as ye,f as ut,$ as Ke,b as Ge}from"./RZSVICHU-BiwjruZZ.js";import"./index-392ivruk.js";var qe=class{constructor(){I(this,"type","xychart");I(this,"title");I(this,"accTitle");I(this,"accDescr");I(this,"orientation");I(this,"xAxis",{type:"band",title:"",categories:[]});I(this,"yAxis",{type:"linear",title:"",min:1/0,max:-1/0});I(this,"hasSetXAxis",!1);I(this,"hasSetYAxis",!1);I(this,"plots",[])}setOrientation(t){this.orientation=t==="horizontal"?"horizontal":"vertical"}setXAxisTitle(t){this.xAxis.title=t.text.trim()}setXAxisRangeData(t,i){this.xAxis={type:"linear",title:this.xAxis.title,min:t,max:i},this.hasSetXAxis=!0}setXAxisBand(t){this.xAxis={type:"band",title:this.xAxis.title,categories:t.map(i=>i.text.trim())},this.hasSetXAxis=!0}setYAxisTitle(t){this.yAxis.title=t.text.trim()}setYAxisRangeData(t,i){this.yAxis={type:"linear",title:this.yAxis.title,min:t,max:i},this.hasSetYAxis=!0}plotData(t){if(t.length===0)return[];this.hasSetXAxis||this.setXAxisRangeData(1,t.length);let i=this.xAxis;if(i.type==="band"&&t.length>i.categories.length&&(t=t.slice(0,i.categories.length)),!this.hasSetYAxis){let{min:r,max:n}=this.yAxis;for(let s of t)s<r&&(r=s),s>n&&(n=s);this.yAxis={type:"linear",title:this.yAxis.title,min:r,max:n}}if(i.type==="band")return i.categories.map((r,n)=>[r,t[n]]);if(t.length===1)return[[`${i.min}`,t[0]]];let l=(i.max-i.min)/(t.length-1);return t.map((r,n)=>[`${i.min+n*l}`,r])}addPlot(t,i,l){let r={type:t,title:i.text.trim(),data:this.plotData(l.map(n=>n.value))};t==="line"&&l.some(n=>n.label.trim()!=="")&&(r.pointLabels=l.map(n=>n.label.trim())),this.plots.push(r)}setLineData(t,i){this.addPlot("line",t,i)}setBarData(t,i){this.addPlot("bar",t,i)}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
2
|
+
`)}},we=["$end","INVALID","NEWLINE","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","XYCHART","CHART_ORIENTATION","X_AXIS","Y_AXIS","ARROW_DELIMITER","LINE","BAR","NUMBER_WITH_DECIMAL","SQUARE_BRACES_START","SQUARE_BRACES_END","STR","ALPHA","COLON","PLUS","COMMA","EQUALS","MULT","BRKT","UNDERSCORE","DOT","AMP","MINUS","NUM","SEMI","EOF"],ve=[33,33,33,33,33,19,5,7,8],_e="`)"+" ".repeat(36)+'{ this.pushstate(md_string); }\n<md_string>(?:(?!`").)+'+" ".repeat(18)+"{ return md_str; }\n<md_string>(?:`",Jt=new Uint8Array(128);for(let[t,i]of[[":",21],["+",22],[",",23],["=",24],["*",25],["#",26],["_",27],[".",28],["&",29],["-",30],[";",32]])Jt[t.charCodeAt(0)]=i;function Je(t){let i=t.length,l=[],r=[],n=[],s=[],x=0,e=0,d=(o,A,m)=>{l.push(o),r.push(t.slice(A,m)),n.push(A),e=m},y=o=>{s.push(x),x=o},M=()=>{s.length>0&&(x=s.pop())},C=o=>{let A=t.indexOf(`
|
|
3
|
+
`,o);return A===-1?i:A},h=o=>{for(;o<i&&Ae(t.charCodeAt(o));)o++;return o},b=o=>{for(;dt(t.charCodeAt(o));)o++;return o},u=o=>et(t,e,o)&&!We(t.charCodeAt(e+o.length));for(;e<i;){let o=t.charCodeAt(e);if(x===5){if(o===34)e++,M();else{let m=t.indexOf('"',e);d(19,e,m===-1?i:m)}continue}if(x===6||x===7){d(ve[x],e,C(e)),M();continue}if(x===8){if(o===125)e++,M();else{let m=t.indexOf("}",e);d(8,e,m===-1?i:m)}continue}let A=t.charCodeAt(e+1);if(o===37&&A===37){e=C(e+2);continue}if(o!==125&&A===37&&t.charCodeAt(e+2)===37){e=C(e+3);continue}if(o===10||o===13){if((x===1||x===3)&&(o===10||A===10)){d(2,e,o===10?e+1:e+2),M();continue}let m=e+1;for(let _=t.charCodeAt(m);_===10||_===13;_=t.charCodeAt(++m));d(2,e,m);continue}switch(o|32){case 116:if(u("title")){d(3,e,e+5);continue}break;case 97:if(et(t,e,"acc")){let m=et(t,e+3,"descr");if(m||et(t,e+3,"title")){let _=h(e+8),w=t.charCodeAt(_);if(w===58){d(m?6:4,e,h(_+1)),y(m?7:6);continue}if(w===123&&m){e=h(_+1),y(8);continue}}}break;case 120:if(u("xychart-beta")){d(9,e,e+12);continue}if(u("xychart")){d(9,e,e+7);continue}if(u("x-axis")){d(11,e,e+6),y(1);continue}break;case 121:if(u("y-axis")){d(12,e,e+6),y(1);continue}break;case 118:if(et(t,e,"vertical")){d(10,e,e+8);continue}break;case 104:if(et(t,e,"horizontal")){d(10,e,e+10);continue}break;case 108:if(u("line")){d(14,e,e+4),y(3);continue}break;case 98:if(u("bar")){d(15,e,e+3),y(3);continue}break}if(o===91){x===1?y(2):x===3&&y(4),d(17,e,e+1);continue}if(o===93){(x===4||x===2)&&M(),d(18,e,e+1);continue}if(x===1&&o===45&&A===45&&t.charCodeAt(e+2)===62){d(13,e,e+3);continue}if(x===1||x===4){let m=o===43||o===45?e+1:e,_=t.charCodeAt(m),w=-1;if(dt(_)?(w=b(m+1),t.charCodeAt(w)===46&&dt(t.charCodeAt(w+1))&&(w=b(w+2))):_===46&&dt(t.charCodeAt(m+1))&&(w=b(m+2)),w!==-1){d(16,e,w);continue}}if(o===96&&et(t,e,_e)){e+=_e.length,M();continue}if(o===34){e++,y(5);continue}if(ge(o)){let m=e+1;for(;ge(t.charCodeAt(m));)m++;d(20,e,m);continue}if(dt(o)){d(31,e,b(e+1));continue}if(Ae(o)){e=h(e+1);continue}if(o<128&&Jt[o]!==0){d(Jt[o],e,e+1);continue}break}return e<i?(l.push(1),r.push(""),n.push(e),{types:l,texts:r,starts:n}):(l.push(ve[x]),r.push(""),n.push(i),l.push(0),r.push(""),n.push(i),{types:l,texts:r,starts:n})}function Xe(...t){let i=new Uint8Array(34);for(let l of t)i[l]=1;return i}var Se=Xe(29,31,20,22,24,25,28,26,30,27),ke=Xe(2,32,33);function Ze(t,i){let{types:l,texts:r,starts:n}=Je(t),s=0,x=h=>{let b=l[s];throw b===1?$e("xychart",t,n[s],"",!0):$e("xychart",t,n[s],`Expecting ${h}, got '${we[b]}'`)},e=h=>(l[s]!==h&&x(`'${we[h]}'`),r[s++]),d=h=>h===19||Se[h]===1,y=()=>{d(l[s])||x("'STR', 'ALPHA', 'NUM'");let h=r[s++];if(l[s-1]!==19)for(;Se[l[s]]===1;)h+=r[s++];return{text:h,type:"text"}},M=()=>{let h=Number(e(16));return e(13),[h,Number(e(16))]},C=()=>{let h=[];for(e(17);;){let b=Number(e(16));if(h.push({value:b,label:l[s]===19?r[s++]:""}),l[s]!==23)break;s++}return e(18),h};for(;;)if(ke[l[s]]===1)s++;else{if(l[s]!==9)break;l[++s]===10&&i.setOrientation(r[s++])}for(;l[s]!==0;){let h=l[s++];switch(h){case 3:i.setDiagramTitle(y().text.trim());break;case 11:case 12:{let b=d(l[s])?y():void 0;if(h===11&&l[s]===17){let u=[];do s++,u.push(y());while(l[s]===23);e(18),i.setXAxisBand(u)}else if(l[s]===16||b===void 0){let[u,o]=M();h===11?i.setXAxisRangeData(u,o):i.setYAxisRangeData(u,o)}h===11?i.setXAxisTitle(b??{type:"text",text:""}):i.setYAxisTitle(b??{type:"text",text:""});break}case 14:case 15:{let b=l[s]===17?{text:"",type:"text"}:y(),u=C();h===14?i.setLineData(b,u):i.setBarData(b,u);break}case 4:i.setAccTitle(e(5).trim());break;case 6:i.setAccDescription(e(7).trim());break;case 8:i.setAccDescription(r[s-1].trim());break;default:s--,x("'title', 'X_AXIS', 'Y_AXIS', 'LINE', 'BAR', 'acc_title', 'acc_descr', 'acc_descr_multiline_value'")}for(;ke[l[s]]===1;)s++}}function Ce(t,i){let l=t/Math.max(i,1),r=Math.floor(Math.log10(l)),n=l/10**r,s=n>=7.07?10:n>=3.16?5:n>=1.41?2:1;return r<0?-(10**-r)/s:s*10**r}function Lt(t,i){return t>0?i/t:i*-t}function mt(t,i){return t>0?i*t:i/-t}function Te(t,i,l){let r=Math.round(Lt(l,t));mt(l,r)<t&&r++;let n=Math.round(Lt(l,i));mt(l,n)>i&&n--;let s=[];for(let x=r;x<=n&&s.length<100;x++)s.push(mt(l,x));return s}var Le=4,st=12,Re=26,De=24,Ee=1e300;function qt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{}}function N(t,i,l=!0){let r=t[i];return typeof r=="boolean"?r:l}function Ne(t,i){return typeof t=="number"&&t>0?Math.round(Math.min(Math.max(t,100),4e3)):i}function W(t){return typeof t=="number"&&isFinite(t)?Math.min(Math.max(t,-Ee),Ee):void 0}function ti(t){let i=0;for(let l of t)i=Math.max(i,l.label.width);return i}function Tt(t,i,l,r){let n=t.lines.length===1?t.lines[0]:void 0;return n&&n.length===1&&n[0].icon===void 0&&n[0].style===0?`<text x="${f(i)}" y="${f(l+t.size*.35)}" text-anchor="${r}">${Ge(n[0].text)}</text>`:ut(t,i+(r==="start"?t.width/2:r==="end"?-t.width/2:0),l,"")}function ei(t,i,l){if(t.plots.length===0)throw new Qe("No Plot to render, please provide a plot with some data","semantic",{type:"xychart"});let r=qt(i.xyChart),n=l.fontSize??16,s=Math.round(n*.875),x=Math.round(n*.75),e=l.measurer??Ve(l.fontFamily),d=l.padding??8,y=Ne(r.width,700),M=je(l,y,240),C=Math.round(Ne(r.height,500)*Math.max(.6,M/y)),h=(t.orientation??r.chartOrientation)==="horizontal",b=N(r,"showDataLabel",!1),u=t.xAxis,o=t.plots,A=(a,c,p)=>Me(a,!1,e,c,p),m=A("0",s,4e3).height,_=A("0",x,4e3).height,w=Me(N(r,"showTitle")?t.title:void 0,!1,e,n,M-2*d,1),Ie=w.height>0?w.height+12:0,pt=[],Rt=0;N(r,"showLegend")&&o.forEach((a,c)=>{if(a.title==="")return;let p=A(a.title,s,M*.3);pt.push({index:c,label:p}),Rt=Math.max(Rt,p.width+st+8)});let Dt=pt.length>0?Rt+De:0,j=o.filter(a=>a.type==="bar").length,g=t.yAxis.min,$=t.yAxis.max,Zt=t.hasSetYAxis&&isFinite(g)&&isFinite($)&&g!==$;if(Zt)g=W(g),$=W($);else{g=1/0,$=-1/0;for(let a of o)for(let[,c]of a.data){let p=W(c);p!==void 0&&(p<g&&(g=p),p>$&&($=p))}g>$&&(g=$=0),j>0&&(g=Math.min(g,0),$=Math.max($,0)),g===$&&(g===0?$=1:(g-=Math.abs(g)/2,$+=Math.abs($)/2))}let te=(a,c)=>{let p=Ce(Math.abs($-g),Math.max(2,Math.min(10,Math.floor(a/c))));return Zt||(g=mt(p,Math.floor(Lt(p,g)+1e-9)),$=mt(p,Math.ceil(Lt(p,$)-1e-9))),Te(Math.min(g,$),Math.max(g,$),p).map(v=>({at:(v-g)/($-g),label:A(String(v),s,4e3)}))},rt=1;if(u.type==="band")rt=Math.max(u.categories.length,1);else for(let a of o)rt=Math.max(rt,a.data.length);let it=1/rt,gt=u.type==="band"||j>0?it/2:0,z=W(u.type==="linear"?u.min:void 0),at=W(u.type==="linear"?u.max:void 0),ee=z!==void 0&&at!==void 0&&z!==at,ie=(a,c)=>u.type==="band"?(a+.5)*it:gt+(c>1?a/(c-1):ee?0:.5)*(1-2*gt),Et=qt(r.xAxis),ae=qt(r.yAxis),At=h?Et:ae,$t=h?ae:Et,ht=A(N(At,"showTitle")?h?u.title:t.yAxis.title:void 0,s,C*.8),Mt=A(N($t,"showTitle")?h?t.yAxis.title:u.title:void 0,s,M*.8),bt=N(At,"showTick")?Le:0,yt=N($t,"showTick")?Le:0,Nt=N(At,"showLabel"),Xt=N($t,"showLabel"),Oe=h?M*.3:Math.max(48,(M-2*d-64-Dt)*it-8),It=u.type==="band"&&N(Et,"showLabel")?u.categories.map(a=>A(a,s,Oe)):[],Ot=0,wt=0;for(let a of It)Ot=Math.max(Ot,a.width),wt=Math.max(wt,a.height);let le=a=>{let c=[];if(u.type==="band"){let p=It.length===0?8:h?wt:Ot+12,v=Math.max(1,Math.ceil(p/(a*it)));for(let L=0;L<u.categories.length;L+=v)c.push({at:(L+.5)*it,label:It[L]??A(void 0,s,0)})}else if(ee){let p=Ce(Math.abs(at-z),Math.max(2,Math.min(10,Math.floor(a/(h?32:80)))));for(let v of Te(Math.min(z,at),Math.max(z,at),p))c.push({at:gt+(v-z)/(at-z)*(1-2*gt),label:A(String(v),s,4e3)})}else z!==void 0&&c.push({at:.5,label:A(String(z),s,4e3)});return c},ot=0,vt=0;for(let a of o){for(let c of a.pointLabels??[])ot=Math.max(ot,e.width(c,x,0));if(b&&h&&a.type==="bar")for(let[,c]of a.data)vt=Math.max(vt,e.width(String(W(c)??""),x,0))}let se=Xt?h||u.type!=="band"?m:wt:0,Ue=yt+(se>0?se+4:0)+(Mt.height>0?Mt.height+4:0),ze=h?0:ot>0||b?_+4:Nt?m/2:0,P=d+Ie+ze,X=Math.max(1,C-d-Ue-P),K=P+X,Ut=h?le(X):te(X,56),re=Nt?ti(Ut):0,T=d+(ht.height>0?ht.height+6:0)+(re>0?re+6:0)+bt,Ye=Math.max(ot>0?ot+12:0,vt>0?vt+8:0),zt=h?Math.min(M*.25,Ye):0,S=Math.max(1,M-d-T-Dt-zt),Yt=h?te(S,80):le(S);if(Xt&&Dt+zt===0){let a=0;for(let c of Yt)a=Math.max(a,c.at*S+c.label.width/2-S);S=Math.max(1,S-a)}let _t=T+S,G=(a,c)=>h?T+c*S:T+a*S,q=(a,c)=>h?P+a*X:K-c*X,Bt=a=>(a-g)/($-g),he=a=>Math.min(Math.max(a,0),1),oe=a=>h?`M${f(G(0,a))},${f(P)}V${f(K)}`:`M${f(T)},${f(q(0,a))}H${f(_t)}`,Ht="";for(let a of h?Yt:Ut)Ht+=oe(a.at);let J="",St="";N(At,"showAxisLine")&&(J+=`M${f(T)},${f(P)}V${f(K)}`),N($t,"showAxisLine")&&(J+=`M${f(T)},${f(K)}H${f(_t)}`);for(let a of Ut){let c=h?P+a.at*X:K-a.at*X;bt&&(J+=`M${f(T)},${f(c)}h${-bt}`),Nt&&(St+=Tt(a.label,T-bt-6,c,"end"))}for(let a of Yt){let c=T+a.at*S;yt&&(J+=`M${f(c)},${f(K)}v${yt}`),Xt&&(St+=Tt(a.label,c,K+yt+4+a.label.height/2,"middle"))}let Pt=(h?X:S)*it,nt=Pt*.7/Math.max(j,1),Ft=j>1?Math.min(2,nt*.2):0,lt=he(Bt(0));j>0&<>0&<<1&&(J+=oe(lt));let ne="",ce="",Qt="",Vt="",Be=0;o.forEach((a,c)=>{var de;let p=be(c),v=a.title?` data-id="${ye(a.title)}"`:"",L=u.type==="band"?Math.min(a.data.length,rt):a.data.length;if(a.type==="bar"){let F=(Be++-(j-1)/2)*nt-(nt-Ft)/2,xt="";for(let R=0;R<L;R++){let D=W(a.data[R][1]);if(D===void 0)continue;let O=ie(R,L),Z=he(Bt(D)),tt=Math.min(lt,Z),B=Math.max(lt,Z),k=h?G(O,tt):G(O,0)+F,E=h?q(O,0)+F:q(O,B),H=h?(B-tt)*S:nt-Ft,U=h?nt-Ft:(B-tt)*X;if(xt+=`<rect x="${f(k)}" y="${f(E)}" width="${f(H)}" height="${f(U)}"/>`,!b)continue;let Q=String(D),Ct=e.width(Q,x,0),V=Z>=lt?1:-1,ue=k+H/2,me=E+U/2,pe="middle";if(h){if(U<x)continue;ue=(V>0?k+H:k)+V*6,pe=V>0?"start":"end"}else{if(Ct+2>Pt/j)continue;me=(V>0?E:E+U)-V*(_/2+2)}Qt+=`<text x="${f(ue)}" y="${f(me+x*.35)}" text-anchor="${pe}">${Q}</text>`}ne+=`<g class="pele-series pele-bars"${v} fill="${p}">${xt}</g>`;return}let ct="",xe="",Gt=!1,ft=0,Y=NaN;for(let F=0;F<L;F++){let xt=W(a.data[F][1]);if(xt===void 0){Y=NaN;continue}let R=ie(F,L),D=Bt(xt),O=D>=0&&D<=1;if(Y!==Y)O&&(ct+=`M${f(G(R,D))},${f(q(R,D))}`),Gt=O;else{let k=D-Y,E=0,H=1;if(k!==0){let U=-Y/k,Q=(1-Y)/k;E=Math.max(E,Math.min(U,Q)),H=Math.min(H,Math.max(U,Q))}else O||(E=2);if(E<=H){let U=ft+(R-ft)*E,Q=Y+k*E,Ct=ft+(R-ft)*H,V=Y+k*H;(!Gt||E>0)&&(ct+=`M${f(G(U,Q))},${f(q(U,Q))}`),ct+=`L${f(G(Ct,V))},${f(q(Ct,V))}`}Gt=O}if(ft=R,Y=D,!O)continue;let Z=G(R,D),tt=q(R,D);Pt>=12&&(xe+=`<circle cx="${f(Z)}" cy="${f(tt)}" r="3"/>`);let B=A((de=a.pointLabels)==null?void 0:de[F],x,4e3);if(B.height>0){let k=B.width/2;Vt+=h?Tt(B,Z+10,tt,"start"):Tt(B,Math.max(Math.min(Z,_t-k),T+k),tt-6-B.height/2,"middle")}}ce+=`<g class="pele-series pele-line"${v} fill="${p}">`+(ct?`<path d="${ct}" fill="none" stroke="${p}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`:"")+xe+"</g>"});let kt="";ht.height>0&&(kt+=`<g transform="translate(${f(d+ht.height/2)},${f(P+X/2)}) rotate(-90)">${ut(ht,0,0,"")}</g>`),kt+=ut(Mt,T+S/2,C-d-Mt.height/2,"");let Wt="",fe=0;for(let a of pt)fe+=Math.max(Re,a.label.height+6);let jt=P+Math.max(0,(X-fe)/2),Kt=_t+zt+De;for(let{index:a,label:c}of pt){let p=Math.max(Re,c.height+6);if(jt+p>C)break;let v=jt+p/2,L=be(a);Wt+=`<g class="pele-legend-item" data-id="${ye(o[a].title)}">`+(o[a].type==="bar"?`<rect x="${f(Kt)}" y="${f(v-st/2)}" width="${st}" height="${st}" rx="2" fill="${L}"/>`:`<path d="M${f(Kt)},${f(v)}h${st}" stroke="${L}" stroke-width="2" stroke-linecap="round"/>`)+ut(c,Kt+st+8+c.width/2,v,"")+"</g>",jt+=p}let He=ut(w,M/2,d+w.height/2,' class="pele-title" font-weight="var(--_tw)"')+(Ht?`<path class="pele-grid" d="${Ht}" stroke="var(--_a)"/>`:"")+`<g class="pele-plot">${ne}${ce}</g>`+(J?`<path class="pele-axis" d="${J}" fill="none" stroke="var(--_b)"/>`:"")+(St?`<g class="pele-axis-labels" font-size="${s}" fill="var(--_m)">${St}</g>`:"")+(kt?`<g class="pele-axis-titles" font-size="${s}">${kt}</g>`:"")+(Qt?`<g class="pele-data-labels" font-size="${x}">${Qt}</g>`:"")+(Vt?`<g class="pele-point-labels" font-size="${x}">${Vt}</g>`:"")+(Wt?`<g class="pele-legend" font-size="${s}">${Wt}</g>`:"");return{svg:Ke("xychart",M,C,n,l,t,He),width:M,height:C,links:[]}}var oi={type:"xychart",section:"xyChart",parse(t,i,l){let r=new qe;return r.title=l,Ze(t,r),r},render:ei};export{oi as xychart};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{x as g,D as v,M as u,$ as w,v as $,V as D,W as _,G as x,O as y,P as z,U as M,z as T,Y as H,H as h}from"./VMV7XPHP-6QkisQwm.js";import{_ as d,f as p,$ as b}from"./RZSVICHU-BiwjruZZ.js";import{H as I}from"./lazy-CKqR1774.js";import"./index-392ivruk.js";function P(i,e){return{type:"info",title:i.title||e,accTitle:i.accTitle?i.accTitle.replace(/^\s+/g,""):void 0,accDescr:i.accDescr?i.accDescr.replace(/\n\s+/g,`
|
|
2
|
+
`):void 0}}var k=[h("showInfo"),h("info"),u,w,$,D,_,x,y,z];function S(i){let e=new g(v(i,k,"info"),k,"info"),t={$type:"Info"};for(;e.kind===5;)e.i++;for(e.expect(1);e.kind===5;)e.i++;if(e.accept(0))for(;e.kind===5;)e.i++;for(;e.kind!==-1;){let a=e.kind;if(a===2?t.accDescr=M(e.take()):a===3?t.accTitle=T(e.take()):a===4?t.title=H(e.take()):e.fail("a title or the end of input"),e.kind===-1)break;for(e.kind!==5&&e.fail("a line break or the end of input");e.kind===5;)e.i++}return t}var A="1.6.0";function C(i,e,t){let a=t.fontSize??16,c=t.measurer??I(t.fontFamily),r=t.padding??8,n=d(i.title,!1,c,a,4e3,1),l=n.height>0?n.height+8:0,o=d(`Pele v${A}`,!1,c,a,4e3),f=Math.ceil(Math.max(n.width,o.width)+2*r),s=Math.ceil(l+o.height+2*r),m=p(n,f/2,r+n.height/2,' class="pele-title" font-weight="var(--_tw)"')+p(o,f/2,r+l+o.height/2,' class="pele-version" fill="var(--_m)"');return{svg:b("info",f,s,a,t,i,m),width:f,height:s,links:[]}}var Q={type:"info",parse:(i,e,t)=>P(S(i),t),render:C};export{Q as info};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function x(e,i,w,r,o,l=0){if(e===""||i<=0)return;let t=o.width(e,w,l);if(t<=i)return{text:e,size:w,width:t};let h=Math.max(r,Math.floor(w*i/t));for(;h>=r;){if(t=o.width(e,h,l),t<=i)return{text:e,size:h,width:t};h--}let d=Array.from(e),n=0,u=d.length-1;for(;n<u;){let f=n+u+1>>1;o.width(d.slice(0,f).join("").trimEnd()+"…",r,l)<=i?n=f:u=f-1}if(n===0)return;let s=d.slice(0,n).join("").trimEnd()+"…";return t=o.width(s,r,l),t<=i?{text:s,size:r,width:t}:void 0}export{x as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f="4q 0 b 0 5 0 6 m 2 u 2 cp 5 b f 4 8 0 2 0 3m 4 2 1 3 3 9 0 2 2 2 0 2 j 2 2a 2 3u 9 4d a 11 3 0 8 12 21 q 6 2 1a 16 10 1 2 2q 2 0 g 1 8 1 b 2 3 0 h 0 2 t u 2g c 0 p w a 1 5 0 6 l 5 0 a 0 4 0 o o 20 0 2 a 2g 1h 4 0 j 0 8 9 g 6 2 6 6 7 3 1 3 l 2 6 2 0 4 3 4 0 h 0 e 1 2 2 f 1 k 5 5 1 3 l 2 6 2 1 2 1 2 1 w 3 2 0 k 2 h 8 2 2 2 l 2 6 2 1 2 4 4 0 j 0 g 1 10 7 3 1 3 l 2 6 2 1 2 4 4 0 v 1 2 2 g 0 i 0 2 5 4 2 2 3 4 1 2 0 2 1 4 1 4 2 4 b n 0 1h 7 2 2 2 m 2 9 2 4 4 0 r 1 7 1 10 7 2 2 2 m 2 9 2 4 4 0 x 0 2 1 g 1 j 7 2 2 2 14 3 0 h 0 i 1 p 5 6 h 4 n 2 8 2 0 3 6 1n 1b 2 1 d 6 1n 1 2 0 3 1 2 0 3 0 7 3 2 6 2 2 2 0 2 0 3 1 2 3 2 1 a 0 3 4 2 0 m 3 x 0 1s 7 2 z s 4 38 16 l 0 h 5 5 3 4 0 4 1 8 2 5 c d 0 i 11 2 0 6 0 3 16 2 98 2 3 3 6 2 0 2 3 3 14 2 3 3 w 2 3 3 6 2 0 2 3 3 e 2 1k 2 3 3 1u 12 f h 2c d h7 3 g 2 p 6 22 m c 2 3 f h f h f c 2 2 g 1f 10 0 5 0 1w 2f 9 14 2 0 6 1x b s 1g t 3 4 c 17 m 6 1l m a 1g 2b 0 2m 1a i 6 1k t e 1 b 17 r z 16 2 b z 30 3 2 3 4 1 a 5b 1t 7p 3 5 3 11 3 5 3 7 2 0 2 0 2 0 2 u 3 1g 2 6 2 0 4 2 2 6 4 3 3 5 5 c 6 2 2 6 39 0 e 0 h c 2u 0 5 0 3 9 2 0 4 4 7 0 2 0 2 0 2 3 2 a 3 3 6 4 5 0 1h 1 22k 1a 2 1a 2 3o 7 3 4 1 d 11 2 0 6 0 3 1j 8 0 h m a 6 2 6 2 6 2 6 2 6 2 6 2 6 2 6 29 0 d2 1 17 4 6 1 5 2d 7 2 2 2h 2 3 6 14 4 2l i q 1i f e9 52t 23 g5o 1g wc 1w 19 3 7g 4 f b 1 l 1a h o 9 1x 1e 8 3 2u 3 3 2 3 d a 26 9 2 2 2 3 2 m u 1f f 1d 1r 5 4 0 f r b m q s 8 1a t 0 1d 14 o 2 2 7 l m 4 0 6 1b 2 0 4 1 3 4 3 0 2 0 p 2 3 a 8 2 d 5 3 5 3 5 a 6 2 6 42 y u 8mb d m 5 1c 6it a5 3 2x 13 6 d 4 6 0 2 9 2 c 2 4 2 0 2 1 2 1 2 2z y a2 j 1r 3 1h 15 b 39 4 2 3q 11 p 7 p c 2g 4 5 3 5 3 5 3 2",h;function n(){let t=f.split(" "),e=new Uint16Array(t.length),l=0;for(let a=0;a<t.length;a+=2){let r=l+parseInt(t[a],36);l=r+parseInt(t[a+1],36),e[a]=r,e[a+1]=l}return e}function g(t){if(t<170||t>65500)return!1;let e=h??(h=n()),l=0,a=(e.length>>1)-1;for(;l<=a;){let r=l+a>>1;if(t<e[r*2])a=r-1;else if(t>e[r*2+1])l=r+1;else return!0}return!1}export{g as h};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var at=Object.defineProperty;var ot=(t,i,r)=>i in t?at(t,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[i]=r;var ee=(t,i,r)=>ot(t,typeof i!="symbol"?i+"":i,r);import{c as nt}from"./MFVI5XKI-DrRaRE9X.js";import{b as Be,d as Oe,m as ct}from"./FKCDD66M-BPFkyrwI.js";import{N as dt,A as ft}from"./JZWSX6AR-OwVPptYv.js";import{R as De}from"./URA2L2QI-B8pYKxOk.js";import{H as ht,$ as pt,x as rt,i as te,e as le,C as ut,L as Ue}from"./lazy-CKqR1774.js";import{m as gt,c as mt}from"./DKTLEL5E-B7ILCVTH.js";import{F as yt,D as bt,S as Ct,v as kt,w as Ie}from"./HWDLEDTA-C_JcdBMO.js";import{_ as Ke,g as wt,x as F,f as pe,b as St,h as vt,y as Xe,$ as At}from"./RZSVICHU-BiwjruZZ.js";import"./index-392ivruk.js";function Tt(t){let i="TB";for(let r of t)typeof r!="string"&&r.stmt==="dir"&&(i=r.value);return i}function _t(t,i,r){let d=[],w=[],E=new Map,o=new Map,e=new Map,D=0,I=0,j=v=>{if(!v.id||v.id==="</join></fork>"||v.id==="</choice>")return;if(v.cssClasses){let g;for(let h of v.cssClasses.split(" ")){let P=r.get(h);if(P){g??(g=v.cssCompiledStyles.slice());for(let W of P.styles)g.push(W)}}g&&(v.cssCompiledStyles=g)}let b=E.get(v.id);if(b){let g=v.parentId??b.parentId;Object.assign(b,v),g!==void 0&&(b.parentId=g)}else E.set(v.id,v),d.push(v)},Z=(v,b,g)=>{var ie;let h=b.id;if(h==="root")return;let P=i.get(h),W=((ie=P==null?void 0:P.classes)==null?void 0:ie.join(" "))??"",K=(P==null?void 0:P.styles)??[],A=o.get(h);if(!A){let J="rect";b.start===!0?J="stateStart":b.start===!1&&(J="stateEnd"),b.type!=="default"&&(J=b.type),A={shape:J,description:h,cssClasses:`${W} statediagram-state`,cssStyles:K,type:void 0,dir:void 0,colorIndex:void 0},o.set(h,A)}if(b.description&&(Array.isArray(A.description)?(A.shape="rectWithTitle",A.description=A.description.concat(b.description)):A.description.length>0?(A.shape="rectWithTitle",A.description=A.description===h?[b.description].flat():[A.description,b.description].flat()):(A.shape="rect",A.description=Array.isArray(b.description)?b.description.slice():b.description)),A.description.length===1&&A.shape==="rectWithTitle"&&(A.shape=A.type==="group"?"roundedWithTitle":"rect"),!A.type&&b.doc){if(A.type="group",A.dir=Tt(b.doc),A.shape=b.type==="divider"?"divider":"roundedWithTitle",A.shape==="divider"&&(v==null?void 0:v.id)!==void 0&&e.has(v.id))A.colorIndex=e.get(v.id);else{let J=I++;A.colorIndex=W.trim()!==""||K.length>0?void 0:J}e.set(h,A.colorIndex),A.cssClasses=`${A.cssClasses} statediagram-cluster ${g?"statediagram-cluster-alt":""}`}let C=A.description,z={id:h,shape:A.shape,label:Array.isArray(C)?C[0]:C,description:Array.isArray(C)?C.slice(1):[],cssClasses:A.cssClasses,cssCompiledStyles:[],cssStyles:A.cssStyles,type:A.type,isGroup:A.type==="group",dir:A.dir,colorIndex:A.colorIndex};z.shape==="divider"&&(z.label=""),v&&v.id!=="root"&&(z.parentId=v.id);let O=b.note;if(!O){j(z);return}let H=(J,ae,se,V)=>({id:J,shape:ae,label:O.text,description:[],cssClasses:se,cssCompiledStyles:[],cssStyles:[],type:V?"group":"node",isGroup:V,dir:void 0,position:O.position}),T=H(`${h}----note-${D++}`,"note","statediagram-note",!1);T.parentId=`${h}----parent`,T.noteFor=h,j(H(T.parentId,"noteGroup",A.cssClasses,!0)),j(T),j(z);let G=O.position==="left of",re=G?T.id:h,U=G?h:T.id;w.push({id:`${re}-${U}`,start:re,end:U,label:"",classes:"transition note-edge",pattern:"dashed"})},R=[{item:void 0,doc:t,at:0,alt:!0}];for(;R.length>0;){let v=R[R.length-1];if(v.at>=v.doc.length){R.pop();continue}let b=v.doc[v.at++];typeof b!="string"&&(b.stmt==="state"?(Z(v.item,b,v.alt),b.doc&&R.push({item:b,doc:b.doc,at:0,alt:!v.alt})):b.stmt==="relation"&&(Z(v.item,b.state1,v.alt),Z(v.item,b.state2,v.alt),w.push({id:`edge${D++}`,start:b.state1.id,end:b.state2.id,label:b.description??"",classes:"transition"})))}for(let v of d)if(v.isGroup&&v.description.length>0)throw new rt(`Group nodes can only have label. Remove the additional description for node [${v.id}]`,"semantic",{type:"state"});return{nodes:d,edges:w}}var xt=class{constructor(){ee(this,"type","state");ee(this,"rootDoc",[]);ee(this,"states",new Map);ee(this,"relations",[]);ee(this,"classes",new Map);ee(this,"links",new Map);ee(this,"graph",{nodes:[],edges:[]});ee(this,"title");ee(this,"accTitle");ee(this,"accDescr");ee(this,"dividerCount",0)}get direction(){let t="TB";for(let i of this.rootDoc)typeof i!="string"&&i.stmt==="dir"&&(t=i.value);return t}setRootDoc(t){this.rootDoc=t,this.translate(),this.extract(t)}extract(t){this.states=new Map,this.relations=[],this.classes=new Map;let i=Array.isArray(t)?t:t.doc;for(let r of i)if(typeof r!="string")switch(r.stmt){case"state":this.addState(r.id.trim(),r.type,r.doc,r.description,r.note);break;case"relation":this.addRelation(r.state1,r.state2,r.description);break;case"classDef":this.addStyleClass(r.id.trim(),r.classes);break;case"style":{let d=r.styleClass.split(",").map(w=>w.replace(/;/g,"").trim());for(let w of this.named(r.id.trim()))w.styles=d.slice();break}case"applyClass":this.setCssClass(r.id.trim(),r.styleClass);break;case"click":this.addLink(typeof r.id=="string"?r.id:r.id.id,r.url,r.tooltip);break}this.graph=_t(i,this.states,this.classes)}translate(){let t=[["root",{stmt:"root",id:"root",doc:this.rootDoc},!0]];for(;t.length>0;){let[i,r,d]=t.pop();if(typeof r=="string")continue;if(r.stmt==="relation"){t.push([i,r.state2,!1],[i,r.state1,!0]);continue}if(r.stmt==="state")r.id==="[*]"?(r.id=i+(d?"_start":"_end"),r.start=d):r.id=r.id.trim();else if(r.stmt!=="root")continue;if(!r.doc)continue;let w=[],E=[];for(let o of r.doc)typeof o!="string"&&o.stmt==="state"&&o.type==="divider"&&!o.doc?(w.push({...o,doc:E}),E=[]):E.push(o);w.length>0&&(E.length>0&&w.push({stmt:"state",id:this.getDividerId(),type:"divider",doc:E}),r.doc=w);for(let o=r.doc.length-1;o>=0;o--)t.push([r.id,r.doc[o],!0])}}addState(t,i="default",r,d,w,E){let o=t.trim(),e=this.states.get(o);if(e?(e.doc||(e.doc=r),e.type||(e.type=i)):(e={stmt:"state",id:o,descriptions:[],type:i,doc:r,note:w,classes:[],styles:[],textStyles:[]},this.states.set(o,e)),d)for(let D of Array.isArray(d)?d:[d])this.addDescription(o,D.trim());if(w&&(e.note=w),E)for(let D of E)this.setCssClass(o,D.trim())}getState(t){return this.states.get(t)}addLink(t,i,r){this.links.set(t,{url:i,tooltip:r})}addRelation(t,i,r=""){for(let d of[t,i])this.addState(d.id,d.type,d.doc,d.description,d.note,d.classes);this.relations.push({id1:t.id.trim(),id2:i.id.trim(),relationTitle:r})}addDescription(t,i){var r,d;(d=(r=this.states.get(t))==null?void 0:r.descriptions)==null||d.push(i.startsWith(":")?i.replace(":","").trim():i)}getDividerId(){return`divider-id-${++this.dividerCount}`}addStyleClass(t,i=""){let r=this.classes.get(t);if(r||(r={id:t,styles:[],textStyles:[]},this.classes.set(t,r)),!!i)for(let d of i.split(",")){let w=d.replace(";","").trim();d.includes("color")&&r.textStyles.push(w.replace("fill","bgFill").replace("color","fill")),r.styles.push(w)}}setCssClass(t,i){var r;for(let d of this.named(t))(r=d.classes)==null||r.push(i)}getDirection(){for(let t of this.rootDoc)if(typeof t!="string"&&t.stmt==="dir")return t.value;return"TB"}setDirection(t){for(let i of this.rootDoc)if(typeof i!="string"&&i.stmt==="dir"){i.value=t;return}this.rootDoc.unshift({stmt:"dir",value:t})}trimColon(t){return t.startsWith(":")?t.slice(1).trim():t.trim()}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
2
|
+
`)}named(t){let i=[];for(let r of t.split(",")){let d=this.states.get(r);d||(this.addState(r),d=this.states.get(r.trim())),d&&i.push(d)}return i}},ze=["$end","INVALID","NL","SD","DESCR","-->","HIDE_EMPTY","scale","WIDTH","COMPOSIT_STATE","STRUCT_START","STRUCT_STOP","STATE_DESCR","AS","ID","FORK","JOIN","CHOICE","CONCURRENT","note","NOTE_TEXT","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","CLICK","STRING","HREF","classDef","CLASSDEF_ID","DEFAULT_CLASSDEF_ID","CLASSDEF_STYLEOPTS","DEFAULT","style","STYLE_IDS","STYLEDEF_STYLEOPTS","class","CLASSENTITY_IDS","STYLECLASS","direction_tb","direction_bt","direction_rl","direction_lr","EDGE_STATE","STYLE_SEPARATOR","left_of","right_of","INVALID"],$t=/direction/gi,Dt=/<<(?:fork|join|choice)>>|\[\[(?:fork|join|choice)\]\]/gi,It=/[\n\r\u2028\u2029]/g,Mt=/%%/g,Rt=/\{/g;function ue(t,i){let r=0,d=-2;return w=>{if(d===-2||w<r||d!==-1&&w>d){t.lastIndex=w;let E=t.exec(i);d=E?E.index:-1,r=w}return d}}function Et(t){let i=t.length,r=[],d=[],w=[],E=[],o=0,e=0,D,I=ue($t,t),j=ue(Dt,t),Z=ue(It,t),R=ue(Mt,t),v=ue(Rt,t),b=-1,g=-1,h=[-1,-1,-1,-1],P=[0,0,0,0],W=-1,K=-1,A=[-1,-1,-1,-1,-1,-1],C=(p,a,m)=>{r.push(p),d.push(t.slice(a,m)),w.push(a),e=m},z=(p,a,m,y)=>{r.push(p),d.push(a),w.push(m),e=y},O=p=>{E.push(o),o=p},H=()=>{E.length>0&&(o=E.pop())},T=(p,a)=>{for(let m=0;m<p.length;m++){let y=p.charCodeAt(m),n=t.charCodeAt(a+m);if(n!==y&&!(y>=97&&y<=122&&n===y-32))return!1}return!0},G=p=>{let a=p;for(;a<i&&le(t.charCodeAt(a));)a++;return a},re=p=>{let a=p;for(;a<i&&te(t.charCodeAt(a));)a++;return a},U=p=>{let a=t.indexOf(`
|
|
3
|
+
`,p);return a===-1?i:a},ie=p=>{let a=Z(p);return a===-1?i:a},J=p=>{if(p<b||p>g){let a=I(p),m=a===-1?i:ie(p);b=p,g=m,h[0]=h[1]=h[2]=h[3]=-1;for(let y=a;y!==-1&&y<m;y=I(y+1)){let n=G(y+9);if(n===y+9)continue;let $=T("tb",n)?0:T("bt",n)?1:T("rl",n)?2:T("lr",n)?3:-1;$!==-1&&(h[$]=y,P[$]=n+2)}}for(let a=0;a<4;a++)if(h[a]>=p)return a;return-1},ae=p=>{if(p<W||p>K){let a=j(p),m=a===-1?i:ie(p);W=p,K=m,A.fill(-1);for(let y=a;y!==-1&&y<m;y=j(y+1)){let n=t.charCodeAt(y+2)|32;A[(t.charCodeAt(y)===60?0:3)+(n===102?0:n===106?1:2)]=y}}for(let a=0;a<6;a++)if(A[a]>=p)return a;return-1},se=(p,a)=>{let m=R(p);return m===-1||m+2>a?(C(14,p,a),!0):m===p?(e=a,!1):(C(14,p,m),!0)},V=p=>(r.push(p),d.push(""),w.push(e),{types:r,texts:d,starts:w,error:D});for(;;){if(e>=i){switch(o){case 0:C(2,i,i);break;case 6:C(22,i,i);break;case 7:C(24,i,i);break;case 8:C(25,i,i);break;case 10:C(32,i,i);break;case 12:C(39,i,i);break;case 14:C(36,i,i);break;case 3:C(12,i,i);break;case 18:C(20,i,i);break;case 4:case 19:C(14,i,i);break}return V(0)}let p=t.charCodeAt(e);switch(o){case 0:case 1:{let a=o===0,m=p|32;if(a){if(m===99&&T("click",e)&&!te(t.charCodeAt(e+5))){C(26,e,e+5);continue}if(m===104&&T("href",e)&&!te(t.charCodeAt(e+4))){C(28,e,e+4);continue}if(p===34){let $=t.indexOf('"',e+1);if($!==-1){C(27,e,$+1);continue}}if(m===100&&T("default",e)&&!te(t.charCodeAt(e+7))){C(33,e,e+7);continue}let n=J(e);if(n!==-1){C(40+n,e,U(P[n]));continue}if(p===10){let $=e+1;for(;t.charCodeAt($)===10;)$++;C(2,e,$);continue}if(le(p)){e=G(e);continue}}else if(p!==10&&le(p)){let n=e+1;for(;n<i&&t.charCodeAt(n)!==10&&le(t.charCodeAt(n));)n++;e=n;continue}if(p===35||p===37&&t.charCodeAt(e+1)===37&&t.charCodeAt(e+2)!==123){e=U(e);continue}if(m===115){if(a&&T("scale",e)){let n=G(e+5);if(n>e+5){C(7,e,n),O(5);continue}}if(T("style",e)){let n=G(e+5);if(n>e+5){C(34,e,n),O(13);continue}}if(T("state",e)){let n=G(e+5);if(n>e+5){e=n,O(2);continue}if(a&&T("diagram",e+5)){let $=T("-v2",e+12)?e+15:e+12;if(n=G($),n>$){C(3,e,n);continue}}}}else if(m===99){if(T("class",e)){let n=T("def",e+5),$=n?e+8:e+5,q=G($);if(q>$){C(n?29:37,e,q),O(n?9:11);continue}}}else if(m===97&&a&&(T("acctitle",e)||T("accdescr",e))){let n=(t.charCodeAt(e+3)|32)===116,$=G(e+8),q=t.charCodeAt($);if(q===58){C(n?21:23,e,G($+1)),O(n?6:7);continue}if(q===123&&!n){e=G($+1),O(8);continue}}if(a){if(p===123){C(10,e,e+1),O(1);continue}}else{let n=J(e);if(n!==-1){C(40+n,e,U(P[n]));continue}if(p===125){C(11,e,e+1),H();continue}if(p===10){e++;continue}}if(m===110&&T("note",e)){let n=G(e+4);if(n>e+4){C(19,e,n),O(15);continue}}if(a&&m===104&&T("hide empty description",e)&&!te(t.charCodeAt(e+22))){C(6,e,e+22);continue}if(p===91&&t.charCodeAt(e+1)===42&&t.charCodeAt(e+2)===93){C(44,e,e+3);continue}let y=e;for(;y<i;){let n=t.charCodeAt(y);if(n===58||n===45||n===123||le(n))break;y++}if(y>e){se(e,y);continue}if(p===58){for(y=e+1;y<i;){let n=t.charCodeAt(y);if(n===10||n===59)break;if(n===58){let $=t.charCodeAt(y+1);if(y+1>=i||$===58||$===10||$===59)break;y++}y++}if(y>e+1){z(4,t.slice(e,y).trim(),e,y);continue}if(t.charCodeAt(e+1)===58&&t.charCodeAt(e+2)===58){C(45,e,e+3);continue}}else if(p===45&&t.charCodeAt(e+1)===45){if(t.charCodeAt(e+2)===62){C(5,e,e+3);continue}if(!a){C(18,e,e+2);continue}}if(!a)return V(1);C(48,e,e+1);continue}case 2:{if(p!==10&&le(p)){let n=e+1;for(;n<i&&t.charCodeAt(n)!==10&&le(t.charCodeAt(n));)n++;e=n;continue}if(p===35||p===37&&t.charCodeAt(e+1)===37&&t.charCodeAt(e+2)!==123){e=U(e);continue}let a=ae(e);if(a!==-1){let n=A[a],$=a===2||a===5;z($?17:a%3===0?15:16,t.slice(e,n).trim(),e,n+($?10:8)),H();continue}if(p===34){e++,O(3);continue}let m=p===10?G(e):e;if(T("as",m)){let n=G(m+2);if(n>m+2){C(13,e,n),O(4);continue}}if(p===10){e++,H();continue}if(p===123){C(10,e,e+1),H(),O(1);continue}if(te(p)){let n=re(e),$=G(n);if($>n&&te(t.charCodeAt($))){let q=v($+1);if(q!==-1&&q<ie($))return D=`Error: State name must be a single word. Found: "${t.slice(e,q+1).trim()}"`,V(1)}}let y=e+1;for(;y<i;){let n=t.charCodeAt(y);if(n===123||le(n))break;y++}C(9,e,y);continue}case 3:{if(p===34){e++,H();continue}let a=t.indexOf('"',e);C(12,e,a===-1?i:a);continue}case 4:{let a=e;for(;a<i;){let m=t.charCodeAt(a);if(m===10||m===123)break;a++}se(e,a)&&H();continue}case 5:{if(p>=48&&p<=57){let m=e+1;for(;m<i&&t.charCodeAt(m)>=48&&t.charCodeAt(m)<=57;)m++;C(8,e,m);continue}let a=G(e);if(a>e&&T("width",a)&&!te(t.charCodeAt(a+5))){e=a+5,H();continue}return V(1)}case 6:C(22,e,U(e)),H();continue;case 7:C(24,e,U(e)),H();continue;case 8:{if(p===125){e++,H();continue}let a=t.indexOf("}",e);C(25,e,a===-1?i:a);continue}case 9:{let a=T("default",e)&&G(e+7)>e+7,m=a?e+7:re(e),y=G(m);if(m===e||y===m)return V(1);C(a?31:30,e,y),H(),O(10);continue}case 10:C(32,e,U(e)),H();continue;case 11:{let a=re(e);if(a===e)return V(1);for(;t.charCodeAt(a)===44;){let m=G(a+1),y=re(m);if(y===m)break;a=y}C(38,e,a),H(),O(12);continue}case 12:C(39,e,U(e)),H();continue;case 13:{let a=e;for(;a<i&&(te(t.charCodeAt(a))||t.charCodeAt(a)===44);)a++;let m=G(a);if(a===e||m===a)return V(1);C(35,e,m),H(),O(14);continue}case 14:C(36,e,U(e)),H();continue;case 15:{if(T("left of",e)&&!te(t.charCodeAt(e+7))){C(46,e,e+7),H(),O(16);continue}if(T("right of",e)&&!te(t.charCodeAt(e+8))){C(47,e,e+8),H(),O(16);continue}if(p===34){e++,H(),O(18);continue}return V(1)}case 16:{let a=G(e),m=a;for(;m<i;){let y=t.charCodeAt(m);if(y===58||y===45||le(y))break;m++}if(m===a)return V(1);se(e,m)&&(H(),O(17));continue}case 17:{let a=G(e);if(t.charCodeAt(a)===58){let n=a+1;for(;n<i;){let $=t.charCodeAt(n);if($===58||$===10||$===59)break;n++}if(n>a+1){z(20,t.slice(e+2,n).trim(),e,n),H();continue}}let m=t.indexOf(`
|
|
4
|
+
`,e),y=-1;for(;m!==-1&&(y=G(m),!(T("end note",y)&&!te(t.charCodeAt(y+8))));)m=t.indexOf(`
|
|
5
|
+
`,y);if(m===-1)return V(1);z(20,t.slice(e,y).trim(),e,y+8),H();continue}case 18:{let a=G(e);if(T("as",a)){C(13,e,G(a+2)),H(),O(19);continue}if(p===34){e++;continue}let m=t.indexOf('"',e);C(20,e,m===-1?i:m);continue}case 19:se(e,U(e))&&H();continue}}}var Lt=["TB","BT","RL","LR"],ke="'NL', 'ID', 'HIDE_EMPTY', 'scale', 'COMPOSIT_STATE', 'STATE_DESCR', 'FORK', 'JOIN', 'CHOICE', 'CONCURRENT', 'note', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'CLICK', 'classDef', 'style', 'class', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'EDGE_STATE'";function Ot(t,i){let{types:r,texts:d,starts:w,error:E}=Et(t),o=0,e=b=>{let g=r[o];throw g===1?E!==void 0?new rt(E,"syntax",{type:"state",...ut(t,w[o])}):Ue("state",t,w[o],"",!0):Ue("state",t,w[o],`Expecting ${b}, got '${ze[g]}'`)},D=b=>(r[o]!==b&&e(`'${ze[b]}'`),d[o++]),I=()=>{let b=r[o];b!==14&&b!==44&&e("'ID', 'EDGE_STATE'");let g=d[o++].trim();return r[o]!==45?{stmt:"state",id:g,type:"default",description:""}:(o++,{stmt:"state",id:g,classes:[D(14).trim()],type:"default",description:""})};for(;r[o]===2;)o++;r[o]!==3&&e("'NL', 'SD'"),o++;let j=[],Z=[],R=b=>{b!=="nl"&&j.push(b)},v=(b,g)=>{o++;let h=[];j.push({stmt:"state",id:b,type:"default",description:g,doc:h}),Z.push(j),j=h};for(;;){let b=r[o];switch(b){case 2:o++;break;case 14:case 44:{let g=I();if(r[o]===4)g.description=i.trimColon(d[o++]),R(g);else if(r[o]===5){o++;let h=I();r[o]===4?R({stmt:"relation",state1:g,state2:h,description:i.trimColon(d[o++])}):R({stmt:"relation",state1:g,state2:h})}else R(g);break}case 6:R(d[o++]);break;case 7:o++,D(8),R(d[o-2]);break;case 9:r[o+1]===10?v(d[o++],""):R(d[o++]);break;case 12:{let g=d[o++];D(13);let h=D(14);if(r[o]===10)v(h,g);else if(h.includes(":")){let P=h.split(":");R({stmt:"state",id:P[0],type:"default",description:[g.trim(),P[1]]})}else R({stmt:"state",id:h,type:"default",description:g.trim()});break}case 15:R({stmt:"state",id:d[o++],type:"fork"});break;case 16:R({stmt:"state",id:d[o++],type:"join"});break;case 17:R({stmt:"state",id:d[o++],type:"choice"});break;case 18:o++,R({stmt:"state",id:i.getDividerId(),type:"divider"});break;case 19:{let g=d[o++];if(r[o]===46||r[o]===47){let h=d[o++].trim(),P=D(14).trim();R({stmt:"state",id:P,note:{position:h,text:D(20).trim()}})}else r[o]!==20&&e("'NOTE_TEXT', 'left_of', 'right_of'"),o++,D(13),D(14),R(g);break}case 40:case 41:case 42:case 43:{let g=Lt[b-40];o++,i.setDirection(g),R({stmt:"dir",value:g});break}case 21:{o++;let g=D(22).trim();i.setAccTitle(g),R(g);break}case 23:{o++;let g=D(24).trim();i.setAccDescription(g),R(g);break}case 25:{let g=d[o++].trim();i.setAccDescription(g),R(g);break}case 26:{o++;let g=I(),h,P="";r[o]===28?(o++,h=D(27)):(r[o]!==27&&e("'STRING', 'HREF'"),h=d[o++],P=D(27)),D(2),R({stmt:"click",id:g,url:h,tooltip:P});break}case 29:{o++;let g=D(30).trim();R({stmt:"classDef",id:g,classes:D(32).trim()});break}case 34:{o++;let g=D(35).trim();R({stmt:"style",id:g,styleClass:D(36).trim()});break}case 37:{o++;let g=D(38).trim();R({stmt:"applyClass",id:g,styleClass:D(39).trim()});break}case 11:Z.length===0&&e(`'$end', ${ke}`),o++,j=Z.pop();break;case 0:return Z.length>0&&e(`'STRUCT_STOP', ${ke}`),i.setRootDoc(j),j;default:e(Z.length>0?`'STRUCT_STOP', ${ke}`:`'$end', ${ke}`)}}}var Ht=40,Gt=16,Nt=44,de=16,Me=10,Ft=16,Ve=10,Re=26,Je=8,Wt=320,Ee=10,Ze=8,qe=' fill="var(--_s)" stroke="var(--_b)"',we=' fill="none" stroke="var(--_b)"',Yt=/(?:^| )statediagram-(?:state|cluster-alt|cluster|note)(?= |$)/g,jt=new Map([["rectWithTitle",1],["stateStart",2],["stateEnd",3],["choice",4],["fork",5],["join",6],["note",7],["divider",10]]),Pt=["pele-node pele-state","pele-node pele-state","pele-node pele-state-start","pele-node pele-state-end","pele-node pele-state-choice","pele-node pele-state-fork","pele-node pele-state-join","pele-note","pele-cluster pele-state-composite"];function Qe(t){return t==="TB"||t==="BT"}function Le(t,i,r){var w;let d=(w=t.state)==null?void 0:w[i];return typeof d=="number"&&d>0?Math.min(d,2e3):r}function et(t){let i=0,r=t.length;for(;i<r&&t.charCodeAt(i)===34;)i++;for(;r>i&&t.charCodeAt(r-1)===34;)r--;return t.slice(i,r)}function tt(t,i,r){return t<i?i:t>r?r:t}function Se(t,i,r,d,w){return`<rect x="${F(t)}" y="${F(i)}" width="${F(r)}" height="${F(d)}"${w}/>`}function ve(t,i,r,d){let w=Oe(0,0);return w.isGroup=!0,w.dir=t,w.padX=i,w.padTop=r,w.padBottom=d,w}function Bt(t,i,r){return gt(t.direction)?mt(r,d=>st(t,i,r,d)):st(t,i,r,!1)}function st(t,i,r,d){let w=t.graph,E=r.fontSize??16,o=Math.round(E*.875),e=r.measurer??ht(r.fontFamily),D=Le(i,"wrappingWidth",200),I=r.padding??8,j=r.icons,Z=d?"TB":Be(t.direction),R=Ke(void 0,!1,e,E,0),v=(l,s,c,k=0)=>Ke(l,!0,e,s,c,k),b=new Map,g=[],h=[],P=(l,s,c)=>(g.push({node:l,kind:s,style:void 0,label:R,lines:[],w:0,h:0,titleH:0}),c&&h.push(c),g.length-1);for(let l of w.nodes){if(l.shape==="noteGroup")continue;let s=l.isGroup?l.shape==="divider"?9:8:jt.get(l.shape)??0;b.set(l.id,P(l,s,void 0))}let W=g.length,K=[];for(let l=0;l<W;l++){let s=g[l].node.parentId,c=s===void 0?void 0:b.get(s);K.push(c!==void 0&&c!==l&&g[c].node.isGroup?c:-1)}{let l=[];for(let u=0;u<W;u++)l.push([]);let s=[],c=new Uint8Array(W);for(let u=0;u<W;u++)K[u]===-1?(c[u]=1,s.push(u)):l[K[u]].push(u);let k=0,x=()=>{for(;k<s.length;k++)for(let u of l[s[k]])c[u]||(c[u]=1,s.push(u))};x();let B=new Int32Array(W).fill(-1);for(let u=0;u<W;u++){if(c[u])continue;let f=u;for(;B[f]!==u;)B[f]=u,f=K[f];K[f]=-1,c[f]=1,s.push(f),x()}}let A=new Int32Array(W).fill(-1);for(let l=0;l<W;l++){let s=g[l].node.noteFor,c=s===void 0?void 0:b.get(s);c!==void 0&&(A[l]=c,K[l]=K[c])}let C=l=>Be(g[l].node.dir),z=l=>Qe(K[l]===-1?Z:C(K[l])),O=new Int32Array(W),H=new Uint8Array(W),T=new Array(W).fill(1/0),G=0,re=new Int32Array(2*W);for(let l of w.edges){let s=b.get(l.start),c=b.get(l.end);if(!(s===void 0||c===void 0)){if(l.pattern==="dashed"){H[g[s].kind===7?c:s]=1;continue}O[s]=Math.max(O[s],++re[2*s]),O[c]=Math.max(O[c],++re[2*c+1]),T[s]===1/0&&(T[s]=G++),T[c]===1/0&&(T[c]=G++)}}for(let l=0;l<W;l++){let s=g[l],c=s.node,k=wt(c.cssStyles.length>0?c.cssCompiledStyles.concat(c.cssStyles):c.cssCompiledStyles),x=(k.bold?1:0)|(k.italic?2:0),B=k.fontSize??E;s.style=k;let u;switch(s.kind){case 8:s.label=v(c.label,B,4e3,x),s.titleH=s.label.height>0?s.label.height+12:0,u=ve(C(l),de,s.titleH+de,de),u.minW=s.label.width+2*de;break;case 9:u=ve(C(l),Me,Me,Me);break;case 2:s.w=s.h=14;break;case 3:s.w=s.h=18;break;case 4:s.w=s.h=30;break;case 5:case 6:{let f=tt(40*O[l]+16,72,320);s.w=z(l)?f:Ze,s.h=z(l)?Ze:f;break}case 10:break;case 7:s.label=v(c.label,o,Math.max(D,Wt)),s.w=s.label.width+24,s.h=s.label.height+16;break;default:{s.label=v(c.label,B,D,x);let f=s.label.width,S=s.label.height+2*Ve;if(s.kind===1){S+=14;for(let L of c.description){let _=v(L===""?" ":L,o,D,x);s.lines.push(_),_.width>f&&(f=_.width),S+=_.height}}s.w=Math.max(f+2*Ft,56),s.h=S}}u??(u=Oe(s.w,s.h)),(s.kind===0||s.kind===1)&&(u.span=(z(l)?s.w:s.h)-24),h.push(u)}let U=[],ie=[],J=[],ae=new Int32Array(W),se=new Float64Array(W),V=new Float64Array(W),p=new Map,a=(l,s)=>{if(!h[l].isGroup)return!1;for(let c=K[s];c!==-1;c=K[c])if(c===l)return!0;return!1},m=(l,s)=>(p.set(U.length,l),T.push(s?-1:1/0),P(void 0,10,Oe(0,0,l)));for(let l of w.edges){let s=b.get(l.start),c=b.get(l.end);if(s===void 0||c===void 0)continue;let k=v(l.label,o,D),x=k.width>0?k.width+12:0;s===c?(ae[s]++,se[s]=Math.max(se[s],x),V[s]+=k.height):a(s,c)?s=m(s,!0):a(c,s)&&(c=m(c,!1)),J.push(l),ie.push(k),U.push({src:s,dst:c,minlen:1,labelW:x,labelH:k.height>0?k.height+4:0,route:[],labelX:0,labelY:0})}for(let l=0;l<W;l++){if(A[l]!==-1)continue;let s=h[l],c=0;if(ae[l]>0){let x=Re+(ae[l]-1)*8;c=z(l)?x+se[l]:x*.75+4+V[l],s.isGroup||(z(l)?(s.w+=2*c,s.h=Math.max(s.h,V[l])):(s.h+=2*c,s.w=Math.max(s.w,se[l])),c=0)}if(!H[l]&&c===0){s.parent=K[l];continue}let k=z(l)?ve("LR",c,0,0):ve("TB",0,c,c);k.parent=K[l],T.push(T[l]),h[l].parent=P(void 0,10,k)}for(let l=0;l<W;l++)A[l]!==-1&&(h[l].parent=h[A[l]].parent);{let l=[];for(let u=0;u<h.length;u++)l.push([]);let s=[];for(let u=0;u<h.length;u++){let f=h[u].parent;f>=0?l[f].push(u):s.push(u)}let c=u=>g[u].kind===2?0:1,k=(u,f)=>c(u)-c(f)||(T[u]===T[f]?0:T[u]<T[f]?-1:1)||u-f,x=0,B=s.sort(k).reverse();for(;B.length>0;){let u=B.pop();h[u].seq=x++;let f=l[u].sort(k);for(let S=f.length-1;S>=0;S--)B.push(f[S])}}let y=ct(h,U,Z,{nodeSep:Le(i,"nodeSpacing",Ht),edgeSep:Gt,rankSep:Le(i,"rankSpacing",Nt),portSep:20,headRoom:Ie("arrow_point")}),n=Math.ceil(y.width+2*I),$=Math.ceil(y.height+2*I),q=[],Ae=new Map;for(let l of U){let s=l.route;for(let c=3;c<s.length-3;c+=3){let k=Math.round(s[c+1]),x=Ae.get(k);x?x.push(s[c]):Ae.set(k,[s[c]])}}let ge=[];for(let l=0;l<h.length;l++)ge.push([]);let oe=[];for(let l=0;l<h.length;l++){let s=h[l].parent;s>=0?ge[s].push(l):oe.push(l)}let it=oe.slice();for(let l=0;l<oe.length;l++)for(let s of ge[oe[l]])oe.push(s);let Te="",me="",He="",Ge="",Ne=(l,s,c,k,x)=>{let B=l.filter(S=>g[S].kind===9);if(B.length<2)return;let u=(S,L)=>L?h[S].x-h[S].w/2:h[S].y-h[S].h/2,f=(S,L)=>L?h[S].x+h[S].w/2:h[S].y+h[S].h/2;for(let S of[!0,!1]){let L=B.slice().sort((M,X)=>u(M,S)-u(X,S)||M-X),_=!0;for(let M=1;M<L.length;M++)f(L[M-1],S)>u(L[M],S)+.5&&(_=!1);if(_){for(let M=1;M<L.length;M++){let X=F((f(L[M-1],S)+u(L[M],S))/2+I);me+=`<path class="pele-divider" d="M${S?`${X},${F(c)}V${F(x)}`:`${F(s)},${X}H${F(k)}`}"/>`}return}}for(let S of B){let L=h[S];me+=Se(L.x-L.w/2+I,L.y-L.h/2+I,L.w,L.h,` class="pele-divider" rx="${Ee}"`)}};Ne(it,I/2,I/2,n-I/2,$-I/2);for(let l of oe){let s=g[l],c=s.node,k=s.style;if(c===void 0||k===void 0||s.kind>=9)continue;let x=h[l],B=x.x+I,u=x.y+I,f=s.w,S=s.h,L=` class="pele-label"${k.text}`,_;switch(s.kind){case 8:{let N=B-x.w/2,Y=u-x.h/2;_=Se(N,Y,x.w,x.h,` rx="${Ee}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${k.shape}`),s.titleH>0&&(_+=`<path d="M${F(N)},${F(Y+s.titleH)}H${F(N+x.w)}"${we}${k.line}/>`+pe(s.label,Ut(x,s.label.width,Ae)+I,Y+s.titleH/2,` class="pele-cluster-label"${k.text}`,j)),Ne(ge[l],N,Y+s.titleH,N+x.w,Y+x.h);break}case 2:_=`<circle r="7" fill="var(--_l)"${k.shape}/>`;break;case 3:_=`<circle r="8.5" fill="var(--_bg)" stroke="var(--_l)"${k.line}/><circle r="5" fill="var(--_l)"${k.shape}/>`;break;case 4:_=`<polygon points="0,${F(-S/2)} ${F(f/2)},0 0,${F(S/2)} ${F(-f/2)},0"${qe}${k.shape}/>`;break;case 5:case 6:_=Se(-f/2,-S/2,f,S,` rx="2" fill="var(--_l)"${k.shape}`);break;case 7:{let N=F(f/2),Y=F(S/2),Q=F(f/2-Je),he=F(Je-S/2);_=`<path d="M-${N},-${Y}H${Q}L${N},${he}V${Y}H-${N}Z" fill="var(--_bg)" stroke="var(--_b)"/><path d="M${Q},-${Y}V${he}H${N}"${we}/>`+pe(s.label,0,0,` class="pele-label" font-size="${o}" fill="var(--_m)"`,j);break}default:{if(_=Se(-f/2,-S/2,f,S,` rx="${F(Math.min(Ee,S/2))}"${qe}${k.shape}`),s.kind===0){_+=pe(s.label,0,0,L,j);break}let N=Ve-S/2+s.label.height;_+=`<path d="M${F(-f/2)},${F(N+6)}H${F(f/2)}"${we}${k.line}/>`+pe(s.label,0,N-s.label.height/2,L,j),N+=14;for(let Y of s.lines)_+=pe(Y,0,N+Y.height/2,` class="pele-state-description" font-size="${o}"${k.text}`,j),N+=Y.height}}let M=t.links.get(c.id);if(M){let N=pt(et(M.tooltip));N&&(_=`<title>${St(N)}</title>`+_),_=dt(_,ft(et(M.url)),c.id,q,r,' target="_blank"')}let X=`<g class="${Pt[s.kind]}${vt(c.cssClasses.replace(Yt,""))}" data-id="${Xe(c.id)}"`;s.kind===8?Te+=`${X}>${_}</g>`:s.kind===7?Ge+=`${X} transform="translate(${F(B)},${F(u)})">${_}</g>`:He+=`${X} transform="translate(${F(B)},${F(u)})">${_}</g>`}let Fe=(l,s,c)=>{let k=h[c];if(k.isGroup)return;let x=g[c],B=x.kind===5||x.kind===6,u=s===0?3:s-3;for(let f of[1,0]){let S=f?k.h:k.w,L=f?x.h:x.w,_=f?x.w:x.h,M=(f?k.y:k.x)+I,X=(f?k.x:k.y)+I,N=l[s+f]-M;if(!(Math.abs(Math.abs(N)-S/2)>=.5)){l[s+f]-=Math.sign(N)*(S-L)/2,B&&_>L&&(l[s+1-f]=tt(l[u+1-f],X-_/2+6,X+_/2-6));return}}},_e=kt();for(let l=0;l<U.length;l++){let s=U[l];s.src===s.dst||s.route.length<6||J[l].pattern==="dashed"||_e.add(s.dst,De(s.route,s.route.length-3,h[s.dst]),"arrow_point")}let xe="",$e="",lt=new Int32Array(W),We=new Float64Array(W);for(let l=0;l<U.length;l++){let s=U[l],c=J[l],k=ie[l],x=c.pattern==="dashed",B=x?"none":"arrow_point",u;if(s.src===s.dst){let f=h[s.src],S=g[s.src],L=lt[s.src]++,_=z(s.src),M=f.isGroup?f.w:S.w,X=f.isGroup?f.h:S.h,N=(_?M:X)/2,Y=Math.max(Math.min((_?X:M)/2-4,8+L*6),2),Q=Re+L*8,he=Ie(B)/(Math.hypot(Q,Y)||1),ye=(ne,ce)=>f.x+I+(_?N+ne:-ce),be=(ne,ce)=>f.y+I+(_?ce:N+ne),Ce=(ne,ce)=>`${F(ye(ne,ce))},${F(be(ne,ce))}`;u={d:`M${Ce(0,-Y)}C${Ce(Q,-2*Y)} ${Ce(Q,2*Y)} ${Ce(Q*he,Y+Y*he)}`,sx:0,sy:0,sdx:0,sdy:0,ex:ye(0,Y),ey:be(0,Y),edx:ye(-Q,-Y)-ye(0,0),edy:be(-Q,-Y)-be(0,0)};let Ye=Math.hypot(u.edx,u.edy)||1;u.edx/=Ye,u.edy/=Ye;let je=Re+(ae[s.src]-1)*8,Pe=We[s.src]+k.height/2;We[s.src]+=k.height,s.labelX=_?f.x+N+je+4+s.labelW/2:f.x,s.labelY=_?f.y-V[s.src]/2+Pe:f.y+N+je*.75+4+Pe}else{let f=s.route.slice(),S=_e.of(s.src,De(f,0,h[s.src])),L=_e.of(s.dst,De(f,f.length-3,h[s.dst]));for(let M=0;M<f.length;M+=3)f[M]+=I,f[M+1]+=I;Fe(f,0,s.src),Fe(f,f.length-3,s.dst);let _=p.get(l);if(_!==void 0&&f.length>=6){let M=h[_],X=g[s.src].kind===10,N=X?0:f.length-3,Y=(M.dir==="TB"||M.dir==="LR")===X,Q=Qe(M.dir)?[f[N],M.y+I+(Y?g[_].titleH-M.h/2:M.h/2),0]:[M.x+I+(Y?-M.w/2:M.w/2),f[N+1],1];f=X?Q.concat(f):f.concat(Q)}u=yt(f,void 0,0,Ie(B),S,L)}if(xe+=`<g class="pele-edge ${x?'pele-note-edge" stroke="var(--_b)" stroke-dasharray="3 4':"pele-transition"}" data-id="${Xe(c.id)}"><path d="${u.d}"/>`+bt(B,u.ex,u.ey,u.edx,u.edy,"var(--_l)")+"</g>",k.width>0){let f=s.labelX+I,S=s.labelY+I;$e+=Ct(c.id,k,f,S,"",j)}}let fe=nt(t.title,e,E,I,n,$,(Te?`<g class="pele-clusters">${Te}</g>`:"")+(me?`<g class="pele-dividers" stroke-dasharray="4 4"${we}>${me}</g>`:"")+(xe?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${xe}</g>`:"")+($e?`<g class="pele-edge-labels" font-size="${o}">${$e}</g>`:"")+`<g class="pele-nodes">${He}${Ge}</g>`);return{svg:At("state",fe.width,fe.height,E,r,t,fe.content),width:fe.width,height:fe.height,links:q}}function Ut(t,i,r){let d=r.get(Math.round(t.y-t.h/2));if(d===void 0||i===0)return t.x;let w=t.x-t.w/2,E=i/2,o=t.x,e=-1;for(let D of[t.x,w+de+E,w+t.w-de-E]){let I=1/0;for(let j of d)j>w&&j<w+t.w&&(I=Math.min(I,Math.abs(j-D)-E));if(I>=6)return D;I>e+.5&&(e=I,o=D)}return o}var ss={type:"state",parse(t,i,r){let d=new xt;return r&&(d.title=r),Ot(t,d),d},render:Bt};export{ss as state};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var lt=Object.defineProperty;var rt=(t,e,a)=>e in t?lt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var be=(t,e,a)=>rt(t,typeof e!="symbol"?e+"":e,a);import{x as st,D as ot,M as ct,$ as ft,v as ht,w as pt,V as $t,W as mt,G as dt,O as ut,P as gt,j as We,Y as yt,z as bt,U as wt,H as xt}from"./VMV7XPHP-6QkisQwm.js";import{D as Mt,w as je}from"./HWDLEDTA-C_JcdBMO.js";import{_ as q,x as i,m as Ge,f as J,$ as kt,a as vt,y as _t}from"./RZSVICHU-BiwjruZZ.js";import{H as St}from"./lazy-CKqR1774.js";import"./index-392ivruk.js";var Dt=class{constructor(){be(this,"domains",new Map);be(this,"transitions",[])}setDomains(t){if(t)for(let e of t){let a=e.domain;this.domains.set(a,{name:a,items:(e.items??[]).map(o=>({label:o.label}))})}}setTransitions(t){t&&(this.transitions=t.filter(e=>e.from!==e.to).map(e=>({from:e.from,to:e.to,label:e.label||void 0})))}};function Ct(t,e){let a=new Dt;return a.setDomains(t.domains),a.setTransitions(t.transitions),{type:"cynefin",title:t.title||e,accTitle:t.accTitle?t.accTitle.replace(/^\s+/g,""):void 0,accDescr:t.accDescr?t.accDescr.replace(/\n\s+/g,`
|
|
2
|
+
`):void 0,domains:a.domains,transitions:a.transitions}}var Ie=[{name:"cynefin-beta:",pattern:"cynefin-beta:"},xt("cynefin-beta"),{name:"-->",pattern:"-->"},{name:":",pattern:":"},{name:"DOMAIN_NAME",pattern:/complex|complicated|clear|chaotic|confusion/y},ct,ft,ht,pt,$t,mt,dt,ut,gt];function At(t){let e=new st(ot(t,Ie,"cynefin"),Ie,"cynefin"),a={$type:"Cynefin",domains:[],transitions:[]},o=()=>{for(;e.kinds[e.i]===9;)e.i++},f=()=>{e.kind!==-1&&(e.kind!==9&&e.fail("a line break or the end of input"),o())};for(o(),e.kind!==1&&e.kind!==0&&e.fail("'cynefin-beta'"),e.i++;e.kind!==-1;)switch(e.kind){case 9:e.i++;break;case 5:a.accDescr=wt(e.take()),f();break;case 6:a.accTitle=bt(e.take()),f();break;case 7:a.title=yt(e.take()),f();break;case 4:{let h=e.take();if(e.accept(2)){let p={$type:"Transition",from:h,to:e.expect(4)};e.accept(3)&&(p.label=We(e.expect(8))),f(),a.transitions.push(p);break}let g={$type:"DomainBlock",domain:h,items:[]};for(o();e.kinds[e.i]===8;)g.items.push({$type:"DomainItem",label:We(e.take())}),o();a.domains.push(g);break}default:e.fail("a domain, a transition, a title, or a line break")}return a}function Qe(t){let e=t+1831565813|0;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Tt(t){let e=0;for(let a=0;a<t.length;a++)e=(e<<5)-e+t.charCodeAt(a),e|=0;return e}function Et(t,e){return typeof t=="number"&&Number.isFinite(t)&&t!==0?t:Tt(e)}var Lt={segments:7,vertical:!0,pointStep:17,controlStep:31,controlShift:7},Ue={segments:7,vertical:!1,pointStep:23,controlStep:37,controlShift:11};function we(t,e,a,o,f,h){let g=(e-t)/h.segments,p=[],y=[];for(let c=0;c<=h.segments;c++){let w=c===0&&h.pinStart||c===h.segments&&h.pinEnd;p.push(t+c*g),y.push(w?a:a+Qe(o+c*h.pointStep)*f*2-f)}let F=h.vertical?[y[0],p[0]]:[p[0],y[0]];for(let c=0;c<h.segments;c++){let w=(p[c]+p[c+1])/2,P=f*1.5*(c%2===0?1:-1)*Qe(o+c*h.controlStep+h.controlShift);h.vertical?F.push(y[c]+P,w,y[c+1]-P,w,y[c+1],p[c+1]):F.push(w,y[c]+P,w,y[c+1]-P,p[c+1],y[c+1])}return F}function Pt(t,e,a,o){let f=a-e;return[t,e,t+o,e+f*.2,t-o*1.5,e+f*.55,t+o*.5,e+f*.75,t-o,e+f*.85,t+o*.3,e+f*.95,t,a]}function K(t){let e="";for(let a=2;a<t.length;a+=6)e+=`C${i(t[a])},${i(t[a+1])} ${i(t[a+2])},${i(t[a+3])} ${i(t[a+4])},${i(t[a+5])}`;return e}function se(t){let e="";for(let a=t.length-6;a>=2;a-=6)e+=`C${i(t[a+2])},${i(t[a+3])} ${i(t[a])},${i(t[a+1])} ${i(t[a-2])},${i(t[a-1])}`;return e}function oe(t){return`M${i(t[0])},${i(t[1])}${K(t)}`}function Zt(t,e,a,o){let f=`${i(a)},${i(o)}`;return`M${i(t-a)},${i(e)}A${f} 0 1,1 ${i(t+a)},${i(e)}A${f} 0 1,1 ${i(t-a)},${i(e)}Z`}var xe=[["complex",0,0,0],["complicated",1,0,1],["chaotic",0,1,3],["clear",1,1,2]],Nt=4,zt=new Map([["complex",["Complex","Probe → Sense → Respond","Emergent Practices"]],["complicated",["Complicated","Sense → Analyse → Respond","Good Practices"]],["clear",["Clear","Sense → Categorise → Respond","Best Practices"]],["chaotic",["Chaotic","Act → Sense → Respond","Novel Practices"]],["confusion",["Confusion","","Disorder"]]]),Ve=3,Ye=200,Rt=10,Bt=4,ce=6,qe=10,Je=20,fe=10;function he(t,e,a,o,f){var g;let h=(g=t.cynefin)==null?void 0:g[e];return typeof h=="number"&&h>=o&&h<=f?h:a}function Ot(t,e,a){var Le;let o=a.fontSize??16,f=Math.round(o*.8125),h=Math.round(o*.875),g=a.measurer??St(a.fontFamily),p=a.padding??8,y=a.icons,F=((Le=e.cynefin)==null?void 0:Le.showDomainDescriptions)!==!1,c=he(e,"boundaryAmplitude",8,0,50),w=Et(he(e,"seed",0,-1e15,1e15),a.idPrefix??"pele"),P=Math.round(h*1.5),Me=(n,l)=>{let r=q(n,!1,g,h,Ye);return{text:n,label:r,w:r.width+2*Rt,h:Math.max(r.height,P)+2*Bt,overflow:l}},ke=n=>{var Q;let l=zt.get(n),r=q(l[0],!1,g,o,4e3,1),s=[];if(F)for(let d of[l[1],l[2]])d&&s.push(q(d,!1,g,f,4e3,2));let $=((Q=t.domains.get(n))==null?void 0:Q.items)??[],T=n==="confusion"&&$.length>Ve?Ve:$.length,x=[];for(let d=0;d<T;d++)x.push(Me($[d].label,!1));T<$.length&&x.push(Me(`+${$.length-T} more`,!0));let D=r.width,E=r.height;for(let d of s)D=Math.max(D,d.width),E+=d.height;x.length>0&&(E+=qe-ce);for(let d of x)D=Math.max(D,d.w),E+=ce+d.h;return{name:n,title:r,subtitles:s,badges:x,w:D,h:E,cx:0,cy:0}},pe=xe.map(([n])=>ke(n)),k=ke("confusion"),H=Math.max(88,k.w*.71+8),W=Math.max(64,k.h*.71+6),v=he(e,"width",640,100,1e4)/2,_=he(e,"height",440,100,1e4)/2;for(let n of pe)v=Math.max(v,n.w+2*Je),_=Math.max(_,n.h+2*Je);for(let n of pe){let l=(v-n.w)/2,r=(_-n.h)/2;if((l/(H+fe))**2+(r/(W+fe))**2>=1)continue;let s=n.w+2*(H+fe),$=n.h+2*(W+fe);s*_<=v*$?v=Math.max(v,s):_=Math.max(_,$)}let j=q(t.title,!1,g,o,4e3,1),ve=j.height>0?j.height+12:0,X=2*v,_e=2*_,S=p,Z=p+ve,C=S+v,A=Z+_,ee=S+X,$e=Z+_e,G=we(Z,A,C,w,c,{...Lt,segments:4,pinEnd:!0}),te=we(S,C,A,w+100,c,{...Ue,segments:4,pinEnd:!0}),I=we(C,ee,A,w+200,c,{...Ue,segments:4,pinStart:!0}),ae=Pt(C,A,$e,X*.03),N=(n,l)=>l?`${i(n[n.length-2])},${i(n[n.length-1])}`:`${i(n[0])},${i(n[1])}`,Ke=new Map([["complex",`M${i(S)},${i(Z)}L${N(G,!1)}${K(G)}${se(te)}Z`],["complicated",`M${N(G,!1)}L${i(ee)},${i(Z)}L${N(I,!0)}${se(I)}${se(G)}Z`],["chaotic",`M${N(te,!1)}${K(te)}${K(ae)}L${i(S)},${i($e)}Z`],["clear",`M${N(I,!1)}${K(I)}L${i(ee)},${i($e)}L${N(ae,!0)}${se(ae)}Z`]]),Se="";for(let[n,,,l]of xe)Se+=`<path class="pele-cynefin-region" data-id="${n}" d="${Ke.get(n)}" fill="${Ge(l)}" fill-opacity="0.14"/>`;let Xe=`<g class="pele-cynefin-boundaries" fill="none" stroke="var(--_b)" stroke-dasharray="6 3"><path d="${oe(G)}"/><path d="${oe(te)}"/><path d="${oe(I)}"/><path class="pele-cynefin-cliff" d="${oe(ae)}" stroke="var(--_l)" stroke-width="2" stroke-dasharray="none" stroke-linecap="round"/></g>`,De=Zt(C,A,H,W),et=`<path d="${De}" fill="var(--_bg)"/><path class="pele-cynefin-region" data-id="confusion" d="${De}" fill="${Ge(Nt)}" fill-opacity="0.18" stroke="var(--_b)" stroke-dasharray="4 2"/>`,Ce=n=>{let l=n.cy-n.h/2,r=J(n.title,n.cx,l+n.title.height/2,' class="pele-label" font-weight="var(--_hw)"');l+=n.title.height;for(let s of n.subtitles)r+=J(s,n.cx,l+s.height/2,` class="pele-cynefin-subtitle" font-size="${f}" font-style="italic" fill="var(--_m)"`),l+=s.height;l+=qe-ce;for(let s of n.badges)l+=ce,r+=`<g class="pele-node${s.overflow?" pele-cynefin-overflow":""}"${s.overflow?"":` data-id="${_t(s.text)}"`}><rect x="${i(n.cx-s.w/2)}" y="${i(l)}" width="${i(s.w)}" height="${i(s.h)}" rx="${vt}" fill="var(--_bg)" stroke="var(--_b)"${s.overflow?' stroke-dasharray="3 2"':""}/>`+J(s.label,n.cx,l+s.h/2,` class="pele-label" font-size="${h}"${s.overflow?' fill="var(--_m)"':""}`,y)+"</g>",l+=s.h;return`<g class="pele-cynefin-domain" data-id="${n.name}">${r}</g>`},ne=new Map,me="";xe.forEach(([n,l,r],s)=>{let $=pe[s];$.cx=S+v*(l+.5),$.cy=Z+_*(r+.5),ne.set(n,$),me+=Ce($)}),k.cx=C,k.cy=A,ne.set("confusion",k),me+=Ce(k);let de=(n,l,r)=>n===k?((l-C)/(H+4))**2+((r-A)/(W+4))**2<=1:Math.abs(l-n.cx)<=n.w/2+8&&Math.abs(r-n.cy)<=n.h/2+8,ue="",Ae=new Map;for(let n of t.transitions){let l=ne.get(n.from),r=ne.get(n.to);if(!l||!r||l===r)continue;let s=n.from<n.to?`${n.from} ${n.to}`:`${n.to} ${n.from}`,$=Ae.get(s)??0;Ae.set(s,$+1);let T=r.cx-l.cx,x=r.cy-l.cy,D=Math.hypot(T,x)||1,E=(l.cx+r.cx)/2,Q=(l.cy+r.cy)/2,d=-x*(E-C)+T*(Q-A)>=0?1:-1,ie=-x/D*d,le=T/D*d,Pe=(l!==k&&r!==k&&Math.abs(T)>1&&Math.abs(x)>1?2*(Math.hypot(H*ie,W*le)+16):D*.15)+$*56,Ze=E+ie*Pe,Ne=Q+le*Pe,z=m=>{let u=1-m;return[u*u*l.cx+2*u*m*Ze+m*m*r.cx,u*u*l.cy+2*u*m*Ne+m*m*r.cy]},ze=(m,u,L,re)=>{for(let O=0;O<16;O++){let Y=(u+L)/2;de(m,...z(Y))===re?u=Y:L=Y}return(u+L)/2},M=48,b=1;for(;b<=M&&de(l,...z(b/M));)b++;if(b>M)continue;let R=ze(l,(b-1)/M,b/M,!0);for(;b<=M&&!de(r,...z(b/M));)b++;let B=b>M?1:ze(r,(b-1)/M,b/M,!1),[at,nt]=z(R),[U,V]=z(B),Re=(m,u,L)=>(1-R)*(1-B)*m+((1-R)*B+R*(1-B))*u+R*B*L,ge=Re(l.cx,Ze,r.cx),ye=Re(l.cy,Ne,r.cy),Be=Math.hypot(U-ge,V-ye)||1,Oe=(U-ge)/Be,Fe=(V-ye)/Be,it=Mt("arrow_point",U,V,Oe,Fe,"var(--_l)");U-=Oe*je("arrow_point"),V-=Fe*je("arrow_point");let He="";if(n.label){let m=q(n.label,!1,g,f,Ye),[u,L]=z((R+B)/2),re=Math.abs(ie)*m.width/2+Math.abs(le)*m.height/2+6,O=m.width/2+4,Y=Math.min(Math.max(u+ie*re,S+O),Math.max(ee-O,S+O));He=J(m,Y,L+le*re,` class="pele-edge-label" font-size="${f}"`,y)}ue+=`<g class="pele-edge" data-id="${n.from}-${n.to}"><path d="M${i(at)},${i(nt)}Q${i(ge)},${i(ye)} ${i(U)},${i(V)}" fill="none" stroke="var(--_l)"/>`+it+He+"</g>"}let Te=Math.ceil(Math.max(X,j.width)+2*p),Ee=Math.ceil(_e+ve+2*p),tt=J(j,S+X/2,p+j.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-cynefin-regions">${Se}</g>`+Xe+et+me+(ue?`<g class="pele-edges">${ue}</g>`:"");return{svg:kt("cynefin",Te,Ee,o,a,t,tt),width:Te,height:Ee,links:[]}}var Qt={type:"cynefin",parse:(t,e,a)=>Ct(At(t),a),render:Ot};export{Qt as cynefin};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var et=Object.defineProperty;var tt=(t,s,l)=>s in t?et(t,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[s]=l;var K=(t,s,l)=>tt(t,typeof s!="symbol"?s+"":s,l);import{c as rt}from"./G3MDBVQH-EkdejvdW.js";import{x as lt,h as st}from"./ELSXBIJH-DG0MW5dC.js";import{b as Be,d as xe,m as at,p as it}from"./FKCDD66M-BPFkyrwI.js";import{M as ot,L as nt,O as ht}from"./JZWSX6AR-OwVPptYv.js";import{H as ct,$ as dt,e as ee,L as ze,i as fe,t as Ce}from"./lazy-CKqR1774.js";import{m as ft,c as ut}from"./DKTLEL5E-B7ILCVTH.js";import{F as pt,S as $t}from"./HWDLEDTA-C_JcdBMO.js";import{_ as le,g as gt,h as yt,a as Se,y as we,x as $,f as Oe,b as Ee,$ as bt,Y as mt,T as _t,q as wt}from"./RZSVICHU-BiwjruZZ.js";import"./index-392ivruk.js";function Et(t){return t==="markdown"||t==="string"||t==="text"?t:"markdown"}var Tt=class{constructor(){K(this,"type","er");K(this,"direction","TB");K(this,"entities",new Map);K(this,"relationships",[]);K(this,"classes",new Map);K(this,"subgraphs",[]);K(this,"title");K(this,"accTitle");K(this,"accDescr");K(this,"subgraphLookup",new Map);K(this,"claimed",new Set)}addEntity(t,s=""){let l=this.entities.get(t);return l===void 0?(l={id:`entity-${t}-${this.entities.size}`,label:t,alias:s,attributes:[],cssClasses:"default",cssStyles:[]},this.entities.set(t,l)):!l.alias&&s&&(l.alias=s),l}addAttributes(t,s){let l=this.addEntity(t);for(let i=s.length-1;i>=0;i--){let c=s[i];c.keys??(c.keys=[]),c.comment??(c.comment=""),l.attributes.push(c)}}addRelationship(t,s,l,i){let c=this.subgraphLookup.has(t)?t:this.addEntity(t).id,r=this.subgraphLookup.has(l)?l:this.addEntity(l).id;this.relationships.push({entityA:c,roleA:s,entityB:r,relSpec:i})}setDirection(t){this.direction=t}addCssStyles(t,s){if(s)for(let l of t){let i=this.entities.get(l);if(i)for(let r of s)i.cssStyles.push(r);let c=this.subgraphLookup.get(l);if(c)for(let r of s)c.cssStyles.push(r)}}addClass(t,s){for(let l of t){let i=this.classes.get(l);if(i===void 0&&(i={id:l,styles:[],textStyles:[]},this.classes.set(l,i)),!!s)for(let c of s)c.includes("color")&&i.textStyles.push(c.replace("fill","bgFill")),i.styles.push(c)}}setClass(t,s){for(let l of t){let i=this.entities.get(l);if(i)for(let r of s)i.cssClasses+=" "+r;let c=this.subgraphLookup.get(l);if(c)for(let r of s)c.classes.push(r)}}addSubGraph(t,s,l){let i=t.text.trim(),c=new Set,r=[],e;for(let u of s.flat()){if(typeof u!="string"){(u==null?void 0:u.stmt)==="dir"&&(e=u.value);continue}let d=u.trim();d===""||c.has(d)||(c.add(d),this.claimed.has(u)||r.push(u))}for(let u of r)this.claimed.add(u);let g={id:i,nodes:r,title:(l.text||"").trim(),classes:[],cssStyles:[],dir:e,labelType:Et(l.type)};return this.subgraphs.push(g),this.subgraphLookup.set(i,g),i}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
2
|
+
`)}},Fe=["$end","INVALID","ER_DIAGRAM","EOF","NEWLINE","COLON","STYLE_SEPARATOR","BLOCK_START","BLOCK_STOP","SQS","SQE","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","END","SUBGRAPH","direction_tb","direction_bt","direction_rl","direction_lr","CLASSDEF","UNICODE_TEXT","STYLE_TEXT","COMMA","CLASS","STYLE","SEMI","NUM","BRKT","ENTITY_NAME","DECIMAL_NUM","ENTITY_ONE","ATTRIBUTE_WORD","ATTRIBUTE_KEY","COMMENT","ZERO_OR_ONE","ZERO_OR_MORE","ONE_OR_MORE","ONLY_ONE","MD_PARENT","NON_IDENTIFYING","IDENTIFYING","WORD","CHAR"],ge=1,Te=2,Ge=4,ye=8,j=new Uint8Array(128);for(let t=0;t<128;t++){let s=t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95,l=s&&(t<48||t>57);s&&(j[t]|=ge|Te|ye),l&&(j[t]|=Ge)}for(let t of"-*")j[t.charCodeAt(0)]|=ge|Te|ye;j[46]|=ge|ye;j[42]|=Ge;for(let t of"[](),")j[t.charCodeAt(0)]|=ye;var Mt=/accTitle\s*:\s*/iy,At=/accDescr\s*:\s*/iy,xt=/accDescr\s*\{\s*/iy,Ct=[/.*direction\s+TB[^\n]*/iy,/.*direction\s+BT[^\n]*/iy,/.*direction\s+RL[^\n]*/iy,/.*direction\s+LR[^\n]*/iy],Ne=/direction/gi,Ie=/[\n\r\u2028\u2029]/g;function Ue(t,s){return t<128?(j[t]&s)!==0:t>=192||t===181}function St(t){let s=t.length,l=[],i=[],c=[],r=0,e=0,g=-2,u=0,d=-1,m=-2,_=-1,A=-1,M=-1,h=(o,a,y)=>{l.push(o),i.push(t.slice(a,y)),c.push(a),e=y},P=(o,a)=>(o.lastIndex=a,o.test(t)?o.lastIndex:-1),X=o=>{for(let a=0;a<o.length;a++){let y=o.charCodeAt(a),Y=t.charCodeAt(e+a);if(Y!==y&&(y<97||y>122||(Y|32)!==y))return!1}return!0},L=o=>X(o)&&!fe(t.charCodeAt(e+o.length)),se=o=>{let a=t.charCodeAt(o);return a>=65&&a<=90?a+32:a},ae=o=>(Ie.lastIndex=o,Ie.test(t)?Ie.lastIndex-1:s),F=o=>{for(;Ce(t.charCodeAt(o));)o++;return o},k=()=>{if(g===-1||g<e&&(Ne.lastIndex=e,g=Ne.test(t)?Ne.lastIndex-9:-1,g===-1)||e<u||(d<e&&(d=ae(e)),g>=d))return!1;for(let o=0;o<4;o++){let a=P(Ct[o],e);if(a>=0)return h(18+o,e,a),!0}return u=d,!1},D=()=>{let o=t.indexOf('"',e+1);if(o===-1){h(45,e,e+1);return}let a=o>e+1;for(let y=e+1;a&&y<o;y++){let Y=t.charCodeAt(y);(Y===37||Y===92||Y===13||Y===10||Y===11||Y===8)&&(a=!1)}h(a?31:44,e,o+1)},f=o=>{let a=t.charCodeAt(e+1);if(a===43&&(o===49||o===48)){h(o===49?39:38,e,e+2);return}let y=F(e+1);if(t.charCodeAt(y)===46&&Ce(t.charCodeAt(y+1))){h(32,e,F(y+2));return}if(o===49){if(ee(a)){let Y=e+2;for(;ee(t.charCodeAt(Y));)Y++;let ie=t.charCodeAt(Y);if(fe(ie)||ie===34||ie===39){h(40,e,e+1);return}}else if(a===45||a===46){let Y=t.charCodeAt(e+2);if(Y===45||Y===46){h(40,e,e+1);return}}if(!fe(a)){h(33,e,e+1);return}}h(29,e,y)},p=o=>{let a=t.charCodeAt(e+1);switch(o){case 101:if(L("erdiagram"))h(2,e,e+9);else if(L("end")){let y=e+3;for(;ee(t.charCodeAt(y));)y++;h(16,e,y)}else return!1;return!0;case 115:if(L("style"))r=6,h(27,e,e+5);else if(L("subgraph"))h(17,e,e+8);else return!1;return!0;case 99:if(L("classdef"))r=6,h(22,e,e+8);else if(L("class"))h(26,e,e+5);else return!1;return!0;case 111:if(L("one or zero"))h(37,e,e+11);else if(L("one or more")||L("one or many"))h(39,e,e+11);else if(L("one"))h(40,e,e+3);else if(L("only one"))h(40,e,e+8);else if(a===124)h(37,e,e+2);else if(a===123)h(38,e,e+2);else if(L("optionally to"))h(42,e,e+13);else return!1;return!0;case 122:if(L("zero or one"))h(37,e,e+11);else if(L("zero or more")||L("zero or many"))h(38,e,e+12);else return!1;return!0;case 109:if(X("many(0)"))h(38,e,e+7);else if(X("many(1)"))h(39,e,e+7);else if(L("many"))h(38,e,e+4);else return!1;return!0;case 116:return L("to")?(h(43,e,e+2),!0):!1;case 117:return a!==46&&a!==45&&a!==124?!1:(h(41,e,e+1),!0);case 124:if(se(e+1)===111&&!fe(t.charCodeAt(e+2)))h(37,e,e+2);else if(a===124)h(40,e,e+2);else if(a===123)h(39,e,e+2);else return!1;return!0;case 125:if(se(e+1)===111&&!fe(t.charCodeAt(e+2)))h(38,e,e+2);else if(a===124)h(39,e,e+2);else return!1;return!0;case 46:return a!==46&&a!==45?!1:(h(42,e,e+2),!0);case 45:if(a===45)h(43,e,e+2);else if(a===46)h(42,e,e+2);else return!1;return!0}return!1},O=o=>{let a;if((o===97||o===65)&&X("acc")){if((a=P(Mt,e))>=0){r=3,h(11,e,a);return}if((a=P(At,e))>=0){r=4,h(13,e,a);return}if((a=P(xt,e))>=0){r=5,e=a;return}}if(!k()){switch(o){case 32:case 9:case 13:a=e+1;for(let y=t.charCodeAt(a);y===32||y===9||y===13;y=t.charCodeAt(a))a++;e=a;return;case 10:for(a=e+1;t.charCodeAt(a)===10;)a++;h(4,e,a);return;case 34:D();return;case 123:r=1,h(7,e,e+1);return;case 35:h(30,e,e+1);return;case 44:h(25,e,e+1);return;case 58:t.charCodeAt(e+1)===58&&t.charCodeAt(e+2)===58?h(6,e,e+3):h(5,e,e+1);return;case 91:h(9,e,e+1);return;case 93:h(10,e,e+1);return}if(Ce(o)){f(o);return}if(!p(o>=65&&o<=90?o+32:o)){if(o>=128||(j[o]&ge)!==0){a=e+1;for(let y=t.charCodeAt(a);y>=128||(j[y]&ge)!==0;y=t.charCodeAt(a))a++;h(23,e,a);return}h(45,e,e+1)}}},G=()=>{if(m===-1||m<e&&(m=t.indexOf("~",e),m===-1))return!1;if(M<e){let a=e;for(;a<s&&!ee(t.charCodeAt(a));)a++;M=a}if(m>=M||(_<e&&(_=ae(e),A=t.lastIndexOf("~",_-1)),A<=m))return!1;let o=A+1;for(;o<s&&!ee(t.charCodeAt(o));)o++;return h(34,e,o),!0},re=o=>{if(ee(o)){for(e++;ee(t.charCodeAt(e));)e++;return}let a=o|32;if((a===112||a===102||a===117)&&(t.charCodeAt(e+1)|32)===107&&!fe(t.charCodeAt(e+2))){h(35,e,e+2);return}if(!G()){if(Ue(o,Ge)){let y=e+1;for(;y<s&&Ue(t.charCodeAt(y),ye);)y++;h(34,e,y);return}if(o===96){r=2,e++;return}if(o===34){let y=t.indexOf('"',e+1);if(y!==-1){h(36,e,y+1);return}}else if(o===125){r=0,h(8,e,e+1);return}h(45,e,e+1)}};for(;e<s;){let o=t.charCodeAt(e),a;switch(r){case 0:O(o);break;case 1:re(o);break;case 2:o===96?(r=1,e++):(a=t.indexOf("`",e),h(34,e,a===-1?s:a));break;case 3:case 4:a=t.indexOf(`
|
|
3
|
+
`,e),h(r===3?12:14,e,a===-1?s:a),r=0;break;case 5:o===125?(r=0,e++):(a=t.indexOf("}",e),h(15,e,a===-1?s:a));break;case 6:if(o===10){for(a=e+1;t.charCodeAt(a)===10;)a++;r=0,h(4,e,a)}else if(ee(o))for(e++;ee(t.charCodeAt(e));)e++;else if(o===58)h(5,e,e+1);else if(o===44)h(25,e,e+1);else if(o===35)h(30,e,e+1);else if(o===59)h(28,e,e+1);else if(o>=128||(j[o]&Te)!==0){a=e+1;for(let y=t.charCodeAt(a);y>=128||(j[y]&Te)!==0;y=t.charCodeAt(a))a++;h(24,e,a)}else return l.push(1),i.push(""),c.push(e),{types:l,texts:i,starts:c};break}}let U=r===0?3:r===3?12:r===4?14:r===5?15:-1;return U!==-1&&(l.push(U),i.push(""),c.push(s)),l.push(0),i.push(""),c.push(s),{types:l,texts:i,starts:c}}var Re=new Map([[37,"ZERO_OR_ONE"],[38,"ZERO_OR_MORE"],[39,"ONE_OR_MORE"],[40,"ONLY_ONE"],[41,"MD_PARENT"]]),Ot=["TB","BT","RL","LR"],Je="'UNICODE_TEXT', 'NUM', 'ENTITY_NAME', 'DECIMAL_NUM', 'ENTITY_ONE'",Nt="'ZERO_OR_ONE', 'ZERO_OR_MORE', 'ONE_OR_MORE', 'ONLY_ONE', 'MD_PARENT'",me="'EOF', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'SUBGRAPH', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'CLASSDEF', 'CLASS', 'STYLE', "+Je;function It(t,s){let{types:l,texts:i,starts:c}=St(t),r=0,e=f=>{let p=l[r];throw p===1?ze("er",t,c[r],"",!0):ze("er",t,c[r],`Expecting ${f}, got '${p===45?i[r]:Fe[p]}'`)},g=f=>(l[r]!==f&&e(`'${Fe[f]}'`),i[r++]),u=()=>{let f=l[r];f!==4&&f!==28&&f!==3&&e("'EOF', 'NEWLINE', 'SEMI'"),r++},d=f=>f===23||f===31||f===29||f===32||f===33,m=()=>{let f=l[r];d(f)||e(Je);let p=i[r++];return f===31?p.slice(1,-1):p},_=()=>{let f=[];for(;;){let p=l[r];if(p!==23&&p!==24&&e("'UNICODE_TEXT', 'STYLE_TEXT'"),f.push(i[r++]),l[r]!==25)return f;r++}},A=f=>f===24||f===29||f===5||f===30,M=()=>{let f=[];for(;;){A(l[r])||e("'STYLE_TEXT', 'COLON', 'NUM', 'BRKT'");let p=i[r++];for(;A(l[r]);)p+=i[r++];if(f.push(p),l[r]!==25)return f;r++}},h=()=>{let f=Re.get(l[r++]),p=l[r];p!==43&&p!==42&&e("'NON_IDENTIFYING', 'IDENTIFYING'");let O=p===43?"IDENTIFYING":"NON_IDENTIFYING";r++;let G=Re.get(l[r]);return G===void 0?e(Nt):(r++,{cardA:G,relType:O,cardB:f})},P=()=>{let f=l[r];f!==44&&f!==31&&f!==23&&e("'UNICODE_TEXT', 'ENTITY_NAME', 'WORD'");let p=i[r++];return f===23?p:p.slice(1,-1)},X=f=>l[r]===45&&i[r]===f,L=()=>{let f=[];do{let p=g(34);X("?")&&(p+=i[r++]),l[r]!==34&&e(p.endsWith("?")?"'ATTRIBUTE_WORD'":"'ATTRIBUTE_WORD', '?'");let O={type:p,name:i[r++]};if(l[r]===35){let G=[i[r++]];for(;X(",");)r++,G.push(g(35));O.keys=G}l[r]===36&&(O.comment=i[r++].slice(1,-1)),f.push(O)}while(l[r]!==8);return f.reverse()},se=()=>{if(l[r]!==7)return;if(r++,l[r]===8){r++;return}let f=L();return r++,f},ae=()=>{let f=m(),p=l[r];if(p===9){r++;let re=m();g(10);let U;l[r]===6&&(r++,U=_());let o=se();return s.addEntity(f,re),o&&s.addAttributes(f,o),U&&s.setClass([f],U),[f]}let O;if(p===6&&(r++,O=_(),p=l[r]),Re.has(p)){let re=h(),U=m(),o;l[r]===6&&(r++,o=_()),g(5);let a=P();return s.addEntity(f),s.addEntity(U),s.addRelationship(f,a,U,re),O&&s.setClass([f],O),o&&s.setClass([U],o),[f,U]}let G=se();return s.addEntity(f),G&&s.addAttributes(f,G),O&&s.setClass([f],O),[f]};g(2);let F=[{id:"",title:"",list:[]}],k=F[0],D=!1;for(;;){let f=l[r];switch(f){case 4:r++;break;case 3:r++,D&&e(`'END', ${me}`);return;case 16:{D||e(me),r++;let p=s.addSubGraph({text:k.id},k.list,{text:k.title});F.pop(),k=F[F.length-1],D=F.length>1,D&&k.list.push(p);break}case 17:{r++;let p=m(),O=p;if(l[r]===9){for(r++,O=m();d(l[r]);)O+=" "+m();g(10)}u(),k={id:p,title:O,list:[]},F.push(k),D=!0;break}case 11:{r++;let p=g(12).trim();s.setAccTitle(p),D&&k.list.push(p);break}case 13:{r++;let p=g(14).trim();s.setAccDescription(p),D&&k.list.push(p);break}case 15:{let p=i[r++].trim();s.setAccDescription(p),D&&k.list.push(p);break}case 18:case 19:case 20:case 21:{r++;let p=Ot[f-18];D?k.list.push({stmt:"dir",value:p}):s.setDirection(p);break}case 22:{let p=i[r++],O=_(),G=M();u(),s.addClass(O,G),D&&k.list.push(p);break}case 26:{let p=i[r++],O=_();s.setClass(O,_()),D&&k.list.push(p);break}case 27:{let p=i[r++],O=_(),G=M();u(),s.addCssStyles(O,G),D&&k.list.push(p);break}default:{d(f)||e(D?`'END', ${me}`:me);let p=ae();if(D)for(let O of p)k.list.push(O)}}}}var Rt=[];function kt(t){let s=[],l=[],i=t.subgraphs,c=u=>{let d=[];for(let m of u){let _=t.classes.get(m);if(_!==void 0){for(let A of _.styles)d.push(A.trim());for(let A of _.textStyles)d.push(A.trim())}}return d},r=new Map,e=new Set;for(let u=i.length-1;u>=0;u--){let d=i[u];e.add(d.id);for(let m of d.nodes)r.set(m,d.id)}for(let u=i.length-1;u>=0;u--){let d=i[u];s.push({id:d.id,label:d.title,alias:"",attributes:Rt,isGroup:!0,parentId:r.get(d.id),cssStyles:d.cssStyles,cssCompiledStyles:c(d.classes),cssClasses:d.classes.join(" "),dir:d.dir,labelType:d.labelType})}let g=new Map;for(let[u,d]of t.entities){if(e.has(u)){g.set(d.id,u);continue}s.push({id:d.id,label:d.label,alias:d.alias,attributes:d.attributes,isGroup:!1,parentId:r.get(u),cssStyles:d.cssStyles,cssCompiledStyles:c(d.cssClasses.split(" ")),cssClasses:d.cssClasses,dir:void 0,labelType:"markdown"})}return t.relationships.forEach((u,d)=>{l.push({id:`id_${u.entityA}_${u.entityB}_${d}`,start:g.get(u.entityA)??u.entityA,end:g.get(u.entityB)??u.entityB,label:u.roleA,arrowTypeStart:u.relSpec.cardB.toLowerCase(),arrowTypeEnd:u.relSpec.cardA.toLowerCase(),pattern:u.relSpec.relType==="IDENTIFYING"?"solid":"dashed"})}),{nodes:s,edges:l}}var te=18,He=5,We=6,ke=10,Xe=3.5;function ue(t,s,l,i,c){let r=(m,_)=>$(s-i*m-c*_)+","+$(l-c*m+i*_),e=m=>`M${r(m,-He)}L${r(m,He)}`,g=`M${r(0,-We)}L${r(ke,0)}L${r(0,We)}`,u=m=>`<circle class="pele-marker" cx="${$(s-i*m)}" cy="${$(l-c*m)}" r="${Xe}" fill="var(--_bg)"/>`,d=m=>`<path class="pele-marker" d="${m}"/>`;switch(t){case"only_one":return d(e(6)+e(10));case"zero_or_one":return d(e(6))+u(13.5);case"one_or_more":return d(g+e(ke+3.5));case"zero_or_more":return d(g)+u(ke+Xe+.5);case"md_parent":return`<path class="pele-marker" d="M${r(0,0)}L${r(6,4)}L${r(12,0)}L${r(6,-4)}Z" fill="var(--_bg)"/>`}return""}var vt=48,Lt=20,Dt=64,pe=20,$e=28,Yt=38,Pe=96,Ze=18,Gt=12,Bt=9,ve=12,Ke=16,Le=9,zt=260,De=1e6,Ft=[],Ut=18,Ht=14,Ve=' fill="var(--_s)" stroke="var(--_b)"';function je(t,s,l){var c;let i=(c=t.er)==null?void 0:c[s];return typeof i=="number"&&i>0?Math.min(i,2e3):l}function _e(t,s,l,i,c){let r=t.lines;if(r.length===0)return"";if(r.length===1&&r[0].length===1&&r[0][0].icon===void 0&&r[0][0].style===0)return`<text${i} x="${$(s)}" y="${$(l)}">${Ee(r[0][0].text)}</text>`;let e=mt(t),g="",u="";for(let d of r){let m=!1;for(let M of d)M.icon!==void 0&&(m=!0);let _=s,A=!1;for(let M of d){if(M.icon!==void 0){let h=t.size*1.1;u+=`<svg class="pele-icon" data-icon="${we(M.icon)}" x="${$(_)}" y="${$(l-t.size*.35-h/2)}" width="${$(h)}" height="${$(h)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${(c==null?void 0:c(M.icon))??""}</svg>`}else if(M.text!==""){let h=m||!A?` x="${$(_)}" y="${$(l)}"`:"";g+=`<tspan${h}${_t(M.style&~e)}>${Ee(M.text)}</tspan>`,A=!0}_+=M.width}l+=t.lineHeight}return`<text${wt(i,e)} xml:space="preserve">${g}</text>${u}`}function Ye(t){let s=rt(t);return s===t?t:s.replace(/</g,"<").replace(/>/g,">")}function Wt(t,s,l){return ft(t.direction)?ut(l,i=>Qe(t,s,l,i)):Qe(t,s,l,!1)}function Qe(t,s,l,i){let c=kt(t),r=l.fontSize??16,e=Math.round(r*.875),g=l.measurer??ct(l.fontFamily),u=l.padding??8,d=l.icons,m=new Map,_=[],A=[];c.nodes.forEach((w,n)=>m.set(w.id,n));let M=[],h=[],P=[],X=new Map,L=[];for(let w of c.edges){let n=m.get(w.start),b=m.get(w.end);if(n===void 0||b===void 0)continue;let T=le(w.label,!0,g,e,200),N;if(n===b){N={label:T,band:0,at:0};let I=X.get(n);I?I.push(N):X.set(n,[N])}L.push(N),P.push(w),h.push(T),M.push({src:n,dst:b,minlen:1,labelW:T.width>0?T.width+12:0,labelH:T.height>0?T.height+4:0,route:[],labelX:0,labelY:0})}let se=w=>{let n=w;for(let b=0;b<c.nodes.length;b++){let T=c.nodes[n].parentId,N=T===void 0?void 0:m.get(T);if(N===void 0)break;let I=c.nodes[N].dir;if(I)return I==="LR"||I==="RL";n=N}return t.direction==="LR"||t.direction==="RL"};for(let w=0;w<c.nodes.length;w++){let n=c.nodes[w],b=gt(n.cssStyles.length>0?n.cssCompiledStyles.concat(n.cssStyles):n.cssCompiledStyles),T=(b.bold?1:0)|(b.italic?2:0),N=b.fontSize??r,I=b.fontSize??e,z=b.fontSize??Math.round(r*.75),B=n.isGroup?le(n.label,!0,g,N,4e3,T):le(n.alias||n.label,!0,g,N,240,T),V=X.get(w)??Ft,x=V.length>0&&!n.isGroup&&se(w),S={node:n,style:b,label:B,w:0,h:0,headH:0,rows:[],cols:[],rowSize:I,keySize:z,below:x},R=0,H=0;for(let v of V)v.band=Math.max(Yt,x?v.label.width+12:v.label.height+6),H+=v.band,R=Math.max(R,x?v.label.height:v.label.width);let E=Math.max(Pe,x?H+8:0),C;if(n.isGroup)C=xe(0,0),C.isGroup=!0,C.dir=n.dir?Be(n.dir):void 0,C.padX=pe,C.padTop=S.label.height>0?S.label.height+16:pe,C.padBottom=pe,C.minW=Math.max(S.label.width+2*pe-12,Pe);else{let v=Math.max(B.height,Math.round(N*1.5));if(n.attributes.length===0)S.w=Math.max(B.width+2*Ze,E),S.h=Math.max(v+2*Gt,x?0:H+8);else{let be=Math.round(I*1.5),Q=[0,0,0,0];for(let Z of n.attributes){let he=[le(Ye(Z.type),!0,g,I,De,T),le(Ye(Z.name),!0,g,I,De,T),le(Z.keys.join(", "),!1,g,z,De,T),le(Ye(Z.comment),!0,g,I,zt,T)],de=be;for(let q=0;q<4;q++)he[q].width>Q[q]&&(Q[q]=he[q].width),he[q].height>de&&(de=he[q].height);S.rows.push({cells:he,h:de+Le}),S.h+=de+Le}let ce=0,J=0;for(let Z of Q)Z!==0&&(J+=Z+(ce>0?Ke:0),ce++);S.w=Math.max(J+2*ve,B.width+2*Ze,E);let oe=ce>0?(S.w-J-2*ve)/ce:0,ne=ve;for(let Z of Q)S.cols.push(ne),Z>0&&(ne+=Z+oe+Ke);S.headH=v+2*Bt,S.h+=S.headH}let W=V.length>0?2*(te+$e*.75+10+R):0;C=x?xe(S.w,S.h+W):xe(S.w+W,S.h)}C.seq=_.length,_.push(S),A.push(C)}c.nodes.forEach((w,n)=>{A[n].parent=w.parentId!==void 0?m.get(w.parentId)??-1:-1});let ae=at(A,M,i?"TB":Be(t.direction),{nodeSep:je(s,"nodeSpacing",vt),edgeSep:Lt,rankSep:je(s,"rankSpacing",Dt),portSep:24});Pt(M,A,_);let F=ae.width;for(let[w,n]of X){let b=A[w];if(!b.isGroup)continue;let T=0;for(let N of n)T=Math.max(T,N.label.width);F=Math.max(F,b.x+b.w/2+te+$e*.75+10+T)}let k=le(t.title,!1,g,r,4e3,1),D=k.height>0?k.height+12:0,f=Math.max(F,k.width),p=u+(f-F)/2,O=u+D;it(A,M,p,O);let G=Math.ceil(f+2*u),re=Math.ceil(ae.height+D+2*u),U=[],o=new Map,a=!1;for(let w of A)w.isGroup&&(a=!0);if(a)for(let w of M)lt(o,w.route);let y="",Y="";for(let w=0;w<_.length;w++){let n=_[w],b=A[w],T=n.node,N=yt(T.cssClasses.replace(/^default\s?/,""));if(b.isGroup){n.w=b.w,n.h=b.h;let C=b.x-b.w/2,v=b.y-b.h/2,W=st(b,n.label.width,o,pe);y+=`<g class="pele-cluster${N}" data-id="${we(T.id)}"><rect x="${$(C)}" y="${$(v)}" width="${$(b.w)}" height="${$(b.h)}" rx="${Se}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${n.style.shape}/>`+Oe(n.label,W,v+8+n.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${n.style.text}`,d)+"</g>";continue}let I=n.w,z=n.h,B=-I/2,V=-z/2,x=n.style.text,S=`x="${$(B)}" y="${$(V)}" width="${$(I)}" height="${$(z)}" rx="${Se}"`,R=Oe(n.label,0,n.rows.length>0?V+n.headH/2:0,` class="pele-label"${x}`,d),H=dt(T.alias||T.label);if(/ internal-link(?: |$)/.test(N+" ")&&R!==""&&l.links!==!1){let C=ot(nt(H),l)!==void 0,v=Ee(H);R=`<a class="internal-link"${C?` href="${v}"${ht(l)}`:""} data-href="${v}">${R}</a>`,U.push({id:T.label,href:H,internal:!0})}let E;if(n.rows.length===0)E=`<rect ${S}${Ve}${n.style.shape}/>`+R;else{let C=Math.round(n.rowSize*1.5),v=n.style.stroke?Ee(n.style.stroke):"var(--_b)",W="",be="",Q=V+n.headH;for(let J=0;J<n.rows.length;J++){let oe=n.rows[J];if(J%2===0){let Ae=`x="${$(B)}" width="${$(I)}"`;J===n.rows.length-1?W+=`<rect ${Ae} y="${$(Q)}" height="${$(oe.h)}" rx="${Se}"/><rect ${Ae} y="${$(Q)}" height="${$(oe.h/2)}"/>`:W+=`<rect ${Ae} y="${$(Q)}" height="${$(oe.h)}"/>`}let ne=Q+Le/2+C/2+n.rowSize*.35,[Z,he,de,q]=oe.cells;be+=_e(Z,B+n.cols[0],ne,` class="pele-er-type" fill="var(--_m)"${x}`,d)+_e(he,B+n.cols[1],ne,` class="pele-er-name"${x}`,d)+_e(de,B+n.cols[2],ne,` class="pele-er-keys" font-size="${n.keySize}" fill="var(--_m)"${x}`,d)+_e(q,B+n.cols[3],ne,` class="pele-er-comment" fill="var(--_m)"${x}`,d),Q+=oe.h}let ce=$(V+n.headH);E=`<rect ${S}${Ve}${n.style.shape}/><g class="pele-er-stripes" fill="var(--_bg)"${n.style.shape.includes("fill:")?' opacity="0.6"':""}>${W}</g><path class="pele-er-divider" d="M${$(B)},${ce}H${$(B+I)}" stroke="${v}"/><rect ${S} fill="none" stroke="var(--_b)"${n.style.line}/>`+R+`<g class="pele-er-attributes" font-size="${n.rowSize}">${be}</g>`}Y+=`<g class="pele-node pele-entity${N}" data-id="${we(T.label)}" transform="translate(${$(b.x)},${$(b.y)})">${E}</g>`}for(let[w,n]of X){let b=_[w],T=0;for(let z of n)T+=z.band;let N=Math.min(1,Math.max((b.below?b.w:b.h)-8,0)/T),I=-T*N/2;for(let z of n)z.band*=N,z.at=I+z.band/2,I+=z.band}let ie="",Me="";for(let w=0;w<M.length;w++){let n=M[w],b=P[w],T=h[w],N,I,z,B=L[w];if(B){let x=A[n.src],S=_[n.src],R=Math.max(Math.min(B.band/2-6,13),1),H=te+$e*.75+6;if(S.below){let E=x.x+B.at,C=x.y+S.h/2,v=$(C+te),W=$(C+te+$e);N=`M${$(E-R)},${$(C)}V${v}C${$(E-R)},${W} ${$(E+R)},${W} ${$(E+R)},${v}V${$(C)}`,I=ue(b.arrowTypeStart,E-R,C,0,-1),z=ue(b.arrowTypeEnd,E+R,C,0,-1),n.labelX=E,n.labelY=C+H+T.height/2}else{let E=x.x+S.w/2,C=x.y+B.at,v=$(E+te),W=$(E+te+$e);N=`M${$(E)},${$(C-R)}H${v}C${W},${$(C-R)} ${W},${$(C+R)} ${v},${$(C+R)}H${$(E)}`,I=ue(b.arrowTypeStart,E,C-R,-1,0),z=ue(b.arrowTypeEnd,E,C+R,-1,0),n.labelX=E+H+T.width/2,n.labelY=C}}else{let x=Xt(n.route);if(x.length<6)continue;qe(x,0,_[n.src],A[n.src]),qe(x,x.length-3,_[n.dst],A[n.dst]);let S=Math.abs(x[x.length-3]-x[0]),R=Math.abs(x[x.length-2]-x[1]),H=x.length===6&&(S<.01||R<.01||Math.hypot(S,R)<=3*te)?0:te,E=pt(x,void 0,H,H);N=H>0?`M${$(E.sx)},${$(E.sy)}L${E.d.slice(1)}L${$(E.ex)},${$(E.ey)}`:E.d,I=ue(b.arrowTypeStart,E.sx,E.sy,E.sdx,E.sdy),z=ue(b.arrowTypeEnd,E.ex,E.ey,E.edx,E.edy)}let V=b.pattern==="dashed";if(ie+=`<g class="pele-edge pele-er-${V?"non-identifying":"identifying"}" data-id="${we(b.id)}"><path d="${N}"${V?' stroke-dasharray="4 3"':""}/>`+I+z+"</g>",T.width>0){let x=n.labelX,S=n.labelY;Me+=$t(b.id,T,x,S,"",d)}}return{svg:bt("er",G,re,r,l,t,Oe(k,G/2,u+k.height/2,' class="pele-title" font-weight="var(--_tw)"')+(y?`<g class="pele-clusters">${y}</g>`:"")+(ie?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${ie}</g>`:"")+(Me?`<g class="pele-edge-labels" font-size="${e}">${Me}</g>`:"")+`<g class="pele-nodes">${Y}</g>`),width:G,height:re,links:U}}function Xt(t){let s=t.slice(0,3);for(let l=3;l<t.length;l+=3){let i=s.length-3,c=r=>Math.abs(s[i+r]-t[l+r])<.01&&Math.abs(t[l+r]-t[l+3+r])<.01;l+3<t.length&&(c(0)||c(1))||s.push(t[l],t[l+1],t[l+2])}return s}function Pt(t,s,l){let i=new Map,c=(r,e,g,u)=>{let d=s[r],m=e[g]-d.x,_=e[g+1]-d.y,A;if(Math.abs(Math.abs(_)-d.h/2)<.5)A=_<0?0:2;else if(Math.abs(Math.abs(m)-d.w/2)<.5)A=m<0?3:1;else return;let M=r*4+A,h={route:e,at:g,toward:e[u+(A&1?1:0)]},P=i.get(M);P?P.push(h):i.set(M,[h])};for(let r of t){let e=r.route.length-3;r.src===r.dst||e<3||(c(r.src,r.route,0,3),c(r.dst,r.route,e,e-3))}for(let[r,e]of i){if(e.length<2)continue;let g=r>>2,u=(r&1)===1,d=s[g].isGroup?s[g]:l[g],m=u?d.h:d.w,_=Math.max(Math.min(Ut,(m-2*Ht)/(e.length-1)),0),A=u?s[g].y:s[g].x;e.sort((M,h)=>M.toward-h.toward);for(let M=0;M<e.length;M++)e[M].route[e[M].at+(u?1:0)]=A+(M-(e.length-1)/2)*_}}function qe(t,s,l,i){if(i.isGroup)return;let c=t[s]-i.x,r=t[s+1]-i.y;i.w!==l.w&&Math.abs(Math.abs(c)-i.w/2)<.5&&(t[s]-=Math.sign(c)*(i.w-l.w)/2),i.h!==l.h&&Math.abs(Math.abs(r)-i.h/2)<.5&&(t[s+1]-=Math.sign(r)*(i.h-l.h)/2)}var lr={type:"er",parse(t,s,l){let i=new Tt;return l&&(i.title=l),It(t,i),i},render:Wt};export{lr as er};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function f(e,i,r,d){let t=d(i,!1),n=e.maxWidth;if(n===void 0||!(n>0)||t.width<=n)return t;let u=Math.min(r,i),a=i;t=d(a,!0);for(let h=0;h<3&&t.width>n&&a>u;h++)a=Math.max(u,a-(t.width-n)),t=d(a,!0);return t}function l(e){let i=e.maxWidth;return i!==void 0&&i>0?Math.max(80,i-2*(e.padding??8)):4e3}function m(e,i,r,d=0){let t=e.maxWidth;return t===void 0||!(t>0)?i:Math.max(Math.min(r,i),Math.min(i,t-d))}var o=640;function c(e,i){let r=i(!1),d=e.maxWidth;if(e.autoDirection===!1||d===void 0||!(d>0)||r.width<=d)return r;let t=e.directionBreakpoint;if(d>=(t!==void 0&&t>0?t:o))return r;let n=i(!0);return n.width<r.width?n:r}function w(e){return e==="LR"||e==="RL"}function x(e,i){let r=i(!1),d=e.maxWidth;if(d===void 0||!(d>0)||r.width<=d)return r;let t=i(!0);return t.width<r.width?t:r}export{c,f,l as h,m as l,w as m,x as p};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var he=Object.defineProperty;var fe=(t,l,n)=>l in t?he(t,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[l]=n;var D=(t,l,n)=>fe(t,typeof l!="symbol"?l+"":l,n);import{L as ge,i as ue,H as ce,x as de}from"./lazy-CKqR1774.js";import{f as ye,h as $e}from"./DKTLEL5E-B7ILCVTH.js";import{y as X,x as k,m as ee,b as G,_ as pe,$ as me,f as ke,g as xe}from"./RZSVICHU-BiwjruZZ.js";import"./index-392ivruk.js";var Ee=class{constructor(){D(this,"type","sankey");D(this,"nodes",[]);D(this,"links",[]);D(this,"title");D(this,"accTitle");D(this,"accDescr");D(this,"lookup",new Map)}findOrCreateNode(t){let l=this.lookup.get(t);return l===void 0&&(l={id:t,index:this.nodes.length},this.lookup.set(t,l),this.nodes.push(l)),l}addLink(t,l,n){this.links.push({source:t,target:l,value:n})}},q=["$end","STUCK","SANKEY","NEWLINE","COMMA","DQUOTE","NON_ESCAPED_TEXT","ESCAPED_TEXT","EOF"];function te(t){return t>=32&&t<=126&&t!==34&&t!==44}function ve(t){let l=t.length,n=[],a=[],g=[],h=[],y=0,s=0,m=(u,E,$)=>{n.push(u),a.push(t.slice(E,$)),g.push(E),s=$},x=u=>t.slice(s,s+u.length).toLowerCase()===u&&!ue(t.charCodeAt(s+u.length));for(;s<l;){let u=t.charCodeAt(s),E=s,$=s;if(y===2){if(u===34&&t.charCodeAt(s+1)!==34){h.length>0&&(y=h.pop()),m(5,s,s+1);continue}for(;$<l;){let f=t.charCodeAt($);if(te(f)||f===44||f===13||f===10)$++;else if(f===34&&t.charCodeAt($+1)===34)$+=2;else break}m(7,s,$)}else{if(y===0&&(u|32)===115){let f=x("sankey-beta")?11:x("sankey")?6:0;if(f>0){h.push(y),y=1,m(2,s,s+f);continue}}if(u===10||u===13&&t.charCodeAt(s+1)===10){m(3,s,u===10?s+1:s+2);continue}if(u===44){m(4,s,s+1);continue}if(u===34){h.push(y),y=2,m(5,s,s+1);continue}for(;$<l&&te(t.charCodeAt($));)$++;m(6,s,$)}if($===E)return m(1,s,s),{types:n,texts:a,starts:g}}return m(y===2?7:8,l,l),m(0,l,l),{types:n,texts:a,starts:g}}var Ae=/[\n\r]+/g;function le(t){return t===10||t===13?!1:t<128?t===32||t===9||t===11||t===12:t===160||t===5760||t>=8192&&t<=8202||t===8232||t===8233||t===8239||t===8287||t===12288||t===65279}function Me(t){let l=0,n=t.length;for(;l<n&&le(t.charCodeAt(l));)l++;for(;n>l&&le(t.charCodeAt(n-1));)n--;return t.slice(l,n).replace(Ae,`
|
|
2
|
+
`).trim()}function we(t,l){let{types:n,texts:a,starts:g}=ve(t),h=0,y=u=>{let E=n[h],$=E===1?q[n[h-1]]:q[E];throw ge("sankey",t,g[h],`Expecting ${u}, got '${$}'`)},s=(u,E="")=>{n[h]!==u&&y(`'${q[u]}'${E}`),h++},m=()=>{if(n[h]===6)return a[h++];n[h]!==5&&y("'DQUOTE', 'NON_ESCAPED_TEXT'"),h++,n[h]!==7&&y("'ESCAPED_TEXT'");let u=a[h++];return s(5),u},x=()=>m().trim().replaceAll('""','"');for(s(2),s(3);;){let u=x();s(4,", 'NEWLINE', 'EOF'");let E=x();s(4,", 'NEWLINE', 'EOF'");let $=m(),f=l.findOrCreateNode(u),F=l.findOrCreateNode(E);if(l.addLink(f,F,parseFloat($.trim())),n[h]!==3)break;h++}n[h]===8&&h++,n[h]!==0&&y("'NEWLINE', 'EOF'")}var Ce=6;function B(t,l){if(t.length>8){t.sort(l);return}for(let n=1;n<t.length;n++){let a=t[n],g=n-1;for(;g>=0&&l(t[g],a)>0;)t[g+1]=t[g],g--;t[g+1]=a}}function be(t,l){let n=t.nodes.length,a=t.links.map(e=>({source:e.source.index,target:e.target.index,value:Number.isFinite(e.value)&&e.value>0?e.value:0,thickness:0,sourceY:0,targetY:0})),g=[],h=[];for(let e=0;e<n;e++)g.push([]),h.push([]);a.forEach((e,r)=>{g[e.source].push(r),h[e.target].push(r)});let y=new Int32Array(n),s=new Int32Array(n),m=[];for(let e=0;e<n;e++)s[e]=h[e].length,s[e]===0&&m.push(e);for(let e=0;e<m.length;e++){let r=m[e];for(let i of g[r]){let c=a[i].target;y[c]<y[r]+1&&(y[c]=y[r]+1),--s[c]===0&&m.push(c)}}if(m.length<n){let e=0;for(;s[e]===0;)e++;let r=new Uint8Array(n);for(;r[e]===0;){r[e]=1;for(let i of h[e])if(s[a[i].source]>0){e=a[i].source;break}}throw new de(`Sankey diagrams cannot have circular links, and "${t.nodes[e].id}" is part of one.`,"semantic",{type:"sankey"})}let x=1;for(let e=0;e<n;e++)y[e]+1>x&&(x=y[e]+1);let u=new Int32Array(n);for(let e=n-1;e>=0;e--){let r=m[e];for(let i of g[r])u[r]<u[a[i].target]+1&&(u[r]=u[a[i].target]+1)}let E=0;for(let e of a)e.value>E&&(E=e.value);let $=E>0?1/E:0,f=[],F=new Float64Array(n),M=[];for(let e=0;e<x;e++)M.push([]);let I=x>1?(l.width-l.nodeWidth)/(x-1):0;for(let e=0;e<n;e++){let r;if(l.alignment==="left")r=y[e];else if(l.alignment==="right")r=x-1-u[e];else if(l.alignment==="center"){if(r=y[e],h[e].length===0&&g[e].length>0){r=x;for(let d of g[e])y[a[d].target]-1<r&&(r=y[a[d].target]-1)}}else r=g[e].length>0?y[e]:x-1;let i=0,c=0,o=0,p=0;for(let d of h[e])i+=a[d].value*$,o+=a[d].value;for(let d of g[e])c+=a[d].value*$,p+=a[d].value;F[e]=Math.max(i,c),f.push({layer:r,value:Math.max(o,p),x:r*I,y:0,height:0}),M[r].push(e)}let W=1;for(let e of M)e.length>W&&(W=e.length);let Y=W>1?Math.min(l.nodePadding,l.height/(W-1)):l.nodePadding,w=1/0;for(let e of M){let r=0;for(let i of e)r+=F[i];r>0&&(w=Math.min(w,(l.height-(e.length-1)*Y)/r))}(!Number.isFinite(w)||w<0)&&(w=0);let P=Math.max(0,l.labelHeight-Y),j=e=>{for(let r of M){let i=(r.length-1)*Y;for(let c of r)i+=Math.max(F[c]*e,P);if(i>l.height+1e-6)return!1}return!0};if(P>0&&!j(w))if(j(0)){let e=0;for(let r=0;r<40;r++){let i=(e+w)/2;j(i)?e=i:w=i}w=e}else P=0;let A=new Float64Array(n);for(let e of a)e.thickness=e.value*$*w;for(let e of M){let r=0;for(let c of e)f[c].height=F[c]*w,A[c]=Math.max(0,P-f[c].height)/2,f[c].y=r+A[c],r+=f[c].height+2*A[c]+Y;let i=(l.height-r+Y)/(e.length+1);e.forEach((c,o)=>f[c].y+=i*(o+1))}let b=e=>f[e].y+f[e].height/2,S=new Float64Array(a.length),_=new Float64Array(a.length),K=(e,r)=>b(a[e].target)-b(a[r].target)||e-r,V=(e,r)=>b(a[e].source)-b(a[r].source)||e-r,R=(e,r)=>b(e)-b(r)||e-r,H=e=>{let r=0;B(g[e],K);for(let i of g[e])S[i]=r+a[i].thickness/2,r+=a[i].thickness},L=e=>{let r=0;B(h[e],V);for(let i of h[e])_[i]=r+a[i].thickness/2,r+=a[i].thickness},U=()=>{for(let e=0;e<n;e++)H(e),L(e)},z=(e,r,i)=>{for(let o of e){let p=i?h[o]:g[o];if(p.length===0)continue;i?L(o):H(o);let d=0,O=0,C=0;for(let v of p){let T=i?f[a[v].source].y+S[v]-_[v]:f[a[v].target].y+_[v]-S[v];d+=T*a[v].thickness,O+=a[v].thickness,C+=b(i?a[v].source:a[v].target)-f[o].height/2}let N=O>0?d/O:C/p.length;f[o].y+=(N-f[o].y)*r}B(e,R);let c=0;for(let o of e)f[o].y-A[o]<c&&(f[o].y=c+A[o]),c=f[o].y+f[o].height+A[o]+Y;c=l.height;for(let o=e.length-1;o>=0;o--){let p=e[o];f[p].y+f[p].height+A[p]>c&&(f[p].y=c-f[p].height-A[p]),c=f[p].y-A[p]-Y}};U();for(let e=0;e<Ce;e++){let r=Math.pow(.99,e);for(let i=x-2;i>=0;i--)z(M[i],r,!1);U();for(let i=1;i<x;i++)z(M[i],r,!0);U()}for(let e=0;e<a.length;e++)a[e].sourceY=f[a[e].source].y+S[e],a[e].targetY=f[a[e].target].y+_[e];return{nodes:f,links:a}}var ne=6,Ne=15;function ie(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Q(t,l,n,a,g){let h=t[l];return typeof h=="number"&&h>=a?Math.min(h,g):n}function ae(t,l){let n=t[l];return typeof n=="string"||typeof n=="number"&&Number.isFinite(n)?String(n):""}function re(t){return Math.abs(t)<1e15?Math.round(t*100)/100:t}function oe(t){return typeof t=="string"?xe([`fill:${t}`]).shape:""}function Ye(t,l,n){let a=ie(l.sankey)?l.sankey:{};return ye(n,Q(a,"width",600,1,1e4),160,g=>Oe(t,a,n,g))}function Oe(t,l,n,a){let g=n.fontSize??16,h=Math.round(g*.875),y=n.measurer??ce(n.fontFamily),s=n.padding??8,m=Q(l,"height",400,1,1e4),x=Math.min(Q(l,"nodeWidth",10,1,200),a),u=l.showValues!==!1,E=ae(l,"prefix"),$=ae(l,"suffix"),f=l.labelStyle==="outlined",F=l.nodeAlignment==="left"||l.nodeAlignment==="right"||l.nodeAlignment==="center"?l.nodeAlignment:"justify",M=typeof l.linkColor=="string"?l.linkColor:"gradient",{nodes:I,links:W}=be(t,{width:a,height:m,nodeWidth:x,nodePadding:Q(l,"nodePadding",12,0,200)+(u?Ne:0),labelHeight:h*1.15,alignment:F}),Y=new Map;if(ie(l.nodeColors))for(let[o,p]of Object.entries(l.nodeColors)){let d=oe(p);d&&Y.set(o,d)}let w=o=>Y.get(t.nodes[o].id)??"",P=0,j=0;I.forEach(o=>{o.value>j&&(j=o.value,P=o.layer)});let A=0,b=a,S=0,_=m,K="",V="";I.forEach((o,p)=>{let d=t.nodes[p].id,O=Math.max(o.height,1);V+=`<rect class="pele-sankey-node" data-id="${X(d)}" x="${k(o.x)}" y="${k(o.y)}" width="${k(x)}" height="${k(O)}" rx="${k(Math.min(2,O/2))}" fill="${ee(p)}"${w(p)}/>`;let C=u?`${E}${re(o.value)}${$}`:"",N=f?o.layer>=P:o.x<a/2,v=y.width(C?`${d} ${C}`:d,h,0),T=N?o.x+x+ne:o.x-ne,Z=o.y+o.height/2;A=Math.min(A,N?T:T-v),b=Math.max(b,N?T+v:T),S=Math.min(S,Z-h*.75),_=Math.max(_,Z+h*.75);let J=` x="${k(T)}" y="${k(Z+h*.35)}" text-anchor="${N?"start":"end"}"`,se=G(d)+(C?` <tspan class="pele-sankey-value" fill="var(--_m)">${G(C)}</tspan>`:"");K+=`<g class="pele-label" data-id="${X(d)}">`+(f?`<text${J} fill="none" stroke="var(--_bg)" stroke-width="3" stroke-linejoin="round">${G(d)}${C?" "+G(C):""}</text>`:"")+`<text${J}>${se}</text></g>`});let R=M==="gradient"||M==="source"||M==="target"?"":oe(M),H="";for(let o of W){let p=M==="target"?o.target:o.source,d=Math.max(o.thickness,1)/2,O=I[o.source].x+x,C=I[o.target].x,N=k((O+C)/2),v=X(t.nodes[o.source].id),T=X(t.nodes[o.target].id);H+=`<path class="pele-sankey-link" data-id="${v}->${T}" d="M${k(O)},${k(o.sourceY-d)}C${N},${k(o.sourceY-d)} ${N},${k(o.targetY-d)} ${k(C)},${k(o.targetY-d)}L${k(C)},${k(o.targetY+d)}C${N},${k(o.targetY+d)} ${N},${k(o.sourceY+d)} ${k(O)},${k(o.sourceY+d)}Z" fill="${ee(p)}"${R||w(p)}><title>${v} → ${T}: ${X(E)}${re(o.value)}${X($)}</title></path>`}let L=pe(t.title,!1,y,g,$e(n),1),U=L.height>0?L.height+12:0,z=Math.max(b-A,L.width),e=s-A+(z-(b-A))/2,r=s+U-S,i=Math.ceil(z+2*s),c=Math.ceil(_-S+U+2*s);return{svg:me("sankey",i,c,g,n,t,ke(L,i/2,s+L.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${k(e)},${k(r)})"><g class="pele-sankey-links" fill-opacity="0.4">${H}</g><g class="pele-sankey-nodes">${V}</g><g class="pele-labels" font-size="${h}">${K}</g></g>`),width:i,height:c,links:[]}}var De={type:"sankey",parse(t,l,n){let a=new Ee;return n&&(a.title=n),we(Me(t),a),a},render:Ye};export{De as sankey};
|