vue3-math-editor 0.2.2 → 0.2.3
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/vue3-math-editor.js +436 -433
- package/package.json +1 -1
package/dist/vue3-math-editor.js
CHANGED
|
@@ -2045,10 +2045,13 @@ function Cr(e) {
|
|
|
2045
2045
|
return e?.kind === "symbol" && Sr.has(e.value);
|
|
2046
2046
|
}
|
|
2047
2047
|
function wr(e) {
|
|
2048
|
+
return !e || Cr(e) ? !1 : e.kind !== "symbol" || !Ct(e.value);
|
|
2049
|
+
}
|
|
2050
|
+
function Tr(e) {
|
|
2048
2051
|
let t = k(e);
|
|
2049
2052
|
return t.length > 0 && t.every(([, e]) => e.length === 0);
|
|
2050
2053
|
}
|
|
2051
|
-
function
|
|
2054
|
+
function Er(e, t = e.cursor.path.length) {
|
|
2052
2055
|
if (t === 0) return null;
|
|
2053
2056
|
let n = e.cursor.path, r = n.slice(0, t - 1), { atom: i, branch: a } = n[t - 1];
|
|
2054
2057
|
return {
|
|
@@ -2058,7 +2061,7 @@ function Tr(e, t = e.cursor.path.length) {
|
|
|
2058
2061
|
branch: a
|
|
2059
2062
|
};
|
|
2060
2063
|
}
|
|
2061
|
-
function
|
|
2064
|
+
function Dr(e, t, n) {
|
|
2062
2065
|
if (t.atom.kind === "piecewise" || t.atom.kind === "units") {
|
|
2063
2066
|
let r = n === 0 ? t.index : t.index + 1;
|
|
2064
2067
|
return {
|
|
@@ -2075,18 +2078,18 @@ function Er(e, t, n) {
|
|
|
2075
2078
|
offset: t.index + n
|
|
2076
2079
|
});
|
|
2077
2080
|
}
|
|
2078
|
-
function
|
|
2081
|
+
function Or(e) {
|
|
2079
2082
|
for (let t = e.cursor.path.length; t > 0; t--) {
|
|
2080
|
-
let n =
|
|
2083
|
+
let n = Er(e, t);
|
|
2081
2084
|
if (n?.atom.kind === "piecewise") return n;
|
|
2082
2085
|
}
|
|
2083
2086
|
return null;
|
|
2084
2087
|
}
|
|
2085
|
-
var
|
|
2088
|
+
var kr = (e, t) => [...e.rowPath, {
|
|
2086
2089
|
atom: e.index,
|
|
2087
2090
|
branch: t
|
|
2088
|
-
}],
|
|
2089
|
-
let t =
|
|
2091
|
+
}], Ar = (e) => e.value.length === 0 && e.condition.length === 0, jr = (e) => {
|
|
2092
|
+
let t = Or(e);
|
|
2090
2093
|
if (!t) return e;
|
|
2091
2094
|
let n = A(t.branch), { pieces: r } = t.atom, i = n.part === "otherwise" ? r.length : n.piece + 1, a = {
|
|
2092
2095
|
...t.atom,
|
|
@@ -2100,13 +2103,13 @@ var Or = (e, t) => [...e.rowPath, {
|
|
|
2100
2103
|
]
|
|
2101
2104
|
};
|
|
2102
2105
|
return q(e, t.rowPath, t.index, 1, [a], {
|
|
2103
|
-
path:
|
|
2106
|
+
path: kr(t, `value${i}`),
|
|
2104
2107
|
offset: 0
|
|
2105
2108
|
});
|
|
2106
|
-
},
|
|
2107
|
-
let t =
|
|
2109
|
+
}, Mr = (e) => {
|
|
2110
|
+
let t = Or(e);
|
|
2108
2111
|
if (!t) return e;
|
|
2109
|
-
let n =
|
|
2112
|
+
let n = kr(t, "otherwise");
|
|
2110
2113
|
if (t.atom.otherwise) return {
|
|
2111
2114
|
root: e.root,
|
|
2112
2115
|
cursor: {
|
|
@@ -2129,7 +2132,7 @@ var Or = (e, t) => [...e.rowPath, {
|
|
|
2129
2132
|
}
|
|
2130
2133
|
};
|
|
2131
2134
|
};
|
|
2132
|
-
function
|
|
2135
|
+
function Nr(e, t) {
|
|
2133
2136
|
let n = A(t.branch), { pieces: r, otherwise: i } = t.atom;
|
|
2134
2137
|
if (n.part === "otherwise") {
|
|
2135
2138
|
if (!i || i.length > 0) return null;
|
|
@@ -2138,24 +2141,24 @@ function Mr(e, t) {
|
|
|
2138
2141
|
...t.atom,
|
|
2139
2142
|
otherwise: null
|
|
2140
2143
|
}], {
|
|
2141
|
-
path:
|
|
2144
|
+
path: kr(t, `cond${n}`),
|
|
2142
2145
|
offset: r[n].condition.length
|
|
2143
2146
|
});
|
|
2144
2147
|
}
|
|
2145
|
-
if (n.part !== "value" || r.length < 2 || !
|
|
2148
|
+
if (n.part !== "value" || r.length < 2 || !Ar(r[n.piece])) return null;
|
|
2146
2149
|
let a = {
|
|
2147
2150
|
...t.atom,
|
|
2148
2151
|
pieces: r.filter((e, t) => t !== n.piece)
|
|
2149
2152
|
}, o = n.piece > 0 ? {
|
|
2150
|
-
path:
|
|
2153
|
+
path: kr(t, `cond${n.piece - 1}`),
|
|
2151
2154
|
offset: r[n.piece - 1].condition.length
|
|
2152
2155
|
} : {
|
|
2153
|
-
path:
|
|
2156
|
+
path: kr(t, "value0"),
|
|
2154
2157
|
offset: 0
|
|
2155
2158
|
};
|
|
2156
2159
|
return q(e, t.rowPath, t.index, 1, [a], o);
|
|
2157
2160
|
}
|
|
2158
|
-
function
|
|
2161
|
+
function Pr(e, t) {
|
|
2159
2162
|
let n = A(t.branch), { pieces: r, otherwise: i } = t.atom;
|
|
2160
2163
|
if (n.part === "otherwise") return !i || i.length > 0 ? null : q(e, t.rowPath, t.index, 1, [{
|
|
2161
2164
|
...t.atom,
|
|
@@ -2164,15 +2167,15 @@ function Nr(e, t) {
|
|
|
2164
2167
|
path: t.rowPath,
|
|
2165
2168
|
offset: t.index + 1
|
|
2166
2169
|
});
|
|
2167
|
-
if (r.length < 2 || !
|
|
2170
|
+
if (r.length < 2 || !Ar(r[n.piece])) return null;
|
|
2168
2171
|
let a = {
|
|
2169
2172
|
...t.atom,
|
|
2170
2173
|
pieces: r.filter((e, t) => t !== n.piece)
|
|
2171
2174
|
}, o = n.piece < a.pieces.length ? {
|
|
2172
|
-
path:
|
|
2175
|
+
path: kr(t, `value${n.piece}`),
|
|
2173
2176
|
offset: 0
|
|
2174
2177
|
} : a.otherwise ? {
|
|
2175
|
-
path:
|
|
2178
|
+
path: kr(t, "otherwise"),
|
|
2176
2179
|
offset: 0
|
|
2177
2180
|
} : {
|
|
2178
2181
|
path: t.rowPath,
|
|
@@ -2180,7 +2183,7 @@ function Nr(e, t) {
|
|
|
2180
2183
|
};
|
|
2181
2184
|
return q(e, t.rowPath, t.index, 1, [a], o);
|
|
2182
2185
|
}
|
|
2183
|
-
function
|
|
2186
|
+
function Fr(e) {
|
|
2184
2187
|
let t = G(e);
|
|
2185
2188
|
return t ? q(e, t.path, t.start, t.end - t.start, [], {
|
|
2186
2189
|
path: t.path,
|
|
@@ -2190,15 +2193,15 @@ function Pr(e) {
|
|
|
2190
2193
|
cursor: e.cursor
|
|
2191
2194
|
} : e;
|
|
2192
2195
|
}
|
|
2193
|
-
function
|
|
2196
|
+
function Ir(e) {
|
|
2194
2197
|
let t = e[0];
|
|
2195
2198
|
return e.length === 1 && t.kind === "group" && t.open === "(" ? t.body : e;
|
|
2196
2199
|
}
|
|
2197
|
-
function
|
|
2200
|
+
function Lr(e, t, n) {
|
|
2198
2201
|
return (r) => {
|
|
2199
2202
|
let i = G(r);
|
|
2200
2203
|
if (!i) {
|
|
2201
|
-
let t =
|
|
2204
|
+
let t = Fr(r), { path: i, offset: a } = t.cursor;
|
|
2202
2205
|
return q(t, i, a, 0, [e([])], {
|
|
2203
2206
|
path: [...i, {
|
|
2204
2207
|
atom: a,
|
|
@@ -2220,12 +2223,12 @@ function Ir(e, t, n) {
|
|
|
2220
2223
|
return q(r, a, o, s - o, [e(c)], l);
|
|
2221
2224
|
};
|
|
2222
2225
|
}
|
|
2223
|
-
function
|
|
2226
|
+
function Rr(e) {
|
|
2224
2227
|
return Be(e)?.latexName ?? e;
|
|
2225
2228
|
}
|
|
2226
|
-
function
|
|
2229
|
+
function zr(e) {
|
|
2227
2230
|
return (t) => {
|
|
2228
|
-
let n =
|
|
2231
|
+
let n = Fr(t);
|
|
2229
2232
|
if (e.length === 0) return n;
|
|
2230
2233
|
let { path: r, offset: i } = n.cursor;
|
|
2231
2234
|
return q(n, r, i, 0, e, {
|
|
@@ -2236,14 +2239,14 @@ function Rr(e) {
|
|
|
2236
2239
|
}
|
|
2237
2240
|
function J(e) {
|
|
2238
2241
|
return (t) => {
|
|
2239
|
-
let n =
|
|
2242
|
+
let n = Fr(t), { path: r, offset: i } = n.cursor;
|
|
2240
2243
|
return q(n, r, i, 0, [P(e)], {
|
|
2241
2244
|
path: r,
|
|
2242
2245
|
offset: i + 1
|
|
2243
2246
|
});
|
|
2244
2247
|
};
|
|
2245
2248
|
}
|
|
2246
|
-
var
|
|
2249
|
+
var Br = (e) => {
|
|
2247
2250
|
if (!G(e)) {
|
|
2248
2251
|
let { path: t, offset: n } = e.cursor, r = K(e.root, t)[n - 1], i = r?.kind === "symbol" ? Dt(r.value) : void 0;
|
|
2249
2252
|
if (i) return q({
|
|
@@ -2255,7 +2258,7 @@ var zr = (e) => {
|
|
|
2255
2258
|
});
|
|
2256
2259
|
}
|
|
2257
2260
|
return J("=")(e);
|
|
2258
|
-
},
|
|
2261
|
+
}, Vr = (e) => {
|
|
2259
2262
|
let t = G(e);
|
|
2260
2263
|
if (t) {
|
|
2261
2264
|
let { path: n, start: r, end: i } = t, a = Te([[K(e.root, n).slice(r, i), []]], R("0.0"));
|
|
@@ -2267,11 +2270,11 @@ var zr = (e) => {
|
|
|
2267
2270
|
offset: 0
|
|
2268
2271
|
});
|
|
2269
2272
|
}
|
|
2270
|
-
return
|
|
2273
|
+
return Hr(Te([[[], []]], R("0.0")), "value0")(e);
|
|
2271
2274
|
};
|
|
2272
|
-
function
|
|
2275
|
+
function Hr(e, t) {
|
|
2273
2276
|
return (n) => {
|
|
2274
|
-
let r =
|
|
2277
|
+
let r = Fr(n), { path: i, offset: a } = r.cursor;
|
|
2275
2278
|
return q(r, i, a, 0, [e], {
|
|
2276
2279
|
path: [...i, {
|
|
2277
2280
|
atom: a,
|
|
@@ -2281,11 +2284,11 @@ function Vr(e, t) {
|
|
|
2281
2284
|
});
|
|
2282
2285
|
};
|
|
2283
2286
|
}
|
|
2284
|
-
var
|
|
2285
|
-
if (G(e)) return
|
|
2286
|
-
let t =
|
|
2287
|
+
var Ur = Lr((e) => xe(Ir(e), []), "den", "num"), Wr = (e) => {
|
|
2288
|
+
if (G(e)) return Ur(e);
|
|
2289
|
+
let t = Fr(e), { path: n, offset: r } = t.cursor, i = K(t.root, n), a = r;
|
|
2287
2290
|
for (; a > 0 && !Cr(i[a - 1]);) a--;
|
|
2288
|
-
let o =
|
|
2291
|
+
let o = Ir(i.slice(a, r)), s = o.length > 0 ? "den" : "num";
|
|
2289
2292
|
return q(t, n, a, r - a, [xe(o, [])], {
|
|
2290
2293
|
path: [...n, {
|
|
2291
2294
|
atom: a,
|
|
@@ -2293,7 +2296,7 @@ var Hr = Ir((e) => xe(Fr(e), []), "den", "num"), Ur = (e) => {
|
|
|
2293
2296
|
}],
|
|
2294
2297
|
offset: 0
|
|
2295
2298
|
});
|
|
2296
|
-
},
|
|
2299
|
+
}, Gr = (e) => {
|
|
2297
2300
|
let t = G(e);
|
|
2298
2301
|
if (t) {
|
|
2299
2302
|
let { path: n, start: r, end: i } = t, a = K(e.root, n).slice(r, i), o = a.length === 1 ? a : [L(a, "(")];
|
|
@@ -2305,7 +2308,7 @@ var Hr = Ir((e) => xe(Fr(e), []), "den", "num"), Ur = (e) => {
|
|
|
2305
2308
|
offset: 0
|
|
2306
2309
|
});
|
|
2307
2310
|
}
|
|
2308
|
-
let n =
|
|
2311
|
+
let n = Fr(e), { path: r, offset: i } = n.cursor, a = K(n.root, r), o = a[i], s = a[i - 1];
|
|
2309
2312
|
return o?.kind === "superscript" ? {
|
|
2310
2313
|
root: n.root,
|
|
2311
2314
|
cursor: {
|
|
@@ -2324,11 +2327,11 @@ var Hr = Ir((e) => xe(Fr(e), []), "den", "num"), Ur = (e) => {
|
|
|
2324
2327
|
}],
|
|
2325
2328
|
offset: s.sup.length
|
|
2326
2329
|
}
|
|
2327
|
-
} :
|
|
2330
|
+
} : wr(s) ? Hr(I(), "sup")(n) : e;
|
|
2328
2331
|
};
|
|
2329
|
-
function
|
|
2332
|
+
function Kr(e, t) {
|
|
2330
2333
|
for (let n = e.cursor.path.length; n > 0; n--) {
|
|
2331
|
-
let r =
|
|
2334
|
+
let r = Er(e, n);
|
|
2332
2335
|
if (r.atom.kind === "group" && t.includes(r.atom.open)) return {
|
|
2333
2336
|
owner: r,
|
|
2334
2337
|
depth: n
|
|
@@ -2336,9 +2339,9 @@ function Gr(e, t) {
|
|
|
2336
2339
|
}
|
|
2337
2340
|
return null;
|
|
2338
2341
|
}
|
|
2339
|
-
function
|
|
2342
|
+
function qr(e) {
|
|
2340
2343
|
return (t) => {
|
|
2341
|
-
let n = t.anchor ? _r(t, "end") : t, r =
|
|
2344
|
+
let n = t.anchor ? _r(t, "end") : t, r = Kr(n, e);
|
|
2342
2345
|
if (!r) return t;
|
|
2343
2346
|
let { owner: i, depth: a } = r, o = {
|
|
2344
2347
|
path: i.rowPath,
|
|
@@ -2355,7 +2358,7 @@ function Kr(e) {
|
|
|
2355
2358
|
return q(n, i.rowPath, i.index, 1, [l, ...s.slice(c)], o);
|
|
2356
2359
|
};
|
|
2357
2360
|
}
|
|
2358
|
-
var
|
|
2361
|
+
var Jr = (e) => Lr((t) => L(t, e), "after", "body"), Yr = (e) => {
|
|
2359
2362
|
if (!G(e)) {
|
|
2360
2363
|
let { path: t, offset: n } = e.cursor, r = ut(K(e.root, t), n);
|
|
2361
2364
|
if (r) return q(e, t, r.start, n - r.start, [L([], r.open)], {
|
|
@@ -2366,8 +2369,8 @@ var qr = (e) => Ir((t) => L(t, e), "after", "body"), Jr = (e) => {
|
|
|
2366
2369
|
offset: 0
|
|
2367
2370
|
});
|
|
2368
2371
|
}
|
|
2369
|
-
return
|
|
2370
|
-
},
|
|
2372
|
+
return Jr("(")(e);
|
|
2373
|
+
}, Xr = (e) => {
|
|
2371
2374
|
if (In(e.cursor)) return e;
|
|
2372
2375
|
let { path: t, offset: n } = e.cursor, r = K(e.root, t)[n - 1];
|
|
2373
2376
|
if (!G(e) && r?.kind === "units") {
|
|
@@ -2387,10 +2390,10 @@ var qr = (e) => Ir((t) => L(t, e), "after", "body"), Jr = (e) => {
|
|
|
2387
2390
|
} : null
|
|
2388
2391
|
};
|
|
2389
2392
|
}
|
|
2390
|
-
let i =
|
|
2391
|
-
return rt(K(i.root, i.cursor.path).slice(0, a)).find((e) => e.end === a) ?
|
|
2393
|
+
let i = Fr(e), a = i.cursor.offset;
|
|
2394
|
+
return rt(K(i.root, i.cursor.path).slice(0, a)).find((e) => e.end === a) ? Hr(we(), "units")(i) : e;
|
|
2392
2395
|
};
|
|
2393
|
-
function
|
|
2396
|
+
function Zr(e) {
|
|
2394
2397
|
return (t) => {
|
|
2395
2398
|
let { path: n, offset: r } = t.cursor, i = K(t.root, n);
|
|
2396
2399
|
return !G(t) && Fn(i[r - 1]) && Un(i, r - 1, e) ? q(t, n, r - 1, 0, [P(e)], {
|
|
@@ -2399,10 +2402,10 @@ function Xr(e) {
|
|
|
2399
2402
|
}) : J(e)(t);
|
|
2400
2403
|
};
|
|
2401
2404
|
}
|
|
2402
|
-
var
|
|
2405
|
+
var Qr = (e) => {
|
|
2403
2406
|
let t = e.anchor ? _r(e, "end") : e;
|
|
2404
2407
|
for (let e = t.cursor.path.length; e > 0; e--) {
|
|
2405
|
-
let n =
|
|
2408
|
+
let n = Er(t, e);
|
|
2406
2409
|
if (n.atom.kind === "units") return {
|
|
2407
2410
|
root: t.root,
|
|
2408
2411
|
cursor: {
|
|
@@ -2412,17 +2415,17 @@ var Zr = (e) => {
|
|
|
2412
2415
|
};
|
|
2413
2416
|
}
|
|
2414
2417
|
return e;
|
|
2415
|
-
},
|
|
2418
|
+
}, $r = Jr("⌊"), ei = Jr("⌈"), ti = qr([
|
|
2416
2419
|
"(",
|
|
2417
2420
|
"⌊",
|
|
2418
2421
|
"⌈"
|
|
2419
|
-
]),
|
|
2420
|
-
if (G(e)) return
|
|
2421
|
-
let t =
|
|
2422
|
-
return t?.atom.kind === "group" && t.atom.open === "|" ?
|
|
2423
|
-
},
|
|
2422
|
+
]), ni = (e) => {
|
|
2423
|
+
if (G(e)) return ui(e);
|
|
2424
|
+
let t = Er(e);
|
|
2425
|
+
return t?.atom.kind === "group" && t.atom.open === "|" ? qr(["|"])(e) : Hr(L([], "|"), "body")(e);
|
|
2426
|
+
}, ri = (e) => {
|
|
2424
2427
|
if (G(e)) return _r(e, "end");
|
|
2425
|
-
let t =
|
|
2428
|
+
let t = Er(e);
|
|
2426
2429
|
return t ? {
|
|
2427
2430
|
root: e.root,
|
|
2428
2431
|
cursor: {
|
|
@@ -2430,8 +2433,8 @@ var Zr = (e) => {
|
|
|
2430
2433
|
offset: t.index + 1
|
|
2431
2434
|
}
|
|
2432
2435
|
} : e;
|
|
2433
|
-
},
|
|
2434
|
-
if (G(e)) return
|
|
2436
|
+
}, ii = (e) => {
|
|
2437
|
+
if (G(e)) return Fr(e);
|
|
2435
2438
|
let { path: t, offset: n } = e.cursor, r = K(e.root, t);
|
|
2436
2439
|
if (n > 0) {
|
|
2437
2440
|
let i = r[n - 1], a = n - 1;
|
|
@@ -2450,13 +2453,13 @@ var Zr = (e) => {
|
|
|
2450
2453
|
offset: a
|
|
2451
2454
|
});
|
|
2452
2455
|
if (i.kind === "function") {
|
|
2453
|
-
let n = R(
|
|
2456
|
+
let n = R(Rr(i.name).slice(0, -1));
|
|
2454
2457
|
return q(e, t, a, 1, n, {
|
|
2455
2458
|
path: t,
|
|
2456
2459
|
offset: a + n.length
|
|
2457
2460
|
});
|
|
2458
2461
|
}
|
|
2459
|
-
if (
|
|
2462
|
+
if (Tr(i)) return q(e, t, a, 1, [], {
|
|
2460
2463
|
path: t,
|
|
2461
2464
|
offset: a
|
|
2462
2465
|
});
|
|
@@ -2472,13 +2475,13 @@ var Zr = (e) => {
|
|
|
2472
2475
|
}
|
|
2473
2476
|
};
|
|
2474
2477
|
}
|
|
2475
|
-
let i =
|
|
2478
|
+
let i = Er(e);
|
|
2476
2479
|
if (!i) return e;
|
|
2477
2480
|
if (i.atom.kind === "piecewise") {
|
|
2478
|
-
let t =
|
|
2481
|
+
let t = Nr(e, i);
|
|
2479
2482
|
if (t) return t;
|
|
2480
2483
|
}
|
|
2481
|
-
if (
|
|
2484
|
+
if (Tr(i.atom)) return q(e, i.rowPath, i.index, 1, [], {
|
|
2482
2485
|
path: i.rowPath,
|
|
2483
2486
|
offset: i.index
|
|
2484
2487
|
});
|
|
@@ -2496,9 +2499,9 @@ var Zr = (e) => {
|
|
|
2496
2499
|
}
|
|
2497
2500
|
};
|
|
2498
2501
|
}
|
|
2499
|
-
return
|
|
2500
|
-
},
|
|
2501
|
-
if (G(e)) return
|
|
2502
|
+
return Dr(e, i, 0);
|
|
2503
|
+
}, ai = (e) => {
|
|
2504
|
+
if (G(e)) return Fr(e);
|
|
2502
2505
|
let { path: t, offset: n } = e.cursor, r = K(e.root, t);
|
|
2503
2506
|
if (n < r.length) {
|
|
2504
2507
|
let i = r[n];
|
|
@@ -2506,11 +2509,11 @@ var Zr = (e) => {
|
|
|
2506
2509
|
path: t,
|
|
2507
2510
|
offset: n
|
|
2508
2511
|
});
|
|
2509
|
-
if (i.kind === "function") return q(e, t, n, 1, R(
|
|
2512
|
+
if (i.kind === "function") return q(e, t, n, 1, R(Rr(i.name).slice(1)), {
|
|
2510
2513
|
path: t,
|
|
2511
2514
|
offset: n
|
|
2512
2515
|
});
|
|
2513
|
-
if (
|
|
2516
|
+
if (Tr(i)) return q(e, t, n, 1, [], {
|
|
2514
2517
|
path: t,
|
|
2515
2518
|
offset: n
|
|
2516
2519
|
});
|
|
@@ -2526,13 +2529,13 @@ var Zr = (e) => {
|
|
|
2526
2529
|
}
|
|
2527
2530
|
};
|
|
2528
2531
|
}
|
|
2529
|
-
let i =
|
|
2532
|
+
let i = Er(e);
|
|
2530
2533
|
if (!i) return e;
|
|
2531
2534
|
if (i.atom.kind === "piecewise") {
|
|
2532
|
-
let t =
|
|
2535
|
+
let t = Pr(e, i);
|
|
2533
2536
|
if (t) return t;
|
|
2534
2537
|
}
|
|
2535
|
-
if (
|
|
2538
|
+
if (Tr(i.atom)) return q(e, i.rowPath, i.index, 1, [], {
|
|
2536
2539
|
path: i.rowPath,
|
|
2537
2540
|
offset: i.index
|
|
2538
2541
|
});
|
|
@@ -2550,9 +2553,9 @@ var Zr = (e) => {
|
|
|
2550
2553
|
}
|
|
2551
2554
|
};
|
|
2552
2555
|
}
|
|
2553
|
-
return
|
|
2556
|
+
return Dr(e, i, a.reduce((e, [, t]) => e + t.length, 0));
|
|
2554
2557
|
};
|
|
2555
|
-
function
|
|
2558
|
+
function oi(e) {
|
|
2556
2559
|
return (t) => {
|
|
2557
2560
|
let n = $n(t.root);
|
|
2558
2561
|
if (n.filter(({ path: e }) => K(t.root, e).length === 0).length === 0) return t;
|
|
@@ -2563,7 +2566,7 @@ function ai(e) {
|
|
|
2563
2566
|
};
|
|
2564
2567
|
};
|
|
2565
2568
|
}
|
|
2566
|
-
function
|
|
2569
|
+
function si(e) {
|
|
2567
2570
|
return (t) => {
|
|
2568
2571
|
let n = G(t);
|
|
2569
2572
|
if (n) {
|
|
@@ -2573,7 +2576,7 @@ function oi(e) {
|
|
|
2573
2576
|
offset: i + 2
|
|
2574
2577
|
});
|
|
2575
2578
|
}
|
|
2576
|
-
let r =
|
|
2579
|
+
let r = Fr(t), { path: i, offset: a } = r.cursor;
|
|
2577
2580
|
return q(r, i, a, 0, [F(e), L([], "(")], {
|
|
2578
2581
|
path: [...i, {
|
|
2579
2582
|
atom: a + 1,
|
|
@@ -2583,39 +2586,39 @@ function oi(e) {
|
|
|
2583
2586
|
});
|
|
2584
2587
|
};
|
|
2585
2588
|
}
|
|
2586
|
-
var
|
|
2587
|
-
function
|
|
2589
|
+
var ci = Lr((e) => Se(e), "after", "body"), li = Lr((e) => Se(e, []), "index", "index"), ui = Lr((e) => L(e, "|"), "after", "body"), di = Lr((e) => Ce(e, []), "variable", "expr");
|
|
2590
|
+
function fi(e) {
|
|
2588
2591
|
switch (e) {
|
|
2589
2592
|
case "frac":
|
|
2590
|
-
case "fraction": return
|
|
2591
|
-
case "sqrt": return
|
|
2592
|
-
case "root": return
|
|
2593
|
-
case "abs": return
|
|
2593
|
+
case "fraction": return Ur;
|
|
2594
|
+
case "sqrt": return ci;
|
|
2595
|
+
case "root": return li;
|
|
2596
|
+
case "abs": return ui;
|
|
2594
2597
|
case "dd":
|
|
2595
2598
|
case "diff":
|
|
2596
|
-
case "derivative": return
|
|
2599
|
+
case "derivative": return di;
|
|
2597
2600
|
case "pow":
|
|
2598
|
-
case "power": return
|
|
2601
|
+
case "power": return Gr;
|
|
2599
2602
|
case "cases":
|
|
2600
|
-
case "piecewise": return
|
|
2601
|
-
case "otherwise": return
|
|
2602
|
-
case "units": return
|
|
2603
|
+
case "piecewise": return Vr;
|
|
2604
|
+
case "otherwise": return Mr;
|
|
2605
|
+
case "units": return Xr;
|
|
2603
2606
|
case "floor":
|
|
2604
|
-
case "lfloor": return
|
|
2607
|
+
case "lfloor": return $r;
|
|
2605
2608
|
case "ceil":
|
|
2606
2609
|
case "ceiling":
|
|
2607
|
-
case "lceil": return
|
|
2610
|
+
case "lceil": return ei;
|
|
2608
2611
|
}
|
|
2609
2612
|
let t = Tt(e);
|
|
2610
2613
|
if (t) return J(t.symbol);
|
|
2611
2614
|
let n = ke(e);
|
|
2612
2615
|
if (n) return J(n.symbol);
|
|
2613
2616
|
let r = Je(e);
|
|
2614
|
-
return r ?
|
|
2617
|
+
return r ? si(r) : zr(Ke.has(e) ? [P(e)] : R(e));
|
|
2615
2618
|
}
|
|
2616
2619
|
//#endregion
|
|
2617
2620
|
//#region src/editor/history.ts
|
|
2618
|
-
var
|
|
2621
|
+
var pi = { kind: "other" }, mi = /* @__PURE__ */ new Set([
|
|
2619
2622
|
"+",
|
|
2620
2623
|
"-",
|
|
2621
2624
|
"=",
|
|
@@ -2631,11 +2634,11 @@ var fi = { kind: "other" }, pi = /* @__PURE__ */ new Set([
|
|
|
2631
2634
|
"⊻",
|
|
2632
2635
|
"¬"
|
|
2633
2636
|
]);
|
|
2634
|
-
function
|
|
2637
|
+
function hi(e, t) {
|
|
2635
2638
|
switch (t.kind) {
|
|
2636
2639
|
case "type": return {
|
|
2637
2640
|
key: `type:${e}`,
|
|
2638
|
-
fresh: !!t.replacedSelection ||
|
|
2641
|
+
fresh: !!t.replacedSelection || mi.has(t.text ?? "") && !t.exponentSign
|
|
2639
2642
|
};
|
|
2640
2643
|
case "deleteBackward":
|
|
2641
2644
|
case "deleteForward": return t.replacedSelection ? {
|
|
@@ -2651,7 +2654,7 @@ function mi(e, t) {
|
|
|
2651
2654
|
};
|
|
2652
2655
|
}
|
|
2653
2656
|
}
|
|
2654
|
-
var
|
|
2657
|
+
var gi = class {
|
|
2655
2658
|
undoStack = [];
|
|
2656
2659
|
redoStack = [];
|
|
2657
2660
|
openGroup = null;
|
|
@@ -2689,43 +2692,43 @@ var hi = class {
|
|
|
2689
2692
|
let t = this.redoStack.pop();
|
|
2690
2693
|
return t === void 0 ? null : (this.undoStack.push(e), this.breakGroup(), t);
|
|
2691
2694
|
}
|
|
2692
|
-
},
|
|
2693
|
-
function _i(e) {
|
|
2694
|
-
return gi.test(e.key) ? e.key : e.key in Ot ? Ot[e.key] : e.key === "*" ? "·" : null;
|
|
2695
|
-
}
|
|
2695
|
+
}, _i = /^[A-Za-z0-9_.+\-=,]$/;
|
|
2696
2696
|
function vi(e) {
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2697
|
+
return _i.test(e.key) ? e.key : e.key in Ot ? Ot[e.key] : e.key === "*" ? "·" : null;
|
|
2698
|
+
}
|
|
2699
|
+
function yi(e) {
|
|
2700
|
+
let { key: t } = e, n = vi(e);
|
|
2701
|
+
if (n === "=") return Br;
|
|
2702
|
+
if (n !== null) return Zr(n);
|
|
2700
2703
|
switch (t) {
|
|
2701
|
-
case "/": return
|
|
2702
|
-
case "^": return
|
|
2703
|
-
case "(": return
|
|
2704
|
-
case ")": return
|
|
2705
|
-
case "{": return
|
|
2706
|
-
case "}": return
|
|
2707
|
-
case "|": return
|
|
2708
|
-
case " ": return
|
|
2709
|
-
case "Backspace": return
|
|
2710
|
-
case "Delete": return
|
|
2711
|
-
case "Tab": return
|
|
2712
|
-
case "Enter": return e.shiftKey ? null :
|
|
2704
|
+
case "/": return Wr;
|
|
2705
|
+
case "^": return Gr;
|
|
2706
|
+
case "(": return Yr;
|
|
2707
|
+
case ")": return ti;
|
|
2708
|
+
case "{": return Xr;
|
|
2709
|
+
case "}": return Qr;
|
|
2710
|
+
case "|": return ni;
|
|
2711
|
+
case " ": return ri;
|
|
2712
|
+
case "Backspace": return ii;
|
|
2713
|
+
case "Delete": return ai;
|
|
2714
|
+
case "Tab": return oi(e.shiftKey ? "backward" : "forward");
|
|
2715
|
+
case "Enter": return e.shiftKey ? null : jr;
|
|
2713
2716
|
default: return null;
|
|
2714
2717
|
}
|
|
2715
2718
|
}
|
|
2716
2719
|
//#endregion
|
|
2717
2720
|
//#region src/editor/mathmlImport.ts
|
|
2718
|
-
var
|
|
2719
|
-
function
|
|
2721
|
+
var bi = "http://www.w3.org/1998/Math/MathML", xi = "http://www.cellml.org/cellml/2.0#";
|
|
2722
|
+
function Si(e) {
|
|
2720
2723
|
return /^\s*(<\?xml[^>]*\?>\s*)?(<!--[\s\S]*?-->\s*)*<([A-Za-z_][\w.-]*:)?(math|apply|piecewise|ci|cn)\b/.test(e);
|
|
2721
2724
|
}
|
|
2722
|
-
function
|
|
2723
|
-
let t = `<wrapper xmlns="${
|
|
2725
|
+
function Ci(e) {
|
|
2726
|
+
let t = `<wrapper xmlns="${bi}" xmlns:cellml="${xi}">${e.replace(/^\s*<\?xml[^>]*\?>/, "")}</wrapper>`, n = new DOMParser().parseFromString(t, "application/xml");
|
|
2724
2727
|
if (n.getElementsByTagName("parsererror").length > 0) return null;
|
|
2725
|
-
let r = n.documentElement, i =
|
|
2728
|
+
let r = n.documentElement, i = wi(r).filter((e) => e.localName === "math"), a = (i.length ? i.flatMap(wi) : wi(r)).map((e) => {
|
|
2726
2729
|
let t = /* @__PURE__ */ new Set();
|
|
2727
2730
|
return {
|
|
2728
|
-
row: new
|
|
2731
|
+
row: new Ai(t).expression(e).row,
|
|
2729
2732
|
problems: [...t]
|
|
2730
2733
|
};
|
|
2731
2734
|
});
|
|
@@ -2735,7 +2738,7 @@ function Si(e) {
|
|
|
2735
2738
|
lineProblems: a.map((e) => e.problems)
|
|
2736
2739
|
};
|
|
2737
2740
|
}
|
|
2738
|
-
var
|
|
2741
|
+
var wi = (e) => Array.from(e.children), Y = {
|
|
2739
2742
|
Or: 1,
|
|
2740
2743
|
Xor: 2,
|
|
2741
2744
|
And: 3,
|
|
@@ -2745,7 +2748,7 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2745
2748
|
Unary: 7,
|
|
2746
2749
|
Term: 8,
|
|
2747
2750
|
Primary: 9
|
|
2748
|
-
},
|
|
2751
|
+
}, Ti = {
|
|
2749
2752
|
or: {
|
|
2750
2753
|
symbol: "∨",
|
|
2751
2754
|
level: Y.Or
|
|
@@ -2758,7 +2761,7 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2758
2761
|
symbol: "∧",
|
|
2759
2762
|
level: Y.And
|
|
2760
2763
|
}
|
|
2761
|
-
},
|
|
2764
|
+
}, Ei = new Map(yt.filter((e) => e.role === "comparison").map((e) => [e.mathml, e.symbol])), Di = new Map(Ee.map((e) => [e.mathml, e.symbol])), Oi = new Map(Object.values(ze).map((e) => [e.mathMlTag, e.name])), ki = /^[A-Za-z_][A-Za-z0-9_]*$/, Ai = class {
|
|
2762
2765
|
problems;
|
|
2763
2766
|
constructor(e) {
|
|
2764
2767
|
this.problems = e;
|
|
@@ -2770,7 +2773,7 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2770
2773
|
case "apply": return this.apply(e);
|
|
2771
2774
|
case "piecewise": return this.piecewise(e);
|
|
2772
2775
|
default: {
|
|
2773
|
-
let t =
|
|
2776
|
+
let t = Di.get(e.localName);
|
|
2774
2777
|
return t ? X([P(t)]) : this.unsupported(`<${e.localName}>`);
|
|
2775
2778
|
}
|
|
2776
2779
|
}
|
|
@@ -2780,43 +2783,43 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2780
2783
|
}
|
|
2781
2784
|
identifier(e) {
|
|
2782
2785
|
let t = (e.textContent ?? "").trim();
|
|
2783
|
-
return t === "_" ? X([]) :
|
|
2786
|
+
return t === "_" ? X([]) : ki.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
2787
|
}
|
|
2785
2788
|
number(e) {
|
|
2786
|
-
let t =
|
|
2789
|
+
let t = Fi(e), n;
|
|
2787
2790
|
if (e.getAttribute("type") === "e-notation") {
|
|
2788
|
-
let t =
|
|
2791
|
+
let t = wi(e).find((e) => e.localName === "sep"), r = t ? Ii(e, t) : e.textContent ?? "", i = t ? Li(e, t) : "0";
|
|
2789
2792
|
n = `${r.trim()}e${i.trim()}`;
|
|
2790
2793
|
} else n = (e.textContent ?? "").trim();
|
|
2791
2794
|
let r = n.startsWith("-"), i = r ? n.slice(1) : n.replace(/^\+/, "");
|
|
2792
2795
|
/^(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(i) || this.problems.add(`"${n}" isn't a number`);
|
|
2793
2796
|
let a = R(i);
|
|
2794
|
-
return t && t !== "dimensionless" && (
|
|
2797
|
+
return t && t !== "dimensionless" && (ki.test(t) || this.problems.add(`"${t}" isn't a units name`), a.push(we(R(t)))), r ? {
|
|
2795
2798
|
row: [P("-"), ...a],
|
|
2796
2799
|
level: Y.Unary
|
|
2797
2800
|
} : X(a);
|
|
2798
2801
|
}
|
|
2799
2802
|
apply(e) {
|
|
2800
|
-
let [t, ...n] =
|
|
2803
|
+
let [t, ...n] = wi(e);
|
|
2801
2804
|
if (!t) return this.unsupported("An empty <apply>");
|
|
2802
|
-
let r = n.filter((e) =>
|
|
2803
|
-
if (o === "eq" ||
|
|
2805
|
+
let r = n.filter((e) => ji.has(e.localName)), i = n.filter((e) => !ji.has(e.localName)), a = () => i.map((e) => this.expression(e)), o = t.localName;
|
|
2806
|
+
if (o === "eq" || Ei.has(o)) {
|
|
2804
2807
|
let [e, t] = a();
|
|
2805
2808
|
if (!e || !t || i.length !== 2) return this.unsupported(`<${o}> without two operands`);
|
|
2806
|
-
let n = o === "eq" ? "=" :
|
|
2809
|
+
let n = o === "eq" ? "=" : Ei.get(o);
|
|
2807
2810
|
return {
|
|
2808
2811
|
row: [
|
|
2809
|
-
...
|
|
2812
|
+
...Ni(e, Y.Additive),
|
|
2810
2813
|
P(n),
|
|
2811
|
-
...
|
|
2814
|
+
...Ni(t, Y.Additive)
|
|
2812
2815
|
],
|
|
2813
2816
|
level: Y.Comparison
|
|
2814
2817
|
};
|
|
2815
2818
|
}
|
|
2816
|
-
if (
|
|
2817
|
-
let { symbol: e, level: t } =
|
|
2819
|
+
if (Ti[o]) {
|
|
2820
|
+
let { symbol: e, level: t } = Ti[o];
|
|
2818
2821
|
return {
|
|
2819
|
-
row:
|
|
2822
|
+
row: Pi(a(), e, t),
|
|
2820
2823
|
level: t
|
|
2821
2824
|
};
|
|
2822
2825
|
}
|
|
@@ -2824,33 +2827,33 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2824
2827
|
case "not": {
|
|
2825
2828
|
let [e] = a();
|
|
2826
2829
|
return e ? {
|
|
2827
|
-
row: [P("¬"), ...
|
|
2830
|
+
row: [P("¬"), ...Ni(e, Y.Not)],
|
|
2828
2831
|
level: Y.Not
|
|
2829
2832
|
} : this.unsupported("<not> without an operand");
|
|
2830
2833
|
}
|
|
2831
2834
|
case "plus": return {
|
|
2832
|
-
row:
|
|
2835
|
+
row: Pi(a(), "+", Y.Additive),
|
|
2833
2836
|
level: Y.Additive
|
|
2834
2837
|
};
|
|
2835
2838
|
case "minus": {
|
|
2836
2839
|
let e = a();
|
|
2837
2840
|
if (e.length === 1) return {
|
|
2838
|
-
row: [P("-"), ...
|
|
2841
|
+
row: [P("-"), ...Ni(e[0], Y.Term)],
|
|
2839
2842
|
level: Y.Unary
|
|
2840
2843
|
};
|
|
2841
2844
|
if (e.length !== 2) return this.unsupported("<minus> with more than two operands");
|
|
2842
2845
|
let [t, n] = e;
|
|
2843
2846
|
return {
|
|
2844
2847
|
row: [
|
|
2845
|
-
...
|
|
2848
|
+
...Ni(t, Y.Additive),
|
|
2846
2849
|
P("-"),
|
|
2847
|
-
...
|
|
2850
|
+
...Ni(n, Y.Term)
|
|
2848
2851
|
],
|
|
2849
2852
|
level: Y.Additive
|
|
2850
2853
|
};
|
|
2851
2854
|
}
|
|
2852
2855
|
case "times": return {
|
|
2853
|
-
row:
|
|
2856
|
+
row: Pi(a(), "·", Y.Term),
|
|
2854
2857
|
level: Y.Term
|
|
2855
2858
|
};
|
|
2856
2859
|
case "divide": {
|
|
@@ -2859,12 +2862,12 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2859
2862
|
}
|
|
2860
2863
|
case "power": {
|
|
2861
2864
|
let [e, t] = a();
|
|
2862
|
-
return !e || !t ? this.unsupported("<power> without two operands") : X([...
|
|
2865
|
+
return !e || !t ? this.unsupported("<power> without two operands") : X([...Ni(e, Y.Primary), I(t.row)]);
|
|
2863
2866
|
}
|
|
2864
2867
|
case "root": {
|
|
2865
2868
|
let [e] = a();
|
|
2866
2869
|
if (!e) return this.unsupported("<root> without an operand");
|
|
2867
|
-
let t =
|
|
2870
|
+
let t = Mi(r, "degree"), n = t ? this.inner(t) : null;
|
|
2868
2871
|
return X([Se(e.row, n)]);
|
|
2869
2872
|
}
|
|
2870
2873
|
case "abs": {
|
|
@@ -2876,59 +2879,59 @@ var Ci = (e) => Array.from(e.children), Y = {
|
|
|
2876
2879
|
}
|
|
2877
2880
|
}
|
|
2878
2881
|
functionCall(e, t, n) {
|
|
2879
|
-
let r =
|
|
2882
|
+
let r = Oi.get(e);
|
|
2880
2883
|
if (!r) return this.unsupported(`<${e}>`);
|
|
2881
2884
|
if (n.length === 0) return this.unsupported(`<${e}> without an operand`);
|
|
2882
2885
|
let i = Ue(r);
|
|
2883
2886
|
if (i && n.length === 1) return X([L(n[0].row, i.open, i.close)]);
|
|
2884
|
-
let a = e === "log" ?
|
|
2887
|
+
let a = e === "log" ? Mi(t, "logbase") : void 0, o = (a ? [n[0], {
|
|
2885
2888
|
row: this.inner(a),
|
|
2886
2889
|
level: Y.Primary
|
|
2887
2890
|
}] : n).flatMap((e, t) => t === 0 ? e.row : [P(","), ...e.row]);
|
|
2888
2891
|
return X([F(r), L(o)]);
|
|
2889
2892
|
}
|
|
2890
2893
|
derivative(e, t) {
|
|
2891
|
-
let n =
|
|
2894
|
+
let n = Mi(e, "bvar"), [r] = t;
|
|
2892
2895
|
if (!n || !r) return this.unsupported("<diff> without <bvar> and an operand");
|
|
2893
|
-
let i =
|
|
2896
|
+
let i = wi(n).find((e) => e.localName === "ci"), a = wi(n).find((e) => e.localName === "degree");
|
|
2894
2897
|
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
2898
|
}
|
|
2896
2899
|
piecewise(e) {
|
|
2897
2900
|
let t = [], n = null, r = (e) => e ? this.expression(e).row : [];
|
|
2898
|
-
for (let i of
|
|
2899
|
-
let [e, a] =
|
|
2901
|
+
for (let i of wi(e)) {
|
|
2902
|
+
let [e, a] = wi(i);
|
|
2900
2903
|
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
2904
|
}
|
|
2902
2905
|
return t.length === 0 ? this.unsupported("A <piecewise> without a <piece>") : X([Te(t, n)]);
|
|
2903
2906
|
}
|
|
2904
2907
|
inner(e) {
|
|
2905
|
-
let [t] =
|
|
2908
|
+
let [t] = wi(e);
|
|
2906
2909
|
return t ? this.expression(t).row : [];
|
|
2907
2910
|
}
|
|
2908
|
-
},
|
|
2911
|
+
}, ji = /* @__PURE__ */ new Set([
|
|
2909
2912
|
"bvar",
|
|
2910
2913
|
"degree",
|
|
2911
2914
|
"logbase"
|
|
2912
|
-
]),
|
|
2915
|
+
]), Mi = (e, t) => e.find((e) => e.localName === t), X = (e) => ({
|
|
2913
2916
|
row: e,
|
|
2914
2917
|
level: Y.Primary
|
|
2915
2918
|
});
|
|
2916
|
-
function
|
|
2919
|
+
function Ni(e, t) {
|
|
2917
2920
|
return e.level < t ? [L(e.row)] : e.row;
|
|
2918
2921
|
}
|
|
2919
|
-
function
|
|
2922
|
+
function Pi(e, t, n) {
|
|
2920
2923
|
let r = [];
|
|
2921
2924
|
return e.forEach((e, i) => {
|
|
2922
2925
|
i > 0 && r.push(P(t));
|
|
2923
2926
|
let a = e.level === Y.Unary && (t === "+" && i > 0 || t === "·" && i === 0) ? Y.Unary : n;
|
|
2924
|
-
r.push(...
|
|
2927
|
+
r.push(...Ni(e, a));
|
|
2925
2928
|
}), r;
|
|
2926
2929
|
}
|
|
2927
|
-
function
|
|
2930
|
+
function Fi(e) {
|
|
2928
2931
|
for (let t of Array.from(e.attributes)) if (t.localName === "units" && (t.prefix === "cellml" || t.namespaceURI?.includes("cellml.org"))) return t.value.trim();
|
|
2929
2932
|
return null;
|
|
2930
2933
|
}
|
|
2931
|
-
function
|
|
2934
|
+
function Ii(e, t) {
|
|
2932
2935
|
let n = "";
|
|
2933
2936
|
for (let r of Array.from(e.childNodes)) {
|
|
2934
2937
|
if (r === t) break;
|
|
@@ -2936,14 +2939,14 @@ function Fi(e, t) {
|
|
|
2936
2939
|
}
|
|
2937
2940
|
return n;
|
|
2938
2941
|
}
|
|
2939
|
-
function
|
|
2942
|
+
function Li(e, t) {
|
|
2940
2943
|
let n = "", r = !1;
|
|
2941
2944
|
for (let i of Array.from(e.childNodes)) r && (n += i.textContent ?? ""), i === t && (r = !0);
|
|
2942
2945
|
return n;
|
|
2943
2946
|
}
|
|
2944
2947
|
//#endregion
|
|
2945
2948
|
//#region src/editor/marks.ts
|
|
2946
|
-
var
|
|
2949
|
+
var Ri = (e) => e.kind ?? "error", zi = (e) => Ri(e) !== "hint", Bi = ["aria-invalid"], Vi = ["data-kind"], Hi = ["innerHTML"], Ui = /*@__PURE__*/ l({
|
|
2947
2950
|
__name: "MathField",
|
|
2948
2951
|
props: {
|
|
2949
2952
|
modelValue: {},
|
|
@@ -2982,7 +2985,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
2982
2985
|
};
|
|
2983
2986
|
}
|
|
2984
2987
|
let T = t(() => G(w())), E = t(() => {
|
|
2985
|
-
let e = new Set(c.marks.filter(
|
|
2988
|
+
let e = new Set(c.marks.filter(zi).flatMap((e) => e.atomIds)), t = c.active ? Ln(c.modelValue, c.cursor) : null;
|
|
2986
2989
|
return t && e.add(t), e;
|
|
2987
2990
|
}), D = t(() => se.renderToString(Ht(c.modelValue, {
|
|
2988
2991
|
activeRow: c.active ? c.cursor.path : null,
|
|
@@ -3016,7 +3019,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3016
3019
|
return n ? [{
|
|
3017
3020
|
box: n,
|
|
3018
3021
|
message: t.message,
|
|
3019
|
-
kind:
|
|
3022
|
+
kind: Ri(t)
|
|
3020
3023
|
}] : [];
|
|
3021
3024
|
}) : [], C.value = null;
|
|
3022
3025
|
}
|
|
@@ -3119,7 +3122,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3119
3122
|
]);
|
|
3120
3123
|
function _e(e, t) {
|
|
3121
3124
|
if (c.readonly) return;
|
|
3122
|
-
let n =
|
|
3125
|
+
let n = yi(e);
|
|
3123
3126
|
if (!n) return;
|
|
3124
3127
|
let r = n(t);
|
|
3125
3128
|
if (r === t) {
|
|
@@ -3129,7 +3132,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3129
3132
|
e.preventDefault(), l("edit", r, k(e, t));
|
|
3130
3133
|
}
|
|
3131
3134
|
function k(e, t) {
|
|
3132
|
-
let n = G(t) !== null, r =
|
|
3135
|
+
let n = G(t) !== null, r = vi(e);
|
|
3133
3136
|
if (r !== null) {
|
|
3134
3137
|
let e = M(t.root, t.cursor.path), i = t.cursor.offset - +!!Fn(e?.[t.cursor.offset - 1]);
|
|
3135
3138
|
return {
|
|
@@ -3145,7 +3148,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3145
3148
|
} : e.key === "Delete" ? {
|
|
3146
3149
|
kind: "deleteForward",
|
|
3147
3150
|
replacedSelection: n
|
|
3148
|
-
} :
|
|
3151
|
+
} : pi;
|
|
3149
3152
|
}
|
|
3150
3153
|
let A = null;
|
|
3151
3154
|
function ve(e) {
|
|
@@ -3180,14 +3183,14 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3180
3183
|
N() && P(e);
|
|
3181
3184
|
}
|
|
3182
3185
|
function xe(e) {
|
|
3183
|
-
N() && !c.readonly && P(e) && l("edit",
|
|
3186
|
+
N() && !c.readonly && P(e) && l("edit", ii(w()), pi);
|
|
3184
3187
|
}
|
|
3185
3188
|
function I(e) {
|
|
3186
3189
|
if (!N() || c.readonly || !e.clipboardData) return;
|
|
3187
3190
|
e.preventDefault();
|
|
3188
3191
|
let t = e.clipboardData, n = dn(t.getData(ln)), r = t.getData("text/plain");
|
|
3189
|
-
if (!n &&
|
|
3190
|
-
l("import",
|
|
3192
|
+
if (!n && Si(r)) {
|
|
3193
|
+
l("import", Ci(r) ?? {
|
|
3191
3194
|
equations: [],
|
|
3192
3195
|
problems: ["The pasted MathML isn't well-formed XML, so nothing was imported"],
|
|
3193
3196
|
lineProblems: []
|
|
@@ -3195,7 +3198,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3195
3198
|
return;
|
|
3196
3199
|
}
|
|
3197
3200
|
let i = n ?? Pn(r);
|
|
3198
|
-
i.length > 0 && l("edit",
|
|
3201
|
+
i.length > 0 && l("edit", zr(i)(w()), pi);
|
|
3199
3202
|
}
|
|
3200
3203
|
return o({ focus: () => u.value?.focus() }), (t, o) => (g(), i("div", {
|
|
3201
3204
|
ref_key: "surfaceEl",
|
|
@@ -3207,7 +3210,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3207
3210
|
tabindex: "0",
|
|
3208
3211
|
role: "textbox",
|
|
3209
3212
|
"aria-label": "Equation",
|
|
3210
|
-
"aria-invalid": n.marks.some(S(
|
|
3213
|
+
"aria-invalid": n.marks.some(S(zi)) || void 0,
|
|
3211
3214
|
onKeydown: he,
|
|
3212
3215
|
onMousedown: j,
|
|
3213
3216
|
onMouseenter: ue,
|
|
@@ -3233,7 +3236,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3233
3236
|
"data-role": "mark",
|
|
3234
3237
|
"data-kind": t.kind,
|
|
3235
3238
|
style: m(de(t.box))
|
|
3236
|
-
}, null, 14,
|
|
3239
|
+
}, null, 14, Vi))], 64))), 128)),
|
|
3237
3240
|
O.value ? (g(), i("div", {
|
|
3238
3241
|
key: ae.value,
|
|
3239
3242
|
class: "caret",
|
|
@@ -3242,7 +3245,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3242
3245
|
a("div", {
|
|
3243
3246
|
class: "math-content",
|
|
3244
3247
|
innerHTML: D.value
|
|
3245
|
-
}, null, 8,
|
|
3248
|
+
}, null, 8, Hi),
|
|
3246
3249
|
C.value ? (g(), i("div", {
|
|
3247
3250
|
key: 3,
|
|
3248
3251
|
class: "mark-tip",
|
|
@@ -3259,16 +3262,16 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
|
|
|
3259
3262
|
class: "fixed-origin",
|
|
3260
3263
|
"aria-hidden": "true"
|
|
3261
3264
|
}, null, 512)
|
|
3262
|
-
], 42,
|
|
3265
|
+
], 42, Bi));
|
|
3263
3266
|
}
|
|
3264
|
-
}),
|
|
3267
|
+
}), Wi = (e, t) => {
|
|
3265
3268
|
let n = e.__vccOpts || e;
|
|
3266
3269
|
for (let [e, r] of t) n[e] = r;
|
|
3267
3270
|
return n;
|
|
3268
|
-
},
|
|
3271
|
+
}, Gi = /*#__PURE__*/ Wi(Ui, [["__scopeId", "data-v-c390dc95"]]);
|
|
3269
3272
|
//#endregion
|
|
3270
3273
|
//#region src/components/contentStable.ts
|
|
3271
|
-
function
|
|
3274
|
+
function Ki(e) {
|
|
3272
3275
|
let n = null;
|
|
3273
3276
|
return t(() => {
|
|
3274
3277
|
let t = e(), r = JSON.stringify(t) ?? "";
|
|
@@ -3280,14 +3283,14 @@ function Gi(e) {
|
|
|
3280
3283
|
}
|
|
3281
3284
|
//#endregion
|
|
3282
3285
|
//#region src/editor/parse.ts
|
|
3283
|
-
function
|
|
3286
|
+
function qi(e) {
|
|
3284
3287
|
let t = [];
|
|
3285
3288
|
return {
|
|
3286
|
-
ast:
|
|
3289
|
+
ast: ta(e, t),
|
|
3287
3290
|
diagnostics: t
|
|
3288
3291
|
};
|
|
3289
3292
|
}
|
|
3290
|
-
var
|
|
3293
|
+
var Ji = {
|
|
3291
3294
|
"+": "+",
|
|
3292
3295
|
"-": "-",
|
|
3293
3296
|
"−": "-",
|
|
@@ -3297,7 +3300,7 @@ var qi = {
|
|
|
3297
3300
|
"×": "*",
|
|
3298
3301
|
",": ",",
|
|
3299
3302
|
...Object.fromEntries(yt.map((e) => [e.symbol, e.symbol]))
|
|
3300
|
-
},
|
|
3303
|
+
}, Yi = /^[A-Za-z_][A-Za-z0-9_]*$/, Xi = [
|
|
3301
3304
|
{
|
|
3302
3305
|
symbol: "∨",
|
|
3303
3306
|
type: "Or"
|
|
@@ -3311,7 +3314,7 @@ var qi = {
|
|
|
3311
3314
|
type: "And"
|
|
3312
3315
|
}
|
|
3313
3316
|
];
|
|
3314
|
-
function
|
|
3317
|
+
function Zi(e, t) {
|
|
3315
3318
|
let n = [], r = 0;
|
|
3316
3319
|
for (; r < e.length;) {
|
|
3317
3320
|
let i = e[r];
|
|
@@ -3385,7 +3388,7 @@ function Xi(e, t) {
|
|
|
3385
3388
|
});
|
|
3386
3389
|
continue;
|
|
3387
3390
|
}
|
|
3388
|
-
let o =
|
|
3391
|
+
let o = Ji[i.value], s = [i.id];
|
|
3389
3392
|
o ? n.push({
|
|
3390
3393
|
kind: "operator",
|
|
3391
3394
|
op: o,
|
|
@@ -3406,19 +3409,19 @@ function Xi(e, t) {
|
|
|
3406
3409
|
}
|
|
3407
3410
|
return n;
|
|
3408
3411
|
}
|
|
3409
|
-
function
|
|
3412
|
+
function Qi(e) {
|
|
3410
3413
|
if (e === "=") return "Equal";
|
|
3411
3414
|
let t = Ct(e);
|
|
3412
3415
|
return t?.role === "comparison" ? t.type : null;
|
|
3413
3416
|
}
|
|
3414
|
-
var
|
|
3415
|
-
function
|
|
3417
|
+
var $i = (e) => e === "*" ? "×" : e === "-" ? "−" : e;
|
|
3418
|
+
function ea() {
|
|
3416
3419
|
return { type: "Placeholder" };
|
|
3417
3420
|
}
|
|
3418
|
-
function
|
|
3419
|
-
return e.length === 0 ?
|
|
3421
|
+
function ta(e, t) {
|
|
3422
|
+
return e.length === 0 ? ea() : new na(Zi(e, t), t).parseAll();
|
|
3420
3423
|
}
|
|
3421
|
-
var
|
|
3424
|
+
var na = class {
|
|
3422
3425
|
tokens;
|
|
3423
3426
|
diagnostics;
|
|
3424
3427
|
index = 0;
|
|
@@ -3431,8 +3434,8 @@ var ta = class {
|
|
|
3431
3434
|
return e;
|
|
3432
3435
|
}
|
|
3433
3436
|
parseLogic(e) {
|
|
3434
|
-
if (e ===
|
|
3435
|
-
let { symbol: t, type: n } =
|
|
3437
|
+
if (e === Xi.length) return this.parseNot();
|
|
3438
|
+
let { symbol: t, type: n } = Xi[e], r = [this.parseLogic(e + 1)];
|
|
3436
3439
|
for (; this.peekOperator(t);) this.next(), r.push(this.parseLogic(e + 1));
|
|
3437
3440
|
return r.length === 1 ? r[0] : {
|
|
3438
3441
|
type: n,
|
|
@@ -3448,7 +3451,7 @@ var ta = class {
|
|
|
3448
3451
|
parseComparison() {
|
|
3449
3452
|
let e = this.parseAdditive(), t = 0;
|
|
3450
3453
|
for (;;) {
|
|
3451
|
-
let n = this.peek(), r = n?.kind === "operator" ?
|
|
3454
|
+
let n = this.peek(), r = n?.kind === "operator" ? Qi(n.op) : null;
|
|
3452
3455
|
if (!n || !r) return e;
|
|
3453
3456
|
this.next(), t++ > 0 && this.diagnostics.push({
|
|
3454
3457
|
message: "Comparisons can't be chained: join them with ∧",
|
|
@@ -3521,12 +3524,12 @@ var ta = class {
|
|
|
3521
3524
|
}
|
|
3522
3525
|
parseSuperscript() {
|
|
3523
3526
|
let e = this.next(), t = e.atom;
|
|
3524
|
-
return t.kind === "superscript" ? this.child(t.sup, "Empty exponent", e.atomIds) :
|
|
3527
|
+
return t.kind === "superscript" ? this.child(t.sup, "Empty exponent", e.atomIds) : ea();
|
|
3525
3528
|
}
|
|
3526
3529
|
parsePrimary() {
|
|
3527
3530
|
this.skipInvalid();
|
|
3528
3531
|
let e = this.peek();
|
|
3529
|
-
if (!e || !this.startsPrimary(e)) return this.reportMissing(e),
|
|
3532
|
+
if (!e || !this.startsPrimary(e)) return this.reportMissing(e), ea();
|
|
3530
3533
|
switch (this.next(), e.kind) {
|
|
3531
3534
|
case "number": return this.parseNumber(e);
|
|
3532
3535
|
case "identifier": return {
|
|
@@ -3539,7 +3542,7 @@ var ta = class {
|
|
|
3539
3542
|
};
|
|
3540
3543
|
case "function": return this.parseFunction(e.name, e.atomIds);
|
|
3541
3544
|
case "structure": return this.parseStructure(e.atom, e.atomIds);
|
|
3542
|
-
default: return
|
|
3545
|
+
default: return ea();
|
|
3543
3546
|
}
|
|
3544
3547
|
}
|
|
3545
3548
|
parseNumber(e) {
|
|
@@ -3555,7 +3558,7 @@ var ta = class {
|
|
|
3555
3558
|
}
|
|
3556
3559
|
unitsName(e) {
|
|
3557
3560
|
let t = e.atom.units.map((e) => e.kind === "symbol" ? e.value : "?").join("");
|
|
3558
|
-
return
|
|
3561
|
+
return Yi.test(t) ? t : (t && this.diagnostics.push({
|
|
3559
3562
|
message: `"${t}" isn't a units name`,
|
|
3560
3563
|
atomIds: e.atomIds
|
|
3561
3564
|
}), null);
|
|
@@ -3568,7 +3571,7 @@ var ta = class {
|
|
|
3568
3571
|
message: `${e} needs an argument`,
|
|
3569
3572
|
atomIds: t,
|
|
3570
3573
|
incomplete: !0
|
|
3571
|
-
}), r = [
|
|
3574
|
+
}), r = [ea()]);
|
|
3572
3575
|
let a = {
|
|
3573
3576
|
type: "FunctionCall",
|
|
3574
3577
|
name: e,
|
|
@@ -3635,10 +3638,10 @@ var ta = class {
|
|
|
3635
3638
|
}
|
|
3636
3639
|
case "superscript": return {
|
|
3637
3640
|
type: "Power",
|
|
3638
|
-
base:
|
|
3641
|
+
base: ea(),
|
|
3639
3642
|
exponent: this.child(e.sup)
|
|
3640
3643
|
};
|
|
3641
|
-
case "units": return
|
|
3644
|
+
case "units": return ea();
|
|
3642
3645
|
}
|
|
3643
3646
|
}
|
|
3644
3647
|
child(e, t, n) {
|
|
@@ -3646,13 +3649,13 @@ var ta = class {
|
|
|
3646
3649
|
message: t,
|
|
3647
3650
|
atomIds: n,
|
|
3648
3651
|
incomplete: !0
|
|
3649
|
-
}),
|
|
3652
|
+
}), ta(e, this.diagnostics);
|
|
3650
3653
|
}
|
|
3651
3654
|
reportMissing(e) {
|
|
3652
3655
|
let t = this.tokens[this.index - 1], n, r;
|
|
3653
|
-
if (t?.kind === "operator" && t.op !== ",") n =
|
|
3656
|
+
if (t?.kind === "operator" && t.op !== ",") n = Qi(t.op) ? t.op === "=" ? "Missing right-hand side" : `Missing right-hand side of ${t.op}` : `Missing operand after ${$i(t.op)}`, r = t.atomIds;
|
|
3654
3657
|
else if (t) return;
|
|
3655
|
-
else if (e?.kind === "operator") n =
|
|
3658
|
+
else if (e?.kind === "operator") n = Qi(e.op) ? e.op === "=" ? "Missing left-hand side" : `Missing left-hand side of ${e.op}` : `Missing operand before ${$i(e.op)}`, r = e.atomIds;
|
|
3656
3659
|
else if (e?.kind === "structure" && e.atom.kind === "superscript") n = "Missing base for the exponent", r = e.atomIds;
|
|
3657
3660
|
else return;
|
|
3658
3661
|
this.diagnostics.push({
|
|
@@ -3706,7 +3709,7 @@ var ta = class {
|
|
|
3706
3709
|
};
|
|
3707
3710
|
//#endregion
|
|
3708
3711
|
//#region src/renderers/mathjson.ts
|
|
3709
|
-
function
|
|
3712
|
+
function ra(e) {
|
|
3710
3713
|
return Be(e)?.mathJson ?? e;
|
|
3711
3714
|
}
|
|
3712
3715
|
function Z(e) {
|
|
@@ -3729,7 +3732,7 @@ function Z(e) {
|
|
|
3729
3732
|
Z(e.radicand),
|
|
3730
3733
|
Z(e.degree)
|
|
3731
3734
|
] : ["Sqrt", Z(e.radicand)];
|
|
3732
|
-
case "FunctionCall": return [
|
|
3735
|
+
case "FunctionCall": return [ra(e.name), ...e.args.map(Z)];
|
|
3733
3736
|
case "Equal":
|
|
3734
3737
|
case "Less":
|
|
3735
3738
|
case "Greater":
|
|
@@ -3768,12 +3771,12 @@ function Z(e) {
|
|
|
3768
3771
|
default: return null;
|
|
3769
3772
|
}
|
|
3770
3773
|
}
|
|
3771
|
-
function
|
|
3774
|
+
function ia(e) {
|
|
3772
3775
|
return JSON.stringify(Z(e), null, 2);
|
|
3773
3776
|
}
|
|
3774
3777
|
//#endregion
|
|
3775
3778
|
//#region src/renderers/mathml.ts
|
|
3776
|
-
function
|
|
3779
|
+
function aa(e) {
|
|
3777
3780
|
throw Error(`Unsupported AST node: ${JSON.stringify(e)}`);
|
|
3778
3781
|
}
|
|
3779
3782
|
function Q(e, t) {
|
|
@@ -3784,7 +3787,7 @@ function Q(e, t) {
|
|
|
3784
3787
|
</apply>
|
|
3785
3788
|
`;
|
|
3786
3789
|
}
|
|
3787
|
-
function
|
|
3790
|
+
function oa(e, t) {
|
|
3788
3791
|
let n = t.cellml ? ` cellml:units="${e.units ?? "dimensionless"}"` : "", [r, i] = String(e.value).split("e"), a = e.scientific ? {
|
|
3789
3792
|
mantissa: e.scientific.mantissa,
|
|
3790
3793
|
exponent: e.scientific.exponent
|
|
@@ -3796,7 +3799,7 @@ function aa(e, t) {
|
|
|
3796
3799
|
}
|
|
3797
3800
|
function $(e, t = {}) {
|
|
3798
3801
|
switch (e.type) {
|
|
3799
|
-
case "Number": return
|
|
3802
|
+
case "Number": return oa(e, t);
|
|
3800
3803
|
case "Identifier": return `<ci>${e.name}</ci>`;
|
|
3801
3804
|
case "Constant": return `<${z(e.name).mathml}/>`;
|
|
3802
3805
|
case "Add": return Q("plus", e.children.map((e) => $(e, t)));
|
|
@@ -3857,12 +3860,12 @@ function $(e, t = {}) {
|
|
|
3857
3860
|
</apply>
|
|
3858
3861
|
`;
|
|
3859
3862
|
case "Placeholder": return "<ci>_</ci>";
|
|
3860
|
-
default: return
|
|
3863
|
+
default: return aa(e);
|
|
3861
3864
|
}
|
|
3862
3865
|
}
|
|
3863
3866
|
//#endregion
|
|
3864
3867
|
//#region src/editor/exports.ts
|
|
3865
|
-
var
|
|
3868
|
+
var sa = [
|
|
3866
3869
|
{
|
|
3867
3870
|
format: "latex",
|
|
3868
3871
|
label: "LaTeX"
|
|
@@ -3875,19 +3878,19 @@ var oa = [
|
|
|
3875
3878
|
format: "mathml",
|
|
3876
3879
|
label: "Content MathML"
|
|
3877
3880
|
}
|
|
3878
|
-
],
|
|
3879
|
-
function
|
|
3881
|
+
], ca = "http://www.w3.org/1998/Math/MathML", la = "http://www.cellml.org/cellml/2.0#";
|
|
3882
|
+
function ua(e, t, n = {}) {
|
|
3880
3883
|
switch (t) {
|
|
3881
3884
|
case "latex": return W(e, n);
|
|
3882
|
-
case "mathjson": return
|
|
3883
|
-
case "mathml": return
|
|
3885
|
+
case "mathjson": return ia(qi(e).ast);
|
|
3886
|
+
case "mathml": return da(e, n);
|
|
3884
3887
|
}
|
|
3885
3888
|
}
|
|
3886
|
-
function
|
|
3887
|
-
let n = $(
|
|
3888
|
-
return
|
|
3889
|
+
function da(e, t = {}) {
|
|
3890
|
+
let n = $(qi(e).ast, t);
|
|
3891
|
+
return fa(`<math ${t.cellml ? `xmlns="${ca}" xmlns:cellml="${la}"` : `xmlns="${ca}"`}>${n}</math>`);
|
|
3889
3892
|
}
|
|
3890
|
-
function
|
|
3893
|
+
function fa(e, t = " ") {
|
|
3891
3894
|
let n = e.match(/<[^>]+>|[^<]+/g) ?? [], r = [], i = 0;
|
|
3892
3895
|
for (let e = 0; e < n.length; e++) {
|
|
3893
3896
|
let a = n[e];
|
|
@@ -3922,7 +3925,7 @@ function da(e, t = " ") {
|
|
|
3922
3925
|
}
|
|
3923
3926
|
//#endregion
|
|
3924
3927
|
//#region src/editor/units.ts
|
|
3925
|
-
function
|
|
3928
|
+
function pa(e, t, n, r = 0) {
|
|
3926
3929
|
if (!n) return {
|
|
3927
3930
|
id: e,
|
|
3928
3931
|
mathml: "",
|
|
@@ -3932,20 +3935,20 @@ function fa(e, t, n, r = 0) {
|
|
|
3932
3935
|
};
|
|
3933
3936
|
let i = [], a = [], o = 0, s = (e) => {
|
|
3934
3937
|
e.type === "Identifier" && !i.includes(e.name) && i.push(e.name), e.type === "Number" && e.units && !a.includes(e.units) && a.push(e.units), e.type === "Placeholder" && o++;
|
|
3935
|
-
for (let t of
|
|
3938
|
+
for (let t of ha(e)) s(t);
|
|
3936
3939
|
};
|
|
3937
3940
|
return s(n.ast), {
|
|
3938
3941
|
id: e,
|
|
3939
|
-
mathml:
|
|
3942
|
+
mathml: da(t, { cellml: !0 }),
|
|
3940
3943
|
variables: i,
|
|
3941
3944
|
units: a,
|
|
3942
|
-
complete: n.diagnostics.length === 0 && r === 0 && o === 0 && !
|
|
3945
|
+
complete: n.diagnostics.length === 0 && r === 0 && o === 0 && !ma(t)
|
|
3943
3946
|
};
|
|
3944
3947
|
}
|
|
3945
|
-
function pa(e) {
|
|
3946
|
-
return e.some((e) => e.kind === "units" && e.units.length === 0 || k(e).some(([, e]) => pa(e)));
|
|
3947
|
-
}
|
|
3948
3948
|
function ma(e) {
|
|
3949
|
+
return e.some((e) => e.kind === "units" && e.units.length === 0 || k(e).some(([, e]) => ma(e)));
|
|
3950
|
+
}
|
|
3951
|
+
function ha(e) {
|
|
3949
3952
|
switch (e.type) {
|
|
3950
3953
|
case "Add":
|
|
3951
3954
|
case "Multiply":
|
|
@@ -3972,7 +3975,7 @@ function ma(e) {
|
|
|
3972
3975
|
default: return [];
|
|
3973
3976
|
}
|
|
3974
3977
|
}
|
|
3975
|
-
function
|
|
3978
|
+
function ga(e, t) {
|
|
3976
3979
|
let n = [], r = t.some((e) => e.numbers?.length || e.units?.length) ? lt(e) : [], i = t.some((e) => e.variables?.length) ? ct(e) : null;
|
|
3977
3980
|
for (let e of t) {
|
|
3978
3981
|
for (let t of e.variables ?? []) for (let r of i?.get(t) ?? []) n.push({
|
|
@@ -3988,7 +3991,7 @@ function ha(e, t) {
|
|
|
3988
3991
|
}
|
|
3989
3992
|
return n;
|
|
3990
3993
|
}
|
|
3991
|
-
function
|
|
3994
|
+
function _a(e, t) {
|
|
3992
3995
|
let n = [];
|
|
3993
3996
|
if (t) for (let [r, i] of ct(e)) {
|
|
3994
3997
|
if (!Object.hasOwn(t, r)) continue;
|
|
@@ -4012,40 +4015,40 @@ function ga(e, t) {
|
|
|
4012
4015
|
}
|
|
4013
4016
|
//#endregion
|
|
4014
4017
|
//#region src/editor/toolbar.ts
|
|
4015
|
-
function
|
|
4018
|
+
function va(e, t) {
|
|
4016
4019
|
let { latexName: n, latexCommand: r } = ze[e];
|
|
4017
4020
|
return {
|
|
4018
4021
|
latex: r ? `\\${n}` : `\\operatorname{${n}}`,
|
|
4019
4022
|
title: `${t} ( ${n} )`,
|
|
4020
|
-
command:
|
|
4023
|
+
command: si(e)
|
|
4021
4024
|
};
|
|
4022
4025
|
}
|
|
4023
|
-
var
|
|
4026
|
+
var ya = [
|
|
4024
4027
|
["sin", "Sine"],
|
|
4025
4028
|
["cos", "Cosine"],
|
|
4026
4029
|
["tan", "Tangent"],
|
|
4027
4030
|
["sec", "Secant"],
|
|
4028
4031
|
["csc", "Cosecant"],
|
|
4029
4032
|
["cot", "Cotangent"]
|
|
4030
|
-
],
|
|
4033
|
+
], ba = (e, t) => ya.map(([n, r]) => {
|
|
4031
4034
|
let i = [
|
|
4032
4035
|
t && "inverse",
|
|
4033
4036
|
e && "hyperbolic",
|
|
4034
4037
|
r.toLowerCase()
|
|
4035
4038
|
].filter(Boolean).join(" ");
|
|
4036
|
-
return
|
|
4037
|
-
}),
|
|
4039
|
+
return va(`${t ? "a" : ""}${n}${e}`, i[0].toUpperCase() + i.slice(1));
|
|
4040
|
+
}), xa = [
|
|
4038
4041
|
{
|
|
4039
4042
|
id: "fraction",
|
|
4040
4043
|
title: "Fraction ( / )",
|
|
4041
4044
|
latex: "\\frac{a}{b}",
|
|
4042
|
-
command:
|
|
4045
|
+
command: Wr
|
|
4043
4046
|
},
|
|
4044
4047
|
{
|
|
4045
4048
|
id: "script",
|
|
4046
4049
|
title: "Power ( ^ )",
|
|
4047
4050
|
latex: "x^{n}",
|
|
4048
|
-
command:
|
|
4051
|
+
command: Gr
|
|
4049
4052
|
},
|
|
4050
4053
|
{
|
|
4051
4054
|
id: "radical",
|
|
@@ -4054,11 +4057,11 @@ var va = [
|
|
|
4054
4057
|
sections: [{ items: [{
|
|
4055
4058
|
latex: "\\sqrt{x}",
|
|
4056
4059
|
title: "Square root ( \\sqrt )",
|
|
4057
|
-
command:
|
|
4060
|
+
command: ci
|
|
4058
4061
|
}, {
|
|
4059
4062
|
latex: "\\sqrt[n]{x}",
|
|
4060
4063
|
title: "nth root ( \\root )",
|
|
4061
|
-
command:
|
|
4064
|
+
command: li
|
|
4062
4065
|
}] }]
|
|
4063
4066
|
},
|
|
4064
4067
|
{
|
|
@@ -4069,17 +4072,17 @@ var va = [
|
|
|
4069
4072
|
{
|
|
4070
4073
|
latex: "|x|",
|
|
4071
4074
|
title: "Absolute value ( | )",
|
|
4072
|
-
command:
|
|
4075
|
+
command: ui
|
|
4073
4076
|
},
|
|
4074
4077
|
{
|
|
4075
4078
|
latex: "\\lfloor x\\rfloor",
|
|
4076
4079
|
title: "Floor ( floor( or \\floor )",
|
|
4077
|
-
command:
|
|
4080
|
+
command: $r
|
|
4078
4081
|
},
|
|
4079
4082
|
{
|
|
4080
4083
|
latex: "\\lceil x\\rceil",
|
|
4081
4084
|
title: "Ceiling ( ceil( or \\ceil )",
|
|
4082
|
-
command:
|
|
4085
|
+
command: ei
|
|
4083
4086
|
}
|
|
4084
4087
|
] }]
|
|
4085
4088
|
},
|
|
@@ -4090,26 +4093,26 @@ var va = [
|
|
|
4090
4093
|
sections: [
|
|
4091
4094
|
{
|
|
4092
4095
|
label: "Trigonometric",
|
|
4093
|
-
items:
|
|
4096
|
+
items: ba("", !1)
|
|
4094
4097
|
},
|
|
4095
4098
|
{
|
|
4096
4099
|
label: "Hyperbolic",
|
|
4097
|
-
items:
|
|
4100
|
+
items: ba("h", !1)
|
|
4098
4101
|
},
|
|
4099
4102
|
{
|
|
4100
4103
|
label: "Inverse trigonometric",
|
|
4101
|
-
items:
|
|
4104
|
+
items: ba("", !0)
|
|
4102
4105
|
},
|
|
4103
4106
|
{
|
|
4104
4107
|
label: "Inverse hyperbolic",
|
|
4105
|
-
items:
|
|
4108
|
+
items: ba("h", !0)
|
|
4106
4109
|
},
|
|
4107
4110
|
{
|
|
4108
4111
|
label: "Exponential and logarithm",
|
|
4109
4112
|
items: [
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
+
va("exp", "Exponential"),
|
|
4114
|
+
va("ln", "Natural logarithm"),
|
|
4115
|
+
va("log", "Logarithm")
|
|
4113
4116
|
]
|
|
4114
4117
|
}
|
|
4115
4118
|
]
|
|
@@ -4118,13 +4121,13 @@ var va = [
|
|
|
4118
4121
|
id: "derivative",
|
|
4119
4122
|
title: "Derivative ( \\dd )",
|
|
4120
4123
|
latex: "\\frac{\\mathrm{d}y}{\\mathrm{d}x}",
|
|
4121
|
-
command:
|
|
4124
|
+
command: di
|
|
4122
4125
|
},
|
|
4123
4126
|
{
|
|
4124
4127
|
id: "cases",
|
|
4125
4128
|
title: "Piecewise ( \\cases )",
|
|
4126
4129
|
latex: "\\left\\{\\begin{smallmatrix}a&p\\\\b&q\\end{smallmatrix}\\right.",
|
|
4127
|
-
command:
|
|
4130
|
+
command: Vr
|
|
4128
4131
|
},
|
|
4129
4132
|
{
|
|
4130
4133
|
id: "symbols",
|
|
@@ -4233,47 +4236,47 @@ var va = [
|
|
|
4233
4236
|
}
|
|
4234
4237
|
]
|
|
4235
4238
|
}
|
|
4236
|
-
],
|
|
4239
|
+
], Sa = { class: "toolbar-group" }, Ca = [
|
|
4237
4240
|
"title",
|
|
4238
4241
|
"data-role",
|
|
4239
4242
|
"aria-haspopup",
|
|
4240
4243
|
"disabled",
|
|
4241
4244
|
"onClick"
|
|
4242
|
-
],
|
|
4245
|
+
], wa = ["innerHTML"], Ta = {
|
|
4243
4246
|
key: 0,
|
|
4244
4247
|
class: "pi pi-chevron-down tool-chevron",
|
|
4245
4248
|
"aria-hidden": "true"
|
|
4246
|
-
},
|
|
4249
|
+
}, Ea = { class: "toolbar-group toolbar-lines" }, Da = {
|
|
4247
4250
|
key: 0,
|
|
4248
4251
|
class: "toolbar-group"
|
|
4249
|
-
},
|
|
4252
|
+
}, Oa = {
|
|
4250
4253
|
key: 0,
|
|
4251
4254
|
class: "gallery"
|
|
4252
|
-
},
|
|
4255
|
+
}, ka = {
|
|
4253
4256
|
key: 0,
|
|
4254
4257
|
class: "gallery-label"
|
|
4255
|
-
},
|
|
4258
|
+
}, Aa = { class: "gallery-items" }, ja = ["title", "onClick"], Ma = ["innerHTML"], Na = [
|
|
4256
4259
|
"data-line",
|
|
4257
4260
|
"data-line-id",
|
|
4258
4261
|
"onFocusin"
|
|
4259
|
-
],
|
|
4262
|
+
], Pa = { class: "equation-label" }, Fa = ["data-kind", "title"], Ia = {
|
|
4260
4263
|
key: 0,
|
|
4261
4264
|
class: "command-chip",
|
|
4262
4265
|
"data-role": "command"
|
|
4263
|
-
},
|
|
4266
|
+
}, La = { class: "status-text" }, Ra = {
|
|
4264
4267
|
key: 0,
|
|
4265
4268
|
class: "status-more"
|
|
4266
|
-
},
|
|
4269
|
+
}, za = {
|
|
4267
4270
|
key: 0,
|
|
4268
4271
|
class: "focus-meta"
|
|
4269
|
-
},
|
|
4272
|
+
}, Ba = { "data-role": "cursor" }, Va = { "data-role": "selection" }, Ha = {
|
|
4270
4273
|
class: "key-help",
|
|
4271
4274
|
"data-role": "key-help"
|
|
4272
|
-
},
|
|
4275
|
+
}, Ua = { class: "key-hint" }, Wa = {
|
|
4273
4276
|
key: 0,
|
|
4274
4277
|
class: "side-column",
|
|
4275
4278
|
"data-role": "side"
|
|
4276
|
-
},
|
|
4279
|
+
}, Ga = { "data-role": "mathml" }, Ka = { class: "output-actions" }, qa = { "data-role": "mathjson" }, Ja = { "data-role": "latex" }, Ya = { "data-role": "ast" }, Xa = "A CellML line must be an equation (… = …)", Za = /*#__PURE__*/ Wi(/* @__PURE__ */ l({
|
|
4277
4280
|
__name: "EquationWorkbench",
|
|
4278
4281
|
props: {
|
|
4279
4282
|
cellml: {
|
|
@@ -4338,7 +4341,7 @@ var va = [
|
|
|
4338
4341
|
function N() {
|
|
4339
4342
|
f(() => ve.value[A.value]?.focus());
|
|
4340
4343
|
}
|
|
4341
|
-
let P = new
|
|
4344
|
+
let P = new gi(), F = _(0);
|
|
4342
4345
|
function xe() {
|
|
4343
4346
|
return JSON.parse(JSON.stringify({
|
|
4344
4347
|
equations: C.value,
|
|
@@ -4346,8 +4349,8 @@ var va = [
|
|
|
4346
4349
|
active: A.value
|
|
4347
4350
|
}));
|
|
4348
4351
|
}
|
|
4349
|
-
function I(e = A.value, t =
|
|
4350
|
-
m.history && (P.checkpoint(xe,
|
|
4352
|
+
function I(e = A.value, t = pi) {
|
|
4353
|
+
m.history && (P.checkpoint(xe, hi(e, t)), F.value++);
|
|
4351
4354
|
}
|
|
4352
4355
|
function Se(e) {
|
|
4353
4356
|
e && (C.value = e.equations, E.value = e.lineIds, A.value = Math.min(e.active, e.equations.length - 1), F.value++, N());
|
|
@@ -4385,7 +4388,7 @@ var va = [
|
|
|
4385
4388
|
function ke(e, t) {
|
|
4386
4389
|
if (m.readonly) return;
|
|
4387
4390
|
let n = t.equations.length;
|
|
4388
|
-
if (n === 1) R(e,
|
|
4391
|
+
if (n === 1) R(e, zr(t.equations[0])(C.value[e]), pi), t.problems.length && k.value.set(E.value[e], t.problems);
|
|
4389
4392
|
else if (n > 1) {
|
|
4390
4393
|
I(e), Oe(t.equations, t.lineProblems);
|
|
4391
4394
|
for (let e of _t.value) h("line-commit", e, { reason: "paste" });
|
|
@@ -4394,7 +4397,7 @@ var va = [
|
|
|
4394
4397
|
z.value = n > 1 ? `Imported ${n} equations from Content MathML, replacing the lines there were.` : n === 0 ? t.problems[0] ?? "Nothing was imported." : null;
|
|
4395
4398
|
}
|
|
4396
4399
|
function Ae(e) {
|
|
4397
|
-
let t =
|
|
4400
|
+
let t = Ci(e);
|
|
4398
4401
|
return t ? (yt = "load", Oe(t.equations, t.lineProblems), j.value = null, z.value = null, P.clear(), F.value++, t) : {
|
|
4399
4402
|
equations: [],
|
|
4400
4403
|
problems: ["The MathML isn't well-formed XML, so nothing was loaded"],
|
|
@@ -4466,7 +4469,7 @@ var va = [
|
|
|
4466
4469
|
}
|
|
4467
4470
|
function We() {
|
|
4468
4471
|
let e = (j.value ?? "").trim();
|
|
4469
|
-
j.value = null, e && Ie(
|
|
4472
|
+
j.value = null, e && Ie(fi(e));
|
|
4470
4473
|
}
|
|
4471
4474
|
function Ge(e) {
|
|
4472
4475
|
if (/^[a-zA-Z0-9]$/.test(e.key)) j.value += e.key;
|
|
@@ -4535,18 +4538,18 @@ var va = [
|
|
|
4535
4538
|
function et(e) {
|
|
4536
4539
|
if (e.length === 0) return null;
|
|
4537
4540
|
let t = $e.get(e);
|
|
4538
|
-
return t || (t =
|
|
4541
|
+
return t || (t = qi(e), $e.set(e, t)), t;
|
|
4539
4542
|
}
|
|
4540
4543
|
let tt = t(() => C.value.map((e) => et(e.root))), nt = t(() => tt.value[A.value] ?? null);
|
|
4541
4544
|
function rt(e, t) {
|
|
4542
4545
|
let n = tt.value[t]?.ast;
|
|
4543
4546
|
return !m.cellml || !n || n.type === "Equal" ? null : {
|
|
4544
|
-
message:
|
|
4547
|
+
message: Xa,
|
|
4545
4548
|
atomIds: e.map((e) => e.id),
|
|
4546
4549
|
incomplete: !0
|
|
4547
4550
|
};
|
|
4548
4551
|
}
|
|
4549
|
-
let it =
|
|
4552
|
+
let it = Ki(() => m.issues), at = Ki(() => m.variableUnits ?? null), ot = t(() => {
|
|
4550
4553
|
let e = /* @__PURE__ */ new Map();
|
|
4551
4554
|
for (let t of it.value) e.set(t.lineId, [...e.get(t.lineId) ?? [], t]);
|
|
4552
4555
|
return e;
|
|
@@ -4556,8 +4559,8 @@ var va = [
|
|
|
4556
4559
|
let e = rt(n, t), i = [
|
|
4557
4560
|
...tt.value[t]?.diagnostics ?? [],
|
|
4558
4561
|
...e ? [e] : [],
|
|
4559
|
-
...
|
|
4560
|
-
], a =
|
|
4562
|
+
...ga(n, ot.value.get(E.value[t]) ?? [])
|
|
4563
|
+
], a = _a(n, at.value);
|
|
4561
4564
|
r = {
|
|
4562
4565
|
all: [...i, ...a],
|
|
4563
4566
|
complete: [...i.filter((e) => !e.incomplete), ...a],
|
|
@@ -4578,10 +4581,10 @@ var va = [
|
|
|
4578
4581
|
line: t,
|
|
4579
4582
|
message: e,
|
|
4580
4583
|
kind: "error"
|
|
4581
|
-
})), ...e.filter(
|
|
4584
|
+
})), ...e.filter(zi).map((e) => ({
|
|
4582
4585
|
line: t,
|
|
4583
4586
|
message: e.message,
|
|
4584
|
-
kind:
|
|
4587
|
+
kind: Ri(e) === "units" ? "units" : "error"
|
|
4585
4588
|
}))];
|
|
4586
4589
|
return n.filter((e, t) => n.findIndex((t) => t.message === e.message) === t);
|
|
4587
4590
|
})), ft = (e) => {
|
|
@@ -4611,7 +4614,7 @@ var va = [
|
|
|
4611
4614
|
let n = E.value[t], r = gt.value.get(e.root);
|
|
4612
4615
|
if (!r || r.id !== n) {
|
|
4613
4616
|
let i = (k.value.get(n)?.length ?? 0) + +!!rt(e.root, t);
|
|
4614
|
-
r =
|
|
4617
|
+
r = pa(n, e.root, tt.value[t], i), gt.value.set(e.root, r);
|
|
4615
4618
|
}
|
|
4616
4619
|
return r;
|
|
4617
4620
|
})), vt = "", yt = "load";
|
|
@@ -4621,7 +4624,7 @@ var va = [
|
|
|
4621
4624
|
let n = JSON.stringify(e);
|
|
4622
4625
|
n !== vt && (vt = n, h("equations-change", e, { source: t }));
|
|
4623
4626
|
}, { immediate: !0 });
|
|
4624
|
-
let bt = t(() => nt.value?.ast ?? null), xt = t(() => bt.value ?
|
|
4627
|
+
let bt = t(() => nt.value?.ast ?? null), xt = t(() => bt.value ? ua(M().root, "latex", x.value) : ""), St = t(() => bt.value ? ia(bt.value) : ""), Ct = t(() => bt.value ? da(M().root, x.value) : ""), wt = t(() => Qn(M().cursor)), Tt = t(() => {
|
|
4625
4628
|
let e = G(M());
|
|
4626
4629
|
return e ? dr(e) : null;
|
|
4627
4630
|
}), Et = _(!1), Dt = _("mathml");
|
|
@@ -4660,9 +4663,9 @@ var va = [
|
|
|
4660
4663
|
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
4664
|
async function It(e, t) {
|
|
4662
4665
|
let n = M(), r = G(n) ? ur(n) : n.root;
|
|
4663
|
-
r.length > 0 && (await kt(
|
|
4666
|
+
r.length > 0 && (await kt(ua(r, e, x.value)), Mt.value = t, window.clearTimeout(Nt), Nt = window.setTimeout(() => Mt.value = null, 1500)), N();
|
|
4664
4667
|
}
|
|
4665
|
-
let Lt = t(() =>
|
|
4668
|
+
let Lt = t(() => sa.map(({ format: e, label: t }) => {
|
|
4666
4669
|
let n = e === "mathml" && m.cellml ? `${t} (CellML)` : t;
|
|
4667
4670
|
return {
|
|
4668
4671
|
label: n,
|
|
@@ -4692,7 +4695,7 @@ var va = [
|
|
|
4692
4695
|
role: "toolbar",
|
|
4693
4696
|
"aria-label": "Equation tools"
|
|
4694
4697
|
}, [
|
|
4695
|
-
a("div",
|
|
4698
|
+
a("div", Sa, [(g(!0), i(e, null, v(S(xa), (e) => (g(), i("button", {
|
|
4696
4699
|
key: e.id,
|
|
4697
4700
|
type: "button",
|
|
4698
4701
|
class: p(["tool-button", { "has-gallery": !!e.sections }]),
|
|
@@ -4702,8 +4705,8 @@ var va = [
|
|
|
4702
4705
|
disabled: l.readonly,
|
|
4703
4706
|
onMousedown: u[0] ||= D(() => {}, ["prevent"]),
|
|
4704
4707
|
onClick: (t) => Xe(e, t)
|
|
4705
|
-
}, [a("span", { innerHTML: Qe(e.latex) }, null, 8,
|
|
4706
|
-
a("div",
|
|
4708
|
+
}, [a("span", { innerHTML: Qe(e.latex) }, null, 8, wa), e.sections ? (g(), i("i", Ta)) : r("", !0)], 42, Ca))), 128))]),
|
|
4709
|
+
a("div", Ea, [
|
|
4707
4710
|
c(S(O), {
|
|
4708
4711
|
icon: "pi pi-plus",
|
|
4709
4712
|
size: "small",
|
|
@@ -4747,7 +4750,7 @@ var va = [
|
|
|
4747
4750
|
onClick: Ce
|
|
4748
4751
|
}, null, 8, ["disabled"])) : r("", !0)
|
|
4749
4752
|
]),
|
|
4750
|
-
l.outputs ? (g(), i("div",
|
|
4753
|
+
l.outputs ? (g(), i("div", Da, [c(S(O), {
|
|
4751
4754
|
icon: "pi pi-copy",
|
|
4752
4755
|
label: H.value,
|
|
4753
4756
|
size: "small",
|
|
@@ -4774,17 +4777,17 @@ var va = [
|
|
|
4774
4777
|
"data-role": "gallery",
|
|
4775
4778
|
class: "me-gallery"
|
|
4776
4779
|
}, {
|
|
4777
|
-
default: T(() => [Ye.value ? (g(), i("div",
|
|
4780
|
+
default: T(() => [Ye.value ? (g(), i("div", Oa, [(g(!0), i(e, null, v(Ye.value.sections, (t, n) => (g(), i("div", {
|
|
4778
4781
|
key: n,
|
|
4779
4782
|
class: "gallery-section"
|
|
4780
|
-
}, [t.label ? (g(), i("div",
|
|
4783
|
+
}, [t.label ? (g(), i("div", ka, y(t.label), 1)) : r("", !0), a("div", Aa, [(g(!0), i(e, null, v(t.items, (e) => (g(), i("button", {
|
|
4781
4784
|
key: e.title,
|
|
4782
4785
|
type: "button",
|
|
4783
4786
|
class: "tool-button",
|
|
4784
4787
|
title: e.title,
|
|
4785
4788
|
onMousedown: u[7] ||= D(() => {}, ["prevent"]),
|
|
4786
4789
|
onClick: (t) => Ze(e.command)
|
|
4787
|
-
}, [a("span", { innerHTML: Qe(e.latex) }, null, 8,
|
|
4790
|
+
}, [a("span", { innerHTML: Qe(e.latex) }, null, 8, Ma)], 40, ja))), 128))])]))), 128))])) : r("", !0)]),
|
|
4788
4791
|
_: 1
|
|
4789
4792
|
}, 512),
|
|
4790
4793
|
a("div", {
|
|
@@ -4799,7 +4802,7 @@ var va = [
|
|
|
4799
4802
|
"data-line": t,
|
|
4800
4803
|
"data-line-id": E.value[t],
|
|
4801
4804
|
onFocusin: (e) => ze(t)
|
|
4802
|
-
}, [a("div",
|
|
4805
|
+
}, [a("div", Pa, y(t + 1), 1), c(Gi, {
|
|
4803
4806
|
ref_for: !0,
|
|
4804
4807
|
ref: (e) => ve.value[t] = e,
|
|
4805
4808
|
class: "equation-field",
|
|
@@ -4828,7 +4831,7 @@ var va = [
|
|
|
4828
4831
|
"onNavigate",
|
|
4829
4832
|
"onEdit",
|
|
4830
4833
|
"onImport"
|
|
4831
|
-
])], 42,
|
|
4834
|
+
])], 42, Na))), 128))], 544),
|
|
4832
4835
|
a("div", {
|
|
4833
4836
|
class: p(["status-bar", V.value ? `status-${V.value.kind}` : null]),
|
|
4834
4837
|
"data-role": "status",
|
|
@@ -4837,17 +4840,17 @@ var va = [
|
|
|
4837
4840
|
role: "status",
|
|
4838
4841
|
onMousedown: u[8] ||= D(() => {}, ["prevent"]),
|
|
4839
4842
|
onClick: mt
|
|
4840
|
-
}, [V.value?.kind === "command" ? (g(), i("span",
|
|
4843
|
+
}, [V.value?.kind === "command" ? (g(), i("span", Ia, [
|
|
4841
4844
|
u[10] ||= a("span", { class: "command-slash" }, "\\", -1),
|
|
4842
4845
|
s(y(V.value.text), 1),
|
|
4843
4846
|
u[11] ||= a("span", { class: "command-caret" }, null, -1)
|
|
4844
|
-
])) : V.value ? (g(), i(e, { key: 1 }, [a("span",
|
|
4845
|
-
l.debug ? (g(), i("p",
|
|
4847
|
+
])) : V.value ? (g(), i(e, { key: 1 }, [a("span", La, y(V.value.text), 1), V.value.more ? (g(), i("span", Ra, "+" + y(V.value.more) + " more", 1)) : r("", !0)], 64)) : r("", !0)], 42, Fa),
|
|
4848
|
+
l.debug ? (g(), i("p", za, [
|
|
4846
4849
|
u[13] ||= s(" Cursor: ", -1),
|
|
4847
|
-
a("span",
|
|
4848
|
-
Tt.value ? (g(), i(e, { key: 0 }, [u[12] ||= s(" · Selection: ", -1), a("span",
|
|
4850
|
+
a("span", Ba, y(wt.value), 1),
|
|
4851
|
+
Tt.value ? (g(), i(e, { key: 0 }, [u[12] ||= s(" · Selection: ", -1), a("span", Va, y(Tt.value), 1)], 64)) : r("", !0)
|
|
4849
4852
|
])) : r("", !0),
|
|
4850
|
-
a("details",
|
|
4853
|
+
a("details", Ha, [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", Ua, [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 }, [
|
|
4851
4854
|
u[14] ||= s(" · ", -1),
|
|
4852
4855
|
u[15] ||= a("kbd", null, "Ctrl", -1),
|
|
4853
4856
|
u[16] ||= s("+", -1),
|
|
@@ -4855,7 +4858,7 @@ var va = [
|
|
|
4855
4858
|
u[18] ||= s(" undo", -1)
|
|
4856
4859
|
], 64)) : r("", !0)])])
|
|
4857
4860
|
], 512),
|
|
4858
|
-
t.$slots.side ? (g(), i("aside",
|
|
4861
|
+
t.$slots.side ? (g(), i("aside", Wa, [ne(t.$slots, "side", {}, void 0, !0)])) : r("", !0),
|
|
4859
4862
|
l.outputs ? (g(), n(S(ce), {
|
|
4860
4863
|
key: 1,
|
|
4861
4864
|
class: "output-card",
|
|
@@ -4906,26 +4909,26 @@ var va = [
|
|
|
4906
4909
|
}), c(S(me), null, {
|
|
4907
4910
|
default: T(() => [
|
|
4908
4911
|
c(S(pe), { value: "mathml" }, {
|
|
4909
|
-
default: T(() => [a("pre",
|
|
4912
|
+
default: T(() => [a("pre", Ga, y(Ct.value), 1)]),
|
|
4910
4913
|
_: 1
|
|
4911
4914
|
}),
|
|
4912
4915
|
c(S(pe), { value: "mathjson" }, {
|
|
4913
|
-
default: T(() => [a("div",
|
|
4916
|
+
default: T(() => [a("div", Ka, [c(S(O), {
|
|
4914
4917
|
icon: "pi pi-copy",
|
|
4915
4918
|
label: Et.value ? "Copied" : "Copy MathJSON",
|
|
4916
4919
|
size: "small",
|
|
4917
4920
|
text: "",
|
|
4918
4921
|
disabled: !St.value,
|
|
4919
4922
|
onClick: At
|
|
4920
|
-
}, null, 8, ["label", "disabled"])]), a("pre",
|
|
4923
|
+
}, null, 8, ["label", "disabled"])]), a("pre", qa, y(St.value), 1)]),
|
|
4921
4924
|
_: 1
|
|
4922
4925
|
}),
|
|
4923
4926
|
c(S(pe), { value: "latex" }, {
|
|
4924
|
-
default: T(() => [a("pre",
|
|
4927
|
+
default: T(() => [a("pre", Ja, y(xt.value), 1)]),
|
|
4925
4928
|
_: 1
|
|
4926
4929
|
}),
|
|
4927
4930
|
c(S(pe), { value: "ast" }, {
|
|
4928
|
-
default: T(() => [a("pre",
|
|
4931
|
+
default: T(() => [a("pre", Ya, y(bt.value ? JSON.stringify(bt.value, null, 2) : ""), 1)]),
|
|
4929
4932
|
_: 1
|
|
4930
4933
|
})
|
|
4931
4934
|
]),
|
|
@@ -4937,7 +4940,7 @@ var va = [
|
|
|
4937
4940
|
})) : r("", !0)
|
|
4938
4941
|
], 34));
|
|
4939
4942
|
}
|
|
4940
|
-
}), [["__scopeId", "data-v-2efa820f"]]),
|
|
4943
|
+
}), [["__scopeId", "data-v-2efa820f"]]), Qa = "new units", $a = [
|
|
4941
4944
|
"yotta",
|
|
4942
4945
|
"zetta",
|
|
4943
4946
|
"exa",
|
|
@@ -4958,15 +4961,15 @@ var va = [
|
|
|
4958
4961
|
"atto",
|
|
4959
4962
|
"zepto",
|
|
4960
4963
|
"yocto"
|
|
4961
|
-
],
|
|
4962
|
-
function
|
|
4964
|
+
], eo = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
4965
|
+
function to(e, t, n) {
|
|
4963
4966
|
let r = [], { name: i, parts: a } = e;
|
|
4964
|
-
return i ?
|
|
4967
|
+
return i ? eo.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) => {
|
|
4965
4968
|
let s = a.length > 1 ? `Part ${o + 1}: ` : "";
|
|
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 &&
|
|
4967
|
-
}), i &&
|
|
4969
|
+
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 && !$a.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`);
|
|
4970
|
+
}), i && eo.test(i) && no(i, a, t) && r.push(`${i} would be made of itself, through other new units`), r;
|
|
4968
4971
|
}
|
|
4969
|
-
function
|
|
4972
|
+
function no(e, t, n) {
|
|
4970
4973
|
let r = /* @__PURE__ */ new Set(), i = (t) => {
|
|
4971
4974
|
if (t === e) return !0;
|
|
4972
4975
|
if (r.has(t)) return !1;
|
|
@@ -4976,17 +4979,17 @@ function to(e, t, n) {
|
|
|
4976
4979
|
};
|
|
4977
4980
|
return t.some((t) => t.units !== e && i(t.units));
|
|
4978
4981
|
}
|
|
4979
|
-
function
|
|
4982
|
+
function ro(e, t) {
|
|
4980
4983
|
return t.filter((t) => t.parts.some((t) => t.units === e)).map((e) => e.name);
|
|
4981
4984
|
}
|
|
4982
|
-
function
|
|
4985
|
+
function io(e) {
|
|
4983
4986
|
return e.parts.map((e) => {
|
|
4984
4987
|
let t = [e.multiplier !== void 0 && e.multiplier !== 1 ? e.multiplier : ""].concat(e.prefix ?? "", e.units).filter((e) => e !== "").join(" "), n = e.exponent ?? 1;
|
|
4985
4988
|
return n === 1 ? t : t.includes(" ") ? `(${t})^${n}` : `${t}^${n}`;
|
|
4986
4989
|
}).join(" · ");
|
|
4987
4990
|
}
|
|
4988
|
-
var
|
|
4989
|
-
function
|
|
4991
|
+
var ao = (e) => e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
4992
|
+
function oo(e, t = "new_units") {
|
|
4990
4993
|
let n = [], r = (t, i) => {
|
|
4991
4994
|
if (!(n.includes(t) || i.has(t.name))) {
|
|
4992
4995
|
i.add(t.name);
|
|
@@ -5000,20 +5003,20 @@ function ao(e, t = "new_units") {
|
|
|
5000
5003
|
for (let t of e) r(t, /* @__PURE__ */ new Set());
|
|
5001
5004
|
let i = n.map((e) => {
|
|
5002
5005
|
let t = e.parts.map((e) => ` <unit${[
|
|
5003
|
-
e.prefix ? ` prefix="${
|
|
5004
|
-
` units="${
|
|
5006
|
+
e.prefix ? ` prefix="${ao(e.prefix)}"` : "",
|
|
5007
|
+
` units="${ao(e.units)}"`,
|
|
5005
5008
|
e.exponent !== void 0 && e.exponent !== 1 ? ` exponent="${e.exponent}"` : "",
|
|
5006
5009
|
e.multiplier !== void 0 && e.multiplier !== 1 ? ` multiplier="${e.multiplier}"` : ""
|
|
5007
5010
|
].join("")}/>`);
|
|
5008
5011
|
return [
|
|
5009
|
-
` <units name="${
|
|
5012
|
+
` <units name="${ao(e.name)}">`,
|
|
5010
5013
|
...t,
|
|
5011
5014
|
" </units>"
|
|
5012
5015
|
].join("\n");
|
|
5013
5016
|
});
|
|
5014
5017
|
return [
|
|
5015
5018
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
|
|
5016
|
-
`<model xmlns="http://www.cellml.org/cellml/2.0#" name="${
|
|
5019
|
+
`<model xmlns="http://www.cellml.org/cellml/2.0#" name="${ao(t)}">`,
|
|
5017
5020
|
...i,
|
|
5018
5021
|
"</model>",
|
|
5019
5022
|
""
|
|
@@ -5021,15 +5024,15 @@ function ao(e, t = "new_units") {
|
|
|
5021
5024
|
}
|
|
5022
5025
|
//#endregion
|
|
5023
5026
|
//#region src/units/UnitsDefinitionForm.vue?vue&type=script&setup=true&lang.ts
|
|
5024
|
-
var
|
|
5027
|
+
var so = { class: "form-name" }, co = { class: "form-parts" }, lo = ["onUpdate:modelValue", "aria-label"], uo = ["value"], fo = [
|
|
5025
5028
|
"onUpdate:modelValue",
|
|
5026
5029
|
"list",
|
|
5027
5030
|
"aria-label"
|
|
5028
|
-
],
|
|
5031
|
+
], po = ["onUpdate:modelValue", "aria-label"], mo = ["onUpdate:modelValue", "aria-label"], ho = ["id"], go = ["value"], _o = {
|
|
5029
5032
|
key: 0,
|
|
5030
5033
|
class: "form-problems",
|
|
5031
5034
|
"data-role": "units-form-problems"
|
|
5032
|
-
},
|
|
5035
|
+
}, vo = { class: "form-actions" }, yo = /*#__PURE__*/ Wi(/* @__PURE__ */ l({
|
|
5033
5036
|
__name: "UnitsDefinitionForm",
|
|
5034
5037
|
props: {
|
|
5035
5038
|
definition: {},
|
|
@@ -5056,7 +5059,7 @@ var oo = { class: "form-name" }, so = { class: "form-parts" }, co = ["onUpdate:m
|
|
|
5056
5059
|
...n !== void 0 && n !== 1 ? { multiplier: n } : {}
|
|
5057
5060
|
};
|
|
5058
5061
|
})
|
|
5059
|
-
})), h = t(() =>
|
|
5062
|
+
})), h = t(() => to(te.value, s.others, s.known));
|
|
5060
5063
|
function ne() {
|
|
5061
5064
|
m.value = !0, h.value.length === 0 && l("save", te.value);
|
|
5062
5065
|
}
|
|
@@ -5066,7 +5069,7 @@ var oo = { class: "form-name" }, so = { class: "form-parts" }, co = ["onUpdate:m
|
|
|
5066
5069
|
"data-role": "units-form",
|
|
5067
5070
|
onSubmit: D(ne, ["prevent"])
|
|
5068
5071
|
}, [
|
|
5069
|
-
a("label",
|
|
5072
|
+
a("label", so, [o[3] ||= a("span", null, "Name", -1), E(a("input", {
|
|
5070
5073
|
"onUpdate:modelValue": o[0] ||= (e) => f.value = e,
|
|
5071
5074
|
type: "text",
|
|
5072
5075
|
spellcheck: "false",
|
|
@@ -5074,7 +5077,7 @@ var oo = { class: "form-name" }, so = { class: "form-parts" }, co = ["onUpdate:m
|
|
|
5074
5077
|
placeholder: "mV_per_ms",
|
|
5075
5078
|
"data-role": "units-form-name"
|
|
5076
5079
|
}, null, 512), [[w, f.value]])]),
|
|
5077
|
-
a("table",
|
|
5080
|
+
a("table", co, [o[5] ||= a("thead", null, [a("tr", null, [
|
|
5078
5081
|
a("th", { scope: "col" }, "Prefix"),
|
|
5079
5082
|
a("th", { scope: "col" }, "Units"),
|
|
5080
5083
|
a("th", {
|
|
@@ -5093,10 +5096,10 @@ var oo = { class: "form-name" }, so = { class: "form-parts" }, co = ["onUpdate:m
|
|
|
5093
5096
|
a("td", null, [E(a("select", {
|
|
5094
5097
|
"onUpdate:modelValue": (e) => t.prefix = e,
|
|
5095
5098
|
"aria-label": `Prefix of part ${n + 1}`
|
|
5096
|
-
}, [o[4] ||= a("option", { value: "" }, "—", -1), (g(!0), i(e, null, v(S(
|
|
5099
|
+
}, [o[4] ||= a("option", { value: "" }, "—", -1), (g(!0), i(e, null, v(S($a), (e) => (g(), i("option", {
|
|
5097
5100
|
key: e,
|
|
5098
5101
|
value: e
|
|
5099
|
-
}, y(e), 9,
|
|
5102
|
+
}, y(e), 9, uo))), 128))], 8, lo), [[ae, t.prefix]])]),
|
|
5100
5103
|
a("td", null, [E(a("input", {
|
|
5101
5104
|
"onUpdate:modelValue": (e) => t.units = e,
|
|
5102
5105
|
type: "text",
|
|
@@ -5105,7 +5108,7 @@ var oo = { class: "form-name" }, so = { class: "form-parts" }, co = ["onUpdate:m
|
|
|
5105
5108
|
autocomplete: "off",
|
|
5106
5109
|
placeholder: "second",
|
|
5107
5110
|
"aria-label": `Units of part ${n + 1}`
|
|
5108
|
-
}, null, 8,
|
|
5111
|
+
}, null, 8, fo), [[w, t.units]])]),
|
|
5109
5112
|
a("td", null, [E(a("input", {
|
|
5110
5113
|
"onUpdate:modelValue": (e) => t.exponent = e,
|
|
5111
5114
|
class: "number",
|
|
@@ -5113,7 +5116,7 @@ var oo = { class: "form-name" }, so = { class: "form-parts" }, co = ["onUpdate:m
|
|
|
5113
5116
|
inputmode: "decimal",
|
|
5114
5117
|
placeholder: "1",
|
|
5115
5118
|
"aria-label": `Exponent of part ${n + 1}`
|
|
5116
|
-
}, null, 8,
|
|
5119
|
+
}, null, 8, po), [[w, t.exponent]])]),
|
|
5117
5120
|
a("td", null, [E(a("input", {
|
|
5118
5121
|
"onUpdate:modelValue": (e) => t.multiplier = e,
|
|
5119
5122
|
class: "number",
|
|
@@ -5121,7 +5124,7 @@ var oo = { class: "form-name" }, so = { class: "form-parts" }, co = ["onUpdate:m
|
|
|
5121
5124
|
inputmode: "decimal",
|
|
5122
5125
|
placeholder: "1",
|
|
5123
5126
|
"aria-label": `Multiplier of part ${n + 1}`
|
|
5124
|
-
}, null, 8,
|
|
5127
|
+
}, null, 8, mo), [[w, t.multiplier]])]),
|
|
5125
5128
|
a("td", null, [c(S(O), {
|
|
5126
5129
|
icon: "pi pi-times",
|
|
5127
5130
|
size: "small",
|
|
@@ -5141,9 +5144,9 @@ var oo = { class: "form-name" }, so = { class: "form-parts" }, co = ["onUpdate:m
|
|
|
5141
5144
|
a("datalist", { id: S(re) }, [(g(!0), i(e, null, v(n.choices, (e) => (g(), i("option", {
|
|
5142
5145
|
key: e,
|
|
5143
5146
|
value: e
|
|
5144
|
-
}, null, 8,
|
|
5145
|
-
m.value && h.value.length ? (g(), i("ul",
|
|
5146
|
-
a("div",
|
|
5147
|
+
}, null, 8, go))), 128))], 8, ho),
|
|
5148
|
+
m.value && h.value.length ? (g(), i("ul", _o, [(g(!0), i(e, null, v(h.value, (e) => (g(), i("li", { key: e }, y(e), 1))), 128))])) : r("", !0),
|
|
5149
|
+
a("div", vo, [
|
|
5147
5150
|
c(S(O), {
|
|
5148
5151
|
icon: "pi pi-plus",
|
|
5149
5152
|
label: "Part",
|
|
@@ -5174,7 +5177,7 @@ var oo = { class: "form-name" }, so = { class: "form-parts" }, co = ["onUpdate:m
|
|
|
5174
5177
|
}), [["__scopeId", "data-v-effe158e"]]);
|
|
5175
5178
|
//#endregion
|
|
5176
5179
|
//#region src/units/panel.ts
|
|
5177
|
-
function
|
|
5180
|
+
function bo(e, t, n) {
|
|
5178
5181
|
let r = [...new Set(e.flatMap((e) => e.variables))], i = Object.keys(t).filter((e) => !r.includes(e)), a = n ? new Set(n) : null;
|
|
5179
5182
|
return [...r, ...i].map((e) => {
|
|
5180
5183
|
let n = t[e] ?? "", i = n ? a && !a.has(n) ? "unknown" : "ok" : "missing";
|
|
@@ -5186,11 +5189,11 @@ function yo(e, t, n) {
|
|
|
5186
5189
|
};
|
|
5187
5190
|
});
|
|
5188
5191
|
}
|
|
5189
|
-
function
|
|
5192
|
+
function xo(e, t, n) {
|
|
5190
5193
|
let r = { ...e }, i = n.trim();
|
|
5191
5194
|
return i ? r[t] = i : delete r[t], r;
|
|
5192
5195
|
}
|
|
5193
|
-
function
|
|
5196
|
+
function So(e, t) {
|
|
5194
5197
|
let n = [...e];
|
|
5195
5198
|
for (let e of t) {
|
|
5196
5199
|
let t = n.findIndex((t) => t.name === e.name);
|
|
@@ -5200,67 +5203,67 @@ function xo(e, t) {
|
|
|
5200
5203
|
}
|
|
5201
5204
|
//#endregion
|
|
5202
5205
|
//#region src/units/UnitsPanel.vue?vue&type=script&setup=true&lang.ts
|
|
5203
|
-
var
|
|
5206
|
+
var Co = { class: "units-title" }, wo = { "data-role": "units-summary" }, To = {
|
|
5204
5207
|
class: "units-section",
|
|
5205
5208
|
"aria-labelledby": "units-files-title"
|
|
5206
|
-
},
|
|
5209
|
+
}, Eo = { class: "section-head" }, Do = { class: "section-actions" }, Oo = {
|
|
5207
5210
|
key: 0,
|
|
5208
5211
|
class: "hint"
|
|
5209
|
-
},
|
|
5212
|
+
}, ko = {
|
|
5210
5213
|
key: 1,
|
|
5211
5214
|
class: "files",
|
|
5212
5215
|
"data-role": "units-files"
|
|
5213
|
-
},
|
|
5216
|
+
}, Ao = ["data-file"], jo = { class: "file-head" }, Mo = { class: "file-name" }, No = { class: "file-count" }, Po = {
|
|
5214
5217
|
key: 0,
|
|
5215
5218
|
class: "units-names"
|
|
5216
|
-
},
|
|
5219
|
+
}, Fo = {
|
|
5217
5220
|
key: 1,
|
|
5218
5221
|
class: "problems",
|
|
5219
5222
|
"data-role": "units-problems"
|
|
5220
|
-
},
|
|
5223
|
+
}, Io = {
|
|
5221
5224
|
class: "units-section",
|
|
5222
5225
|
"aria-labelledby": "units-new-title",
|
|
5223
5226
|
"data-role": "new-units"
|
|
5224
|
-
},
|
|
5227
|
+
}, Lo = { class: "section-head" }, Ro = { class: "section-actions" }, zo = {
|
|
5225
5228
|
key: 0,
|
|
5226
5229
|
class: "hint"
|
|
5227
|
-
},
|
|
5230
|
+
}, Bo = {
|
|
5228
5231
|
key: 1,
|
|
5229
5232
|
class: "new-units"
|
|
5230
|
-
},
|
|
5233
|
+
}, Vo = ["data-units"], Ho = {
|
|
5231
5234
|
key: 1,
|
|
5232
5235
|
class: "new-units-row"
|
|
5233
|
-
},
|
|
5236
|
+
}, Uo = { class: "new-units-name" }, Wo = {
|
|
5234
5237
|
class: "new-units-definition",
|
|
5235
5238
|
"data-role": "new-units-definition"
|
|
5236
|
-
},
|
|
5239
|
+
}, Go = {
|
|
5237
5240
|
key: 3,
|
|
5238
5241
|
class: "problems",
|
|
5239
5242
|
"data-role": "new-units-problems"
|
|
5240
|
-
},
|
|
5243
|
+
}, Ko = {
|
|
5241
5244
|
class: "units-section",
|
|
5242
5245
|
"aria-labelledby": "units-variables-title"
|
|
5243
|
-
},
|
|
5246
|
+
}, qo = { class: "section-head" }, Jo = {
|
|
5244
5247
|
key: 0,
|
|
5245
5248
|
class: "missing-count",
|
|
5246
5249
|
"data-role": "missing-count"
|
|
5247
|
-
},
|
|
5250
|
+
}, Yo = {
|
|
5248
5251
|
key: 0,
|
|
5249
5252
|
class: "hint"
|
|
5250
|
-
},
|
|
5253
|
+
}, Xo = {
|
|
5251
5254
|
key: 1,
|
|
5252
5255
|
class: "variables",
|
|
5253
5256
|
"data-role": "variables"
|
|
5254
|
-
},
|
|
5257
|
+
}, Zo = ["data-variable", "data-state"], Qo = {
|
|
5255
5258
|
scope: "row",
|
|
5256
5259
|
class: "variable-name"
|
|
5257
|
-
},
|
|
5260
|
+
}, $o = [
|
|
5258
5261
|
"value",
|
|
5259
5262
|
"list",
|
|
5260
5263
|
"aria-label",
|
|
5261
5264
|
"aria-invalid",
|
|
5262
5265
|
"onChange"
|
|
5263
|
-
],
|
|
5266
|
+
], es = { class: "variable-state" }, ts = ["id"], ns = ["value"], rs = /*#__PURE__*/ Wi(/* @__PURE__ */ l({
|
|
5264
5267
|
__name: "UnitsPanel",
|
|
5265
5268
|
props: /*@__PURE__*/ d({
|
|
5266
5269
|
status: {},
|
|
@@ -5287,7 +5290,7 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5287
5290
|
"update:newUnits"
|
|
5288
5291
|
],
|
|
5289
5292
|
setup(o) {
|
|
5290
|
-
let l = o, u = ie(o, "sources"), d = ie(o, "variableUnits"), f = ie(o, "newUnits"), m = t(() => l.status === "ready"), ee = t(() =>
|
|
5293
|
+
let l = o, u = ie(o, "sources"), d = ie(o, "variableUnits"), f = ie(o, "newUnits"), m = t(() => l.status === "ready"), ee = t(() => bo(l.lines, d.value, m.value ? l.unitsNames : null)), te = t(() => ee.value.filter((e) => e.state === "missing").length), h = t(() => ({
|
|
5291
5294
|
ready: {
|
|
5292
5295
|
value: "libCellML",
|
|
5293
5296
|
severity: "success"
|
|
@@ -5316,12 +5319,12 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5316
5319
|
name: e.name,
|
|
5317
5320
|
text: await e.text()
|
|
5318
5321
|
})));
|
|
5319
|
-
r.length && (u.value =
|
|
5322
|
+
r.length && (u.value = So(u.value, r));
|
|
5320
5323
|
}
|
|
5321
5324
|
function w(e) {
|
|
5322
5325
|
u.value = u.value.filter((t) => t.name !== e);
|
|
5323
5326
|
}
|
|
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(
|
|
5327
|
+
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(Qa));
|
|
5325
5328
|
function pe(e) {
|
|
5326
5329
|
let t = [...f.value], n = D.value;
|
|
5327
5330
|
if (n == null) t.push(e);
|
|
@@ -5342,7 +5345,7 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5342
5345
|
}
|
|
5343
5346
|
let he = C();
|
|
5344
5347
|
function _e(e, t) {
|
|
5345
|
-
d.value =
|
|
5348
|
+
d.value = xo(d.value, e, t.target.value);
|
|
5346
5349
|
}
|
|
5347
5350
|
let k = {
|
|
5348
5351
|
ok: "",
|
|
@@ -5354,14 +5357,14 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5354
5357
|
"data-role": "units-panel",
|
|
5355
5358
|
"data-status": o.status
|
|
5356
5359
|
}, {
|
|
5357
|
-
title: T(() => [a("div",
|
|
5360
|
+
title: T(() => [a("div", Co, [l[4] ||= a("span", null, "Units", -1), c(S(ge), {
|
|
5358
5361
|
severity: h.value.severity,
|
|
5359
5362
|
value: h.value.value,
|
|
5360
5363
|
"data-role": "units-status"
|
|
5361
5364
|
}, null, 8, ["severity", "value"])])]),
|
|
5362
|
-
subtitle: T(() => [a("span",
|
|
5365
|
+
subtitle: T(() => [a("span", wo, y(re.value), 1)]),
|
|
5363
5366
|
content: T(() => [
|
|
5364
|
-
a("section",
|
|
5367
|
+
a("section", To, [a("div", Eo, [l[5] ||= a("h3", { id: "units-files-title" }, "Units files", -1), a("div", Do, [
|
|
5365
5368
|
ne(t.$slots, "actions", {}, void 0, !0),
|
|
5366
5369
|
c(S(O), {
|
|
5367
5370
|
icon: "pi pi-folder-open",
|
|
@@ -5382,7 +5385,7 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5382
5385
|
"data-role": "units-file-input",
|
|
5383
5386
|
onChange: ae
|
|
5384
5387
|
}, null, 544)
|
|
5385
|
-
])]), u.value.length === 0 ? (g(), i("p",
|
|
5388
|
+
])]), u.value.length === 0 ? (g(), i("p", Oo, [...l[6] ||= [
|
|
5386
5389
|
s(" Built-in units (", -1),
|
|
5387
5390
|
a("code", null, "second", -1),
|
|
5388
5391
|
s(", ", -1),
|
|
@@ -5390,13 +5393,13 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5390
5393
|
s(", ", -1),
|
|
5391
5394
|
a("code", null, "volt", -1),
|
|
5392
5395
|
s(", …) are always available. Load CellML files for others; only their units are kept. ", -1)
|
|
5393
|
-
]])) : (g(), i("ul",
|
|
5396
|
+
]])) : (g(), i("ul", ko, [(g(!0), i(e, null, v(u.value, (t) => (g(), i("li", {
|
|
5394
5397
|
key: t.name,
|
|
5395
5398
|
"data-file": t.name
|
|
5396
5399
|
}, [
|
|
5397
|
-
a("div",
|
|
5398
|
-
a("span",
|
|
5399
|
-
a("span",
|
|
5400
|
+
a("div", jo, [
|
|
5401
|
+
a("span", Mo, y(t.name), 1),
|
|
5402
|
+
a("span", No, y(m.value ? b(E(t.name).length, "units definition") : ""), 1),
|
|
5400
5403
|
c(S(O), {
|
|
5401
5404
|
icon: "pi pi-times",
|
|
5402
5405
|
size: "small",
|
|
@@ -5408,11 +5411,11 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5408
5411
|
onClick: (e) => w(t.name)
|
|
5409
5412
|
}, null, 8, ["aria-label", "onClick"])
|
|
5410
5413
|
]),
|
|
5411
|
-
E(t.name).length ? (g(), i("div",
|
|
5412
|
-
oe(t.name).length ? (g(), i("ul",
|
|
5413
|
-
], 8,
|
|
5414
|
-
a("section",
|
|
5415
|
-
a("div",
|
|
5414
|
+
E(t.name).length ? (g(), i("div", Po, [(g(!0), i(e, null, v(E(t.name), (e) => (g(), i("code", { key: e }, y(e), 1))), 128))])) : r("", !0),
|
|
5415
|
+
oe(t.name).length ? (g(), i("ul", Fo, [(g(!0), i(e, null, v(oe(t.name), (e, t) => (g(), i("li", { key: t }, y(e.message), 1))), 128))])) : r("", !0)
|
|
5416
|
+
], 8, Ao))), 128))]))]),
|
|
5417
|
+
a("section", Io, [
|
|
5418
|
+
a("div", Lo, [l[7] ||= a("h3", { id: "units-new-title" }, "New units", -1), a("div", Ro, [ne(t.$slots, "new-units-actions", { definitions: f.value }, void 0, !0), c(S(O), {
|
|
5416
5419
|
icon: "pi pi-plus",
|
|
5417
5420
|
label: "Define units",
|
|
5418
5421
|
size: "small",
|
|
@@ -5422,11 +5425,11 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5422
5425
|
title: "Define units of your own, kept in a file apart from the units files",
|
|
5423
5426
|
onClick: l[1] ||= (e) => D.value = null
|
|
5424
5427
|
}, null, 8, ["disabled"])])]),
|
|
5425
|
-
f.value.length === 0 && D.value === void 0 ? (g(), i("p",
|
|
5426
|
-
f.value.length ? (g(), i("ul",
|
|
5428
|
+
f.value.length === 0 && D.value === void 0 ? (g(), i("p", zo, " Units you define are kept in a units file of their own, apart from the files loaded. ")) : r("", !0),
|
|
5429
|
+
f.value.length ? (g(), i("ul", Bo, [(g(!0), i(e, null, v(f.value, (e, t) => (g(), i("li", {
|
|
5427
5430
|
key: e.name,
|
|
5428
5431
|
"data-units": e.name
|
|
5429
|
-
}, [D.value === t ? (g(), n(
|
|
5432
|
+
}, [D.value === t ? (g(), n(yo, {
|
|
5430
5433
|
key: 0,
|
|
5431
5434
|
definition: e,
|
|
5432
5435
|
others: le.value,
|
|
@@ -5439,9 +5442,9 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5439
5442
|
"others",
|
|
5440
5443
|
"known",
|
|
5441
5444
|
"choices"
|
|
5442
|
-
])) : (g(), i("div",
|
|
5443
|
-
a("code",
|
|
5444
|
-
a("span",
|
|
5445
|
+
])) : (g(), i("div", Ho, [
|
|
5446
|
+
a("code", Uo, y(e.name), 1),
|
|
5447
|
+
a("span", Wo, " = " + y(S(io)(e)), 1),
|
|
5445
5448
|
c(S(O), {
|
|
5446
5449
|
icon: "pi pi-pencil",
|
|
5447
5450
|
size: "small",
|
|
@@ -5464,8 +5467,8 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5464
5467
|
rounded: "",
|
|
5465
5468
|
severity: "secondary",
|
|
5466
5469
|
"aria-label": `Remove ${e.name}`,
|
|
5467
|
-
title: S(
|
|
5468
|
-
disabled: D.value !== void 0 || S(
|
|
5470
|
+
title: S(ro)(e.name, f.value).length ? `Used by ${S(ro)(e.name, f.value).join(", ")}` : "Remove these units",
|
|
5471
|
+
disabled: D.value !== void 0 || S(ro)(e.name, f.value).length > 0,
|
|
5469
5472
|
onClick: (e) => me(t)
|
|
5470
5473
|
}, null, 8, [
|
|
5471
5474
|
"aria-label",
|
|
@@ -5473,8 +5476,8 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5473
5476
|
"disabled",
|
|
5474
5477
|
"onClick"
|
|
5475
5478
|
])
|
|
5476
|
-
]))], 8,
|
|
5477
|
-
D.value === null ? (g(), n(
|
|
5479
|
+
]))], 8, Vo))), 128))])) : r("", !0),
|
|
5480
|
+
D.value === null ? (g(), n(yo, {
|
|
5478
5481
|
key: 2,
|
|
5479
5482
|
others: le.value,
|
|
5480
5483
|
known: ue.value,
|
|
@@ -5486,17 +5489,17 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5486
5489
|
"known",
|
|
5487
5490
|
"choices"
|
|
5488
5491
|
])) : r("", !0),
|
|
5489
|
-
fe.value.length ? (g(), i("ul",
|
|
5492
|
+
fe.value.length ? (g(), i("ul", Go, [(g(!0), i(e, null, v(fe.value, (e, t) => (g(), i("li", { key: t }, y(e.message), 1))), 128))])) : r("", !0)
|
|
5490
5493
|
]),
|
|
5491
|
-
a("section",
|
|
5492
|
-
a("div",
|
|
5493
|
-
ee.value.length === 0 ? (g(), i("p",
|
|
5494
|
+
a("section", Ko, [
|
|
5495
|
+
a("div", qo, [l[8] ||= a("h3", { id: "units-variables-title" }, "Variables", -1), te.value ? (g(), i("span", Jo, y(b(te.value, "variable")) + " without units ", 1)) : r("", !0)]),
|
|
5496
|
+
ee.value.length === 0 ? (g(), i("p", Yo, " The variables in your equations are listed here, to give each one its units. ")) : (g(), i("table", Xo, [a("tbody", null, [(g(!0), i(e, null, v(ee.value, (t) => (g(), i("tr", {
|
|
5494
5497
|
key: t.name,
|
|
5495
5498
|
class: p([`state-${t.state}`, { unused: !t.used }]),
|
|
5496
5499
|
"data-variable": t.name,
|
|
5497
5500
|
"data-state": t.state
|
|
5498
5501
|
}, [
|
|
5499
|
-
a("th",
|
|
5502
|
+
a("th", Qo, y(t.name), 1),
|
|
5500
5503
|
a("td", null, [a("input", {
|
|
5501
5504
|
class: "units-input",
|
|
5502
5505
|
type: "text",
|
|
@@ -5508,8 +5511,8 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5508
5511
|
"aria-label": `Units of ${t.name}`,
|
|
5509
5512
|
"aria-invalid": t.state !== "ok",
|
|
5510
5513
|
onChange: (e) => _e(t.name, e)
|
|
5511
|
-
}, null, 40,
|
|
5512
|
-
a("td",
|
|
5514
|
+
}, null, 40, $o)]),
|
|
5515
|
+
a("td", es, [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), {
|
|
5513
5516
|
icon: "pi pi-times",
|
|
5514
5517
|
size: "small",
|
|
5515
5518
|
text: "",
|
|
@@ -5517,13 +5520,13 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5517
5520
|
severity: "secondary",
|
|
5518
5521
|
"aria-label": `Forget the units of ${t.name}`,
|
|
5519
5522
|
title: "Forget these units",
|
|
5520
|
-
onClick: (e) => d.value = S(
|
|
5523
|
+
onClick: (e) => d.value = S(xo)(d.value, t.name, "")
|
|
5521
5524
|
}, null, 8, ["aria-label", "onClick"])], 64))])
|
|
5522
|
-
], 10,
|
|
5525
|
+
], 10, Zo))), 128))])])),
|
|
5523
5526
|
a("datalist", { id: S(he) }, [(g(!0), i(e, null, v(o.unitsNames, (e) => (g(), i("option", {
|
|
5524
5527
|
key: e,
|
|
5525
5528
|
value: e
|
|
5526
|
-
}, null, 8,
|
|
5529
|
+
}, null, 8, ns))), 128))], 8, ts)
|
|
5527
5530
|
])
|
|
5528
5531
|
]),
|
|
5529
5532
|
_: 3
|
|
@@ -5532,7 +5535,7 @@ var So = { class: "units-title" }, Co = { "data-role": "units-summary" }, wo = {
|
|
|
5532
5535
|
}), [["__scopeId", "data-v-ada663af"]]);
|
|
5533
5536
|
//#endregion
|
|
5534
5537
|
//#region src/units/libcellml.ts
|
|
5535
|
-
function
|
|
5538
|
+
function is(e) {
|
|
5536
5539
|
let t = [];
|
|
5537
5540
|
for (let n = 0; n < e.issueCount(); n++) {
|
|
5538
5541
|
let r = e.issue(n), i = r.level(), a = r.referenceRule();
|
|
@@ -5540,14 +5543,14 @@ function rs(e) {
|
|
|
5540
5543
|
message: r.description(),
|
|
5541
5544
|
level: i.value,
|
|
5542
5545
|
rule: a?.value ?? -1
|
|
5543
|
-
}),
|
|
5546
|
+
}), as(i), a && as(a), r.delete();
|
|
5544
5547
|
}
|
|
5545
5548
|
return t;
|
|
5546
5549
|
}
|
|
5547
|
-
function
|
|
5550
|
+
function as(e) {
|
|
5548
5551
|
e.delete?.();
|
|
5549
5552
|
}
|
|
5550
|
-
var
|
|
5553
|
+
var os = class {
|
|
5551
5554
|
held = [];
|
|
5552
5555
|
track(e) {
|
|
5553
5556
|
return e && this.held.push(e), e;
|
|
@@ -5556,16 +5559,16 @@ var as = class {
|
|
|
5556
5559
|
for (let e of this.held.splice(0).reverse()) e.delete();
|
|
5557
5560
|
}
|
|
5558
5561
|
};
|
|
5559
|
-
function
|
|
5562
|
+
function ss(e) {
|
|
5560
5563
|
return Object.keys(e.Units.StandardUnit).filter((e) => /^[A-Z_]+$/.test(e)).map((e) => e.toLowerCase());
|
|
5561
5564
|
}
|
|
5562
5565
|
//#endregion
|
|
5563
5566
|
//#region src/units/messages.ts
|
|
5564
|
-
var
|
|
5565
|
-
function
|
|
5567
|
+
var cs = /'([^']+)' is (?:in )?'([^']+)'(?: \(i\.e\. '[^']*'\))?/g;
|
|
5568
|
+
function ls(e) {
|
|
5566
5569
|
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;
|
|
5567
5570
|
if (!r) return null;
|
|
5568
|
-
let i = [...r[2].matchAll(
|
|
5571
|
+
let i = [...r[2].matchAll(cs)].map(([, e, t]) => ({
|
|
5569
5572
|
text: e,
|
|
5570
5573
|
units: t
|
|
5571
5574
|
}));
|
|
@@ -5575,27 +5578,27 @@ function cs(e) {
|
|
|
5575
5578
|
operands: i
|
|
5576
5579
|
};
|
|
5577
5580
|
}
|
|
5578
|
-
function
|
|
5581
|
+
function us(e) {
|
|
5579
5582
|
let [t, n] = e.operands;
|
|
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}: ${
|
|
5583
|
+
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}: ${ds(t)}, ${ds(n)}` : `Units don't match in ${e.expression}`;
|
|
5581
5584
|
}
|
|
5582
|
-
var
|
|
5583
|
-
function
|
|
5585
|
+
var ds = (e) => e.units === "dimensionless" ? `${e.text} is dimensionless` : `${e.text} is in ${e.units}`, fs = /[A-Za-z_][A-Za-z0-9_]*/g, ps = /\bd(?:\^\d+)?([A-Za-z_][A-Za-z0-9_]*)\/d([A-Za-z_][A-Za-z0-9_]*)(?:\^\d+)?/g, ms = /(?<![A-Za-z_0-9.])\d+(?:\.\d*)?(?:e[+-]?\d+)?/g;
|
|
5586
|
+
function hs(e, t) {
|
|
5584
5587
|
let n = /* @__PURE__ */ new Set(), r = (e) => {
|
|
5585
5588
|
t.includes(e) && n.add(e);
|
|
5586
|
-
}, i = e.replace(
|
|
5587
|
-
for (let [e] of i.replace(
|
|
5589
|
+
}, i = e.replace(ps, (e, n, i) => t.includes(`d${n}`) || t.includes(`d${i}`) ? e : (r(n), r(i), " "));
|
|
5590
|
+
for (let [e] of i.replace(ms, " ").matchAll(fs)) r(e);
|
|
5588
5591
|
return [...n];
|
|
5589
5592
|
}
|
|
5590
|
-
function
|
|
5591
|
-
return [...e.matchAll(
|
|
5593
|
+
function gs(e) {
|
|
5594
|
+
return [...e.matchAll(ms)].map(([e]) => Number(e));
|
|
5592
5595
|
}
|
|
5593
5596
|
//#endregion
|
|
5594
5597
|
//#region src/units/check.ts
|
|
5595
|
-
function
|
|
5598
|
+
function _s(e, t) {
|
|
5596
5599
|
return e.variables.filter((e) => !t[e]);
|
|
5597
5600
|
}
|
|
5598
|
-
var
|
|
5601
|
+
var vs = 500, ys = class {
|
|
5599
5602
|
lc;
|
|
5600
5603
|
library;
|
|
5601
5604
|
cache = /* @__PURE__ */ new Map();
|
|
@@ -5612,7 +5615,7 @@ var _s = 500, vs = class {
|
|
|
5612
5615
|
})) : [];
|
|
5613
5616
|
}
|
|
5614
5617
|
prechecked(e, t) {
|
|
5615
|
-
let n =
|
|
5618
|
+
let n = _s(e, t).map((e) => ({
|
|
5616
5619
|
message: `${e} has no units`,
|
|
5617
5620
|
variables: [e]
|
|
5618
5621
|
})), r = [.../* @__PURE__ */ new Set([...e.variables.map((e) => t[e]), ...e.units])].filter((e) => e && !this.library.isKnown(e)).map((n) => ({
|
|
@@ -5626,10 +5629,10 @@ var _s = 500, vs = class {
|
|
|
5626
5629
|
let n = `${e.mathml}\n${e.variables.map((e) => `${e}:${t[e]}`).join(" ")}`, r = this.cache.get(n);
|
|
5627
5630
|
if (r) return r;
|
|
5628
5631
|
let i = this.analyse(e, t);
|
|
5629
|
-
return this.cache.size >=
|
|
5632
|
+
return this.cache.size >= vs && this.cache.delete(this.cache.keys().next().value), this.cache.set(n, i), i;
|
|
5630
5633
|
}
|
|
5631
5634
|
analyse(e, t) {
|
|
5632
|
-
let { lc: n } = this, r = new
|
|
5635
|
+
let { lc: n } = this, r = new os();
|
|
5633
5636
|
try {
|
|
5634
5637
|
let i = r.track(new n.Model());
|
|
5635
5638
|
i.setName("units_check"), this.library.addTo(i, [...e.variables.map((e) => t[e]), ...e.units], r);
|
|
@@ -5642,12 +5645,12 @@ var _s = 500, vs = class {
|
|
|
5642
5645
|
a.setMath(e.mathml), i.addComponent(a), i.linkUnits();
|
|
5643
5646
|
let o = r.track(new n.Validator());
|
|
5644
5647
|
o.validateModel(i);
|
|
5645
|
-
let s =
|
|
5646
|
-
if (s.length) return s.map((e) => ({ message: `libCellML: ${
|
|
5648
|
+
let s = is(o).filter((e) => e.level === 0);
|
|
5649
|
+
if (s.length) return s.map((e) => ({ message: `libCellML: ${xs(e.message)}` }));
|
|
5647
5650
|
let c = r.track(new n.Analyser());
|
|
5648
5651
|
c.analyseModel(i);
|
|
5649
|
-
let l =
|
|
5650
|
-
return [...new Set(l)].map((t) =>
|
|
5652
|
+
let l = is(c).filter((e) => e.rule === 112).map((e) => e.message);
|
|
5653
|
+
return [...new Set(l)].map((t) => bs(t, e.variables));
|
|
5651
5654
|
} finally {
|
|
5652
5655
|
r.dispose();
|
|
5653
5656
|
}
|
|
@@ -5656,36 +5659,36 @@ var _s = 500, vs = class {
|
|
|
5656
5659
|
this.cache.clear();
|
|
5657
5660
|
}
|
|
5658
5661
|
};
|
|
5659
|
-
function
|
|
5660
|
-
let n =
|
|
5661
|
-
if (!n) return { message:
|
|
5662
|
+
function bs(e, t) {
|
|
5663
|
+
let n = ls(e);
|
|
5664
|
+
if (!n) return { message: xs(e) };
|
|
5662
5665
|
let r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
|
|
5663
5666
|
for (let e of n.operands) {
|
|
5664
|
-
let n =
|
|
5667
|
+
let n = hs(e.text, t);
|
|
5665
5668
|
for (let e of n) r.add(e);
|
|
5666
|
-
if (n.length === 0) for (let t of
|
|
5669
|
+
if (n.length === 0) for (let t of gs(e.text)) i.add(t);
|
|
5667
5670
|
}
|
|
5668
5671
|
return {
|
|
5669
|
-
message:
|
|
5672
|
+
message: us(n),
|
|
5670
5673
|
...r.size ? { variables: [...r] } : {},
|
|
5671
5674
|
...i.size ? { numbers: [...i] } : {}
|
|
5672
5675
|
};
|
|
5673
5676
|
}
|
|
5674
|
-
function
|
|
5677
|
+
function xs(e) {
|
|
5675
5678
|
return e.replace(/ in component 'equation'/g, "").replace(/ in model 'units_check'/g, "");
|
|
5676
5679
|
}
|
|
5677
5680
|
//#endregion
|
|
5678
5681
|
//#region src/units/library.ts
|
|
5679
|
-
var
|
|
5682
|
+
var Ss = class e {
|
|
5680
5683
|
lc;
|
|
5681
5684
|
names;
|
|
5682
5685
|
sources;
|
|
5683
5686
|
problems;
|
|
5684
5687
|
standard;
|
|
5685
5688
|
defined = /* @__PURE__ */ new Map();
|
|
5686
|
-
handles = new
|
|
5689
|
+
handles = new os();
|
|
5687
5690
|
constructor(e, t) {
|
|
5688
|
-
this.lc = e, this.standard = new Set(
|
|
5691
|
+
this.lc = e, this.standard = new Set(ss(e));
|
|
5689
5692
|
let n = [], r = [], i = /* @__PURE__ */ new Map();
|
|
5690
5693
|
for (let e of t) {
|
|
5691
5694
|
let t = [];
|
|
@@ -5741,7 +5744,7 @@ var xs = class e {
|
|
|
5741
5744
|
let n = new this.lc.Parser(!1);
|
|
5742
5745
|
try {
|
|
5743
5746
|
let r = this.handles.track(n.parseModel(e.text));
|
|
5744
|
-
for (let r of
|
|
5747
|
+
for (let r of is(n)) r.level === 0 && t.push({
|
|
5745
5748
|
source: e.name,
|
|
5746
5749
|
message: r.message
|
|
5747
5750
|
});
|
|
@@ -5750,21 +5753,21 @@ var xs = class e {
|
|
|
5750
5753
|
n.delete();
|
|
5751
5754
|
}
|
|
5752
5755
|
}
|
|
5753
|
-
},
|
|
5754
|
-
function
|
|
5755
|
-
let n = e.libcellml === void 0 ? u(
|
|
5756
|
+
}, Cs = "$libcellml";
|
|
5757
|
+
function ws(e) {
|
|
5758
|
+
let n = e.libcellml === void 0 ? u(Cs, null) : e.libcellml, r = e.delay ?? 300, i = t(() => x(e.enabled) ?? !0), a = t(() => Ts(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 = () => {
|
|
5756
5759
|
clearTimeout(p), p = void 0, d.value = f && i.value ? f.check(x(e.lines), x(e.variableUnits)) : [];
|
|
5757
5760
|
}, ee = () => {
|
|
5758
5761
|
f?.dispose(), l.value?.dispose(), f = null, l.value = null;
|
|
5759
5762
|
}, te = t(() => {
|
|
5760
5763
|
let t = x(e.newUnits) ?? [];
|
|
5761
|
-
return t.length ?
|
|
5764
|
+
return t.length ? oo(t) : "";
|
|
5762
5765
|
});
|
|
5763
5766
|
return oe([a, () => [...x(e.sources), ...te.value ? [{
|
|
5764
|
-
name:
|
|
5767
|
+
name: Qa,
|
|
5765
5768
|
text: te.value
|
|
5766
5769
|
}] : []]], ([e, t]) => {
|
|
5767
|
-
ee(), e && (l.value =
|
|
5770
|
+
ee(), e && (l.value = Ss.load(e, t), f = new ys(e, l.value)), m();
|
|
5768
5771
|
}, { immediate: !0 }), oe(i, () => m()), oe([() => x(e.lines), () => x(e.variableUnits)], () => {
|
|
5769
5772
|
clearTimeout(p), p = setTimeout(m, r);
|
|
5770
5773
|
}), h(() => {
|
|
@@ -5778,16 +5781,16 @@ function Cs(e) {
|
|
|
5778
5781
|
files: t(() => l.value?.sources ?? []),
|
|
5779
5782
|
problems: t(() => l.value?.problems ?? []),
|
|
5780
5783
|
newUnitsFile: te,
|
|
5781
|
-
unitsNames: t(() => a.value && l.value ? [...
|
|
5784
|
+
unitsNames: t(() => a.value && l.value ? [...ss(a.value), ...l.value.names] : []),
|
|
5782
5785
|
missing: t(() => {
|
|
5783
5786
|
let t = x(e.variableUnits);
|
|
5784
|
-
return [...new Set(x(e.lines).flatMap((e) =>
|
|
5787
|
+
return [...new Set(x(e.lines).flatMap((e) => _s(e, t)))];
|
|
5785
5788
|
}),
|
|
5786
5789
|
check: m
|
|
5787
5790
|
};
|
|
5788
5791
|
}
|
|
5789
|
-
function
|
|
5792
|
+
function Ts(e) {
|
|
5790
5793
|
return e ? "Parser" in e ? b(e) : e.status === "ready" && e.library ? b(e.library) : null : null;
|
|
5791
5794
|
}
|
|
5792
5795
|
//#endregion
|
|
5793
|
-
export {
|
|
5796
|
+
export { Za as EquationWorkbench, Cs as LIBCELLML_KEY, rs as UnitsPanel, Ci as importContentMathML, ws as useUnitsChecker };
|