vue3-math-editor 0.2.1 → 0.2.2
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/dist/style.css +1 -1
- package/dist/vue3-math-editor.js +712 -681
- package/package.json +1 -1
package/dist/vue3-math-editor.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createStaticVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, inject as u, mergeModels as d, nextTick as f, normalizeClass as p, normalizeStyle as m, onBeforeUnmount as ee, onMounted as te, onScopeDispose as h, openBlock as g, ref as _, renderList as v, renderSlot as ne, shallowRef as re, toDisplayString as y, toRaw as b, toValue as x, unref as S, useId as C, useModel as ie, vModelSelect as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
1
|
+
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createStaticVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, inject as u, mergeModels as d, nextTick as f, normalizeClass as p, normalizeStyle as m, onBeforeUnmount as ee, onMounted as te, onScopeDispose as h, openBlock as g, ref as _, renderList as v, renderSlot as ne, shallowRef as re, toDisplayString as y, toRaw as b, toValue as x, unref as S, useId as C, useModel as ie, vModelSelect as ae, vModelText as w, watch as oe, withCtx as T, withDirectives as E, withModifiers as D } from "vue";
|
|
2
|
+
import se from "katex";
|
|
3
|
+
import O from "primevue/button";
|
|
4
|
+
import ce from "primevue/card";
|
|
5
|
+
import le from "primevue/menu";
|
|
6
|
+
import ue from "primevue/popover";
|
|
7
|
+
import de from "primevue/tab";
|
|
8
|
+
import fe from "primevue/tablist";
|
|
9
|
+
import pe from "primevue/tabpanel";
|
|
10
|
+
import me from "primevue/tabpanels";
|
|
11
|
+
import he from "primevue/tabs";
|
|
12
|
+
import ge from "primevue/tag";
|
|
13
13
|
//#region src/editor/layout.ts
|
|
14
|
-
var
|
|
14
|
+
var _e = {
|
|
15
15
|
"(": ")",
|
|
16
16
|
"|": "|",
|
|
17
17
|
"⌊": "⌋",
|
|
18
18
|
"⌈": "⌉"
|
|
19
19
|
};
|
|
20
|
-
function
|
|
20
|
+
function k(e) {
|
|
21
21
|
switch (e.kind) {
|
|
22
22
|
case "fraction": return [["num", e.num], ["den", e.den]];
|
|
23
23
|
case "superscript": return [["sup", e.sup]];
|
|
@@ -29,7 +29,7 @@ function A(e) {
|
|
|
29
29
|
default: return [];
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function A(e) {
|
|
33
33
|
if (e === "otherwise") return { part: "otherwise" };
|
|
34
34
|
let t = /^(value|cond)(\d+)$/.exec(e);
|
|
35
35
|
return t ? {
|
|
@@ -37,9 +37,9 @@ function _e(e) {
|
|
|
37
37
|
piece: Number(t[2])
|
|
38
38
|
} : null;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function ve(e, t, n) {
|
|
41
41
|
if (e.kind === "piecewise") {
|
|
42
|
-
let r =
|
|
42
|
+
let r = A(t);
|
|
43
43
|
if (!r) throw Error(`No branch ${t} in a piecewise`);
|
|
44
44
|
if (r.part === "otherwise") return {
|
|
45
45
|
...e,
|
|
@@ -62,93 +62,93 @@ function j(e, t, n) {
|
|
|
62
62
|
[t]: n
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
65
|
+
function j(e, t) {
|
|
66
|
+
return k(e).find(([e]) => e === t)?.[1] ?? null;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function M(e, t) {
|
|
69
69
|
let n = e;
|
|
70
70
|
for (let e of t) {
|
|
71
71
|
let t = n[e.atom];
|
|
72
72
|
if (!t) return null;
|
|
73
|
-
let r =
|
|
73
|
+
let r = j(t, e.branch);
|
|
74
74
|
if (!r) return null;
|
|
75
75
|
n = r;
|
|
76
76
|
}
|
|
77
77
|
return n;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function ye(e, t) {
|
|
80
80
|
return e.length === t.length && e.every((e, n) => e.atom === t[n].atom && e.branch === t[n].branch);
|
|
81
81
|
}
|
|
82
|
-
var
|
|
83
|
-
function
|
|
84
|
-
return
|
|
82
|
+
var be = 0;
|
|
83
|
+
function N() {
|
|
84
|
+
return be += 1, `a${be}`;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function P(e) {
|
|
87
87
|
return {
|
|
88
88
|
kind: "symbol",
|
|
89
|
-
id:
|
|
89
|
+
id: N(),
|
|
90
90
|
value: e
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function F(e) {
|
|
94
94
|
return {
|
|
95
95
|
kind: "function",
|
|
96
|
-
id:
|
|
96
|
+
id: N(),
|
|
97
97
|
name: e
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function xe(e = [], t = []) {
|
|
101
101
|
return {
|
|
102
102
|
kind: "fraction",
|
|
103
|
-
id:
|
|
103
|
+
id: N(),
|
|
104
104
|
num: e,
|
|
105
105
|
den: t
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function I(e = []) {
|
|
109
109
|
return {
|
|
110
110
|
kind: "superscript",
|
|
111
|
-
id:
|
|
111
|
+
id: N(),
|
|
112
112
|
sup: e
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function Se(e = [], t = null) {
|
|
116
116
|
return {
|
|
117
117
|
kind: "root",
|
|
118
|
-
id:
|
|
118
|
+
id: N(),
|
|
119
119
|
index: t,
|
|
120
120
|
body: e
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
let r = n ??
|
|
123
|
+
function L(e = [], t = "(", n) {
|
|
124
|
+
let r = n ?? _e[t] ?? t;
|
|
125
125
|
return {
|
|
126
126
|
kind: "group",
|
|
127
|
-
id:
|
|
127
|
+
id: N(),
|
|
128
128
|
open: t,
|
|
129
129
|
close: r,
|
|
130
130
|
body: e
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function Ce(e = [], t = []) {
|
|
134
134
|
return {
|
|
135
135
|
kind: "derivative",
|
|
136
|
-
id:
|
|
136
|
+
id: N(),
|
|
137
137
|
expr: e,
|
|
138
138
|
variable: t
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function we(e = []) {
|
|
142
142
|
return {
|
|
143
143
|
kind: "units",
|
|
144
|
-
id:
|
|
144
|
+
id: N(),
|
|
145
145
|
units: e
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function Te(e = [[[], []]], t = null) {
|
|
149
149
|
return {
|
|
150
150
|
kind: "piecewise",
|
|
151
|
-
id:
|
|
151
|
+
id: N(),
|
|
152
152
|
pieces: e.map(([e, t]) => ({
|
|
153
153
|
value: e,
|
|
154
154
|
condition: t
|
|
@@ -156,12 +156,12 @@ function we(e = [[[], []]], t = null) {
|
|
|
156
156
|
otherwise: t
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
-
function
|
|
160
|
-
return e.flatMap((e) => typeof e == "string" ? Array.from(e).map((e) =>
|
|
159
|
+
function R(...e) {
|
|
160
|
+
return e.flatMap((e) => typeof e == "string" ? Array.from(e).map((e) => P(e)) : [e]);
|
|
161
161
|
}
|
|
162
162
|
//#endregion
|
|
163
163
|
//#region src/editor/constants.ts
|
|
164
|
-
var
|
|
164
|
+
var Ee = [
|
|
165
165
|
{
|
|
166
166
|
symbol: "pi",
|
|
167
167
|
latex: "\\pi",
|
|
@@ -212,7 +212,7 @@ var Te = [
|
|
|
212
212
|
mathJson: "False",
|
|
213
213
|
commands: ["false"]
|
|
214
214
|
}
|
|
215
|
-
],
|
|
215
|
+
], De = new Map(Ee.map((e) => [e.symbol, e])), Oe = new Map(Ee.flatMap((e) => e.commands.map((t) => [t, e]))), z = (e) => De.get(e), ke = (e) => Oe.get(e), Ae = /* @__PURE__ */ new Map([["pi", "pi"], ["infty", "infinity"]]), je = /* @__PURE__ */ new Map([
|
|
216
216
|
["e", "exponentiale"],
|
|
217
217
|
["NaN", "notanumber"],
|
|
218
218
|
["true", "true"],
|
|
@@ -521,7 +521,7 @@ for (let e of Object.values(ze)) {
|
|
|
521
521
|
function Je(e) {
|
|
522
522
|
return qe.get(e);
|
|
523
523
|
}
|
|
524
|
-
var Ye = (e, t) => e?.kind === "symbol" && t.test(e.value), Xe = (e) => e?.kind === "symbol" && Ke.has(e.value) && !
|
|
524
|
+
var Ye = (e, t) => e?.kind === "symbol" && t.test(e.value), Xe = (e) => e?.kind === "symbol" && Ke.has(e.value) && !z(e.value), Ze = (e) => Ye(e, /^[A-Za-z]$/), Qe = (e) => Ze(e) || Xe(e), $e = (e) => Ye(e, /^[A-Za-z0-9_]$/) || Xe(e);
|
|
525
525
|
function et(e, t) {
|
|
526
526
|
let n = t;
|
|
527
527
|
for (; n < e.length && $e(e[n]);) {
|
|
@@ -532,7 +532,7 @@ function et(e, t) {
|
|
|
532
532
|
return n;
|
|
533
533
|
}
|
|
534
534
|
function tt(e) {
|
|
535
|
-
return
|
|
535
|
+
return z(e)?.symbol;
|
|
536
536
|
}
|
|
537
537
|
function nt(e) {
|
|
538
538
|
let t = [], n = 0;
|
|
@@ -576,9 +576,9 @@ function at(e) {
|
|
|
576
576
|
let t = e.pieces[0]?.value ?? [], n = Le(t, +(t[0]?.kind === "symbol" && t[0].value === "-")), r = t[t.length - 1];
|
|
577
577
|
return !n || n.end !== t.length - 1 || r?.kind !== "units" ? null : it(r) || null;
|
|
578
578
|
}
|
|
579
|
-
var
|
|
580
|
-
function
|
|
581
|
-
let t =
|
|
579
|
+
var ot = /* @__PURE__ */ new WeakMap(), st = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
580
|
+
function ct(e) {
|
|
581
|
+
let t = ot.get(e);
|
|
582
582
|
if (t) return t;
|
|
583
583
|
let n = /* @__PURE__ */ new Map(), r = (e, t) => {
|
|
584
584
|
let r = n.get(e);
|
|
@@ -595,12 +595,12 @@ function st(e) {
|
|
|
595
595
|
n = o.end - 1;
|
|
596
596
|
continue;
|
|
597
597
|
}
|
|
598
|
-
if (a.kind === "symbol" &&
|
|
598
|
+
if (a.kind === "symbol" && st.test(a.value) && !z(a.value) && r(a.value, [a.id]), a.kind !== "units") for (let [, e] of k(a)) i(e);
|
|
599
599
|
}
|
|
600
600
|
};
|
|
601
|
-
return i(e),
|
|
601
|
+
return i(e), ot.set(e, n), n;
|
|
602
602
|
}
|
|
603
|
-
function
|
|
603
|
+
function lt(e) {
|
|
604
604
|
let t = [], n = (e, r = null) => {
|
|
605
605
|
for (let n of rt(e)) {
|
|
606
606
|
let i = e[n.end], a = i?.kind === "units" ? i : null, o = e.slice(n.start, n.end + +!!a).map((e) => e.id), s = e.slice(n.start, n.end).map((e) => e.id), c = Number(n.text);
|
|
@@ -622,14 +622,14 @@ function ct(e) {
|
|
|
622
622
|
units: null
|
|
623
623
|
});
|
|
624
624
|
}
|
|
625
|
-
for (let t of e) if (t.kind !== "units") for (let [e, r] of
|
|
625
|
+
for (let t of e) if (t.kind !== "units") for (let [e, r] of k(t)) {
|
|
626
626
|
let i = t.kind === "piecewise" && e === "otherwise";
|
|
627
627
|
n(r, i ? at(t) : null);
|
|
628
628
|
}
|
|
629
629
|
};
|
|
630
630
|
return n(e), t;
|
|
631
631
|
}
|
|
632
|
-
function
|
|
632
|
+
function ut(e, t) {
|
|
633
633
|
let n = e[t - 1];
|
|
634
634
|
if (n?.kind === "function") {
|
|
635
635
|
let e = Ue(n.name);
|
|
@@ -646,22 +646,22 @@ function lt(e, t) {
|
|
|
646
646
|
}
|
|
647
647
|
//#endregion
|
|
648
648
|
//#region src/editor/names.ts
|
|
649
|
-
var
|
|
650
|
-
function
|
|
651
|
-
let t =
|
|
649
|
+
var dt = /^([A-Za-z]+?)(\d*)$/;
|
|
650
|
+
function ft(e) {
|
|
651
|
+
let t = dt.exec(e);
|
|
652
652
|
if (!t) return null;
|
|
653
653
|
let [, n] = t;
|
|
654
|
-
return Ke.has(n) && !
|
|
654
|
+
return Ke.has(n) && !z(n) ? n : null;
|
|
655
655
|
}
|
|
656
|
-
function
|
|
656
|
+
function V(e, t = {}) {
|
|
657
657
|
let n = tt(e);
|
|
658
|
-
return n ? [
|
|
659
|
-
let n = t > 0 ? [
|
|
658
|
+
return n ? [P(n)] : t.greekNames === !1 ? R(e) : e.split("_").flatMap((e, t) => {
|
|
659
|
+
let n = t > 0 ? [P("_")] : [], r = ft(e);
|
|
660
660
|
return r ? [
|
|
661
661
|
...n,
|
|
662
|
-
|
|
663
|
-
...
|
|
664
|
-
] : [...n, ...
|
|
662
|
+
P(r),
|
|
663
|
+
...R(e.slice(r.length))
|
|
664
|
+
] : [...n, ...R(e)];
|
|
665
665
|
});
|
|
666
666
|
}
|
|
667
667
|
var pt = (e) => e.map((e) => `${e.atom}.${e.branch}`).join("/");
|
|
@@ -681,7 +681,7 @@ function gt(e, t, n, r, i) {
|
|
|
681
681
|
let a = pt(t), o = (e, i) => !r.cursorAway && (mt(n.cursor, t, e, i) || mt(n.anchor, t, e, i)), s = [];
|
|
682
682
|
for (let t of nt(e)) {
|
|
683
683
|
if (t.functionName || o(t.start, t.end)) continue;
|
|
684
|
-
let n = e.slice(t.start, t.end), i =
|
|
684
|
+
let n = e.slice(t.start, t.end), i = V(t.name, r), a = i.length === n.length && i.every((e, t) => e.kind === "symbol" && n[t].kind === "symbol" && e.value === n[t].value), c = r.greekNames === !1 && n.some(Xe);
|
|
685
685
|
!a && !c && s.push({
|
|
686
686
|
start: t.start,
|
|
687
687
|
end: t.end,
|
|
@@ -690,12 +690,12 @@ function gt(e, t, n, r, i) {
|
|
|
690
690
|
}
|
|
691
691
|
let c = e, l = !1, u = e.map((e, a) => {
|
|
692
692
|
let o = e;
|
|
693
|
-
for (let [s, c] of
|
|
693
|
+
for (let [s, c] of k(e)) {
|
|
694
694
|
let e = gt(c, [...t, {
|
|
695
695
|
atom: a,
|
|
696
696
|
branch: s
|
|
697
697
|
}], n, r, i);
|
|
698
|
-
e !== c && (o =
|
|
698
|
+
e !== c && (o = ve(o, s, e));
|
|
699
699
|
}
|
|
700
700
|
return o !== e && (l = !0), o;
|
|
701
701
|
});
|
|
@@ -925,7 +925,7 @@ function Vt(e, t, n = {}) {
|
|
|
925
925
|
if (t in Mt) return `\\mathrel{${H(e, Mt[t])}}`;
|
|
926
926
|
if (t === ",") return `\\mathpunct{${H(e, ",")}}`;
|
|
927
927
|
if (t in Nt) return H(e, Nt[t]);
|
|
928
|
-
let r =
|
|
928
|
+
let r = z(t);
|
|
929
929
|
return r ? H(e, r.latex) : /^[0-9.]$/.test(t) || /^[A-Za-z]$/.test(t) ? H(e, t) : Ke.has(t) && n.greekNames !== !1 ? H(e, `\\${t}`) : /^[A-Za-z]+$/.test(t) ? H(e, `\\mathit{${t}}`) : H(e, `\\text{${Array.from(t).map((e) => Pt[e] ?? e).join("")}}`);
|
|
930
930
|
}
|
|
931
931
|
function Ht(e, t = {}) {
|
|
@@ -933,7 +933,7 @@ function Ht(e, t = {}) {
|
|
|
933
933
|
}
|
|
934
934
|
function Ut(e, t, n) {
|
|
935
935
|
let r;
|
|
936
|
-
if (e.length === 0) r = `\\htmlClass{me-ph${n.activeRow &&
|
|
936
|
+
if (e.length === 0) r = `\\htmlClass{me-ph${n.activeRow && ye(n.activeRow, t) ? " me-ph-active" : ""}}{\\square}`;
|
|
937
937
|
else {
|
|
938
938
|
let i = [], a = new Map(nt(e).map((e) => [e.start, e])), o = new Map(rt(e).filter((e) => e.exponent !== null).map((e) => [e.start, e]));
|
|
939
939
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -990,7 +990,7 @@ function Wt(e, t, n) {
|
|
|
990
990
|
}
|
|
991
991
|
function Gt(e, t, n) {
|
|
992
992
|
if (e.length === 0) {
|
|
993
|
-
let e = `me-ph me-units-ph${n.activeRow &&
|
|
993
|
+
let e = `me-ph me-units-ph${n.activeRow && ye(n.activeRow, t) ? " me-ph-active" : ""}`;
|
|
994
994
|
return `\\htmlData{row=${kt(t)}}{\\htmlClass{${e}}{\\text{\\scriptsize units}}}`;
|
|
995
995
|
}
|
|
996
996
|
let r = e.map((e, r) => {
|
|
@@ -1050,7 +1050,7 @@ function Qt(e, t) {
|
|
|
1050
1050
|
}
|
|
1051
1051
|
var $t = (e) => e?.kind === "symbol" || e?.kind === "function";
|
|
1052
1052
|
function en(e, t, n, r) {
|
|
1053
|
-
let i =
|
|
1053
|
+
let i = M(t, n);
|
|
1054
1054
|
if (!i) return null;
|
|
1055
1055
|
if (i.length === 0) {
|
|
1056
1056
|
let t = Zt(e, n), r = t ? Yt(t) : null;
|
|
@@ -1090,7 +1090,7 @@ function tn(e, t, n) {
|
|
|
1090
1090
|
};
|
|
1091
1091
|
}
|
|
1092
1092
|
function nn(e, t, n, r) {
|
|
1093
|
-
let i =
|
|
1093
|
+
let i = M(t, n);
|
|
1094
1094
|
if (!i) return 0;
|
|
1095
1095
|
let a = 0, o = Infinity;
|
|
1096
1096
|
for (let s = 0; s <= i.length; s++) {
|
|
@@ -1113,7 +1113,7 @@ function an(e, t, n, r) {
|
|
|
1113
1113
|
let i = [];
|
|
1114
1114
|
for (let a of Array.from(e.querySelectorAll("[data-row]"))) {
|
|
1115
1115
|
let e = At(a.getAttribute("data-row"));
|
|
1116
|
-
if (!e || e.length <= i.length || !
|
|
1116
|
+
if (!e || e.length <= i.length || !M(t, e) || rn(a, n, r)) continue;
|
|
1117
1117
|
let o = Yt(a);
|
|
1118
1118
|
o && n >= o.left - 2 && n <= o.right + 2 && r >= o.top - 2 && r <= o.bottom + 2 && (i = e);
|
|
1119
1119
|
}
|
|
@@ -1123,7 +1123,7 @@ function an(e, t, n, r) {
|
|
|
1123
1123
|
};
|
|
1124
1124
|
}
|
|
1125
1125
|
function on(e, t, n) {
|
|
1126
|
-
let r =
|
|
1126
|
+
let r = M(t, n.path);
|
|
1127
1127
|
return r ? sn(e, r.slice(n.start, n.end).map((e) => e.id)) : null;
|
|
1128
1128
|
}
|
|
1129
1129
|
function sn(e, t, n = 2) {
|
|
@@ -1198,9 +1198,9 @@ function mn(e) {
|
|
|
1198
1198
|
return e.map((e) => {
|
|
1199
1199
|
let t = {
|
|
1200
1200
|
...e,
|
|
1201
|
-
id:
|
|
1201
|
+
id: N()
|
|
1202
1202
|
};
|
|
1203
|
-
for (let [n, r] of
|
|
1203
|
+
for (let [n, r] of k(e)) t = ve(t, n, mn(r));
|
|
1204
1204
|
return t;
|
|
1205
1205
|
});
|
|
1206
1206
|
}
|
|
@@ -1225,7 +1225,7 @@ var hn = {
|
|
|
1225
1225
|
function _n(e, t = {}) {
|
|
1226
1226
|
if (e in hn) return hn[e];
|
|
1227
1227
|
if (/^[A-Za-z0-9.+\-=,]$/.test(e)) return e;
|
|
1228
|
-
let n =
|
|
1228
|
+
let n = z(e);
|
|
1229
1229
|
return n ? /[a-z]$/i.test(n.latex) ? `${n.latex} ` : n.latex : Ke.has(e) && t.greekNames !== !1 ? `\\${e} ` : /^[A-Za-z]+$/.test(e) ? `\\mathit{${e}}` : `\\text{${Array.from(e, (e) => gn[e] ?? e).join("")}}`;
|
|
1230
1230
|
}
|
|
1231
1231
|
var vn = (e) => e?.kind === "symbol" && (/^[+\-−=,·*×]$/.test(e.value) || Ct(e.value) !== void 0);
|
|
@@ -1254,13 +1254,13 @@ function yn(e, t, n) {
|
|
|
1254
1254
|
let i = n.typesetNames === !1 ? null : bn(e, n);
|
|
1255
1255
|
if (i) return i;
|
|
1256
1256
|
let a = e.split("_");
|
|
1257
|
-
return n.greekNames !== !1 && a.some((e) =>
|
|
1258
|
-
let t =
|
|
1257
|
+
return n.greekNames !== !1 && a.some((e) => ft(e)) ? a.map((e) => {
|
|
1258
|
+
let t = ft(e);
|
|
1259
1259
|
return t ? `\\${t}${e.slice(t.length) || " "}` : e.length === 1 ? e : `\\mathit{${e}}`;
|
|
1260
1260
|
}).join("\\_") : e.length === 1 ? e : `\\mathit{${e.replace(/_/g, "\\_")}}`;
|
|
1261
1261
|
}
|
|
1262
1262
|
function bn(e, t) {
|
|
1263
|
-
let n =
|
|
1263
|
+
let n = V(e, t).map((e) => e.value), r = vt(n);
|
|
1264
1264
|
if (!r) return null;
|
|
1265
1265
|
let i = ([e, r]) => xn(n.slice(e, r), t), a = (e) => r.parts.filter((t) => t.role === e).map((e) => i(e.text)).join(","), o = a("sub"), s = a("sup"), c = `${i(r.base)}${o ? `_{${o}}` : ""}${s ? `^{${s}}` : ""}`;
|
|
1266
1266
|
return s ? `{${c}}` : c;
|
|
@@ -1394,7 +1394,7 @@ var wn = [
|
|
|
1394
1394
|
break;
|
|
1395
1395
|
}
|
|
1396
1396
|
}
|
|
1397
|
-
return this.casesDepth--,
|
|
1397
|
+
return this.casesDepth--, Te(e.length > 0 ? e : [[[], []]], t);
|
|
1398
1398
|
}
|
|
1399
1399
|
readConditionWord() {
|
|
1400
1400
|
let e = this.peek();
|
|
@@ -1440,42 +1440,42 @@ var wn = [
|
|
|
1440
1440
|
case "|": {
|
|
1441
1441
|
this.absDepth++;
|
|
1442
1442
|
let e = this.readUntilChar("|");
|
|
1443
|
-
this.absDepth--, t.push(
|
|
1443
|
+
this.absDepth--, t.push(L(e, "|"));
|
|
1444
1444
|
return;
|
|
1445
1445
|
}
|
|
1446
1446
|
case ")":
|
|
1447
1447
|
case "]": return;
|
|
1448
1448
|
case "^":
|
|
1449
|
-
t.push(
|
|
1449
|
+
t.push(I(this.readScript()));
|
|
1450
1450
|
return;
|
|
1451
1451
|
case "_":
|
|
1452
|
-
t.push(
|
|
1452
|
+
t.push(P("_"), ...jn(this.readScript(), 1));
|
|
1453
1453
|
return;
|
|
1454
1454
|
case "/":
|
|
1455
1455
|
t.push(this.readInfixFraction(t));
|
|
1456
1456
|
return;
|
|
1457
1457
|
case "*":
|
|
1458
|
-
t.push(
|
|
1458
|
+
t.push(P("·"));
|
|
1459
1459
|
return;
|
|
1460
1460
|
case "=": {
|
|
1461
1461
|
let e = t[t.length - 1], n = e?.kind === "symbol" ? e.value : "", r = Dt(n === "!" ? "¬" : n);
|
|
1462
|
-
r ? t[t.length - 1] =
|
|
1462
|
+
r ? t[t.length - 1] = P(r) : n !== "=" && t.push(P("="));
|
|
1463
1463
|
return;
|
|
1464
1464
|
}
|
|
1465
1465
|
case "!":
|
|
1466
|
-
t.push(
|
|
1466
|
+
t.push(P("¬"));
|
|
1467
1467
|
return;
|
|
1468
1468
|
case "&": {
|
|
1469
1469
|
let e = t[t.length - 1];
|
|
1470
|
-
(e?.kind !== "symbol" || e.value !== "∧") && t.push(
|
|
1470
|
+
(e?.kind !== "symbol" || e.value !== "∧") && t.push(P("∧"));
|
|
1471
1471
|
return;
|
|
1472
1472
|
}
|
|
1473
|
-
default: t.push(
|
|
1473
|
+
default: t.push(P(e === "−" ? "-" : e));
|
|
1474
1474
|
}
|
|
1475
1475
|
}
|
|
1476
1476
|
pushBrackets(e, t, n) {
|
|
1477
|
-
let r = n === "(" ?
|
|
1478
|
-
r ? e.splice(r.start, e.length - r.start,
|
|
1477
|
+
let r = n === "(" ? ut(e, e.length) : null;
|
|
1478
|
+
r ? e.splice(r.start, e.length - r.start, L(t, r.open)) : e.push(L(t, n === "[" ? "(" : n));
|
|
1479
1479
|
}
|
|
1480
1480
|
readUntilChar(e) {
|
|
1481
1481
|
let t = this.readRow({ char: e });
|
|
@@ -1492,7 +1492,7 @@ var wn = [
|
|
|
1492
1492
|
close: !0,
|
|
1493
1493
|
right: !0
|
|
1494
1494
|
}), a = i[0];
|
|
1495
|
-
return i.length === 1 && a.kind === "group" && a.open === "(" && (i = a.body),
|
|
1495
|
+
return i.length === 1 && a.kind === "group" && a.open === "(" && (i = a.body), xe(n, i);
|
|
1496
1496
|
}
|
|
1497
1497
|
readScript() {
|
|
1498
1498
|
let e = this.peek();
|
|
@@ -1500,7 +1500,7 @@ var wn = [
|
|
|
1500
1500
|
if (e.kind === "char" && /[0-9]/.test(e.value)) {
|
|
1501
1501
|
let e = "";
|
|
1502
1502
|
for (; this.peek()?.kind === "char" && /[0-9.]/.test(this.peek().value);) e += this.next().value;
|
|
1503
|
-
return Array.from(e, (e) =>
|
|
1503
|
+
return Array.from(e, (e) => P(e));
|
|
1504
1504
|
}
|
|
1505
1505
|
return this.readArgument();
|
|
1506
1506
|
}
|
|
@@ -1538,7 +1538,7 @@ var wn = [
|
|
|
1538
1538
|
if (Dn.has(e)) return;
|
|
1539
1539
|
let r = Tt(e);
|
|
1540
1540
|
if (r) {
|
|
1541
|
-
t.push(
|
|
1541
|
+
t.push(P(r.symbol));
|
|
1542
1542
|
return;
|
|
1543
1543
|
}
|
|
1544
1544
|
switch (e) {
|
|
@@ -1554,12 +1554,12 @@ var wn = [
|
|
|
1554
1554
|
case "dfrac":
|
|
1555
1555
|
case "tfrac": {
|
|
1556
1556
|
let e = this.readArgument(), n = this.readArgument(), r = (e) => e[0] !== void 0 && this.uprightD.has(e[0]);
|
|
1557
|
-
t.push(r(e) && r(n) ?
|
|
1557
|
+
t.push(r(e) && r(n) ? Ce(e.slice(1), n.slice(1)) : xe(e, n));
|
|
1558
1558
|
return;
|
|
1559
1559
|
}
|
|
1560
1560
|
case "sqrt": {
|
|
1561
1561
|
let e = null;
|
|
1562
|
-
this.peek()?.kind === "char" && this.peek().value === "[" && (this.next(), e = this.readUntilChar("]")), t.push(
|
|
1562
|
+
this.peek()?.kind === "char" && this.peek().value === "[" && (this.next(), e = this.readUntilChar("]")), t.push(Se(this.readArgument(), e));
|
|
1563
1563
|
return;
|
|
1564
1564
|
}
|
|
1565
1565
|
case "left": {
|
|
@@ -1572,7 +1572,7 @@ var wn = [
|
|
|
1572
1572
|
case "lfloor":
|
|
1573
1573
|
case "lceil": {
|
|
1574
1574
|
let n = this.readRow({ command: e === "lfloor" ? "rfloor" : "rceil" });
|
|
1575
|
-
this.next(), t.push(
|
|
1575
|
+
this.next(), t.push(L(n, e === "lfloor" ? "⌊" : "⌈"));
|
|
1576
1576
|
return;
|
|
1577
1577
|
}
|
|
1578
1578
|
case "rfloor":
|
|
@@ -1580,17 +1580,17 @@ var wn = [
|
|
|
1580
1580
|
case "right": return;
|
|
1581
1581
|
case "cdot":
|
|
1582
1582
|
case "ast":
|
|
1583
|
-
t.push(
|
|
1583
|
+
t.push(P("·"));
|
|
1584
1584
|
return;
|
|
1585
1585
|
case "times":
|
|
1586
|
-
t.push(
|
|
1586
|
+
t.push(P("×"));
|
|
1587
1587
|
return;
|
|
1588
1588
|
case "square":
|
|
1589
1589
|
case "Box": return;
|
|
1590
1590
|
case "{":
|
|
1591
1591
|
case "}":
|
|
1592
1592
|
case "|":
|
|
1593
|
-
t.push(
|
|
1593
|
+
t.push(P(e));
|
|
1594
1594
|
return;
|
|
1595
1595
|
case "mathrm":
|
|
1596
1596
|
case "operatorname":
|
|
@@ -1605,37 +1605,37 @@ var wn = [
|
|
|
1605
1605
|
}
|
|
1606
1606
|
let i = Je(e);
|
|
1607
1607
|
if (i) {
|
|
1608
|
-
t.push(
|
|
1608
|
+
t.push(F(i));
|
|
1609
1609
|
return;
|
|
1610
1610
|
}
|
|
1611
1611
|
let a = Me(e);
|
|
1612
|
-
t.push(
|
|
1612
|
+
t.push(P(a ?? e));
|
|
1613
1613
|
}
|
|
1614
1614
|
readNamed(e, t, n) {
|
|
1615
1615
|
if (!t) return;
|
|
1616
1616
|
if (e === "mathrm" && (t === "E" || t === "e" && this.peek()?.kind === "open")) {
|
|
1617
|
-
n.push(
|
|
1617
|
+
n.push(P(t));
|
|
1618
1618
|
return;
|
|
1619
1619
|
}
|
|
1620
1620
|
let r = e === "mathrm" ? Ne(t) : void 0;
|
|
1621
1621
|
if (r) {
|
|
1622
|
-
n.push(
|
|
1622
|
+
n.push(P(r));
|
|
1623
1623
|
return;
|
|
1624
1624
|
}
|
|
1625
1625
|
if (e === "mathrm" && t === "d") {
|
|
1626
|
-
let e =
|
|
1626
|
+
let e = P("d");
|
|
1627
1627
|
this.uprightD.add(e), n.push(e);
|
|
1628
1628
|
return;
|
|
1629
1629
|
}
|
|
1630
1630
|
if (e === "operatorname" || e === "mathrm") {
|
|
1631
|
-
n.push(
|
|
1631
|
+
n.push(F(Je(t) ?? t));
|
|
1632
1632
|
return;
|
|
1633
1633
|
}
|
|
1634
1634
|
if (e === "text" || e === "textrm") {
|
|
1635
|
-
n.push(...Array.from(t, (e) =>
|
|
1635
|
+
n.push(...Array.from(t, (e) => P(e)));
|
|
1636
1636
|
return;
|
|
1637
1637
|
}
|
|
1638
|
-
n.push(...Array.from(t, (e) =>
|
|
1638
|
+
n.push(...Array.from(t, (e) => P(e)));
|
|
1639
1639
|
}
|
|
1640
1640
|
};
|
|
1641
1641
|
function An(e) {
|
|
@@ -1643,21 +1643,21 @@ function An(e) {
|
|
|
1643
1643
|
return t.length > 0 && t[t.length - 1].end === e.length;
|
|
1644
1644
|
}
|
|
1645
1645
|
function jn(e, t) {
|
|
1646
|
-
return e.flatMap((e) => e.kind === "symbol" && e.value === "," ? Array.from({ length: t }, () =>
|
|
1646
|
+
return e.flatMap((e) => e.kind === "symbol" && e.value === "," ? Array.from({ length: t }, () => P("_")) : [e]);
|
|
1647
1647
|
}
|
|
1648
1648
|
function Mn(e) {
|
|
1649
1649
|
let t = e[e.length - 1];
|
|
1650
1650
|
if (t?.kind !== "superscript" || e.length < 2) return e;
|
|
1651
1651
|
let n = [
|
|
1652
1652
|
...e.slice(0, -1),
|
|
1653
|
-
|
|
1654
|
-
|
|
1653
|
+
P("_"),
|
|
1654
|
+
P("_"),
|
|
1655
1655
|
...jn(t.sup, 2)
|
|
1656
1656
|
], r = nt(n);
|
|
1657
1657
|
return r.length !== 1 || r[0].start !== 0 || r[0].end !== n.length || r[0].functionName ? e : vt(n.map((e) => e.value))?.parts.filter((e) => e.role === "sup").every((e) => Qe(n[e.text[0]])) ? n : e;
|
|
1658
1658
|
}
|
|
1659
1659
|
function Nn(e) {
|
|
1660
|
-
return
|
|
1660
|
+
return we(Array.from(e.trim(), (e) => P(e)));
|
|
1661
1661
|
}
|
|
1662
1662
|
function Pn(e) {
|
|
1663
1663
|
return new kn(Cn(e)).readAll();
|
|
@@ -1671,7 +1671,7 @@ function Ln(e, t) {
|
|
|
1671
1671
|
let t = n?.[e.atom];
|
|
1672
1672
|
if (!t) return null;
|
|
1673
1673
|
if (t.kind === "units") return t.id;
|
|
1674
|
-
n =
|
|
1674
|
+
n = k(t).find(([t]) => t === e.branch)?.[1] ?? null;
|
|
1675
1675
|
}
|
|
1676
1676
|
return null;
|
|
1677
1677
|
}
|
|
@@ -1695,7 +1695,7 @@ function Un(e, t, n) {
|
|
|
1695
1695
|
return r !== null && Vn.test(r + n);
|
|
1696
1696
|
}
|
|
1697
1697
|
function Wn(e, t) {
|
|
1698
|
-
let n =
|
|
1698
|
+
let n = M(e, t.path);
|
|
1699
1699
|
return n && Fn(n[t.offset]) ? {
|
|
1700
1700
|
...t,
|
|
1701
1701
|
offset: t.offset + 1
|
|
@@ -1722,12 +1722,12 @@ function qn(e, t, n, r) {
|
|
|
1722
1722
|
return (s.units.length === 0 || !Hn(e, c)) && !r ? (a.push(c), []) : [s];
|
|
1723
1723
|
}
|
|
1724
1724
|
let l = s;
|
|
1725
|
-
for (let [e, i] of
|
|
1725
|
+
for (let [e, i] of k(s)) {
|
|
1726
1726
|
let a = qn(i, [...t, {
|
|
1727
1727
|
atom: c,
|
|
1728
1728
|
branch: e
|
|
1729
1729
|
}], n, r);
|
|
1730
|
-
a !== i && (l =
|
|
1730
|
+
a !== i && (l = ve(l, e, a));
|
|
1731
1731
|
}
|
|
1732
1732
|
return l !== s && (o = !0), [l];
|
|
1733
1733
|
});
|
|
@@ -1764,7 +1764,7 @@ function Xn(e) {
|
|
|
1764
1764
|
};
|
|
1765
1765
|
}
|
|
1766
1766
|
function Zn(e, t) {
|
|
1767
|
-
return e.offset === t.offset &&
|
|
1767
|
+
return e.offset === t.offset && ye(e.path, t.path);
|
|
1768
1768
|
}
|
|
1769
1769
|
function Qn(e) {
|
|
1770
1770
|
return `${e.path.map((e) => `${e.atom}.${e.branch}`).join(" › ") || "root"} @ ${e.offset}`;
|
|
@@ -1774,7 +1774,7 @@ function $n(e) {
|
|
|
1774
1774
|
for (let i = 0; i <= e.length; i++) if (!Fn(e[i]) && (t.push({
|
|
1775
1775
|
path: r,
|
|
1776
1776
|
offset: i
|
|
1777
|
-
}), i < e.length)) for (let [t, a] of
|
|
1777
|
+
}), i < e.length)) for (let [t, a] of k(e[i])) n(a, [...r, {
|
|
1778
1778
|
atom: i,
|
|
1779
1779
|
branch: t
|
|
1780
1780
|
}]);
|
|
@@ -1783,7 +1783,7 @@ function $n(e) {
|
|
|
1783
1783
|
}
|
|
1784
1784
|
function er(e, t) {
|
|
1785
1785
|
if (t.length === 0) return null;
|
|
1786
|
-
let n = t.slice(0, -1), r =
|
|
1786
|
+
let n = t.slice(0, -1), r = M(e, n), { atom: i, branch: a } = t[t.length - 1];
|
|
1787
1787
|
if (!r || !r[i]) throw Error("Cursor path does not resolve");
|
|
1788
1788
|
return {
|
|
1789
1789
|
rowPath: n,
|
|
@@ -1794,14 +1794,14 @@ function er(e, t) {
|
|
|
1794
1794
|
};
|
|
1795
1795
|
}
|
|
1796
1796
|
function tr(e, t) {
|
|
1797
|
-
let n =
|
|
1797
|
+
let n = M(e, t);
|
|
1798
1798
|
if (!n) throw Error("Cursor path does not resolve");
|
|
1799
1799
|
return n;
|
|
1800
1800
|
}
|
|
1801
1801
|
function nr(e, t) {
|
|
1802
1802
|
let n = tr(e, t.path);
|
|
1803
1803
|
if (t.offset < n.length) {
|
|
1804
|
-
let e = n[t.offset], r = Fn(e) ? [] :
|
|
1804
|
+
let e = n[t.offset], r = Fn(e) ? [] : k(e);
|
|
1805
1805
|
if (r.length > 0) return {
|
|
1806
1806
|
path: [...t.path, {
|
|
1807
1807
|
atom: t.offset,
|
|
@@ -1817,7 +1817,7 @@ function nr(e, t) {
|
|
|
1817
1817
|
}
|
|
1818
1818
|
let r = er(e, t.path);
|
|
1819
1819
|
if (!r) return null;
|
|
1820
|
-
let i =
|
|
1820
|
+
let i = k(r.atom), a = i[i.findIndex(([e]) => e === r.branch) + 1];
|
|
1821
1821
|
return a ? {
|
|
1822
1822
|
path: [...r.rowPath, {
|
|
1823
1823
|
atom: r.atomIndex,
|
|
@@ -1837,7 +1837,7 @@ function rr(e, t) {
|
|
|
1837
1837
|
path: t.path,
|
|
1838
1838
|
offset: r
|
|
1839
1839
|
});
|
|
1840
|
-
let i =
|
|
1840
|
+
let i = k(n[r]);
|
|
1841
1841
|
if (i.length > 0) {
|
|
1842
1842
|
let [e, n] = i[i.length - 1];
|
|
1843
1843
|
return {
|
|
@@ -1855,7 +1855,7 @@ function rr(e, t) {
|
|
|
1855
1855
|
}
|
|
1856
1856
|
let r = er(e, t.path);
|
|
1857
1857
|
if (!r) return null;
|
|
1858
|
-
let i =
|
|
1858
|
+
let i = k(r.atom), a = i[i.findIndex(([e]) => e === r.branch) - 1];
|
|
1859
1859
|
if (a) {
|
|
1860
1860
|
let [e, t] = a;
|
|
1861
1861
|
return {
|
|
@@ -1881,7 +1881,7 @@ var ir = {
|
|
|
1881
1881
|
};
|
|
1882
1882
|
function ar(e, t) {
|
|
1883
1883
|
if (e.kind !== "piecewise") return ir[e.kind] ?? null;
|
|
1884
|
-
let n =
|
|
1884
|
+
let n = A(t);
|
|
1885
1885
|
if (!n) return null;
|
|
1886
1886
|
let r = n.part === "otherwise" ? "value" : n.part, i = e.pieces.map((e, t) => `${r}${t}`);
|
|
1887
1887
|
return e.otherwise ? [...i, "otherwise"] : i;
|
|
@@ -1891,7 +1891,7 @@ function sr(e, t, n, r) {
|
|
|
1891
1891
|
for (let i = t.path.length; i > 0; i--) {
|
|
1892
1892
|
let a = er(e, t.path.slice(0, i)), o = ar(a.atom, a.branch);
|
|
1893
1893
|
if (!o) continue;
|
|
1894
|
-
let s =
|
|
1894
|
+
let s = k(a.atom).map(([e]) => e), c = o.filter((e) => s.includes(e)), l = c.indexOf(a.branch), u = c[l + n];
|
|
1895
1895
|
if (l < 0 || !u) continue;
|
|
1896
1896
|
let d = [...a.rowPath, {
|
|
1897
1897
|
atom: a.atomIndex,
|
|
@@ -1926,7 +1926,7 @@ function G(e) {
|
|
|
1926
1926
|
}
|
|
1927
1927
|
function ur(e) {
|
|
1928
1928
|
let t = G(e);
|
|
1929
|
-
return t ?
|
|
1929
|
+
return t ? M(e.root, t.path).slice(t.start, t.end) : [];
|
|
1930
1930
|
}
|
|
1931
1931
|
function dr(e) {
|
|
1932
1932
|
return `${e.path.map((e) => `${e.atom}.${e.branch}`).join(" › ") || "root"} ${e.start}–${e.end}`;
|
|
@@ -1944,7 +1944,7 @@ function fr(e, t, n) {
|
|
|
1944
1944
|
};
|
|
1945
1945
|
}
|
|
1946
1946
|
function pr(e, t) {
|
|
1947
|
-
let n = e.anchor ?? e.cursor, { path: r, offset: i } = e.cursor, a =
|
|
1947
|
+
let n = e.anchor ?? e.cursor, { path: r, offset: i } = e.cursor, a = M(e.root, r), o;
|
|
1948
1948
|
if (t === "forward" ? i < a.length : i > 0) {
|
|
1949
1949
|
let e = i + (t === "forward" ? 1 : -1);
|
|
1950
1950
|
t === "backward" && Fn(a[i - 1]) && (e = Math.max(0, i - 2)), t === "forward" && Fn(a[e]) && e++, o = {
|
|
@@ -2010,16 +2010,16 @@ function br() {
|
|
|
2010
2010
|
};
|
|
2011
2011
|
}
|
|
2012
2012
|
function K(e, t) {
|
|
2013
|
-
let n =
|
|
2013
|
+
let n = M(e, t);
|
|
2014
2014
|
if (!n) throw Error("Cursor path does not resolve");
|
|
2015
2015
|
return n;
|
|
2016
2016
|
}
|
|
2017
2017
|
function xr(e, t, n) {
|
|
2018
2018
|
if (t.length === 0) return n(e);
|
|
2019
|
-
let [r, ...i] = t, a = e[r.atom], o =
|
|
2019
|
+
let [r, ...i] = t, a = e[r.atom], o = j(a, r.branch);
|
|
2020
2020
|
if (!o) throw Error("Cursor path does not resolve");
|
|
2021
2021
|
let s = e.slice();
|
|
2022
|
-
return s[r.atom] =
|
|
2022
|
+
return s[r.atom] = ve(a, r.branch, xr(o, i, n)), s;
|
|
2023
2023
|
}
|
|
2024
2024
|
function q(e, t, n, r, i, a) {
|
|
2025
2025
|
return {
|
|
@@ -2045,7 +2045,7 @@ function Cr(e) {
|
|
|
2045
2045
|
return e?.kind === "symbol" && Sr.has(e.value);
|
|
2046
2046
|
}
|
|
2047
2047
|
function wr(e) {
|
|
2048
|
-
let t =
|
|
2048
|
+
let t = k(e);
|
|
2049
2049
|
return t.length > 0 && t.every(([, e]) => e.length === 0);
|
|
2050
2050
|
}
|
|
2051
2051
|
function Tr(e, t = e.cursor.path.length) {
|
|
@@ -2069,7 +2069,7 @@ function Er(e, t, n) {
|
|
|
2069
2069
|
}
|
|
2070
2070
|
};
|
|
2071
2071
|
}
|
|
2072
|
-
let r =
|
|
2072
|
+
let r = k(t.atom).flatMap(([, e]) => e);
|
|
2073
2073
|
return q(e, t.rowPath, t.index, 1, r, {
|
|
2074
2074
|
path: t.rowPath,
|
|
2075
2075
|
offset: t.index + n
|
|
@@ -2088,7 +2088,7 @@ var Or = (e, t) => [...e.rowPath, {
|
|
|
2088
2088
|
}], kr = (e) => e.value.length === 0 && e.condition.length === 0, Ar = (e) => {
|
|
2089
2089
|
let t = Dr(e);
|
|
2090
2090
|
if (!t) return e;
|
|
2091
|
-
let n =
|
|
2091
|
+
let n = A(t.branch), { pieces: r } = t.atom, i = n.part === "otherwise" ? r.length : n.piece + 1, a = {
|
|
2092
2092
|
...t.atom,
|
|
2093
2093
|
pieces: [
|
|
2094
2094
|
...r.slice(0, i),
|
|
@@ -2114,7 +2114,7 @@ var Or = (e, t) => [...e.rowPath, {
|
|
|
2114
2114
|
offset: t.atom.otherwise.length
|
|
2115
2115
|
}
|
|
2116
2116
|
};
|
|
2117
|
-
let r =
|
|
2117
|
+
let r = R("0.0");
|
|
2118
2118
|
return {
|
|
2119
2119
|
...q(e, t.rowPath, t.index, 1, [{
|
|
2120
2120
|
...t.atom,
|
|
@@ -2130,7 +2130,7 @@ var Or = (e, t) => [...e.rowPath, {
|
|
|
2130
2130
|
};
|
|
2131
2131
|
};
|
|
2132
2132
|
function Mr(e, t) {
|
|
2133
|
-
let n =
|
|
2133
|
+
let n = A(t.branch), { pieces: r, otherwise: i } = t.atom;
|
|
2134
2134
|
if (n.part === "otherwise") {
|
|
2135
2135
|
if (!i || i.length > 0) return null;
|
|
2136
2136
|
let n = r.length - 1;
|
|
@@ -2156,7 +2156,7 @@ function Mr(e, t) {
|
|
|
2156
2156
|
return q(e, t.rowPath, t.index, 1, [a], o);
|
|
2157
2157
|
}
|
|
2158
2158
|
function Nr(e, t) {
|
|
2159
|
-
let n =
|
|
2159
|
+
let n = A(t.branch), { pieces: r, otherwise: i } = t.atom;
|
|
2160
2160
|
if (n.part === "otherwise") return !i || i.length > 0 ? null : q(e, t.rowPath, t.index, 1, [{
|
|
2161
2161
|
...t.atom,
|
|
2162
2162
|
otherwise: null
|
|
@@ -2237,7 +2237,7 @@ function Rr(e) {
|
|
|
2237
2237
|
function J(e) {
|
|
2238
2238
|
return (t) => {
|
|
2239
2239
|
let n = Pr(t), { path: r, offset: i } = n.cursor;
|
|
2240
|
-
return q(n, r, i, 0, [
|
|
2240
|
+
return q(n, r, i, 0, [P(e)], {
|
|
2241
2241
|
path: r,
|
|
2242
2242
|
offset: i + 1
|
|
2243
2243
|
});
|
|
@@ -2249,7 +2249,7 @@ var zr = (e) => {
|
|
|
2249
2249
|
if (i) return q({
|
|
2250
2250
|
root: e.root,
|
|
2251
2251
|
cursor: e.cursor
|
|
2252
|
-
}, t, n - 1, 1, [
|
|
2252
|
+
}, t, n - 1, 1, [P(i)], {
|
|
2253
2253
|
path: t,
|
|
2254
2254
|
offset: n
|
|
2255
2255
|
});
|
|
@@ -2258,7 +2258,7 @@ var zr = (e) => {
|
|
|
2258
2258
|
}, Br = (e) => {
|
|
2259
2259
|
let t = G(e);
|
|
2260
2260
|
if (t) {
|
|
2261
|
-
let { path: n, start: r, end: i } = t, a =
|
|
2261
|
+
let { path: n, start: r, end: i } = t, a = Te([[K(e.root, n).slice(r, i), []]], R("0.0"));
|
|
2262
2262
|
return q(e, n, r, i - r, [a], {
|
|
2263
2263
|
path: [...n, {
|
|
2264
2264
|
atom: r,
|
|
@@ -2267,7 +2267,7 @@ var zr = (e) => {
|
|
|
2267
2267
|
offset: 0
|
|
2268
2268
|
});
|
|
2269
2269
|
}
|
|
2270
|
-
return Vr(
|
|
2270
|
+
return Vr(Te([[[], []]], R("0.0")), "value0")(e);
|
|
2271
2271
|
};
|
|
2272
2272
|
function Vr(e, t) {
|
|
2273
2273
|
return (n) => {
|
|
@@ -2281,12 +2281,12 @@ function Vr(e, t) {
|
|
|
2281
2281
|
});
|
|
2282
2282
|
};
|
|
2283
2283
|
}
|
|
2284
|
-
var Hr = Ir((e) =>
|
|
2284
|
+
var Hr = Ir((e) => xe(Fr(e), []), "den", "num"), Ur = (e) => {
|
|
2285
2285
|
if (G(e)) return Hr(e);
|
|
2286
2286
|
let t = Pr(e), { path: n, offset: r } = t.cursor, i = K(t.root, n), a = r;
|
|
2287
2287
|
for (; a > 0 && !Cr(i[a - 1]);) a--;
|
|
2288
2288
|
let o = Fr(i.slice(a, r)), s = o.length > 0 ? "den" : "num";
|
|
2289
|
-
return q(t, n, a, r - a, [
|
|
2289
|
+
return q(t, n, a, r - a, [xe(o, [])], {
|
|
2290
2290
|
path: [...n, {
|
|
2291
2291
|
atom: a,
|
|
2292
2292
|
branch: s
|
|
@@ -2296,8 +2296,8 @@ var Hr = Ir((e) => L(Fr(e), []), "den", "num"), Ur = (e) => {
|
|
|
2296
2296
|
}, Wr = (e) => {
|
|
2297
2297
|
let t = G(e);
|
|
2298
2298
|
if (t) {
|
|
2299
|
-
let { path: n, start: r, end: i } = t, a = K(e.root, n).slice(r, i), o = a.length === 1 ? a : [
|
|
2300
|
-
return q(e, n, r, i - r, [...o,
|
|
2299
|
+
let { path: n, start: r, end: i } = t, a = K(e.root, n).slice(r, i), o = a.length === 1 ? a : [L(a, "(")];
|
|
2300
|
+
return q(e, n, r, i - r, [...o, I()], {
|
|
2301
2301
|
path: [...n, {
|
|
2302
2302
|
atom: r + o.length,
|
|
2303
2303
|
branch: "sup"
|
|
@@ -2324,7 +2324,7 @@ var Hr = Ir((e) => L(Fr(e), []), "den", "num"), Ur = (e) => {
|
|
|
2324
2324
|
}],
|
|
2325
2325
|
offset: s.sup.length
|
|
2326
2326
|
}
|
|
2327
|
-
} : Vr(
|
|
2327
|
+
} : Vr(I(), "sup")(n);
|
|
2328
2328
|
};
|
|
2329
2329
|
function Gr(e, t) {
|
|
2330
2330
|
for (let n = e.cursor.path.length; n > 0; n--) {
|
|
@@ -2355,10 +2355,10 @@ function Kr(e) {
|
|
|
2355
2355
|
return q(n, i.rowPath, i.index, 1, [l, ...s.slice(c)], o);
|
|
2356
2356
|
};
|
|
2357
2357
|
}
|
|
2358
|
-
var qr = (e) => Ir((t) =>
|
|
2358
|
+
var qr = (e) => Ir((t) => L(t, e), "after", "body"), Jr = (e) => {
|
|
2359
2359
|
if (!G(e)) {
|
|
2360
|
-
let { path: t, offset: n } = e.cursor, r =
|
|
2361
|
-
if (r) return q(e, t, r.start, n - r.start, [
|
|
2360
|
+
let { path: t, offset: n } = e.cursor, r = ut(K(e.root, t), n);
|
|
2361
|
+
if (r) return q(e, t, r.start, n - r.start, [L([], r.open)], {
|
|
2362
2362
|
path: [...t, {
|
|
2363
2363
|
atom: r.start,
|
|
2364
2364
|
branch: "body"
|
|
@@ -2388,12 +2388,12 @@ var qr = (e) => Ir((t) => R(t, e), "after", "body"), Jr = (e) => {
|
|
|
2388
2388
|
};
|
|
2389
2389
|
}
|
|
2390
2390
|
let i = Pr(e), a = i.cursor.offset;
|
|
2391
|
-
return rt(K(i.root, i.cursor.path).slice(0, a)).find((e) => e.end === a) ? Vr(
|
|
2391
|
+
return rt(K(i.root, i.cursor.path).slice(0, a)).find((e) => e.end === a) ? Vr(we(), "units")(i) : e;
|
|
2392
2392
|
};
|
|
2393
2393
|
function Xr(e) {
|
|
2394
2394
|
return (t) => {
|
|
2395
2395
|
let { path: n, offset: r } = t.cursor, i = K(t.root, n);
|
|
2396
|
-
return !G(t) && Fn(i[r - 1]) && Un(i, r - 1, e) ? q(t, n, r - 1, 0, [
|
|
2396
|
+
return !G(t) && Fn(i[r - 1]) && Un(i, r - 1, e) ? q(t, n, r - 1, 0, [P(e)], {
|
|
2397
2397
|
path: n,
|
|
2398
2398
|
offset: r + 1
|
|
2399
2399
|
}) : J(e)(t);
|
|
@@ -2419,7 +2419,7 @@ var Zr = (e) => {
|
|
|
2419
2419
|
]), ti = (e) => {
|
|
2420
2420
|
if (G(e)) return li(e);
|
|
2421
2421
|
let t = Tr(e);
|
|
2422
|
-
return t?.atom.kind === "group" && t.atom.open === "|" ? Kr(["|"])(e) : Vr(
|
|
2422
|
+
return t?.atom.kind === "group" && t.atom.open === "|" ? Kr(["|"])(e) : Vr(L([], "|"), "body")(e);
|
|
2423
2423
|
}, ni = (e) => {
|
|
2424
2424
|
if (G(e)) return _r(e, "end");
|
|
2425
2425
|
let t = Tr(e);
|
|
@@ -2450,7 +2450,7 @@ var Zr = (e) => {
|
|
|
2450
2450
|
offset: a
|
|
2451
2451
|
});
|
|
2452
2452
|
if (i.kind === "function") {
|
|
2453
|
-
let n =
|
|
2453
|
+
let n = R(Lr(i.name).slice(0, -1));
|
|
2454
2454
|
return q(e, t, a, 1, n, {
|
|
2455
2455
|
path: t,
|
|
2456
2456
|
offset: a + n.length
|
|
@@ -2460,7 +2460,7 @@ var Zr = (e) => {
|
|
|
2460
2460
|
path: t,
|
|
2461
2461
|
offset: a
|
|
2462
2462
|
});
|
|
2463
|
-
let o =
|
|
2463
|
+
let o = k(i), [s, c] = o[o.length - 1];
|
|
2464
2464
|
return {
|
|
2465
2465
|
root: e.root,
|
|
2466
2466
|
cursor: {
|
|
@@ -2482,7 +2482,7 @@ var Zr = (e) => {
|
|
|
2482
2482
|
path: i.rowPath,
|
|
2483
2483
|
offset: i.index
|
|
2484
2484
|
});
|
|
2485
|
-
let a =
|
|
2485
|
+
let a = k(i.atom), o = a.findIndex(([e]) => e === i.branch);
|
|
2486
2486
|
if (o > 0) {
|
|
2487
2487
|
let [t, n] = a[o - 1];
|
|
2488
2488
|
return {
|
|
@@ -2506,7 +2506,7 @@ var Zr = (e) => {
|
|
|
2506
2506
|
path: t,
|
|
2507
2507
|
offset: n
|
|
2508
2508
|
});
|
|
2509
|
-
if (i.kind === "function") return q(e, t, n, 1,
|
|
2509
|
+
if (i.kind === "function") return q(e, t, n, 1, R(Lr(i.name).slice(1)), {
|
|
2510
2510
|
path: t,
|
|
2511
2511
|
offset: n
|
|
2512
2512
|
});
|
|
@@ -2514,7 +2514,7 @@ var Zr = (e) => {
|
|
|
2514
2514
|
path: t,
|
|
2515
2515
|
offset: n
|
|
2516
2516
|
});
|
|
2517
|
-
let [a] =
|
|
2517
|
+
let [a] = k(i)[0];
|
|
2518
2518
|
return {
|
|
2519
2519
|
root: e.root,
|
|
2520
2520
|
cursor: {
|
|
@@ -2536,7 +2536,7 @@ var Zr = (e) => {
|
|
|
2536
2536
|
path: i.rowPath,
|
|
2537
2537
|
offset: i.index
|
|
2538
2538
|
});
|
|
2539
|
-
let a =
|
|
2539
|
+
let a = k(i.atom), o = a.findIndex(([e]) => e === i.branch);
|
|
2540
2540
|
if (o < a.length - 1) {
|
|
2541
2541
|
let [t] = a[o + 1];
|
|
2542
2542
|
return {
|
|
@@ -2568,13 +2568,13 @@ function oi(e) {
|
|
|
2568
2568
|
let n = G(t);
|
|
2569
2569
|
if (n) {
|
|
2570
2570
|
let { path: r, start: i, end: a } = n, o = K(t.root, r).slice(i, a);
|
|
2571
|
-
return q(t, r, i, a - i, [
|
|
2571
|
+
return q(t, r, i, a - i, [F(e), L(o, "(")], {
|
|
2572
2572
|
path: r,
|
|
2573
2573
|
offset: i + 2
|
|
2574
2574
|
});
|
|
2575
2575
|
}
|
|
2576
2576
|
let r = Pr(t), { path: i, offset: a } = r.cursor;
|
|
2577
|
-
return q(r, i, a, 0, [
|
|
2577
|
+
return q(r, i, a, 0, [F(e), L([], "(")], {
|
|
2578
2578
|
path: [...i, {
|
|
2579
2579
|
atom: a + 1,
|
|
2580
2580
|
branch: "body"
|
|
@@ -2583,7 +2583,7 @@ function oi(e) {
|
|
|
2583
2583
|
});
|
|
2584
2584
|
};
|
|
2585
2585
|
}
|
|
2586
|
-
var si = Ir((e) =>
|
|
2586
|
+
var si = Ir((e) => Se(e), "after", "body"), ci = Ir((e) => Se(e, []), "index", "index"), li = Ir((e) => L(e, "|"), "after", "body"), ui = Ir((e) => Ce(e, []), "variable", "expr");
|
|
2587
2587
|
function di(e) {
|
|
2588
2588
|
switch (e) {
|
|
2589
2589
|
case "frac":
|
|
@@ -2611,7 +2611,7 @@ function di(e) {
|
|
|
2611
2611
|
let n = ke(e);
|
|
2612
2612
|
if (n) return J(n.symbol);
|
|
2613
2613
|
let r = Je(e);
|
|
2614
|
-
return r ? oi(r) : Rr(Ke.has(e) ? [
|
|
2614
|
+
return r ? oi(r) : Rr(Ke.has(e) ? [P(e)] : R(e));
|
|
2615
2615
|
}
|
|
2616
2616
|
//#endregion
|
|
2617
2617
|
//#region src/editor/history.ts
|
|
@@ -2758,7 +2758,7 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2758
2758
|
symbol: "∧",
|
|
2759
2759
|
level: Y.And
|
|
2760
2760
|
}
|
|
2761
|
-
}, Ti = new Map(yt.filter((e) => e.role === "comparison").map((e) => [e.mathml, e.symbol])), Ei = new Map(
|
|
2761
|
+
}, Ti = new Map(yt.filter((e) => e.role === "comparison").map((e) => [e.mathml, e.symbol])), Ei = new Map(Ee.map((e) => [e.mathml, e.symbol])), Di = new Map(Object.values(ze).map((e) => [e.mathMlTag, e.name])), Oi = /^[A-Za-z_][A-Za-z0-9_]*$/, ki = class {
|
|
2762
2762
|
problems;
|
|
2763
2763
|
constructor(e) {
|
|
2764
2764
|
this.problems = e;
|
|
@@ -2771,7 +2771,7 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2771
2771
|
case "piecewise": return this.piecewise(e);
|
|
2772
2772
|
default: {
|
|
2773
2773
|
let t = Ei.get(e.localName);
|
|
2774
|
-
return t ? X([
|
|
2774
|
+
return t ? X([P(t)]) : this.unsupported(`<${e.localName}>`);
|
|
2775
2775
|
}
|
|
2776
2776
|
}
|
|
2777
2777
|
}
|
|
@@ -2780,7 +2780,7 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2780
2780
|
}
|
|
2781
2781
|
identifier(e) {
|
|
2782
2782
|
let t = (e.textContent ?? "").trim();
|
|
2783
|
-
return t === "_" ? X([]) : Oi.test(t) ? (Je(t) ? this.problems.add(`The variable ${t} has the name of a function, so it reads as one here`) : tt(t) && this.problems.add(`The variable ${t} has a reserved name, so it reads as the constant here`), X(
|
|
2783
|
+
return t === "_" ? X([]) : Oi.test(t) ? (Je(t) ? this.problems.add(`The variable ${t} has the name of a function, so it reads as one here`) : tt(t) && this.problems.add(`The variable ${t} has a reserved name, so it reads as the constant here`), X(V(t))) : (this.problems.add(`"${t}" isn't a CellML variable name`), X(R(t)));
|
|
2784
2784
|
}
|
|
2785
2785
|
number(e) {
|
|
2786
2786
|
let t = Pi(e), n;
|
|
@@ -2790,9 +2790,9 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2790
2790
|
} else n = (e.textContent ?? "").trim();
|
|
2791
2791
|
let r = n.startsWith("-"), i = r ? n.slice(1) : n.replace(/^\+/, "");
|
|
2792
2792
|
/^(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(i) || this.problems.add(`"${n}" isn't a number`);
|
|
2793
|
-
let a =
|
|
2794
|
-
return t && t !== "dimensionless" && (Oi.test(t) || this.problems.add(`"${t}" isn't a units name`), a.push(
|
|
2795
|
-
row: [
|
|
2793
|
+
let a = R(i);
|
|
2794
|
+
return t && t !== "dimensionless" && (Oi.test(t) || this.problems.add(`"${t}" isn't a units name`), a.push(we(R(t)))), r ? {
|
|
2795
|
+
row: [P("-"), ...a],
|
|
2796
2796
|
level: Y.Unary
|
|
2797
2797
|
} : X(a);
|
|
2798
2798
|
}
|
|
@@ -2807,7 +2807,7 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2807
2807
|
return {
|
|
2808
2808
|
row: [
|
|
2809
2809
|
...Mi(e, Y.Additive),
|
|
2810
|
-
|
|
2810
|
+
P(n),
|
|
2811
2811
|
...Mi(t, Y.Additive)
|
|
2812
2812
|
],
|
|
2813
2813
|
level: Y.Comparison
|
|
@@ -2824,7 +2824,7 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2824
2824
|
case "not": {
|
|
2825
2825
|
let [e] = a();
|
|
2826
2826
|
return e ? {
|
|
2827
|
-
row: [
|
|
2827
|
+
row: [P("¬"), ...Mi(e, Y.Not)],
|
|
2828
2828
|
level: Y.Not
|
|
2829
2829
|
} : this.unsupported("<not> without an operand");
|
|
2830
2830
|
}
|
|
@@ -2835,7 +2835,7 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2835
2835
|
case "minus": {
|
|
2836
2836
|
let e = a();
|
|
2837
2837
|
if (e.length === 1) return {
|
|
2838
|
-
row: [
|
|
2838
|
+
row: [P("-"), ...Mi(e[0], Y.Term)],
|
|
2839
2839
|
level: Y.Unary
|
|
2840
2840
|
};
|
|
2841
2841
|
if (e.length !== 2) return this.unsupported("<minus> with more than two operands");
|
|
@@ -2843,7 +2843,7 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2843
2843
|
return {
|
|
2844
2844
|
row: [
|
|
2845
2845
|
...Mi(t, Y.Additive),
|
|
2846
|
-
|
|
2846
|
+
P("-"),
|
|
2847
2847
|
...Mi(n, Y.Term)
|
|
2848
2848
|
],
|
|
2849
2849
|
level: Y.Additive
|
|
@@ -2855,21 +2855,21 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2855
2855
|
};
|
|
2856
2856
|
case "divide": {
|
|
2857
2857
|
let [e, t] = a();
|
|
2858
|
-
return !e || !t ? this.unsupported("<divide> without two operands") : X([
|
|
2858
|
+
return !e || !t ? this.unsupported("<divide> without two operands") : X([xe(e.row, t.row)]);
|
|
2859
2859
|
}
|
|
2860
2860
|
case "power": {
|
|
2861
2861
|
let [e, t] = a();
|
|
2862
|
-
return !e || !t ? this.unsupported("<power> without two operands") : X([...Mi(e, Y.Primary),
|
|
2862
|
+
return !e || !t ? this.unsupported("<power> without two operands") : X([...Mi(e, Y.Primary), I(t.row)]);
|
|
2863
2863
|
}
|
|
2864
2864
|
case "root": {
|
|
2865
2865
|
let [e] = a();
|
|
2866
2866
|
if (!e) return this.unsupported("<root> without an operand");
|
|
2867
2867
|
let t = ji(r, "degree"), n = t ? this.inner(t) : null;
|
|
2868
|
-
return X([
|
|
2868
|
+
return X([Se(e.row, n)]);
|
|
2869
2869
|
}
|
|
2870
2870
|
case "abs": {
|
|
2871
2871
|
let [e] = a();
|
|
2872
|
-
return e ? X([
|
|
2872
|
+
return e ? X([L(e.row, "|")]) : this.unsupported("<abs> without an operand");
|
|
2873
2873
|
}
|
|
2874
2874
|
case "diff": return this.derivative(r, i);
|
|
2875
2875
|
default: return this.functionCall(o, r, a());
|
|
@@ -2880,18 +2880,18 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2880
2880
|
if (!r) return this.unsupported(`<${e}>`);
|
|
2881
2881
|
if (n.length === 0) return this.unsupported(`<${e}> without an operand`);
|
|
2882
2882
|
let i = Ue(r);
|
|
2883
|
-
if (i && n.length === 1) return X([
|
|
2883
|
+
if (i && n.length === 1) return X([L(n[0].row, i.open, i.close)]);
|
|
2884
2884
|
let a = e === "log" ? ji(t, "logbase") : void 0, o = (a ? [n[0], {
|
|
2885
2885
|
row: this.inner(a),
|
|
2886
2886
|
level: Y.Primary
|
|
2887
|
-
}] : n).flatMap((e, t) => t === 0 ? e.row : [
|
|
2888
|
-
return X([
|
|
2887
|
+
}] : n).flatMap((e, t) => t === 0 ? e.row : [P(","), ...e.row]);
|
|
2888
|
+
return X([F(r), L(o)]);
|
|
2889
2889
|
}
|
|
2890
2890
|
derivative(e, t) {
|
|
2891
2891
|
let n = ji(e, "bvar"), [r] = t;
|
|
2892
2892
|
if (!n || !r) return this.unsupported("<diff> without <bvar> and an operand");
|
|
2893
2893
|
let i = Ci(n).find((e) => e.localName === "ci"), a = Ci(n).find((e) => e.localName === "degree");
|
|
2894
|
-
return a && (a.textContent ?? "").trim() !== "1" ? this.unsupported("A derivative of order other than 1") : i ? X([
|
|
2894
|
+
return a && (a.textContent ?? "").trim() !== "1" ? this.unsupported("A derivative of order other than 1") : i ? X([Ce(this.expression(r).row, this.expression(i).row)]) : this.unsupported("<bvar> without a <ci>");
|
|
2895
2895
|
}
|
|
2896
2896
|
piecewise(e) {
|
|
2897
2897
|
let t = [], n = null, r = (e) => e ? this.expression(e).row : [];
|
|
@@ -2899,7 +2899,7 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2899
2899
|
let [e, a] = Ci(i);
|
|
2900
2900
|
i.localName === "piece" ? ((!e || !a) && this.problems.add("A <piece> without a value and a condition"), t.push([r(e), r(a)])) : i.localName === "otherwise" ? (e || this.problems.add("An <otherwise> without a value"), n = r(e)) : this.problems.add(`<${i.localName}> in <piecewise> isn't supported; it was left out`);
|
|
2901
2901
|
}
|
|
2902
|
-
return t.length === 0 ? this.unsupported("A <piecewise> without a <piece>") : X([
|
|
2902
|
+
return t.length === 0 ? this.unsupported("A <piecewise> without a <piece>") : X([Te(t, n)]);
|
|
2903
2903
|
}
|
|
2904
2904
|
inner(e) {
|
|
2905
2905
|
let [t] = Ci(e);
|
|
@@ -2914,12 +2914,12 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2914
2914
|
level: Y.Primary
|
|
2915
2915
|
});
|
|
2916
2916
|
function Mi(e, t) {
|
|
2917
|
-
return e.level < t ? [
|
|
2917
|
+
return e.level < t ? [L(e.row)] : e.row;
|
|
2918
2918
|
}
|
|
2919
2919
|
function Ni(e, t, n) {
|
|
2920
2920
|
let r = [];
|
|
2921
2921
|
return e.forEach((e, i) => {
|
|
2922
|
-
i > 0 && r.push(
|
|
2922
|
+
i > 0 && r.push(P(t));
|
|
2923
2923
|
let a = e.level === Y.Unary && (t === "+" && i > 0 || t === "·" && i === 0) ? Y.Unary : n;
|
|
2924
2924
|
r.push(...Mi(e, a));
|
|
2925
2925
|
}), r;
|
|
@@ -2973,7 +2973,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
2973
2973
|
"import"
|
|
2974
2974
|
],
|
|
2975
2975
|
setup(n, { expose: o, emit: s }) {
|
|
2976
|
-
let c = n, l = s, u = _(null), d = _(!1), h = _(null), ne = _(!1), re = _(null), b = _(null), x = _([]), C = _(null), ie = _(0);
|
|
2976
|
+
let c = n, l = s, u = _(null), d = _(!1), h = _(null), ne = _(!1), re = _(null), b = _(null), x = _([]), C = _(null), ie = _(null), ae = _(0);
|
|
2977
2977
|
function w() {
|
|
2978
2978
|
return {
|
|
2979
2979
|
root: c.modelValue,
|
|
@@ -2984,21 +2984,21 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
2984
2984
|
let T = t(() => G(w())), E = t(() => {
|
|
2985
2985
|
let e = new Set(c.marks.filter(Ri).flatMap((e) => e.atomIds)), t = c.active ? Ln(c.modelValue, c.cursor) : null;
|
|
2986
2986
|
return t && e.add(t), e;
|
|
2987
|
-
}), D = t(() =>
|
|
2987
|
+
}), D = t(() => se.renderToString(Ht(c.modelValue, {
|
|
2988
2988
|
activeRow: c.active ? c.cursor.path : null,
|
|
2989
2989
|
shownUnits: E.value,
|
|
2990
2990
|
greekNames: c.greekNames,
|
|
2991
2991
|
typesetNames: c.typesetNames,
|
|
2992
2992
|
cursors: c.active ? [c.cursor, c.anchor] : []
|
|
2993
|
-
}), Kt)), O = t(() => c.active && d.value && !T.value && h.value !== null && !ne.value),
|
|
2994
|
-
function
|
|
2993
|
+
}), Kt)), O = t(() => c.active && d.value && !T.value && h.value !== null && !ne.value), ce = t(() => c.active && d.value && b.value !== null), le = t(() => c.active && re.value !== null);
|
|
2994
|
+
function ue() {
|
|
2995
2995
|
let e = u.value, t = e ? tn(e, c.modelValue, c.cursor) : null;
|
|
2996
2996
|
h.value = t ? {
|
|
2997
2997
|
left: `${t.left}px`,
|
|
2998
2998
|
top: `${t.top}px`,
|
|
2999
2999
|
height: `${t.height}px`
|
|
3000
3000
|
} : null, ne.value = t?.placeholder ?? !1;
|
|
3001
|
-
let n = c.cursor.path, r = e && n.length > 0 &&
|
|
3001
|
+
let n = c.cursor.path, r = e && n.length > 0 && M(c.modelValue, n)?.length ? cn(e, n) : null;
|
|
3002
3002
|
b.value = r ? {
|
|
3003
3003
|
left: `${r.left}px`,
|
|
3004
3004
|
top: `${r.top}px`,
|
|
@@ -3020,7 +3020,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3020
3020
|
}] : [];
|
|
3021
3021
|
}) : [], C.value = null;
|
|
3022
3022
|
}
|
|
3023
|
-
function
|
|
3023
|
+
function de(e) {
|
|
3024
3024
|
return {
|
|
3025
3025
|
left: `${e.left}px`,
|
|
3026
3026
|
top: `${e.top}px`,
|
|
@@ -3028,51 +3028,54 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3028
3028
|
height: `${e.height + 4}px`
|
|
3029
3029
|
};
|
|
3030
3030
|
}
|
|
3031
|
-
function
|
|
3031
|
+
function fe(e) {
|
|
3032
3032
|
let t = u.value;
|
|
3033
3033
|
if (!t || A || x.value.length === 0) {
|
|
3034
3034
|
C.value = null;
|
|
3035
3035
|
return;
|
|
3036
3036
|
}
|
|
3037
|
-
let n = t.getBoundingClientRect(), r = e.clientX - n.left + t.scrollLeft, i = e.clientY - n.top + t.scrollTop, a = x.value.filter(({ box: e }) => r >= e.left && r <= e.left + e.width && i >= e.top && i <= e.top + e.height + 4), o = a.find((e) => e.kind !== "hint") ?? a[0]
|
|
3037
|
+
let n = t.getBoundingClientRect(), r = e.clientX - n.left + t.scrollLeft, i = e.clientY - n.top + t.scrollTop, a = x.value.filter(({ box: e }) => r >= e.left && r <= e.left + e.width && i >= e.top && i <= e.top + e.height + 4), o = a.find((e) => e.kind !== "hint") ?? a[0], s = ie.value?.getBoundingClientRect() ?? {
|
|
3038
|
+
left: 0,
|
|
3039
|
+
top: 0
|
|
3040
|
+
};
|
|
3038
3041
|
C.value = o ? {
|
|
3039
3042
|
message: o.message,
|
|
3040
|
-
left: n.left + o.box.left - t.scrollLeft,
|
|
3041
|
-
top: n.top + o.box.top + o.box.height + 6 - t.scrollTop
|
|
3043
|
+
left: n.left + o.box.left - t.scrollLeft - s.left,
|
|
3044
|
+
top: n.top + o.box.top + o.box.height + 6 - t.scrollTop - s.top
|
|
3042
3045
|
} : null;
|
|
3043
3046
|
}
|
|
3044
|
-
|
|
3047
|
+
oe([
|
|
3045
3048
|
D,
|
|
3046
3049
|
() => c.cursor,
|
|
3047
3050
|
() => c.anchor,
|
|
3048
3051
|
() => c.active,
|
|
3049
3052
|
() => c.marks
|
|
3050
3053
|
], async () => {
|
|
3051
|
-
await f(),
|
|
3054
|
+
await f(), ue(), ae.value++;
|
|
3052
3055
|
}, {
|
|
3053
3056
|
immediate: !0,
|
|
3054
3057
|
deep: !0
|
|
3055
3058
|
}), te(() => {
|
|
3056
|
-
window.addEventListener("resize",
|
|
3059
|
+
window.addEventListener("resize", ue), document.addEventListener("copy", F), document.addEventListener("cut", xe), document.addEventListener("paste", I), document.fonts?.ready.then(ue);
|
|
3057
3060
|
}), ee(() => {
|
|
3058
|
-
window.removeEventListener("resize",
|
|
3061
|
+
window.removeEventListener("resize", ue), document.removeEventListener("copy", F), document.removeEventListener("cut", xe), document.removeEventListener("paste", I), be();
|
|
3059
3062
|
});
|
|
3060
|
-
let
|
|
3063
|
+
let pe = (e, t) => {
|
|
3061
3064
|
let n = u.value, r = n ? tn(n, c.modelValue, c.cursor) : null;
|
|
3062
3065
|
if (!n || !r) return c.cursor.offset;
|
|
3063
3066
|
let i = n.getBoundingClientRect().left + r.left - n.scrollLeft;
|
|
3064
3067
|
return nn(n, c.modelValue, t, i);
|
|
3065
3068
|
};
|
|
3066
|
-
function
|
|
3069
|
+
function me(e) {
|
|
3067
3070
|
l("navigate", {
|
|
3068
3071
|
cursor: e.cursor,
|
|
3069
3072
|
anchor: e.anchor ?? null
|
|
3070
3073
|
});
|
|
3071
3074
|
}
|
|
3072
|
-
function
|
|
3075
|
+
function he(e) {
|
|
3073
3076
|
let t = w();
|
|
3074
3077
|
if ((e.ctrlKey || e.metaKey) && !e.altKey && e.key.toLowerCase() === "a") {
|
|
3075
|
-
e.preventDefault(),
|
|
3078
|
+
e.preventDefault(), me(hr(t));
|
|
3076
3079
|
return;
|
|
3077
3080
|
}
|
|
3078
3081
|
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
@@ -3086,7 +3089,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3086
3089
|
}
|
|
3087
3090
|
case "ArrowUp":
|
|
3088
3091
|
case "ArrowDown":
|
|
3089
|
-
if (n = yr(t, e.key === "ArrowUp" ? "up" : "down",
|
|
3092
|
+
if (n = yr(t, e.key === "ArrowUp" ? "up" : "down", pe), !n) return;
|
|
3090
3093
|
break;
|
|
3091
3094
|
case "Home":
|
|
3092
3095
|
case "End": {
|
|
@@ -3103,32 +3106,32 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3103
3106
|
n = _r(t);
|
|
3104
3107
|
break;
|
|
3105
3108
|
default:
|
|
3106
|
-
|
|
3109
|
+
_e(e, t);
|
|
3107
3110
|
return;
|
|
3108
3111
|
}
|
|
3109
|
-
e.preventDefault(), n &&
|
|
3112
|
+
e.preventDefault(), n && me(n);
|
|
3110
3113
|
}
|
|
3111
|
-
let
|
|
3114
|
+
let ge = /* @__PURE__ */ new Set([
|
|
3112
3115
|
"Backspace",
|
|
3113
3116
|
"Delete",
|
|
3114
3117
|
"Tab",
|
|
3115
3118
|
"Enter"
|
|
3116
3119
|
]);
|
|
3117
|
-
function
|
|
3120
|
+
function _e(e, t) {
|
|
3118
3121
|
if (c.readonly) return;
|
|
3119
3122
|
let n = vi(e);
|
|
3120
3123
|
if (!n) return;
|
|
3121
3124
|
let r = n(t);
|
|
3122
3125
|
if (r === t) {
|
|
3123
|
-
|
|
3126
|
+
ge.has(e.key) || e.preventDefault();
|
|
3124
3127
|
return;
|
|
3125
3128
|
}
|
|
3126
|
-
e.preventDefault(), l("edit", r,
|
|
3129
|
+
e.preventDefault(), l("edit", r, k(e, t));
|
|
3127
3130
|
}
|
|
3128
|
-
function
|
|
3131
|
+
function k(e, t) {
|
|
3129
3132
|
let n = G(t) !== null, r = _i(e);
|
|
3130
3133
|
if (r !== null) {
|
|
3131
|
-
let e =
|
|
3134
|
+
let e = M(t.root, t.cursor.path), i = t.cursor.offset - +!!Fn(e?.[t.cursor.offset - 1]);
|
|
3132
3135
|
return {
|
|
3133
3136
|
kind: "type",
|
|
3134
3137
|
text: r,
|
|
@@ -3145,42 +3148,42 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3145
3148
|
} : fi;
|
|
3146
3149
|
}
|
|
3147
3150
|
let A = null;
|
|
3148
|
-
function
|
|
3151
|
+
function ve(e) {
|
|
3149
3152
|
let t = u.value;
|
|
3150
3153
|
return t ? an(t, c.modelValue, e.clientX, e.clientY) : null;
|
|
3151
3154
|
}
|
|
3152
3155
|
function j(e) {
|
|
3153
3156
|
if (e.preventDefault(), C.value = null, e.button !== 0) return;
|
|
3154
|
-
let t =
|
|
3157
|
+
let t = ve(e);
|
|
3155
3158
|
if (!t) return;
|
|
3156
3159
|
u.value?.focus();
|
|
3157
3160
|
let n = w();
|
|
3158
|
-
A = e.shiftKey ? n.anchor ?? n.cursor : t,
|
|
3161
|
+
A = e.shiftKey ? n.anchor ?? n.cursor : t, me(gr(n, A, t)), window.addEventListener("mousemove", ye), window.addEventListener("mouseup", be);
|
|
3159
3162
|
}
|
|
3160
|
-
function
|
|
3163
|
+
function ye(e) {
|
|
3161
3164
|
if (!A) return;
|
|
3162
|
-
let t =
|
|
3163
|
-
t &&
|
|
3165
|
+
let t = ve(e);
|
|
3166
|
+
t && me(gr(w(), A, t));
|
|
3164
3167
|
}
|
|
3165
|
-
function
|
|
3166
|
-
A = null, window.removeEventListener("mousemove",
|
|
3168
|
+
function be() {
|
|
3169
|
+
A = null, window.removeEventListener("mousemove", ye), window.removeEventListener("mouseup", be);
|
|
3167
3170
|
}
|
|
3168
|
-
let
|
|
3169
|
-
function
|
|
3171
|
+
let N = () => !!u.value && document.activeElement === u.value;
|
|
3172
|
+
function P(e) {
|
|
3170
3173
|
let t = ur(w());
|
|
3171
3174
|
return t.length === 0 || !e.clipboardData ? !1 : (e.preventDefault(), e.clipboardData.setData("text/plain", W(t, {
|
|
3172
3175
|
greekNames: c.greekNames,
|
|
3173
3176
|
typesetNames: c.typesetNames
|
|
3174
3177
|
})), e.clipboardData.setData(ln, un(t)), !0);
|
|
3175
3178
|
}
|
|
3176
|
-
function
|
|
3177
|
-
|
|
3179
|
+
function F(e) {
|
|
3180
|
+
N() && P(e);
|
|
3178
3181
|
}
|
|
3179
|
-
function
|
|
3180
|
-
|
|
3182
|
+
function xe(e) {
|
|
3183
|
+
N() && !c.readonly && P(e) && l("edit", ri(w()), fi);
|
|
3181
3184
|
}
|
|
3182
|
-
function
|
|
3183
|
-
if (!
|
|
3185
|
+
function I(e) {
|
|
3186
|
+
if (!N() || c.readonly || !e.clipboardData) return;
|
|
3184
3187
|
e.preventDefault();
|
|
3185
3188
|
let t = e.clipboardData, n = dn(t.getData(ln)), r = t.getData("text/plain");
|
|
3186
3189
|
if (!n && xi(r)) {
|
|
@@ -3205,20 +3208,21 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3205
3208
|
role: "textbox",
|
|
3206
3209
|
"aria-label": "Equation",
|
|
3207
3210
|
"aria-invalid": n.marks.some(S(Ri)) || void 0,
|
|
3208
|
-
onKeydown:
|
|
3211
|
+
onKeydown: he,
|
|
3209
3212
|
onMousedown: j,
|
|
3210
|
-
|
|
3213
|
+
onMouseenter: ue,
|
|
3214
|
+
onMousemove: fe,
|
|
3211
3215
|
onMouseleave: o[0] ||= (e) => C.value = null,
|
|
3212
3216
|
onFocus: o[1] ||= (e) => d.value = !0,
|
|
3213
3217
|
onBlur: o[2] ||= (e) => d.value = !1
|
|
3214
3218
|
}, [
|
|
3215
|
-
|
|
3219
|
+
ce.value ? (g(), i("div", {
|
|
3216
3220
|
key: 0,
|
|
3217
3221
|
class: "row-tint",
|
|
3218
3222
|
"data-role": "active-row",
|
|
3219
3223
|
style: m(b.value)
|
|
3220
3224
|
}, null, 4)) : r("", !0),
|
|
3221
|
-
|
|
3225
|
+
le.value ? (g(), i("div", {
|
|
3222
3226
|
key: 1,
|
|
3223
3227
|
class: "selection",
|
|
3224
3228
|
style: m(re.value)
|
|
@@ -3228,10 +3232,10 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3228
3232
|
class: p(["mark", `mark-${t.kind}`]),
|
|
3229
3233
|
"data-role": "mark",
|
|
3230
3234
|
"data-kind": t.kind,
|
|
3231
|
-
style: m(
|
|
3235
|
+
style: m(de(t.box))
|
|
3232
3236
|
}, null, 14, Bi))], 64))), 128)),
|
|
3233
3237
|
O.value ? (g(), i("div", {
|
|
3234
|
-
key:
|
|
3238
|
+
key: ae.value,
|
|
3235
3239
|
class: "caret",
|
|
3236
3240
|
style: m(h.value)
|
|
3237
3241
|
}, null, 4)) : r("", !0),
|
|
@@ -3248,14 +3252,20 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3248
3252
|
left: `${C.value.left}px`,
|
|
3249
3253
|
top: `${C.value.top}px`
|
|
3250
3254
|
})
|
|
3251
|
-
}, y(C.value.message), 5)) : r("", !0)
|
|
3255
|
+
}, y(C.value.message), 5)) : r("", !0),
|
|
3256
|
+
a("span", {
|
|
3257
|
+
ref_key: "fixedOriginEl",
|
|
3258
|
+
ref: ie,
|
|
3259
|
+
class: "fixed-origin",
|
|
3260
|
+
"aria-hidden": "true"
|
|
3261
|
+
}, null, 512)
|
|
3252
3262
|
], 42, zi));
|
|
3253
3263
|
}
|
|
3254
3264
|
}), Ui = (e, t) => {
|
|
3255
3265
|
let n = e.__vccOpts || e;
|
|
3256
3266
|
for (let [e, r] of t) n[e] = r;
|
|
3257
3267
|
return n;
|
|
3258
|
-
}, Wi = /*#__PURE__*/ Ui(Hi, [["__scopeId", "data-v-
|
|
3268
|
+
}, Wi = /*#__PURE__*/ Ui(Hi, [["__scopeId", "data-v-c390dc95"]]);
|
|
3259
3269
|
//#endregion
|
|
3260
3270
|
//#region src/components/contentStable.ts
|
|
3261
3271
|
function Gi(e) {
|
|
@@ -3380,7 +3390,7 @@ function Xi(e, t) {
|
|
|
3380
3390
|
kind: "operator",
|
|
3381
3391
|
op: o,
|
|
3382
3392
|
atomIds: s
|
|
3383
|
-
}) :
|
|
3393
|
+
}) : z(i.value) ? n.push({
|
|
3384
3394
|
kind: "constant",
|
|
3385
3395
|
name: i.value,
|
|
3386
3396
|
atomIds: s
|
|
@@ -3703,7 +3713,7 @@ function Z(e) {
|
|
|
3703
3713
|
switch (e.type) {
|
|
3704
3714
|
case "Number": return e.value;
|
|
3705
3715
|
case "Identifier": return e.name;
|
|
3706
|
-
case "Constant": return
|
|
3716
|
+
case "Constant": return z(e.name).mathJson;
|
|
3707
3717
|
case "Add": return ["Add", ...e.children.map(Z)];
|
|
3708
3718
|
case "Multiply": return ["Multiply", ...e.children.map(Z)];
|
|
3709
3719
|
case "Subtract": return [
|
|
@@ -3788,7 +3798,7 @@ function $(e, t = {}) {
|
|
|
3788
3798
|
switch (e.type) {
|
|
3789
3799
|
case "Number": return aa(e, t);
|
|
3790
3800
|
case "Identifier": return `<ci>${e.name}</ci>`;
|
|
3791
|
-
case "Constant": return `<${
|
|
3801
|
+
case "Constant": return `<${z(e.name).mathml}/>`;
|
|
3792
3802
|
case "Add": return Q("plus", e.children.map((e) => $(e, t)));
|
|
3793
3803
|
case "Multiply": return Q("times", e.children.map((e) => $(e, t)));
|
|
3794
3804
|
case "Subtract": return Q("minus", [$(e.minuend, t), $(e.subtrahend, t)]);
|
|
@@ -3933,7 +3943,7 @@ function fa(e, t, n, r = 0) {
|
|
|
3933
3943
|
};
|
|
3934
3944
|
}
|
|
3935
3945
|
function pa(e) {
|
|
3936
|
-
return e.some((e) => e.kind === "units" && e.units.length === 0 ||
|
|
3946
|
+
return e.some((e) => e.kind === "units" && e.units.length === 0 || k(e).some(([, e]) => pa(e)));
|
|
3937
3947
|
}
|
|
3938
3948
|
function ma(e) {
|
|
3939
3949
|
switch (e.type) {
|
|
@@ -3963,7 +3973,7 @@ function ma(e) {
|
|
|
3963
3973
|
}
|
|
3964
3974
|
}
|
|
3965
3975
|
function ha(e, t) {
|
|
3966
|
-
let n = [], r = t.some((e) => e.numbers?.length || e.units?.length) ?
|
|
3976
|
+
let n = [], r = t.some((e) => e.numbers?.length || e.units?.length) ? lt(e) : [], i = t.some((e) => e.variables?.length) ? ct(e) : null;
|
|
3967
3977
|
for (let e of t) {
|
|
3968
3978
|
for (let t of e.variables ?? []) for (let r of i?.get(t) ?? []) n.push({
|
|
3969
3979
|
message: e.message,
|
|
@@ -3980,7 +3990,7 @@ function ha(e, t) {
|
|
|
3980
3990
|
}
|
|
3981
3991
|
function ga(e, t) {
|
|
3982
3992
|
let n = [];
|
|
3983
|
-
if (t) for (let [r, i] of
|
|
3993
|
+
if (t) for (let [r, i] of ct(e)) {
|
|
3984
3994
|
if (!Object.hasOwn(t, r)) continue;
|
|
3985
3995
|
let e = t[r];
|
|
3986
3996
|
for (let t of i) n.push({
|
|
@@ -3989,7 +3999,7 @@ function ga(e, t) {
|
|
|
3989
3999
|
kind: "hint"
|
|
3990
4000
|
});
|
|
3991
4001
|
}
|
|
3992
|
-
for (let r of
|
|
4002
|
+
for (let r of lt(e)) {
|
|
3993
4003
|
if (!r.units && !t) continue;
|
|
3994
4004
|
let e = r.inherited ? ", as in the first piece" : "";
|
|
3995
4005
|
n.push({
|
|
@@ -4223,51 +4233,47 @@ var va = [
|
|
|
4223
4233
|
}
|
|
4224
4234
|
]
|
|
4225
4235
|
}
|
|
4226
|
-
], xa = { class: "
|
|
4227
|
-
class: "toolbar",
|
|
4228
|
-
role: "toolbar",
|
|
4229
|
-
"aria-label": "Equation tools"
|
|
4230
|
-
}, Ca = { class: "toolbar-group" }, wa = [
|
|
4236
|
+
], xa = { class: "toolbar-group" }, Sa = [
|
|
4231
4237
|
"title",
|
|
4232
4238
|
"data-role",
|
|
4233
4239
|
"aria-haspopup",
|
|
4234
4240
|
"disabled",
|
|
4235
4241
|
"onClick"
|
|
4236
|
-
],
|
|
4242
|
+
], Ca = ["innerHTML"], wa = {
|
|
4237
4243
|
key: 0,
|
|
4238
4244
|
class: "pi pi-chevron-down tool-chevron",
|
|
4239
4245
|
"aria-hidden": "true"
|
|
4240
|
-
},
|
|
4246
|
+
}, Ta = { class: "toolbar-group toolbar-lines" }, Ea = {
|
|
4241
4247
|
key: 0,
|
|
4242
4248
|
class: "toolbar-group"
|
|
4243
|
-
},
|
|
4249
|
+
}, Da = {
|
|
4244
4250
|
key: 0,
|
|
4245
4251
|
class: "gallery"
|
|
4246
|
-
},
|
|
4252
|
+
}, Oa = {
|
|
4247
4253
|
key: 0,
|
|
4248
4254
|
class: "gallery-label"
|
|
4249
|
-
},
|
|
4255
|
+
}, ka = { class: "gallery-items" }, Aa = ["title", "onClick"], ja = ["innerHTML"], Ma = [
|
|
4250
4256
|
"data-line",
|
|
4251
4257
|
"data-line-id",
|
|
4252
4258
|
"onFocusin"
|
|
4253
|
-
],
|
|
4259
|
+
], Na = { class: "equation-label" }, Pa = ["data-kind", "title"], Fa = {
|
|
4254
4260
|
key: 0,
|
|
4255
4261
|
class: "command-chip",
|
|
4256
4262
|
"data-role": "command"
|
|
4257
|
-
},
|
|
4263
|
+
}, Ia = { class: "status-text" }, La = {
|
|
4258
4264
|
key: 0,
|
|
4259
4265
|
class: "status-more"
|
|
4260
|
-
},
|
|
4266
|
+
}, Ra = {
|
|
4261
4267
|
key: 0,
|
|
4262
4268
|
class: "focus-meta"
|
|
4263
|
-
},
|
|
4269
|
+
}, za = { "data-role": "cursor" }, Ba = { "data-role": "selection" }, Va = {
|
|
4264
4270
|
class: "key-help",
|
|
4265
4271
|
"data-role": "key-help"
|
|
4266
|
-
},
|
|
4272
|
+
}, Ha = { class: "key-hint" }, Ua = {
|
|
4267
4273
|
key: 0,
|
|
4268
4274
|
class: "side-column",
|
|
4269
4275
|
"data-role": "side"
|
|
4270
|
-
},
|
|
4276
|
+
}, Wa = { "data-role": "mathml" }, Ga = { class: "output-actions" }, Ka = { "data-role": "mathjson" }, qa = { "data-role": "latex" }, Ja = { "data-role": "ast" }, Ya = "A CellML line must be an equation (… = …)", Xa = /*#__PURE__*/ Ui(/* @__PURE__ */ l({
|
|
4271
4277
|
__name: "EquationWorkbench",
|
|
4272
4278
|
props: {
|
|
4273
4279
|
cellml: {
|
|
@@ -4308,146 +4314,161 @@ var va = [
|
|
|
4308
4314
|
},
|
|
4309
4315
|
emits: ["equations-change", "line-commit"],
|
|
4310
4316
|
setup(l, { expose: u, emit: d }) {
|
|
4311
|
-
let m = l,
|
|
4317
|
+
let m = l, h = d, x = t(() => ({
|
|
4312
4318
|
cellml: m.cellml,
|
|
4313
4319
|
greekNames: m.greekNames,
|
|
4314
4320
|
typesetNames: m.typesetNames
|
|
4315
|
-
})),
|
|
4321
|
+
})), C = re([br()]), ie = (e, t) => C.value.map((n, r) => r === e ? t : n), ae = 0, w = () => `line-${++ae}`, E = _([w()]), _e = _(/* @__PURE__ */ new Map()), k = _(/* @__PURE__ */ new Map()), A = _(0), ve = _([]), j = _(null);
|
|
4316
4322
|
function M() {
|
|
4317
|
-
return
|
|
4323
|
+
return C.value[A.value];
|
|
4318
4324
|
}
|
|
4319
|
-
function
|
|
4320
|
-
|
|
4325
|
+
function ye(e, t) {
|
|
4326
|
+
C.value = ie(e, be(t));
|
|
4321
4327
|
}
|
|
4322
|
-
let
|
|
4328
|
+
let be = (e, t = !1) => ht(Gn(e), {
|
|
4323
4329
|
greekNames: m.greekNames,
|
|
4324
4330
|
cursorAway: t
|
|
4325
4331
|
});
|
|
4326
|
-
|
|
4327
|
-
let n =
|
|
4328
|
-
n && (
|
|
4329
|
-
}),
|
|
4330
|
-
|
|
4332
|
+
oe(A, (e, t) => {
|
|
4333
|
+
let n = C.value[t];
|
|
4334
|
+
n && (C.value = ie(t, be(n, !0)));
|
|
4335
|
+
}), oe(() => m.greekNames, () => {
|
|
4336
|
+
C.value = C.value.map((e, t) => be(e, t !== A.value));
|
|
4331
4337
|
});
|
|
4332
|
-
function
|
|
4333
|
-
f(() =>
|
|
4338
|
+
function N() {
|
|
4339
|
+
f(() => ve.value[A.value]?.focus());
|
|
4334
4340
|
}
|
|
4335
|
-
let
|
|
4336
|
-
function
|
|
4341
|
+
let P = new hi(), F = _(0);
|
|
4342
|
+
function xe() {
|
|
4337
4343
|
return JSON.parse(JSON.stringify({
|
|
4338
|
-
equations:
|
|
4339
|
-
lineIds:
|
|
4344
|
+
equations: C.value,
|
|
4345
|
+
lineIds: E.value,
|
|
4340
4346
|
active: A.value
|
|
4341
4347
|
}));
|
|
4342
4348
|
}
|
|
4343
|
-
function
|
|
4344
|
-
m.history && (
|
|
4349
|
+
function I(e = A.value, t = fi) {
|
|
4350
|
+
m.history && (P.checkpoint(xe, mi(e, t)), F.value++);
|
|
4345
4351
|
}
|
|
4346
|
-
function
|
|
4347
|
-
e && (
|
|
4352
|
+
function Se(e) {
|
|
4353
|
+
e && (C.value = e.equations, E.value = e.lineIds, A.value = Math.min(e.active, e.equations.length - 1), F.value++, N());
|
|
4348
4354
|
}
|
|
4349
|
-
let
|
|
4350
|
-
function
|
|
4351
|
-
if (b(t.root) === b(
|
|
4352
|
-
|
|
4355
|
+
let L = () => Se(P.undo(xe())), Ce = () => Se(P.redo(xe())), we = t(() => F.value >= 0 && P.canUndo), Te = t(() => F.value >= 0 && P.canRedo);
|
|
4356
|
+
function R(e, t, n) {
|
|
4357
|
+
if (b(t.root) === b(C.value[e].root)) {
|
|
4358
|
+
De(e, {
|
|
4353
4359
|
cursor: t.cursor,
|
|
4354
4360
|
anchor: t.anchor ?? null
|
|
4355
4361
|
});
|
|
4356
4362
|
return;
|
|
4357
4363
|
}
|
|
4358
|
-
|
|
4364
|
+
I(e, n), ye(e, t), Ee(e);
|
|
4359
4365
|
}
|
|
4360
|
-
function
|
|
4361
|
-
|
|
4366
|
+
function Ee(e) {
|
|
4367
|
+
k.value.delete(E.value[e]), z.value = null;
|
|
4362
4368
|
}
|
|
4363
|
-
function
|
|
4364
|
-
|
|
4365
|
-
...
|
|
4369
|
+
function De(e, { cursor: t, anchor: n }) {
|
|
4370
|
+
P.breakGroup(), ye(e, {
|
|
4371
|
+
...C.value[e],
|
|
4366
4372
|
cursor: t,
|
|
4367
4373
|
anchor: n
|
|
4368
4374
|
});
|
|
4369
4375
|
}
|
|
4370
|
-
function
|
|
4371
|
-
let n = e.map((e) =>
|
|
4376
|
+
function Oe(e, t = []) {
|
|
4377
|
+
let n = e.map((e) => be({
|
|
4372
4378
|
root: e,
|
|
4373
4379
|
cursor: Xn(e),
|
|
4374
4380
|
anchor: null
|
|
4375
4381
|
}, !0));
|
|
4376
|
-
|
|
4382
|
+
C.value = n.length ? n : [br()], E.value = C.value.map(() => w()), A.value = 0, k.value = new Map(E.value.flatMap((e, n) => t[n]?.length ? [[e, t[n]]] : [])), _e.value = new Map(_t.value.map((e) => [e.id, e.mathml]));
|
|
4377
4383
|
}
|
|
4378
|
-
let
|
|
4379
|
-
function
|
|
4384
|
+
let z = _(null);
|
|
4385
|
+
function ke(e, t) {
|
|
4380
4386
|
if (m.readonly) return;
|
|
4381
4387
|
let n = t.equations.length;
|
|
4382
|
-
if (n === 1)
|
|
4388
|
+
if (n === 1) R(e, Rr(t.equations[0])(C.value[e]), fi), t.problems.length && k.value.set(E.value[e], t.problems);
|
|
4383
4389
|
else if (n > 1) {
|
|
4384
|
-
|
|
4385
|
-
for (let e of
|
|
4386
|
-
|
|
4390
|
+
I(e), Oe(t.equations, t.lineProblems);
|
|
4391
|
+
for (let e of _t.value) h("line-commit", e, { reason: "paste" });
|
|
4392
|
+
N();
|
|
4387
4393
|
}
|
|
4388
|
-
|
|
4394
|
+
z.value = n > 1 ? `Imported ${n} equations from Content MathML, replacing the lines there were.` : n === 0 ? t.problems[0] ?? "Nothing was imported." : null;
|
|
4389
4395
|
}
|
|
4390
|
-
function
|
|
4396
|
+
function Ae(e) {
|
|
4391
4397
|
let t = Si(e);
|
|
4392
|
-
return t ? (
|
|
4398
|
+
return t ? (yt = "load", Oe(t.equations, t.lineProblems), j.value = null, z.value = null, P.clear(), F.value++, t) : {
|
|
4393
4399
|
equations: [],
|
|
4394
4400
|
problems: ["The MathML isn't well-formed XML, so nothing was loaded"],
|
|
4395
4401
|
lineProblems: []
|
|
4396
4402
|
};
|
|
4397
4403
|
}
|
|
4398
4404
|
u({
|
|
4399
|
-
setMathML:
|
|
4400
|
-
focus:
|
|
4401
|
-
}), te(() => {
|
|
4402
|
-
m.autofocus && P();
|
|
4405
|
+
setMathML: Ae,
|
|
4406
|
+
focus: N
|
|
4403
4407
|
});
|
|
4404
|
-
|
|
4408
|
+
let je = _(null), Me = _(null), Ne = _(!1), B = 0;
|
|
4409
|
+
function Pe() {
|
|
4410
|
+
if (B = 0, !je.value || !Me.value) return;
|
|
4411
|
+
let e = Me.value.getBoundingClientRect().top - je.value.getBoundingClientRect().top;
|
|
4412
|
+
Ne.value = e > .5;
|
|
4413
|
+
}
|
|
4414
|
+
function Fe() {
|
|
4415
|
+
B ||= requestAnimationFrame(Pe);
|
|
4416
|
+
}
|
|
4417
|
+
te(() => {
|
|
4418
|
+
m.autofocus && N(), document.addEventListener("scroll", Fe, {
|
|
4419
|
+
capture: !0,
|
|
4420
|
+
passive: !0
|
|
4421
|
+
}), window.addEventListener("resize", Fe, { passive: !0 }), Pe();
|
|
4422
|
+
}), ee(() => {
|
|
4423
|
+
document.removeEventListener("scroll", Fe, { capture: !0 }), window.removeEventListener("resize", Fe), B && cancelAnimationFrame(B);
|
|
4424
|
+
});
|
|
4425
|
+
function Ie(e) {
|
|
4405
4426
|
if (m.readonly) return;
|
|
4406
4427
|
let t = M(), n = e(t);
|
|
4407
|
-
n !== t && (
|
|
4428
|
+
n !== t && (I(), ye(A.value, n), Ee(A.value)), N();
|
|
4408
4429
|
}
|
|
4409
|
-
function
|
|
4430
|
+
function Le(e) {
|
|
4410
4431
|
if (m.readonly) return;
|
|
4411
|
-
|
|
4432
|
+
He(A.value, e), I();
|
|
4412
4433
|
let t = A.value + 1;
|
|
4413
|
-
|
|
4414
|
-
...
|
|
4434
|
+
C.value = [
|
|
4435
|
+
...C.value.slice(0, t),
|
|
4415
4436
|
br(),
|
|
4416
|
-
...
|
|
4417
|
-
],
|
|
4437
|
+
...C.value.slice(t)
|
|
4438
|
+
], E.value.splice(t, 0, w()), A.value = t, N();
|
|
4418
4439
|
}
|
|
4419
|
-
function
|
|
4420
|
-
e < 0 || e >=
|
|
4440
|
+
function Re(e) {
|
|
4441
|
+
e < 0 || e >= C.value.length || (e !== A.value && He(A.value, "navigate"), P.breakGroup(), A.value = e, N());
|
|
4421
4442
|
}
|
|
4422
|
-
function
|
|
4423
|
-
e !== A.value && (
|
|
4443
|
+
function ze(e) {
|
|
4444
|
+
e !== A.value && (He(A.value, "navigate"), A.value = e);
|
|
4424
4445
|
}
|
|
4425
|
-
let
|
|
4426
|
-
function
|
|
4446
|
+
let Be = _(null);
|
|
4447
|
+
function Ve(e) {
|
|
4427
4448
|
let t = e.relatedTarget;
|
|
4428
|
-
t && (
|
|
4449
|
+
t && (Be.value?.contains(t) || t.closest("[data-me-popover]")) || He(A.value, "blur");
|
|
4429
4450
|
}
|
|
4430
|
-
function
|
|
4431
|
-
let n =
|
|
4432
|
-
n && (
|
|
4451
|
+
function He(e, t) {
|
|
4452
|
+
let n = _t.value[e];
|
|
4453
|
+
n && (_e.value.get(n.id) ?? "") !== n.mathml && (_e.value.set(n.id, n.mathml), h("line-commit", n, { reason: t }));
|
|
4433
4454
|
}
|
|
4434
|
-
function
|
|
4435
|
-
if (m.readonly ||
|
|
4436
|
-
|
|
4455
|
+
function Ue() {
|
|
4456
|
+
if (m.readonly || C.value.length <= 1) return;
|
|
4457
|
+
I();
|
|
4437
4458
|
let e = A.value;
|
|
4438
|
-
|
|
4459
|
+
C.value = C.value.filter((t, n) => n !== e), E.value.splice(A.value, 1), A.value = Math.max(0, A.value - 1);
|
|
4439
4460
|
let t = M();
|
|
4440
|
-
|
|
4461
|
+
ye(A.value, {
|
|
4441
4462
|
...t,
|
|
4442
4463
|
cursor: Xn(t.root),
|
|
4443
4464
|
anchor: null
|
|
4444
|
-
}),
|
|
4465
|
+
}), N();
|
|
4445
4466
|
}
|
|
4446
|
-
function
|
|
4467
|
+
function We() {
|
|
4447
4468
|
let e = (j.value ?? "").trim();
|
|
4448
|
-
j.value = null, e &&
|
|
4469
|
+
j.value = null, e && Ie(di(e));
|
|
4449
4470
|
}
|
|
4450
|
-
function
|
|
4471
|
+
function Ge(e) {
|
|
4451
4472
|
if (/^[a-zA-Z0-9]$/.test(e.key)) j.value += e.key;
|
|
4452
4473
|
else if (e.key === "Backspace") j.value = j.value ? j.value.slice(0, -1) : null;
|
|
4453
4474
|
else if ([
|
|
@@ -4455,105 +4476,105 @@ var va = [
|
|
|
4455
4476
|
" ",
|
|
4456
4477
|
"Tab",
|
|
4457
4478
|
"("
|
|
4458
|
-
].includes(e.key))
|
|
4479
|
+
].includes(e.key)) We();
|
|
4459
4480
|
else if (e.key === "Escape") j.value = null;
|
|
4460
4481
|
else return;
|
|
4461
4482
|
e.preventDefault(), e.stopPropagation();
|
|
4462
4483
|
}
|
|
4463
|
-
function
|
|
4484
|
+
function Ke(e) {
|
|
4464
4485
|
if (!e.target?.closest?.("[data-role=\"side\"]")) {
|
|
4465
4486
|
if (j.value !== null) {
|
|
4466
|
-
|
|
4487
|
+
Ge(e);
|
|
4467
4488
|
return;
|
|
4468
4489
|
}
|
|
4469
4490
|
if ((e.ctrlKey || e.metaKey) && !e.altKey) {
|
|
4470
4491
|
let t = e.key.toLowerCase();
|
|
4471
4492
|
if ((t === "z" || t === "y") && m.history) {
|
|
4472
4493
|
if (e.preventDefault(), e.stopPropagation(), m.readonly) return;
|
|
4473
|
-
t === "y" || e.shiftKey ?
|
|
4494
|
+
t === "y" || e.shiftKey ? Ce() : L();
|
|
4474
4495
|
}
|
|
4475
4496
|
return;
|
|
4476
4497
|
}
|
|
4477
4498
|
e.key === "\\" && !e.altKey && !m.readonly && (e.preventDefault(), e.stopPropagation(), j.value = "");
|
|
4478
4499
|
}
|
|
4479
4500
|
}
|
|
4480
|
-
function
|
|
4501
|
+
function qe(e) {
|
|
4481
4502
|
if (!e.defaultPrevented) switch (e.key) {
|
|
4482
4503
|
case "Enter":
|
|
4483
|
-
e.preventDefault(),
|
|
4504
|
+
e.preventDefault(), Le("enter");
|
|
4484
4505
|
return;
|
|
4485
4506
|
case "ArrowUp":
|
|
4486
|
-
e.preventDefault(),
|
|
4507
|
+
e.preventDefault(), Re(A.value - 1);
|
|
4487
4508
|
return;
|
|
4488
4509
|
case "ArrowDown":
|
|
4489
|
-
e.preventDefault(),
|
|
4510
|
+
e.preventDefault(), Re(A.value + 1);
|
|
4490
4511
|
return;
|
|
4491
4512
|
case "Backspace":
|
|
4492
|
-
M().root.length === 0 && (e.preventDefault(),
|
|
4513
|
+
M().root.length === 0 && (e.preventDefault(), Ue());
|
|
4493
4514
|
return;
|
|
4494
4515
|
}
|
|
4495
4516
|
}
|
|
4496
|
-
let
|
|
4497
|
-
function
|
|
4517
|
+
let Je = _(null), Ye = _(null);
|
|
4518
|
+
function Xe(e, t) {
|
|
4498
4519
|
if (e.command) {
|
|
4499
|
-
|
|
4520
|
+
Ie(e.command);
|
|
4500
4521
|
return;
|
|
4501
4522
|
}
|
|
4502
|
-
|
|
4523
|
+
Ye.value?.id !== e.id && Je.value?.hide(), Ye.value = e, f(() => Je.value?.toggle(t));
|
|
4503
4524
|
}
|
|
4504
|
-
function
|
|
4505
|
-
|
|
4525
|
+
function Ze(e) {
|
|
4526
|
+
Je.value?.hide(), Ie(e);
|
|
4506
4527
|
}
|
|
4507
|
-
function
|
|
4508
|
-
return
|
|
4528
|
+
function Qe(e) {
|
|
4529
|
+
return se.renderToString(e, {
|
|
4509
4530
|
throwOnError: !1,
|
|
4510
4531
|
strict: "ignore"
|
|
4511
4532
|
});
|
|
4512
4533
|
}
|
|
4513
|
-
let
|
|
4514
|
-
function
|
|
4534
|
+
let $e = /* @__PURE__ */ new WeakMap();
|
|
4535
|
+
function et(e) {
|
|
4515
4536
|
if (e.length === 0) return null;
|
|
4516
|
-
let t =
|
|
4517
|
-
return t || (t = Ki(e),
|
|
4537
|
+
let t = $e.get(e);
|
|
4538
|
+
return t || (t = Ki(e), $e.set(e, t)), t;
|
|
4518
4539
|
}
|
|
4519
|
-
let
|
|
4520
|
-
function
|
|
4521
|
-
let n =
|
|
4540
|
+
let tt = t(() => C.value.map((e) => et(e.root))), nt = t(() => tt.value[A.value] ?? null);
|
|
4541
|
+
function rt(e, t) {
|
|
4542
|
+
let n = tt.value[t]?.ast;
|
|
4522
4543
|
return !m.cellml || !n || n.type === "Equal" ? null : {
|
|
4523
|
-
message:
|
|
4544
|
+
message: Ya,
|
|
4524
4545
|
atomIds: e.map((e) => e.id),
|
|
4525
4546
|
incomplete: !0
|
|
4526
4547
|
};
|
|
4527
4548
|
}
|
|
4528
|
-
let
|
|
4549
|
+
let it = Gi(() => m.issues), at = Gi(() => m.variableUnits ?? null), ot = t(() => {
|
|
4529
4550
|
let e = /* @__PURE__ */ new Map();
|
|
4530
|
-
for (let t of
|
|
4551
|
+
for (let t of it.value) e.set(t.lineId, [...e.get(t.lineId) ?? [], t]);
|
|
4531
4552
|
return e;
|
|
4532
|
-
}),
|
|
4533
|
-
let n = e.root, r =
|
|
4553
|
+
}), st = t(() => (ot.value, at.value, m.cellml, /* @__PURE__ */ new WeakMap())), ct = t(() => C.value.map((e, t) => {
|
|
4554
|
+
let n = e.root, r = st.value.get(n);
|
|
4534
4555
|
if (!r) {
|
|
4535
|
-
let e =
|
|
4536
|
-
...
|
|
4556
|
+
let e = rt(n, t), i = [
|
|
4557
|
+
...tt.value[t]?.diagnostics ?? [],
|
|
4537
4558
|
...e ? [e] : [],
|
|
4538
|
-
...ha(n,
|
|
4539
|
-
], a = ga(n,
|
|
4559
|
+
...ha(n, ot.value.get(E.value[t]) ?? [])
|
|
4560
|
+
], a = ga(n, at.value);
|
|
4540
4561
|
r = {
|
|
4541
4562
|
all: [...i, ...a],
|
|
4542
4563
|
complete: [...i.filter((e) => !e.incomplete), ...a],
|
|
4543
4564
|
hints: a
|
|
4544
|
-
},
|
|
4565
|
+
}, st.value.set(n, r);
|
|
4545
4566
|
}
|
|
4546
4567
|
return r;
|
|
4547
4568
|
}));
|
|
4548
|
-
function
|
|
4569
|
+
function lt(e) {
|
|
4549
4570
|
if (m.validate === "commit") {
|
|
4550
|
-
let t =
|
|
4551
|
-
return (
|
|
4571
|
+
let t = _t.value[e];
|
|
4572
|
+
return (_e.value.get(t.id) ?? "") === t.mathml ? "all" : "hints";
|
|
4552
4573
|
}
|
|
4553
4574
|
return e === A.value ? "complete" : "all";
|
|
4554
4575
|
}
|
|
4555
|
-
let
|
|
4556
|
-
let n = [...(
|
|
4576
|
+
let ut = t(() => ct.value.map((e, t) => e[lt(t)])), dt = t(() => ut.value.map((e, t) => {
|
|
4577
|
+
let n = [...(lt(t) === "hints" ? [] : k.value.get(E.value[t]) ?? []).map((e) => ({
|
|
4557
4578
|
line: t,
|
|
4558
4579
|
message: e,
|
|
4559
4580
|
kind: "error"
|
|
@@ -4563,48 +4584,48 @@ var va = [
|
|
|
4563
4584
|
kind: Li(e) === "units" ? "units" : "error"
|
|
4564
4585
|
}))];
|
|
4565
4586
|
return n.filter((e, t) => n.findIndex((t) => t.message === e.message) === t);
|
|
4566
|
-
})),
|
|
4567
|
-
let t =
|
|
4587
|
+
})), ft = (e) => {
|
|
4588
|
+
let t = dt.value[e];
|
|
4568
4589
|
return t.length ? t.some((e) => e.kind === "error") ? "has-error" : "has-units-issue" : null;
|
|
4569
4590
|
}, V = t(() => {
|
|
4570
4591
|
if (j.value !== null) return {
|
|
4571
4592
|
kind: "command",
|
|
4572
4593
|
text: j.value
|
|
4573
4594
|
};
|
|
4574
|
-
let e =
|
|
4595
|
+
let e = dt.value.flat(), t = dt.value[A.value][0] ?? e[0];
|
|
4575
4596
|
return t ? {
|
|
4576
4597
|
kind: t.kind,
|
|
4577
4598
|
text: `Line ${t.line + 1}: ${t.message}`,
|
|
4578
4599
|
more: e.length - 1,
|
|
4579
4600
|
line: t.line
|
|
4580
|
-
} :
|
|
4601
|
+
} : z.value ? {
|
|
4581
4602
|
kind: "info",
|
|
4582
|
-
text:
|
|
4603
|
+
text: z.value
|
|
4583
4604
|
} : null;
|
|
4584
|
-
}),
|
|
4585
|
-
function
|
|
4605
|
+
}), pt = t(() => dt.value.flat().map((e) => `Line ${e.line + 1}: ${e.message}`).join("\n"));
|
|
4606
|
+
function mt() {
|
|
4586
4607
|
let e = V.value?.line;
|
|
4587
|
-
e !== void 0 &&
|
|
4608
|
+
e !== void 0 && Re(e);
|
|
4588
4609
|
}
|
|
4589
|
-
let
|
|
4590
|
-
let n =
|
|
4610
|
+
let gt = t(() => (k.value.size, m.cellml, /* @__PURE__ */ new WeakMap())), _t = t(() => C.value.map((e, t) => {
|
|
4611
|
+
let n = E.value[t], r = gt.value.get(e.root);
|
|
4591
4612
|
if (!r || r.id !== n) {
|
|
4592
|
-
let i = (
|
|
4593
|
-
r = fa(n, e.root,
|
|
4613
|
+
let i = (k.value.get(n)?.length ?? 0) + +!!rt(e.root, t);
|
|
4614
|
+
r = fa(n, e.root, tt.value[t], i), gt.value.set(e.root, r);
|
|
4594
4615
|
}
|
|
4595
4616
|
return r;
|
|
4596
|
-
})),
|
|
4597
|
-
|
|
4598
|
-
let t =
|
|
4599
|
-
|
|
4617
|
+
})), vt = "", yt = "load";
|
|
4618
|
+
oe(_t, (e) => {
|
|
4619
|
+
let t = yt;
|
|
4620
|
+
yt = "edit";
|
|
4600
4621
|
let n = JSON.stringify(e);
|
|
4601
|
-
n !==
|
|
4622
|
+
n !== vt && (vt = n, h("equations-change", e, { source: t }));
|
|
4602
4623
|
}, { immediate: !0 });
|
|
4603
|
-
let
|
|
4624
|
+
let bt = t(() => nt.value?.ast ?? null), xt = t(() => bt.value ? la(M().root, "latex", x.value) : ""), St = t(() => bt.value ? ra(bt.value) : ""), Ct = t(() => bt.value ? ua(M().root, x.value) : ""), wt = t(() => Qn(M().cursor)), Tt = t(() => {
|
|
4604
4625
|
let e = G(M());
|
|
4605
4626
|
return e ? dr(e) : null;
|
|
4606
|
-
}),
|
|
4607
|
-
function
|
|
4627
|
+
}), Et = _(!1), Dt = _("mathml");
|
|
4628
|
+
function Ot(e) {
|
|
4608
4629
|
let t = document.createElement("textarea");
|
|
4609
4630
|
t.value = e, t.setAttribute("readonly", "true"), t.style.position = "fixed", t.style.opacity = "0", document.body.appendChild(t), t.select();
|
|
4610
4631
|
try {
|
|
@@ -4615,41 +4636,41 @@ var va = [
|
|
|
4615
4636
|
document.body.removeChild(t);
|
|
4616
4637
|
}
|
|
4617
4638
|
}
|
|
4618
|
-
async function
|
|
4639
|
+
async function kt(e) {
|
|
4619
4640
|
try {
|
|
4620
4641
|
if (navigator.clipboard?.writeText) {
|
|
4621
4642
|
await navigator.clipboard.writeText(e);
|
|
4622
4643
|
return;
|
|
4623
4644
|
}
|
|
4624
4645
|
} catch {}
|
|
4625
|
-
|
|
4646
|
+
Ot(e);
|
|
4626
4647
|
}
|
|
4627
|
-
async function
|
|
4628
|
-
if (
|
|
4629
|
-
|
|
4648
|
+
async function At() {
|
|
4649
|
+
if (St.value) {
|
|
4650
|
+
Et.value = !0;
|
|
4630
4651
|
try {
|
|
4631
|
-
await St
|
|
4652
|
+
await kt(St.value);
|
|
4632
4653
|
} finally {
|
|
4633
4654
|
window.setTimeout(() => {
|
|
4634
|
-
|
|
4655
|
+
Et.value = !1;
|
|
4635
4656
|
}, 1200);
|
|
4636
4657
|
}
|
|
4637
4658
|
}
|
|
4638
4659
|
}
|
|
4639
|
-
let
|
|
4640
|
-
async function
|
|
4660
|
+
let jt = _(null), Mt = _(null), Nt, Pt = t(() => G(M()) !== null), Ft = t(() => M().root.length > 0), H = t(() => Mt.value ? `Copied ${Mt.value}` : Pt.value ? "Copy selection as" : "Copy as");
|
|
4661
|
+
async function It(e, t) {
|
|
4641
4662
|
let n = M(), r = G(n) ? ur(n) : n.root;
|
|
4642
|
-
r.length > 0 && (await
|
|
4663
|
+
r.length > 0 && (await kt(la(r, e, x.value)), Mt.value = t, window.clearTimeout(Nt), Nt = window.setTimeout(() => Mt.value = null, 1500)), N();
|
|
4643
4664
|
}
|
|
4644
|
-
let
|
|
4665
|
+
let Lt = t(() => oa.map(({ format: e, label: t }) => {
|
|
4645
4666
|
let n = e === "mathml" && m.cellml ? `${t} (CellML)` : t;
|
|
4646
4667
|
return {
|
|
4647
4668
|
label: n,
|
|
4648
|
-
command: () =>
|
|
4669
|
+
command: () => It(e, n)
|
|
4649
4670
|
};
|
|
4650
4671
|
}));
|
|
4651
|
-
function
|
|
4652
|
-
|
|
4672
|
+
function Rt(e) {
|
|
4673
|
+
jt.value?.toggle(e);
|
|
4653
4674
|
}
|
|
4654
4675
|
return (t, u) => (g(), i("section", {
|
|
4655
4676
|
class: p(["editor-grid", {
|
|
@@ -4657,11 +4678,21 @@ var va = [
|
|
|
4657
4678
|
"no-outputs": !l.outputs,
|
|
4658
4679
|
readonly: l.readonly
|
|
4659
4680
|
}]),
|
|
4660
|
-
onKeydownCapture:
|
|
4681
|
+
onKeydownCapture: Ke
|
|
4661
4682
|
}, [
|
|
4662
|
-
a("div",
|
|
4663
|
-
|
|
4664
|
-
|
|
4683
|
+
a("div", {
|
|
4684
|
+
ref_key: "panelEl",
|
|
4685
|
+
ref: je,
|
|
4686
|
+
class: "editor-panel"
|
|
4687
|
+
}, [
|
|
4688
|
+
a("div", {
|
|
4689
|
+
ref_key: "toolbarEl",
|
|
4690
|
+
ref: Me,
|
|
4691
|
+
class: p(["toolbar", { stuck: Ne.value }]),
|
|
4692
|
+
role: "toolbar",
|
|
4693
|
+
"aria-label": "Equation tools"
|
|
4694
|
+
}, [
|
|
4695
|
+
a("div", xa, [(g(!0), i(e, null, v(S(ba), (e) => (g(), i("button", {
|
|
4665
4696
|
key: e.id,
|
|
4666
4697
|
type: "button",
|
|
4667
4698
|
class: p(["tool-button", { "has-gallery": !!e.sections }]),
|
|
@@ -4669,11 +4700,11 @@ var va = [
|
|
|
4669
4700
|
"data-role": `toolbar-${e.id}`,
|
|
4670
4701
|
"aria-haspopup": e.sections ? "true" : void 0,
|
|
4671
4702
|
disabled: l.readonly,
|
|
4672
|
-
onMousedown: u[0] ||=
|
|
4673
|
-
onClick: (t) =>
|
|
4674
|
-
}, [a("span", { innerHTML:
|
|
4675
|
-
a("div",
|
|
4676
|
-
c(S(
|
|
4703
|
+
onMousedown: u[0] ||= D(() => {}, ["prevent"]),
|
|
4704
|
+
onClick: (t) => Xe(e, t)
|
|
4705
|
+
}, [a("span", { innerHTML: Qe(e.latex) }, null, 8, Ca), e.sections ? (g(), i("i", wa)) : r("", !0)], 42, Sa))), 128))]),
|
|
4706
|
+
a("div", Ta, [
|
|
4707
|
+
c(S(O), {
|
|
4677
4708
|
icon: "pi pi-plus",
|
|
4678
4709
|
size: "small",
|
|
4679
4710
|
text: "",
|
|
@@ -4681,96 +4712,96 @@ var va = [
|
|
|
4681
4712
|
"aria-label": "Add equation line",
|
|
4682
4713
|
"data-role": "add-line",
|
|
4683
4714
|
disabled: l.readonly,
|
|
4684
|
-
onMousedown: u[1] ||=
|
|
4685
|
-
onClick: u[2] ||= (e) =>
|
|
4715
|
+
onMousedown: u[1] ||= D(() => {}, ["prevent"]),
|
|
4716
|
+
onClick: u[2] ||= (e) => Le("new-line")
|
|
4686
4717
|
}, null, 8, ["disabled"]),
|
|
4687
|
-
c(S(
|
|
4718
|
+
c(S(O), {
|
|
4688
4719
|
icon: "pi pi-trash",
|
|
4689
4720
|
size: "small",
|
|
4690
4721
|
text: "",
|
|
4691
4722
|
severity: "danger",
|
|
4692
4723
|
title: "Remove equation line",
|
|
4693
4724
|
"aria-label": "Remove equation line",
|
|
4694
|
-
disabled: l.readonly ||
|
|
4695
|
-
onMousedown: u[3] ||=
|
|
4696
|
-
onClick:
|
|
4725
|
+
disabled: l.readonly || C.value.length <= 1,
|
|
4726
|
+
onMousedown: u[3] ||= D(() => {}, ["prevent"]),
|
|
4727
|
+
onClick: Ue
|
|
4697
4728
|
}, null, 8, ["disabled"]),
|
|
4698
|
-
m.history ? (g(), n(S(
|
|
4729
|
+
m.history ? (g(), n(S(O), {
|
|
4699
4730
|
key: 0,
|
|
4700
4731
|
icon: "pi pi-undo",
|
|
4701
4732
|
size: "small",
|
|
4702
4733
|
text: "",
|
|
4703
4734
|
title: "Undo (Ctrl+Z)",
|
|
4704
|
-
disabled: l.readonly || !
|
|
4705
|
-
onMousedown: u[4] ||=
|
|
4706
|
-
onClick:
|
|
4735
|
+
disabled: l.readonly || !we.value,
|
|
4736
|
+
onMousedown: u[4] ||= D(() => {}, ["prevent"]),
|
|
4737
|
+
onClick: L
|
|
4707
4738
|
}, null, 8, ["disabled"])) : r("", !0),
|
|
4708
|
-
m.history ? (g(), n(S(
|
|
4739
|
+
m.history ? (g(), n(S(O), {
|
|
4709
4740
|
key: 1,
|
|
4710
4741
|
icon: "pi pi-refresh",
|
|
4711
4742
|
size: "small",
|
|
4712
4743
|
text: "",
|
|
4713
4744
|
title: "Redo (Ctrl+Shift+Z)",
|
|
4714
|
-
disabled: l.readonly || !
|
|
4715
|
-
onMousedown: u[5] ||=
|
|
4716
|
-
onClick:
|
|
4745
|
+
disabled: l.readonly || !Te.value,
|
|
4746
|
+
onMousedown: u[5] ||= D(() => {}, ["prevent"]),
|
|
4747
|
+
onClick: Ce
|
|
4717
4748
|
}, null, 8, ["disabled"])) : r("", !0)
|
|
4718
4749
|
]),
|
|
4719
|
-
l.outputs ? (g(), i("div",
|
|
4750
|
+
l.outputs ? (g(), i("div", Ea, [c(S(O), {
|
|
4720
4751
|
icon: "pi pi-copy",
|
|
4721
|
-
label:
|
|
4752
|
+
label: H.value,
|
|
4722
4753
|
size: "small",
|
|
4723
4754
|
text: "",
|
|
4724
4755
|
title: "Copy the selection, or the whole equation, as LaTeX, MathJSON or Content MathML",
|
|
4725
4756
|
"aria-haspopup": "true",
|
|
4726
4757
|
"aria-controls": "copy-as-menu",
|
|
4727
4758
|
"data-role": "copy-as",
|
|
4728
|
-
disabled: !
|
|
4729
|
-
onMousedown: u[6] ||=
|
|
4730
|
-
onClick:
|
|
4731
|
-
}, null, 8, ["label", "disabled"]), c(S(
|
|
4759
|
+
disabled: !Ft.value,
|
|
4760
|
+
onMousedown: u[6] ||= D(() => {}, ["prevent"]),
|
|
4761
|
+
onClick: Rt
|
|
4762
|
+
}, null, 8, ["label", "disabled"]), c(S(le), {
|
|
4732
4763
|
id: "copy-as-menu",
|
|
4733
4764
|
ref_key: "copyMenu",
|
|
4734
|
-
ref:
|
|
4735
|
-
model:
|
|
4765
|
+
ref: jt,
|
|
4766
|
+
model: Lt.value,
|
|
4736
4767
|
popup: !0
|
|
4737
4768
|
}, null, 8, ["model"])])) : r("", !0)
|
|
4738
|
-
]),
|
|
4739
|
-
c(S(
|
|
4769
|
+
], 2),
|
|
4770
|
+
c(S(ue), {
|
|
4740
4771
|
ref_key: "gallery",
|
|
4741
|
-
ref:
|
|
4772
|
+
ref: Je,
|
|
4742
4773
|
"data-me-popover": "",
|
|
4743
4774
|
"data-role": "gallery",
|
|
4744
4775
|
class: "me-gallery"
|
|
4745
4776
|
}, {
|
|
4746
|
-
default:
|
|
4777
|
+
default: T(() => [Ye.value ? (g(), i("div", Da, [(g(!0), i(e, null, v(Ye.value.sections, (t, n) => (g(), i("div", {
|
|
4747
4778
|
key: n,
|
|
4748
4779
|
class: "gallery-section"
|
|
4749
|
-
}, [t.label ? (g(), i("div",
|
|
4780
|
+
}, [t.label ? (g(), i("div", Oa, y(t.label), 1)) : r("", !0), a("div", ka, [(g(!0), i(e, null, v(t.items, (e) => (g(), i("button", {
|
|
4750
4781
|
key: e.title,
|
|
4751
4782
|
type: "button",
|
|
4752
4783
|
class: "tool-button",
|
|
4753
4784
|
title: e.title,
|
|
4754
|
-
onMousedown: u[7] ||=
|
|
4755
|
-
onClick: (t) =>
|
|
4756
|
-
}, [a("span", { innerHTML:
|
|
4785
|
+
onMousedown: u[7] ||= D(() => {}, ["prevent"]),
|
|
4786
|
+
onClick: (t) => Ze(e.command)
|
|
4787
|
+
}, [a("span", { innerHTML: Qe(e.latex) }, null, 8, ja)], 40, Aa))), 128))])]))), 128))])) : r("", !0)]),
|
|
4757
4788
|
_: 1
|
|
4758
4789
|
}, 512),
|
|
4759
4790
|
a("div", {
|
|
4760
4791
|
ref_key: "stackEl",
|
|
4761
|
-
ref:
|
|
4792
|
+
ref: Be,
|
|
4762
4793
|
class: "equations-stack",
|
|
4763
|
-
onKeydown:
|
|
4764
|
-
onFocusout:
|
|
4765
|
-
}, [(g(!0), i(e, null, v(
|
|
4766
|
-
key:
|
|
4767
|
-
class: p(["equation-row", [{ active: t === A.value },
|
|
4794
|
+
onKeydown: qe,
|
|
4795
|
+
onFocusout: Ve
|
|
4796
|
+
}, [(g(!0), i(e, null, v(C.value, (e, t) => (g(), i("div", {
|
|
4797
|
+
key: E.value[t],
|
|
4798
|
+
class: p(["equation-row", [{ active: t === A.value }, ft(t)]]),
|
|
4768
4799
|
"data-line": t,
|
|
4769
|
-
"data-line-id":
|
|
4770
|
-
onFocusin: (e) =>
|
|
4771
|
-
}, [a("div",
|
|
4800
|
+
"data-line-id": E.value[t],
|
|
4801
|
+
onFocusin: (e) => ze(t)
|
|
4802
|
+
}, [a("div", Na, y(t + 1), 1), c(Wi, {
|
|
4772
4803
|
ref_for: !0,
|
|
4773
|
-
ref: (e) =>
|
|
4804
|
+
ref: (e) => ve.value[t] = e,
|
|
4774
4805
|
class: "equation-field",
|
|
4775
4806
|
"model-value": e.root,
|
|
4776
4807
|
cursor: e.cursor,
|
|
@@ -4778,12 +4809,12 @@ var va = [
|
|
|
4778
4809
|
active: t === A.value,
|
|
4779
4810
|
readonly: l.readonly,
|
|
4780
4811
|
autofocus: l.autofocus && t === A.value ? !0 : void 0,
|
|
4781
|
-
marks:
|
|
4812
|
+
marks: ut.value[t],
|
|
4782
4813
|
"greek-names": l.greekNames,
|
|
4783
4814
|
"typeset-names": l.typesetNames,
|
|
4784
|
-
onNavigate: (e) =>
|
|
4785
|
-
onEdit: (e, n) =>
|
|
4786
|
-
onImport: (e) =>
|
|
4815
|
+
onNavigate: (e) => De(t, e),
|
|
4816
|
+
onEdit: (e, n) => R(t, e, n),
|
|
4817
|
+
onImport: (e) => ke(t, e)
|
|
4787
4818
|
}, null, 8, [
|
|
4788
4819
|
"model-value",
|
|
4789
4820
|
"cursor",
|
|
@@ -4797,50 +4828,50 @@ var va = [
|
|
|
4797
4828
|
"onNavigate",
|
|
4798
4829
|
"onEdit",
|
|
4799
4830
|
"onImport"
|
|
4800
|
-
])], 42,
|
|
4831
|
+
])], 42, Ma))), 128))], 544),
|
|
4801
4832
|
a("div", {
|
|
4802
4833
|
class: p(["status-bar", V.value ? `status-${V.value.kind}` : null]),
|
|
4803
4834
|
"data-role": "status",
|
|
4804
4835
|
"data-kind": V.value?.kind,
|
|
4805
|
-
title:
|
|
4836
|
+
title: pt.value || void 0,
|
|
4806
4837
|
role: "status",
|
|
4807
|
-
onMousedown: u[8] ||=
|
|
4808
|
-
onClick:
|
|
4809
|
-
}, [V.value?.kind === "command" ? (g(), i("span",
|
|
4838
|
+
onMousedown: u[8] ||= D(() => {}, ["prevent"]),
|
|
4839
|
+
onClick: mt
|
|
4840
|
+
}, [V.value?.kind === "command" ? (g(), i("span", Fa, [
|
|
4810
4841
|
u[10] ||= a("span", { class: "command-slash" }, "\\", -1),
|
|
4811
4842
|
s(y(V.value.text), 1),
|
|
4812
4843
|
u[11] ||= a("span", { class: "command-caret" }, null, -1)
|
|
4813
|
-
])) : V.value ? (g(), i(e, { key: 1 }, [a("span",
|
|
4814
|
-
l.debug ? (g(), i("p",
|
|
4844
|
+
])) : V.value ? (g(), i(e, { key: 1 }, [a("span", Ia, y(V.value.text), 1), V.value.more ? (g(), i("span", La, "+" + y(V.value.more) + " more", 1)) : r("", !0)], 64)) : r("", !0)], 42, Pa),
|
|
4845
|
+
l.debug ? (g(), i("p", Ra, [
|
|
4815
4846
|
u[13] ||= s(" Cursor: ", -1),
|
|
4816
|
-
a("span",
|
|
4817
|
-
|
|
4847
|
+
a("span", za, y(wt.value), 1),
|
|
4848
|
+
Tt.value ? (g(), i(e, { key: 0 }, [u[12] ||= s(" · Selection: ", -1), a("span", Ba, y(Tt.value), 1)], 64)) : r("", !0)
|
|
4818
4849
|
])) : r("", !0),
|
|
4819
|
-
a("details",
|
|
4850
|
+
a("details", Va, [u[20] ||= o("<summary data-v-2efa820f>Keys and typing</summary><p class=\"key-hint\" data-v-2efa820f><kbd data-v-2efa820f>←</kbd><kbd data-v-2efa820f>→</kbd> move through every position · <kbd data-v-2efa820f>↑</kbd><kbd data-v-2efa820f>↓</kbd> numerator/denominator, else previous/next line · <kbd data-v-2efa820f>Home</kbd><kbd data-v-2efa820f>End</kbd> start/end · <kbd data-v-2efa820f>Tab</kbd> next empty slot · <kbd data-v-2efa820f>Space</kbd> step out of a fraction, exponent or bracket · <kbd data-v-2efa820f>Enter</kbd> new line (in a piecewise: new piece; <kbd data-v-2efa820f>Backspace</kbd> in an empty piece removes it; <code data-v-2efa820f>\\otherwise</code> adds one) </p><p class=\"key-hint\" data-v-2efa820f> Select with <kbd data-v-2efa820f>Shift</kbd>+<kbd data-v-2efa820f>←</kbd><kbd data-v-2efa820f>→</kbd>, <kbd data-v-2efa820f>Shift</kbd>+<kbd data-v-2efa820f>Home</kbd><kbd data-v-2efa820f>End</kbd>, <kbd data-v-2efa820f>Ctrl</kbd>+<kbd data-v-2efa820f>A</kbd> or by dragging · <code data-v-2efa820f>/</code>, <code data-v-2efa820f>^</code>, <code data-v-2efa820f>(</code>, <code data-v-2efa820f>|</code>, <code data-v-2efa820f>\\sqrt</code>, <code data-v-2efa820f>\\sin</code>, … or a toolbar button then wraps the selection · typing replaces it · <kbd data-v-2efa820f>Esc</kbd> clears it · <kbd data-v-2efa820f>Ctrl</kbd>+<kbd data-v-2efa820f>C</kbd>/<kbd data-v-2efa820f>X</kbd>/<kbd data-v-2efa820f>V</kbd> copy, cut and paste (copies as LaTeX for other apps; pastes LaTeX or plain text such as <code data-v-2efa820f>(x+1)/2</code>) </p>", 3), a("p", Ha, [u[19] ||= o(" Type letters, numbers and <code data-v-2efa820f>+ − * = ,</code> where the caret is · conditions: <code data-v-2efa820f>< > <= >= !=</code>, <code data-v-2efa820f>&</code> (∧), <code data-v-2efa820f>!</code> (¬), <code data-v-2efa820f>\\or</code> (∨) · <code data-v-2efa820f>/</code> makes a fraction of what's before the caret · <code data-v-2efa820f>^</code> exponent · <code data-v-2efa820f>( )</code> and <code data-v-2efa820f>| |</code> brackets · <code data-v-2efa820f>0.25{mV}</code> a number's units · letters, digits and <code data-v-2efa820f>_</code> with no operator between them are one name (<code data-v-2efa820f>Vm_init</code>); multiply names with <code data-v-2efa820f>*</code> (<code data-v-2efa820f>a*b</code>) · a name spelling a function (<code data-v-2efa820f>sin</code>, <code data-v-2efa820f>cosh</code>, …) is that function · <code data-v-2efa820f>\\</code> commands (<code data-v-2efa820f>\\frac \\sqrt \\root \\abs \\dd \\cases \\sin \\pi \\e \\inf \\alpha</code> …) · <kbd data-v-2efa820f>Backspace</kbd>/<kbd data-v-2efa820f>Delete</kbd> delete", 41), m.history ? (g(), i(e, { key: 0 }, [
|
|
4820
4851
|
u[14] ||= s(" · ", -1),
|
|
4821
4852
|
u[15] ||= a("kbd", null, "Ctrl", -1),
|
|
4822
4853
|
u[16] ||= s("+", -1),
|
|
4823
4854
|
u[17] ||= a("kbd", null, "Z", -1),
|
|
4824
4855
|
u[18] ||= s(" undo", -1)
|
|
4825
4856
|
], 64)) : r("", !0)])])
|
|
4826
|
-
]),
|
|
4827
|
-
t.$slots.side ? (g(), i("aside",
|
|
4828
|
-
l.outputs ? (g(), n(S(
|
|
4857
|
+
], 512),
|
|
4858
|
+
t.$slots.side ? (g(), i("aside", Ua, [ne(t.$slots, "side", {}, void 0, !0)])) : r("", !0),
|
|
4859
|
+
l.outputs ? (g(), n(S(ce), {
|
|
4829
4860
|
key: 1,
|
|
4830
4861
|
class: "output-card",
|
|
4831
4862
|
"data-role": "outputs"
|
|
4832
4863
|
}, {
|
|
4833
|
-
content:
|
|
4834
|
-
value:
|
|
4835
|
-
"onUpdate:value": u[9] ||= (e) =>
|
|
4864
|
+
content: T(() => [c(S(he), {
|
|
4865
|
+
value: Dt.value,
|
|
4866
|
+
"onUpdate:value": u[9] ||= (e) => Dt.value = e
|
|
4836
4867
|
}, {
|
|
4837
|
-
default:
|
|
4838
|
-
default:
|
|
4839
|
-
c(S(
|
|
4868
|
+
default: T(() => [c(S(fe), null, {
|
|
4869
|
+
default: T(() => [
|
|
4870
|
+
c(S(de), {
|
|
4840
4871
|
value: "mathml",
|
|
4841
4872
|
"data-role": "tab-mathml"
|
|
4842
4873
|
}, {
|
|
4843
|
-
default:
|
|
4874
|
+
default: T(() => [u[21] ||= s(" Content MathML ", -1), l.cellml ? (g(), n(S(ge), {
|
|
4844
4875
|
key: 0,
|
|
4845
4876
|
class: "tab-tag",
|
|
4846
4877
|
severity: "secondary",
|
|
@@ -4849,52 +4880,52 @@ var va = [
|
|
|
4849
4880
|
})) : r("", !0)]),
|
|
4850
4881
|
_: 1
|
|
4851
4882
|
}),
|
|
4852
|
-
c(S(
|
|
4883
|
+
c(S(de), {
|
|
4853
4884
|
value: "mathjson",
|
|
4854
4885
|
"data-role": "tab-mathjson"
|
|
4855
4886
|
}, {
|
|
4856
|
-
default:
|
|
4887
|
+
default: T(() => [...u[22] ||= [s("MathJSON", -1)]]),
|
|
4857
4888
|
_: 1
|
|
4858
4889
|
}),
|
|
4859
|
-
c(S(
|
|
4890
|
+
c(S(de), {
|
|
4860
4891
|
value: "latex",
|
|
4861
4892
|
"data-role": "tab-latex"
|
|
4862
4893
|
}, {
|
|
4863
|
-
default:
|
|
4894
|
+
default: T(() => [...u[23] ||= [s("LaTeX", -1)]]),
|
|
4864
4895
|
_: 1
|
|
4865
4896
|
}),
|
|
4866
|
-
c(S(
|
|
4897
|
+
c(S(de), {
|
|
4867
4898
|
value: "ast",
|
|
4868
4899
|
"data-role": "tab-ast"
|
|
4869
4900
|
}, {
|
|
4870
|
-
default:
|
|
4901
|
+
default: T(() => [...u[24] ||= [s("AST", -1)]]),
|
|
4871
4902
|
_: 1
|
|
4872
4903
|
})
|
|
4873
4904
|
]),
|
|
4874
4905
|
_: 1
|
|
4875
|
-
}), c(S(
|
|
4876
|
-
default:
|
|
4877
|
-
c(S(
|
|
4878
|
-
default:
|
|
4906
|
+
}), c(S(me), null, {
|
|
4907
|
+
default: T(() => [
|
|
4908
|
+
c(S(pe), { value: "mathml" }, {
|
|
4909
|
+
default: T(() => [a("pre", Wa, y(Ct.value), 1)]),
|
|
4879
4910
|
_: 1
|
|
4880
4911
|
}),
|
|
4881
|
-
c(S(
|
|
4882
|
-
default:
|
|
4912
|
+
c(S(pe), { value: "mathjson" }, {
|
|
4913
|
+
default: T(() => [a("div", Ga, [c(S(O), {
|
|
4883
4914
|
icon: "pi pi-copy",
|
|
4884
|
-
label:
|
|
4915
|
+
label: Et.value ? "Copied" : "Copy MathJSON",
|
|
4885
4916
|
size: "small",
|
|
4886
4917
|
text: "",
|
|
4887
|
-
disabled: !
|
|
4888
|
-
onClick:
|
|
4889
|
-
}, null, 8, ["label", "disabled"])]), a("pre",
|
|
4918
|
+
disabled: !St.value,
|
|
4919
|
+
onClick: At
|
|
4920
|
+
}, null, 8, ["label", "disabled"])]), a("pre", Ka, y(St.value), 1)]),
|
|
4890
4921
|
_: 1
|
|
4891
4922
|
}),
|
|
4892
|
-
c(S(
|
|
4893
|
-
default:
|
|
4923
|
+
c(S(pe), { value: "latex" }, {
|
|
4924
|
+
default: T(() => [a("pre", qa, y(xt.value), 1)]),
|
|
4894
4925
|
_: 1
|
|
4895
4926
|
}),
|
|
4896
|
-
c(S(
|
|
4897
|
-
default:
|
|
4927
|
+
c(S(pe), { value: "ast" }, {
|
|
4928
|
+
default: T(() => [a("pre", Ja, y(bt.value ? JSON.stringify(bt.value, null, 2) : ""), 1)]),
|
|
4898
4929
|
_: 1
|
|
4899
4930
|
})
|
|
4900
4931
|
]),
|
|
@@ -4906,7 +4937,7 @@ var va = [
|
|
|
4906
4937
|
})) : r("", !0)
|
|
4907
4938
|
], 34));
|
|
4908
4939
|
}
|
|
4909
|
-
}), [["__scopeId", "data-v-
|
|
4940
|
+
}), [["__scopeId", "data-v-2efa820f"]]), Za = "new units", Qa = [
|
|
4910
4941
|
"yotta",
|
|
4911
4942
|
"zetta",
|
|
4912
4943
|
"exa",
|
|
@@ -4927,15 +4958,15 @@ var va = [
|
|
|
4927
4958
|
"atto",
|
|
4928
4959
|
"zepto",
|
|
4929
4960
|
"yocto"
|
|
4930
|
-
],
|
|
4931
|
-
function
|
|
4961
|
+
], $a = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
4962
|
+
function eo(e, t, n) {
|
|
4932
4963
|
let r = [], { name: i, parts: a } = e;
|
|
4933
|
-
return i ?
|
|
4964
|
+
return i ? $a.test(i) ? (t.some((e) => e.name === i) || n?.includes(i)) && r.push(`There are units called ${i} already`) : r.push(`${i} isn't a units name: use letters, digits and _, not starting with a digit`) : r.push("Give the units a name"), a.length === 0 && r.push("Add what the units are made of"), a.forEach((e, o) => {
|
|
4934
4965
|
let s = a.length > 1 ? `Part ${o + 1}: ` : "";
|
|
4935
|
-
e.units ? e.units === i ? r.push(`${s}units can't be made of themselves`) : n && !n.includes(e.units) && !t.some((t) => t.name === e.units) && r.push(`${s}no units called ${e.units} are defined`) : r.push(`${s}choose the units it is made of`), e.prefix && !
|
|
4936
|
-
}), i &&
|
|
4966
|
+
e.units ? e.units === i ? r.push(`${s}units can't be made of themselves`) : n && !n.includes(e.units) && !t.some((t) => t.name === e.units) && r.push(`${s}no units called ${e.units} are defined`) : r.push(`${s}choose the units it is made of`), e.prefix && !Qa.includes(e.prefix) && r.push(`${s}${e.prefix} isn't a prefix`), e.exponent !== void 0 && !Number.isFinite(e.exponent) && r.push(`${s}the exponent must be a number`), e.multiplier !== void 0 && !Number.isFinite(e.multiplier) && r.push(`${s}the multiplier must be a number`);
|
|
4967
|
+
}), i && $a.test(i) && to(i, a, t) && r.push(`${i} would be made of itself, through other new units`), r;
|
|
4937
4968
|
}
|
|
4938
|
-
function
|
|
4969
|
+
function to(e, t, n) {
|
|
4939
4970
|
let r = /* @__PURE__ */ new Set(), i = (t) => {
|
|
4940
4971
|
if (t === e) return !0;
|
|
4941
4972
|
if (r.has(t)) return !1;
|
|
@@ -4945,17 +4976,17 @@ function ro(e, t, n) {
|
|
|
4945
4976
|
};
|
|
4946
4977
|
return t.some((t) => t.units !== e && i(t.units));
|
|
4947
4978
|
}
|
|
4948
|
-
function
|
|
4979
|
+
function no(e, t) {
|
|
4949
4980
|
return t.filter((t) => t.parts.some((t) => t.units === e)).map((e) => e.name);
|
|
4950
4981
|
}
|
|
4951
|
-
function
|
|
4982
|
+
function ro(e) {
|
|
4952
4983
|
return e.parts.map((e) => {
|
|
4953
4984
|
let t = [e.multiplier !== void 0 && e.multiplier !== 1 ? e.multiplier : ""].concat(e.prefix ?? "", e.units).filter((e) => e !== "").join(" "), n = e.exponent ?? 1;
|
|
4954
4985
|
return n === 1 ? t : t.includes(" ") ? `(${t})^${n}` : `${t}^${n}`;
|
|
4955
4986
|
}).join(" · ");
|
|
4956
4987
|
}
|
|
4957
|
-
var
|
|
4958
|
-
function
|
|
4988
|
+
var io = (e) => e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
4989
|
+
function ao(e, t = "new_units") {
|
|
4959
4990
|
let n = [], r = (t, i) => {
|
|
4960
4991
|
if (!(n.includes(t) || i.has(t.name))) {
|
|
4961
4992
|
i.add(t.name);
|
|
@@ -4969,20 +5000,20 @@ function so(e, t = "new_units") {
|
|
|
4969
5000
|
for (let t of e) r(t, /* @__PURE__ */ new Set());
|
|
4970
5001
|
let i = n.map((e) => {
|
|
4971
5002
|
let t = e.parts.map((e) => ` <unit${[
|
|
4972
|
-
e.prefix ? ` prefix="${
|
|
4973
|
-
` units="${
|
|
5003
|
+
e.prefix ? ` prefix="${io(e.prefix)}"` : "",
|
|
5004
|
+
` units="${io(e.units)}"`,
|
|
4974
5005
|
e.exponent !== void 0 && e.exponent !== 1 ? ` exponent="${e.exponent}"` : "",
|
|
4975
5006
|
e.multiplier !== void 0 && e.multiplier !== 1 ? ` multiplier="${e.multiplier}"` : ""
|
|
4976
5007
|
].join("")}/>`);
|
|
4977
5008
|
return [
|
|
4978
|
-
` <units name="${
|
|
5009
|
+
` <units name="${io(e.name)}">`,
|
|
4979
5010
|
...t,
|
|
4980
5011
|
" </units>"
|
|
4981
5012
|
].join("\n");
|
|
4982
5013
|
});
|
|
4983
5014
|
return [
|
|
4984
5015
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
|
|
4985
|
-
`<model xmlns="http://www.cellml.org/cellml/2.0#" name="${
|
|
5016
|
+
`<model xmlns="http://www.cellml.org/cellml/2.0#" name="${io(t)}">`,
|
|
4986
5017
|
...i,
|
|
4987
5018
|
"</model>",
|
|
4988
5019
|
""
|
|
@@ -4990,15 +5021,15 @@ function so(e, t = "new_units") {
|
|
|
4990
5021
|
}
|
|
4991
5022
|
//#endregion
|
|
4992
5023
|
//#region src/units/UnitsDefinitionForm.vue?vue&type=script&setup=true&lang.ts
|
|
4993
|
-
var
|
|
5024
|
+
var oo = { class: "form-name" }, so = { class: "form-parts" }, co = ["onUpdate:modelValue", "aria-label"], lo = ["value"], uo = [
|
|
4994
5025
|
"onUpdate:modelValue",
|
|
4995
5026
|
"list",
|
|
4996
5027
|
"aria-label"
|
|
4997
|
-
],
|
|
5028
|
+
], fo = ["onUpdate:modelValue", "aria-label"], po = ["onUpdate:modelValue", "aria-label"], mo = ["id"], ho = ["value"], go = {
|
|
4998
5029
|
key: 0,
|
|
4999
5030
|
class: "form-problems",
|
|
5000
5031
|
"data-role": "units-form-problems"
|
|
5001
|
-
},
|
|
5032
|
+
}, _o = { class: "form-actions" }, vo = /*#__PURE__*/ Ui(/* @__PURE__ */ l({
|
|
5002
5033
|
__name: "UnitsDefinitionForm",
|
|
5003
5034
|
props: {
|
|
5004
5035
|
definition: {},
|
|
@@ -5025,7 +5056,7 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
|
|
|
5025
5056
|
...n !== void 0 && n !== 1 ? { multiplier: n } : {}
|
|
5026
5057
|
};
|
|
5027
5058
|
})
|
|
5028
|
-
})), h = t(() =>
|
|
5059
|
+
})), h = t(() => eo(te.value, s.others, s.known));
|
|
5029
5060
|
function ne() {
|
|
5030
5061
|
m.value = !0, h.value.length === 0 && l("save", te.value);
|
|
5031
5062
|
}
|
|
@@ -5033,17 +5064,17 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
|
|
|
5033
5064
|
return (t, o) => (g(), i("form", {
|
|
5034
5065
|
class: "units-form",
|
|
5035
5066
|
"data-role": "units-form",
|
|
5036
|
-
onSubmit:
|
|
5067
|
+
onSubmit: D(ne, ["prevent"])
|
|
5037
5068
|
}, [
|
|
5038
|
-
a("label",
|
|
5069
|
+
a("label", oo, [o[3] ||= a("span", null, "Name", -1), E(a("input", {
|
|
5039
5070
|
"onUpdate:modelValue": o[0] ||= (e) => f.value = e,
|
|
5040
5071
|
type: "text",
|
|
5041
5072
|
spellcheck: "false",
|
|
5042
5073
|
autocomplete: "off",
|
|
5043
5074
|
placeholder: "mV_per_ms",
|
|
5044
5075
|
"data-role": "units-form-name"
|
|
5045
|
-
}, null, 512), [[
|
|
5046
|
-
a("table",
|
|
5076
|
+
}, null, 512), [[w, f.value]])]),
|
|
5077
|
+
a("table", so, [o[5] ||= a("thead", null, [a("tr", null, [
|
|
5047
5078
|
a("th", { scope: "col" }, "Prefix"),
|
|
5048
5079
|
a("th", { scope: "col" }, "Units"),
|
|
5049
5080
|
a("th", {
|
|
@@ -5059,14 +5090,14 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
|
|
|
5059
5090
|
key: t.key,
|
|
5060
5091
|
"data-role": "units-form-part"
|
|
5061
5092
|
}, [
|
|
5062
|
-
a("td", null, [
|
|
5093
|
+
a("td", null, [E(a("select", {
|
|
5063
5094
|
"onUpdate:modelValue": (e) => t.prefix = e,
|
|
5064
5095
|
"aria-label": `Prefix of part ${n + 1}`
|
|
5065
|
-
}, [o[4] ||= a("option", { value: "" }, "—", -1), (g(!0), i(e, null, v(S(
|
|
5096
|
+
}, [o[4] ||= a("option", { value: "" }, "—", -1), (g(!0), i(e, null, v(S(Qa), (e) => (g(), i("option", {
|
|
5066
5097
|
key: e,
|
|
5067
5098
|
value: e
|
|
5068
|
-
}, y(e), 9,
|
|
5069
|
-
a("td", null, [
|
|
5099
|
+
}, y(e), 9, lo))), 128))], 8, co), [[ae, t.prefix]])]),
|
|
5100
|
+
a("td", null, [E(a("input", {
|
|
5070
5101
|
"onUpdate:modelValue": (e) => t.units = e,
|
|
5071
5102
|
type: "text",
|
|
5072
5103
|
list: S(re),
|
|
@@ -5074,24 +5105,24 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
|
|
|
5074
5105
|
autocomplete: "off",
|
|
5075
5106
|
placeholder: "second",
|
|
5076
5107
|
"aria-label": `Units of part ${n + 1}`
|
|
5077
|
-
}, null, 8,
|
|
5078
|
-
a("td", null, [
|
|
5108
|
+
}, null, 8, uo), [[w, t.units]])]),
|
|
5109
|
+
a("td", null, [E(a("input", {
|
|
5079
5110
|
"onUpdate:modelValue": (e) => t.exponent = e,
|
|
5080
5111
|
class: "number",
|
|
5081
5112
|
type: "text",
|
|
5082
5113
|
inputmode: "decimal",
|
|
5083
5114
|
placeholder: "1",
|
|
5084
5115
|
"aria-label": `Exponent of part ${n + 1}`
|
|
5085
|
-
}, null, 8,
|
|
5086
|
-
a("td", null, [
|
|
5116
|
+
}, null, 8, fo), [[w, t.exponent]])]),
|
|
5117
|
+
a("td", null, [E(a("input", {
|
|
5087
5118
|
"onUpdate:modelValue": (e) => t.multiplier = e,
|
|
5088
5119
|
class: "number",
|
|
5089
5120
|
type: "text",
|
|
5090
5121
|
inputmode: "decimal",
|
|
5091
5122
|
placeholder: "1",
|
|
5092
5123
|
"aria-label": `Multiplier of part ${n + 1}`
|
|
5093
|
-
}, null, 8,
|
|
5094
|
-
a("td", null, [c(S(
|
|
5124
|
+
}, null, 8, po), [[w, t.multiplier]])]),
|
|
5125
|
+
a("td", null, [c(S(O), {
|
|
5095
5126
|
icon: "pi pi-times",
|
|
5096
5127
|
size: "small",
|
|
5097
5128
|
text: "",
|
|
@@ -5110,10 +5141,10 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
|
|
|
5110
5141
|
a("datalist", { id: S(re) }, [(g(!0), i(e, null, v(n.choices, (e) => (g(), i("option", {
|
|
5111
5142
|
key: e,
|
|
5112
5143
|
value: e
|
|
5113
|
-
}, null, 8,
|
|
5114
|
-
m.value && h.value.length ? (g(), i("ul",
|
|
5115
|
-
a("div",
|
|
5116
|
-
c(S(
|
|
5144
|
+
}, null, 8, ho))), 128))], 8, mo),
|
|
5145
|
+
m.value && h.value.length ? (g(), i("ul", go, [(g(!0), i(e, null, v(h.value, (e) => (g(), i("li", { key: e }, y(e), 1))), 128))])) : r("", !0),
|
|
5146
|
+
a("div", _o, [
|
|
5147
|
+
c(S(O), {
|
|
5117
5148
|
icon: "pi pi-plus",
|
|
5118
5149
|
label: "Part",
|
|
5119
5150
|
size: "small",
|
|
@@ -5123,7 +5154,7 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
|
|
|
5123
5154
|
onClick: o[1] ||= (e) => p.value.push(d())
|
|
5124
5155
|
}),
|
|
5125
5156
|
o[6] ||= a("span", { class: "spacer" }, null, -1),
|
|
5126
|
-
c(S(
|
|
5157
|
+
c(S(O), {
|
|
5127
5158
|
label: "Cancel",
|
|
5128
5159
|
size: "small",
|
|
5129
5160
|
text: "",
|
|
@@ -5131,7 +5162,7 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
|
|
|
5131
5162
|
type: "button",
|
|
5132
5163
|
onClick: o[2] ||= (e) => l("cancel")
|
|
5133
5164
|
}),
|
|
5134
|
-
c(S(
|
|
5165
|
+
c(S(O), {
|
|
5135
5166
|
label: n.definition ? "Save" : "Add",
|
|
5136
5167
|
size: "small",
|
|
5137
5168
|
type: "submit",
|
|
@@ -5143,7 +5174,7 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
|
|
|
5143
5174
|
}), [["__scopeId", "data-v-effe158e"]]);
|
|
5144
5175
|
//#endregion
|
|
5145
5176
|
//#region src/units/panel.ts
|
|
5146
|
-
function
|
|
5177
|
+
function yo(e, t, n) {
|
|
5147
5178
|
let r = [...new Set(e.flatMap((e) => e.variables))], i = Object.keys(t).filter((e) => !r.includes(e)), a = n ? new Set(n) : null;
|
|
5148
5179
|
return [...r, ...i].map((e) => {
|
|
5149
5180
|
let n = t[e] ?? "", i = n ? a && !a.has(n) ? "unknown" : "ok" : "missing";
|
|
@@ -5155,11 +5186,11 @@ function xo(e, t, n) {
|
|
|
5155
5186
|
};
|
|
5156
5187
|
});
|
|
5157
5188
|
}
|
|
5158
|
-
function
|
|
5189
|
+
function bo(e, t, n) {
|
|
5159
5190
|
let r = { ...e }, i = n.trim();
|
|
5160
5191
|
return i ? r[t] = i : delete r[t], r;
|
|
5161
5192
|
}
|
|
5162
|
-
function
|
|
5193
|
+
function xo(e, t) {
|
|
5163
5194
|
let n = [...e];
|
|
5164
5195
|
for (let e of t) {
|
|
5165
5196
|
let t = n.findIndex((t) => t.name === e.name);
|
|
@@ -5169,67 +5200,67 @@ function Co(e, t) {
|
|
|
5169
5200
|
}
|
|
5170
5201
|
//#endregion
|
|
5171
5202
|
//#region src/units/UnitsPanel.vue?vue&type=script&setup=true&lang.ts
|
|
5172
|
-
var
|
|
5203
|
+
var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
5173
5204
|
class: "units-section",
|
|
5174
5205
|
"aria-labelledby": "units-files-title"
|
|
5175
|
-
},
|
|
5206
|
+
}, To = { class: "section-head" }, Eo = { class: "section-actions" }, Do = {
|
|
5176
5207
|
key: 0,
|
|
5177
5208
|
class: "hint"
|
|
5178
|
-
},
|
|
5209
|
+
}, Oo = {
|
|
5179
5210
|
key: 1,
|
|
5180
5211
|
class: "files",
|
|
5181
5212
|
"data-role": "units-files"
|
|
5182
|
-
},
|
|
5213
|
+
}, ko = ["data-file"], Ao = { class: "file-head" }, jo = { class: "file-name" }, Mo = { class: "file-count" }, No = {
|
|
5183
5214
|
key: 0,
|
|
5184
5215
|
class: "units-names"
|
|
5185
|
-
},
|
|
5216
|
+
}, Po = {
|
|
5186
5217
|
key: 1,
|
|
5187
5218
|
class: "problems",
|
|
5188
5219
|
"data-role": "units-problems"
|
|
5189
|
-
},
|
|
5220
|
+
}, Fo = {
|
|
5190
5221
|
class: "units-section",
|
|
5191
5222
|
"aria-labelledby": "units-new-title",
|
|
5192
5223
|
"data-role": "new-units"
|
|
5193
|
-
},
|
|
5224
|
+
}, Io = { class: "section-head" }, Lo = { class: "section-actions" }, Ro = {
|
|
5194
5225
|
key: 0,
|
|
5195
5226
|
class: "hint"
|
|
5196
|
-
},
|
|
5227
|
+
}, zo = {
|
|
5197
5228
|
key: 1,
|
|
5198
5229
|
class: "new-units"
|
|
5199
|
-
},
|
|
5230
|
+
}, Bo = ["data-units"], Vo = {
|
|
5200
5231
|
key: 1,
|
|
5201
5232
|
class: "new-units-row"
|
|
5202
|
-
},
|
|
5233
|
+
}, Ho = { class: "new-units-name" }, Uo = {
|
|
5203
5234
|
class: "new-units-definition",
|
|
5204
5235
|
"data-role": "new-units-definition"
|
|
5205
|
-
},
|
|
5236
|
+
}, Wo = {
|
|
5206
5237
|
key: 3,
|
|
5207
5238
|
class: "problems",
|
|
5208
5239
|
"data-role": "new-units-problems"
|
|
5209
|
-
},
|
|
5240
|
+
}, Go = {
|
|
5210
5241
|
class: "units-section",
|
|
5211
5242
|
"aria-labelledby": "units-variables-title"
|
|
5212
|
-
},
|
|
5243
|
+
}, Ko = { class: "section-head" }, qo = {
|
|
5213
5244
|
key: 0,
|
|
5214
5245
|
class: "missing-count",
|
|
5215
5246
|
"data-role": "missing-count"
|
|
5216
|
-
},
|
|
5247
|
+
}, Jo = {
|
|
5217
5248
|
key: 0,
|
|
5218
5249
|
class: "hint"
|
|
5219
|
-
},
|
|
5250
|
+
}, Yo = {
|
|
5220
5251
|
key: 1,
|
|
5221
5252
|
class: "variables",
|
|
5222
5253
|
"data-role": "variables"
|
|
5223
|
-
},
|
|
5254
|
+
}, Xo = ["data-variable", "data-state"], Zo = {
|
|
5224
5255
|
scope: "row",
|
|
5225
5256
|
class: "variable-name"
|
|
5226
|
-
},
|
|
5257
|
+
}, Qo = [
|
|
5227
5258
|
"value",
|
|
5228
5259
|
"list",
|
|
5229
5260
|
"aria-label",
|
|
5230
5261
|
"aria-invalid",
|
|
5231
5262
|
"onChange"
|
|
5232
|
-
],
|
|
5263
|
+
], $o = { class: "variable-state" }, es = ["id"], ts = ["value"], ns = /*#__PURE__*/ Ui(/* @__PURE__ */ l({
|
|
5233
5264
|
__name: "UnitsPanel",
|
|
5234
5265
|
props: /*@__PURE__*/ d({
|
|
5235
5266
|
status: {},
|
|
@@ -5256,7 +5287,7 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
|
|
|
5256
5287
|
"update:newUnits"
|
|
5257
5288
|
],
|
|
5258
5289
|
setup(o) {
|
|
5259
|
-
let l = o, u = ie(o, "sources"), d = ie(o, "variableUnits"), f = ie(o, "newUnits"), m = t(() => l.status === "ready"), ee = t(() =>
|
|
5290
|
+
let l = o, u = ie(o, "sources"), d = ie(o, "variableUnits"), f = ie(o, "newUnits"), m = t(() => l.status === "ready"), ee = t(() => yo(l.lines, d.value, m.value ? l.unitsNames : null)), te = t(() => ee.value.filter((e) => e.state === "missing").length), h = t(() => ({
|
|
5260
5291
|
ready: {
|
|
5261
5292
|
value: "libCellML",
|
|
5262
5293
|
severity: "success"
|
|
@@ -5278,21 +5309,21 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
|
|
|
5278
5309
|
let t = new Set(l.issues.map((e) => e.lineId)).size;
|
|
5279
5310
|
return l.issues.length === 0 ? `No units problems in ${b(e, "equation")}.` : `${b(l.issues.length, "units problem")} in ${b(t, "equation")}.`;
|
|
5280
5311
|
}), b = (e, t) => `${e} ${t}${e === 1 ? "" : "s"}`, x = _(null);
|
|
5281
|
-
async function
|
|
5312
|
+
async function ae(e) {
|
|
5282
5313
|
let t = e.target, n = [...t.files ?? []];
|
|
5283
5314
|
t.value = "";
|
|
5284
5315
|
let r = await Promise.all(n.map(async (e) => ({
|
|
5285
5316
|
name: e.name,
|
|
5286
5317
|
text: await e.text()
|
|
5287
5318
|
})));
|
|
5288
|
-
r.length && (u.value =
|
|
5319
|
+
r.length && (u.value = xo(u.value, r));
|
|
5289
5320
|
}
|
|
5290
|
-
function
|
|
5321
|
+
function w(e) {
|
|
5291
5322
|
u.value = u.value.filter((t) => t.name !== e);
|
|
5292
5323
|
}
|
|
5293
|
-
let
|
|
5294
|
-
function
|
|
5295
|
-
let t = [...f.value], n =
|
|
5324
|
+
let oe = (e) => l.problems.filter((t) => t.source === e), E = (e) => l.files.find((t) => t.name === e)?.units ?? [], D = _(void 0), se = t(() => D.value === void 0 || D.value === null ? null : f.value[D.value]), le = t(() => f.value.filter((e, t) => t !== D.value)), ue = t(() => m.value ? l.unitsNames.filter((e) => e !== se.value?.name) : null), de = t(() => [.../* @__PURE__ */ new Set([...l.unitsNames, ...le.value.map((e) => e.name)])].filter((e) => e !== se.value?.name)), fe = t(() => oe(Za));
|
|
5325
|
+
function pe(e) {
|
|
5326
|
+
let t = [...f.value], n = D.value;
|
|
5296
5327
|
if (n == null) t.push(e);
|
|
5297
5328
|
else {
|
|
5298
5329
|
let r = t[n].name;
|
|
@@ -5304,35 +5335,35 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
|
|
|
5304
5335
|
} : t)
|
|
5305
5336
|
});
|
|
5306
5337
|
}
|
|
5307
|
-
f.value = t,
|
|
5338
|
+
f.value = t, D.value = void 0;
|
|
5308
5339
|
}
|
|
5309
|
-
function
|
|
5340
|
+
function me(e) {
|
|
5310
5341
|
f.value = f.value.filter((t, n) => n !== e);
|
|
5311
5342
|
}
|
|
5312
|
-
let
|
|
5313
|
-
function
|
|
5314
|
-
d.value =
|
|
5343
|
+
let he = C();
|
|
5344
|
+
function _e(e, t) {
|
|
5345
|
+
d.value = bo(d.value, e, t.target.value);
|
|
5315
5346
|
}
|
|
5316
|
-
let
|
|
5347
|
+
let k = {
|
|
5317
5348
|
ok: "",
|
|
5318
5349
|
missing: "no units",
|
|
5319
5350
|
unknown: "unknown units"
|
|
5320
5351
|
};
|
|
5321
|
-
return (t, l) => (g(), n(S(
|
|
5352
|
+
return (t, l) => (g(), n(S(ce), {
|
|
5322
5353
|
class: "units-panel",
|
|
5323
5354
|
"data-role": "units-panel",
|
|
5324
5355
|
"data-status": o.status
|
|
5325
5356
|
}, {
|
|
5326
|
-
title:
|
|
5357
|
+
title: T(() => [a("div", So, [l[4] ||= a("span", null, "Units", -1), c(S(ge), {
|
|
5327
5358
|
severity: h.value.severity,
|
|
5328
5359
|
value: h.value.value,
|
|
5329
5360
|
"data-role": "units-status"
|
|
5330
5361
|
}, null, 8, ["severity", "value"])])]),
|
|
5331
|
-
subtitle:
|
|
5332
|
-
content:
|
|
5333
|
-
a("section",
|
|
5362
|
+
subtitle: T(() => [a("span", Co, y(re.value), 1)]),
|
|
5363
|
+
content: T(() => [
|
|
5364
|
+
a("section", wo, [a("div", To, [l[5] ||= a("h3", { id: "units-files-title" }, "Units files", -1), a("div", Eo, [
|
|
5334
5365
|
ne(t.$slots, "actions", {}, void 0, !0),
|
|
5335
|
-
c(S(
|
|
5366
|
+
c(S(O), {
|
|
5336
5367
|
icon: "pi pi-folder-open",
|
|
5337
5368
|
label: "Load units files",
|
|
5338
5369
|
size: "small",
|
|
@@ -5349,9 +5380,9 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
|
|
|
5349
5380
|
multiple: "",
|
|
5350
5381
|
hidden: "",
|
|
5351
5382
|
"data-role": "units-file-input",
|
|
5352
|
-
onChange:
|
|
5383
|
+
onChange: ae
|
|
5353
5384
|
}, null, 544)
|
|
5354
|
-
])]), u.value.length === 0 ? (g(), i("p",
|
|
5385
|
+
])]), u.value.length === 0 ? (g(), i("p", Do, [...l[6] ||= [
|
|
5355
5386
|
s(" Built-in units (", -1),
|
|
5356
5387
|
a("code", null, "second", -1),
|
|
5357
5388
|
s(", ", -1),
|
|
@@ -5359,14 +5390,14 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
|
|
|
5359
5390
|
s(", ", -1),
|
|
5360
5391
|
a("code", null, "volt", -1),
|
|
5361
5392
|
s(", …) are always available. Load CellML files for others; only their units are kept. ", -1)
|
|
5362
|
-
]])) : (g(), i("ul",
|
|
5393
|
+
]])) : (g(), i("ul", Oo, [(g(!0), i(e, null, v(u.value, (t) => (g(), i("li", {
|
|
5363
5394
|
key: t.name,
|
|
5364
5395
|
"data-file": t.name
|
|
5365
5396
|
}, [
|
|
5366
|
-
a("div",
|
|
5367
|
-
a("span",
|
|
5368
|
-
a("span",
|
|
5369
|
-
c(S(
|
|
5397
|
+
a("div", Ao, [
|
|
5398
|
+
a("span", jo, y(t.name), 1),
|
|
5399
|
+
a("span", Mo, y(m.value ? b(E(t.name).length, "units definition") : ""), 1),
|
|
5400
|
+
c(S(O), {
|
|
5370
5401
|
icon: "pi pi-times",
|
|
5371
5402
|
size: "small",
|
|
5372
5403
|
text: "",
|
|
@@ -5374,44 +5405,44 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
|
|
|
5374
5405
|
severity: "secondary",
|
|
5375
5406
|
"aria-label": `Remove ${t.name}`,
|
|
5376
5407
|
title: "Remove this file",
|
|
5377
|
-
onClick: (e) =>
|
|
5408
|
+
onClick: (e) => w(t.name)
|
|
5378
5409
|
}, null, 8, ["aria-label", "onClick"])
|
|
5379
5410
|
]),
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
], 8,
|
|
5383
|
-
a("section",
|
|
5384
|
-
a("div",
|
|
5411
|
+
E(t.name).length ? (g(), i("div", No, [(g(!0), i(e, null, v(E(t.name), (e) => (g(), i("code", { key: e }, y(e), 1))), 128))])) : r("", !0),
|
|
5412
|
+
oe(t.name).length ? (g(), i("ul", Po, [(g(!0), i(e, null, v(oe(t.name), (e, t) => (g(), i("li", { key: t }, y(e.message), 1))), 128))])) : r("", !0)
|
|
5413
|
+
], 8, ko))), 128))]))]),
|
|
5414
|
+
a("section", Fo, [
|
|
5415
|
+
a("div", Io, [l[7] ||= a("h3", { id: "units-new-title" }, "New units", -1), a("div", Lo, [ne(t.$slots, "new-units-actions", { definitions: f.value }, void 0, !0), c(S(O), {
|
|
5385
5416
|
icon: "pi pi-plus",
|
|
5386
5417
|
label: "Define units",
|
|
5387
5418
|
size: "small",
|
|
5388
5419
|
text: "",
|
|
5389
5420
|
"data-role": "define-units",
|
|
5390
|
-
disabled:
|
|
5421
|
+
disabled: D.value !== void 0,
|
|
5391
5422
|
title: "Define units of your own, kept in a file apart from the units files",
|
|
5392
|
-
onClick: l[1] ||= (e) =>
|
|
5423
|
+
onClick: l[1] ||= (e) => D.value = null
|
|
5393
5424
|
}, null, 8, ["disabled"])])]),
|
|
5394
|
-
f.value.length === 0 &&
|
|
5395
|
-
f.value.length ? (g(), i("ul",
|
|
5425
|
+
f.value.length === 0 && D.value === void 0 ? (g(), i("p", Ro, " Units you define are kept in a units file of their own, apart from the files loaded. ")) : r("", !0),
|
|
5426
|
+
f.value.length ? (g(), i("ul", zo, [(g(!0), i(e, null, v(f.value, (e, t) => (g(), i("li", {
|
|
5396
5427
|
key: e.name,
|
|
5397
5428
|
"data-units": e.name
|
|
5398
|
-
}, [
|
|
5429
|
+
}, [D.value === t ? (g(), n(vo, {
|
|
5399
5430
|
key: 0,
|
|
5400
5431
|
definition: e,
|
|
5401
|
-
others:
|
|
5402
|
-
known:
|
|
5403
|
-
choices:
|
|
5404
|
-
onSave:
|
|
5405
|
-
onCancel: l[2] ||= (e) =>
|
|
5432
|
+
others: le.value,
|
|
5433
|
+
known: ue.value,
|
|
5434
|
+
choices: de.value,
|
|
5435
|
+
onSave: pe,
|
|
5436
|
+
onCancel: l[2] ||= (e) => D.value = void 0
|
|
5406
5437
|
}, null, 8, [
|
|
5407
5438
|
"definition",
|
|
5408
5439
|
"others",
|
|
5409
5440
|
"known",
|
|
5410
5441
|
"choices"
|
|
5411
|
-
])) : (g(), i("div",
|
|
5412
|
-
a("code",
|
|
5413
|
-
a("span",
|
|
5414
|
-
c(S(
|
|
5442
|
+
])) : (g(), i("div", Vo, [
|
|
5443
|
+
a("code", Ho, y(e.name), 1),
|
|
5444
|
+
a("span", Uo, " = " + y(S(ro)(e)), 1),
|
|
5445
|
+
c(S(O), {
|
|
5415
5446
|
icon: "pi pi-pencil",
|
|
5416
5447
|
size: "small",
|
|
5417
5448
|
text: "",
|
|
@@ -5419,66 +5450,66 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
|
|
|
5419
5450
|
severity: "secondary",
|
|
5420
5451
|
"aria-label": `Change ${e.name}`,
|
|
5421
5452
|
title: "Change these units",
|
|
5422
|
-
disabled:
|
|
5423
|
-
onClick: (e) =>
|
|
5453
|
+
disabled: D.value !== void 0,
|
|
5454
|
+
onClick: (e) => D.value = t
|
|
5424
5455
|
}, null, 8, [
|
|
5425
5456
|
"aria-label",
|
|
5426
5457
|
"disabled",
|
|
5427
5458
|
"onClick"
|
|
5428
5459
|
]),
|
|
5429
|
-
c(S(
|
|
5460
|
+
c(S(O), {
|
|
5430
5461
|
icon: "pi pi-times",
|
|
5431
5462
|
size: "small",
|
|
5432
5463
|
text: "",
|
|
5433
5464
|
rounded: "",
|
|
5434
5465
|
severity: "secondary",
|
|
5435
5466
|
"aria-label": `Remove ${e.name}`,
|
|
5436
|
-
title: S(
|
|
5437
|
-
disabled:
|
|
5438
|
-
onClick: (e) =>
|
|
5467
|
+
title: S(no)(e.name, f.value).length ? `Used by ${S(no)(e.name, f.value).join(", ")}` : "Remove these units",
|
|
5468
|
+
disabled: D.value !== void 0 || S(no)(e.name, f.value).length > 0,
|
|
5469
|
+
onClick: (e) => me(t)
|
|
5439
5470
|
}, null, 8, [
|
|
5440
5471
|
"aria-label",
|
|
5441
5472
|
"title",
|
|
5442
5473
|
"disabled",
|
|
5443
5474
|
"onClick"
|
|
5444
5475
|
])
|
|
5445
|
-
]))], 8,
|
|
5446
|
-
|
|
5476
|
+
]))], 8, Bo))), 128))])) : r("", !0),
|
|
5477
|
+
D.value === null ? (g(), n(vo, {
|
|
5447
5478
|
key: 2,
|
|
5448
|
-
others:
|
|
5449
|
-
known:
|
|
5450
|
-
choices:
|
|
5451
|
-
onSave:
|
|
5452
|
-
onCancel: l[3] ||= (e) =>
|
|
5479
|
+
others: le.value,
|
|
5480
|
+
known: ue.value,
|
|
5481
|
+
choices: de.value,
|
|
5482
|
+
onSave: pe,
|
|
5483
|
+
onCancel: l[3] ||= (e) => D.value = void 0
|
|
5453
5484
|
}, null, 8, [
|
|
5454
5485
|
"others",
|
|
5455
5486
|
"known",
|
|
5456
5487
|
"choices"
|
|
5457
5488
|
])) : r("", !0),
|
|
5458
|
-
|
|
5489
|
+
fe.value.length ? (g(), i("ul", Wo, [(g(!0), i(e, null, v(fe.value, (e, t) => (g(), i("li", { key: t }, y(e.message), 1))), 128))])) : r("", !0)
|
|
5459
5490
|
]),
|
|
5460
|
-
a("section",
|
|
5461
|
-
a("div",
|
|
5462
|
-
ee.value.length === 0 ? (g(), i("p",
|
|
5491
|
+
a("section", Go, [
|
|
5492
|
+
a("div", Ko, [l[8] ||= a("h3", { id: "units-variables-title" }, "Variables", -1), te.value ? (g(), i("span", qo, y(b(te.value, "variable")) + " without units ", 1)) : r("", !0)]),
|
|
5493
|
+
ee.value.length === 0 ? (g(), i("p", Jo, " The variables in your equations are listed here, to give each one its units. ")) : (g(), i("table", Yo, [a("tbody", null, [(g(!0), i(e, null, v(ee.value, (t) => (g(), i("tr", {
|
|
5463
5494
|
key: t.name,
|
|
5464
5495
|
class: p([`state-${t.state}`, { unused: !t.used }]),
|
|
5465
5496
|
"data-variable": t.name,
|
|
5466
5497
|
"data-state": t.state
|
|
5467
5498
|
}, [
|
|
5468
|
-
a("th",
|
|
5499
|
+
a("th", Zo, y(t.name), 1),
|
|
5469
5500
|
a("td", null, [a("input", {
|
|
5470
5501
|
class: "units-input",
|
|
5471
5502
|
type: "text",
|
|
5472
5503
|
value: t.units,
|
|
5473
|
-
list: S(
|
|
5504
|
+
list: S(he),
|
|
5474
5505
|
placeholder: "units",
|
|
5475
5506
|
spellcheck: "false",
|
|
5476
5507
|
autocomplete: "off",
|
|
5477
5508
|
"aria-label": `Units of ${t.name}`,
|
|
5478
5509
|
"aria-invalid": t.state !== "ok",
|
|
5479
|
-
onChange: (e) =>
|
|
5480
|
-
}, null, 40,
|
|
5481
|
-
a("td",
|
|
5510
|
+
onChange: (e) => _e(t.name, e)
|
|
5511
|
+
}, null, 40, Qo)]),
|
|
5512
|
+
a("td", $o, [t.used ? (g(), i(e, { key: 0 }, [s(y(k[t.state]), 1)], 64)) : (g(), i(e, { key: 1 }, [l[9] ||= s(" not used ", -1), c(S(O), {
|
|
5482
5513
|
icon: "pi pi-times",
|
|
5483
5514
|
size: "small",
|
|
5484
5515
|
text: "",
|
|
@@ -5486,13 +5517,13 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
|
|
|
5486
5517
|
severity: "secondary",
|
|
5487
5518
|
"aria-label": `Forget the units of ${t.name}`,
|
|
5488
5519
|
title: "Forget these units",
|
|
5489
|
-
onClick: (e) => d.value = S(
|
|
5520
|
+
onClick: (e) => d.value = S(bo)(d.value, t.name, "")
|
|
5490
5521
|
}, null, 8, ["aria-label", "onClick"])], 64))])
|
|
5491
|
-
], 10,
|
|
5492
|
-
a("datalist", { id: S(
|
|
5522
|
+
], 10, Xo))), 128))])])),
|
|
5523
|
+
a("datalist", { id: S(he) }, [(g(!0), i(e, null, v(o.unitsNames, (e) => (g(), i("option", {
|
|
5493
5524
|
key: e,
|
|
5494
5525
|
value: e
|
|
5495
|
-
}, null, 8,
|
|
5526
|
+
}, null, 8, ts))), 128))], 8, es)
|
|
5496
5527
|
])
|
|
5497
5528
|
]),
|
|
5498
5529
|
_: 3
|
|
@@ -5501,7 +5532,7 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
|
|
|
5501
5532
|
}), [["__scopeId", "data-v-ada663af"]]);
|
|
5502
5533
|
//#endregion
|
|
5503
5534
|
//#region src/units/libcellml.ts
|
|
5504
|
-
function
|
|
5535
|
+
function rs(e) {
|
|
5505
5536
|
let t = [];
|
|
5506
5537
|
for (let n = 0; n < e.issueCount(); n++) {
|
|
5507
5538
|
let r = e.issue(n), i = r.level(), a = r.referenceRule();
|
|
@@ -5509,14 +5540,14 @@ function as(e) {
|
|
|
5509
5540
|
message: r.description(),
|
|
5510
5541
|
level: i.value,
|
|
5511
5542
|
rule: a?.value ?? -1
|
|
5512
|
-
}),
|
|
5543
|
+
}), is(i), a && is(a), r.delete();
|
|
5513
5544
|
}
|
|
5514
5545
|
return t;
|
|
5515
5546
|
}
|
|
5516
|
-
function
|
|
5547
|
+
function is(e) {
|
|
5517
5548
|
e.delete?.();
|
|
5518
5549
|
}
|
|
5519
|
-
var
|
|
5550
|
+
var as = class {
|
|
5520
5551
|
held = [];
|
|
5521
5552
|
track(e) {
|
|
5522
5553
|
return e && this.held.push(e), e;
|
|
@@ -5525,16 +5556,16 @@ var ss = class {
|
|
|
5525
5556
|
for (let e of this.held.splice(0).reverse()) e.delete();
|
|
5526
5557
|
}
|
|
5527
5558
|
};
|
|
5528
|
-
function
|
|
5559
|
+
function os(e) {
|
|
5529
5560
|
return Object.keys(e.Units.StandardUnit).filter((e) => /^[A-Z_]+$/.test(e)).map((e) => e.toLowerCase());
|
|
5530
5561
|
}
|
|
5531
5562
|
//#endregion
|
|
5532
5563
|
//#region src/units/messages.ts
|
|
5533
|
-
var
|
|
5534
|
-
function
|
|
5564
|
+
var ss = /'([^']+)' is (?:in )?'([^']+)'(?: \(i\.e\. '[^']*'\))?/g;
|
|
5565
|
+
function cs(e) {
|
|
5535
5566
|
let t = /^The units in '([^']+)'.* are not equivalent\. (.*)$/s.exec(e), n = /^The unit of '[^']+' in '([^']+)'.* is not dimensionless\. (.*)$/s.exec(e), r = t ?? n;
|
|
5536
5567
|
if (!r) return null;
|
|
5537
|
-
let i = [...r[2].matchAll(
|
|
5568
|
+
let i = [...r[2].matchAll(ss)].map(([, e, t]) => ({
|
|
5538
5569
|
text: e,
|
|
5539
5570
|
units: t
|
|
5540
5571
|
}));
|
|
@@ -5544,27 +5575,27 @@ function us(e) {
|
|
|
5544
5575
|
operands: i
|
|
5545
5576
|
};
|
|
5546
5577
|
}
|
|
5547
|
-
function
|
|
5578
|
+
function ls(e) {
|
|
5548
5579
|
let [t, n] = e.operands;
|
|
5549
|
-
return e.kind === "notDimensionless" ? `${t.text} in ${e.expression} must be dimensionless, but is in ${t.units}` : n && t.units === n.units ? `The parts of ${n.text} have different units` : n ? `Units don't match in ${e.expression}: ${
|
|
5580
|
+
return e.kind === "notDimensionless" ? `${t.text} in ${e.expression} must be dimensionless, but is in ${t.units}` : n && t.units === n.units ? `The parts of ${n.text} have different units` : n ? `Units don't match in ${e.expression}: ${us(t)}, ${us(n)}` : `Units don't match in ${e.expression}`;
|
|
5550
5581
|
}
|
|
5551
|
-
var
|
|
5552
|
-
function
|
|
5582
|
+
var us = (e) => e.units === "dimensionless" ? `${e.text} is dimensionless` : `${e.text} is in ${e.units}`, ds = /[A-Za-z_][A-Za-z0-9_]*/g, fs = /\bd(?:\^\d+)?([A-Za-z_][A-Za-z0-9_]*)\/d([A-Za-z_][A-Za-z0-9_]*)(?:\^\d+)?/g, ps = /(?<![A-Za-z_0-9.])\d+(?:\.\d*)?(?:e[+-]?\d+)?/g;
|
|
5583
|
+
function ms(e, t) {
|
|
5553
5584
|
let n = /* @__PURE__ */ new Set(), r = (e) => {
|
|
5554
5585
|
t.includes(e) && n.add(e);
|
|
5555
|
-
}, i = e.replace(
|
|
5556
|
-
for (let [e] of i.replace(
|
|
5586
|
+
}, i = e.replace(fs, (e, n, i) => t.includes(`d${n}`) || t.includes(`d${i}`) ? e : (r(n), r(i), " "));
|
|
5587
|
+
for (let [e] of i.replace(ps, " ").matchAll(ds)) r(e);
|
|
5557
5588
|
return [...n];
|
|
5558
5589
|
}
|
|
5559
|
-
function
|
|
5560
|
-
return [...e.matchAll(
|
|
5590
|
+
function hs(e) {
|
|
5591
|
+
return [...e.matchAll(ps)].map(([e]) => Number(e));
|
|
5561
5592
|
}
|
|
5562
5593
|
//#endregion
|
|
5563
5594
|
//#region src/units/check.ts
|
|
5564
|
-
function
|
|
5595
|
+
function gs(e, t) {
|
|
5565
5596
|
return e.variables.filter((e) => !t[e]);
|
|
5566
5597
|
}
|
|
5567
|
-
var
|
|
5598
|
+
var _s = 500, vs = class {
|
|
5568
5599
|
lc;
|
|
5569
5600
|
library;
|
|
5570
5601
|
cache = /* @__PURE__ */ new Map();
|
|
@@ -5581,7 +5612,7 @@ var ys = 500, bs = class {
|
|
|
5581
5612
|
})) : [];
|
|
5582
5613
|
}
|
|
5583
5614
|
prechecked(e, t) {
|
|
5584
|
-
let n =
|
|
5615
|
+
let n = gs(e, t).map((e) => ({
|
|
5585
5616
|
message: `${e} has no units`,
|
|
5586
5617
|
variables: [e]
|
|
5587
5618
|
})), r = [.../* @__PURE__ */ new Set([...e.variables.map((e) => t[e]), ...e.units])].filter((e) => e && !this.library.isKnown(e)).map((n) => ({
|
|
@@ -5595,10 +5626,10 @@ var ys = 500, bs = class {
|
|
|
5595
5626
|
let n = `${e.mathml}\n${e.variables.map((e) => `${e}:${t[e]}`).join(" ")}`, r = this.cache.get(n);
|
|
5596
5627
|
if (r) return r;
|
|
5597
5628
|
let i = this.analyse(e, t);
|
|
5598
|
-
return this.cache.size >=
|
|
5629
|
+
return this.cache.size >= _s && this.cache.delete(this.cache.keys().next().value), this.cache.set(n, i), i;
|
|
5599
5630
|
}
|
|
5600
5631
|
analyse(e, t) {
|
|
5601
|
-
let { lc: n } = this, r = new
|
|
5632
|
+
let { lc: n } = this, r = new as();
|
|
5602
5633
|
try {
|
|
5603
5634
|
let i = r.track(new n.Model());
|
|
5604
5635
|
i.setName("units_check"), this.library.addTo(i, [...e.variables.map((e) => t[e]), ...e.units], r);
|
|
@@ -5611,12 +5642,12 @@ var ys = 500, bs = class {
|
|
|
5611
5642
|
a.setMath(e.mathml), i.addComponent(a), i.linkUnits();
|
|
5612
5643
|
let o = r.track(new n.Validator());
|
|
5613
5644
|
o.validateModel(i);
|
|
5614
|
-
let s =
|
|
5615
|
-
if (s.length) return s.map((e) => ({ message: `libCellML: ${
|
|
5645
|
+
let s = rs(o).filter((e) => e.level === 0);
|
|
5646
|
+
if (s.length) return s.map((e) => ({ message: `libCellML: ${bs(e.message)}` }));
|
|
5616
5647
|
let c = r.track(new n.Analyser());
|
|
5617
5648
|
c.analyseModel(i);
|
|
5618
|
-
let l =
|
|
5619
|
-
return [...new Set(l)].map((t) =>
|
|
5649
|
+
let l = rs(c).filter((e) => e.rule === 112).map((e) => e.message);
|
|
5650
|
+
return [...new Set(l)].map((t) => ys(t, e.variables));
|
|
5620
5651
|
} finally {
|
|
5621
5652
|
r.dispose();
|
|
5622
5653
|
}
|
|
@@ -5625,36 +5656,36 @@ var ys = 500, bs = class {
|
|
|
5625
5656
|
this.cache.clear();
|
|
5626
5657
|
}
|
|
5627
5658
|
};
|
|
5628
|
-
function
|
|
5629
|
-
let n =
|
|
5630
|
-
if (!n) return { message:
|
|
5659
|
+
function ys(e, t) {
|
|
5660
|
+
let n = cs(e);
|
|
5661
|
+
if (!n) return { message: bs(e) };
|
|
5631
5662
|
let r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
|
|
5632
5663
|
for (let e of n.operands) {
|
|
5633
|
-
let n =
|
|
5664
|
+
let n = ms(e.text, t);
|
|
5634
5665
|
for (let e of n) r.add(e);
|
|
5635
|
-
if (n.length === 0) for (let t of
|
|
5666
|
+
if (n.length === 0) for (let t of hs(e.text)) i.add(t);
|
|
5636
5667
|
}
|
|
5637
5668
|
return {
|
|
5638
|
-
message:
|
|
5669
|
+
message: ls(n),
|
|
5639
5670
|
...r.size ? { variables: [...r] } : {},
|
|
5640
5671
|
...i.size ? { numbers: [...i] } : {}
|
|
5641
5672
|
};
|
|
5642
5673
|
}
|
|
5643
|
-
function
|
|
5674
|
+
function bs(e) {
|
|
5644
5675
|
return e.replace(/ in component 'equation'/g, "").replace(/ in model 'units_check'/g, "");
|
|
5645
5676
|
}
|
|
5646
5677
|
//#endregion
|
|
5647
5678
|
//#region src/units/library.ts
|
|
5648
|
-
var
|
|
5679
|
+
var xs = class e {
|
|
5649
5680
|
lc;
|
|
5650
5681
|
names;
|
|
5651
5682
|
sources;
|
|
5652
5683
|
problems;
|
|
5653
5684
|
standard;
|
|
5654
5685
|
defined = /* @__PURE__ */ new Map();
|
|
5655
|
-
handles = new
|
|
5686
|
+
handles = new as();
|
|
5656
5687
|
constructor(e, t) {
|
|
5657
|
-
this.lc = e, this.standard = new Set(
|
|
5688
|
+
this.lc = e, this.standard = new Set(os(e));
|
|
5658
5689
|
let n = [], r = [], i = /* @__PURE__ */ new Map();
|
|
5659
5690
|
for (let e of t) {
|
|
5660
5691
|
let t = [];
|
|
@@ -5710,7 +5741,7 @@ var Cs = class e {
|
|
|
5710
5741
|
let n = new this.lc.Parser(!1);
|
|
5711
5742
|
try {
|
|
5712
5743
|
let r = this.handles.track(n.parseModel(e.text));
|
|
5713
|
-
for (let r of
|
|
5744
|
+
for (let r of rs(n)) r.level === 0 && t.push({
|
|
5714
5745
|
source: e.name,
|
|
5715
5746
|
message: r.message
|
|
5716
5747
|
});
|
|
@@ -5719,22 +5750,22 @@ var Cs = class e {
|
|
|
5719
5750
|
n.delete();
|
|
5720
5751
|
}
|
|
5721
5752
|
}
|
|
5722
|
-
},
|
|
5723
|
-
function
|
|
5724
|
-
let n = e.libcellml === void 0 ? u(
|
|
5753
|
+
}, Ss = "$libcellml";
|
|
5754
|
+
function Cs(e) {
|
|
5755
|
+
let n = e.libcellml === void 0 ? u(Ss, null) : e.libcellml, r = e.delay ?? 300, i = t(() => x(e.enabled) ?? !0), a = t(() => ws(n)), o = t(() => n !== null), s = t(() => a.value !== null), c = t(() => s.value ? "ready" : o.value ? "loading" : "unavailable"), l = re(null), d = re([]), f = null, p, m = () => {
|
|
5725
5756
|
clearTimeout(p), p = void 0, d.value = f && i.value ? f.check(x(e.lines), x(e.variableUnits)) : [];
|
|
5726
5757
|
}, ee = () => {
|
|
5727
5758
|
f?.dispose(), l.value?.dispose(), f = null, l.value = null;
|
|
5728
5759
|
}, te = t(() => {
|
|
5729
5760
|
let t = x(e.newUnits) ?? [];
|
|
5730
|
-
return t.length ?
|
|
5761
|
+
return t.length ? ao(t) : "";
|
|
5731
5762
|
});
|
|
5732
|
-
return
|
|
5733
|
-
name:
|
|
5763
|
+
return oe([a, () => [...x(e.sources), ...te.value ? [{
|
|
5764
|
+
name: Za,
|
|
5734
5765
|
text: te.value
|
|
5735
5766
|
}] : []]], ([e, t]) => {
|
|
5736
|
-
ee(), e && (l.value =
|
|
5737
|
-
}, { immediate: !0 }),
|
|
5767
|
+
ee(), e && (l.value = xs.load(e, t), f = new vs(e, l.value)), m();
|
|
5768
|
+
}, { immediate: !0 }), oe(i, () => m()), oe([() => x(e.lines), () => x(e.variableUnits)], () => {
|
|
5738
5769
|
clearTimeout(p), p = setTimeout(m, r);
|
|
5739
5770
|
}), h(() => {
|
|
5740
5771
|
clearTimeout(p), ee();
|
|
@@ -5747,16 +5778,16 @@ function Ts(e) {
|
|
|
5747
5778
|
files: t(() => l.value?.sources ?? []),
|
|
5748
5779
|
problems: t(() => l.value?.problems ?? []),
|
|
5749
5780
|
newUnitsFile: te,
|
|
5750
|
-
unitsNames: t(() => a.value && l.value ? [...
|
|
5781
|
+
unitsNames: t(() => a.value && l.value ? [...os(a.value), ...l.value.names] : []),
|
|
5751
5782
|
missing: t(() => {
|
|
5752
5783
|
let t = x(e.variableUnits);
|
|
5753
|
-
return [...new Set(x(e.lines).flatMap((e) =>
|
|
5784
|
+
return [...new Set(x(e.lines).flatMap((e) => gs(e, t)))];
|
|
5754
5785
|
}),
|
|
5755
5786
|
check: m
|
|
5756
5787
|
};
|
|
5757
5788
|
}
|
|
5758
|
-
function
|
|
5789
|
+
function ws(e) {
|
|
5759
5790
|
return e ? "Parser" in e ? b(e) : e.status === "ready" && e.library ? b(e.library) : null : null;
|
|
5760
5791
|
}
|
|
5761
5792
|
//#endregion
|
|
5762
|
-
export {
|
|
5793
|
+
export { Xa as EquationWorkbench, Ss as LIBCELLML_KEY, ns as UnitsPanel, Si as importContentMathML, Cs as useUnitsChecker };
|