@layers-app/editor 0.7.47 → 0.7.49
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/README.md +830 -830
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -4
- package/dist/layers.2sxk2h9p.js +423 -0
- package/dist/layers.3fhqDXGQ.js +32 -0
- package/dist/layers.52famHy6.js +1 -0
- package/dist/layers.6LJL3iMX.js +960 -0
- package/dist/layers.6lVF0vjp.js +806 -0
- package/dist/layers.6vQhCrMO.js +42 -0
- package/dist/layers.7JqFgE4-.js +15 -0
- package/dist/layers.8jPh7nZ7.js +10 -0
- package/dist/layers.9YYn67yF.js +34 -0
- package/dist/layers.9o0Jdg-U.js +36 -0
- package/dist/layers.9pNaFvaX.js +1 -0
- package/dist/layers.B0L7owR9.js +1286 -0
- package/dist/layers.B124trWB.js +40 -0
- package/dist/layers.B19hGmey.js +1 -0
- package/dist/layers.B3D4g2HH.js +1 -0
- package/dist/layers.B4bJKqOt.js +1 -0
- package/dist/layers.B50R5EaK.js +41 -0
- package/dist/layers.B74E_Mhu.js +6 -0
- package/dist/layers.B7K7JjK6.js +1510 -0
- package/dist/layers.B7c71bAt.js +32 -0
- package/dist/layers.B96L1hG2.js +11 -0
- package/dist/layers.B9Rx2foX.js +805 -0
- package/dist/layers.BAtv1CM7.js +1 -0
- package/dist/layers.BB461pvX.js +1 -0
- package/dist/layers.BBix4GLX.js +76 -0
- package/dist/layers.BIeVwYKL.js +1 -0
- package/dist/layers.BJDrjORS.js +244 -0
- package/dist/layers.BKyEhTMV.js +41 -0
- package/dist/layers.BLUQsSE-.js +9 -0
- package/dist/layers.BLd2spTm.js +1 -0
- package/dist/layers.BNuBcDIb.js +35 -0
- package/dist/layers.BPHAY1-9.js +22 -0
- package/dist/layers.BQ2I5acy.js +9 -0
- package/dist/layers.BRWyWzwh.js +10 -0
- package/dist/layers.BS6VvqxC.js +40 -0
- package/dist/layers.BSTBZrFn.js +1 -0
- package/dist/layers.BTbPm8pR.js +39 -0
- package/dist/layers.BV-egvVp.js +8 -0
- package/dist/layers.BVr10oU3.js +9 -0
- package/dist/layers.BWw1mK7X.js +10 -0
- package/dist/layers.BXIUEFQw.js +37 -0
- package/dist/layers.BXS2uNb0.js +40 -0
- package/dist/layers.BaGJS1l7.js +40 -0
- package/dist/layers.BbCfEXyj.js +55 -0
- package/dist/layers.Bc8eVF2x.js +10 -0
- package/dist/layers.BdYtCOnE.js +11 -0
- package/dist/layers.Be6CBZHC.js +2 -0
- package/dist/layers.BeKf3u57.js +5 -0
- package/dist/layers.BgQO_ULY.js +207 -0
- package/dist/layers.BhDueLVc.js +40 -0
- package/dist/layers.BhDyoOpp.js +1089 -0
- package/dist/layers.BiakMAVz.js +36 -0
- package/dist/layers.BpilXLfW.js +6 -0
- package/dist/layers.Bpw9JnCv.js +52 -0
- package/dist/layers.Bq2f36dx.js +1 -0
- package/dist/layers.BsA7eoz8.js +2966 -0
- package/dist/layers.BsxmtGhi.js +4 -0
- package/dist/layers.BszXwlqm.js +1 -0
- package/dist/layers.Bt2v9ZR3.js +44 -0
- package/dist/layers.BtKGefaP.js +39 -0
- package/dist/layers.BtLFUN9L.js +33 -0
- package/dist/layers.BtTn3DWi.js +1 -0
- package/dist/layers.BtWDGtLj.js +160 -0
- package/dist/layers.Bw7qkQsX.js +8 -0
- package/dist/layers.BwxPrRZD.js +4 -0
- package/dist/layers.Bxcxrsy_.js +1583 -0
- package/dist/layers.C-XVPziT.js +1 -0
- package/dist/layers.C3E0dLDD.js +37 -0
- package/dist/layers.C3ctqQ_d.js +1225 -0
- package/dist/layers.C57RR3BP.js +5 -0
- package/dist/layers.C5TvEQpd.js +4 -0
- package/dist/layers.C5XJmJhy.js +794 -0
- package/dist/layers.C5XRUPsP.js +504 -0
- package/dist/layers.C6lFx_9o.js +32 -0
- package/dist/layers.C6vIa6gn.js +11 -0
- package/dist/layers.C8_lu5UH.js +23 -0
- package/dist/layers.CAXlMwAW.js +7 -0
- package/dist/layers.CBwlQeze.js +38 -0
- package/dist/layers.CCVxi5hB.js +1 -0
- package/dist/layers.CDVEdgbo.js +10 -0
- package/dist/layers.CEWorf-C.js +7 -0
- package/dist/layers.CFHq5644.js +10 -0
- package/dist/layers.CG7r3vnU.js +41 -0
- package/dist/layers.CGJlI-Xk.js +37 -0
- package/dist/layers.CHZsXQcr.js +1 -0
- package/dist/layers.CHh5bEfC.js +41 -0
- package/dist/layers.CI55as3L.js +205 -0
- package/dist/layers.CIleDfVS.js +21941 -0
- package/dist/layers.CImHWuWy.js +1 -0
- package/dist/layers.CJaUnfvI.js +122 -0
- package/dist/layers.CKmkJeNx.js +8 -0
- package/dist/layers.CLCDYoNw.js +40 -0
- package/dist/layers.CLLW_-MM.js +1 -0
- package/dist/{layers.Hq0pIRX3.js → layers.CLSq6d5G.js} +21 -21
- package/dist/layers.CPK-8aJ9.js +8 -0
- package/dist/layers.CQrT2kiR.js +4 -0
- package/dist/layers.CROEZPe3.js +1 -0
- package/dist/layers.CTizu7k3.js +1 -0
- package/dist/layers.CTtXyJIC.js +51 -0
- package/dist/layers.CUFmR0uO.js +2238 -0
- package/dist/layers.CUQCdPfS.js +1 -0
- package/dist/layers.CXwIo_E2.js +934 -0
- package/dist/layers.C_IvrzZ3.js +7 -0
- package/dist/layers.Cbh8488l.js +9 -0
- package/dist/layers.CeWHZgFl.js +223 -0
- package/dist/layers.ChByNJR4.js +1 -0
- package/dist/layers.CiayK_jX.js +7 -0
- package/dist/layers.CiloWOji.js +2 -0
- package/dist/layers.CivvhzLf.js +11 -0
- package/dist/layers.CjKkiQ-5.js +40 -0
- package/dist/layers.Cm1JRCTb.js +189 -0
- package/dist/layers.Cn0EJP31.js +1126 -0
- package/dist/layers.CoUMygdc.js +9 -0
- package/dist/layers.CqJ3U1Dv.js +1 -0
- package/dist/layers.CqVTtuYm.js +6 -0
- package/dist/layers.CrTPxY8M.js +40 -0
- package/dist/layers.CrhlCVRH.js +8 -0
- package/dist/layers.CvKfVfgR.js +41 -0
- package/dist/layers.Cw1UVYRF.js +39 -0
- package/dist/{layers.Cfvta__C.js → layers.Cw6AQ1zH.js} +1 -1
- package/dist/layers.Cw76BJN2.js +32 -0
- package/dist/layers.CxuRP1lw.js +6 -0
- package/dist/layers.Cyu04oeV.js +7 -0
- package/dist/layers.Cyzu9PKQ.js +1 -0
- package/dist/layers.CzYE0Ooc.js +42 -0
- package/dist/layers.D0zn4_Mx.js +1 -0
- package/dist/layers.D16HelAS.js +213 -0
- package/dist/layers.D1BZqHRU.js +38 -0
- package/dist/layers.D2PgPKOo.js +13 -0
- package/dist/layers.D4T8fTcj.js +1223 -0
- package/dist/layers.D5Kikhmz.js +295 -0
- package/dist/layers.D5vKDO3Z.js +1 -0
- package/dist/layers.D634RCv2.js +6 -0
- package/dist/layers.D6fxuXiV.js +39 -0
- package/dist/layers.D77Lwa5B.js +10 -0
- package/dist/layers.D7jGxypv.js +8 -0
- package/dist/layers.D9Aq-VH-.js +36 -0
- package/dist/layers.DAN-8W9x.js +48149 -0
- package/dist/layers.DB59_4ZT.js +118 -0
- package/dist/layers.DBKCfxsn.js +7 -0
- package/dist/layers.DC44PHoe.js +1 -0
- package/dist/layers.DDIKIPEl.js +425 -0
- package/dist/layers.DDNSbyH9.js +11 -0
- package/dist/layers.DE-1MOCW.js +6 -0
- package/dist/layers.DEJLOhUD.js +5 -0
- package/dist/layers.DF5Jf3M9.js +9 -0
- package/dist/layers.DFEtOzCz.js +37 -0
- package/dist/layers.DFiKSx4e.js +9 -0
- package/dist/layers.DGwBwWGl.js +373 -0
- package/dist/layers.DJtJoK2T.js +8 -0
- package/dist/layers.DJugFK-r.js +129 -0
- package/dist/layers.DJuxVMes.js +39 -0
- package/dist/layers.DLOvj2ew.js +70 -0
- package/dist/layers.DLmk4e9A.js +8 -0
- package/dist/layers.DLwuMfdd.js +84 -0
- package/dist/layers.DMRUFJsX.js +8 -0
- package/dist/layers.DMkBISW1.js +1 -0
- package/dist/layers.DN9HoVxI.js +18 -0
- package/dist/layers.DO0X6c0O.js +323 -0
- package/dist/layers.DOrgOHBr.js +1 -0
- package/dist/layers.DPlZKJgj.js +437 -0
- package/dist/layers.DQxhNW5R.js +9 -0
- package/dist/layers.DReq7_oC.js +296 -0
- package/dist/layers.DT9rsUtv.js +198 -0
- package/dist/layers.DU05EaWA.js +907 -0
- package/dist/layers.DUEmMZLx.js +41 -0
- package/dist/layers.DWAsYusl.js +116 -0
- package/dist/layers.DWYk3UK6.js +40 -0
- package/dist/layers.DWhMR9ZJ.js +139 -0
- package/dist/layers.DXS1j64l.js +271 -0
- package/dist/layers.DYURS4FP.js +84 -0
- package/dist/layers.D_RUDzWv.js +21620 -0
- package/dist/layers.DbVdGKld.js +1 -0
- package/dist/layers.DbaKVP5e.js +1 -0
- package/dist/layers.DcAdQwtK.js +7 -0
- package/dist/layers.DcMkjKaG.js +6 -0
- package/dist/layers.DgvrVyqi.js +96 -0
- package/dist/layers.Dhq37bku.js +10 -0
- package/dist/layers.DjUOC4st.js +16 -0
- package/dist/layers.DjkEwMtb.js +796 -0
- package/dist/layers.Dl8xQWMG.js +39 -0
- package/dist/layers.DlufDKX8.js +139 -0
- package/dist/layers.DnJXYiZP.js +40 -0
- package/dist/layers.DnXs_pNB.js +39 -0
- package/dist/layers.Do15drP1.js +3 -0
- package/dist/layers.DokfH0hd.js +39 -0
- package/dist/layers.DpNZa-jp.js +9 -0
- package/dist/layers.Dr3MCGOM.js +1088 -0
- package/dist/layers.DrQ8hvnX.js +5 -0
- package/dist/layers.DsptZoFe.js +42 -0
- package/dist/layers.DtD3skoW.js +1619 -0
- package/dist/layers.Dtms4fW5.js +5 -0
- package/dist/layers.Du0f9MLd.js +42 -0
- package/dist/layers.DuZA4Xas.js +32 -0
- package/dist/layers.Dwh8gx1i.js +1 -0
- package/dist/layers.DwizeusR.js +9 -0
- package/dist/layers.DxA6ocdw.js +70 -0
- package/dist/layers.Dy1naDTQ.js +14 -0
- package/dist/layers.DyL1tlRE.js +276 -0
- package/dist/layers.DyRolv1I.js +8 -0
- package/dist/layers.DzFqkluR.js +2482 -0
- package/dist/layers.DzSq4y89.js +14 -0
- package/dist/layers.Gsg2l9lj.js +1 -0
- package/dist/layers.H6NhhT0Z.js +35 -0
- package/dist/layers.JWCLFILJ.js +1 -0
- package/dist/{layers.BtvuN20E.js → layers.MmOx3Q5y.js} +10159 -9401
- package/dist/layers.NYVxQ2J0.js +38 -0
- package/dist/layers.Oz9AvXqT.js +772 -0
- package/dist/layers.R8mPlCA0.js +261 -0
- package/dist/layers.TMqEBNpX.js +1 -0
- package/dist/layers.Te010ICg.js +8583 -0
- package/dist/layers.VN0Yeq2V.js +1 -0
- package/dist/layers.WnvKMTKL.js +61 -0
- package/dist/layers.WxQ6m-UP.js +36 -0
- package/dist/layers.X0_Gx5lN.js +42 -0
- package/dist/layers.Y9FRICz5.js +10 -0
- package/dist/layers.ZGwk_KWb.js +7 -0
- package/dist/layers.b0h5ZBmD.js +61 -0
- package/dist/{layers.CsQlovyR.js → layers.b9B2NY7n.js} +1950 -2191
- package/dist/layers.blh6SXpL.js +8 -0
- package/dist/layers.d5j1lEFQ.js +2 -0
- package/dist/layers.eGX8dSo1.js +1 -0
- package/dist/layers.eIIS5NDC.js +1 -0
- package/dist/layers.fxqbBEns.js +35 -0
- package/dist/layers.hAT_4n_i.js +6 -0
- package/dist/layers.jPwVCOt0.js +39 -0
- package/dist/layers.jgfr1mFT.js +65 -0
- package/dist/layers.lCpg7dOn.js +21 -0
- package/dist/layers.lMAyLkuo.js +1 -0
- package/dist/layers.lX16IRwc.js +10 -0
- package/dist/layers.oFuJymzn.js +41 -0
- package/dist/layers.p872qi0O.js +1034 -0
- package/dist/layers.pHpJOB6N.js +1 -0
- package/dist/layers.pgbpWh46.js +84 -0
- package/dist/layers.pixPTfNv.js +33 -0
- package/dist/layers.rmoiicvu.js +41 -0
- package/dist/layers.rvTNl4lr.js +7 -0
- package/dist/layers.ssiSYLMt.js +32 -0
- package/dist/layers.xcmbrsYu.js +257 -0
- package/dist/layers.xtkyz0Y7.js +1268 -0
- package/package.json +2 -2
- package/dist/layers.B88sQYuh.js +0 -297
- package/dist/layers.BgMykHnn.js +0 -154
- package/dist/layers.Ct1ojjl3.js +0 -1
- package/dist/layers.JT_kEFH5.js +0 -129
- package/dist/layers.NW1lST7i.js +0 -1
- package/dist/layers.pwc3O6Es.js +0 -261
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { jsxs as E, Fragment as T, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as N, useEffect as d, useState as C, useCallback as f } from "react";
|
|
3
|
+
import { createPortal as U } from "react-dom";
|
|
4
|
+
import { k as P, d as S, c as $, l as V, H as X, n as Y, O as J } from "./layers.MmOx3Q5y.js";
|
|
5
|
+
import { useLexicalComposerContext as W } from "@lexical/react/LexicalComposerContext";
|
|
6
|
+
import { LexicalErrorBoundary as _ } from "@lexical/react/LexicalErrorBoundary";
|
|
7
|
+
import { useLexicalEditable as Z } from "@lexical/react/useLexicalEditable";
|
|
8
|
+
import { Textarea as K, Group as ee, Button as H } from "@mantine/core";
|
|
9
|
+
import { $getNodeByKey as v, COMMAND_PRIORITY_EDITOR as te } from "lexical";
|
|
10
|
+
import ne from "./layers.b9B2NY7n.js";
|
|
11
|
+
function w({
|
|
12
|
+
equation: r,
|
|
13
|
+
inline: a,
|
|
14
|
+
onDoubleClick: s
|
|
15
|
+
}) {
|
|
16
|
+
const n = N(null);
|
|
17
|
+
return d(() => {
|
|
18
|
+
const l = n.current;
|
|
19
|
+
l !== null && ne.render(r, l, {
|
|
20
|
+
displayMode: !a,
|
|
21
|
+
errorColor: "#cc0000",
|
|
22
|
+
output: "html",
|
|
23
|
+
strict: "warn",
|
|
24
|
+
throwOnError: !1,
|
|
25
|
+
trust: !1
|
|
26
|
+
});
|
|
27
|
+
}, [r, a]), /* @__PURE__ */ E(T, { children: [
|
|
28
|
+
/* @__PURE__ */ o(
|
|
29
|
+
"img",
|
|
30
|
+
{
|
|
31
|
+
src: "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
|
|
32
|
+
width: 0,
|
|
33
|
+
height: 0,
|
|
34
|
+
alt: ""
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
/* @__PURE__ */ o(
|
|
38
|
+
"span",
|
|
39
|
+
{
|
|
40
|
+
role: "button",
|
|
41
|
+
tabIndex: -1,
|
|
42
|
+
onDoubleClick: s,
|
|
43
|
+
ref: n
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
/* @__PURE__ */ o(
|
|
47
|
+
"img",
|
|
48
|
+
{
|
|
49
|
+
src: "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
|
|
50
|
+
width: 0,
|
|
51
|
+
height: 0,
|
|
52
|
+
alt: ""
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
] });
|
|
56
|
+
}
|
|
57
|
+
let M = !1;
|
|
58
|
+
const I = /* @__PURE__ */ new Map();
|
|
59
|
+
function oe(r) {
|
|
60
|
+
M || (M = !0, r.registerCommand(
|
|
61
|
+
J,
|
|
62
|
+
(a) => {
|
|
63
|
+
const s = I.get(a);
|
|
64
|
+
return s ? (s(), !0) : !1;
|
|
65
|
+
},
|
|
66
|
+
te
|
|
67
|
+
));
|
|
68
|
+
}
|
|
69
|
+
function pe({
|
|
70
|
+
equation: r,
|
|
71
|
+
inline: a,
|
|
72
|
+
nodeKey: s
|
|
73
|
+
}) {
|
|
74
|
+
const [n] = W(), l = Z(), p = N(null), B = N(null), [m, x] = C(r), [c, u] = C(!1), [O, F] = C({ top: 0, left: 0 }), [j, D] = C(!1), b = f(() => {
|
|
75
|
+
const e = p.current;
|
|
76
|
+
if (!e) return;
|
|
77
|
+
const i = (e.closest(
|
|
78
|
+
".editor-equation"
|
|
79
|
+
) || e).getBoundingClientRect();
|
|
80
|
+
F({
|
|
81
|
+
top: i.bottom + 18,
|
|
82
|
+
left: i.left
|
|
83
|
+
}), D(!0);
|
|
84
|
+
}, []);
|
|
85
|
+
d(() => {
|
|
86
|
+
oe(n);
|
|
87
|
+
}, [n]), d(() => {
|
|
88
|
+
const e = () => {
|
|
89
|
+
l && u(!0);
|
|
90
|
+
};
|
|
91
|
+
return I.set(s, e), () => {
|
|
92
|
+
I.delete(s);
|
|
93
|
+
};
|
|
94
|
+
}, [l, s]);
|
|
95
|
+
const A = f(() => {
|
|
96
|
+
if (l) {
|
|
97
|
+
if (c) {
|
|
98
|
+
u(!1);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
b(), u(!0);
|
|
102
|
+
}
|
|
103
|
+
}, [l, c, b]), k = f(() => {
|
|
104
|
+
const e = m.trim();
|
|
105
|
+
n.update(() => {
|
|
106
|
+
const t = v(s);
|
|
107
|
+
if (P(t)) {
|
|
108
|
+
if (t.isInline && t.isInline() && e === "") {
|
|
109
|
+
t.remove();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
t.setEquation(e);
|
|
113
|
+
}
|
|
114
|
+
}), u(!1);
|
|
115
|
+
}, [n, s, m]), q = f(() => {
|
|
116
|
+
if (!r && a) {
|
|
117
|
+
n.update(() => {
|
|
118
|
+
const e = v(s);
|
|
119
|
+
P(e) && e.remove();
|
|
120
|
+
}), u(!1);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
x(r), r && u(!1);
|
|
124
|
+
}, [n, r, a, s]);
|
|
125
|
+
d(() => {
|
|
126
|
+
c || x(r);
|
|
127
|
+
}, [r, c]), d(() => {
|
|
128
|
+
if (!c) {
|
|
129
|
+
S(n.getRootElement()), D(!1);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
$(n.getRootElement()), b();
|
|
133
|
+
const e = window.requestAnimationFrame(() => {
|
|
134
|
+
const t = B.current;
|
|
135
|
+
if (!t) return;
|
|
136
|
+
const i = t.value.length;
|
|
137
|
+
t.focus(), t.setSelectionRange(i, i);
|
|
138
|
+
});
|
|
139
|
+
return () => {
|
|
140
|
+
window.cancelAnimationFrame(e), S(n.getRootElement());
|
|
141
|
+
};
|
|
142
|
+
}, [c, b]), d(() => {
|
|
143
|
+
if (!c) return;
|
|
144
|
+
const e = (t) => {
|
|
145
|
+
const i = t.target, g = p.current, y = document.querySelector(".equation-block__popup");
|
|
146
|
+
i && (g != null && g.contains(i) || y instanceof HTMLElement && y.contains(i)) || (a && !m.trim() && n.update(() => {
|
|
147
|
+
const L = v(s);
|
|
148
|
+
P(L) && L.remove();
|
|
149
|
+
}), u(!1));
|
|
150
|
+
};
|
|
151
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
152
|
+
}, [n, a, c, s, m]);
|
|
153
|
+
const h = (c ? m : r).trim(), R = h.length > 0;
|
|
154
|
+
d(() => {
|
|
155
|
+
const e = p.current;
|
|
156
|
+
if (!e) return;
|
|
157
|
+
const t = e.closest(".editor-equation"), i = h;
|
|
158
|
+
if (t) {
|
|
159
|
+
if (!i) {
|
|
160
|
+
t.removeAttribute("data-lexical-equation");
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const g = btoa(unescape(encodeURIComponent(i)));
|
|
165
|
+
t.setAttribute("data-lexical-equation", g);
|
|
166
|
+
} catch {
|
|
167
|
+
t.setAttribute("data-lexical-equation", i);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}, [h]);
|
|
171
|
+
const z = a && !l ? /* @__PURE__ */ o("span", { className: "equation-inline-trigger", children: /* @__PURE__ */ o(_, { onError: (e) => {
|
|
172
|
+
var t;
|
|
173
|
+
return (t = n._onError) == null ? void 0 : t.call(n, e);
|
|
174
|
+
}, children: /* @__PURE__ */ o(
|
|
175
|
+
w,
|
|
176
|
+
{
|
|
177
|
+
equation: r,
|
|
178
|
+
inline: a,
|
|
179
|
+
onDoubleClick: A
|
|
180
|
+
}
|
|
181
|
+
) }) }) : a ? /* @__PURE__ */ o(
|
|
182
|
+
"span",
|
|
183
|
+
{
|
|
184
|
+
className: `equation-inline-trigger${R ? "" : " equation-inline-trigger--empty"}`,
|
|
185
|
+
onClick: A,
|
|
186
|
+
ref: p,
|
|
187
|
+
children: R ? /* @__PURE__ */ o(_, { onError: (e) => {
|
|
188
|
+
var t;
|
|
189
|
+
return (t = n._onError) == null ? void 0 : t.call(n, e);
|
|
190
|
+
}, children: /* @__PURE__ */ o(
|
|
191
|
+
w,
|
|
192
|
+
{
|
|
193
|
+
equation: h,
|
|
194
|
+
inline: a,
|
|
195
|
+
onDoubleClick: A
|
|
196
|
+
}
|
|
197
|
+
) }) : /* @__PURE__ */ E("span", { className: "equation-inline-placeholder", children: [
|
|
198
|
+
/* @__PURE__ */ o(X, { icon: Y, size: 24 }),
|
|
199
|
+
/* @__PURE__ */ o("span", { children: "New equation" })
|
|
200
|
+
] })
|
|
201
|
+
}
|
|
202
|
+
) : /* @__PURE__ */ o("div", { className: "equation-block", ref: p, children: /* @__PURE__ */ o(
|
|
203
|
+
"div",
|
|
204
|
+
{
|
|
205
|
+
className: "equation-block__container",
|
|
206
|
+
onClick: A,
|
|
207
|
+
style: { cursor: l ? "pointer" : "default" },
|
|
208
|
+
children: R ? /* @__PURE__ */ o(_, { onError: (e) => {
|
|
209
|
+
var t;
|
|
210
|
+
return (t = n._onError) == null ? void 0 : t.call(n, e);
|
|
211
|
+
}, children: /* @__PURE__ */ o(
|
|
212
|
+
w,
|
|
213
|
+
{
|
|
214
|
+
equation: h,
|
|
215
|
+
inline: a,
|
|
216
|
+
onDoubleClick: A
|
|
217
|
+
}
|
|
218
|
+
) }) : /* @__PURE__ */ o("div", { className: "equation-block__placeholder", children: "Add a TeX equation" })
|
|
219
|
+
}
|
|
220
|
+
) }), G = f(
|
|
221
|
+
(e) => {
|
|
222
|
+
e.stopPropagation(), x(e.currentTarget.value);
|
|
223
|
+
},
|
|
224
|
+
[]
|
|
225
|
+
), Q = f(
|
|
226
|
+
V({
|
|
227
|
+
onConfirm: k,
|
|
228
|
+
onCancel: q
|
|
229
|
+
}),
|
|
230
|
+
[k, q]
|
|
231
|
+
);
|
|
232
|
+
return /* @__PURE__ */ E(T, { children: [
|
|
233
|
+
z,
|
|
234
|
+
c && j && U(
|
|
235
|
+
/* @__PURE__ */ o(
|
|
236
|
+
"div",
|
|
237
|
+
{
|
|
238
|
+
className: "equation-block__popup",
|
|
239
|
+
style: {
|
|
240
|
+
position: "fixed",
|
|
241
|
+
top: O.top,
|
|
242
|
+
left: O.left,
|
|
243
|
+
zIndex: 103
|
|
244
|
+
},
|
|
245
|
+
children: /* @__PURE__ */ E("div", { className: "equation-block__editor", children: [
|
|
246
|
+
/* @__PURE__ */ o(
|
|
247
|
+
K,
|
|
248
|
+
{
|
|
249
|
+
autosize: !0,
|
|
250
|
+
minRows: 2,
|
|
251
|
+
variant: "unstyled",
|
|
252
|
+
value: m,
|
|
253
|
+
onChange: G,
|
|
254
|
+
onKeyDown: Q,
|
|
255
|
+
placeholder: "x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}",
|
|
256
|
+
classNames: {
|
|
257
|
+
wrapper: "equation-block__textarea-wrapper"
|
|
258
|
+
},
|
|
259
|
+
autoFocus: !0,
|
|
260
|
+
ref: B
|
|
261
|
+
}
|
|
262
|
+
),
|
|
263
|
+
/* @__PURE__ */ E(ee, { justify: "flex-end", gap: "sm", children: [
|
|
264
|
+
/* @__PURE__ */ o(H, { variant: "subtle", color: "gray", onClick: q, children: "Cancel" }),
|
|
265
|
+
/* @__PURE__ */ o(H, { onClick: k, children: "Save" })
|
|
266
|
+
] })
|
|
267
|
+
] })
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
document.body
|
|
271
|
+
)
|
|
272
|
+
] });
|
|
273
|
+
}
|
|
274
|
+
export {
|
|
275
|
+
pe as default
|
|
276
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./layers.DgvrVyqi.js");require("./layers.DT9rsUtv.js");require("lodash-es/memoize.js");require("lodash-es/merge.js");require("lodash-es/isEmpty.js");const pt=require("./layers.B19hGmey.js"),mt=require("./layers.BIeVwYKL.js");function rt(t,n){let s;if(n===void 0)for(const a of t)a!=null&&(s<a||s===void 0&&a>=a)&&(s=a);else{let a=-1;for(let u of t)(u=n(u,++a,t))!=null&&(s<u||s===void 0&&u>=u)&&(s=u)}return s}function ft(t,n){let s;if(n===void 0)for(const a of t)a!=null&&(s>a||s===void 0&&a>=a)&&(s=a);else{let a=-1;for(let u of t)(u=n(u,++a,t))!=null&&(s>u||s===void 0&&u>=u)&&(s=u)}return s}function Z(t,n){let s=0;if(n===void 0)for(let a of t)(a=+a)&&(s+=a);else{let a=-1;for(let u of t)(u=+n(u,++a,t))&&(s+=u)}return s}function kt(t){return t.target.depth}function _t(t){return t.depth}function xt(t,n){return n-1-t.height}function yt(t,n){return t.sourceLinks.length?t.depth:n-1}function vt(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?ft(t.sourceLinks,kt)-1:0}function G(t){return function(){return t}}function ot(t,n){return Y(t.source,n.source)||t.index-n.index}function lt(t,n){return Y(t.target,n.target)||t.index-n.index}function Y(t,n){return t.y0-n.y0}function J(t){return t.value}function bt(t){return t.index}function wt(t){return t.nodes}function St(t){return t.links}function at(t,n){const s=t.get(n);if(!s)throw new Error("missing: "+n);return s}function ct({nodes:t}){for(const n of t){let s=n.y0,a=s;for(const u of n.sourceLinks)u.y0=s+u.width/2,s+=u.width;for(const u of n.targetLinks)u.y1=a+u.width/2,a+=u.width}}function Lt(){let t=0,n=0,s=1,a=1,u=24,_=8,g,p=bt,i=yt,o,c,m=wt,b=St,y=6;function x(){const e={nodes:m.apply(null,arguments),links:b.apply(null,arguments)};return A(e),E(e),T(e),C(e),S(e),ct(e),e}x.update=function(e){return ct(e),e},x.nodeId=function(e){return arguments.length?(p=typeof e=="function"?e:G(e),x):p},x.nodeAlign=function(e){return arguments.length?(i=typeof e=="function"?e:G(e),x):i},x.nodeSort=function(e){return arguments.length?(o=e,x):o},x.nodeWidth=function(e){return arguments.length?(u=+e,x):u},x.nodePadding=function(e){return arguments.length?(_=g=+e,x):_},x.nodes=function(e){return arguments.length?(m=typeof e=="function"?e:G(e),x):m},x.links=function(e){return arguments.length?(b=typeof e=="function"?e:G(e),x):b},x.linkSort=function(e){return arguments.length?(c=e,x):c},x.size=function(e){return arguments.length?(t=n=0,s=+e[0],a=+e[1],x):[s-t,a-n]},x.extent=function(e){return arguments.length?(t=+e[0][0],s=+e[1][0],n=+e[0][1],a=+e[1][1],x):[[t,n],[s,a]]},x.iterations=function(e){return arguments.length?(y=+e,x):y};function A({nodes:e,links:f}){for(const[h,r]of e.entries())r.index=h,r.sourceLinks=[],r.targetLinks=[];const l=new Map(e.map((h,r)=>[p(h,r,e),h]));for(const[h,r]of f.entries()){r.index=h;let{source:k,target:v}=r;typeof k!="object"&&(k=r.source=at(l,k)),typeof v!="object"&&(v=r.target=at(l,v)),k.sourceLinks.push(r),v.targetLinks.push(r)}if(c!=null)for(const{sourceLinks:h,targetLinks:r}of e)h.sort(c),r.sort(c)}function E({nodes:e}){for(const f of e)f.value=f.fixedValue===void 0?Math.max(Z(f.sourceLinks,J),Z(f.targetLinks,J)):f.fixedValue}function T({nodes:e}){const f=e.length;let l=new Set(e),h=new Set,r=0;for(;l.size;){for(const k of l){k.depth=r;for(const{target:v}of k.sourceLinks)h.add(v)}if(++r>f)throw new Error("circular link");l=h,h=new Set}}function C({nodes:e}){const f=e.length;let l=new Set(e),h=new Set,r=0;for(;l.size;){for(const k of l){k.height=r;for(const{source:v}of k.targetLinks)h.add(v)}if(++r>f)throw new Error("circular link");l=h,h=new Set}}function O({nodes:e}){const f=rt(e,r=>r.depth)+1,l=(s-t-u)/(f-1),h=new Array(f);for(const r of e){const k=Math.max(0,Math.min(f-1,Math.floor(i.call(null,r,f))));r.layer=k,r.x0=t+k*l,r.x1=r.x0+u,h[k]?h[k].push(r):h[k]=[r]}if(o)for(const r of h)r.sort(o);return h}function j(e){const f=ft(e,l=>(a-n-(l.length-1)*g)/Z(l,J));for(const l of e){let h=n;for(const r of l){r.y0=h,r.y1=h+r.value*f,h=r.y1+g;for(const k of r.sourceLinks)k.width=k.value*f}h=(a-h+g)/(l.length+1);for(let r=0;r<l.length;++r){const k=l[r];k.y0+=h*(r+1),k.y1+=h*(r+1)}$(l)}}function S(e){const f=O(e);g=Math.min(_,(a-n)/(rt(f,l=>l.length)-1)),j(f);for(let l=0;l<y;++l){const h=Math.pow(.99,l),r=Math.max(1-h,(l+1)/y);D(f,h,r),N(f,h,r)}}function N(e,f,l){for(let h=1,r=e.length;h<r;++h){const k=e[h];for(const v of k){let R=0,z=0;for(const{source:W,value:K}of v.targetLinks){let F=K*(v.layer-W.layer);R+=M(W,v)*F,z+=F}if(!(z>0))continue;let U=(R/z-v.y0)*f;v.y0+=U,v.y1+=U,w(v)}o===void 0&&k.sort(Y),P(k,l)}}function D(e,f,l){for(let h=e.length,r=h-2;r>=0;--r){const k=e[r];for(const v of k){let R=0,z=0;for(const{target:W,value:K}of v.sourceLinks){let F=K*(W.layer-v.layer);R+=V(v,W)*F,z+=F}if(!(z>0))continue;let U=(R/z-v.y0)*f;v.y0+=U,v.y1+=U,w(v)}o===void 0&&k.sort(Y),P(k,l)}}function P(e,f){const l=e.length>>1,h=e[l];d(e,h.y0-g,l-1,f),I(e,h.y1+g,l+1,f),d(e,a,e.length-1,f),I(e,n,0,f)}function I(e,f,l,h){for(;l<e.length;++l){const r=e[l],k=(f-r.y0)*h;k>1e-6&&(r.y0+=k,r.y1+=k),f=r.y1+g}}function d(e,f,l,h){for(;l>=0;--l){const r=e[l],k=(r.y1-f)*h;k>1e-6&&(r.y0-=k,r.y1-=k),f=r.y0-g}}function w({sourceLinks:e,targetLinks:f}){if(c===void 0){for(const{source:{sourceLinks:l}}of f)l.sort(lt);for(const{target:{targetLinks:l}}of e)l.sort(ot)}}function $(e){if(c===void 0)for(const{sourceLinks:f,targetLinks:l}of e)f.sort(lt),l.sort(ot)}function M(e,f){let l=e.y0-(e.sourceLinks.length-1)*g/2;for(const{target:h,width:r}of e.sourceLinks){if(h===f)break;l+=r+g}for(const{source:h,width:r}of f.targetLinks){if(h===e)break;l-=r}return l}function V(e,f){let l=f.y0-(f.targetLinks.length-1)*g/2;for(const{source:h,width:r}of f.targetLinks){if(h===e)break;l+=r+g}for(const{target:h,width:r}of e.sourceLinks){if(h===f)break;l-=r}return l}return x}var tt=Math.PI,et=2*tt,B=1e-6,Et=et-B;function nt(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function dt(){return new nt}nt.prototype=dt.prototype={constructor:nt,moveTo:function(t,n){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(t,n){this._+="L"+(this._x1=+t)+","+(this._y1=+n)},quadraticCurveTo:function(t,n,s,a){this._+="Q"+ +t+","+ +n+","+(this._x1=+s)+","+(this._y1=+a)},bezierCurveTo:function(t,n,s,a,u,_){this._+="C"+ +t+","+ +n+","+ +s+","+ +a+","+(this._x1=+u)+","+(this._y1=+_)},arcTo:function(t,n,s,a,u){t=+t,n=+n,s=+s,a=+a,u=+u;var _=this._x1,g=this._y1,p=s-t,i=a-n,o=_-t,c=g-n,m=o*o+c*c;if(u<0)throw new Error("negative radius: "+u);if(this._x1===null)this._+="M"+(this._x1=t)+","+(this._y1=n);else if(m>B)if(!(Math.abs(c*p-i*o)>B)||!u)this._+="L"+(this._x1=t)+","+(this._y1=n);else{var b=s-_,y=a-g,x=p*p+i*i,A=b*b+y*y,E=Math.sqrt(x),T=Math.sqrt(m),C=u*Math.tan((tt-Math.acos((x+m-A)/(2*E*T)))/2),O=C/T,j=C/E;Math.abs(O-1)>B&&(this._+="L"+(t+O*o)+","+(n+O*c)),this._+="A"+u+","+u+",0,0,"+ +(c*b>o*y)+","+(this._x1=t+j*p)+","+(this._y1=n+j*i)}},arc:function(t,n,s,a,u,_){t=+t,n=+n,s=+s,_=!!_;var g=s*Math.cos(a),p=s*Math.sin(a),i=t+g,o=n+p,c=1^_,m=_?a-u:u-a;if(s<0)throw new Error("negative radius: "+s);this._x1===null?this._+="M"+i+","+o:(Math.abs(this._x1-i)>B||Math.abs(this._y1-o)>B)&&(this._+="L"+i+","+o),s&&(m<0&&(m=m%et+et),m>Et?this._+="A"+s+","+s+",0,1,"+c+","+(t-g)+","+(n-p)+"A"+s+","+s+",0,1,"+c+","+(this._x1=i)+","+(this._y1=o):m>B&&(this._+="A"+s+","+s+",0,"+ +(m>=tt)+","+c+","+(this._x1=t+s*Math.cos(u))+","+(this._y1=n+s*Math.sin(u))))},rect:function(t,n,s,a){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)+"h"+ +s+"v"+ +a+"h"+-s+"Z"},toString:function(){return this._}};function ut(t){return function(){return t}}function At(t){return t[0]}function Tt(t){return t[1]}var Mt=Array.prototype.slice;function Nt(t){return t.source}function Ct(t){return t.target}function Pt(t){var n=Nt,s=Ct,a=At,u=Tt,_=null;function g(){var p,i=Mt.call(arguments),o=n.apply(this,i),c=s.apply(this,i);if(_||(_=p=dt()),t(_,+a.apply(this,(i[0]=o,i)),+u.apply(this,i),+a.apply(this,(i[0]=c,i)),+u.apply(this,i)),p)return _=null,p+""||null}return g.source=function(p){return arguments.length?(n=p,g):n},g.target=function(p){return arguments.length?(s=p,g):s},g.x=function(p){return arguments.length?(a=typeof p=="function"?p:ut(+p),g):a},g.y=function(p){return arguments.length?(u=typeof p=="function"?p:ut(+p),g):u},g.context=function(p){return arguments.length?(_=p??null,g):_},g}function It(t,n,s,a,u){t.moveTo(n,s),t.bezierCurveTo(n=(n+a)/2,s,n,u,a,u)}function Ot(){return Pt(It)}function $t(t){return[t.source.x1,t.y0]}function Dt(t){return[t.target.x0,t.y1]}function jt(){return Ot().source($t).target(Dt)}var it=(function(){var t=function(p,i,o,c){for(o=o||{},c=p.length;c--;o[p[c]]=i);return o},n=[1,9],s=[1,10],a=[1,5,10,12],u={trace:function(){},yy:{},symbols_:{error:2,start:3,SANKEY:4,NEWLINE:5,csv:6,opt_eof:7,record:8,csv_tail:9,EOF:10,"field[source]":11,COMMA:12,"field[target]":13,"field[value]":14,field:15,escaped:16,non_escaped:17,DQUOTE:18,ESCAPED_TEXT:19,NON_ESCAPED_TEXT:20,$accept:0,$end:1},terminals_:{2:"error",4:"SANKEY",5:"NEWLINE",10:"EOF",11:"field[source]",12:"COMMA",13:"field[target]",14:"field[value]",18:"DQUOTE",19:"ESCAPED_TEXT",20:"NON_ESCAPED_TEXT"},productions_:[0,[3,4],[6,2],[9,2],[9,0],[7,1],[7,0],[8,5],[15,1],[15,1],[16,3],[17,1]],performAction:function(i,o,c,m,b,y,x){var A=y.length-1;switch(b){case 7:const E=m.findOrCreateNode(y[A-4].trim().replaceAll('""','"')),T=m.findOrCreateNode(y[A-2].trim().replaceAll('""','"')),C=parseFloat(y[A].trim());m.addLink(E,T,C);break;case 8:case 9:case 11:this.$=y[A];break;case 10:this.$=y[A-1];break}},table:[{3:1,4:[1,2]},{1:[3]},{5:[1,3]},{6:4,8:5,15:6,16:7,17:8,18:n,20:s},{1:[2,6],7:11,10:[1,12]},t(s,[2,4],{9:13,5:[1,14]}),{12:[1,15]},t(a,[2,8]),t(a,[2,9]),{19:[1,16]},t(a,[2,11]),{1:[2,1]},{1:[2,5]},t(s,[2,2]),{6:17,8:5,15:6,16:7,17:8,18:n,20:s},{15:18,16:7,17:8,18:n,20:s},{18:[1,19]},t(s,[2,3]),{12:[1,20]},t(a,[2,10]),{15:21,16:7,17:8,18:n,20:s},t([1,5,10],[2,7])],defaultActions:{11:[2,1],12:[2,5]},parseError:function(i,o){if(o.recoverable)this.trace(i);else{var c=new Error(i);throw c.hash=o,c}},parse:function(i){var o=this,c=[0],m=[],b=[null],y=[],x=this.table,A="",E=0,T=0,C=2,O=1,j=y.slice.call(arguments,1),S=Object.create(this.lexer),N={yy:{}};for(var D in this.yy)Object.prototype.hasOwnProperty.call(this.yy,D)&&(N.yy[D]=this.yy[D]);S.setInput(i,N.yy),N.yy.lexer=S,N.yy.parser=this,typeof S.yylloc>"u"&&(S.yylloc={});var P=S.yylloc;y.push(P);var I=S.options&&S.options.ranges;typeof N.yy.parseError=="function"?this.parseError=N.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function d(){var v;return v=m.pop()||S.lex()||O,typeof v!="number"&&(v instanceof Array&&(m=v,v=m.pop()),v=o.symbols_[v]||v),v}for(var w,$,M,V,e={},f,l,h,r;;){if($=c[c.length-1],this.defaultActions[$]?M=this.defaultActions[$]:((w===null||typeof w>"u")&&(w=d()),M=x[$]&&x[$][w]),typeof M>"u"||!M.length||!M[0]){var k="";r=[];for(f in x[$])this.terminals_[f]&&f>C&&r.push("'"+this.terminals_[f]+"'");S.showPosition?k="Parse error on line "+(E+1)+`:
|
|
2
|
+
`+S.showPosition()+`
|
|
3
|
+
Expecting `+r.join(", ")+", got '"+(this.terminals_[w]||w)+"'":k="Parse error on line "+(E+1)+": Unexpected "+(w==O?"end of input":"'"+(this.terminals_[w]||w)+"'"),this.parseError(k,{text:S.match,token:this.terminals_[w]||w,line:S.yylineno,loc:P,expected:r})}if(M[0]instanceof Array&&M.length>1)throw new Error("Parse Error: multiple actions possible at state: "+$+", token: "+w);switch(M[0]){case 1:c.push(w),b.push(S.yytext),y.push(S.yylloc),c.push(M[1]),w=null,T=S.yyleng,A=S.yytext,E=S.yylineno,P=S.yylloc;break;case 2:if(l=this.productions_[M[1]][1],e.$=b[b.length-l],e._$={first_line:y[y.length-(l||1)].first_line,last_line:y[y.length-1].last_line,first_column:y[y.length-(l||1)].first_column,last_column:y[y.length-1].last_column},I&&(e._$.range=[y[y.length-(l||1)].range[0],y[y.length-1].range[1]]),V=this.performAction.apply(e,[A,T,E,N.yy,M[1],b,y].concat(j)),typeof V<"u")return V;l&&(c=c.slice(0,-1*l*2),b=b.slice(0,-1*l),y=y.slice(0,-1*l)),c.push(this.productions_[M[1]][0]),b.push(e.$),y.push(e._$),h=x[c[c.length-2]][c[c.length-1]],c.push(h);break;case 3:return!0}}return!0}},_=(function(){var p={EOF:1,parseError:function(o,c){if(this.yy.parser)this.yy.parser.parseError(o,c);else throw new Error(o)},setInput:function(i,o){return this.yy=o||this.yy||{},this._input=i,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var i=this._input[0];this.yytext+=i,this.yyleng++,this.offset++,this.match+=i,this.matched+=i;var o=i.match(/(?:\r\n?|\n).*/g);return o?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),i},unput:function(i){var o=i.length,c=i.split(/(?:\r\n?|\n)/g);this._input=i+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-o),this.offset-=o;var m=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),c.length-1&&(this.yylineno-=c.length-1);var b=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===m.length?this.yylloc.first_column:0)+m[m.length-c.length].length-c[0].length:this.yylloc.first_column-o},this.options.ranges&&(this.yylloc.range=[b[0],b[0]+this.yyleng-o]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(i){this.unput(this.match.slice(i))},pastInput:function(){var i=this.matched.substr(0,this.matched.length-this.match.length);return(i.length>20?"...":"")+i.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var i=this.match;return i.length<20&&(i+=this._input.substr(0,20-i.length)),(i.substr(0,20)+(i.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var i=this.pastInput(),o=new Array(i.length+1).join("-");return i+this.upcomingInput()+`
|
|
5
|
+
`+o+"^"},test_match:function(i,o){var c,m,b;if(this.options.backtrack_lexer&&(b={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(b.yylloc.range=this.yylloc.range.slice(0))),m=i[0].match(/(?:\r\n?|\n).*/g),m&&(this.yylineno+=m.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:m?m[m.length-1].length-m[m.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+i[0].length},this.yytext+=i[0],this.match+=i[0],this.matches=i,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(i[0].length),this.matched+=i[0],c=this.performAction.call(this,this.yy,this,o,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),c)return c;if(this._backtrack){for(var y in b)this[y]=b[y];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var i,o,c,m;this._more||(this.yytext="",this.match="");for(var b=this._currentRules(),y=0;y<b.length;y++)if(c=this._input.match(this.rules[b[y]]),c&&(!o||c[0].length>o[0].length)){if(o=c,m=y,this.options.backtrack_lexer){if(i=this.test_match(c,b[y]),i!==!1)return i;if(this._backtrack){o=!1;continue}else return!1}else if(!this.options.flex)break}return o?(i=this.test_match(o,b[m]),i!==!1?i:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
|
|
6
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var o=this.next();return o||this.lex()},begin:function(o){this.conditionStack.push(o)},popState:function(){var o=this.conditionStack.length-1;return o>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(o){return o=this.conditionStack.length-1-Math.abs(o||0),o>=0?this.conditionStack[o]:"INITIAL"},pushState:function(o){this.begin(o)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(o,c,m,b){switch(m){case 0:return this.pushState("csv"),4;case 1:return 10;case 2:return 5;case 3:return 12;case 4:return this.pushState("escaped_text"),18;case 5:return 20;case 6:return this.popState("escaped_text"),18;case 7:return 19}},rules:[/^(?:sankey-beta\b)/i,/^(?:$)/i,/^(?:((\u000D\u000A)|(\u000A)))/i,/^(?:(\u002C))/i,/^(?:(\u0022))/i,/^(?:([\u0020-\u0021\u0023-\u002B\u002D-\u007E])*)/i,/^(?:(\u0022)(?!(\u0022)))/i,/^(?:(([\u0020-\u0021\u0023-\u002B\u002D-\u007E])|(\u002C)|(\u000D)|(\u000A)|(\u0022)(\u0022))*)/i],conditions:{csv:{rules:[1,2,3,4,5,6,7],inclusive:!1},escaped_text:{rules:[6,7],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7],inclusive:!0}}};return p})();u.lexer=_;function g(){this.yy={}}return g.prototype=u,u.Parser=g,new g})();it.parser=it;const H=it;let X=[],Q=[],q={};const zt=()=>{X=[],Q=[],q={},L.clear()};class Bt{constructor(n,s,a=0){this.source=n,this.target=s,this.value=a}}const qt=(t,n,s)=>{X.push(new Bt(t,n,s))};class Vt{constructor(n){this.ID=n}}const Rt=t=>(t=L.common$1.sanitizeText(t,L.getConfig()),q[t]||(q[t]=new Vt(t),Q.push(q[t])),q[t]),Ut=()=>Q,Wt=()=>X,Ft=()=>({nodes:Q.map(t=>({id:t.ID})),links:X.map(t=>({source:t.source.ID,target:t.target.ID,value:t.value}))}),Gt={nodesMap:q,getConfig:()=>L.getConfig().sankey,getNodes:Ut,getLinks:Wt,getGraph:Ft,addLink:qt,findOrCreateNode:Rt,getAccTitle:L.getAccTitle,setAccTitle:L.setAccTitle,getAccDescription:L.getAccDescription,setAccDescription:L.setAccDescription,getDiagramTitle:L.getDiagramTitle,setDiagramTitle:L.setDiagramTitle,clear:zt},gt=class st{static next(n){return new st(n+ ++st.count)}constructor(n){this.id=n,this.href=`#${n}`}toString(){return"url("+this.href+")"}};gt.count=0;let ht=gt;const Yt={left:_t,right:xt,center:vt,justify:yt},Ht=function(t,n,s,a){const{securityLevel:u,sankey:_}=L.getConfig(),g=L.defaultConfig.sankey;let p;u==="sandbox"&&(p=L.select("#i"+n));const i=u==="sandbox"?L.select(p.nodes()[0].contentDocument.body):L.select("body"),o=u==="sandbox"?i.select(`[id="${n}"]`):L.select(`[id="${n}"]`),c=(_==null?void 0:_.width)??g.width,m=(_==null?void 0:_.height)??g.width,b=(_==null?void 0:_.useMaxWidth)??g.useMaxWidth,y=(_==null?void 0:_.nodeAlignment)??g.nodeAlignment,x=(_==null?void 0:_.prefix)??g.prefix,A=(_==null?void 0:_.suffix)??g.suffix,E=(_==null?void 0:_.showValues)??g.showValues,T=a.db.getGraph(),C=Yt[y];Lt().nodeId(d=>d.id).nodeWidth(10).nodePadding(10+(E?15:0)).nodeAlign(C).extent([[0,0],[c,m]])(T);const S=pt.ordinal(mt.schemeTableau10);o.append("g").attr("class","nodes").selectAll(".node").data(T.nodes).join("g").attr("class","node").attr("id",d=>(d.uid=ht.next("node-")).id).attr("transform",function(d){return"translate("+d.x0+","+d.y0+")"}).attr("x",d=>d.x0).attr("y",d=>d.y0).append("rect").attr("height",d=>d.y1-d.y0).attr("width",d=>d.x1-d.x0).attr("fill",d=>S(d.id));const N=({id:d,value:w})=>E?`${d}
|
|
7
|
+
${x}${Math.round(w*100)/100}${A}`:d;o.append("g").attr("class","node-labels").attr("font-family","sans-serif").attr("font-size",14).selectAll("text").data(T.nodes).join("text").attr("x",d=>d.x0<c/2?d.x1+6:d.x0-6).attr("y",d=>(d.y1+d.y0)/2).attr("dy",`${E?"0":"0.35"}em`).attr("text-anchor",d=>d.x0<c/2?"start":"end").text(N);const D=o.append("g").attr("class","links").attr("fill","none").attr("stroke-opacity",.5).selectAll(".link").data(T.links).join("g").attr("class","link").style("mix-blend-mode","multiply"),P=(_==null?void 0:_.linkColor)||"gradient";if(P==="gradient"){const d=D.append("linearGradient").attr("id",w=>(w.uid=ht.next("linearGradient-")).id).attr("gradientUnits","userSpaceOnUse").attr("x1",w=>w.source.x1).attr("x2",w=>w.target.x0);d.append("stop").attr("offset","0%").attr("stop-color",w=>S(w.source.id)),d.append("stop").attr("offset","100%").attr("stop-color",w=>S(w.target.id))}let I;switch(P){case"gradient":I=d=>d.uid;break;case"source":I=d=>S(d.source.id);break;case"target":I=d=>S(d.target.id);break;default:I=P}D.append("path").attr("d",jt()).attr("stroke",I).attr("stroke-width",d=>Math.max(1,d.width)),L.setupGraphViewbox$1(void 0,o,0,b)},Xt={draw:Ht},Qt=t=>t.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g,"").replaceAll(/([\n\r])+/g,`
|
|
8
|
+
`).trim(),Kt=H.parse.bind(H);H.parse=t=>Kt(Qt(t));const Zt={parser:H,db:Gt,renderer:Xt};exports.diagram=Zt;
|